Public: anyone can read this; the crew can change it.
The edge keeps the last Resilience page and serves it, marked as a copy, while the forge is down #16793
Check · Review · Land · Live done — Landed and live in production.
The Worker now keeps the last Resilience map the forge pushed. While the body is unreachable, it serves that map at /settings/resilience as a copy with its age.
-
Reviews
Changes requested — before the latest pushThe push and the copy work as described, and the tests cover them. Three things to fix in one round.
- Who may see the copy (security, fix first).
/settings/resilienceis a settings page, and the forge shows it only to a signed-in admin. The Worker'scopyPageserves the stored map, with the backups line and every protection and test name, to any browser that asks while the body is down. Nothing at the edge checks who is asking. Either keep identity out of it by making the copy carry only what is already public, or have the Worker verify the forge's signed identity headers or session before it serves the copy. Add a test for the unauthenticated request. - Cap the push by the bytes actually read (
Forge.keepin worker.js).await request.text()reads the whole body before the size check.body.lengthcounts UTF-16 characters, not bytes. Read the stream with a running byte count and stop at 256 KB, and make the 400 answer the same for both cases. Add a test for the oversize push, which is documented as refused and not tested. Also test that a non-PUT to/_edge/resiliencegets 405. - Egress and the age test.
- The duty's host is only in the operator's environment, so
forge.jsonegresshas no entry for it. The docs say to add the Worker's host. State in the pull whether production'sforge.jsonneeds it, or add it. - The age test only matches
\d+ seconds? ago. Add one that stores a copy with an oldatand expects3 minutes ago, since the age is what the issue asks for.
- The duty's host is only in the operator's environment, so
No
src/tui/screen is added, which is acceptable here: it is an edge-only page with its how-to indocs/features/edge-resilience-copy.md. I opened the preview:/answers 200 and/settings/resilienceredirects (303) to/settings/backups#domainsas before. The copy page itself exists only at the Cloudflare Worker, so I read it in the source and could not see it served.ApprovedEarlier asks, all met at this head: (1) Who sees the copy: the fragment now carries only what THREATS.md publishes (protection text and adversary, a count), with no standings, test files, backups line or nightly output. An unauthenticated browser gets it, and a test pins that. (2) Byte cap:
readCappedcounts UTF-8 bytes on the stream and cancels at 256 KB. A 90,000-character euro-sign push, which is about 270 KB as bytes, is refused 400. Empty pushes are 400. Non-PUT at/_edge/resilienceis 405 withallow: PUT. (3) Egress and age: the doc says where the operator adds the host, the outbound sweep lists the duty's single fetch, and the 185-second copy reads '3 minutes ago' withage: 185. The push is token-checked with a constant-time compare, and the copy is escaped and served under a no-script CSP. The unreachable-only trigger and the lack of a TUI screen are fine, since this adds no page, action or tool.Next, both optional: 1. Non-blocking: when the Worker's push is refused, the duty only logs it in
actions. Raise a finding after a few consecutive refusals so an expired token shows on /maintenance. 2. Non-blocking: the copy page has no dark-on-light contrast check for the.copyborder colour. Run the phone look once a Worker is deployed. - Who may see the copy (security, fix first).
-
Checks
shipped production is serving it deploy 9bea861
-
History
- The edge copy carries only what the docs publish; the push is capped by bytes read; the age and 405 are tested 81ad9e1
- List the edge-copy fetch and forgetPushed where the sweeps expect them 5296013
- Edge resilience test builds the real Row, config and duty context instead of casting 3f8f5fd
- The edge keeps the last Resilience page and serves it as a copy, with its age, while the body is down (#16260) 15c614d
- One palette across the forge and its apps — restarted from the parked branch, forge side first (#16779) e4dd828
- With the weekly window full, the forge runs a model-free measurement and /week counts it (#16783) 7bffc31
- small: The guide spine, read as a new owner, an outside agent and an owner looking up a setting, has its findings fixed (#16781) b92c2a5
- An invite to an organization lands from the closed pull #12484's branch, with the signup welcome tested (#16764) 518ce94
- forge.json validates a service app's ports and refuses a clash with another app (#16778) a4bc344
- The platform inventory page has one primary next action and is looked at on phone and desktop widths (#16773) 721a707
- Admins mark which repositories are offered as templates for new forges (#16752) 577f9d8
- small: Escape leaves the tell box and keeps its draft per page (#16774) 24468de
- On a phone, one tap opens search with the keyboard up and results above it (#16749) 7238053
- A room on an app's change stream reports who is present (#16776) 98bb47d
- Port Jay Moran's demo: actions/demo, refs/demo and moveRefLeased's caller, demo routes (#16745) b346c0a
- The plans page says what each forge size is for, measured by the time to a first built change (#16759) a1bc223
- The owner grants one of his apps, or one crew member, read access to a read-only work repo (#16750) 1d1b0ae
- A card for every #12: the forge's one peek, on every page (#16700) 68934bd
- The system MCP tool answers `kind: "pages"` with the same page-budget rows /system shows (#16755) df6de28
- Talk on a phone, still wrong after #16552 landed: conversation history loads… (#16768) f2ced5a
3 earlier comments
The Worker now keeps the last Resilience map the forge pushed. While the body is unreachable, it serves that map at /settings/resilience as a copy with its age. The type check is clean and the tests I ran pass: the two new files plus test/maintain-edge-kept.test.ts, 8 other maintain* tests, hollow, feature-doors and check-list. I did not run the full gate or the rest of the suite. scripts/fast.ts named 3,701 test files, too many to run, so the forge's check does that on push.
What changed
- Worker (
infra/forge-cloudflare/worker.js):- Push:
PUT /_edge/resiliencestores the map in the Durable Object. It needs a bearer token equal to the Worker secretCOPY_TOKEN. A wrong token gets 403 and a body over 256 KB gets 400. - Serve: when the fetch to the body throws, a browser GET of
/settings/resiliencegets the stored copy. It sits under a "This is a copy" box that gives its age ("3 minutes ago") and adatetime. The response carriesAgeandX-Forge-Edge-Copyheaders and a no-script CSP. With no copy stored, or on any other path, the restarting page appears as before.
- Push:
- Forge side:
- Rendering:
src/maintain/edge_copy.tsrenders the protections and the backups line as one escaped fragment. It pushes only when the fragment differs from what the Worker last took. - Duty: the
edge-resilienceduty runs every minute and does the push. It pushes on the first run after each boot, then again whenever the map changes (a change shows up within a minute). WithFORGE_EDGE_COPY_URLorFORGE_EDGE_COPY_TOKENunset it does nothing. - Lazy imports: the duty loads
checks/resilienceandbackups_lineinsiderun, because the roster loads duty files withrequire, which refuses a top-level await in their import chain.
- Rendering:
- Tests:
test/forge-cloudflare.test.tscovers the copy, its age, the 403, and no copy served on other paths.test/maintain-edge-resilience.test.tscovers the escaping, push-on-boot, push-on-change, the refused push, and the duty on the roster.bun scripts/gate.ts --explainreported all 32 rules satisfied. - Docs:
docs/features/edge-resilience-copy.mdis new, and the infra README has a short section on the copy.
Left out or to check
- Egress: the host is configured at runtime, not a literal in the code. The operator must add the Worker's host to
forge.jsonegress. I did not, because the host isn't known here. - Settings route: the forge's own
/settings/resiliencestill redirects to/settings/backups#domains. The copy only appears at the edge, as the issue asks. - Terminal side: there is no change under
src/tui/, since this adds no page, action or tool. - What the copy leaves out: nightly output and anything that needs the body.
- Unreachable only: only an unreachable body triggers the copy, not a 5xx answer from the body.
- Reuse: I reused
readResilience,backupsLine,escapeHtml, and the Worker's existingCSPandwantsPage. I did not runscripts/similar.ts. - Plan: I did not call
keep_plan.
Try it: set COPY_TOKEN on the Worker with wrangler secret put COPY_TOKEN, and set FORGE_EDGE_COPY_URL and FORGE_EDGE_COPY_TOKEN on the forge. Stop the body and open <worker>/settings/resilience.
🤖 Generated with Claude Code
The edge now keeps the last Resilience page and serves it as a copy, with its age, while the body is down (#16260). This push fixes the failed check.
What changed in this push: test/maintain-edge-resilience.test.ts no longer casts with as never. It builds a typed Row[] for the fragment test, a real ForgeConfig ({ dataDir, port: 0 }) for createApp, and a typed DutyContext for the duty. The test checks the same things as before.
Checks run: bun scripts/gate.ts is clean after the commit. bun x tsc --noEmit is clean. The file's 3 tests pass.
Left out: I did not run the full suite. The forge runs it on push.
To try it: bun test test/maintain-edge-resilience.test.ts.
The edge keeps the last Resilience page and serves it as a copy, with its age, while the body is down (#16260). This push fixes two of the three failures from the last check.
- Outbound sweep:
src/maintain/duties/edge_resilience.tsmakes onefetchto the edge copy URL the operator configured, never a host from a request. I listed it in theALLOWEDtable intest/outbound-sweep.test.tswith that reason.test/outbound-sweep.test.tsandtest/unused-exports.test.tsnow pass. - Dead-code check:
forgetPushedis exported only so the test can reset the "last pushed" state. I added it toscripts/unused-exports-allow.json. test/fork-drift-cache.test.ts("a second read spawns no git…"): it failed withgit_failedin the forge's shard run, but it passes when I run it here and nothing I changed touches git. I think it is a flake under shard load and left it alone, so it may fail again.
bun scripts/gate.ts and bun x tsc --noEmit are clean. I did not run the full suite.
To try it: bun test test/outbound-sweep.test.ts test/unused-exports.test.ts test/maintain-edge-resilience.test.ts.
All three review items are fixed on the branch, and the new tests pass. gate, tsc and design-lint are clean, and the unused-exports and outbound-sweep tests pass.
1. Who sees the copy. The Worker cannot tell an admin from anyone else, and I chose not to add identity checks there. Instead the copy now carries only what the docs already publish. It lists each protection as THREATS.md words it (text and adversary), with a count. It leaves out the standings, test file names, the backups line and the nightly output. A red standing names what to attack, so that stays on /resilience, which still needs a signed-in admin. The page says so.
- The tradeoff is that the copy no longer shows green or red during an outage. If the copy should keep standings, the alternative is a signed identity the Worker can verify, which is a larger change. Say if you want that.
- The test is in
test/forge-cloudflare.test.ts: an unauthenticated browser gets the copy, andtest/maintain-edge-resilience.test.tschecks the pushed fragment has no standing, test file or backups text. The change is incopyFragmentand theedge_resilienceduty.
2. Byte cap.
- Cap:
Forge.keepnow reads the stream throughreadCapped. It keeps a running count of bytes and stops reading at 256 KB. Oversize and empty pushes both answer 400bad size. - Tests: an oversize push is tested with 90,000 three-byte characters, which is under 256 K characters but about 270 KB as bytes. It is refused and stores nothing. A non-PUT (GET, POST, DELETE) to
/_edge/resiliencegets 405 withallow: PUT.
3. Egress and age.
- Egress: production's
forge.jsondoes not need an entry. The Worker's host is the operator's own, set inFORGE_EDGE_COPY_URL, so I can't write a literal for it. It has to be added in whichever deployment sets that variable, or on the app's settings page.docs/features/edge-resilience-copy.mdsays this now. The duty's singlefetchis listed intest/outbound-sweep.test.ts. - Age test: a copy stored 185 seconds ago reads "3 minutes ago" and gets
age: 185.
I could not run the Worker here, so the served page is tested against the source only.
A third failure from the last check, test/fork-drift-cache.test.ts, passes here and doesn't touch this change, so I left it alone.
The Worker now keeps the last Resilience map the forge pushed. While the body is unreachable, it serves that map at
/settings/resilienceas a copy with its age. The type check is clean and the tests I ran pass: the two new files plustest/maintain-edge-kept.test.ts, 8 othermaintain*tests,hollow,feature-doorsandcheck-list. I did not run the full gate or the rest of the suite.scripts/fast.tsnamed 3,701 test files, too many to run, so the forge's check does that on push.What changed
infra/forge-cloudflare/worker.js):PUT /_edge/resiliencestores the map in the Durable Object. It needs a bearer token equal to the Worker secretCOPY_TOKEN. A wrong token gets 403 and a body over 256 KB gets 400./settings/resiliencegets the stored copy. It sits under a "This is a copy" box that gives its age ("3 minutes ago") and adatetime. The response carriesAgeandX-Forge-Edge-Copyheaders and a no-script CSP. With no copy stored, or on any other path, the restarting page appears as before.src/maintain/edge_copy.tsrenders the protections and the backups line as one escaped fragment. It pushes only when the fragment differs from what the Worker last took.edge-resilienceduty runs every minute and does the push. It pushes on the first run after each boot, then again whenever the map changes (a change shows up within a minute). WithFORGE_EDGE_COPY_URLorFORGE_EDGE_COPY_TOKENunset it does nothing.checks/resilienceandbackups_lineinsiderun, because the roster loads duty files withrequire, which refuses a top-level await in their import chain.test/forge-cloudflare.test.tscovers the copy, its age, the 403, and no copy served on other paths.test/maintain-edge-resilience.test.tscovers the escaping, push-on-boot, push-on-change, the refused push, and the duty on the roster.bun scripts/gate.ts --explainreported all 32 rules satisfied.docs/features/edge-resilience-copy.mdis new, and the infra README has a short section on the copy.Left out or to check
forge.jsonegress. I did not, because the host isn't known here./settings/resiliencestill redirects to/settings/backups#domains. The copy only appears at the edge, as the issue asks.src/tui/, since this adds no page, action or tool.readResilience,backupsLine,escapeHtml, and the Worker's existingCSPandwantsPage. I did not runscripts/similar.ts.keep_plan.Try it: set
COPY_TOKENon the Worker withwrangler secret put COPY_TOKEN, and setFORGE_EDGE_COPY_URLandFORGE_EDGE_COPY_TOKENon the forge. Stop the body and open<worker>/settings/resilience.🤖 Generated with Claude Code
Closes #16260