spec rev 5.1, plan: cut cross-box response caching (Paul, rule 2)
Task 10's purge across boxes is replaced by: a case 3 request bypasses the response cache. Recorded in spec section 7.2 and plan Task 10.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+51
−34
docs/superpowers/plans/2026-11-19-path-routes-across-boxes.md+6 −12docs/superpowers/reviews/ASTRA-FINDINGS-path-routes-across-boxes-task10-R2.md+22 −0docs/superpowers/specs/2026-11-19-path-routes-across-boxes-design.md+23 −22
diff --git a/docs/superpowers/plans/2026-11-19-path-routes-across-boxes.md b/docs/superpowers/plans/2026-11-19-path-routes-across-boxes.md| index 06c07463f..d24855d6b 100644 |
| --- a/docs/superpowers/plans/2026-11-19-path-routes-across-boxes.md |
| +++ b/docs/superpowers/plans/2026-11-19-path-routes-across-boxes.md |
| @@ -316,22 +316,16 @@ Harness: a three-edge scene on the `BackhaulHolderScene` pattern: boxes A (hub), |
| **Review:** Astra task review (HA). |
| -### Task 10: Purge for a front host this box does not serve |
| +### Task 10: Case 3 bypasses the response cache (revised 2026-11-20) |
| -**Files:** |
| -- Modify: `internal/edge/purge_header.go` (`purgeOwns`, `resolvePurgeOwnersIn` and their callers at ~747, ~789), `internal/edge/pagecache.go` (`ownsHost`) |
| -- Test: `internal/edge/purge_across_test.go` |
| +Rev 4's Task 10 (purge across boxes) was built (c3897881, 1c9df470) and cut by Paul under rule 2 after two Astra rounds in the shared-host cache authority family; spec §7.2 (rev 5.1) records it. |
| -**Interfaces:** |
| -- Produces: `func (e *Edge) purgeOwnsIn(t *routeTable, owner registry.Route, host string) bool` replacing the free `purgeOwns` (a method, so it can read `e.homes`); callers pass the `*routeTable` they already loaded (`e.table()`). New branch for `host` not in `t.hosts`: true only when `t.remote[host]` has a prefix whose target is `owner.Host`, `t.remote[host].account == release.RouteAccount(owner)`, `e.homes.Load().exactPathRoute(host)` returns `Front` with matching account/app, and `t.hosts[owner.Host]` is `sameInstance` as `owner`. `resolvePurgeOwnersIn` takes `*routeTable` and accepts `Carlos-Purge-Host: <front>` under the same rule. |
| +**Files:** revert the functional changes of c3897881 and 1c9df470 (`internal/edge/purge_header.go`, `pagecache.go`, `pathselect.go`, the guard allowlists); modify the response-cache lookup and store in `ServeHTTP`'s cache stage (call only; logic in `pathhop.go`). Test: `internal/edge/path_across_cache_test.go`. |
| -- [ ] **Step 1: Write the failing tests.** `TestPurgeAcrossEvictsExactURL`, `TestPurgeAcrossEvictsPath`, `TestPurgeAcrossEvictsWholeHost` (tenant here, front not served here, entries cached under the front host: each purge drops them); `TestPurgeAcrossRefusedAfterPrefixMoves`; `TestPurgeAcrossRefusedForOtherAccount`. Existing `-run 'TestPurge'` tests stay green. |
| -- [ ] **Step 2: Run** `go test ./internal/edge/ -run 'TestPurgeAcross' -count=1` → FAIL. |
| -- [ ] **Step 3: Implement.** |
| -- [ ] **Step 4: Run** `-run 'TestPurge|TestPageCache'` → PASS. |
| -- [ ] **Step 5: Commit** `edge: a path target purges its pages under the front host (#186)`. |
| +- A request whose selected upstream carries `front != nil` (case 3) neither looks up nor stores in the response LRU. Purge code is today's. |
| +- Tests: `TestPathAcrossCase3NotCached` (a cacheable case 3 response is not stored; a second identical request reaches the backend again); `TestPathAcrossCase3NeverServedFromCatchAllCache` (a local catch-all's cached page under H is not served to a case 3 request for H's prefix); `TestPathAcrossSameBoxStillCached` (case 1 caching unchanged); `TestPurgeAcrossSkipped` (a target's `Carlos-Purge-Host: <front>` on a box that does not serve the front evicts nothing and errors nothing). |
| -**Review:** Astra task review (cache, security gate). |
| +**Review:** Astra task review (cache). |
| ### Task 11: Refuse a gate login for a cross-box target |
diff --git a/docs/superpowers/reviews/ASTRA-FINDINGS-path-routes-across-boxes-task10-R2.md b/docs/superpowers/reviews/ASTRA-FINDINGS-path-routes-across-boxes-task10-R2.md| new file mode 100644 |
| index 000000000..54bdadcf6 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/ASTRA-FINDINGS-path-routes-across-boxes-task10-R2.md |
| @@ -0,0 +1,22 @@ |
| +R1 P1-1 — **resolved**: foreign catch-all purges are denied through explicit hosts, `*`, cap degradation, and `all` expansion. |
| +R1 P1-2 — **partly resolved**: steady-state shadowed responses bypass the LRU, but an in-flight response can still be stored after shadowing and become unpurgeable. |
| + |
| +1. **P1 — The cache predicate does not protect the namespace across routing changes.** |
| + |
| + **Evidence:** [edge.go:2989](/home/paulca/.paseo/worktrees/03ai90xp/path-routes-across-boxes/internal/edge/edge.go:2989) evaluates `caseThreeCacheable` before proxying. The captured boolean subsequently permits [storage at edge.go:3051](/home/paulca/.paseo/worktrees/03ai90xp/path-routes-across-boxes/internal/edge/edge.go:3051), without rechecking or fencing a reload. Meanwhile, [purge_header.go:899](/home/paulca/.paseo/worktrees/03ai90xp/path-routes-across-boxes/internal/edge/purge_header.go:899) judges purge authority against the new table. |
| + |
| + **Failure scenario:** T begins a cacheable GET under unshadowed H. A foreign catch-all appears before the response finishes. The response is nevertheless stored. T then changes the underlying data and purges H; the purge is refused. Remove the catch-all before expiry, and T’s next GET can replay the invalidated response. This reproduces R1 P1-2 through the race explicitly acknowledged in the report. |
| + |
| + Existing entries also survive the opposite transition. The new test caches W’s foreign-account `/other` response, deletes W’s wildcard, and enables T’s caching under H. Reload does not clear W’s entry. T’s subsequent whole-host purge deletes it too; the test checks only T’s `/acme/page`. Thus the claimed exclusive namespace is not established merely by changing the predicate’s result. |
| + |
| + **Fix:** Enforce the existing structural ruling across namespace transitions: clear affected host entries when their cache authority changes, and fence outstanding recordings so they cannot repopulate the previous namespace. Coordinate publication, cache admission and storage; a standalone store-time check still leaves a check/store race. This can use host-level fencing without adding account tags to LRU entries. Add deterministic tests for an in-flight response crossing shadowing and for foreign entries surviving unshadowing. |
| + |
| + **Invariant / fault family:** **Shared-host cache authority**, repeating round 1. The namespace used for lookup, storage and purge must remain consistent across routing changes, not merely within one snapshot. |
| + |
| +The **foreign catch-all losing purge access to its own entries** is an acceptable consequence of the fixed ruling, with freshness bounded by TTL. The **in-flight store race is not acceptable as implemented**: it violates “a shadowed case 3 response is not stored” and recreates the failed-invalidation case. |
| + |
| +This is the second consecutive round in the same fault family, so stopping rule 2 applies before another fix. I recommend enforcing the already chosen invariant at the namespace transition boundary with guard tests. |
| + |
| +No files edited. Focused tests could not start because Go’s work directory was read-only; no full suite ran. GOCACHE remained unset. |
| + |
| +NOT READY |
| \ No newline at end of file |
diff --git a/docs/superpowers/specs/2026-11-19-path-routes-across-boxes-design.md b/docs/superpowers/specs/2026-11-19-path-routes-across-boxes-design.md| index 2e841f59b..5de4afd07 100644 |
| --- a/docs/superpowers/specs/2026-11-19-path-routes-across-boxes-design.md |
| +++ b/docs/superpowers/specs/2026-11-19-path-routes-across-boxes-design.md |
| @@ -1,6 +1,6 @@ |
| # Path routes across boxes: a prefix whose target lives on another box |
| -Rev 5, 2026-11-19. **Approved by Paul, 2026-11-19.** Discussion #186. Builds on the path-routing design |
| +Rev 5.1, 2026-11-20 (§7.2 cut by Paul during the build). Rev 5 approved by Paul 2026-11-19. Discussion #186. Builds on the path-routing design |
| (`2026-09-02-path-based-routing-design.md`, "the 09-02 design" below) and |
| changes none of its rulings except the one it was written to lift: §6's |
| "a prefix's target route must be homed on the same box as the hostname's |
| @@ -439,27 +439,28 @@ for a name the regional table holds on the box; a regional name is never a |
| front route or a target route. A cross-box target may be in another region: |
| that hop is an ordinary cross-region backhaul. |
| -### 7.2 Purge (round 1 P1-7) |
| - |
| -A target app emits `Carlos-Purge-Host: <front host>` (09-02's "what an app |
| -must do"). Its box holds the front host's entries for that target. Two |
| -guards must accept the front host, from one snapshot: |
| - |
| -- `resolvePurgeHost`'s path-routing branch, and |
| -- the execution guard `purgeOwns` (`applyPurgeTargets`) and the control |
| - channel's `ownsHost` (`pagecache.go`), which today refuse any host absent |
| - from `m`. |
| - |
| -Both accept a front host absent from `m` only when this box's remote map for |
| -it has a prefix selecting the purging route, the front route check of §5.3 |
| -holds, and the purging route is the current instance, with the existing |
| -account requirement. Tests evict real entries for an exact URL, a path and |
| -a whole-host purge, and refuse once the prefix or ownership changes. |
| - |
| -A hub's whole-host purge drops the hub box's entries only; tenant pages |
| -cached on other boxes are purged by their own apps. **My call:** |
| -acceptable, and arguably more correct than today, where a hub's |
| -`Carlos-Purge: *` also drops every co-located tenant's pages. |
| +### 7.2 Purge and the response cache (Paul, 2026-11-20) |
| + |
| +Rev 5 let a target box cache the target's pages under the front host and let |
| +the target purge them there. Building it (Task 10, Astra task rounds 1 and 2) |
| +found one fault family twice: a front shadowed on the target box by a local |
| +catch-all shares one cache namespace between two tenancies, and keeping |
| +"what may be cached" equal to "what may be purged" across routing changes |
| +needs host-level fencing in the cache path. Rule 2 applied and Paul chose to |
| +cut it: |
| + |
| +- **A request served by a case 3 local target (the front is not served on |
| + this box) never uses the response cache**: no lookup and no store. The page |
| + cache already excludes it (§5.5). Nothing is cached under the front on the |
| + target's box, so there is nothing to purge there, and no catch-all can |
| + serve or drop a tenant's page under the front. |
| +- **Purge is unchanged from today.** A target's `Carlos-Purge-Host: <front>` |
| + on a box that does not serve the front is skipped, as before. |
| +- **Same-box path routes keep caching**, exactly as today (case 1). |
| + |
| +Cost: cacheable pages of a tenant reached across boxes always reach the app, |
| +so a hibernating tenant wakes for them. Restoring it is a separate change |
| +(owner-tagged cache entries). |
| ### 7.3 The password gate (round 1 P2-8) |