plans: fleet first reconcile, Task 5 shared walk (Task 3 parked)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+118
−0
docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md+118 −0
Intent
Attributed to this commit: 15.2 g CO₂e (1,853,172 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on fleet-shared-walk, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md b/docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md| index 281471be1..e66c1a42a 100644 |
| --- a/docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md |
| +++ b/docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md |
| @@ -204,3 +204,121 @@ what that pass needs, not after every seed and a tick's sleep. |
| (Task 1's "duties: wait for the activator startup" line). The latch is a |
| safety order (sweep before wakes and before reconcile acts on seeded |
| records); any change gets its own task and review. |
| + |
| +### Task 3 request budget |
| + |
| +Steady state on a fleet box, nothing changing. A fleet box has no change |
| +index, so its record walks ride the existing instances loop (every 5 to 6 |
| +minutes, mean 5.5: about 262 passes a day). Each pass walks the records |
| +three times: reconcile at `instances/`, the sidecar pass at `sidecars/`, the |
| +moves pass at `instances/`. That is about 785 walks a day, the same before |
| +and after; no timer is added. Each walk also lists `accounts/` and reads |
| +every record (two GETs per record); both are unchanged and left out below. |
| + |
| +Per walk at the hub: the whole-tree listing costs W = ceil(N/1000) S3 LIST |
| +requests (N = objects under the account's `apps/<sqid>/`) and 1 door |
| +request. The per-app walk costs P = ceil((F + A)/1000) for the delimiter |
| +listing of `apps/<sqid>/` (S3 pages it over the F objects directly under |
| +it and the A app directories together), plus, per app, ceil(K/1000) for |
| +its K keys at the sub (one page for none), and 1 + A door requests. Both |
| +are priced exactly from the last whole-tree key set the box received. |
| +The walk takes per app only when P < W. It lists the whole tree when it |
| +has no memory (no memory file, an unusable one, or a root process) and |
| +every 12th walk. So with nothing changing a 12-walk cycle costs W + 11P |
| +if P < W, else 12W: never more than 12W. |
| + |
| +| account | N, A | W, P | S3 LISTs a day before | after | door requests a day before | after | |
| +|---|---|---|---|---|---|---| |
| +| small | 500, 2 | 1, 3 | 785 | 785 | 785 | 785 | |
| +| mid | 5,000, 20 | 5, 21 | 3,925 | 3,925 | 785 | 785 | |
| +| big (r10r estimate) | ~40,000, ~5 | ~40, 6 | ~31,400 | ~6,940 | 785 | ~4,380 | |
| + |
| +The r10r row is an estimate from timing (dev v0.37.0 startup lines): one |
| +whole `apps/` listing through the door took 3.8 to 4.6 s against about |
| +20 ms on a small account, which at 60 to 120 ms per S3 page plus the key |
| +list sent over the tunnel is roughly 30 to 60 pages (30,000 to 60,000 |
| +objects). A is assumed. Door requests are tunnel HTTP to the hub, not S3 |
| +requests; they go up only where S3 LISTs go down more. S3 LIST at |
| +$0.005 per 1000: big account about $0.16 a day before, $0.035 after. |
| + |
| +Witness: `TestScopedWalkNeverCostsTheHubMoreS3Lists` (internal/provision) |
| +counts the hub's S3 requests behind the real door for 24 steady-state |
| +walks per size. The bucket fake pages as S3 does (a delimiter page holds |
| +Contents and CommonPrefixes together), at a 10-key page so the fixtures |
| +stay small: small 24 = 24, mid 192 = 192, big 744 -> 150, and the review's |
| +case (20 apps, one record each, objects directly under the account |
| +outnumbering the apps ten to one) 816 = 816, per app never chosen. |
| + |
| +Changes are transients, not steady state: |
| + |
| +- **Shrink** (log retention empties the tree): per-app walks keep their |
| + price until the recheck, at most 11 walks (about 20 minutes at 3 walks |
| + per 5.5-minute pass). Worst case per shrink event: 11 x (P - 1) extra |
| + S3 LISTs, since the shrunk tree costs at least 1. For the r10r estimate |
| + (P = 6) that is at most 55 LISTs once, against about 31,400 a day saved. |
| + A restart in the window only brings the recheck sooner. |
| + `TestScopedWalkReturnsToTheWholeTreeAfterAShrink` (with and without a |
| + restart) shows the walk back on the whole tree within the cycle, and |
| + staying there. |
| +- **Growth**: whole-tree walks see it on the next walk; per-app walks see |
| + new apps and new keys at their sub on the next walk, and new objects |
| + directly under the account at the recheck. |
| + `TestScopedWalkGoesPerAppAfterAGrowth`. |
| + |
| +Restarts (walk memory file): the agent keeps the walk's cost inputs |
| +(whole-tree pages, objects directly under the account, app count, per-app |
| +pages per subdirectory, the walk count, the account and the box identity) |
| +in `<data dir>/record-walk-cost.json`. A restart's first walk on a big |
| +account is therefore per app instead of a whole-tree listing (r10r: about |
| +6 S3 LISTs instead of about 40, and 1 + A small door listings instead of |
| +a 4 s one). The file is local, so it adds no S3 request. A restart takes |
| +the walk count as the last checkpoint plus 3 and writes that back, so |
| +restarts only bring the recheck sooner, and a box restarted after every |
| +walk still rechecks within 3 restarts |
| +(`TestScopedWalkRecheckSurvivesRepeatedRestarts`). Each recheck costs what |
| +every walk cost before, so the table holds with any number of restarts. |
| +Local writes: the whole-tree listing, every 4th walk, a change in per-app |
| +cost, and one per restart: about 200 a day against 785 walks. A missing, |
| +special, oversized, linked, corrupt, old-format, other-version or |
| +other-box file is no memory: the whole tree, as before. |
| + |
| +## Task 3 outcome: parked (2026-11-16) |
| + |
| +The adaptive door-shaped walk (d941a849, then branch fleet-door-record-walk, |
| +tip 2e350661) reached AGENTS.md stopping rule 2: two review rounds in the S3 |
| +request budget family (Astra: page pricing assumes full S3 pages). Release |
| +manager 8a3d302 chose option C below. The branch stays unmerged; see #964. |
| + |
| +### Task 5: share one record walk across the legs of a pass |
| + |
| +Goal: fewer record walks per pass for every account size, so the steady-state |
| +request budget goes down or stays equal by construction (no pricing logic, no |
| +hub change). Dev v0.37.0 on r10r box-1: each walk lists the account's whole |
| +apps subtree over the door (~2.3 s per list on a big account) and a fleet |
| +box's first pass makes about 4 walks (offline view at arming, reconcile's |
| +record scan, the moves pass, and any others); the goal is 1-2. |
| + |
| +1. Inventory every record walk a pass and the arming path make (who calls |
| + `readAllRecordsJudged`, `listAppSubtree`, the record snapshot in |
| + recordview*.go, `refreshOfflineView`, the moves pass's own snapshot, the |
| + instances loop, the backstop). For each, cite the rule that says how fresh |
| + its read must be. In particular: moves spec §4.3 says the moves pass takes |
| + its own snapshot and is never handed reconcile's snapshot; moves spec §9.4 |
| + and movesoffline.go say the offline keep view must be read before any |
| + reconcile; R1 (stale-wake fence) and R2 (restore-required) and the region |
| + HA rules (§25, §7.5) may require fresh reads at decision points. Write the |
| + result as an explicit table in this plan ("Fresh-read rules"): leg, may |
| + reuse the pass's walk (yes/no), why, rule cited. |
| +2. Build one shared walk per pass (and at arming, the offline view's walk |
| + reused by the boot pass's reconcile if the rules allow), scoped to one |
| + pass, never cached across passes, never a timer. Legs marked "no" keep |
| + their own fresh walk. A spec rule that forbids reuse wins over speed; do |
| + not change any spec. |
| +3. Tests: a test that counts store calls per pass (whole-tree lists and record |
| + GETs) before and after, for a first pass and a steady-state pass, asserting |
| + after <= before; and witnesses that each "no" leg still reads fresh (a |
| + record changed between the shared walk and that leg is seen by it). |
| +4. Request budget: state per box per day with nothing changing, before and |
| + after, for small (1-3 apps), mid (~20) and big (r10r-sized) accounts. It |
| + must not go up for any size. |
| +5. Census as before (NAME=fleet-first-reconcile-speed-5). |