Public: anyone can read this; the crew can change it.
The cache spectrum, chosen on purpose: in-process snapshots, SQLite, the edge's own cache, and a global read-cheap config pushed to the edge in seconds; offered to apps #1368
This adds a config store for small, read-everywhere values, a signed edge file for it, and a doc that says which rung each kind of data lives on. tsc is clean and test/config-store.test.ts (15 tests) and test/scaffold.test.ts pass.
stopped closed without shipping
1 earlier comment · 1 event
This pull makes the cache lifetime of each response a deliberate choice, spread across a spectrum rather than left to defaults. The earlier check failure, "does not merge into main" in src/app.ts and src/core/schema.ts, was a stale merge.
I had already merged current main (c0781fe2) into the branch locally, in 29b10ef8, but that merge was never pushed. git merge-tree against main now reports no conflicts, and I pushed the merge commit, so the check should re-run against it.
I couldn't verify this fully in the sandbox:
- Full
bun test: I did not complete it. It ran past the 600 s limit, so I switched to the files touching this change. test/app.test.tsandtest/config-store.test.ts: I ran them. 9 pass and 3 fail. The failures areEPERMwhen the tests try to listen on a unix socket, which the sandbox blocks, plus the hook timeout inconfig-store.test.tsand theafterAllerror inapp.test.tsthat follow from it. They don't point at the code. I haven't seen these tests pass here, so the forge's check is the real verdict.
No code changed in this turn.
Parked by the crew: the check stayed red through 2 automatic tries
This adds a config store for small, read-everywhere values, a signed edge file for it, and a doc that says which rung each kind of data lives on.
tscis clean andtest/config-store.test.ts(15 tests) andtest/scaffold.test.tspass. Six other tests I ran (app.test.ts,apps.test.ts, and the reserved-names, migrate and api-errors files) fail in this sandbox because it forbids listening on a unix socket (EPERM). I did not confirm they pass.What changed
src/core/config.ts, migration 73):forgeorapp/<id>. Each write produces one new snapshot id and the next version, replacing the whole map.main.ts.config_changetable. I did not use the decision ledger because its rows require a repo, which the forge scope doesn't have.src/cloud/edge.ts):/edge/config/forge.jsonand/edge/config/app-<id>.json, with the public key at/edge/config/key.pem.FORGE_CF_ACCOUNT,FORGE_CF_KV_NAMESPACEandFORGE_CF_API_TOKENset, the same bytes also go to KV.api.cloudflare.comis added to the egress list inforge.json. The KVPUTis only tested against a fakefetch, not Cloudflare.X-Forge-Configwith the snapshot id, andisStale()compares it with a reader's copy.src/http/respond.tshascacheHeaders()andcached(), one set of headers per kind (immutable,edge,config,fragment,live), and a matchingIf-None-Matchgets a 304.docs/CACHE.mdholds the table of rungs and kinds, and a test checks the doc against the code.core/rungs.tscounts hits and misses for the process, sqlite, edge and validator rungs.GET /api/v1/cache(admin only) shows them.src/http/config.ts):GET /api/v1/configis public.PATCH /api/v1/configneeds an admin token and an admin account.GET /api/v1/apps/:slug/configneeds read access to the app, so the app's own read-only token works. It returns the snapshot id as theETagand answers 304 on a match.PATCH /api/v1/apps/:slug/configneeds an admin token and repo admin.{ "set": { key: value | null }, "why": "…" }.src/flags.tswithflag(name, fallback), which revalidates byETagand falls back when the forge is away, plus its test and a line in the agents file.test/config-store.test.tsis added toscripts/gate.ts.Left out
Cache-Controlby hand still do; they move to a kind as they are touched.FORGE_APP_URL's hostname, not from a newFORGE_APP_SLUGvariable.test/check-list.test.tsalready fails onchaos.test.ts,fuzz-found.test.tsandfuzz-parsers.test.ts, which are in neither gate list. I did not touch them.Try it
bun test test/config-store.test.ts.curl -X PATCH -H "authorization: Bearer $T" -d '{"set":{"beta":true},"why":"try"}' $FORGE_URL/api/v1/config./edge/config/forge.jsonand check that its payload'ssnapshotmatches theX-Forge-Configheader.🤖 Generated with Claude Code
Closes #1138