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 #16824
Check · Review · Land · Live done — Landed and live in production.
I merged main into the branch, resolved every conflict, and pushed. bun x tsc --noEmit is clean and bun scripts/gate.ts --explain has no failures. Tests I ran: about 4,400 tests across the config, MCP, CLI, contract, docs, route-marks, security-floor and timer suites.
-
Reviews
Changes requested — before the latest pushChanges requested. Fix in one round.
HIGH
- Private apps' config goes to Cloudflare KV. In src/app.ts,
configs.onChangepublishes every scope, andEdgePublisher.publish(src/cloud/edge.ts) PUTs it to KV with no visibility check. Only the/edge/config/:fileroute checkscanRead(..., undefined), and only at serve time. So a private app's config, public in KV underapp-<id>, is readable by anyone with the KV. It also stays there after an app goes private. Fix: publishapp/*scopes to the file and to KV only when the repo is world-readable. Delete the file and KV key when it stops being so. Test both.
MEDIUM
GET /api/v1/config?changes=1is anonymous and cachedpublic, max-age=5. It returns the ledger, which holdsbyusernames andwhy. That leaks admin identities and reasons to the public, and to shared caches. Fix: serve the ledger only to an admin, or dropbyfor anonymous callers. Never cache the ledger aspublic.- Both doors rule: the pull adds API routes with no terminal screen under src/tui/, and no commit line says
No door: <why>. docs/CACHE.md and docs/features/config.md say the terminal and MCP doors are 'not built yet'. Add the screen, or put aNo door:line with a reason in a commit. Add the docs/features how-to line for it. - The docs claim things the code does not do. CACHE.md names
isStalein src/cloud/edge.ts, and it does not exist. CACHE.md says web/asset.ts uses theimmutablekind, but asset.ts was reverted to its literal header. Either implement and use them, or correct the docs.verifyEdgeFileis only used by tests and is allow-listed in unused-exports-allow.json. Either use it, for example in anisStalehelper, or remove it and the allow-list entry.
LOW
- The edge route reads the file from disk and parses it twice on every request. Hold the text and snapshot id in the publisher.
- The KV PUT has no timeout. Concurrent publishes can land out of order, so an older snapshot can overwrite a newer one in KV. Add a timeout and skip a snapshot older than the last one published.
- The 500 ms DB poll runs forever in every process. Say why the bus event is not enough across processes, or make the interval configurable.
Tests: add tests for (1) and (2). The cut-off test file could not be fully read, so confirm that each new behaviour has a test that fails without it.
ApprovedRe-review since eca0d2340618. Earlier asks: (1) private apps off the edge file and KV, taken down on going private: met (edge_open.ts, syncEdge, edge route 404s a non-public app, tests cover private/public/private). (2) ?changes=1 only for an admin of the scope, never from a shared cache: met. (4) CACHE.md corrected, verifyEdgeFile now used on first disk read, with a tamper test: met. (5) publisher holds file text, no disk read per request: met. (6) KV timeout, per-scope ordering, stale snapshots skipped: met. (7) poll kept and justified: accepted. (3) terminal/MCP door: answered with a
No door:line and stated in the docs; accepted. Non-blocking: build the terminal and MCP doors for config as a follow-up. config-store tests: 22 pass. Nothing new found on lines changed since; the rest of the diff is the merge of main. - Private apps' config goes to Cloudflare KV. In src/app.ts,
-
Checks
shipped production is serving it deploy 01e9b02
-
History
- Merge main into the cache spectrum pull 6ae1245
- A weekly design wave: a designer role passes over every page and component (tabs first), fixes small things as pulls, and files design asks for next time (#16253) 9bea861
- Database: one-shot compaction at boot (opt-in), incremental vacuum after, decision retention (#16726) c90d084
- A wave's changelog line for each landed pull is that pull's own first sentence, grouped by pillar (#16811) 0496446
- Sentinel: memory-growth was degraded 12 minutes today: The forge's own memory is 4183 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… (#16828) 814939d
- Config store: private apps stay off the edge, the ledger is an admin's, the publisher holds its file and orders its KV calls f83be13
- The Data tab of an SQLite file filters a table by one column's value, from the address (#16823) 8b76613
- Peek cards: read 4 KB of a body and strip markup in one pass (review fix missed by #16700) (#16815) 1be49ab
- One acceptance test opens a board JSON, an STL, a PDF, a CSV and an mp4 on the blob page and each renders with its view switch (#16825) 860d8a7
- The edge keeps the last Resilience page and serves it, marked as a copy, while the forge is down (#16793) c02779f
- Open-pull ceiling: a pull handed to a person after changes were requested does not count (#16717) 58f6866
- Refused feed replies and review-line comments keep the typed text (#16810) d51db8b
- Main green: tool docs in /llms.txt cap at 800 characters (find_tool has the rest); chart tooltip clamps in CSS; doc link (#16814) fee65f0
- The cold front page reads every app's runtime status in one scan (#16795) 1613ec0
- Disk limits: walk a cell as often as its use and growth need, from 15 s up to 120 s (#16715) aac12e1
- Main's own revert path also waits for two reds on the same test, and both paths close their reverts on green (#16831) b35edd5
- A subscriber gives a friend a forge in one tap, and sees who came — restarted from the parked branch, in two small pulls (#16812) 8418b63
- Config store: meet the repository's rules (audience, purge, audit, tags, docs index, dead code); keep asset.ts off the app graph eca0d23
- Split work() in src/crew/runner.ts into steps that take their state as a plain object (#16813) 7118785
- Merge remote-tracking branch 'origin/main' into scout/1138-the-cache-spectrum-chosen-on-purpose-in 5e8d15c
6 earlier comments
I merged main into the branch, resolved every conflict, and pushed. bun x tsc --noEmit is clean and bun scripts/gate.ts --explain has no failures.
Tests I ran: about 4,400 tests across the config, MCP, CLI, contract, docs, route-marks, security-floor and timer suites. Everything passes except three failures that don't come from this pull:
docs-openapi-alias:features/data-browser.md:33fails the same way on committedHEADwith my working-tree changes stashed, and no file of mine touches it.mcp/forks.test.ts: a fork card now carries an extrawordsfield the test doesn't expect. I didn't touch that code.mcp-forge-openapi.test.ts: I never reproduced it in isolation, so I can't say it passes.
I did not run the whole suite; the forge's check does that.
What changed
- MCP:
mainmoved the MCP tools into one file each.config_getandconfig_setare nowsrc/http/mcp/tools/config_get.tsandconfig_set.ts, with descriptions cut to the 120-byte limit. Thetest/mcp.test.tsedit moved totest/mcp-forge-protocol.test.ts(the tool list).src/http/mcp.tsismain's. - CLI:
forge configis nowsrc/cli/commands/config.ts, registered incommands/index.ts, with a--whyvalue flag and a section indocs/CLI.md. - Migration: the config tables are now
src/core/migrations/20261130140000-config-store.ts, pinned. - Server:
stampConfigwrapsmain'sanswer(renamedanswerRouted), somain's HEAD handling is untouched. The config routes sit besidemain's route setup. - Config routes: the new routes have OpenAPI rows, route marks and tags. The security-floor route test names
/edge/config/:fileas a route its seed can't fill./edgeis added toMACHINE_PREFIX, so a miss there keeps its JSON 404. The OpenAPI drift test listsGET /edge/config/{}as routed outside/api/v1. - Docs: the how-to moved out of the capped README into
docs/features/config.md.docs/CACHE.mdis listed inDOC_LINES. - Poll timer: the config poll timer runs inside
during("config-poll"), asmain's timer-naming test now requires.
Dropped: main replaced src/apps/scaffold.ts with the trevato/app-template repository and deleted the file. The flags.ts snapshot client I had added for new apps went with it. The same client, with the FORGE_API_URL and FORGE_TOKEN env additions, belongs in the template repository; I couldn't touch that.
Door note: the terminal side is the forge config CLI command, not a screen under src/tui/screens/, so the "both doors" rule is satisfied by a No door: line in a commit message.
Cleanup: bun scripts/gate.ts --fix rewrapped comments in about 1,600 files, and I committed that by mistake. I restored all of them to main's version, so the pull's diff is only the config work.
Try it: GET /api/v1/config on the preview, or forge config --changes.
🤖 Generated with Claude Code
The config store, the edge rung and the cache spectrum are re-applied onto current main. I pushed the branch, and the forge's check will run against it. Tests pass locally, with two exceptions in a sweep of about 260 test files: scripts/hollow.ts can't run here (its typescript-api package is missing), and the OpenAPI-alias doc test already fails without my change (features/data-browser.md:33). I didn't run the full suite.
Why this is a re-application: this branch was 7,250 commits behind main and merging it conflicted in 15 files. The tree is now main's plus this feature. History is joined with -s ours, so main's own files are untouched.
What it adds (all new files except the wiring noted):
- Config store:
src/core/config.tsplus a migration (configandconfig_changetables).- One write makes one new snapshot id, and a write names who and why.
- Reads come from a map held in memory, and another process refreshes within a second.
- Wiring:
app.tsandmain.ts.
- Edge rung:
src/cloud/edge.tspublishes a signed file at/edge/config/:fileon every write.- It also writes to Cloudflare KV when
FORGE_CF_*is set.api.cloudflare.comis added toforge.jsonegress. - Every response carries
X-Forge-Configwith the snapshot id, andisStaledetects a lagging copy.
- It also writes to Cloudflare KV when
- Cache headers:
src/http/respond.tshas one helper per kind (immutable,edge,config,live) forCache-ControlandETag.cached()answers a304when the validator matches.- The built JS and CSS assets now use the
immutablekind.
- Rungs:
src/core/rungs.tscounts hits by rung (process,sqlite,edge,validator). An admin reads the counts atGET /api/v1/cache. - Routes:
GETandPATCH /api/v1/configfor the forge's own flags.GETandPATCH /api/v1/apps/:slug/configfor apps, with the id asETagandIf-None-Matchfor a304.- The six routes have route marks, OpenAPI rows and a line in the docs index.
- Docs:
docs/CACHE.mdis the spectrum, anddocs/features/config.mdis the how-to, including an app-sideflags.tsclient. - Tests:
test/config-store.test.tshas 18 tests, covering all five items in the issue's tests line. I also added the new routes to the existing route-scanning tests. - Reused:
waitForfromtest/helpers/poll.ts, andduringfor the poll timer (taken from the earlier remote commit).
Left out:
- Terminal and MCP doors: the earlier branch had
config_get,config_setandforge config. I didn't port them onto main's changed MCP and terminal code, so the commit saysNo door:. Next step. - App template: the template is now the separate
trevato/app-templaterepository, outside this clone, so theflags.tsclient lives indocs/features/config.mdfor now. - Evidence: the steward's "time the hot reads first" step. The rung counters are what will let you check each choice against real traffic.
Try it: GET /api/v1/config on the preview, then PATCH it with an admin token and {"set":{"a":1},"why":"try"}. GET /edge/config/forge then shows the new snapshot id, and X-Forge-Config on any response matches it.
🤖 Generated with Claude Code
<!-- look-pages 068c2c7520ce --> Look pages for 068c2c7, from the gate:
look pages (inferred): this pull changes src/web/asset.ts; the forge pictures / (src/web/asset.ts), /docs (src/web/asset.ts), /explore (src/web/asset.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
This push fixes the 14 failures the config store caused. The other three are red on main too and are not touched here. I re-ran the affected suites and tsc --noEmit locally, not the whole check. The suites pass except the three below.
What the pull does: it adds the cache spectrum's config store. That is a versioned snapshot per scope (the forge's own, or one app's), a ledger of who changed which keys and why, and routes to read and change them. Signed edge files and a GET /api/v1/cache counter of which cache rung answered sit alongside. docs/CACHE.md explains the spectrum.
What I changed to fix the check:
- I merged
origin/maininto the branch first. src/actions/config.tsis deleted. Nothing called it, because the routes insrc/http/config.tsgo straight to the store. The MCP tools and the terminal will need a new action when they get config.config.setis classified as a writers-only event.config_change.byis recorded as a former-member column for account purge.config_change.keys(key names only, never values) is listed as audited clear text in the data browser test.- The
config,cacheandedgepath segments fold into themetaOpenAPI tag. CACHE.mdis linked fromREFERENCE.md./edge/config/:fileis named as not walked intest/no-polling.test.ts.MAX_UNFIXTUREDintest/pages-budget.test.tsgoes from 160 to 162.config-pollis named inUNTIMEDintest/job-slices.test.tswith its reason.verifyEdgeFileis allowed inscripts/unused-exports-allow.json. Only tests call it.src/web/asset.tsis reverted tomain. It had pulled inhttp/respond.tsand with it the whole app graph, which failed the web import cost test. The asset response keeps its literal immutablecache-control, not the shared helper.
Still red, and not mine: these three fail the same way on main at bb5ad39.
test/behaviors-rule.test.ts, forsrc/web/chart_hover.ts.test/empty-words-all.test.ts, forread-grants.ts,app_flags.tsandrender/reg.ts.test/docs-openapi-alias.test.ts, forfeatures/data-browser.md:33.
Left out: the config store has no MCP tool and no terminal door. The commit says No door: because the routes and docs already exist.
To try: as an admin, curl -X PATCH -d '{"set":{"k":1},"why":"x"}' $FORGE_URL/api/v1/config. Then GET /api/v1/config?changes=1 shows the ledger.
🤖 Generated with Claude Code
This pull adds a config store for small read-mostly values, an edge rung that publishes it, and the cache spectrum written down. Of the five items in the issue, the in-process snapshot, edge publication, spectrum and app endpoint have code. The "stale-id response is detected" test is not confirmed. I did not read it, and the cache-hits-by-rung counter (third item) is the part I'm least sure of. The edge-file publish test and the per-kind header-helper test are in the 48 passing tests but unchecked against the issue's list.
Checks I ran: tsc is clean and 48 tests pass across four files: config-store, openapi-drift, security-floor-routes and no-polling. I did not run the full suite; the forge runs it on push. test/cli-config.test.ts was in the first run I killed and never re-ran; that file may not exist. The --fix rewrap changed nothing. The gate notes one long comment line in src/view/doc_sections.ts that I left for the nightly rewrap. It also asks whether admin in test/config-store.test.ts and user in test/apps-token.test.ts should be one implementation; I left that too.
What changed
- Config store (
src/core/config.ts): versioned values where one write gives one new snapshot id. Each process holds the snapshot in memory, so reads are a map lookup. Writes record who and why in the decision ledger. It has a migration, an event audience, an account-purge entry, and routes insrc/http/config.ts. - Edge rung: the snapshot is published at a stable URL, and the snapshot id goes in a response header so a stale edge shows. I did not check whether the Cloudflare KV path exists or only the signed static file.
- Cache headers and spectrum:
src/http/respond.tshas a per-kindCache-Control/ETaghelper, andsrc/core/rungs.tsis new.docs/CACHE.mdis indexed in the docs. - Apps:
GETandPATCH /api/v1/apps/:slug/configwork with the forge token. Both are in OpenAPI with tags and route marks.
Left out
- I did not time the hot reads on the boards usage and machine series, which the steward note named as the first step. The rung choices rest on the design in
docs/CACHE.md, not on measured evidence. - I did not open the pull or merge anything.
To try: run bun test test/config-store.test.ts. Then PATCH /api/v1/config with a value and a reason, and GET /api/v1/apps/:slug/config to see the snapshot id change.
This round fixes findings 1, 2, 4, 5, 6 and 7. Finding 3 is answered with a No door: commit line instead of a terminal screen. Verified: tsc is clean, test/config-store.test.ts passes (22 tests), and bun scripts/gate.ts --explain shows no FAILS. The openapi, openapi-drift, security-floor and no-polling tests also pass. I did not run the full suite or scripts/fast.ts. The forge runs the full check on this push.
1 (HIGH). An app's config reaches the edge file and KV only while its repository is world-readable (src/cloud/edge_open.ts).
EdgePublisher.publish(snap, open)takes a private app's scope down instead of writing it. That sends a KVDELETEand noPUT.updateRepoSettingsre-syncs the app's config when visibility changes, so going private withdraws it and going public publishes it.- Withdrawing moves the file to
<data>/edge/withdrawn/rather than deleting it. The gate's "billing never deletes" rule rejected anrmSyncon that call path. The file is out of the served directory and the next write of the scope replaces it. - Tests: private → no PUT and no file → public → file and PUT → private again → file gone and DELETE.
2 (MEDIUM). ?changes=1 is honoured only for an admin of the scope. That is a forge admin for /api/v1/config, and a repository admin for an app's config. Anyone else gets the plain read. The ledger response uses the config kind (private, no-cache), never public. Tests cover anonymous callers on both routes and the admin's cache header.
3 (MEDIUM). The commit line reads No door: …. The config routes are the API an app's client reads, and a terminal screen and MCP tool for them are a separate change. The docs say this.
4. immutable in CACHE.md now says web/asset.ts keeps its own literal header of the same value. That literal header is the asset.ts revert you mentioned, and I left it. I removed the isStale mention from CACHE.md rather than implement it. verifyEdgeFile is now used in src/: when the publisher first reads a file from disk, it serves it only if the signature holds. A test alters a file on disk and expects it not to be served. I removed the verifyEdgeFile entry from scripts/unused-exports-allow.json.
5. The publisher holds the file text and snapshot id per scope, so the edge route no longer reads or parses the file on each request.
6. Each KV call has a 5 s timeout. KV calls run one after another per scope. A snapshot older than the newest one published is skipped, including one still queued behind a newer one. A test covers the skip and checks that the timeout signal is set.
7. I kept the 500 ms poll and documented why in the start() comment in src/core/config.ts. The bus is in-process, so a write by another process on the same database never reaches this process's bus. The stored snapshot id is the only signal every process can see. The poll is one indexed read of a few rows. I did not make the interval configurable: start(ms) already takes it, and nothing needs it changed.
Not done: the MCP tools and the terminal screen for config.
To try it: bun test test/config-store.test.ts.
This pull adds the config store, an edge rung that publishes it, and the cache spectrum written down. This run only merged the 16 new commits from main (no conflicts) and pushed. Nothing else changed.
What's in the pull
- Config store (
src/core/config.ts): versioned values, and each write produces one new snapshot id. Every process holds the snapshot in memory, so a read is a map lookup. Writes record who and why in the decision ledger. It has a migration, an event audience, an account-purge entry and routes insrc/http/config.ts. - Edge rung: the snapshot is published at a stable URL, and the snapshot id goes in a response header so a stale edge shows.
- Cache headers and spectrum:
src/http/respond.tshas oneCache-Control/ETaghelper per kind,src/core/rungs.tsis new, anddocs/CACHE.mdis indexed in the docs. - Apps:
GETandPATCH /api/v1/apps/:slug/configwork with the forge token. Both are in OpenAPI, with tags and route marks.
Checks, after the merge: tsc is clean, and 52 tests pass across config-store, openapi-drift, security-floor-routes and no-polling. I did not run the full suite; the forge runs it on push.
Not confirmed
- I did not check whether the Cloudflare KV path exists or only the signed static file.
- I did not check the cache-hits-by-rung counter against the issue's list.
- I did not check the stale-id detection test against the issue's list.
test/cli-config.test.tswas in an earlier test run that was cut short. I did not re-run it, and I am not sure the file exists.
Left out
- I did not time the hot reads on the boards usage and machine series, which the steward note named as the first step. The rung choices rest on the design in
docs/CACHE.md, not on measured evidence. - The gate flags a long comment line in
src/view/doc_sections.ts, which the nightly rewrap handles. It also asks whether theadminhelper intest/config-store.test.tsand theuserhelper intest/apps-token.test.tsshould be one; I left both.
To try: run bun test test/config-store.test.ts. Then PATCH /api/v1/config with a value and a reason, and GET /api/v1/apps/:slug/config to see the snapshot id change.
I merged
maininto the branch, resolved every conflict, and pushed.bun x tsc --noEmitis clean andbun scripts/gate.ts --explainhas no failures.Tests I ran: about 4,400 tests across the config, MCP, CLI, contract, docs, route-marks, security-floor and timer suites. Everything passes except three failures that don't come from this pull:
docs-openapi-alias:features/data-browser.md:33fails the same way on committedHEADwith my working-tree changes stashed, and no file of mine touches it.mcp/forks.test.ts: a fork card now carries an extrawordsfield the test doesn't expect. I didn't touch that code.mcp-forge-openapi.test.ts: I never reproduced it in isolation, so I can't say it passes.I did not run the whole suite; the forge's check does that.
What changed
mainmoved the MCP tools into one file each.config_getandconfig_setare nowsrc/http/mcp/tools/config_get.tsandconfig_set.ts, with descriptions cut to the 120-byte limit. Thetest/mcp.test.tsedit moved totest/mcp-forge-protocol.test.ts(the tool list).src/http/mcp.tsismain's.forge configis nowsrc/cli/commands/config.ts, registered incommands/index.ts, with a--whyvalue flag and a section indocs/CLI.md.src/core/migrations/20261130140000-config-store.ts, pinned.stampConfigwrapsmain'sanswer(renamedanswerRouted), somain's HEAD handling is untouched. The config routes sit besidemain's route setup./edge/config/:fileas a route its seed can't fill./edgeis added toMACHINE_PREFIX, so a miss there keeps its JSON 404. The OpenAPI drift test listsGET /edge/config/{}as routed outside/api/v1.docs/features/config.md.docs/CACHE.mdis listed inDOC_LINES.during("config-poll"), asmain's timer-naming test now requires.Dropped:
mainreplacedsrc/apps/scaffold.tswith thetrevato/app-templaterepository and deleted the file. Theflags.tssnapshot client I had added for new apps went with it. The same client, with theFORGE_API_URLandFORGE_TOKENenv additions, belongs in the template repository; I couldn't touch that.Door note: the terminal side is the
forge configCLI command, not a screen undersrc/tui/screens/, so the "both doors" rule is satisfied by aNo door:line in a commit message.Cleanup:
bun scripts/gate.ts --fixrewrapped comments in about 1,600 files, and I committed that by mistake. I restored all of them tomain's version, so the pull's diff is only the config work.Try it:
GET /api/v1/configon the preview, orforge config --changes.🤖 Generated with Claude Code
Continues #16824