carlos / platform Public

feat: give one-copy stateless deploys a durable release id

Persist selected release IDs in the existing failure book and invalidate them
atomically with explicit retry clears. Cover restart reuse, record recovery,
terminal-phase reuse and durable-before-use behavior.

This is partial Task 2g progress: production rollout and first-wake
preparation are not wired. The rollout dependencies do not yet carry the
fresh record facts and combined canonical declaration observation required
by the no-duplicate-read contract. See the Task 2g controller report.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 43bb69b8ba49e8bb96319055e1886795c62c7b5f parent ac0c1ee
4 files changed, +278 −9
  • docs/superpowers/notes/census-proposal-stateless-replicas-1.md +5 −1
  • internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv +4 −1
  • internal/rollout/failures.go +66 −7
  • internal/rollout/stateless_test.go +203 −0

CI failed — run details

Intent

Human

<task-notification> <task-id>bscgoruys</task-id> <tool-use-id>toolu_01NoyeFXH6W3KKAVdhQC5E6K</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/412bbef6-9468-4e8d-b9fe-5343bad21de8/tasks/bscgoruys.output</output-file> <status>completed</status> <summary>Background command "Wait for Task 2f implementer" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 16.1 g CO₂e (1,843,450 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on stateless-replicas-1-runtime, 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/notes/census-proposal-stateless-replicas-1.md b/docs/superpowers/notes/census-proposal-stateless-replicas-1.md
index c89a4cbb4..e0a385e8d 100644
--- a/docs/superpowers/notes/census-proposal-stateless-replicas-1.md
+++ b/docs/superpowers/notes/census-proposal-stateless-replicas-1.md
@@ -11,10 +11,12 @@ Ruling `census-ruling-stateless-replicas-1`. The independent reviewer approves o
| `internal/host/agent.go` `fastTick` | body | unchanged (1) | Call coordinator Tick on the existing tick before convergence; client renews held terms only at the pinned interval. Existing registry read unchanged. |
| `internal/host/agent.go` `haRecordFacts` | body | unchanged (3) | Return RecordFacts with lifetime identity, Coordinator and ReplicaDeploy from the same judged record object; same store and record reads, no extra GET. |
| `internal/host/agent.go` `runAgent` | body | unchanged (6) | Construct coordination with existing fleet API credentials on fleet boxes, trusted deployment store otherwise; invalid fleet identity leaves it unarmed. Assign production observation callback, close after service shutdown with a five-second context. Existing read sites unchanged. |
+| `internal/rollout/failures.go` `FailureBook.saveLocked` | body | unchanged (0) | Persist the additive replica_releases selection carrier in the existing failure-book atomic write; no new path, record writer or authority. IDs are returned only after a successful save. |
+| `internal/rollout/failures.go` `OpenFailureBook` | body | unchanged (1) | Load the additive replica_releases carrier from the same existing failure-book ReadFile; unchanged schema acceptance, identity recovery, reconciliation and read site. No additional read. |
| `ship_check.go` `rootfsCheck.runArgs` | body | unchanged (2) | Stateless local checks mount only the run volume and omit the database mount; same probe read, no new read. |
| `internal/activator/rootfsrelease.go` `Service.runRelease` | sites | -registry:Host, -whole:Route ×10 | Delegate unchanged stateful admission and stop/proof behavior to runReleaseAdmitted with no durable admission hook; reads moved to that method. |
-Envelopes re-pinned: `.`, `internal/activator`, `internal/host`, `internal/provision`, `internal/release`, `internal/replicas`.
+Envelopes re-pinned: `.`, `internal/activator`, `internal/host`, `internal/provision`, `internal/release`, `internal/replicas`, `internal/rollout`.
Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
@@ -27,6 +29,8 @@ Recorded dispositions, which each change must still satisfy:
- `internal/host/agent.go` `fastTick`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=observes the change index before any pass (observeIndex), runs the backstop's requested full pass and a scoped pass for moved app scopes (indexTick), and arms the canary pointer gate on the sweep (canaryPointerGate) only on a tick whose own index observation succeeded; read site unchanged, offset moved
- `internal/host/agent.go` `haRecordFacts`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (region HA P1a), the agent as carlos: activator.Config.Record, the closure the HA classification calls on a lifetime index miss: opens the deployment store once (openDeployStore, kept under a mutex) and reads the host's record through judgedRecord(store, judge, release.RouteAccount(rt), rt.App, rt.Host) (CI fix: provision.ReadRecordJudged under the box's lifetime judge, which also GETs the host's incarnation slot control/host-incarnations/<host>.json from the same deployment store; a record the slot no longer vouches for, or a tombstone, reads as os.ErrNotExist; a nil judge, host claims on, is provision.GetRecord exactly), turned into a lifetime entry by provision.LifetimeEntryOf; the reads are the row it is handed (registry:App, registry:Host, whole:Route); the record is the console-written deployment record the reconcile passes already read; an open or read error is returned and the wake fails closed; root never calls it
- `internal/host/agent.go` `runAgent`: authority, task B,C,D,F. Basis: rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind
+- `internal/rollout/failures.go` `FailureBook.saveLocked`: authority, task E3. Basis: rev3=PROPOSED-p3;run=8;identity=root adoption uid 0 or legacy rollout uid carlos;basis=root instance uses checked store writer; legacy instances retain the original atomic file writer and epoch semantics
+- `internal/rollout/failures.go` `OpenFailureBook`: authority, task E1,E3,J1,J4. Basis: fix1-merge-review;basis=Loads schema-three durable generations and refuses unsafe identity recovery on entropy failure.
- `ship_check.go` `rootfsCheck.runArgs`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-1;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (rootfs Plan 1), builds the docker or podman run argv for one check container; the scanner matches the word Command, here a field of release.Process (a process's argv), not os/exec; reads no file; decides nothing for root;rev3=census-ruling-rootfs-check-volumes;basis=R2 P1: the data and run volume mounts (-v) now carry :nocopy through rootfsCheck.volumeMount, so Docker and Podman never fill an empty check volume from the image directory at the mount point (which would reset the prepared owner and mode); same volumes, same paths, same probe mount, nothing else in the argv changed. Runs on the person's machine as the person; no box unit; no read added.
- `internal/activator/rootfsrelease.go` `Service.runRelease`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1: new; the one place a release command runs. Refuses while any record of the host is open; skips the row's good build (releaseRan); reads the declared processes (declaredProcesses: the existing staged-manifest read) and refuses on a read error, never treating it as no release; runs only when releaseDue; needs a lease watch and a ReleaseBackend; its gate is the caller's plus the lease's Err and its safety deadline more than releaseStopLead (cmdStopBound, 2 min) away; creates the record under a.mu after releaseAdmitLocked; publishes the generations file and the build state (recordBuild) before anything runs; times out at the manifest's timeout_sec (default, capped at runs.MaxTimeout); ReleaseEnv; a supervisor stops the unit ahead of the lease's safety deadline; StartRelease under the exec gate; polls the unit (root's existing cmd status); stops and settles it (the existing cmd hold's stop, cmdStopBound); only a non-zero exit, a signal or the timeout with the unit proven gone is the build's failure (*ReleaseError); registry:Host sites are the record key and log lines;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 9: newCmdHold takes the hold's role; a release command's hold is instancectl.RoleCmd, the unit it runs in; nothing else changed, no read added
diff --git a/internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv b/internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv
index aa6233c2f..ed5ac5d9d 100644
--- a/internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv
+++ b/internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv
@@ -1,5 +1,5 @@
# Census overlay stateless-replicas-1, written by census-propose (#369). census-ruling-stateless-replicas-1, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-stateless-replicas-1.md.
-# 8 body, 1 sites, 6 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 10 body, 1 sites, 7 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
# 4 new dispositions: 0 reads re-frozen at their disposition with the claim, 4 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
@legacy 8532ad0b6523e01bb6548e7a0ff565615b99e39a8921c338db522812368899a3 cli.go runShip legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-1;basis=rootfs Plan 1 Task 9: takes --rootfs, --processes, --hibernate, --jit and --check and hands a rootfs ship to runShipRootfs (ship_rootfs.go) before the binary path; the --notes-file ReadFile moved into shipNoteText (its own row, the same read of the file the person named) and the direct-mode version mint into mintDirectVersion; one read site fewer, none added; Task 12: the --hibernate flag help is RFS-1-C32's new text, the same reads;rev3=census-ruling-edge-asset-cache-1;basis=takes --assets (repeatable), checks the folders with checkShipAssets (release.ValidAssetPaths; refused on a static site) before the mode split, carries them into the API meta (sess.shipAssets) and the direct-mode manifest (shipAssetsBlock), and passes them to runShipRootfs (rootfsShipOpts.assets), which runs the same check and carries them the same two ways; after a direct-mode ship has stored a release declaring folders, directShipAssetGens runs the console ship door's backfill (provision.MintMissingAssetGens: lists the app's record keys and gives each record without an asset generation one, a CAS write in the deployment bucket as the person running the CLI) and fails naming any record it could not mint; read sites unchanged (2), none added;rev3=census-ruling-rootfs-apps-4;basis=adds the repeatable --env flag and refuses it before anything else unless --check is given (shipEnvRefusal, parseShipCheckEnv); the parsed values go into rootfsShipOpts.checkEnv. --env values reach the check's local container runtime as -e argv only, never root, never a box. No read added; read sites unchanged (2).;rev3=census-ruling-stateless-replicas-1;basis=Carry --stateless into binary/API and rootfs ship options; same two read sites, no new read. file:ReadFile@7899,file:ReadFile@8123 d6f244d2c3bcae95eb8ec0fa7e57c52e9b50c7e9e2e00dda85f930b643731a51
@legacy 6cdd33926c20f85e6eeb7e15d78d04842cb9d59acbd6cb3fdde202c361a08d3e internal/activator/hawake.go ExecBackend.isHA legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: the one HA classification: a legacy route is not HA and reads nothing; else the lifetime index, and on a miss the record (Config.Record, the deployment store's console-written record via haRecordFacts); a failed read is an error; the row's sticky HA (+registry:HA) and the index's marks only add HA; +registry:Host x2, +whole:Route x2;rev3=census-ruling-stateless-replicas-1;basis=Extract LifetimeEntry from the extended Config.Record result; existing HA classification and read/error gates unchanged. registry:HA@573,registry:Host@280,registry:Host@486,whole:Route@126,whole:Route@373 8337ad81c8e8671acb44eacc642a1c43246a90d23ea69d35d1d7d7b58f2fcc89
@@ -18,6 +18,8 @@ internal/host/agent.go fastConvergeLoop authority B3 rev3=census-ruling-self-ser
internal/host/agent.go fastTick legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=observes the change index before any pass (observeIndex), runs the backstop's requested full pass and a scoped pass for moved app scopes (indexTick), and arms the canary pointer gate on the sweep (canaryPointerGate) only on a tick whose own index observation succeeded; read site unchanged, offset moved;rev3=census-ruling-stateless-replicas-1;basis=Call coordinator Tick on the existing tick before convergence; client renews held terms only at the pinned interval. Existing registry read unchanged. registry:Host@4776 717574378829734fb3461a7ec0a4e4e9089466745685d39008ad51b571ddf993
internal/host/agent.go haRecordFacts legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new (region HA P1a), the agent as carlos: activator.Config.Record, the closure the HA classification calls on a lifetime index miss: opens the deployment store once (openDeployStore, kept under a mutex) and reads the host's record through judgedRecord(store, judge, release.RouteAccount(rt), rt.App, rt.Host) (CI fix: provision.ReadRecordJudged under the box's lifetime judge, which also GETs the host's incarnation slot control/host-incarnations/<host>.json from the same deployment store; a record the slot no longer vouches for, or a tombstone, reads as os.ErrNotExist; a nil judge, host claims on, is provision.GetRecord exactly), turned into a lifetime entry by provision.LifetimeEntryOf; the reads are the row it is handed (registry:App, registry:Host, whole:Route); the record is the console-written deployment record the reconcile passes already read; an open or read error is returned and the wake fails closed; root never calls it;rev3=census-ruling-stateless-replicas-1;basis=Return RecordFacts with lifetime identity, Coordinator and ReplicaDeploy from the same judged record object; same store and record reads, no extra GET. registry:App@596,registry:Host@604,whole:Route@591 db6d777c93afde9836873ce72b6cbb62a55567eb3fb01f85f7e1e12274e0c66d
internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-stateless-replicas-1;basis=Construct coordination with existing fleet API credentials on fleet boxes, trusted deployment store otherwise; invalid fleet identity leaves it unarmed. Assign production observation callback, close after service shutdown with a five-second context. Existing read sites unchanged. file:Exec@17664,file:Open@1150,file:Statfs@45008,registry:App@11419,whole:Route@11411,whole:Route@28976 982510112e4bce377dddd0343847282cbc274e4e047fc01e67cd60ec139461e9
+internal/rollout/failures.go FailureBook.saveLocked authority E3 rev3=PROPOSED-p3;run=8;identity=root adoption uid 0 or legacy rollout uid carlos;basis=root instance uses checked store writer; legacy instances retain the original atomic file writer and epoch semantics;rev3=census-ruling-stateless-replicas-1;basis=Persist the additive replica_releases selection carrier in the existing failure-book atomic write; no new path, record writer or authority. IDs are returned only after a successful save. 443cdc68cd2c5cae070a81e4b0d98bbd8551adba8de795e18f5b505f4a03f1d7
+internal/rollout/failures.go OpenFailureBook authority E1,E3,J1,J4 fix1-merge-review;basis=Loads schema-three durable generations and refuses unsafe identity recovery on entropy failure.;rev3=census-ruling-stateless-replicas-1;basis=Load the additive replica_releases carrier from the same existing failure-book ReadFile; unchanged schema acceptance, identity recovery, reconciliation and read site. No additional read. file:ReadFile@136 b92f6a033f129bffb158e8768b1b14ee88e855f67c2f0da360c65c93d27d8cf8
ship_check.go rootfsCheck.runArgs legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-1;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (rootfs Plan 1), builds the docker or podman run argv for one check container; the scanner matches the word Command, here a field of release.Process (a process's argv), not os/exec; reads no file; decides nothing for root;rev3=census-ruling-rootfs-check-volumes;basis=R2 P1: the data and run volume mounts (-v) now carry :nocopy through rootfsCheck.volumeMount, so Docker and Podman never fill an empty check volume from the image directory at the mount point (which would reset the prepared owner and mode); same volumes, same paths, same probe mount, nothing else in the argv changed. Runs on the person's machine as the person; no box unit; no read added.;rev3=census-ruling-stateless-replicas-1;basis=Stateless local checks mount only the run volume and omit the database mount; same probe read, no new read. file:Command@887,file:Command@971 e684fd3273527a209460ed81e5bcd472a4282f46830fe580e5f07f0b0d876684
internal/activator/replicaobservation.go ObservedReplicaRelease legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Read route Account, App and Host only to match the attempt-local observation carrier; refuse absent/stateful/incomplete/mismatched evidence, return copied deploy state and canonical target. No store or filesystem read, no authority granted. registry:Account@283,registry:App@307,registry:Host@328 17cf71ccf92a913a42bef47ea461888ab0045b2ed7acabc81648e55cca322bbb
internal/activator/rootfsrelease.go Service.runReleaseAdmitted legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Extract existing runner unchanged except optional pre-exec durable release transition after local admission and before any command; same staged process reads, stop/proof and exec gates, no new filesystem path. registry:Host@216,whole:Route@3085,whole:Route@3314,whole:Route@3802,whole:Route@3831,whole:Route@5879,whole:Route@621,whole:Route@6347,whole:Route@6624,whole:Route@7054,whole:Route@849,whole:Route@934 de8d9d6b31ac2b8cf2c34aaca32ecfbdd2c8966f75def906e3baef5bb409d109
@@ -30,3 +32,4 @@ internal/activator/rootfsrelease.go Service.runRelease legacy accepted-legacy ac
@coverage internal/provision 80abfa28c9854d534818202aab9b1b4c09adb5d943b49a51e9efd77152d9a1ae
@coverage internal/release c1012571516227abff9612aba085e749489e8b8119c0b55444f53a15ed881fb1
@coverage internal/replicas 53b94eb040154539a0a977498b4b8bc1d53d82f67c1c6233667a0b823dd30d8a
+@coverage internal/rollout d95e28f37f3456b4b1fb38c848ffe310b2816ab4089347332b2f6b8cb9e02831
diff --git a/internal/rollout/failures.go b/internal/rollout/failures.go
index 04b50f5d7..32e7b9f69 100644
--- a/internal/rollout/failures.go
+++ b/internal/rollout/failures.go
@@ -17,6 +17,7 @@ import (
"github.com/carlosframework/platform/internal/activator"
"github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/replicas"
)
// FailureFile is the failure records' home in the agent's data dir (spec
@@ -226,9 +227,16 @@ const reconciledReason = "the agent restarted before this execution recorded its
// a file of schema 1 or 2 a new identity (rule 4).
const failureSchema = 3
+type replicaReleaseSelection struct {
+ Identity replicas.Identity `json:"identity"`
+ Target replicas.Build `json:"target"`
+ ID string `json:"id"`
+}
+
type failureFile struct {
- Schema int `json:"schema"`
- Records []FailureRecord `json:"records"`
+ ReplicaReleases map[string]replicaReleaseSelection `json:"replica_releases,omitempty"`
+ Schema int `json:"schema"`
+ Records []FailureRecord `json:"records"`
// HoldRan is the hold-ran markers by host. It is additive to schema 1: an
// agent that predates it ignores the key (encoding/json skips unknown
// fields), and a file without it has no markers.
@@ -376,10 +384,11 @@ func genKey(acct, app string) string { return acct + "/" + app }
// fails). Restoring or cloning a data dir must give the copy a new
// identity: drop the file's "book" key, and the open makes one (rule 4).
type FailureBook struct {
- write func([]byte) error
- path string
- mu sync.Mutex
- recs []FailureRecord
+ replicaReleases map[string]replicaReleaseSelection
+ write func([]byte) error
+ path string
+ mu sync.Mutex
+ recs []FailureRecord
// held is the hold-ran markers by host (HoldRan), saved with the records.
held map[string]HoldRan
// intents are the executions in flight by host (Intent), saved with the
@@ -523,6 +532,7 @@ func OpenFailureBook(dataDir string) (*FailureBook, error) {
if f.Schema != 1 && f.Schema != 2 && f.Schema != failureSchema {
return nil, fmt.Errorf("%s: unknown schema %d", b.path, f.Schema)
}
+ b.replicaReleases = f.ReplicaReleases
b.recs = f.Records
b.held = f.HoldRan
b.intents = f.Intents
@@ -741,7 +751,7 @@ func (b *FailureBook) saveLocked() error {
return nil
}
raw, err := json.MarshalIndent(failureFile{Schema: failureSchema, Records: b.recs, HoldRan: b.held, Seq: b.seq, Intents: b.intents,
- Book: b.idLocked(), Gens: b.gens, Durable: true}, "", " ")
+ Book: b.idLocked(), Gens: b.gens, Durable: true, ReplicaReleases: b.replicaReleases}, "", " ")
if err == nil {
if b.write != nil {
err = b.write(raw)
@@ -828,6 +838,14 @@ func (b *FailureBook) clearedLocked(acct, app, build, host string) {
b.cleared = map[[4]string]uint64{}
}
b.cleared[clearKey(acct, app, build, host)] = b.bumpLocked()
+ // Keep retry invalidation in the same durable save as the grant's clear.
+ // An empty ID is a retry marker, so record evidence cannot resurrect it.
+ for key, selected := range b.replicaReleases {
+ if selected.Identity.Account == acct && selected.Identity.App == app && selected.Target.Version == build && (host == "" || selected.Identity.Host == host) {
+ selected.ID = ""
+ b.replicaReleases[key] = selected
+ }
+ }
}
// Record writes r unless a record for its build already stands, in which case
@@ -1306,3 +1324,44 @@ func (b *FailureBook) List() []FailureRecord {
}
return out
}
+
+// ReplicaDeployID persists the selected release attempt before preparation can
+// acquire authority. Only a changed target/lifetime or an explicit retry changes
+// the ID. A durable terminal result never creates another attempt by itself.
+func (b *FailureBook) ReplicaDeployID(id replicas.Identity, target replicas.Build, observed *replicas.Deploy) (string, error) {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ if id.Account == "" || id.App == "" || id.Host == "" || id.Incarnation == "" || target.Version == "" || target.Digest == "" {
+ return "", replicas.ErrFenced
+ }
+ // A failed prior save must land before any selected ID can escape.
+ if err := b.retryLocked(); err != nil {
+ return "", err
+ }
+ key := id.Host
+ selected, exists := b.replicaReleases[key]
+ if exists && selected.Identity == id && selected.Target == target && selected.ID != "" {
+ return selected.ID, nil
+ }
+ next := ""
+ // Recover an attempt made by this or a previous box, unless the local
+ // durable selection explicitly invalidated it for a retry.
+ if !exists && observed != nil && observed.ID != "" && observed.Incarnation == id.Incarnation && observed.Target == target {
+ next = observed.ID
+ }
+ if next == "" {
+ var err error
+ next, err = newBookID()
+ if err != nil {
+ return "", err
+ }
+ }
+ if b.replicaReleases == nil {
+ b.replicaReleases = map[string]replicaReleaseSelection{}
+ }
+ b.replicaReleases[key] = replicaReleaseSelection{Identity: id, Target: target, ID: next}
+ if err := b.saveLocked(); err != nil {
+ return "", err
+ }
+ return next, nil
+}
diff --git a/internal/rollout/stateless_test.go b/internal/rollout/stateless_test.go
new file mode 100644
index 000000000..a07c27839
--- /dev/null
+++ b/internal/rollout/stateless_test.go
@@ -0,0 +1,203 @@
+package rollout
+
+import (
+ "errors"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/replicas"
+)
+
+func TestStatelessDeployIDSurvivesRestart(t *testing.T) {
+ dir := t.TempDir()
+ b, err := OpenFailureBook(dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ id := replicas.Identity{Account: "bab", App: "shop", Host: "example.com", Incarnation: "lifetime-1"}
+ target := replicas.Build{Version: "v1", Digest: "canonical-1"}
+ first, err := b.ReplicaDeployID(id, target, nil)
+ if err != nil || first == "" {
+ t.Fatalf("first selection = %q, %v", first, err)
+ }
+ again, err := OpenFailureBook(dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ same, err := again.ReplicaDeployID(id, target, nil)
+ if err != nil || same != first {
+ t.Fatalf("restart = %q, %v; want %q", same, err, first)
+ }
+ for _, phase := range []string{"pending", "releasing", "released", "failed", "unknown"} {
+ old := &replicas.Deploy{ID: first, Incarnation: id.Incarnation, Target: target, Phase: phase}
+ got, err := again.ReplicaDeployID(id, target, old)
+ if err != nil || got != first {
+ t.Fatalf("%s automatically changed attempt: %q, %v", phase, got, err)
+ }
+ }
+ target = replicas.Build{Version: "v2", Digest: "canonical-2"}
+ next, err := again.ReplicaDeployID(id, target, nil)
+ if err != nil || next == first || next == "" {
+ t.Fatalf("new build = %q, %v", next, err)
+ }
+ target.Digest = "canonical-2-replaced"
+ changed, err := again.ReplicaDeployID(id, target, nil)
+ if err != nil || changed == next || changed == "" {
+ t.Fatalf("changed canonical bytes = %q, %v", changed, err)
+ }
+ id.Incarnation = "lifetime-2"
+ fresh, err := again.ReplicaDeployID(id, target, nil)
+ if err != nil || fresh == changed || fresh == "" {
+ t.Fatalf("new lifetime = %q, %v", fresh, err)
+ }
+}
+
+func TestStatelessDeployIDRecoversRecordEvidence(t *testing.T) {
+ b, err := OpenFailureBook(t.TempDir())
+ if err != nil {
+ t.Fatal(err)
+ }
+ id := replicas.Identity{Account: "bab", App: "shop", Host: "example.com", Incarnation: "lifetime"}
+ target := replicas.Build{Version: "v1", Digest: "canonical"}
+ old := &replicas.Deploy{ID: "durable-record-id", Incarnation: id.Incarnation, Target: target, Phase: "released"}
+ got, err := b.ReplicaDeployID(id, target, old)
+ if err != nil || got != old.ID {
+ t.Fatalf("record recovery = %q, %v", got, err)
+ }
+}
+
+func TestStatelessDeployIDExplicitRetry(t *testing.T) {
+ for _, retry := range []string{"host", "pointer"} {
+ t.Run(retry, func(t *testing.T) {
+ dir := t.TempDir()
+ b, err := OpenFailureBook(dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ id := replicas.Identity{Account: "bab", App: "shop", Host: "example.com", Incarnation: "lifetime"}
+ target := replicas.Build{Version: "v1", Digest: "canonical"}
+ first, err := b.ReplicaDeployID(id, target, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ old := &replicas.Deploy{ID: first, Incarnation: id.Incarnation, Target: target, Phase: "failed"}
+ _, err = b.Record(FailureRecord{Account: id.Account, App: id.App, Host: id.Host, Build: target.Version, At: t0, PromotedAt: t0})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if retry == "host" {
+ epoch := b.PublishedEpoch(id.Account, id.App, target.Version, id.Host)
+ cleared, _, _, err := b.RetryHostAt(id.Account, id.App, target.Version, id.Host, b.ID(), epoch)
+ if err != nil || !cleared {
+ t.Fatalf("host retry = %v, %v", cleared, err)
+ }
+ } else {
+ cleared, err := b.ClearOnPointer(id.Account, id.App, target.Version, t0.Add(time.Second))
+ if err != nil || !cleared {
+ t.Fatalf("pointer retry = %v, %v", cleared, err)
+ }
+ }
+ b, err = OpenFailureBook(dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ next, err := b.ReplicaDeployID(id, target, old)
+ if err != nil || next == first || next == "" {
+ t.Fatalf("retry after restart = %q, %v", next, err)
+ }
+ same, err := b.ReplicaDeployID(id, target, old)
+ if err != nil || same != next {
+ t.Fatalf("retry repeated = %q, %v", same, err)
+ }
+ })
+ }
+}
+
+func TestStatelessDeployIDRequiresDurableSave(t *testing.T) {
+ dir := t.TempDir()
+ b, err := OpenFailureBook(dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ id := replicas.Identity{Account: "bab", App: "shop", Host: "example.com", Incarnation: "lifetime"}
+ target := replicas.Build{Version: "v1", Digest: "canonical"}
+ b.write = func([]byte) error { return errors.New("save refused") }
+ got, err := b.ReplicaDeployID(id, target, nil)
+ if err == nil || got != "" {
+ t.Fatalf("unpersisted selection escaped = %q, %v", got, err)
+ }
+ b.write = nil
+ got, err = b.ReplicaDeployID(id, target, nil)
+ if err != nil || got == "" {
+ t.Fatalf("save recovery = %q, %v", got, err)
+ }
+ b, err = OpenFailureBook(dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ same, err := b.ReplicaDeployID(id, target, nil)
+ if err != nil || same != got {
+ t.Fatalf("saved selection = %q, %v", same, err)
+ }
+}
+
+func TestStatelessDeployIDRefusesIncompleteIdentity(t *testing.T) {
+ id := replicas.Identity{Account: "bab", App: "shop", Host: "example.com", Incarnation: "lifetime"}
+ target := replicas.Build{Version: "v1", Digest: "canonical"}
+ for _, field := range []string{"account", "app", "host", "incarnation", "version", "digest"} {
+ t.Run(field, func(t *testing.T) {
+ identity, build := id, target
+ switch field {
+ case "account":
+ identity.Account = ""
+ case "app":
+ identity.App = ""
+ case "host":
+ identity.Host = ""
+ case "incarnation":
+ identity.Incarnation = ""
+ case "version":
+ build.Version = ""
+ case "digest":
+ build.Digest = ""
+ }
+ b, err := OpenFailureBook(t.TempDir())
+ if err != nil {
+ t.Fatal(err)
+ }
+ got, err := b.ReplicaDeployID(identity, build, nil)
+ if !errors.Is(err, replicas.ErrFenced) || got != "" {
+ t.Fatalf("incomplete selection escaped = %q, %v", got, err)
+ }
+ })
+ }
+}
+
+func TestStatelessDeployIDRejectedRetryKeepsID(t *testing.T) {
+ b, err := OpenFailureBook(t.TempDir())
+ if err != nil {
+ t.Fatal(err)
+ }
+ id := replicas.Identity{Account: "bab", App: "shop", Host: "example.com", Incarnation: "lifetime"}
+ target := replicas.Build{Version: "v1", Digest: "canonical"}
+ first, err := b.ReplicaDeployID(id, target, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, err = b.Record(FailureRecord{Account: id.Account, App: id.App, Host: id.Host, Build: target.Version, At: t0, PromotedAt: t0})
+ if err != nil {
+ t.Fatal(err)
+ }
+ cleared, _, _, err := b.RetryHostAt(id.Account, id.App, target.Version, id.Host, "wrong-book", b.PublishedEpoch(id.Account, id.App, target.Version, id.Host))
+ if err != nil || cleared {
+ t.Fatalf("invalid retry = %v, %v", cleared, err)
+ }
+ cleared, err = b.ClearOnPointer(id.Account, id.App, target.Version, t0)
+ if err != nil || cleared {
+ t.Fatalf("old pointer = %v, %v", cleared, err)
+ }
+ same, err := b.ReplicaDeployID(id, target, nil)
+ if err != nil || same != first {
+ t.Fatalf("rejected retry changed ID = %q, %v", same, err)
+ }
+}