The cache spectrum

Each kind of data lives on one rung, chosen on purpose. Climb only when the rung below is too slow for who reads it; never keep the same fact as truth on two rungs.

RungWhat lives thereRead costChangesTruth?
gitcode, forge.json, the repository's own filesa git reada pushyes — the only truth (CLAUDE.md, invariant 4)
SQLitethe derived index (issues, pulls, events), config rows and their ledger (config, config_change), sessionsone indexed queryevery actionderived from git, except config and sessions
processthe current config snapshot of each scope, held by every forge processa map lookuprefreshed on the config.set bus event, or by a half-second poll for another process's writea copy of SQLite
edgethe signed snapshot file, at a stable URL and (behind Cloudflare) in KVnone of the forge'spublished within seconds of a writea copy of SQLite
validatorETag + If-None-Match: the client keeps the body, the forge answers 304a lookupper requestn/a

Which data, which rung

One helper per kind

Cache-Control and ETag come from cacheHeaders(kind, etag) and cached(...) in src/http/respond.ts; a route names the kind and never writes the header. The table CACHE_CONTROL is the single source and test/config-store.test.ts checks this page against it.

KindCache-ControlETagUsed for
immutablepublic, max-age=31536000, immutableoptionalcontent-addressed assets; web/asset.ts keeps its own literal header of the same value
edgepublic, max-age=5, stale-while-revalidate=30snapshot idthe published snapshot, the forge's public config
configprivate, no-cachesnapshot idan app's config for its signed-in reader
liveno-storeneveranything that must not be kept

Routes that predate the helper still set their own headers (web/pages/*, apps/proxy.ts); they move to a kind as they are touched.

The edge rung

Every write produces one snapshot id. Each process that learns of it publishes <data>/edge/config/<name>.json, an Ed25519-signed { payload, sig }, served at /edge/config/<name>.json (forge, or app-<id> for an app whose repository anyone can read). The public key is at /edge/config/key.pem. With FORGE_CF_ACCOUNT, FORGE_CF_KV_NAMESPACE and FORGE_CF_API_TOKEN set, the same bytes are also PUT to that KV namespace under the same name, so a Worker reads flags without the forge.

A stale edge is visible. Every response carries X-Forge-Config, the id of the snapshot this forge holds; compare it with the snapshot in the file you have.

Apps

GET /api/v1/apps/:slug/config (any credential that can read the app, so the read-only token an app starts with) returns { snapshot, version, values, updated_at } with the id as ETag; send it back as If-None-Match for a 304. PATCH with { "set": { key: value | null }, "why": "…" } needs an admin token and repository admin. The edge file of a public app is the same data without the forge.

The MCP tools and the terminal door are not built yet (the change carries a No door: line); an app's client is in docs/features/config.md.

Checking the choice

GET /api/v1/cache (admin) returns this process's hit/miss counts per rung: process (snapshot already held), sqlite (loaded or refreshed), edge (published file served), validator (304s). The counters are in memory and reset with the process.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs