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

Capture the response headers of a bare 400 from the app proxy during a restart #13739

Merged opened this

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

Merged

When the parent's reach probe gets an unwelcome answer from a child, it now records the server, x-forge-app and via headers of that answer. That should be enough to tell the app, the proxy and an edge apart the next time a bare 400 shows up. What counts as unwelcome: any answer that fails the probe, or any 4xx.

Notes

shipped production is serving it deploy 59903fa

opened this

When the parent's reach probe gets an unwelcome answer from a child, it now records the server, x-forge-app and via headers of that answer. That should be enough to tell the app, the proxy and an edge apart the next time a bare 400 shows up.

  • What counts as unwelcome: any answer that fails the probe, or any 4xx. This covers the child's home and each of its apps. The 400 case matters because a 400 that carries the app's own x-forge-app still counts as ok. Without this it would leave no trace.
  • Where it lands: on the Proof in src/spawn/reach.ts as a new optional seen field, which the existing <data>/reach/<child>.json record keeps. A header the answer lacked is recorded as an empty string, so a bare 400 with no x-forge-app is visible. Welcome answers record nothing, and values are cut at 200 characters.
  • Test: a new case in test/spawn-reach.test.ts covers a bare 400, a 400 that carries the app's header, and a plain 200.
  • Checks: tsc --noEmit is clean and the 11 tests in test/spawn-reach.test.ts pass. I ran no other tests; the forge runs the full check on the push.

I did not surface seen anywhere on a page. It sits in the reach record for whoever reads it after the next bare 400. I also did not change the proxy's own relay path in src/apps/proxy.ts, since the outside probe is what sees an edge's headers.

Reading the record needs access to the forge's data directory: <data>/reach/<child>.json.

🤖 Generated with Claude Code

Closes #13738

commented

When the parent's reach probe gets an unwelcome answer from a child, it now records the server, x-forge-app and via headers of that answer. That should be enough to tell the app, the proxy and an edge apart the next time a bare 400 shows up.

  • What counts as unwelcome: any answer that fails the probe, or any 4xx. This covers the child's home and each of its apps. The 400 case matters because a 400 that carries the app's own x-forge-app still counts as ok. Without this it would leave no trace.
  • Where it lands: on the Proof in src/spawn/reach.ts as a new optional seen field, which the existing <data>/reach/<child>.json record keeps. A header the answer lacked is recorded as an empty string, so a bare 400 with no x-forge-app is visible. Welcome answers record nothing, and values are cut at 200 characters.
  • Test: a new case in test/spawn-reach.test.ts covers a bare 400, a 400 that carries the app's header, and a plain 200.
  • Checks: tsc --noEmit is clean and the 11 tests in test/spawn-reach.test.ts pass. I ran no other tests; the forge runs the full check on the push.

I did not surface seen anywhere on a page. It sits in the reach record for whoever reads it after the next bare 400. I also did not change the proxy's own relay path in src/apps/proxy.ts, since the outside probe is what sees an edge's headers.

Reading the record needs access to the forge's data directory: <data>/reach/<child>.json.

🤖 Generated with Claude Code

commented

A probe that gets an unwelcome answer now keeps that answer's server, x-forge-app and via headers, so the app, the proxy and an edge can be told apart. The failing spawn test is fixed and pushed. I ran test/spawn-reach-door.test.ts and test/spawn-reach.test.ts (15 tests pass), plus tsc --noEmit and gate.ts --fix. The forge's check on this push is still to come.

  • What changed: src/spawn/reach.ts adds an optional seen field to a proof. It is set on a failed answer or a 4xx, and absent otherwise. A header the answer lacked is recorded as an empty string, and values are cut to 200 characters.
  • The fix: test/spawn-reach-door.test.ts still expected the proof without seen. I updated it to expect seen: { server: "", via: "", "x-forge-app": "" } for the "answered 200, not by the app" case. The test was stale, not the code.
  • Not touched: test/client-size.test.ts ("no first page's client JavaScript or CSS passes its ceiling…") also failed in the check. The check log says it is red on main at 2952881 with the same tests, so it isn't caused by this pull. I didn't change it.
Approved

Approved. A failed probe or a 4xx now keeps server, x-forge-app and via on the Proof. Absent headers are recorded as empty strings, values are cut at 200 characters, and welcome answers record nothing. The test covers a bare 400, a 400 carrying the app header, and a 200. The stale door test was the test being wrong, and the pull says so. I read the diff only. I did not fetch the preview or the screenshots. The change adds no page, no write and no input, so security, both-doors and README do not apply.

Two things I would do next:

  1. Surface seen where someone can read it, for example on the child reach line, or in the proof sentence when status is 400. Today it sits in <data>/reach/<child>.json, which only someone with data access can read.
  2. Drop seen from the 4xx-with-our-header case once the bare-400 question is answered, so an app that legitimately 404s on / does not rewrite its reach record on every sweep.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs