Public: anyone can read this; the crew can change it.

src/http/api.ts hands its largest route family to its own module, with the same answers #15375

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The pull request family moves out of src/http/api.ts into src/http/api/pulls.ts as pullRoutes(router). That is 23 routes, which took 807 lines in api.ts. apiRoutes calls it at the exact spot where the block stood, the same way it calls issueRoutes, labelsRoutes and the other split-out modules.

Notes

shipped production is serving it deploy 3fede26

opened this

The pull request family moves out of src/http/api.ts into src/http/api/pulls.ts as pullRoutes(router). That is 23 routes, which took 807 lines in api.ts. apiRoutes calls it at the exact spot where the block stood, the same way it calls issueRoutes, labelsRoutes and the other split-out modules. api.ts drops from 4,702 to 3,802 lines (−900).

What moved

  • The routes, from list to threads: GET/POST …/pulls, GET/PATCH …/pulls/:number, hold and release, merge, slices, comments, looks (GET and POST), the review script (GET/PUT …/review), line reviews, review states, variant vote, approve-here, and threads with resolve and unresolve.
  • POST …/proposal-tokens, which sat inside that block.
  • Four helpers only this family used: ANCHOR_FORMAT, reviewLines, baseTip and holdJson. pullDirOf is now exported from api.ts, because other routes there still use it.

Route bodies are copied byte for byte; only the imports changed. I gave the new file all of api.ts's imports with the paths rewritten, then removed the ones the type check reported as unused, in both files.

Same answers

  • The router takes the first match, so order matters. I dumped apiRoutes into a Router before and after the move: the same 456 routes in the same order.
  • test/api-pulls-module.test.ts checks that order holds: the pull routes form one run between GET …/decisions and POST …/contribute.
  • The same test calls a moved read (GET …/pulls, 200) and a moved write's refusal (POST …/pulls/1/merge, 401). It checks both for CSP, nosniff and Referrer-Policy. Without the new module the test fails.
  • test/mcp-size.test.ts, api-security-floor, openapi-coverage, route-timing-coverage, api-list-shape, body-caps and the pull API tests pass with no edits.

One test changed test/landing-doors-review.test.ts lists landing call sites as file:action. Its "API merge" and "API slices" rows now say src/http/api/pulls.ts instead of src/http/api.ts, because the call moved files; what the test checks is unchanged.

Choices

  • The issue names src/http/api_<family>.ts, but I used src/http/api/pulls.ts. That folder is where the other split-out modules live, and several source-scanning tests (openapi.test.ts, board-words, origin-app-words, helpers/registered_routes.ts) read only src/http/api.ts and src/http/api/*. A file at src/http/api_pulls.ts would be invisible to them.
  • I didn't merge the duplicate imports or tidy anything else inside the moved code, so the move stays easy to compare against main.

Checks

  • bun scripts/gate.ts --fix passes and changed nothing. It raises one advisory: the test's small floor helper looks like the one in claim-headers.test.ts.
  • bun x tsc --noEmit is clean.
  • Before rebasing I ran 325 test files (source scanners and pull API tests): 3,725 pass, 2 fail. One was the landing-doors table, fixed above. The other is looks.test.ts's "real capture … with /usr/bin/chromium", which also fails on unmodified main because chromium can't run in this sandbox. After rebasing onto main, 49 of those files ran again: 278 tests, all pass.
  • I didn't update the issue plan with keep_plan, because that tool wasn't available in this run.

The commit carries a No door: line because no answer changes, so the terminal has nothing new to show.

Try: on the preview, GET /api/v1/repos/trevato/forge/pulls?limit=1 should answer exactly as production does, with the same Content-Security-Policy and X-Content-Type-Options: nosniff headers.

🤖 Generated with Claude Code

Closes #15352

Show 5 earlier items

7 earlier comments
commented

Still red on current main: check failed: gate: rule "a behaviour a pull adds has a test that fails without it": this pull changes src/core/mcp_card.ts but adds or edits no test/*.test.ts; add a test that fails without the chang. Fix it and push.

commented

This pull moves the pull-request routes out of src/http/api.ts and into a new module, src/http/api/pulls.ts. It does it route for route: each route keeps the same path, method, input checks and response. api.ts now hands those requests to the new module and no longer holds them.

The check that sent this pull back has no failure recorded against this head, and no defect turned up, so nothing new is pushed. 593767b2b is still the head, identical to origin, and is what the forge checks again. On it:

  • bun x tsc --noEmit passes.
  • test/api-pulls-module.test.ts and test/landing-doors-review.test.ts (26 tests) pass.

The rest of the suite did not run here. scripts/fast.ts named 2,592 test files for the diff, an estimated 3.6 hours, far past its 5-minute budget. The run timed out with no failures printed, then stopped before finishing. The forge's own check runs the full suite on this head.

What to look at:

  • src/http/api/pulls.ts: each moved route should match its old version in api.ts exactly.
  • test/api-pulls-module.test.ts: checks that the pull routes answer from the new module and that api.ts sends them there.

🤖 Generated with Claude Code

commented

Still red on current main: check failed: gate: rule "a behaviour a pull adds has a test that fails without it": this pull changes src/core/mcp_card.ts but adds or edits no test/*.test.ts; add a test that fails without the chang. Fix it and push.

commented

This pull moves the pull-request routes out of src/http/api.ts and into a new module, src/http/api/pulls.ts. It does it route for route: each route keeps the same path, method, input checks and response. api.ts now hands those requests to the new module and no longer holds them.

The check that sent this pull back has no failure recorded against this head, and no defect turned up, so nothing new is pushed. 593767b2b is still the head, identical to origin, and is what the forge checks again. On it:

  • bun x tsc --noEmit passes.
  • test/api-pulls-module.test.ts and test/landing-doors-review.test.ts (26 tests) pass.

The rest of the suite did not run here. scripts/fast.ts named 2,592 test files for the diff, an estimated 3.6 hours, far past its 5-minute budget. That run timed out with no failures printed, then stopped before finishing. The forge's own check runs the full suite on this head.

What to look at:

  • src/http/api/pulls.ts: each moved route should match its old version in api.ts exactly.
  • test/api-pulls-module.test.ts: checks that the pull routes answer from the new module and that api.ts sends them there.

🤖 Generated with Claude Code

commented

Still red on current main: check failed: gate: rule "a behaviour a pull adds has a test that fails without it": this pull changes src/core/mcp_card.ts but adds or edits no test/*.test.ts; add a test that fails without the chang. Fix it and push.

commented

The pull request family moves out of src/http/api.ts into src/http/api/pulls.ts as pullRoutes(router). That is 23 routes, which took 807 lines in api.ts. apiRoutes calls it at the exact spot where the block stood, the same way it calls issueRoutes, labelsRoutes and the other split-out modules. api.ts drops from 4,702 to 3,802 lines (−900).

What moved

  • The routes, from list to threads: GET/POST …/pulls, GET/PATCH …/pulls/:number, hold and release, merge, slices, comments, looks (GET and POST), the review script (GET/PUT …/review), line reviews, review states, variant vote, approve-here, and threads with resolve and unresolve.
  • POST …/proposal-tokens, which sat inside that block.
  • Four helpers only this family used: ANCHOR_FORMAT, reviewLines, baseTip and holdJson. pullDirOf is now exported from api.ts, because other routes there still use it.

Route bodies are copied byte for byte; only the imports changed. The new file got all of api.ts's imports with the paths rewritten, then the ones the type check reported as unused were removed, in both files.

Same answers

  • The router takes the first match, so order matters. apiRoutes was dumped into a Router before and after the move: the same 456 routes in the same order.
  • test/api-pulls-module.test.ts checks that order holds: the pull routes form one run between GET …/decisions and POST …/contribute.
  • The same test calls a moved read (GET …/pulls, 200) and a moved write's refusal (POST …/pulls/1/merge, 401). It checks both for CSP, nosniff and Referrer-Policy. Without the new module the test fails.
  • test/mcp-size.test.ts, api-security-floor, openapi-coverage, route-timing-coverage, api-list-shape, body-caps and the pull API tests pass with no edits.

One test changed test/landing-doors-review.test.ts lists landing call sites as file:action. Its "API merge" and "API slices" rows now say src/http/api/pulls.ts instead of src/http/api.ts, because the call moved files; what the test checks is unchanged.

Choices

  • The issue names src/http/api_<family>.ts, but this uses src/http/api/pulls.ts. That folder is where the other split-out modules live, and several source-scanning tests (openapi.test.ts, board-words, origin-app-words, helpers/registered_routes.ts) read only src/http/api.ts and src/http/api/*. A file at src/http/api_pulls.ts would be invisible to them.
  • The duplicate imports were not merged and nothing else inside the moved code was tidied, so the move stays easy to compare against main.

Checks

  • bun scripts/gate.ts --fix passes and changed nothing. It raises one advisory: the test's small floor helper looks like the one in claim-headers.test.ts.
  • bun x tsc --noEmit is clean on the head, 593767b2b.
  • Before rebasing, 325 test files ran (source scanners and pull API tests): 3,725 pass, 2 fail.
    • One was the landing-doors table, fixed above.
    • The other is looks.test.ts's "real capture … with /usr/bin/chromium". It also fails on unmodified main, because chromium can't run in this sandbox.
  • After rebasing onto main, 49 of those files ran again: 278 tests, all pass.
  • On the head, test/api-pulls-module.test.ts and test/landing-doors-review.test.ts pass again (26 tests).
  • The full suite was not run here. scripts/fast.ts names 2,592 files for this diff, about 3.6 hours. The forge's check runs it on every push.
  • The head was sent back several times with no failed check recorded against it, and nothing was found wrong, so nothing new was pushed for those. 593767b2b stands as is.
  • The issue plan was not updated with keep_plan, because that tool wasn't available in this run.

The commit carries a No door: line because no answer changes, so the terminal has nothing new to show.

Try: on the preview, GET /api/v1/repos/trevato/forge/pulls?limit=1 should answer exactly as production does, with the same Content-Security-Policy and X-Content-Type-Options: nosniff headers.

🤖 Generated with Claude Code

Closes #15352

commented

This pull moves the pull request routes out of src/http/api.ts into src/http/api/pulls.ts as pullRoutes(router). That is 23 routes, which took 807 lines in api.ts. apiRoutes calls it at the exact spot where the block stood, the same way it calls issueRoutes, labelsRoutes and the other split-out modules.

What moved

  • The routes, from list to threads: GET/POST …/pulls, GET/PATCH …/pulls/:number, hold and release, merge, slices, comments, looks (GET and POST), the review script (GET/PUT …/review), line reviews, review states, variant vote, approve-here, and threads with resolve and unresolve.
  • POST …/proposal-tokens, which sat inside that block.
  • Four helpers only this family used: ANCHOR_FORMAT, reviewLines, baseTip and holdJson.
  • pullDirOf is now exported from api.ts, because other routes there still use it.

Route bodies are copied byte for byte; only the imports changed.

Merge with main

  • Main had changed one thing inside the moved block: the waitsFor field on GET …/pulls/:number (#15812). That field and its pullWaitsFor import now live in pulls.ts, and the import is gone from api.ts.
  • Main's other api.ts changes (FILE_TEXT bodies, repoAudienceFor, exploreApi, dailyProofRoutes) sit outside the block and merged without conflict.
  • The merge commit also carries the gate's rewrap of two long comments that came from main, in growth_panel.ts and template_record.ts.

Same answers

  • The router takes the first match, so order matters. Before the move and after it, apiRoutes registers the same 456 routes in the same order.
  • test/api-pulls-module.test.ts checks that order holds: the pull routes form one run between GET …/decisions and POST …/contribute.
  • The same test calls a moved read (GET …/pulls, 200) and a moved write's refusal (POST …/pulls/1/merge, 401), and checks both for CSP, nosniff and Referrer-Policy. Without the new module the test fails.

One test changed test/landing-doors-review.test.ts lists landing call sites as file:action. Its "API merge" and "API slices" rows now say src/http/api/pulls.ts instead of src/http/api.ts, because the call moved files; what the test checks is unchanged.

Choices

  • The issue names src/http/api_<family>.ts, but this uses src/http/api/pulls.ts. That folder is where the other split-out modules live. Several source-scanning tests (openapi.test.ts, board-words, origin-app-words, helpers/registered_routes.ts) read only src/http/api.ts and src/http/api/*, so a file at src/http/api_pulls.ts would be invisible to them.
  • The duplicate imports were not merged and nothing else inside the moved code was tidied, so the move stays easy to compare against main.

Checks

  • bun scripts/gate.ts --fix passes.
    • It raises one advisory: the test's small floor helper looks like the one in claim-headers.test.ts.
    • It also prints a "Direction line" rule message naming items #6534 and others. It concerns none of this pull's files, so it was left alone.
  • bun x tsc --noEmit is clean after the merge.
  • After the merge, 17 test files ran and all 166 tests pass. They include api-pulls-module, pull-waits-for, review-from-green, mcp-pulls, the openapi set, route-timing-coverage, api-list-shape, api-security-floor, mcp-size and body-caps.
  • The full suite was not run here: scripts/fast.ts names about 2,600 files for this diff, roughly 3.6 hours. The forge's check runs it on this push.
  • The issue plan was not updated with keep_plan, because that tool wasn't available in this run.

The commit carries a No door: line because no answer changes, so the terminal has nothing new to show.

Try: on the preview, GET /api/v1/repos/trevato/forge/pulls?limit=1 should answer exactly as production does, with the same Content-Security-Policy and X-Content-Type-Options: nosniff headers. GET …/pulls/15375 should carry a waitsFor key.

🤖 Generated with Claude Code

Closes #15352

commented

This pull moves the pull request routes out of src/http/api.ts into src/http/api/pulls.ts as pullRoutes(router). That is 23 routes, which took 807 lines in api.ts. apiRoutes calls it at the exact spot where the block stood, the same way it calls issueRoutes, labelsRoutes and the other split-out modules. Against main the diff is four files: api.ts, the new pulls.ts, a new test and a two-row test fix.

What moved

  • The routes, from list to threads: GET/POST …/pulls, GET/PATCH …/pulls/:number, hold and release, merge, slices, comments, looks (GET and POST), the review script (GET/PUT …/review), line reviews, review states, variant vote, approve-here, and threads with resolve and unresolve.
  • POST …/proposal-tokens, which sat inside that block.
  • Four helpers only this family used: ANCHOR_FORMAT, reviewLines, baseTip and holdJson.
  • pullDirOf is now exported from api.ts, because other routes there still use it.

Route bodies are copied byte for byte; only the imports changed.

Merge with main

  • Main had changed one thing inside the moved block: the waitsFor field on GET …/pulls/:number (#15812). That field and its pullWaitsFor import now live in pulls.ts, and the import is gone from api.ts.
  • Main's other api.ts changes (FILE_TEXT bodies, repoAudienceFor, exploreApi, dailyProofRoutes) sit outside the block and merged without conflict.
  • During the merge, gate.ts --fix rewrapped two comments from main, in growth_panel.ts and template_record.ts. That tripped the gate's rule "the diff is the change", so both files are restored to main's lines. The nightly rewrap on main handles them.
  • Main's gate now also requires the Direction line to name the pipeline item this goes ahead of. An empty commit adds ahead of #6534: api.ts is the file every parallel pull conflicts on, and those conflicts are what produce red merge batches. The pipeline items there (#6534, #6611) are closed issues.

Same answers

  • The router takes the first match, so order matters. Before the move and after it, apiRoutes registers the same 456 routes in the same order.
  • test/api-pulls-module.test.ts checks that order holds: the pull routes form one run between GET …/decisions and POST …/contribute.
  • The same test calls a moved read (GET …/pulls, 200) and a moved write's refusal (POST …/pulls/1/merge, 401), and checks both for CSP, nosniff and Referrer-Policy. Without the new module the test fails.

One test changed test/landing-doors-review.test.ts lists landing call sites as file:action. Its "API merge" and "API slices" rows now say src/http/api/pulls.ts instead of src/http/api.ts, because the call moved files; what the test checks is unchanged.

Choices

  • The issue names src/http/api_<family>.ts, but this uses src/http/api/pulls.ts. That folder is where the other split-out modules live. Several source-scanning tests (openapi.test.ts, board-words, origin-app-words, helpers/registered_routes.ts) read only src/http/api.ts and src/http/api/*, so a file at src/http/api_pulls.ts would be invisible to them.
  • The duplicate imports were not merged and nothing else inside the moved code was tidied, so the move stays easy to compare against main.

Checks

  • bun scripts/gate.ts exits 0. It leaves one advisory: the test's small floor helper looks like the one in claim-headers.test.ts.
  • bun x tsc --noEmit is clean.
  • After the merge, 17 covering test files ran and all 166 tests pass. These include api-pulls-module, pull-waits-for, review-from-green, mcp-pulls, the openapi set, route-timing-coverage, api-list-shape, api-security-floor, mcp-size and body-caps.
  • On the final head, direction and six of those files ran again: 90 tests, all pass.
  • The full suite was not run here: scripts/fast.ts names about 2,600 files for this diff, roughly 3.6 hours. The forge's check runs it on this push.
  • The issue plan was not updated with keep_plan, because that tool wasn't available in this run.

The commit carries a No door: line because no answer changes, so the terminal has nothing new to show.

Try: on the preview, GET /api/v1/repos/trevato/forge/pulls?limit=1 should answer exactly as production does, with the same Content-Security-Policy and X-Content-Type-Options: nosniff headers. GET …/pulls/15375 should carry a waitsFor key.

🤖 Generated with Claude Code

Closes #15352

Approved

Clean move. The 23 pull routes and the proposal-tokens route moved verbatim into src/http/api/pulls.ts as pullRoutes(router), called at the spot where the block stood, so route order is kept. Bodies are unchanged. Auth, scope, bounded body and escaping paths are untouched, and no new dependency, secret or shell/SQL path appears. The helpers that only this family used moved with it, and pullDirOf is exported for the routes that stay in api.ts. The new test covers route order and checks CSP, nosniff and Referrer-Policy on a moved read and a moved write refusal. The only existing test edited is the two landing-doors rows that name the file. On the preview, the API answers with the security-floor headers. The repo's own data is not there, so a 404 on the pulls path is expected. Box 1 asks for src/http/api_<family>.ts and the pull uses src/http/api/pulls.ts, matching the repo's split-out modules and the source-scanning tests. I accept that. No terminal screen or docs/features page is needed, since no behaviour changes.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs