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

src/http/server.ts hands the app-hook handling to its own module, with the same answers #15627

Merged opened this

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

Merged

hookCallerAllowed and handleHook now live in a new module, src/http/hook.ts, and src/http/server.ts imports them from there. The bodies are moved, not rewritten. server.ts drops from 3,695 to 3,416 lines (279 shorter).

Notes

shipped production is serving it deploy 3fede26

opened this

hookCallerAllowed and handleHook now live in a new module, src/http/hook.ts, and src/http/server.ts imports them from there. The bodies are moved, not rewritten. server.ts drops from 3,695 to 3,416 lines (279 shorter). It also loses about 25 imports that only the moved code used; those now sit at the top of hook.ts. The only edits in the moved code are the two added export keywords.

  • Floor unchanged: the internal listener in server.ts (serveInternal and answerInternal) still checks the boot secret first. It still wraps every answer in securityFloor(await answerInternal(...)), which is the exact text test/security-floor-doors.test.ts reads.
  • No circular import: hook.ts takes app and the request and imports nothing from server.ts.
  • Deliberately left alone: serveInternal, answerInternal and the stale-socket sweep stay in server.ts with the rest of the listener wiring. The post-receive code builds the push origin the same way twice; that is left as it was, because changing it would be a rewrite, not a move.
  • Gate note: bun scripts/gate.ts says hookCallerAllowed looks 0.75 similar to isProber in src/release/prober.ts. It did not block the push; it is the same function as before, just moved.

Checks run: bun x tsc --noEmit is clean and bun scripts/gate.ts --fix changed nothing. scripts/fast.ts named 2,639 test files, too many to run here, so I picked the push and hook tests by hand. That covers the floor and body-cap tests (security-floor-doors, body-caps) and 69 suites on hook calls, protected defaults, proposal and outside-agent namespaces, secret-holding pushes, mirrors and the crew sandbox. 877 tests pass, 0 fail and 18 are skipped; the skips are the unix-socket cases, which the forge's check runs. No test file was edited.

The commits carry the gate's lines: No door, No look, No test, Try, and a Direction line in an empty commit. That line names #6534 only because the gate asks for a pipeline item; none of the listed items relates to this move.

To try it: open src/http/hook.ts and compare it with the lines removed from src/http/server.ts (git diff --stat main: 285 lines in, 285 out). On the preview, git push a branch: it should land and print what it printed before, and a push to a protected default branch by someone who isn't an admin should still be refused.

🤖 Generated with Claude Code

Closes #15622

2 earlier comments
commented

hookCallerAllowed and handleHook now live in a new module, src/http/hook.ts, and src/http/server.ts imports them from there. The bodies are moved, not rewritten. server.ts drops from 3,695 to 3,416 lines (279 shorter). It also loses about 25 imports that only the moved code used; those now sit at the top of hook.ts. The only edits in the moved code are the two added export keywords.

  • Floor unchanged: the internal listener in server.ts (serveInternal and answerInternal) still checks the boot secret first. It still wraps every answer in securityFloor(await answerInternal(...)), which is the exact text test/security-floor-doors.test.ts reads.
  • No circular import: hook.ts takes app and the request and imports nothing from server.ts.
  • Deliberately left alone: serveInternal, answerInternal and the stale-socket sweep stay in server.ts with the rest of the listener wiring. The post-receive code builds the push origin the same way twice; that is left as it was, because changing it would be a rewrite, not a move.
  • Gate note: bun scripts/gate.ts says hookCallerAllowed looks 0.75 similar to isProber in src/release/prober.ts. It did not block the push; it is the same function as before, just moved.

Checks run: bun x tsc --noEmit is clean and bun scripts/gate.ts --fix changed nothing. scripts/fast.ts named 2,639 test files, too many to run here, so I picked the push and hook tests by hand. That covers the floor and body-cap tests (security-floor-doors, body-caps) and 69 suites on hook calls, protected defaults, proposal and outside-agent namespaces, secret-holding pushes, mirrors and the crew sandbox. 877 tests pass, 0 fail and 18 are skipped; the skips are the unix-socket cases, which the forge's check runs. No test file was edited.

The commits carry the gate's lines: No door, No look, No test, Try, and a Direction line in an empty commit. That line names #6534 only because the gate asks for a pipeline item; none of the listed items relates to this move.

To try it: open src/http/hook.ts and compare it with the lines removed from src/http/server.ts (git diff --stat main: 285 lines in, 285 out). On the preview, git push a branch: it should land and print what it printed before, and a push to a protected default branch by someone who isn't an admin should still be refused.

🤖 Generated with Claude Code

commented

This moves the app-hook handler out of src/http/server.ts, whole and unchanged, into a module of its own, src/http/hook.ts, so server.ts gets smaller and easier to review ahead of #6534. Nothing it does changes: pre-receive still refuses a push or lets it land, and post-receive still records the landing.

The follow-up commit fixes the doc that the first check run failed on. docs/CACHING.md still named the writer of the push event as http/server#handleHook, in its KPI table and its Panel table. Both rows now say http/hook#handleHook. test/caching-doc.test.ts checks that each write the doc names exists and appends its event, and it passes again.

The other test that failed in that run, "the blob page's switch > a kind with no renderer keeps its view…" in test/media.test.ts, has nothing to do with this move. It only reads blob pages, which this pull doesn't change. I didn't find the cause: it passed in all four local runs, and the check log didn't show its assertion. Nothing was changed for it. If it fails on this push too, it needs a look of its own.

The gate (bun scripts/gate.ts --fix) and bun x tsc --noEmit both pass. The gate also printed an advisory note that hookCallerAllowed in the moved code looks a lot like isProber in src/release/prober.ts (0.75 similar). This pull leaves both as they are, since it only moves code.

To try it: bun test test/caching-doc.test.ts test/media.test.ts, then compare git show 11b34ed65 --stat with the diff, which should show the same function lines leaving server.ts and arriving in hook.ts.

🤖 Generated with Claude Code

commented

This moves the app-hook handler out of src/http/server.ts, whole and unchanged, into a module of its own, src/http/hook.ts, so server.ts gets smaller and easier to review ahead of #6534. Nothing it does changes: pre-receive still refuses a push or lets it land, and post-receive still records the landing. server.ts now imports handleHook and hookCallerAllowed from ./hook.ts. The rest of its diff is the moved code and the imports only that code used.

  • Doc fix: docs/CACHING.md named the writer of the push event as http/server#handleHook in its KPI and Panel tables. Both rows now say http/hook#handleHook, and test/caching-doc.test.ts passes.
  • Merge of main: the branch now includes origin/main up to 279c4885a.
  • Last check's failures: two files failed, and both pass locally, before and after the merge. I found no cause, so nothing was changed for them:
    • test/gate-bypass.test.ts: all eight of its tests failed together (shard 11), which suggests its shared setup failed in that shard. It passed in four local runs.
    • test/following-cache.test.ts ("an answer git failed to give is not remembered", shard 51) doesn't use the hook or the server at all. It also passed in four local runs.

    The check before that failed on an unrelated blob-page test in test/media.test.ts that also passes here. If any of these fail again, they need a look of their own.

  • Not run here: this sandbox can't bind a unix socket, so the socket-mode suites (stale-socket recovery, the egress proxy, cell limits) were skipped locally. The forge's check runs them.

The gate and bun x tsc --noEmit pass on the merged tree. The gate also notes that hookCallerAllowed looks a lot like isProber in src/release/prober.ts. This pull only moves code, so it leaves both as they are.

To try it: bun test test/caching-doc.test.ts test/gate-bypass.test.ts test/following-cache.test.ts test/media.test.ts, then git show 11b34ed65 to confirm that the lines leaving server.ts are the lines arriving in hook.ts.

🤖 Generated with Claude Code

Approved

Clean move. hook.ts holds hookCallerAllowed and handleHook byte-for-byte (only export added); server.ts imports it, drops the imports only the moved code used, and keeps serveInternal and securityFloor wrapping every hook answer. No new dependency and no new input or output surface. The CACHING.md rows are updated to match the new path. The preview answers / with 200. The first response was slow (about 10 s), most likely a cold start; this change adds no request-path work.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs