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

The daily proof reads the forge's own origin through its own handler, so the forge's egress gate never stands between it and itself #15942

Merged opened this

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

Merged

The daily proof now reads the forge's own public origin through the forge's own request handler, inside the same process, so the egress gate no longer refuses it. Other hosts still go through fetch. forge.json and the egress list are unchanged.

Notes

shipped production is serving it deploy 3fede26

opened this

The daily proof now reads the forge's own public origin through the forge's own request handler, inside the same process, so the egress gate no longer refuses it. Other hosts still go through fetch. forge.json and the egress list are unchanged. Whether it passes on production is not shown yet: after the next production run, check that /api/v1/proof/daily shows pass > 0.

What changed

  • New module, src/release/own_fetch.ts. ownFetcher(app, origin, outside) sends requests for the forge's own origin to forgeHttp(app).handle(...) and wraps the answer in securityFloor. The security headers the probe checks are therefore the real ones.
    • Only GET and POST /mcp are answered. Any other method throws "is not a read" before it reaches the router.
    • cookie and authorization headers are removed, so the handler never gets the owner's session.
    • Requests for any other origin go to outside.
  • src/maintain/duties/daily_proof.ts. When no fetcher is injected (the production duty), each run builds an ownFetcher with the global fetch as outside and closes it when the run ends. An injected fetcher works exactly as before, so the existing stubbed tests are unchanged.
  • healthz evidence. The "healthz fast" line now ends with "measured in process, faster than a visitor's", because the network a visitor crosses is not in the timing.

Left out

  • Server-Timing. In the live server this header is added by the listener's bookkeeping (counted), not by forgeHttp, so in-process answers don't carry it. No v1 check reads it, so nothing depends on it.
  • Perf records. The probe's requests are not added to the forge's perf records. That keeps the proof's self-reads out of the forge's own traffic numbers.
  • No new MCP tool. None was needed, and the MCP size ceilings are unchanged.
  • Plan and estimate. The keep_plan and estimate tools were not available in this run, so the issue has no plan and no time was promised.

Tests

  • Gate test. A new test in test/daily-proof.test.ts makes the global fetch throw the gate's refusal and runs dailyProof() against a real app.
    • It gets nine lines, none with "refused by this forge" or "no answer", and nothing reaches the outside fetch.
    • The security-header lines PASS on the real headers.
    • It fails when the duty change is removed.
    • Other lines may still be UNKNOWN or FAIL, for reasons unrelated to the gate. On the fresh test forge, "stranger journey green on a release" fails because it has no release, and the "version agrees", "schedules ran in 24 h" and "keeper's last beat" lines are UNKNOWN.
  • Fetcher test. A second test checks the fetcher's limits: another origin goes to outside, a POST to /signup is refused, and a request carrying a bearer token and a session cookie is answered as anonymous.
  • What ran. bun scripts/gate.ts --fix, bun x tsc --noEmit and test/mcp-size.test.ts, plus the 125 files scripts/fast.ts named. That run had two failures; both were fixed by not calling fetch inside the new module, and the two affected suites (fetch-timeout, outbound-sweep) pass now. All of these ran in the sandbox.

Try it: bun test test/daily-proof.test.ts

🤖 Generated with Claude Code

Closes #15936

2 earlier comments · 1 event
commented

The daily proof now reads the forge's own public origin through the forge's own request handler, inside the same process, so the egress gate no longer refuses it. Other hosts still go through fetch. forge.json and the egress list are unchanged. Whether it passes on production is not shown yet: after the next production run, check that /api/v1/proof/daily shows pass > 0.

What changed

  • New module, src/release/own_fetch.ts. ownFetcher(app, origin, outside) sends requests for the forge's own origin to forgeHttp(app).handle(...) and wraps the answer in securityFloor. The security headers the probe checks are therefore the real ones.
    • Only GET and POST /mcp are answered. Any other method throws "is not a read" before it reaches the router.
    • cookie and authorization headers are removed, so the handler never gets the owner's session.
    • Requests for any other origin go to outside.
  • src/maintain/duties/daily_proof.ts. When no fetcher is injected (the production duty), each run builds an ownFetcher with the global fetch as outside and closes it when the run ends. An injected fetcher works exactly as before, so the existing stubbed tests are unchanged.
  • healthz evidence. The "healthz fast" line now ends with "measured in process, faster than a visitor's", because the network a visitor crosses is not in the timing.

Left out

  • Server-Timing. In the live server this header is added by the listener's bookkeeping (counted), not by forgeHttp, so in-process answers don't carry it. No v1 check reads it, so nothing depends on it.
  • Perf records. The probe's requests are not added to the forge's perf records. That keeps the proof's self-reads out of the forge's own traffic numbers.
  • No new MCP tool. None was needed, and the MCP size ceilings are unchanged.
  • Plan and estimate. The keep_plan and estimate tools were not available in this run, so the issue has no plan and no time was promised.

Tests

  • Gate test. A new test in test/daily-proof.test.ts makes the global fetch throw the gate's refusal and runs dailyProof() against a real app.
    • It gets nine lines, none with "refused by this forge" or "no answer", and nothing reaches the outside fetch.
    • The security-header lines PASS on the real headers.
    • It fails when the duty change is removed.
    • Other lines may still be UNKNOWN or FAIL, for reasons unrelated to the gate. On the fresh test forge, "stranger journey green on a release" fails because it has no release, and the "version agrees", "schedules ran in 24 h" and "keeper's last beat" lines are UNKNOWN.
  • Fetcher test. A second test checks the fetcher's limits: another origin goes to outside, a POST to /signup is refused, and a request carrying a bearer token and a session cookie is answered as anonymous.
  • What ran. bun scripts/gate.ts --fix, bun x tsc --noEmit and test/mcp-size.test.ts, plus the 125 files scripts/fast.ts named. That run had two failures; both were fixed by not calling fetch inside the new module, and the two affected suites (fetch-timeout, outbound-sweep) pass now. All of these ran in the sandbox.

Try it: bun test test/daily-proof.test.ts

🤖 Generated with Claude Code

commented

The daily proof can now pass on production. When it reads the forge's own public origin, the forge's own router answers that read in process instead of sending it out through the egress gate. The gate blocks the forge's own host like any undeclared one, so the proof failed on every production run.

What changed

  • src/release/own_fetch.ts (new): when the duty is given no fetcher, it answers reads of its own origin through forgeHttp and securityFloor.
    • It drops any cookie or authorization header, so the proof sees what a stranger sees, never the owner's session.
    • It only answers GET and the probe's POST /mcp, and refuses anything else.
    • Requests to any other origin still go through fetch.
  • src/maintain/duties/daily_proof.ts: uses that fetcher, and its healthz evidence now says the timing was measured in process. That makes it faster than a real visitor's.

Gate rule "pipeline first" own_fetch.ts is a new module, so the gate counts it as a feature. A follow-up empty commit carries a Direction: line saying it fixes an existing duty that fails on every production run (#15936), ahead of #6534.

The gate still prints a note that ownFetcher looks like a near-copy of something called Fetcher. That match is its own inner function, not a second implementation; the note doesn't fail the check, so I left it.

Checks: bun scripts/gate.ts passes (only that note remains), bun x tsc --noEmit is clean, and bun test test/daily-proof.test.ts passes 13 of 13.

Try it: run the daily-proof duty against production and check that the healthz line says "measured in process" and the duty no longer stops at the egress gate.

🤖 Generated with Claude Code

Approved

Approved. The duty reads its own origin through forgeHttp in process, drops cookie and authorization, answers only GET and POST /mcp, and sends other hosts to fetch. forge.json is untouched and the gate test fails without the change. Two things I would do next: (1) the issue says Server-Timing is real in-process, but the answers carry none because the listener adds it, not forgeHttp. Either add it in own_fetch.ts or reword the box. (2) dailyProof run() has a three-way branch with an inline healthz evidence rewrite. Move that into own_fetch.ts, or a small function, so the duty stays flat. A person checks box 4 after the next production run.

commented

Left #15936 open: 2 unticked items remain (When the duty's base is the forge's own origin, its fetcher answers GET (and the two token-free MCP POSTs the probe makes) by calling the forge's own request handler in process, with the same headers a visitor gets, so the security headers and Server-Timing it checks are the real ones; every other host still uses fetch.; After the next production run, /api/v1/proof/daily shows pass > 0 (say so in the pull; a person checks it).).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs