carlos / platform Public

plan: edge page cache slice 1 rev 3 after Astra plan round 2

Round 2 findings unedited. Paul's rule-2 choices: one current-inputs
invariant with unit-backed instances refused in v1, and one client
scrub list with a guard test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 4c5c988fca7e8a2b1c672894ba9901c1325facdb parent c006cd4
3 files changed, +512 −179
  • docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md +315 −179
  • docs/superpowers/plans/CODEX-FINDINGS-PAGE-CACHE-PLAN1-R2.md +100 −0
  • docs/superpowers/plans/CODEX-REVIEW-BRIEF-PAGE-CACHE-PLAN1-R3.md +97 −0
diff --git a/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md b/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md
index 157dad7e0..7d9892730 100644
--- a/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md
+++ b/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md
@@ -2,14 +2,27 @@
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
-Plan rev 2, after Astra plan round 1
-(`CODEX-FINDINGS-PAGE-CACHE-PLAN1-R1.md`). Marks like **(P1-3)** point
-at the finding a passage answers.
+Plan rev 3, after Astra plan rounds 1 and 2
+(`CODEX-FINDINGS-PAGE-CACHE-PLAN1-R1.md`, `-R2.md`). Marks like
+**(P1-3)** point at a round-1 finding, and **(R2-1)** at a round-2 one.
+
+Stopping rule 2 fired after round 2 in two families. Paul chose, on
+2026-11-08:
+- **Release and config invalidation:** "One invariant + gate units".
+ One function computes an instance's current inputs. A page is served
+ only while its tag matches them, and stored only when the answering
+ process started from exactly those inputs. Unit-backed instances are
+ refused in v1.
+- **Marker stripping:** "One list, every scrub". Every client-boundary
+ scrub iterates one vocabulary list, and a guard test checks each
+ scrub against every entry.
+
+Round 3 is the last in the plan's budget.
**Goal:** An app marks a response with `Carlos-Page-Cache: on`, and its
home box keeps the page on disk and serves it without waking the app,
-until the app clears it or the process answering for the instance
-changes build or config.
+until the app clears it or the instance's installed build or delivered
+config changes.
**Architecture:**
- **`internal/pageindex`** is the spec's page index (§6.1). It is the
@@ -23,11 +36,25 @@ changes build or config.
responses through the index, and routes both purge channels into it.
- **Opted-in instances** (holding a durable opt-in mark) skip the LRU
entirely.
-- **Every page carries its serving identity:** the build and config the
- answering process was started with, recorded at the activator's
- existing spawn points. A hit needs the current identity, so a new
- release or config invalidates without a separate clear, while a wake
- of the same build and config keeps the pages **(P1-3, P1-4)**.
+- **One invariant decides release and config freshness (Paul's
+ choice; R2-1, R2-2):**
+ - **The current inputs.** `currentInputs(route)` is computed from
+ box-local state only: the installed build (`route.Version`) and a
+ fingerprint of the instance's delivered config files.
+ - **Serving.** A page is served only while its tag equals the current
+ inputs. A sleeping instance whose build or config changed misses at
+ once and wakes.
+ - **Storing.** A page is stored only when the process answering was
+ started from exactly the current inputs, both when the render began
+ and when it finished. The activator publishes a process's inputs at
+ the moment it becomes current (`noteCurrent`, or a non-staged spawn),
+ never at staging.
+ - **What follows:** a same-build, same-config wake keeps its pages,
+ and an old process still serving during a staged switch never
+ stores.
+- **Unit-backed instances** (`route.Backing == registry.BackingUnit`)
+ are refused in v1: always `bypass` and documented, with a follow-up
+ for a root-to-agent inputs signal (R2-3).
- **Not in this slice:**
- far boxes, leases and pushes;
- single-flight: the spec's Join (§6.1) arrives with far fills in
@@ -43,10 +70,12 @@ repo root.
- **Coverage:** slice 1 is §11 item 1. The sections it builds are §4,
§5, §6, §8.1 (home side), §8.6 and §10.
- **One change of mechanism:** §8.6's "clear on a new release or config"
- is implemented as serving-identity tagging. Entries from an earlier
- identity become unreachable at the moment the new process answers,
- which is the same guarantee without a hook that could fire early or
- late. Plan round 1 showed both hooks did.
+ is implemented as the current-inputs invariant above. Entries tagged
+ with earlier inputs are unreachable as soon as the inputs change,
+ whether or not the instance is awake. That is the same guarantee
+ without a hook that could fire early or late. Plan round 1 showed both
+ hooks did.
+- **One cut:** unit-backed instances are left out of v1 (Paul's choice).
**Branch:** `edge-page-cache-1`, cut from `main` after
`design-edge-page-cache` (spec and this plan) has merged (stopping rule
@@ -58,7 +87,10 @@ repo root.
- The marker header is exactly `Carlos-Page-Cache`. Value `on`, with an
optional `; ignore-cookies="a,b"` parameter.
- The edge strips it from every final response, every 1xx response and
- every trailer, on every box, armed or not **(P1-7)**.
+ every trailer, on every box, armed or not, local or backhauled
+ **(P1-7, R2-4)**.
+- **One list:** every client-boundary scrub iterates
+ `clientScrubVocabulary`, and nothing keeps a list of its own.
- Lifetime is `s-maxage`, else `max-age`. It must be positive and is
capped at 365 days. `private`, `no-store` and `no-cache` refuse.
@@ -81,14 +113,16 @@ repo root.
**Eligible requests** (`pageRouteEligible`):
- **The route:** `Kind == "instance"`, not `IsForward()`, not `HA`, not
- `IsSidecar()`, `Status == "ready"`, `Gate == ""`, `ImportGate == ""`,
- `!PagesOff`.
+ `IsSidecar()`, `Backing != registry.BackingUnit`, `Status == "ready"`,
+ `Gate == ""`, `ImportGate == ""`, `!PagesOff`.
- **No path rows (P1-6):** neither the requested hostname's own entry in
`e.current()` nor its primary has path rows. The request was not
dispatched by path to another instance.
- **Asset prefixes:** the path is not under a prefix the serving build
declares, and the declaration is known **(P2-9)**.
-- **Identity:** the instance has a known serving identity.
+- **Inputs:** `currentInputs(route)` is known.
+- **Storing also needs** the answering process's published inputs to
+ equal `currentInputs(route)`, both at Begin and at Finish.
**Keys and scopes:**
- A **scope** is (account, app, instance), where the instance is the
@@ -112,8 +146,9 @@ resets page contents but keeps the mark, so the LRU stays off.
as absent (still stripped; a marked response still never enters the
LRU).
- **`Carlos-Cache: hit|miss|bypass`** goes on every response of an
- opted-in instance, and on every marked response, whether or not a body
- was recorded **(P2-10)**:
+ opted-in instance, and on every marked response, whatever the method,
+ eligibility or inputs, and whether or not a body was recorded
+ **(P2-10, R2-6)**:
- `hit`: served from the index;
- `miss`: the request was storable and the response was considered;
- `bypass`: everything else.
@@ -212,9 +247,9 @@ type Clear struct {
Hosts []string // nil = every host of the scope
Targets []Target // nil = everything on Hosts
}
-type Ticket struct{ Scope Scope; Epoch, Seq uint64; Identity string }
-type Info struct{ ValidAt uint64; Ignore []string; Identity string }
-type Miss int // MissNone (a hit), MissAbsent, MissCookies, MissIdentity
+type Ticket struct{ Scope Scope; Epoch, Seq uint64; Inputs string }
+type Info struct{ ValidAt uint64; Ignore []string; Inputs string }
+type Miss int // MissNone (a hit), MissAbsent, MissCookies, MissInputs
type Config struct {
Store *assetcache.Store
MarkDir string
@@ -225,14 +260,15 @@ type Config struct {
}
const MaxBody = 8 << 20
func Open(cfg Config) (*Index, error)
-func (x *Index) Begin(s Scope, identity string) Ticket
+func (x *Index) Begin(s Scope, inputs string) Ticket
func (x *Index) Reserve(t Ticket, k Key, contentLength int64) (*Pending, error)
func (p *Pending) Write(b []byte) (int, error)
func (p *Pending) Abort()
func (p *Pending) Finish(m assetcache.Meta, ignore []string) (published bool, err error)
func (x *Index) Clear(s Scope, c Clear) (seq uint64)
func (x *Index) Reset(s Scope)
-func (x *Index) Lookup(s Scope, k Key, identity string, cookieNames []string) (*assetcache.Entry, Miss)
+func (x *Index) Lookup(s Scope, k Key, inputs string, cookieNames []string) (*assetcache.Entry, Miss)
+func (x *Index) Sweep() int // drops records whose physical object the store no longer has; returns how many
func (x *Index) MarkOptIn(s Scope) error
func (x *Index) ClearOptIn(s Scope) error
func (x *Index) OptedIn(s Scope) bool
@@ -262,8 +298,8 @@ func (x *Index) Scopes() []Scope
- no clear in that range matches the logical key;
- **if it indexes:** it replaces the logical key's record. The
previous physical object is deleted after the lock is released.
- `Info.ValidAt` is set to the current sequence, and `Info.Identity`
- to `t.Identity`;
+ `Info.ValidAt` is set to the current sequence, and `Info.Inputs` to
+ `t.Inputs`;
- **if it doesn't:** it deletes only its own physical object and
returns `false`.
- **`Clear`:**
@@ -280,8 +316,7 @@ func (x *Index) Scopes() []Scope
- `Targets == nil` means everything.
- **`Lookup`:**
- finds the logical key's record under the current epoch;
- - requires `record.Identity == identity`, otherwise returns
- `MissIdentity`;
+ - requires `record.Inputs == inputs`, otherwise returns `MissInputs`;
- requires every cookie name to be in `Ignore`, otherwise
`MissCookies`;
- then calls `Store.Get(physical key)`. A miss there (evicted or
@@ -289,6 +324,10 @@ func (x *Index) Scopes() []Scope
- **`Open`** runs `Store.Retain(func(k) bool { return
!assetcache.IsPageKey(k) })` once, because an earlier process's
epochs are gone.
+- **`Sweep` (R2-8)** checks every record against `Store.Get` and drops
+ the dangling ones. The edge calls it on the asset sweep's tick
+ (`assetSweepEvery`). Records are then bounded by the store's own
+ entries plus what was published since the last sweep.
- **Opt-in marks:**
- each is one file per scope in `MarkDir`, named by the hex sha256
of `Account + "\x00" + App + "\x00" + Instance`;
@@ -298,10 +337,10 @@ func (x *Index) Scopes() []Scope
- [ ] **Step 1: Write failing tests** (a temp-dir store):
- **Publish and look up:**
- - `TestPublishThenLookup`: a hit with the same identity, and its
- body reads back.
- - `TestLookupNeedsIdentity`: publish under identity `b1`, then
- Lookup with `b2` → `MissIdentity`.
+ - `TestPublishThenLookup`: a hit with the same inputs, and its body
+ reads back.
+ - `TestLookupNeedsInputs`: publish under inputs `b1`, then Lookup
+ with `b2` → `MissInputs`.
- **Clears:**
- `TestClearRemovesMatching`: `/a`, `/a?x=1` and `/b` with path and
URL targets, as in rev 1.
@@ -327,6 +366,9 @@ func (x *Index) Scopes() []Scope
behind the index's back, then Lookup → `MissAbsent`, and the
record is gone.
- `TestOpenDropsEarlierPages`.
+ - `TestSweepBoundsRecords` (R2-8): with a store budget for about 10
+ entries, publish 500 distinct query keys and call `Sweep`. The
+ record count is ≤ the store's page entries, with no Reset.
- **Marks and size:**
- `TestOptInMarkSurvivesOpen`.
- `TestTooLargeAborts`.
@@ -349,7 +391,7 @@ func (x *Index) Scopes() []Scope
- **The setup:** 8 goroutines run 2000 random operations (300 under
`-short`) over 3 scopes. The scopes differ in account, app or
instance, with 2 hosts each, overlapping host names across scopes,
- 6 paths and 2 identities.
+ 6 paths and 2 input values.
- **The operations:** Begin + Reserve + Write + Finish, where
`afterCommit` randomly yields or sleeps 0–2 ms; Clear with random
targets; Reset; Lookup; MarkOptIn and ClearOptIn.
@@ -364,7 +406,7 @@ func (x *Index) Scopes() []Scope
seq > the body's ticket seq, matches its key;
- **I3:** the body's scope, host, path and query equal the Lookup's
arguments;
- - the identity equals the Lookup's identity.
+ - the inputs equal the Lookup's inputs.
- **Seeding:** the seed comes from `-seed` (default the time), and is
printed on failure.
- [ ] **Step 2: Write `TestStoreHoldsNoUnindexedPages`.** After the
@@ -426,120 +468,153 @@ func (x *Index) Scopes() []Scope
- [ ] **Step 5: Commit:** `registry: per-instance pages switch, mirrored
on assets_off`.
-### Task 5: The marker is read once, stripped everywhere, kept out of the LRU
+### Task 5: One scrub list; the marker is read once, stripped everywhere, kept out of the LRU
**Files:**
- Create: `internal/edge/pagemark.go`.
+- Modify `internal/edge/assetcatch.go` (Paul's choice, "One list, every
+ scrub"; R2-4):
+ - rename `assetVocabulary` (:966) to `clientScrubVocabulary` and add
+ `pageCacheHeader` to it;
+ - `stripAssetResponseHeaders`, `stripAssetTrailers`,
+ `assetInformationalScrub` and `scrubBackhaulResponse` (:1362) all
+ iterate it;
+ - `scrubBackhaulResponse` keeps only the entries its `assetFill`
+ argument names (the ack and expiry headers), by an explicit keep set
+ rather than a list of its own.
- Modify:
- - `internal/edge/assetcatch.go:966`: add `pageCacheHeader` to
- `assetVocabulary`, so `stripAssetResponseHeaders`,
- `stripAssetTrailers` and `assetInformationalScrub` all remove it;
- `internal/edge/cookiescope.go:85`: in `responseModifier`, call
- `takePageMark(resp)` before `stripAssetResponseHeaders`;
+ `takePageMark(resp)` before the scrub;
- `internal/edge/edge.go`:
- wrap the local proxy and activator calls (:2707–2730) in
- `assetInformationalScrub{w}`, as `edge.go:4285` already does for
- hops, so a local route's 1xx is scrubbed too;
+ `assetInformationalScrub{w}`, as `edge.go:4285` does for hops;
- `maybeStore` (:2907) refuses when `pageMarkOf(rec.request)` is
`Marked`.
-- Test: `internal/edge/pagemark_test.go`.
+- Test: `internal/edge/pagemark_test.go`,
+ `internal/edge/scrub_guard_test.go`.
**Interfaces:**
- Produces:
```go
+var clientScrubVocabulary = []string{assetFillHeader, assetAckHeader, assetExpiresHeader, assetCacheHeader, pageCacheHeader}
type pageMark struct{ Marked bool; Ignore []string; Bad bool }
func withPageMarkHolder(r *http.Request) *http.Request
func pageMarkOf(r *http.Request) *pageMark // nil when no holder
-func takePageMark(resp *http.Response) // parses the final response's header into the holder; never reads trailers or 1xx
+func takePageMark(resp *http.Response) // final response header only; never trailers or 1xx
const pageCacheHeader = "Carlos-Page-Cache"
```
- **Parsing:**
- `on` gives `Marked`;
- `on; ignore-cookies="a,b"` adds the names;
- anything else sets `Bad`.
-- **Where the holder goes:** ServeHTTP attaches it at the LRU point for
- every GET and HEAD it may cache or page-cache, before the activator or
- proxy runs.
+- **Where the holder goes (R2-6):** ServeHTTP attaches it for **every**
+ proxied request to a `Kind == "instance"` route, whatever the method,
+ before the activator or proxy runs.
- [ ] **Step 1: Write failing tests**
+ - **`TestEveryScrubRemovesEveryVocabularyEntry`** (the guard). For
+ each scrub function and each entry in `clientScrubVocabulary`:
+ - set the entry as a header, a trailer (announced and not) and on a
+ 1xx;
+ - run the scrub, and assert it's gone. `scrubBackhaulResponse` with
+ `assetFill=true` may keep only the ack and expiry headers.
+ - **The table of scrub functions** is listed in the test. A comment
+ says a new client-boundary scrub must be added to it.
- `TestPageMarkStrippedFinalHeader`: on an edge with no page index,
- the app sends the marker, and the visitor's response lacks it.
- - `TestPageMarkStripped103`: the app writes a `103` carrying the
- marker, then a 200. The client's informational response lacks it
- (use `httptrace.ClientTrace.Got1xxResponse`).
- - `TestPageMarkStrippedTrailers`: the app announces `Trailer:
- Carlos-Page-Cache` and sets it, and separately sets an unannounced
- trailer of that name. The client sees neither, and neither marks
- the page.
- - `TestPageMarkParses`: a table of values.
+ the visitor never sees the marker.
+ - `TestPageMarkStrippedThroughBackhaul` (R2-4): a mock older home
+ returns the marker on an ordinary backhaul. The visitor never sees
+ it, with page caching armed and unarmed.
+ - `TestPageMarkStripped103` (use
+ `httptrace.ClientTrace.Got1xxResponse`).
+ - `TestPageMarkStrippedTrailers`: announced and unannounced. Neither
+ marks the page.
+ - `TestPageMarkParses`.
- `TestMarkedResponseNeverEntersLRU`.
- `TestUnmarkedResponseStillUsesLRU`.
- [ ] **Step 2: Run them to see them fail.**
- [ ] **Step 3: Implement as above.**
-- [ ] **Step 4: Run them to see them pass,** plus `-run
- 'Asset.*Scrub|Vocabulary|Trailer'` for the neighbours.
-- [ ] **Step 5: Commit:** `edge: read and strip Carlos-Page-Cache
- everywhere; marked responses skip the LRU`.
+- [ ] **Step 4: Watch the guard fail** when one scrub reverts to a
+ private list. Restore it.
+- [ ] **Step 5: Run them to see them pass,** plus `-run
+ 'Asset.*Scrub|Vocabulary|Trailer|Backhaul'`.
+- [ ] **Step 6: Commit:** `edge: one client scrub list; read and strip
+ Carlos-Page-Cache everywhere`.
+
+### Task 6: The current inputs, and the inputs each process was started from
-### Task 6: The serving identity, recorded where processes start
+This is the invariant Paul chose ("One invariant + gate units"; R2-1,
+R2-2, R2-3).
**Files:**
-- Modify: `internal/edge/cache.go`: add the identity table, beside the
- existing indexes.
-- Modify: every activator site that calls `b.Cache.PurgeHost` on a
- process start:
- - `internal/activator/backend_exec.go:2298, :2573, :2852`;
- - `internal/activator/rootfs.go:427`;
- - `internal/activator/genbackend.go:362` (GenSwitched).
- Each also calls `b.Cache.NoteServing(rt.Host, identity)`.
-- Create: `internal/activator/servingidentity.go`.
-- Test: `internal/activator/servingidentity_test.go`,
- `internal/edge/cache_test.go`.
+- Create: `internal/activator/inputs.go`, holding the one function both
+ sides use.
+- Modify: `internal/activator/genservice.go:96` (`noteCurrent`), and
+ the exec spawn site that makes a process current without staging
+ (`backend_exec.go:2565–2575`, the `exe == ""` branch).
+ - **When a process is staged:** its inputs are captured when it
+ starts, and carried with it (on `genMember`, or the `Gen` the
+ staging returns).
+ - **When they are published:** only when it becomes current.
+- Modify: `internal/edge/cache.go`: a table of published inputs.
+- Test: `internal/activator/inputs_test.go`, `internal/edge/cache_test.go`.
**Interfaces:**
- Produces:
```go
-func (c *Cache) NoteServing(host, identity string)
-func (c *Cache) ServingIdentity(host string) (string, bool) // false until a start was noted in this agent process
-func servingIdentity(build string, configFiles []string) (string, error) // hex sha256 over the build and each config file's path and bytes, in a stable order
+// in internal/activator:
+func CurrentInputs(rt registry.Route, configFiles func(registry.Route) []string) (string, bool)
+// hex sha256 over rt.Version and each config file's path and bytes, in
+// a stable order; false when a file cannot be read. A missing file is
+// fingerprinted as absent, which is a valid state.
+func (b *ExecBackend) configFilesFor(rt registry.Route) []string
+// exactly the env files the spawn reads (readEnvFile at backend_exec.go:2421
+// and the sidecar env at :3355), so both sides fingerprint the same set
+// in internal/edge:
+func (c *Cache) NoteProcessInputs(host, inputs string) // the current process's launch inputs
+func (c *Cache) ProcessInputs(host string) (string, bool) // false until noted in this agent process
+func (c *Cache) SetCurrentInputs(f func(registry.Route) (string, bool)) // the host wires CurrentInputs here
+func (c *Cache) CurrentInputs(rt registry.Route) (string, bool)
```
-**What goes into the identity:**
-- **The build:** the build that process was started from. At
- GenSwitched it is the generation's build; at the other sites, the
- build the spawn launches.
-- **The config files:** every config file the activator hands that
- process, read at the start.
-
-**Rules:**
-- **Unreadable config:** `NoteServing(host, "")`. An empty identity
- means "unknown", and pages bypass for that instance.
-- **Wakes:** a wake of the same build and config computes the same
- identity.
-- **Other starts:** a site that starts a process but doesn't call
- `PurgeHost` today gets no identity, so its pages bypass. Name any such
- site in the commit message.
+**The rules:**
+- **The fingerprint cache:** `CurrentInputs` is called on every page
+ lookup. It caches each file's fingerprint by (path, size, mtime,
+ inode) and re-hashes only when those change. A lookup costs one
+ `stat` per config file.
+- **Unit-backed routes** never reach these. `pageRouteEligible` refuses
+ them (Task 7).
+- **The two sides must agree:** the inputs a process launches from are
+ computed by `CurrentInputs` over the same files, read at launch.
- [ ] **Step 1: Write failing tests**
- - `TestServingIdentityStableAcrossWake`: the same build and files give
- the same identity.
- - `TestServingIdentityChangesWithBuildOrConfig`: each change gives a
- different identity.
- - `TestUnreadableConfigGivesEmpty`.
- - `TestCacheNoteServing`: round-trip, and an unknown host → `false`.
- - **A focused activator test per start site, through the real
- backend:**
- - `TestExecSpawnNotesIdentity`;
- - `TestGenSwitchNotesNewIdentity`: a staged successor doesn't change
- the identity until the switch.
+ - **The function:**
+ - `TestCurrentInputsStable`: the same version and files give the
+ same value, twice.
+ - `TestCurrentInputsChanges`: a version change, a file edit, and a
+ file removal each give a new value.
+ - `TestCurrentInputsStatCache`: an unchanged stat doesn't read the
+ file again (count reads with a seam).
+ - **Through the real exec backend:**
+ - `TestNonStagedSpawnPublishesInputs`: a fresh spawn publishes
+ inputs equal to `CurrentInputs` at launch.
+ - `TestWakeSameInputsSameValue`: sleep, then wake with nothing
+ changed. The published inputs are unchanged.
+ - `TestStagedSuccessorPublishesAtSwitch`: stage a successor with new
+ inputs (native nested and rootfs backends). Until the switch,
+ `ProcessInputs` still returns the incumbent's inputs. After the
+ switch it returns the successor's, which are its launch-time
+ inputs, even if config changed again after it launched.
+ - **The table:** `TestCacheProcessInputs`, a round-trip, and an
+ unknown host → `false`.
- [ ] **Step 2: Run them to see them fail:** `go test
- ./internal/activator -run 'ServingIdentity|SpawnNotesIdentity|GenSwitchNotes'
+ ./internal/activator -run 'CurrentInputs|PublishesInputs|WakeSameInputs|StagedSuccessor'
-count=1` (with the task-owned `TMPDIR`).
- [ ] **Step 3: Implement as above.**
-- [ ] **Step 4: Run them to see them pass,** plus `-run 'Purge|Gen'` in
- `internal/activator`.
-- [ ] **Step 5: Commit:** `activator: record each instance's serving
- identity at process start`.
+- [ ] **Step 4: Run them to see them pass,** plus `-run
+ 'Purge|Gen|Swap'` in `internal/activator`.
+- [ ] **Step 5: Commit:** `activator: current inputs and per-process
+ launch inputs, published when current`.
### Task 7: Serving and storing pages on the home box
@@ -547,10 +622,12 @@ func servingIdentity(build string, configFiles []string) (string, error) // hex
- Create: `internal/edge/pagecache.go`, `internal/edge/pagerecord.go`.
- Modify: `internal/edge/edge.go`, at the LRU gate (:2673–2690) and the
proxy calls (:2707–2729).
-- Modify: `internal/host/assetpolicy.go`: add `DeclaresPrefix`
- **(P2-9)**.
-- Modify: `internal/edge/assettypes.go`: an optional interface for it.
+- Modify: `internal/host/assetpolicy.go`: add `DeclaresPrefix` and a
+ background declaration loader **(P2-9, R2-5)**.
+- Modify: `internal/edge/assettypes.go`: an optional interface for
+ `DeclaresPrefix`.
- Test: `internal/edge/pagecache_test.go`,
+ `internal/edge/pagecache_sim_test.go`,
`internal/host/assetpolicy_test.go`.
**Interfaces:**
@@ -558,59 +635,71 @@ func servingIdentity(build string, configFiles []string) (string, error) // hex
- Tasks 2, 5 and 6;
- `serveAssetEntry` (`assetserve.go:37`), `parseMaxAge`
(`edge.go:3110`), `canonicalAssetPath` (`assetcatch.go:47`);
- - `lookupUpstreamPath` (`edge.go:1761`).
+ - `assetManifestCache.cached` (`assetmanifests.go:64`).
- Produces:
```go
func (e *Edge) EnablePageCache(x *pageindex.Index)
func pageScopeOf(up upstream) pageindex.Scope // Account via release.RouteAccount(up.route), App, Instance = up.route.Host
-func (e *Edge) pageRouteEligible(host, path string, up upstream) (identity string, ok bool)
+func (e *Edge) pageRouteEligible(host, path string, up upstream) (inputs string, ok bool)
func pageReadable(r *http.Request) (cookieNames []string, ok bool)
func pageStorable(r *http.Request) bool
func pageAdmit(status int, h http.Header, mark *pageMark) (lifetime time.Duration, ok bool)
func (e *Edge) pagesOptedIn(up upstream) bool
-// host side, read through an optional edge interface:
type assetDeclarations interface{ DeclaresPrefix(host, build, path string) (declared, known bool) }
func (p *assetPolicy) DeclaresPrefix(host, build, path string) (declared, known bool)
+func (p *assetPolicy) WantDeclarations(acct, app, build string) // queue a background manifest read
```
-**Two details:**
-- **`DeclaresPrefix`** reads the release manifest through
- `p.manifests.paths`, whatever `AssetsOff`, the asset generation or the
- catch snapshot say. When the manifest hasn't been read, it returns
- `known=false`, and the page cache bypasses.
-- **`pageRouteEligible`** checks the requested hostname's own
- `e.current()[host]` entry for path rows, not only the dispatched
- upstream. It also refuses when that entry's `route.Host` differs from
- the dispatched `up.route.Host` (a path dispatch) **(P1-6)**.
+**Declarations (R2-5):**
+- **On requests:** `DeclaresPrefix` reads only
+ `p.manifests.cached(acct, app, build)`, with `build = route.Version`,
+ whatever `AssetsOff` says. It never reads storage on a request.
+- **When the cache has no entry:** it returns `known=false` and calls
+ `WantDeclarations`. That queues a background `p.manifests.paths` read
+ on the policy's own schedule, deduplicated and bounded.
+- **After the read:** later requests know the answer. An assets-off
+ instance goes from bypass to cacheable without a request-time read.
+
+**Eligibility:**
+- **Path rows (P1-6):** `pageRouteEligible` checks the requested
+ hostname's own `e.current()[host]` entry for path rows, and refuses a
+ path dispatch: that entry's `route.Host` differs from `up.route.Host`.
+- **Unit-backed routes** are refused.
+- **The inputs it returns** are `Cache.CurrentInputs(up.route)`. Not
+ known means not eligible.
**At the LRU gate:**
-1. **Whenever `pagesOptedIn(up)` holds,** whatever the path or
- eligibility, the LRU is off: `cacheable = false`. This is the one
- place §5.3's rule is checked.
-2. **When `pageRouteEligible` holds and `pageReadable` passes,** call
- `idx.Lookup(scope, key, identity, cookies)`.
- - On a hit, `serveAssetEntry(w, r, entry, now, "hit")`. Return only
- if it returned nil. On an error the writer is untouched, so
- continue down the miss path **(P1-8)**.
- - The Miss reason feeds the diagnostic in step 4.
-3. **When it is also `pageStorable`,** `t := idx.Begin(scope,
- identity)`. A `pageRecorder` reserves at WriteHeader if `pageAdmit`
- passes and `Content-Length` (when present) ≤ `MaxBody`, then tees.
- After the proxy returns:
- - a `Set-Cookie` trailer, an error or an overflow means `Abort`;
- - otherwise `MarkOptIn` (durable), then `Finish`;
- - Finish's meta uses `assetStoredHeader`, `Lifetime`, and
- `Expires = now + lifetime`.
-4. **The diagnostic writer** wraps every response of an eligible route,
- whatever the method. At WriteHeader it sets `Carlos-Cache` when the
+1. **Whenever `pagesOptedIn(up)` holds,** whatever the path, eligibility
+ or inputs, the LRU is off: `cacheable = false`. This is the one place
+ §5.3's rule is checked.
+2. **When eligible and `pageReadable`,** call `idx.Lookup(scope, key,
+ inputs, cookies)`. On a hit, call `serveAssetEntry(w, r, entry, now,
+ "hit")`, and return only if it returned nil. Otherwise continue down
+ the miss path **(P1-8)**.
+3. **When eligible and `pageStorable`,** and only when
+ `Cache.ProcessInputs(host) == inputs` (the answering process started
+ from the current inputs):
+ - `t := idx.Begin(scope, inputs)`;
+ - a `pageRecorder` reserves at WriteHeader if `pageAdmit` passes and
+ `Content-Length` (when present) ≤ `MaxBody`, then tees.
+ - **After the proxy returns:**
+ - abort on a `Set-Cookie` trailer, an error or an overflow;
+ - abort also if `CurrentInputs` or `ProcessInputs` no longer equal
+ `inputs`;
+ - otherwise `MarkOptIn` (durable), then `Finish`. Its meta uses
+ `assetStoredHeader`, `Lifetime`, and `Expires = now + lifetime`.
+4. **The diagnostic writer (R2-6)** wraps every proxied response of a
+ `Kind == "instance"` route on an armed box, independent of
+ eligibility and inputs. At WriteHeader it sets `Carlos-Cache` when the
instance is opted in or the holder says `Marked`:
- - `miss` when step 3 ran;
- - `bypass` otherwise, including a cookie miss, a POST and a HEAD
- miss.
- It never sets the header on other apps' responses.
+ - `miss` when step 3 recorded;
+ - `bypass` otherwise.
- [ ] **Step 1: Write failing tests** (a `newLAScene`-style scene with
- an asset store, a page index, and `NoteServing(host, "id1")`):
+ an asset store, a page index, and a fake config file):
+ - **The scene's inputs:** `SetCurrentInputs` wired to a test
+ `CurrentInputs`, and `NoteProcessInputs(host, CurrentInputs(rt))`
+ as a spawn would publish them.
- **The core path:**
- `TestPageMissThenHitWithoutApp`.
- `TestPageHitOnHibernatingRouteDoesNotWake`.
@@ -623,43 +712,80 @@ func (p *assetPolicy) DeclaresPrefix(host, build, path string) (declared, known
- `TestPageCookieRequestNotStoredAnywhere` (Review Focus 4).
- `TestPageIgnoredCookieHits`, `TestPageAuthorizationBypasses`.
- **Hit behaviour:** `TestPageHeadRangeConditional` (Review Focus 1).
- - **Identity:**
- - `TestPageNewIdentityMisses`: a hit under `id1`, then
- `NoteServing(host, "id2")` → `miss` that reaches the app.
- - `TestPageUnknownIdentityBypasses`: with no `NoteServing`, the
+ - **Inputs (R2-1, R2-2):**
+ - `TestPageSleepingNewBuildMisses`:
+ - cache a page, then mark the route hibernating;
+ - set `route.Version` to a new build without any spawn, and
+ Reload;
+ - request only the cached URL. It misses, and the activator is
+ asked to wake.
+ - `TestPageSleepingConfigChangeMisses`: the same, editing the config
+ file. A second variant removes it.
+ - `TestPageSameInputsWakeKeepsHits`: a wake with nothing changed
+ still hits.
+ - `TestPageOldProcessDuringStagingNotStored`: the current inputs
+ change while `ProcessInputs` still returns the old ones. A marked
response is `bypass` and isn't stored.
- - **Failed delivery:** `TestPageEvictedBetweenLookupAndOpenFallsThrough`
- (P1-8). Pause between Lookup and Open with a seam, delete the store
- object, and the response is the app's 200 with a body.
- - **Opt-in and the LRU:** `TestOptedInInstanceSkipsLRU`. A seeded LRU
- entry and an unmarked `s-maxage` path under a declared asset prefix
- both reach the app after opt-in.
- - **Path routing:** `TestPagePathRoutedHostRefused` (P1-6). Host A
- routes `/blog` to instance B, with B's own path map empty, and an
- alias of A. A marked answer through A or its alias is never stored,
- under either scope.
+ - `TestPageUnitBackedBypasses` (R2-3): `Backing: BackingUnit`. A
+ marked response is `bypass` and isn't stored.
+ - **Failed delivery:**
+ `TestPageEvictedBetweenLookupAndOpenFallsThrough` (P1-8).
+ - **Opt-in and the LRU:** `TestOptedInInstanceSkipsLRU`.
+ - **Path routing:** `TestPagePathRoutedHostRefused` (P1-6).
- **Asset prefixes:**
- - `TestPageAssetPrefixWinsWhenAssetsOff` (P2-9): an `AssetsOff`
- route whose release declares `/assets/`. A marked `/assets/x` is
- not stored.
- - `TestPageUnknownDeclarationBypasses`.
- - **Diagnostics:** `TestPageDiagnostics` (P2-10), a table:
+ - `TestPageAssetPrefixWinsWhenAssetsOff` (P2-9).
+ - `TestPageDeclarationsLoadInBackground` (R2-5). An assets-off
+ instance's first marked request is `bypass`, with no storage read
+ on the request path (assert with a counting manifest store).
+ After the background load, the next one is stored, and a marked
+ `/assets/x` never is.
+ - **Diagnostics:** `TestPageDiagnostics` (P2-10, R2-6), a table:
- hit → `hit`;
- stored miss → `miss`;
- a cookie-rejected lookup → `bypass`;
- - a marked POST → `bypass`;
+ - the first marked POST on a not-yet-opted-in instance → `bypass`;
+ - a marked GET with unknown inputs → `bypass`;
- a HEAD miss → `bypass`;
+ - an opted-in instance made temporarily ineligible → `bypass`;
- an unrelated app → no header.
- **Ineligible routes:** `TestPageIneligibleRoutes`, the table from
- rev 1.
+ rev 1 plus unit-backed.
- **Host side:** `TestDeclaresPrefixIgnoresAssetsOff`.
-- [ ] **Step 2: Run them to see them fail:** `go test ./internal/edge
- -run 'TestPage|TestOptedIn' -count=1` (with the task-owned `TMPDIR`),
- and `go test ./internal/host -run DeclaresPrefix -count=1`.
-- [ ] **Step 3: Implement as above.**
-- [ ] **Step 4: Run them to see them pass,** then `-run
+- [ ] **Step 2: Write `TestEdgeSimulationNoPersonalLeak` (I2;
+ R2-7).**
+ - **The setup:** a fake app whose every body names the request's
+ provenance (a request id, plus whether it carried `Cookie` or
+ `Authorization`).
+ - **The run:** 1000 random requests (200 under `-short`) over 2
+ instances and 4 paths, mixing:
+ - anonymous requests, requests with ignorable cookies, requests with
+ session cookies, and requests with `Authorization`;
+ - marked and unmarked `s-maxage` responses;
+ - LRU entries stored before opt-in;
+ - opt-in transitions;
+ - gate add and remove reloads;
+ - clears.
+ - **The assertion:** whenever a response comes from either cache (no
+ app call for that request), its body's provenance is anonymous. The
+ one exception is a request carrying only ignorable cookies, which
+ may get an anonymous body.
+ - **Seeding:** the seed is printed on failure.
+- [ ] **Step 3: Run them to see them fail:** `go test ./internal/edge
+ -run 'TestPage|TestOptedIn|TestEdgeSimulation' -count=1` (with the
+ task-owned `TMPDIR`), and `go test ./internal/host -run DeclaresPrefix
+ -count=1`.
+- [ ] **Step 4: Implement as above.**
+- [ ] **Step 5: Watch each guard fail under its own mutation,** then
+ restore:
+ - drop `maybeStore`'s marked refusal → the simulation or
+ `TestMarkedResponseNeverEntersLRU` fails;
+ - drop the opted-in LRU gate → the simulation or
+ `TestOptedInInstanceSkipsLRU` fails;
+ - drop the inputs check in Lookup → `TestPageSleepingNewBuildMisses`
+ fails.
+- [ ] **Step 6: Run them to see them pass,** then `-run
'Cache|Asset|Purge'` for the neighbours.
-- [ ] **Step 5: Commit:** `edge: home-box page cache at the LRU point`.
+- [ ] **Step 7: Commit:** `edge: home-box page cache at the LRU point`.
### Task 8: Clears reach the index (header, socket and `all`)
@@ -695,7 +821,8 @@ today, then calls `clearPages` for each host with the same targets:
**Socket channel.** `{"path":"all"}` does the same, and every other
socket path also calls `clearPages`. Activator start sites still call
-only `PurgeHost`, plus Task 6's `NoteServing`. They never clear pages.
+only `PurgeHost`, plus Task 6's `NoteProcessInputs`. They never clear
+pages.
- [ ] **Step 1: Write failing tests**
- `TestPurgeHeaderClearsPage`.
@@ -726,8 +853,8 @@ only `PurgeHost`, plus Task 6's `NoteServing`. They never clear pages.
gate, a sidecar, a status that isn't ready): `Reset` only. The mark
stays, so the LRU stays off.
-Releases and config are not handled here: Task 6's identity covers
-them.
+Releases and config are not handled here. Task 6's current-inputs
+invariant covers them, checked on every lookup and store.
- [ ] **Step 1: Write failing tests**
- `TestRouteDepartureResetsAndClearsMark`.
@@ -766,9 +893,17 @@ func armEdgePageCache(getenv func(string) string, dataDir string, store *assetca
- **Declarations:** the asset policy's `DeclaresPrefix` reaches the edge
through the same `LocalAssets` value already passed to
`EnableAssetCache`.
+- **Current inputs:** the host wires `e.cache.SetCurrentInputs` to
+ `activator.CurrentInputs` with the exec backend's `configFilesFor`, at
+ the point the activator and the cache are both built
+ (`agent.go:334`).
+- **The sweep:** `EnablePageCache` registers `idx.Sweep` on the asset
+ sweep's tick (`assetSweepEvery`).
-- [ ] **Step 1: Write a failing test:**
- `TestArmPageCacheNeedsFlagAndStore`, a table.
+- [ ] **Step 1: Write failing tests**
+ - `TestArmPageCacheNeedsFlagAndStore`, a table.
+ - `TestAgentWiresCurrentInputs`: a focused agent test. After the
+ wiring, `Cache.CurrentInputs` answers for an exec route.
- [ ] **Step 2: Run it to see it fail.**
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run it to see it pass.**
@@ -798,8 +933,9 @@ func armEdgePageCache(getenv func(string) string, dataDir string, store *assetca
asset paragraph (:285–289). It covers the marker, lifetimes, the
`max-age=0` advice, ignorable cookies, what is never cached,
`Carlos-Cache`, the clear targets including `all`, that a new
- release or config stops old pages being served, and that asset
- paths win;
+ release or config stops old pages being served, that asset paths
+ win, and that unit-backed instances (`carlos-app@` units) are not
+ page-cached yet;
- a `### carlos instances set-pages` section;
- the `CARLOS_PURGE` row (:1186);
- `docs/site/rootfs.md:46` if needed.
diff --git a/docs/superpowers/plans/CODEX-FINDINGS-PAGE-CACHE-PLAN1-R2.md b/docs/superpowers/plans/CODEX-FINDINGS-PAGE-CACHE-PLAN1-R2.md
new file mode 100644
index 000000000..6e3f8a615
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-FINDINGS-PAGE-CACHE-PLAN1-R2.md
@@ -0,0 +1,100 @@
+- **R1 P1-1 — Resolved:** unique physical keys prevent a rejected render from replacing a published object.
+- **R1 P1-2 — Resolved:** `Delete` releases `s.mu` before calling `drop`.
+- **R1 P1-3 — Partly resolved:** serving identity replaces Version tracking, but sleeping updates and staged starts remain unsafe.
+- **R1 P1-4 — Partly resolved:** exec starts gain identity tracking; sleeping config changes and unit-backed delivery remain uncovered.
+- **R1 P1-5 — Resolved:** temporary ineligibility preserves the opt-in mark.
+- **R1 P1-6 — Resolved:** eligibility checks the requested host and rejects path dispatch.
+- **R1 P1-7 — Partly resolved:** local headers, informational responses and trailers are covered; final backhaul headers are not.
+- **R1 P1-8 — Resolved:** failed body opening falls through to the app.
+- **R1 P2-9 — Partly resolved:** independent declaration lookup is proposed, but its data source and build input remain incomplete.
+- **R1 P2-10 — Partly resolved:** cookie rejection is represented; marked POSTs and unknown-identity responses still lack the required wiring.
+- **R1 P2-11 — Partly resolved:** I1/I3 simulation and a publication guard are added; randomized I2 coverage and several mutation checks remain absent.
+- **R1 P2-12 — Resolved:** scratch uses disk-backed storage and the default Go cache.
+
+Reviewed `design-edge-page-cache` at `c006cd41ed172977b4edafda271dadda38eff299`. No files changed, subagents spawned, or tests run.
+
+1. **P1 — Tasks 6, 7 and 9: Sleeping instances can serve old pages indefinitely after a release or config change.**
+
+ **Evidence:** [Plan:489](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:489) updates identity at starts and switches; [plan:729](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:729) explicitly removes release/config handling from reload. However, [agent.go:3027](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/host/agent.go:3027) leaves sleeping instances to adopt the new build on their next wake. Config delivery likewise records delivery-on-wake without starting anything at [syncexec.go:1518](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/appconfig/syncexec.go:1518).
+
+ **Failure:** Cache a page under identity A, let the instance sleep, then install build B or deliver changed configuration. The identity table still contains A. Requests for that page hit before the activator, preventing the wake that would update the identity. Old pages remain servable until expiry, potentially 365 days.
+
+ **Fix:** Define both the active process identity and the effective inputs for the next start. Changed inputs on a sleeping instance must invalidate its old pages without requiring a wake. Add real-wiring tests for build changes, config changes and config removal while asleep, followed exclusively by requests for an already-cached URL. Retain the same-build, same-config wake test.
+
+ **Boundary:** Spec §8.6; release/config invalidation must work independently of cache misses.
+
+2. **P1 — Task 6: Two prescribed identity hooks publish a successor’s identity before it serves.**
+
+ **Evidence:** [Plan:489–494](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:489) adds `NoteServing` at every listed purge site. Nested staged successors call `spawnUnitFrom` at [genbackend.go:300](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/activator/genbackend.go:300), which unconditionally reaches the purge at [backend_exec.go:2849](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/activator/backend_exec.go:2849). Rootfs staged successors similarly reach `spawnRootfs` at [rootfs.go:271](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/activator/rootfs.go:271) and its purge at [rootfs.go:426](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/activator/rootfs.go:426). The actual serving switch happens later at [swap.go:787–796](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/activator/swap.go:787).
+
+ **Failure:** Successor B starts while A remains current. The new hook publishes identity B. A request then receives A’s page but stores it under B. After the switch, that old page passes B’s identity check. The prescribed “staged successor doesn't change the identity until the switch” test fails for these backends.
+
+ **Fix:** Capture the identity with the process, but publish it only when that process becomes current. Use the exact configuration snapshot consumed by the launch, carrying it to `GenSwitched`; do not reread mutable config files there. Extend the staged-successor test to nested native and rootfs backends, including an old-process render between staging and switching.
+
+ **Boundary:** Spec §8.6; the cache identity must name the process that actually serves.
+
+3. **P1 — Task 6: Unit-backed instances never receive a usable identity.**
+
+ **Evidence:** [Plan:519](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:519) explicitly bypasses starts without an existing `PurgeHost` call. [UnitBackend.Start:146–162](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/activator/backend_unit.go:146) has no such call. `SplitBackend` dispatches unit-backed starts to that backend at [backend_unit.go:489–499](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/activator/backend_unit.go:489). Unit config delivery also runs separately at [unitsync.go:318](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/appconfig/unitsync.go:318).
+
+ **Failure:** A unit-backed instance sends a valid marker on every response but always fails the known-identity predicate. It never stores or serves pages. This excludes a supported home-box case; the spec explicitly describes unit-backed apps using response-header clears.
+
+ **Fix:** Specify an identity signal covering unit-backed starts, adoption of already-running units, and root-side release/config restarts. Capture the actual launched inputs through an appropriate root-to-agent interface. Add unit-backed fill/hit, release-change, config-change and same-build-wake tests through that wiring.
+
+ **Boundary:** Slice-1 coverage and spec §8.6; safe bypass does not deliver the required unit-backed feature.
+
+4. **P1 — Task 5: Final backhaul responses can still leak the marker.**
+
+ **Evidence:** [Plan:434–442](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:434) extends `assetVocabulary` and the local response hook. But [scrubBackhaulResponse:1362](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/edge/assetcatch.go:1362) deletes an explicit list of final headers rather than iterating that vocabulary. `assetInformationalScrub` leaves final responses untouched at [assetcatch.go:1379](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/edge/assetcatch.go:1379).
+
+ **Failure:** During a mixed-version rollout, an older home forwards an app’s `Carlos-Page-Cache` header. A newly updated receiving box still forwards that final header to the visitor.
+
+ **Fix:** Add unconditional marker removal to the final backhaul response scrub. Test a mock older home returning the marker through ordinary backhaul, with page caching both armed and unarmed.
+
+ **Boundary:** Unconditional marker stripping on every box. This concerns existing backhaul handling, not implementing far-box page caching.
+
+5. **P2 — Tasks 6 and 7: Declaration lookup lacks a complete source contract.**
+
+ **Evidence:** [Plan:577–580](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:577) says to call `p.manifests.paths` while returning unknown when the manifest has not been read. In fact, [assetmanifests.go:42–50](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/host/assetmanifests.go:42) fetches an uncached manifest from storage; `cached` is the read-only lookup. The existing loader refuses `AssetsOff` before loading manifests at [assetpolicy.go:302](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/host/assetpolicy.go:302). Task 6 also exposes only an opaque digest, while `DeclaresPrefix` requires the serving build.
+
+ **Failure:** Following `paths` adds storage reads to request eligibility. Following the stated unknown-until-loaded rule can leave assets-off instances bypassing permanently. A sleeping instance’s retained digest does not supply the build needed for the declaration lookup.
+
+ **Fix:** Retain the build alongside the fingerprint. Specify background declaration loading independent of asset-catching eligibility, then use `cached` on requests. Test an assets-off instance progressing from unknown declarations to cacheable pages without a request-time storage read.
+
+ **Boundary:** Declared asset-prefix ownership and workable identity/declaration interfaces.
+
+6. **P2 — Tasks 5 and 7: The diagnostic writer cannot produce all prescribed results.**
+
+ **Evidence:** [Plan:460](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:460) attaches the marker holder only to GET and HEAD. [Plan:604–609](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:604) requires that holder to identify marked POSTs and installs the writer only for eligible routes. Known identity is itself an eligibility condition at [plan:91](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:91).
+
+ **Failure:** A marked POST on an instance not yet opted in has no holder, so it gets no diagnostic. An unknown-identity response gets no diagnostic writer, contradicting `TestPageUnknownIdentityBypasses`.
+
+ **Fix:** Attach marker observation to every applicable proxied method. Install diagnostics independently of cache admission and known identity. Test a first marked POST, an unknown-identity marked GET, and an opted-in instance that becomes temporarily ineligible.
+
+ **Boundary:** The promised `Carlos-Cache` visibility.
+
+7. **P2 — Tasks 3 and 7: Required I2 verification remains missing.**
+
+ **Evidence:** The simulation operations and assertions at [plan:348–367](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:348) contain no cookie/Authorization provenance or LRU operations. The mutation list at [plan:380](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:380) covers publication fencing and the key guard. [Spec:743–771](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/specs/2026-11-08-edge-page-cache-design.md:743) additionally requires I2 assertions and independently demonstrated cache-separation fences.
+
+ **Failure:** The simulation can pass if the edge re-enables a personalized pre-opt-in LRU entry during an opt-in transition. The added index ownership assertions cannot detect that defect.
+
+ **Fix:** Add randomized edge operations with cookie/Authorization provenance, pre-opt-in LRU entries and opt-in/predicate transitions. Assert that neither cache serves forbidden provenance. Watch the marked-response and opted-in-LRU guards fail under their own mutations.
+
+ **Boundary:** Required evidence for I2 and spec §12.
+
+8. **P2 — Task 2: Eviction leaves unbounded index metadata.**
+
+ **Evidence:** [Plan:250](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:250) retains a record for each logical key. Evicted records are removed only when that same key is looked up at [plan:287](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md:287). Store eviction calls `drop` independently at [evict.go:25](/home/paulca/amadan.net/carlos/platform-design-edge-page-cache/internal/assetcache/evict.go:25), without notifying the page index.
+
+ **Failure:** Repeated requests with distinct queries publish distinct records. The disk store remains within budget, but records for evicted objects accumulate in memory because those queries are never requested again.
+
+ **Fix:** Specify bounded index retention or eviction reconciliation owned by the index. Test many distinct keys against a small store budget and assert that metadata remains bounded without a final Reset.
+
+ **Boundary:** Shared-cache resource bounds and store/index lifecycle.
+
+No P3 findings.
+
+The release/config and marker-stripping fault families recur from round 1, triggering stopping rule 2. Before another repair cycle, choose an upfront gate, a feature cut, or one centrally enforced invariant with guard tests or simulation. I recommend the centrally enforced invariant for both families.
+
+**NOT READY**
\ No newline at end of file
diff --git a/docs/superpowers/plans/CODEX-REVIEW-BRIEF-PAGE-CACHE-PLAN1-R3.md b/docs/superpowers/plans/CODEX-REVIEW-BRIEF-PAGE-CACHE-PLAN1-R3.md
new file mode 100644
index 000000000..fe844ce2d
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-REVIEW-BRIEF-PAGE-CACHE-PLAN1-R3.md
@@ -0,0 +1,97 @@
+# Review brief: edge page cache plan 1 (home box), round 3 of 3
+
+Repo carlos/platform, branch `design-edge-page-cache`, the commit named in
+your prompt.
+Under review: `docs/superpowers/plans/2026-11-08-edge-page-cache-plan-1-home.md`.
+Authorities: the approved spec
+`docs/superpowers/specs/2026-11-08-edge-page-cache-design.md` (rev 4, approved
+by Paul; it merges together with this plan), and the code on this branch
+(`internal/edge`, `internal/assetcache`, `internal/registry`,
+`internal/provision`, `internal/console`, `internal/host`, CLI files in the
+repo root).
+
+You are an independent reviewer and the engineer who will implement each
+task with only the plan and spec in hand. Check every file, line, signature
+and behaviour the plan names against the code.
+
+## Fixed: do not re-argue
+
+- The spec's design, its rulings in §16, and Paul's rule-2 choices:
+ - one page index per box owns every publish, clear, reset and lookup;
+ - an opted-in instance never uses the LRU.
+- The slice boundary: home box only, with no far boxes, leases, pushes or
+ single-flight.
+
+## What to check
+
+1. **Fit with the spec.** Does each task deliver what spec slice 1
+ (§11 item 1) needs, with nothing in the spec's invariants I1 (home
+ side), I2 and I3 left untested? Does any task contradict the spec?
+2. **Fit with the code.**
+ - Are the named sites real, and are the signatures workable? Pay
+ particular attention to:
+ - where `ModifyResponse` runs relative to the recorders (Task 5's
+ context holder);
+ - the LRU gate (Task 6);
+ - `applyPurgeTargets` and `ListenControl` (Task 7);
+ - `OnReload` and the Version signal (Task 8);
+ - the config-delivery hook (Task 9).
+ - Does anything the plan relies on not exist?
+3. **Safety.** Could a task as written:
+ - serve a personalised page;
+ - serve a page after a clear;
+ - leak the marker;
+ - let the asset sweep or store eviction break the index;
+ - or make a wake clear pages?
+4. **Tests.** Does each test fail for the right reason before the change
+ and prove the behaviour after it? Name any missing test for a real
+ failure mode.
+5. **Order and size.** Can each task be built and pass its tests with
+ only the earlier tasks done?
+
+## Round 3
+
+Earlier rounds: `CODEX-FINDINGS-PAGE-CACHE-PLAN1-R1.md` (plan rev 1) and
+`CODEX-FINDINGS-PAGE-CACHE-PLAN1-R2.md` (plan rev 2). This is the last
+round in the budget.
+
+First give one line per round-2 P1 and P2: resolved, partly, or not. The
+plan's "(R2-n)" marks show where each was answered. Carry unresolved ones
+forward at their severity, then add new findings. The verdict covers
+everything outstanding.
+
+Stopping rule 2 fired after round 2, and Paul chose the fixes (see the
+plan's header). These are fixed; report only a mechanism that fails to
+deliver them:
+- **Release and config freshness:** one current-inputs invariant, with
+ unit-backed instances refused in v1;
+- **Marker stripping:** every scrub iterates one vocabulary list, with a
+ guard test.
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work.
+ Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review.
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for
+ another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not
+raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives:
+- the task;
+- the problem;
+- the evidence (file:line, verified);
+- the failure scenario;
+- a concrete fix;
+- the invariant or boundary it breaks.
+
+End with exactly one verdict: **READY**, **READY AFTER FIXES**
+(no P1; the P2s are fixed without another round), or **NOT READY** (P1s
+listed).
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites.