spec: config receipts (#522) rev 2, builder check settled
Root pass memory, fleet boxes, sleeping units, moves, last_delivered.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/specs/2026-11-02-config-receipts-design.md+103 −28
CI cancelled — superseded by a newer push — run details
Intent
<task-notification> <task-id>a0f3eaac8eaa12178</task-id> <tool-use-id>toolu_01QFAwFMRhTws9M5PqbHmCrB</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/4c585ebb-d953-40f5-8f58-fbd337832024/tasks/a0f3eaac8eaa12178.output</output-file> <status>completed</status> <summary>Agent "Builder check on #522 spec" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>I'd need five questions answered before planning this well, plus one the spec already flags for review. Plan 1 (versions, digests, conditional writes, receipts) is clear enough to plan as written. All but the last question concern Plan 2, and the top two affect cost and scope. 1. **Where should the root pass remember the last ack it wrote?** §5.3 says the writer keeps it in memory and reads the bucket "only after a restart of the writer". But the root pass that writes acks for unit and named-unit routes is a oneshot process: `carlos adopt`, run hourly by `carlos-adopt.timer` and on request by `carlos-config-sync.service` (`internal/host/units/`). Every run is a restart, so each pass would read the bucket once per unit route. That breaks the "no new per-box bucket traffic" promise. - **Why it matters:** the options are a root-owned cache file on disk (new root state, which goes into the census section), accepting one read per route per pass, or a different way to detect change. Each gives a different plan and a different cost. 2. **Are customer-fleet boxes in scope for Plan 2?** Fleet boxes reach the bucket through the edge's store door. Its write rule (`aclWrite`, `internal/edge/storedoor.go:644`) allows only `fleets/<fleet>/**` and the app log, error and analytics families. Writes to `control/config-ack/...` are refused, and `configAckFunc` only logs the failure. - **Why it matters:** if fleet boxes are in scope, Plan 2 needs a new ack location, a change to the edge door's rules, and console reads from two places. If not, every fleet route reads `unknown` forever. That decides whether Oficina's six apps get proof of delivery at all, so I'd also need to know where those apps run. 3. **What should a sleeping (scale-to-zero) route, or one waiting for a restart, say?** - The ack states have no "hibernating" entry. - The verdict table has no row for an ack in `restart-pending`, or for the `delivered (file)` answer in §5.5. - The root pass can't see a wake, because the activator starts the unit and the root pass only runs hourly or on request. - As written, a sleeping route whose file is current turns `stale` after 2 minutes, and `--wait` times out on it. Related to this: - §5.5 sends any changed invocation to `restart-pending`. That would include a deploy, a wake or a crash restart, even when the new process started after the file was written, so it really does have the config. - Because `process` is part of the change test, every wake would also cost a bucket write. - **Why it matters:** this sets the core verdict logic, which states end `--wait`, and the write cost for apps that sleep. 4. **Who owns the ack object during a move?** `WriteConfigAck`'s comment says nothing else writes that key, but other code does: - `RenderHeld` writes the same key with `MoveOp` and `FileSHA256`. - Landing a move waits for the ack to name the move (`movesoffline_land.go:938`). - The source's final step copies the ack and then deletes it (`movesfinal.go:664`). - Rollback reads it (`movesrollback.go:1582`). Once the sync pass writes on refusals and on any state change, it could overwrite a held render's ack and stall a move. Another writer could also make its remembered last ack wrong. - **Why it matters:** does the new writer skip held routes, keep the move fields, or should held renders write schema 2 as well? 5. **When an ack moves to `blocked` after an earlier success, should it keep a record of the last delivery?** `carlos relay status` (`relayMatchingAck`, `apirelay.go`) reads `RelaySuffixes` and `RestartError` from the latest ack. A blocked ack that replaces the delivered one drops those fields, so relay status would fall back to "written, awaiting delivery" while the process is still running the old config. - **Why it matters:** the answer decides whether schema 2 needs a "last delivered" section (versions, process, relay suffixes) alongside the current state, and whether relay status is allowed to go backwards. 6. **Should `config/effective` and `config/delivery` be Admin-only?** §4.8 flags this as the one open question for review. It only changes how the two doors are registered, so it matters least, but it's a ruling rather than a builder call. I'd fix these spec errors myself; they don't need answers: - `LoadMergedHostVersions` returns etags, not raw bytes, and the box sync sweeps deliberately don't use it (see its comment in `instances.go`). Both `config/effective` and the box-side versions need a new loader that returns each layer's bytes. - The deferred ack is at `internal/host/rollout.go:476`, not `rollout.go`. I checked all of this against the code in the worktree without editing anything, and created no scratch files.</result> <usage><subagent_tokens>129873</subagent_tokens><tool_uses>35</tool_uses><duration_ms>365251</duration_ms></usage> </task-notification>
Attributed to this commit: 11.9 g CO₂e (1,170,460 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-config-receipts-522, 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/specs/2026-11-02-config-receipts-design.md b/docs/superpowers/specs/2026-11-02-config-receipts-design.md| index fc15907d6..b1005c34f 100644 |
| --- a/docs/superpowers/specs/2026-11-02-config-receipts-design.md |
| +++ b/docs/superpowers/specs/2026-11-02-config-receipts-design.md |
| @@ -1,6 +1,6 @@ |
| # Config versions, digests and receipts: proving what a config change touched |
| -Status: DRAFT rev 1, 2026-11-02. Discussion: amadan carlos/platform #522 |
| +Status: DRAFT rev 2, 2026-11-02 (rev 2: builder check's five Plan 2 gaps settled, see §7 calls 6, 9-12). Discussion: amadan carlos/platform #522 |
| (filed by the Oficina Home agent; its consumer is oficina/home #103). |
| Branch `design-config-receipts-522`, cut from main `5394c7f9`. Every |
| file:line below is on that commit. |
| @@ -251,8 +251,11 @@ otherwise). Answer: |
| layer. An overlay is platform-written; its plain values are shown as they are |
| in the owner's other reads today (decided by the builder from what |
| `instances.go` already exposes; if nothing exposes them, digest only). |
| -- Read with the same loader boxes render from (`LoadMergedHostVersions`), so |
| - the answer cannot disagree with what a box would build. |
| +- Read with the same merge rules boxes render with. `LoadMergedHostVersions` |
| + returns etags, not bytes, and the box sweeps deliberately do not call it (see |
| + its comment in `instances.go`), so Plan 1 adds a loader that returns each |
| + layer's raw bytes alongside the merged manifest, built on the same merge |
| + functions. The box side uses the same loader in Plan 2 (§5.3). |
| ### 4.5 Conditional writes |
| @@ -449,7 +452,7 @@ is not: |
| Reusable: `renderedIdentity` (`claimsync.go:26`, a hash of the rendered file |
| plus which layers were present) is already computed by every writer; |
| -`LoadMergedHostVersions` returns every layer's raw read; `InstanceConfigDelivery` |
| +Plan 1's raw-bytes loader gives every layer's version; `InstanceConfigDelivery` |
| (`configack.go:164`) already has the delivered / stale / unknown-agent / |
| not-yet-delivered vocabulary, unused in production. |
| @@ -473,9 +476,18 @@ Additive to `ConfigAck`; `ConfigAckSchema` becomes 2. New fields: |
| |---|---| |
| | `state` | `delivered`, `restart-pending`, `restart-failed`, `blocked`, `file-only` | |
| | `reason` | for `blocked` and `restart-failed`: a code from a closed list (§5.4) | |
| +| `written` | when the file now on disk was written (the delivery event, not the ack time) | |
| | `versions` | `{"default": "cv1:…", "environment": "cv1:…", "overlay": "cv1:…"}` for the layers this render read, `"none"` for absent ones, omitted for ones the route does not resolve through (an owned environment has no `default`) | |
| | `rendered` | the `renderedIdentity` of the file written | |
| | `process` | see §5.5; absent when not known | |
| +| `last_delivered` | when `state` is not `delivered`: the last delivered ack's `versions`, `rendered`, `written`, `process` and `relay_suffixes`, carried forward. Absent if there never was one | |
| + |
| +`last_delivered` exists so a block after a success says what the process is |
| +still running ("blocked: not declared; running the config written 7 September"), |
| +and so `carlos relay status` (`relayMatchingAck`, `apirelay.go`), which reads |
| +`RelaySuffixes` from the latest ack, does not go backwards when a later pass is |
| +refused. Relay status reads `last_delivered.relay_suffixes` when the top-level |
| +ones are absent. |
| - Versions are computed on the box from the raw bytes it read, with the same |
| function the console uses (Plan 1 puts it in `internal/appconfig`), so the |
| @@ -487,12 +499,39 @@ Additive to `ConfigAck`; `ConfigAckSchema` becomes 2. New fields: |
| keeps its meaning. |
| **When it is written.** On every pass that evaluates the route, the writer |
| -compares the ack it would write with the one in the bucket (state, reason, |
| -versions, rendered, process; not the timestamp) and writes only if they |
| -differ. The writer keeps the last ack it wrote in memory, so an unchanged |
| -route costs no bucket request at all; the bucket is read only after a restart |
| -of the writer. This keeps the request budget at today's level plus one write |
| -per real change. Bucket requests cost money per box, so no new per-box polling. |
| +compares the ack it would write with the current one (state, reason, |
| +versions, rendered, written; not `process` alone and not the timestamp) and |
| +writes only if they differ. |
| + |
| +- The agent is long-running: it keeps the last ack it wrote per route in |
| + memory, so an unchanged route costs nothing; it reads the bucket only after |
| + it restarts. |
| +- The root pass is a oneshot (`carlos adopt`, hourly from `carlos-adopt.timer` |
| + and on request from `carlos-config-sync.service`). It has no memory between |
| + runs, so it reads each unit route's ack once per pass: one GET per unit |
| + route per pass, alongside the bundle reads that pass already makes. At the |
| + hourly floor that is about 720 GETs per route per month, a negligible cost. |
| + No root-owned cache file is added. (My call: new root state would cost more |
| + in census and review than the requests do.) |
| + |
| +A wake, a deploy or a crash restart does not rewrite the ack (§5.5), so apps |
| +that sleep cost nothing extra. |
| + |
| +**Moves.** A route held by a move is skipped by the ordinary sync passes |
| +today and stays skipped: its ack belongs to the move (`RenderHeld`, landing's |
| +check at `movesoffline_land.go:938`, the source's copy-and-delete at |
| +`movesfinal.go:664`, rollback at `movesrollback.go:1582`). `RenderHeld` writes |
| +the schema 2 fields too, keeping `MoveOp` and `FileSHA256`, so the console reads |
| +a held route like any other. The builder confirms in the plan that every new |
| +writer path (refusals included) is behind the same held-route skip. |
| + |
| +**Fleet boxes.** A box on a customer fleet reaches the bucket through the |
| +edge's store door, which lets it write only under `fleets/<fleet>/` and the |
| +app log families (`aclWrite`, `internal/edge/storedoor.go:644`). Today its |
| +config acks are refused and only logged. Plan 2 writes a fleet box's acks to |
| +`fleets/<fleet>/config-ack/<box>/<host>.json`, which the door already allows, |
| +and the console reads both prefixes. No change to the door. (My call: leaving |
| +fleets out would make every fleet route read `unknown` for good.) |
| **Who writes it**, by route shape: |
| @@ -521,16 +560,28 @@ owner looks) is answered by `carlos routes` and `env set` showing these. |
| "Delivered" must mean a process started after the file was written, not only |
| that the file is there. |
| -- **Units** (both unit shapes): after a successful restart, the root pass reads |
| - the unit's `InvocationID` and `ActiveEnterTimestampMonotonic` / wall time |
| - through the same systemd interface it restarted with, and records |
| +The process is recorded **at the delivery event only**, and the test is one |
| +inequality: the process that will read the config starts after `written`. |
| + |
| +- **Units** (both unit shapes), running at delivery: after a successful |
| + restart the root pass reads the unit's `InvocationID` and start time through |
| + the same systemd interface it restarted with, and records |
| `process: {"invocation": "…", "started": "<RFC 3339>"}`. `state: delivered` |
| - requires a start time after the file write. A unit that was not restarted |
| - (hibernating, or delivery wrote nothing new) keeps the previous ack's process |
| - if the invocation is unchanged; otherwise the state is `restart-pending`. |
| + requires `started` after `written`. A restart that fails is |
| + `restart-failed`. |
| +- **Units not running at delivery** (asleep, scaled to zero, stopped): nothing |
| + to restart, and the next start reads the file just written. `state: |
| + delivered` with `process: {"asleep": true}`. A later wake does not touch the |
| + ack: whatever starts after `written` has the config by construction, and the |
| + root pass cannot see wakes anyway. |
| +- **Later restarts** (a deploy, a crash, a wake) start after `written` too, so |
| + they never make a delivered route undelivered and never rewrite the ack. |
| + `restart-pending` is only for a pass that wrote the file and deliberately did |
| + not restart (a unit carlos may not restart yet, such as one held for a |
| + swap); the builder lists those cases from `sync.go` and `unitsync.go`. |
| - **Exec routes under the rollout scheduler**: the deferred ack |
| - (`rollout.go:476`) records the generation that started with this rendered |
| - revision: `process: {"generation": "…", "started": "…"}`. |
| + (`internal/host/rollout.go:476`) records the generation that started with |
| + this rendered revision: `process: {"generation": "…", "started": "…"}`. |
| - **Exec routes without the scheduler** (`syncexec.go` bounce): the bounce's |
| result and the new instance's start time, as far as the agent's own process |
| table knows it; otherwise `process` is absent and the console says |
| @@ -562,10 +613,12 @@ Verdicts: |
| | Verdict | When | |
| |---|---| |
| -| `delivered` | ack `delivered`, versions equal stored, process started after the write | |
| +| `delivered` | ack `delivered`, versions equal stored, and either a process started after `written` or the unit was asleep (shown as `delivered (asleep)`) | |
| +| `delivered (file)` | ack `delivered`, versions equal stored, exec route with no process record (§5.5) | |
| +| `restart-pending` | ack `restart-pending`, versions equal stored: the file is current and the process has not been restarted onto it | |
| | `pending` | versions differ and the latest stored write is younger than the grace window (default 2 minutes, the fast loop's convergence plus a restart) | |
| | `stale` | versions differ beyond the grace window | |
| -| `blocked` | ack `blocked` or `restart-failed`, with the reason | |
| +| `blocked` | ack `blocked` or `restart-failed`, with the reason and, from `last_delivered`, what the process is still running | |
| | `file-only` | ack `file-only`, versions equal | |
| | `not-delivered-by-carlos` | TCP-addr route not opted in | |
| | `unknown` | no ack, schema below 2, or the box is not reporting | |
| @@ -576,9 +629,11 @@ read. |
| The PUT's restart notice keeps its fields and gains nothing in Plan 2. The CLI |
| gains `--wait` on `env set` / `secrets set`: after the receipt it polls |
| -`config/delivery` for the app's routes until every verdict is `delivered`, |
| -`blocked` or `file-only`, or a timeout (default 2 minutes), and prints the |
| -outcome. Polling is the console reading acks the boxes already wrote; it adds |
| +`config/delivery` for the app's routes until every verdict is settled |
| +(`delivered` in any form, `blocked`, `file-only`, `not-delivered-by-carlos`), |
| +or a timeout (default 2 minutes), and prints each route's outcome. |
| +`restart-pending`, `pending` and `unknown` are not settled; at the timeout they |
| +are printed as they stand and the command exits non-zero. Polling is the console reading acks the boxes already wrote; it adds |
| no box-side traffic. |
| ### 5.7 Plan 2 tests |
| @@ -592,7 +647,13 @@ no box-side traffic. |
| | wrong storage: ack for another host or box | not matched; that box `unknown` | |
| | file written, restart failed | `blocked`, `restart-failed` | |
| | process started before the file write | not `delivered` | |
| -| unchanged route over many passes | no bucket write (asserted on a counting store) | |
| +| unit asleep at delivery, woken later | `delivered (asleep)`, then still delivered; no ack write on wake | |
| +| crash restart after delivery | still `delivered`; no ack write | |
| +| block after success | `blocked` carrying `last_delivered`; relay status unchanged | |
| +| route held by a move | ordinary pass writes nothing; held render's ack carries schema 2 fields | |
| +| fleet box | ack under `fleets/<fleet>/config-ack/`, read by the console | |
| +| unchanged route over many agent passes | no bucket request (counting store) | |
| +| unchanged route over many root passes | one GET per pass, no write (counting store) | |
| | box heartbeat stale | `unknown` | |
| | old agent (schema 1 ack) | `unknown` | |
| | reason text | always a code from the list; no tenant strings in acks | |
| @@ -606,8 +667,12 @@ Touches the root binary's packages: `internal/appconfig` (ack shape), |
| `internal/host` (root pass and agent writers), `internal/rollout` (generation |
| on the deferred ack), and `internal/console` plus the root CLI for the read. |
| What root newly does: writes an ack on the stamped path (an existing write |
| -class, to an existing prefix), writes on refusals, and reads a unit's |
| -`InvocationID` and start time from systemd after restarting it. It reads no |
| +class, to an existing prefix), writes on refusals, reads each unit route's ack |
| +once per pass (its own prior output, parsed into a fixed struct and used only |
| +for the change test), and reads a unit's `InvocationID` and start time from |
| +systemd after restarting it. The ack read is the one new read; it is root's |
| +own record, under `control/` (or the fleet's prefix), not tenant-written, and |
| +a malformed one only causes a rewrite. It reads no |
| new tenant input: reason codes are fixed, unit names come from the declaration |
| file root already trusts. Run `make census-card`, brief Astra from |
| `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`, record the verdict on |
| @@ -635,8 +700,18 @@ next platform release; no roll ordering beyond the usual dev first. |
| gate; flagged for review (§4.8). |
| 4. Precondition in the JSON body, header as optional synonym (§4.5). |
| 5. Audit rows gain versions, still never names (§4.6). |
| -6. Acks are written on state change only, with the last one cached in |
| - memory, so delivery proof adds no per-pass bucket traffic (§5.3). |
| +6. Acks are written on state change only. The agent caches the last one in |
| + memory; the root pass reads one ack per unit route per pass rather than |
| + keeping a root-owned cache file (§5.3). |
| 7. Grace window before `pending` becomes `stale`: 2 minutes (§5.6). |
| 8. `--wait` on `env set` / `secrets set` polls the console, not the boxes |
| (§5.6). |
| +9. Fleet boxes are in scope; their acks go under `fleets/<fleet>/`, which the |
| + store door already allows (§5.3). |
| +10. A process is recorded only when config is delivered; later restarts and |
| + wakes never rewrite the ack, and a unit asleep at delivery counts as |
| + delivered (§5.5). |
| +11. A block after a success keeps a `last_delivered` section, so the owner |
| + sees what is still running and relay status does not go backwards (§5.3). |
| +12. Routes held by a move keep their ack owned by the move; held renders gain |
| + the schema 2 fields (§5.3). |