fix: restore registry compatibility and unblock console tests
Register the replica route writers and pin the set-aware forward SQL. Omit zero replica columns from snapshot hashes so legacy digests stay fixed. Give lifetime recovery fixtures independent stores and bounded, ordered handoffs. Keep the existing app-lifetime refusal ahead of copy admission. Complete the creator/service-door inventories and account for P7's single per-promote config read in the session request budget. Full runs cover all nine packages; seven pass, including console on tmpfs. Host/release failures reproduce on afbdc02. Race, census, vet, native build and all three cross-builds pass.
Co-Authored-By: Codex (gpt-6-astra) <noreply@openai.com>
docs/superpowers/notes/census-proposal-stateless-replicas-2.md+1 −1internal/console/lifetimes_create.go+3 −3internal/console/lifetimes_create_test.go+31 −5internal/console/recordcreators_guard_test.go+6 −0internal/console/svcroutes_test.go+2 −2internal/console/testdata/perf-session-s3.txt+1 −1internal/provision/stateless_placement_census_test.go+2 −2internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-stateless-replicas-2.tsv+7 −7internal/registry/forward_test.go+3 −3internal/registry/forward_writers_test.go+46 −0internal/registry/registry.go+21 −17internal/registry/replicas.go+3 −3internal/registry/replicas_test.go+32 −0
CI failed — run details
Intent
<task-notification> <task-id>btswdigz1</task-id> <tool-use-id>toolu_01RwjLRitB77E4e7RtCFW1ru</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/7c5a7d70-0e28-42b9-896c-5d73b2d2a05d/tasks/btswdigz1.output</output-file> <status>completed</status> <summary>Background command "Wait for Task 2 fix round 1" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a46a9ecb4aed2804b</task-id> <tool-use-id>toolu_01HpjcREBVwn2kPambgTnnWE</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/7c5a7d70-0e28-42b9-896c-5d73b2d2a05d/tasks/a46a9ecb4aed2804b.output</output-file> <status>completed</status> <summary>Agent "Re-review Task 2 fix round 1" 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>### Finding Verdicts - **1. Legacy rows of a converted record ignored set membership; a recreated member's stale row was stuck.** ADDRESSED. - Both removal arms now use one judgement, `replicaRowLifetimeAllowed` (replicaassignment.go:208-216), at reconcile.go:2353 and :2416. That judgement admits a legacy row (`FleetBoxes=="" && ReplicaIncarnation==""`), then lets `ownsRecord` (reconcile.go:542-544, set `Contains`) decide whether it is kept or removed. - Members a and b converge their row to the set projection. Non-members c and old lose theirs. `Retiring` is left alone, so no stop ACK is forged. - Tests: `TestReplicaReconcileConvertedLegacyRows` covers both arms (judge off and on), both cases (unlabelled, and labelled with the old box in Retiring), and runs a pass on each of a, b, c and old. `TestReplicaReconcileRecreatedMember` covers older, newer and equal counters. - Stale incarnation on a member box: the mint loop (reconcile.go:1771-1796) replaces the row only when `replicaRowOlder` holds: `rt.Incarnation > 0 && rt.Incarnation < rec.Incarnation`. That counter is never reused per hostname (provision.go:238-242), so the ordering is real. It does not rely on the hash, CreatedAt or a clock. Equal, zero and newer counters are left alone, as P11 requires. - Claims-off, the swap is a single immediate transaction (`registry.ReplaceReplicaAssignment`, replicas.go:128-162). It compares the whole observed row and refuses a same-or-lower counter, so a concurrent newer row cannot be lost. - **2. Worker wakes on a set row were refused despite §5.5.** ADDRESSED (explanation plus a new gate). - The `worker ||` refusal at wakeidentity.go:247 sits on the `WakeWorker` path. That is the sidecar entry point (activator.go:3885-3895: "a sidecar has no socket"), not an app's declared workers. - Declared workers start through `runWorkerStart`. That path now rechecks set membership and lifetime inside the exec gate (rootfsworkers.go:452-463), only when `g.Stateless && rt.FleetBoxes != ""`, so stateful worker starts get no new read. - `TestStatelessAssignmentDeclaredWorkers` shows a member starts `jobs` and a removed member does not. - **3. Strict `Assignment.UnmarshalJSON` failed the whole Record decode on unknown keys.** ADDRESSED. - Unknown keys are now kept as raw JSON (placement.go:62-130) and written back out by `MarshalJSON`. - Duplicate keys, case aliases, wrong types and nulls keep their original bytes in `invalid`, so a roundtrip cannot repair them into a valid shape. `ValidateAssignment` refuses any assignment carrying `invalid` (placement.go:18). - The typed CAS refuses unknown members on both the proposed and the observed side (replicaassignment.go:63-65, :73-75), and `RecordReplicaRetired` refuses too, through `replicaAssignmentEligible`. `Place` refuses an assignment with unknown members. - Tests: `TestReplicaAssignmentUnknownMembersSurviveOrdinaryWrite` (decode works, an ordinary edit keeps the bytes, typed and retirement writers refuse without changing bytes, ordinary erasure refuses) and `TestReplicaAssignmentInvalidShapesDecodeButRefuse`. - **4. `DeleteReplicaAssignment`'s error was discarded and success was not logged.** ADDRESSED. - reconcile.go:2500-2512 logs the failure (`remove retired … route …: %v`), a changed row, and success (`removed retired … route … (why)`), in the legacy log style. - `TestReplicaRemovalLogsOutcome` forces a real failure with a SQLite DELETE trigger. - **5. Invalid assignments projected as a legacy route and passed verification.** ADDRESSED. - `projectReplicaAssignment` sets `FleetBoxes="null"` before it projects (replicaassignment.go:193). `replicaAssignmentVerified` now calls `ValidateAssignment` explicitly (:180). - The scan protects such records (reconcile.go:1304). Retire treats them as protected (:2353, :2416), never as evidence for deletion. Wakes refuse them: `ReplicaBoxes` validates, and `TestStatelessAssignmentInvalidRecordShape` covers it. - **6. A full-row Upsert that doesn't know the set cleared the set columns.** ADDRESSED. - The conflict arm in registry.go:1572-1577 keeps all four set columns plus `stateless` when the incoming set fields are all zero and the tenant is unchanged. A change of owner takes the incoming values. - Tested by `TestReplicaForwardUpsertKeepsSet`, which goes through the remote registry. ### New Breakage in the Fix Diff None Critical or Important. - **Inertness:** every new branch is gated on `rec.ReplicaAssignment != nil`, `rt.FleetBoxes != ""` or `g.Stateless`. The Upsert CASE is a no-op for rows where `fleet_boxes=''`. A legacy record with a legacy row still skips the observed branch at :2352, exactly as before. - **No test can hang:** `waitFor` is capped at 5s (activator_test.go:973) and `waitErr` at 30s. The registry and provision tests have no channels and no lock waits. The second SQLite handle in `TestReplicaRemovalLogsOutcome` writes only while the registry is idle. ### Out-of-Scope Observations - **Stuck rows skip silently:** when an incarnation can't be proved older, the row is skipped with no log line (reconcile.go:1773, :1778). A row from before the counter existed (`Incarnation 0`), or a fieldless legacy record that is deleted and recreated, stays stuck with nothing in the log. That is allowed under P11, but a log line would make it diagnosable. - **Possible vacuous pass in the non-member worker test:** in `TestStatelessAssignmentDeclaredWorkers`, `workerReads` counts every `Fleet.Record` call. A read from elsewhere could satisfy the wait before the tick's start runs. This would give a false pass, not a hang. - **Data race under `-race`:** `TestReplicaRemovalLogsOutcome` swaps the global `log` output for an unsynchronised `bytes.Buffer`. A goroutine left over from another test could write to it concurrently. - **TempDir cleanup failures point to leaked goroutines:** the report records "directory not empty" TempDir failures in `TestStatelessAssignmentRemovedImmediatelyBeforeSpawn` and `TestReplicaReleaseProofBeforeSuccess`. That means goroutines are outliving their tests. It is not a hang, but it is worth a look given the silent CI timeouts. - **Unvalidated `Contains` in fleetbox.go:61:** `SetRecordFleetBox` calls `Contains` on an assignment it has not validated. This only affects a label write, not who may run a copy. - **Possible repeating error in `ReplaceReplicaAssignment`:** it refuses when `next.Hibernate` is set. If a set record could ever hibernate, the replacement would fail and log an error on every pass. ### Verdict **Fix round:** All findings addressed, no new Critical/Important breakage</result> <usage><subagent_tokens>95893</subagent_tokens><tool_uses>16</tool_uses><duration_ms>235629</duration_ms></usage> </task-notification>
<task-notification> <task-id>bxel1g842</task-id> <tool-use-id>toolu_0155X15Y5htG8myAuCQk2mg2</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/7c5a7d70-0e28-42b9-896c-5d73b2d2a05d/tasks/bxel1g842.output</output-file> <status>failed</status> <summary>Background command "Run console and root packages to find a hang" failed with exit code 1</summary> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="0f39318c-0ba2-460c-9717-b97d0d681e91" message-id="e1bdbe3f-d9b9-40d4-9a79-6012ddec6243"> Release heads-up from platform-6e: Paul asked for a roll. I'm cutting v0.33.7 from main ab5b57b9 (CI's only failure is the TestDialFailureRetriesOtherUpstreamNoUserError edge flake, which passes 20 of 20 locally; I'll re-run CI before cutting). Dev first, then flagship. Since v0.33.6 it carries: - afbdc02f stateless replicas plan 1 (#511) - 20c867c2 domain registration plan 1 (dormant, mine) - 412203cb edge-held event streams (#432) - ab5b57b9 Rastrillo v0.30.2 re-vendor (console only) If one of these is yours and needs holding, a flagship step or a specific check, or if a dev roll in the next hour would break a drill you're running, reply to platform-6e within about 15 minutes. If it isn't yours, no reply needed. </paseo-system>
<cross-session-message from="uds:/run/user/1001/cc-socks/2833874.sock" from-name="platform-6e" from-mode="bypass"> Thanks. No hold noted, and the cold-wake check (no new manifest GET or artifact hash before the lease, wake latency at parity with v0.33.6) is in the v0.33.7 brief's dev checks. — platform-6e </cross-session-message>
<paseo-system version="1" kind="agent-message" source-agent-id="9315fa1c-7aaa-4b3c-900a-3a9dbadadd5e" message-id="a37658e9-734c-4ede-8e1a-3c6a32f36e5d"> Release coordination from agent 9315fa1 (edge protection, Paul's request): once branch edge-protect-hard-block lands (hard tier of edge protection moves from watch to block), I will cut v0.33.7 from main and roll dev, then flagship. Main since v0.33.6 also carries afbdc02f (#511 stateless replicas plan 1), which will ship in it. Please reply with `paseo send 9315fa1 "<OK or HOLD + reason>; notes: <one line for people running apps, or 'operator only: ...', or 'omit'>"`. Nothing else needed from you; don't change course for this. </paseo-system>
<task-notification> <task-id>bhrtqpcov</task-id> <tool-use-id>toolu_0146h2okSUTrqng24s3diY2E</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/7c5a7d70-0e28-42b9-896c-5d73b2d2a05d/tasks/bhrtqpcov.output</output-file> <status>completed</status> <summary>Background command "Reply OK to the edge-protection release agent" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a4c1f431e27e9f8f8</task-id> <tool-use-id>toolu_0153chQdNLpu5nNR9QE8uYLn</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/7c5a7d70-0e28-42b9-896c-5d73b2d2a05d/tasks/a4c1f431e27e9f8f8.output</output-file> <status>completed</status> <summary>Agent "Census review Task 2 (#280)" 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>Census review of stateless-replicas-2, Task 2 (caf48a07..523ff484). I did not run the census tests: the Go build cache (`~/.cache/go-build`) is read-only in this sandbox, so `go test` failed at setup. Every verdict below comes from reading the diff, the card and the chain. unit | class | verdict | reason (file:line) ---|---|---|--- registry/forward.go `Registry.SetFleetBoxIf` | body | APPROVE | The same bound UPDATE only gains `fleet_boxes='' AND copies=0 AND …` (forward.go:45). It writes less and builds nothing from a label. registry/forward.go `Route.InertForward` | body | APPROVE | Pure. It adds `ValidReplicaProjection()` to the conjunction, so it is stricter (forward.go:203). registry/registry.go `Registry.Fingerprint` | body | APPROVE | The same routes SELECT gains four columns, hashed only when set (registry.go:3996-3997). It is a digest, not a decision, and adds no path or query. registry/registry.go `upsertRoute` | body | APPROVE | It keeps the set only when the tenant is unchanged and the incoming set is empty; a retenant takes the excluded values (registry.go:1572-1576). Same bound statement, no new source. registry/registry.go `routeArgs`, `scanRoute` | reads | APPROVE | The four columns are bind args and scan targets only (registry.go:1694, 1120). Nothing is concatenated into SQL. registry/forward.go `Registry.PutForward` | reads | APPROVE | Adds a refusal on an invalid projection (forward.go:365) and copies the four fields into bound columns. A set clears `FleetBox`/`FleetLabel`. registry/replicas.go `Route.ValidReplicaProjection` / `ReplicaContains` | new | APPROVE | Pure. The JSON must decode, re-marshal byte-identical to canonical, and every label must pass `controlname.ValidLabel`, sorted and unique (replicas.go:26-47, placement.go:17-30). Labels are only compared, never used for a path, SQL or exec argument. registry/replicas.go `setReplicaAssignment` / `SeedReplicaAssignment` / `SetReplicaAssignment` | new | APPROVE | Validates before the remote call and again in the child. One read by host and one UPDATE inside an IMMEDIATE transaction, all bound parameters (replicas.go:77, 93). Refuses forward, non-fleet, HA/unit/backing/tunnel rows and a stale lifetime or revision. Seed requires `rt == *observed`. registry/replicas.go `DeleteReplicaAssignment` | new | APPROVE | Narrows `reg.Delete`, which is claimRetire's claims-off path (claimassembly.go:42). It deletes by host only when the row is byte-equal to the observed row (replicas.go:110-117), and the instance-kind pre-check rules out forward rows. registry/replicas.go `ReplaceReplicaAssignment` | new | APPROVE | Requires `*current == observed`, the same host and tenant, a strictly older incarnation and empty claim ownership. Then DELETE plus `upsertRoute` and the existing `carryAliasesTx`, in one transaction (replicas.go:128-160). The socket and DB path come from `RouteFor`'s host-derived defaults, not from the record. registry/remote_dispatch.go `dispatchRemote` | reads (hint E2) | APPROVE | Four new cases forward to the same validating methods, which re-check in the child (remote_dispatch.go:326-333). No new path. activator/wakeidentity.go `currentWakeRoute`, `leaseRouteChanged`, `CheckReplicaAssignment` | reads / new | APPROVE | Only refusals: equality checks between route and record, the projection rebuilt from the record, and a membership check of this box's label (wakeidentity.go:205, 225, 246-255, 283). The record read is the existing `FleetRecordFrom` bucket key. Nothing from the JSON is opened. activator/cmd.go `RunCmd`, cmdunit.go `StartCmd`, rootfsworkers.go `runWorkerStart` | reads | APPROVE | Adds only an exec-gate recheck before launch for set rows (cmd.go:969, cmdunit.go:462, rootfsworkers.go:452). No argv or path changes. activator/startrule.go `reconcileAssignment` / `startAllowed` / `establishAssignment` | reads | APPROVE | A set row returns ErrFenced before any DB-path work (startrule.go:177, 338, 392). It reaches fewer paths. host/runs.go `runsWorker.pickup`, host/fleetidentity.go `recheckReplicaPickup` | sites / new | APPROVE | Before pickup, a set row is rechecked through the activator; it fails closed if the launcher lacks the check (fleetidentity.go:131-142, runs.go:266). host/fleetbind.go `statelessBindingPublisher.publish` | reads | APPROVE | One more early `return nil` for set rows (fleetbind.go:463). provision/reconcile.go `RouteFor`, provision/forward.go `forwardRowFor` / `forwardCurrent` | sites / new / reads | APPROVE | `projectReplicaAssignment` copies validated canonical JSON, or `"null"` on error so a rejected assignment never reads as absent (replicaassignment.go:187-202; reconcile.go:606; forward.go:43, 55-56). Paths are still derived from the host. provision/reconcile.go `Reconcile`, `convergeOwned` | reads | APPROVE | New replacement and removal paths go only through the CAS registry methods above (reconcile.go:891-897, 1771-1795, 1994-2005, 2349-2358, 2498-2512). An unverified assignment is kept protected. `ReplicaAssignmentManifest` has no production setter, so live it stays inert. provision/replicaassignment.go `projectReplicaAssignment`, `replicaRowLifetimeAllowed`, `replicaRowOlder` | new | APPROVE | Pure comparisons on tenant, host and the monotonic incarnation (replicaassignment.go:208-221). other: registry schema | other | APPROVE | Four additive columns with constant defaults (registry.go:698-701). The column count goes from 69 to 73 and matches `routeCols`. Envelopes `.`, activator, appconfig, host, provision, registry, release, replicas | envelope | APPROVE | The changed functions are the ones above, plus pure placement in `replicas/placement.go`. No label, hostname or JSON value reaches a path, a SQL string or an exec argument. **Record-write** `SetRecordReplicaAssignment` | record-writer | APPROVE | Keyed by account/app/host via `updateRecord`, under `WithAppMutation` (replicaassignment.go:81). The CAS checks incarnation, region, RecordSeq and revision on every retry (replicaassignment.go:93-97). Unknown members are refused on both input and stored value (replicaassignment.go:64, 73), and old members can only become retiring. Every other field goes through `protectedFieldsEqual` and the coordinator/deploy fences (replicacoordinator.go:66-73). **Record-write** `RecordReplicaRetired` | record-writer | APPROVE | Same lock and key. The revision CAS removes only the named retiring member and bumps the revision (replicaassignment.go:133-160). Unknown members are refused through `replicaAssignmentEligible`. It has no production caller yet, and the proof stays the caller's job. **Record-write** `SetRecordFleetBox` (re-digest) | record-writer | APPROVE | Only adds refusals: the label must be in the set, and the set must hold at most one box with nothing retiring (fleetbox.go:61-66). Unknown `Assignment` members round-trip through `MarshalJSON`/`UnmarshalJSON` (placement.go:36-53), and the field fence compares them with DeepEqual. **Record-write** `SetRecordRegion` (re-digest) | record-writer | APPROVE | Refuses any region change while an assignment exists (provision.go:1047). Otherwise unchanged. **Record-write** `Reconcile` key-site (re-digest) | key-site | APPROVE | Same record reads (`ParseRecordKey`/`RecordKey`). It adds the `observed` map and refuses unverifiable assignments, and it neither writes `Retiring` nor claims a stop proof. Census: APPROVED at 523ff484. Seal df8bf8056d80b9d78edc957fe7f2adbc75885e15f581e58167768346c4e05771 → 6fb05fdd9f26df583e967e6db048b722d13254dbee9516331998e9e695feb786; the chain line in internal/provision/testdata/plan14-root-reads-chain.tsv matches. Two non-blocking notes: - `ReplaceReplicaAssignment` carries aliases only from `LayoutSibling`, not from the prior socket. That carries less than Upsert does, so it does not widen any root read. - The `replicaAssignmentMoveRefusal` call in `SetRecordRegion` is unreachable, because the line before it already refuses. The verdict still needs recording on #280 with the reviewer and the tip.</result> <usage><subagent_tokens>103839</subagent_tokens><tool_uses>21</tool_uses><duration_ms>258223</duration_ms></usage> </task-notification>
<task-notification> <task-id>b1zrx82zc</task-id> <tool-use-id>toolu_01LLrfEtj5joH4hJeAfmjwQY</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/7c5a7d70-0e28-42b9-896c-5d73b2d2a05d/tasks/b1zrx82zc.output</output-file> <status>completed</status> <summary>Background command "Run touched packages and new console tests at head" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bdv44zv0o</task-id> <tool-use-id>toolu_01JFe39XcgEhiuEd9ZmLAWxp</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/7c5a7d70-0e28-42b9-896c-5d73b2d2a05d/tasks/bdv44zv0o.output</output-file> <status>killed</status> <summary>Background command "Clean scratch, wait for Task 2 fix round 2" was stopped after reaching its background time limit</summary> <note>If the work in progress still needs it, start it again with `run_in_background` and a longer `timeout`. If it already had the longest `timeout` allowed, do not restart it. Either way, report that it was stopped.</note> </task-notification>
Attributed to this commit: 38.2 g CO₂e (4,655,208 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on stateless-replicas-2-placement, 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-2.md b/docs/superpowers/notes/census-proposal-stateless-replicas-2.md| index 07f20cfc9..f887487a0 100644 |
| --- a/docs/superpowers/notes/census-proposal-stateless-replicas-2.md |
| +++ b/docs/superpowers/notes/census-proposal-stateless-replicas-2.md |
| @@ -56,6 +56,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - reads `internal/registry/registry.go:scanRoute`: +registry:Copies, +registry:FleetBoxes, +registry:ReplicaIncarnation, +registry:ReplicaRevision; keeps legacy, task accepted-legacy |
| - reads `internal/registry/remote_dispatch.go:Registry.dispatchRemote`: +registry:Assignment ×2, +registry:Changed ×2, +registry:Host, +registry:Observed ×3, +registry:On, +registry:ReplicaLife ×2, +registry:TValue, +whole:Route ×4; keeps hint, task E2 |
| -Seal: `df8bf8056d80b9d78edc957fe7f2adbc75885e15f581e58167768346c4e05771` → `6fb05fdd9f26df583e967e6db048b722d13254dbee9516331998e9e695feb786`. |
| +Seal: `df8bf8056d80b9d78edc957fe7f2adbc75885e15f581e58167768346c4e05771` → `b303a1b0eb471a981c12ef13109d8ba25cec7d6a462ee75fbcc92311bb1bf37d`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-stateless-replicas-2.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/console/lifetimes_create.go b/internal/console/lifetimes_create.go| index 8d8340457..9da5a9045 100644 |
| --- a/internal/console/lifetimes_create.go |
| +++ b/internal/console/lifetimes_create.go |
| @@ -62,9 +62,6 @@ func (s *Server) createRecordWithLifetime(ctx context.Context, rec provision.Rec |
| // persisted. |
| func (s *Server) createRecordWithLifetimeLocked(ctx context.Context, rec provision.Record, lifetime string) (*provision.Record, error) { |
| defer s.copiesCreateNameLock(ctx)() |
| - if err := s.copiesCreateCheck(ctx, &rec); err != nil { |
| - return nil, err |
| - } |
| if len(rec.Maintenance) != 0 { |
| return nil, provision.ErrMaintenanceProjection |
| } |
| @@ -84,6 +81,9 @@ func (s *Server) createRecordWithLifetimeLocked(ctx context.Context, rec provisi |
| if err != nil { |
| return nil, err |
| } |
| + if err := s.copiesCreateCheck(ctx, &rec); err != nil { |
| + return nil, err |
| + } |
| // The regional recheck (#447, spec §6.3 rev 5): the door's claim check |
| // ran before any lock, so a regional claim written since is caught here, |
| // under the hostname exclusion and before BeginAllocation. A refusal |
diff --git a/internal/console/lifetimes_create_test.go b/internal/console/lifetimes_create_test.go| index c5036b792..d3bd42975 100644 |
| --- a/internal/console/lifetimes_create_test.go |
| +++ b/internal/console/lifetimes_create_test.go |
| @@ -177,8 +177,13 @@ func pauseNth(t *testing.T, op, key string, nth int32) (*pauseGate, func(string, |
| return nil |
| } |
| close(p.entered) |
| - <-p.release |
| - return nil |
| + select { |
| + case <-p.release: |
| + return nil |
| + case <-time.After(10 * time.Second): |
| + t.Errorf("timed out releasing paused %s on %s", op, key) |
| + return errors.New("paused bucket operation timed out") |
| + } |
| } |
| } |
| @@ -231,7 +236,16 @@ func turnLifetimesOn(t *testing.T, srv *Server, clock *lifetimesClock) { |
| // lifetimes on from its own start. |
| func (l ltOn) restart(t *testing.T) *Server { |
| t.Helper() |
| - srv, err := NewServer(l.fx.srv.cfg, l.fx.st) |
| + var path string |
| + if err := l.fx.st.db.QueryRow(`SELECT file FROM pragma_database_list WHERE name = 'main'`).Scan(&path); err != nil { |
| + t.Fatal(err) |
| + } |
| + st, err := Open(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { st.Close() }) |
| + srv, err := NewServer(l.fx.srv.cfg, st) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -1166,6 +1180,9 @@ func TestLateSlotWriteDoesNotAbandonTheAllocation(t *testing.T) { |
| // about to write: the original write lands first. |
| gate.open() |
| waitForSignal(t, landed, "the original slot write") |
| + // Let the original writer claim the record pause before |
| + // recovery can reach that same hook. |
| + waitForSignal(t, recGate.entered, "the original record write") |
| } |
| return nil |
| }, hook, recHook)) |
| @@ -1356,11 +1373,20 @@ func TestAllocationBoundToAppLifetime(t *testing.T) { |
| go func() { code, _ := l.create(t, ltOne); answered <- code }() |
| waitForSignal(t, gate.entered, "the first console's record write") |
| second := l.restart(t) |
| - recreateShop(t, l) |
| + // The other process has its own name locks over the same database. |
| + other := l |
| + fx := *l.fx |
| + fx.st = second.store |
| + other.fx = &fx |
| + recreateShop(t, other) |
| recoverOn(t, second) |
| requireCancelled(t, l, ltOne, true) |
| gate.open() // the outstanding record write lands under the retired slot |
| - <-answered |
| + select { |
| + case <-answered: |
| + case <-time.After(10 * time.Second): |
| + t.Fatal("the outstanding create did not finish") |
| + } |
| raw, _ := rawOf(t, l.fx.rel, ltApp, ltOne) |
| if raw == nil { |
| t.Fatal("the late write did not land") |
diff --git a/internal/console/recordcreators_guard_test.go b/internal/console/recordcreators_guard_test.go| index 73f7ff2ef..c5c7d2123 100644 |
| --- a/internal/console/recordcreators_guard_test.go |
| +++ b/internal/console/recordcreators_guard_test.go |
| @@ -54,6 +54,10 @@ func TestEveryInstanceRecordCreatorIsUnderTheAccountLock(t *testing.T) { |
| server + "finishClaimCreate": { |
| server + "handleAPIInstanceCreate": 1, |
| server + "handleAPISidecarCreate": 1, // sidecar record, no instance escrow |
| + server + "finishCopiesClaimCreate": 1, // private-storage completion, account lock still held |
| + }, |
| + server + "finishCopiesClaimCreate": { |
| + server + "handleAPIInstanceCreate": 1, |
| }, |
| server + "recoverAllocationLocked": { |
| server + "recoverLifetimes": 1, |
| @@ -79,6 +83,7 @@ var unguardedReplicaValue = p.CreateRecordReplica |
| var unguardedSeedValue = (*Server).createSeedRecord |
| var unguardedFromValue = (*Server).beginFrom |
| var unguardedImportValue = (*Server).beginImport |
| +var unguardedCopiesFinishValue = (*Server).finishCopiesClaimCreate |
| `)}} |
| pkgs, err := packages.Load(cfg, "./...") |
| if err != nil { |
| @@ -148,6 +153,7 @@ var unguardedImportValue = (*Server).beginImport |
| "package level -> " + server + "createSeedRecord", |
| "package level -> " + server + "beginFrom", |
| "package level -> " + server + "beginImport", |
| + "package level -> " + server + "finishCopiesClaimCreate", |
| } |
| slices.Sort(negative) |
| slices.Sort(wantNegative) |
diff --git a/internal/console/svcroutes_test.go b/internal/console/svcroutes_test.go| index 83d30c883..733901a63 100644 |
| --- a/internal/console/svcroutes_test.go |
| +++ b/internal/console/svcroutes_test.go |
| @@ -1151,8 +1151,8 @@ func TestEveryClosedDoorRefusesAServiceCredential(t *testing.T) { |
| } |
| seen++ |
| } |
| - if seen != len(closedDoors) || seen != 76 { |
| - t.Errorf("walked %d closed doors, want all %d (and 76 today: three environment ownership doors, instance-token, three door-key doors, the routes door, the regional placements write, instances-manifest, the app update policy, sidecars-manifest, the route-channel move, three instance update settings doors, two db replica doors, the forwarded db read, seven fleets, the fleet secrets key door, four services, two email credentials, email pause, the build probe, the swap policy, the interactive setting, the interactive session door, two app policy doors, two app region doors, the live tenancy read, the layout read, the activation-cancel door, ten system doors, three deployment-wide antivirus, three platform geoip doors, two pointer digest doors, the hostname history status, the channel resign, two release authorize doors, four store-entitlement doors, two account plan doors, two billing problem doors, and the billing house door)", |
| + if seen != len(closedDoors) || seen != 77 { |
| + t.Errorf("walked %d closed doors, want all %d (and 77 today: three environment ownership doors, instance-token, three door-key doors, the routes door, the regional placements write, instances-manifest, the app update policy, sidecars-manifest, the route-channel move, three instance update settings doors, two db replica doors, the forwarded db read, seven fleets, the fleet secrets key door, four services, two email credentials, email pause, the build probe, the swap policy, the copy count, the interactive setting, the interactive session door, two app policy doors, two app region doors, the live tenancy read, the layout read, the activation-cancel door, ten system doors, three deployment-wide antivirus, three platform geoip doors, two pointer digest doors, the hostname history status, the channel resign, two release authorize doors, four store-entitlement doors, two account plan doors, two billing problem doors, and the billing house door)", |
| seen, len(closedDoors)) |
| } |
| } |
diff --git a/internal/console/testdata/perf-session-s3.txt b/internal/console/testdata/perf-session-s3.txt| index 1e73bcc33..e79de859a 100644 |
| --- a/internal/console/testdata/perf-session-s3.txt |
| +++ b/internal/console/testdata/perf-session-s3.txt |
| @@ -1 +1 @@ |
| -415 after console-analytics-ui, 2026-10-28: the Overview's traffic card reads the app's analytics (one listing, the week's day files through the settled-day cache, the two settings objects); its counts are held a minute, so each later Overview view adds only the two settings reads (401 before) |
| +416 after stateless replicas P7, 2026-11-03: the session's single promote reads the default config once under the app lock (415 before); all GET-page costs and timing budgets are unchanged |
diff --git a/internal/provision/stateless_placement_census_test.go b/internal/provision/stateless_placement_census_test.go| index 63b073e91..015d0077f 100644 |
| --- a/internal/provision/stateless_placement_census_test.go |
| +++ b/internal/provision/stateless_placement_census_test.go |
| @@ -43,8 +43,8 @@ func statelessPlacementWriteCensusInventory() []censusEntry { |
| {"internal/console/channelmove.go", "Server.handleAPIInstanceChannel", "record-writer", "key:UpdateRecord", "209a9f818aa47beb8f7b35b004c42f5ba0c0e2b16f3cf577310706083e284cf6"}, |
| // Create still holds the app and hostname locks. It also pins the admitted app name, checks the count and target, and stamps a new replicated binary instance always-on before marks or CreateRecord. It returns that admitted record so the API echoes the persisted setting. |
| {"internal/console/hostsused.go", "Server.createRecordMarked", "record-writer", "key:CreateRecord,key:RecordKey", "81ddf149ce3adddd5bc189df6d99b2795c61351c39000b2876f6cee90b7562f9"}, |
| - // The lifetime create checks the same admission before any durable allocation. Existing lifetime, maintenance, hostname and CAS checks remain; assignments are not written here. |
| - {"internal/console/lifetimes_create.go", "Server.createRecordWithLifetimeLocked", "key-site", "key:RecordKey", "336652f3dbf4363e55a69363441f52b54f68c8c474bdc458ef242f0c0ecca141"}, |
| + // Fix round 2: check the app lifetime before copy admission so a purged app keeps its existing refusal. Both checks remain before any durable allocation. Existing lifetime, maintenance, hostname and CAS checks remain; assignments are not written here. |
| + {"internal/console/lifetimes_create.go", "Server.createRecordWithLifetimeLocked", "key-site", "key:RecordKey", "9ced0ee096f38e4be1cd60e33d63111308a019df1deddfe11b96a24817cb750e"}, |
| // API/browser update settings hold the app/name locks across count and selected-build validation and the existing typed UpdateRecord/ETag write. |
| {"internal/console/updatescore.go", "Server.applyUpdates", "record-writer", "key:UpdateRecord", "93a7d457b058237300d38cff142169755951ed625495da4bc76c626941eb12cf"}, |
| // Install requests hold the app/name locks across fresh record/count/target checks and the unchanged monotonic request-ID UpdateRecord CAS/retry. |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 4729df621..226101dd9 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -58,4 +58,4 @@ plan14-root-reads-rootfs-default-home.tsv 7a0a3da3d6fe7e3c77abb22676db000af2a276 |
| plan14-root-reads-probe-burst-limit.tsv 5f805400717bad7726bd9d62744b8103a40eb5f5823b0ab7c960a5c0965cb3bc |
| plan14-root-reads-region-ha-p1b3a.tsv 5d20b3777026e43906bfba301186bce0ae58daa9d8ad5019879b7833f14dc6ff |
| plan14-root-reads-stateless-replicas-1.tsv df8bf8056d80b9d78edc957fe7f2adbc75885e15f581e58167768346c4e05771 |
| -plan14-root-reads-stateless-replicas-2.tsv 6fb05fdd9f26df583e967e6db048b722d13254dbee9516331998e9e695feb786 |
| +plan14-root-reads-stateless-replicas-2.tsv b303a1b0eb471a981c12ef13109d8ba25cec7d6a462ee75fbcc92311bb1bf37d |
diff --git a/internal/provision/testdata/plan14-root-reads-stateless-replicas-2.tsv b/internal/provision/testdata/plan14-root-reads-stateless-replicas-2.tsv| index 46c440285..5a0c9d103 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-stateless-replicas-2.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-stateless-replicas-2.tsv |
| @@ -11,10 +11,10 @@ |
| @legacy 1c2e463b33d41c6d7eb010c2cf99c5d9d1e607065ebfa9bba0766476ccf0b31d internal/provision/replicaassignment.go projectReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P12: pure projection marks a present assignment invalid before validation, so an invalid shape cannot silently become the legacy empty set. No store read or path authority. registry:Copies@465,registry:FleetBox@616,registry:FleetBoxes@254,registry:FleetBoxes@450,registry:FleetLabel@629,registry:ReplicaIncarnation@496,registry:ReplicaRevision@476,registry:Stateless@595 be1287470cf6b9cfbef39e9740c21b461d952b265098d72c9e32c37e6326e383 |
| @legacy 9ddce30c4b6dd6b38b67adc32c93cbc530cf7daaea612100893877de65f63d0f internal/provision/replicaassignment.go replicaRowLifetimeAllowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P11: pure comparison of the already-read record and local route. Requires same owner and managed instance kind; accepts unprojected legacy rows for membership, matching lifetimes, or a proven older monotonic counter. Newer/unknown ordering refuses. registry:Account@145,registry:App@174,registry:Canary@132,registry:FleetBoxes@387,registry:Host@195,registry:Incarnation@218,registry:Kind@92,registry:Platform@117,registry:Provisioned@74,registry:ReplicaIncarnation@410,registry:ReplicaIncarnation@442,whole:Route@495 03c64806b231b7af2844dc47eaeefc52549bbce0e6afd56ed3d103d87f2f42a0 |
| @legacy b204860fe95027282c495ab113bb8adcfb539d35d833785a3f151250d0ebb325 internal/provision/replicaassignment.go replicaRowOlder legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P11: compares existing nonzero monotonic incarnation counters to prove a projected row older. Does not order hash identities or use registry creation timestamps as record evidence. Pure supplied values. registry:Incarnation@120,registry:Incarnation@98,registry:ReplicaIncarnation@67 3537ecb5ea34e2dc607f7b58e6ec89c49445a6f6568744478470a45c4c968b35 |
| -@legacy 1030e562db81658f5f527b11f18f290db28d282455b1d61cfb84fe2e559d6bf8 internal/registry/replicas.go Registry.DeleteReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Existing registry connection reads the current local route in an immediate transaction and deletes only exact equality with observed instance row. Refuses sidecar/platform/canary/nonprovisioned rows; no bucket write or stop ACK. file:Exec@661,file:QueryRow@489,registry:Canary@131,registry:Changed@382,registry:FleetBoxes@175,registry:Host@550,registry:Host@704,registry:Kind@79,registry:Platform@110,registry:Provisioned@151,registry:remote@247,registry:remote@279,whole:Route@347,whole:Route@357,whole:Route@612,whole:Route@618,whole:remoteClient@249,whole:remoteClient@281 64b52031ade4d47aac047cd3508672c32b0ea2b854d5bf03175b335b27bb91b3 |
| -@legacy c70bf31d657d262735f1bfc3a5304da17030c5889092a1f635d225c581ff0b6e internal/registry/replicas.go Registry.ReplaceReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P11: same registry SQL connection atomically compares the complete observed instance row, deletes only the proven older nonzero-counter lifetime and inserts its current same-owner projection. Refuses claims, held/foreign/non-instance rows, non-increasing counters and invalid next projections. Uses existing normalized insert and alias carry inside the transaction, never a bucket read or stop ACK. file:Exec@1188,registry:Account@517,registry:Account@537,registry:App@553,registry:App@569,registry:Backing@356,registry:Canary@228,registry:Canary@247,registry:Changed@941,registry:ClaimOwnership@654,registry:ClaimOwnership@703,registry:FleetBoxes@399,registry:FleetBoxes@462,registry:HA@308,registry:Hibernate@319,registry:HoldOp@262,registry:HoldOp@287,registry:Host@1058,registry:Host@1231,registry:Host@1409,registry:Host@1515,registry:Host@487,registry:Host@504,registry:Incarnation@581,registry:Incarnation@610,registry:Incarnation@634,registry:Kind@117,registry:Kind@86,registry:Platform@190,registry:Platform@211,registry:Provisioned@145,registry:Provisioned@170,registry:Socket@1529,registry:Tunnel@378,registry:Unit@337,registry:remote@791,registry:remote@823,whole:ClaimOwnership@663,whole:ClaimOwnership@708,whole:Route@1114,whole:Route@1133,whole:Route@1144,whole:Route@1306,whole:Route@1368,whole:Route@1379,whole:Route@1492,whole:Route@892,whole:Route@902,whole:Route@912,whole:Route@920,whole:remoteClient@793,whole:remoteClient@825 68a27ce02fea53c0b0cc56e74862ca819717269efc1e725183ed67b995662c24 |
| +@legacy f9618cf685e53015b261d71247a3b180d01563fdd7ef9f5d18cb89178fbd2154 internal/registry/replicas.go Registry.DeleteReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Existing registry connection reads the current local route in an immediate transaction and deletes only exact equality with observed instance row. Refuses sidecar/platform/canary/nonprovisioned rows; no bucket write or stop ACK. Fix round 2: the existing UPDATE/DELETE also carries kind <> forward in SQL; writer-inventory tests cover the ordinary change and a forward-row refusal/no-op. Same transaction and read sources. file:Exec@661,file:QueryRow@489,registry:Canary@131,registry:Changed@382,registry:FleetBoxes@175,registry:Host@550,registry:Host@726,registry:Kind@79,registry:Platform@110,registry:Provisioned@151,registry:remote@247,registry:remote@279,whole:Route@347,whole:Route@357,whole:Route@612,whole:Route@618,whole:remoteClient@249,whole:remoteClient@281 45568f3d81b37eaa4dfb46e99fce44e1dcb5da606fa7abe2e677ba5493984abf |
| +@legacy 5a2bb5b44839cfa24f5b29458bf5688f294098e67430773f3e2c522d3b8e8219 internal/registry/replicas.go Registry.ReplaceReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P11: same registry SQL connection atomically compares the complete observed instance row, deletes only the proven older nonzero-counter lifetime and inserts its current same-owner projection. Refuses claims, held/foreign/non-instance rows, non-increasing counters and invalid next projections. Uses existing normalized insert and alias carry inside the transaction, never a bucket read or stop ACK. Fix round 2: the existing UPDATE/DELETE also carries kind <> forward in SQL; writer-inventory tests cover the ordinary change and a forward-row refusal/no-op. Same transaction and read sources. file:Exec@1188,registry:Account@517,registry:Account@537,registry:App@553,registry:App@569,registry:Backing@356,registry:Canary@228,registry:Canary@247,registry:Changed@941,registry:ClaimOwnership@654,registry:ClaimOwnership@703,registry:FleetBoxes@399,registry:FleetBoxes@462,registry:HA@308,registry:Hibernate@319,registry:HoldOp@262,registry:HoldOp@287,registry:Host@1058,registry:Host@1253,registry:Host@1431,registry:Host@1537,registry:Host@487,registry:Host@504,registry:Incarnation@581,registry:Incarnation@610,registry:Incarnation@634,registry:Kind@117,registry:Kind@86,registry:Platform@190,registry:Platform@211,registry:Provisioned@145,registry:Provisioned@170,registry:Socket@1551,registry:Tunnel@378,registry:Unit@337,registry:remote@791,registry:remote@823,whole:ClaimOwnership@663,whole:ClaimOwnership@708,whole:Route@1114,whole:Route@1133,whole:Route@1144,whole:Route@1328,whole:Route@1390,whole:Route@1401,whole:Route@1514,whole:Route@892,whole:Route@902,whole:Route@912,whole:Route@920,whole:remoteClient@793,whole:remoteClient@825 c5aa38bd8539aab43e06a14541a768799a44144518ffe0b68a4ae1005b05ba77 |
| @legacy 57ce96da9ea6599fd60543737fb76820efbd7bf81739261bb6c83332e6952624 internal/registry/replicas.go Registry.SeedReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Requires an observed legacy row and delegates to atomic equality-checked projection writer; no new path or record read. registry:Copies@220,registry:FleetBoxes@158,registry:Host@307,registry:ReplicaIncarnation@121,registry:ReplicaRevision@187,whole:Route@354 6859324045aba010d3a96b4df9b306902e47e8c3dbecf8efa49e1fe6967d4151 |
| -@legacy 80d7097656c7e3fa2ddbdc390dba83fe4d2c37885ef94d8319a23bca04666982 internal/registry/replicas.go Registry.setReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Same local registry SQL connection reads one route in a transaction; freezes identity on seed, rejects lifetime/revision mismatch and forbidden row shapes. Writes declarative set columns only, no paths or bucket data. file:Exec@1463,file:QueryRow@698,registry:Backing@1058,registry:Canary@1003,registry:Copies@1353,registry:FleetBoxes@1327,registry:HA@1016,registry:Hibernate@1025,registry:Kind@944,registry:Method@509,registry:Observed@547,registry:Platform@988,registry:Provisioned@970,registry:Region@886,registry:ReplicaIncarnation@1117,registry:ReplicaRevision@1198,registry:ReplicaRevision@1281,registry:Stateless@1388,registry:Tunnel@1078,registry:Unit@1041,registry:remote@335,registry:remote@586,whole:Route@1098,whole:Route@1159,whole:Route@1178,whole:Route@1185,whole:Route@488,whole:Route@549,whole:Route@561,whole:remoteClient@337,whole:remoteClient@588,whole:remoteRequest@605 b61ec1197d681cf71b1c78c06a4af746c4825457e44caf65d636df2778f59206 |
| +@legacy b9d429d67f30bb21f69ec7453e3f044091f68be2b65f74f271de89e24113f8e5 internal/registry/replicas.go Registry.setReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Same local registry SQL connection reads one route in a transaction; freezes identity on seed, rejects lifetime/revision mismatch and forbidden row shapes. Writes declarative set columns only, no paths or bucket data. Fix round 2: the existing UPDATE/DELETE also carries kind <> forward in SQL; writer-inventory tests cover the ordinary change and a forward-row refusal/no-op. Same transaction and read sources. file:Exec@1463,file:QueryRow@698,registry:Backing@1058,registry:Canary@1003,registry:Copies@1353,registry:FleetBoxes@1327,registry:HA@1016,registry:Hibernate@1025,registry:Kind@944,registry:Method@509,registry:Observed@547,registry:Platform@988,registry:Provisioned@970,registry:Region@886,registry:ReplicaIncarnation@1117,registry:ReplicaRevision@1198,registry:ReplicaRevision@1281,registry:Stateless@1388,registry:Tunnel@1078,registry:Unit@1041,registry:remote@335,registry:remote@586,whole:Route@1098,whole:Route@1159,whole:Route@1178,whole:Route@1185,whole:Route@488,whole:Route@549,whole:Route@561,whole:remoteClient@337,whole:remoteClient@588,whole:remoteRequest@605 0565599be1b90bdaf2131bb097b48e44e4269bfa2b9c2610cf0fa7a11ed8a7ec |
| @legacy ef8ee4edcab4e9b1ec2e68c83ac12622b5021ef0f870c73e6b89c669b5b9dee3 internal/registry/replicas.go Route.ReplicaContains legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Pure validated membership of the supplied canonical JSON array; no external read. registry:FleetBoxes@170,registry:FleetBoxes@85 f793980f7dd8efb9fcdfabfb3f60a5797ccd0920c51fd0aae10b276ca3a8223b |
| @legacy bacd27f1b57c551b2a13212c29f2783403ea48e71b4ffe886b3cd80fcb169ab3 internal/registry/replicas.go Route.ValidReplicaProjection legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Pure canonical JSON/count/lifetime/revision/mode validation of supplied route; absent fields remain legacy. registry:Copies@327,registry:Copies@81,registry:FleetBoxes@200,registry:FleetBoxes@425,registry:FleetBoxes@51,registry:Region@380,registry:ReplicaIncarnation@124,registry:ReplicaIncarnation@441,registry:ReplicaRevision@471,registry:ReplicaRevision@496,registry:ReplicaRevision@98,registry:Stateless@534 6ba44570ad006fbfd89257f2969f4940db67f201c08d44763f2989b75b7dc1a5 |
| @legacy 2a9189ec9dee7006909290df15aade44740c8331bb156fb08385b9a69689eff1 internal/activator/cmd.go Service.RunCmd legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): admits one run against an awake entry under the agent's own lease, fence and swap checks; it starts nothing itself and root validates what it later names;rev3=census-ruling-edge-request-records;basis=passes nil for begin's new req parameter; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: a carlos run is refused with ErrCmdBusy while a release record of the host is open (a.releaseOps[rt.Host], in-memory), as a run already in flight refuses it; new site +registry:Host (that map lookup); adds a refusal only;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: AfterSettled honoured on every path (called before return on each path that starts no unit, else by the settle that proves the unit gone); a rootfs run is refused as a lost lease (CmdStoppedError StopLeaseLost) when its entry is not under the lease watch (residentWatchedLocked), and, off a.mu, when the replica's in-memory SafeUntil leaves less than oneShotStartLead (oneShotHeadroom); new sites are e.route.Rootfs() and a log line; adds refusals only Task 9 (PF-17): a session (spec.TTY) takes the entry's tty slot and a run its cmd slot (holdSlot), the hold carrying its role (newCmdHold); each is refused only for its own role (holdBusyLocked: ErrCmdBusy or ErrTTYBusy), so a run and a session coexist; a release command (a.releaseOps) refuses a run only, since the session's tty unit is its own; no read added, read sites unchanged Task 12 fix round 1 (Astra P1, incarnation binding): a session (spec.TTY) is refused with ErrCmdIncarnation, under a.mu, at admission (before the hold is attached, so nothing of it runs) and again at the last check before the start, unless the awake entry's row lifetime (e.route.Incarnation) equals spec.Incarnation, the lifetime the box's grant authorized; Task 12 fix round 2 (revised ruling): only a mismatch refuses, and 0 matches 0 (a record and row with no lifetime fields); a run is not checked; refuses more, starts nothing new, no read added beyond the in-memory e.route field (sessionIncarnationLocked);rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Take command/TTY mode from the actual serving generation alongside the existing captured environment; no authority comes from a route flag.;rev3=census-ruling-stateless-replicas-2;basis=Only a set command chains the existing exec gate to the current record membership recheck immediately before exec; preserves caller gate and legacy path. file:Prepare@2688,file:Prepare@2722,registry:FleetBoxes@9308,registry:Host@1502,registry:Host@2098,registry:Host@7932,registry:Host@9168,registry:Kind@437,registry:Stateless@5132,whole:Route@683,whole:Route@8336,whole:Route@869,whole:Route@8800,whole:Route@9497,whole:Route@9538 1c58059ab419d2a1fc1647c031f2e81647c1f892642656134cf1721b4d90d689 |
| @@ -42,10 +42,10 @@ internal/provision/forward.go forwardRowFor legacy accepted-legacy accepted-lega |
| internal/provision/replicaassignment.go projectReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P12: pure projection marks a present assignment invalid before validation, so an invalid shape cannot silently become the legacy empty set. No store read or path authority. registry:Copies@465,registry:FleetBox@616,registry:FleetBoxes@254,registry:FleetBoxes@450,registry:FleetLabel@629,registry:ReplicaIncarnation@496,registry:ReplicaRevision@476,registry:Stateless@595 be1287470cf6b9cfbef39e9740c21b461d952b265098d72c9e32c37e6326e383 |
| internal/provision/replicaassignment.go replicaRowLifetimeAllowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P11: pure comparison of the already-read record and local route. Requires same owner and managed instance kind; accepts unprojected legacy rows for membership, matching lifetimes, or a proven older monotonic counter. Newer/unknown ordering refuses. registry:Account@145,registry:App@174,registry:Canary@132,registry:FleetBoxes@387,registry:Host@195,registry:Incarnation@218,registry:Kind@92,registry:Platform@117,registry:Provisioned@74,registry:ReplicaIncarnation@410,registry:ReplicaIncarnation@442,whole:Route@495 03c64806b231b7af2844dc47eaeefc52549bbce0e6afd56ed3d103d87f2f42a0 |
| internal/provision/replicaassignment.go replicaRowOlder legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P11: compares existing nonzero monotonic incarnation counters to prove a projected row older. Does not order hash identities or use registry creation timestamps as record evidence. Pure supplied values. registry:Incarnation@120,registry:Incarnation@98,registry:ReplicaIncarnation@67 3537ecb5ea34e2dc607f7b58e6ec89c49445a6f6568744478470a45c4c968b35 |
| -internal/registry/replicas.go Registry.DeleteReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Existing registry connection reads the current local route in an immediate transaction and deletes only exact equality with observed instance row. Refuses sidecar/platform/canary/nonprovisioned rows; no bucket write or stop ACK. file:Exec@661,file:QueryRow@489,registry:Canary@131,registry:Changed@382,registry:FleetBoxes@175,registry:Host@550,registry:Host@704,registry:Kind@79,registry:Platform@110,registry:Provisioned@151,registry:remote@247,registry:remote@279,whole:Route@347,whole:Route@357,whole:Route@612,whole:Route@618,whole:remoteClient@249,whole:remoteClient@281 64b52031ade4d47aac047cd3508672c32b0ea2b854d5bf03175b335b27bb91b3 |
| -internal/registry/replicas.go Registry.ReplaceReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P11: same registry SQL connection atomically compares the complete observed instance row, deletes only the proven older nonzero-counter lifetime and inserts its current same-owner projection. Refuses claims, held/foreign/non-instance rows, non-increasing counters and invalid next projections. Uses existing normalized insert and alias carry inside the transaction, never a bucket read or stop ACK. file:Exec@1188,registry:Account@517,registry:Account@537,registry:App@553,registry:App@569,registry:Backing@356,registry:Canary@228,registry:Canary@247,registry:Changed@941,registry:ClaimOwnership@654,registry:ClaimOwnership@703,registry:FleetBoxes@399,registry:FleetBoxes@462,registry:HA@308,registry:Hibernate@319,registry:HoldOp@262,registry:HoldOp@287,registry:Host@1058,registry:Host@1231,registry:Host@1409,registry:Host@1515,registry:Host@487,registry:Host@504,registry:Incarnation@581,registry:Incarnation@610,registry:Incarnation@634,registry:Kind@117,registry:Kind@86,registry:Platform@190,registry:Platform@211,registry:Provisioned@145,registry:Provisioned@170,registry:Socket@1529,registry:Tunnel@378,registry:Unit@337,registry:remote@791,registry:remote@823,whole:ClaimOwnership@663,whole:ClaimOwnership@708,whole:Route@1114,whole:Route@1133,whole:Route@1144,whole:Route@1306,whole:Route@1368,whole:Route@1379,whole:Route@1492,whole:Route@892,whole:Route@902,whole:Route@912,whole:Route@920,whole:remoteClient@793,whole:remoteClient@825 68a27ce02fea53c0b0cc56e74862ca819717269efc1e725183ed67b995662c24 |
| +internal/registry/replicas.go Registry.DeleteReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Existing registry connection reads the current local route in an immediate transaction and deletes only exact equality with observed instance row. Refuses sidecar/platform/canary/nonprovisioned rows; no bucket write or stop ACK. Fix round 2: the existing UPDATE/DELETE also carries kind <> forward in SQL; writer-inventory tests cover the ordinary change and a forward-row refusal/no-op. Same transaction and read sources. file:Exec@661,file:QueryRow@489,registry:Canary@131,registry:Changed@382,registry:FleetBoxes@175,registry:Host@550,registry:Host@726,registry:Kind@79,registry:Platform@110,registry:Provisioned@151,registry:remote@247,registry:remote@279,whole:Route@347,whole:Route@357,whole:Route@612,whole:Route@618,whole:remoteClient@249,whole:remoteClient@281 45568f3d81b37eaa4dfb46e99fce44e1dcb5da606fa7abe2e677ba5493984abf |
| +internal/registry/replicas.go Registry.ReplaceReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=P11: same registry SQL connection atomically compares the complete observed instance row, deletes only the proven older nonzero-counter lifetime and inserts its current same-owner projection. Refuses claims, held/foreign/non-instance rows, non-increasing counters and invalid next projections. Uses existing normalized insert and alias carry inside the transaction, never a bucket read or stop ACK. Fix round 2: the existing UPDATE/DELETE also carries kind <> forward in SQL; writer-inventory tests cover the ordinary change and a forward-row refusal/no-op. Same transaction and read sources. file:Exec@1188,registry:Account@517,registry:Account@537,registry:App@553,registry:App@569,registry:Backing@356,registry:Canary@228,registry:Canary@247,registry:Changed@941,registry:ClaimOwnership@654,registry:ClaimOwnership@703,registry:FleetBoxes@399,registry:FleetBoxes@462,registry:HA@308,registry:Hibernate@319,registry:HoldOp@262,registry:HoldOp@287,registry:Host@1058,registry:Host@1253,registry:Host@1431,registry:Host@1537,registry:Host@487,registry:Host@504,registry:Incarnation@581,registry:Incarnation@610,registry:Incarnation@634,registry:Kind@117,registry:Kind@86,registry:Platform@190,registry:Platform@211,registry:Provisioned@145,registry:Provisioned@170,registry:Socket@1551,registry:Tunnel@378,registry:Unit@337,registry:remote@791,registry:remote@823,whole:ClaimOwnership@663,whole:ClaimOwnership@708,whole:Route@1114,whole:Route@1133,whole:Route@1144,whole:Route@1328,whole:Route@1390,whole:Route@1401,whole:Route@1514,whole:Route@892,whole:Route@902,whole:Route@912,whole:Route@920,whole:remoteClient@793,whole:remoteClient@825 c5aa38bd8539aab43e06a14541a768799a44144518ffe0b68a4ae1005b05ba77 |
| internal/registry/replicas.go Registry.SeedReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Requires an observed legacy row and delegates to atomic equality-checked projection writer; no new path or record read. registry:Copies@220,registry:FleetBoxes@158,registry:Host@307,registry:ReplicaIncarnation@121,registry:ReplicaRevision@187,whole:Route@354 6859324045aba010d3a96b4df9b306902e47e8c3dbecf8efa49e1fe6967d4151 |
| -internal/registry/replicas.go Registry.setReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Same local registry SQL connection reads one route in a transaction; freezes identity on seed, rejects lifetime/revision mismatch and forbidden row shapes. Writes declarative set columns only, no paths or bucket data. file:Exec@1463,file:QueryRow@698,registry:Backing@1058,registry:Canary@1003,registry:Copies@1353,registry:FleetBoxes@1327,registry:HA@1016,registry:Hibernate@1025,registry:Kind@944,registry:Method@509,registry:Observed@547,registry:Platform@988,registry:Provisioned@970,registry:Region@886,registry:ReplicaIncarnation@1117,registry:ReplicaRevision@1198,registry:ReplicaRevision@1281,registry:Stateless@1388,registry:Tunnel@1078,registry:Unit@1041,registry:remote@335,registry:remote@586,whole:Route@1098,whole:Route@1159,whole:Route@1178,whole:Route@1185,whole:Route@488,whole:Route@549,whole:Route@561,whole:remoteClient@337,whole:remoteClient@588,whole:remoteRequest@605 b61ec1197d681cf71b1c78c06a4af746c4825457e44caf65d636df2778f59206 |
| +internal/registry/replicas.go Registry.setReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Same local registry SQL connection reads one route in a transaction; freezes identity on seed, rejects lifetime/revision mismatch and forbidden row shapes. Writes declarative set columns only, no paths or bucket data. Fix round 2: the existing UPDATE/DELETE also carries kind <> forward in SQL; writer-inventory tests cover the ordinary change and a forward-row refusal/no-op. Same transaction and read sources. file:Exec@1463,file:QueryRow@698,registry:Backing@1058,registry:Canary@1003,registry:Copies@1353,registry:FleetBoxes@1327,registry:HA@1016,registry:Hibernate@1025,registry:Kind@944,registry:Method@509,registry:Observed@547,registry:Platform@988,registry:Provisioned@970,registry:Region@886,registry:ReplicaIncarnation@1117,registry:ReplicaRevision@1198,registry:ReplicaRevision@1281,registry:Stateless@1388,registry:Tunnel@1078,registry:Unit@1041,registry:remote@335,registry:remote@586,whole:Route@1098,whole:Route@1159,whole:Route@1178,whole:Route@1185,whole:Route@488,whole:Route@549,whole:Route@561,whole:remoteClient@337,whole:remoteClient@588,whole:remoteRequest@605 0565599be1b90bdaf2131bb097b48e44e4269bfa2b9c2610cf0fa7a11ed8a7ec |
| internal/registry/replicas.go Route.ReplicaContains legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Pure validated membership of the supplied canonical JSON array; no external read. registry:FleetBoxes@170,registry:FleetBoxes@85 f793980f7dd8efb9fcdfabfb3f60a5797ccd0920c51fd0aae10b276ca3a8223b |
| internal/registry/replicas.go Route.ValidReplicaProjection legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Pure canonical JSON/count/lifetime/revision/mode validation of supplied route; absent fields remain legacy. registry:Copies@327,registry:Copies@81,registry:FleetBoxes@200,registry:FleetBoxes@425,registry:FleetBoxes@51,registry:Region@380,registry:ReplicaIncarnation@124,registry:ReplicaIncarnation@441,registry:ReplicaRevision@471,registry:ReplicaRevision@496,registry:ReplicaRevision@98,registry:Stateless@534 6ba44570ad006fbfd89257f2969f4940db67f201c08d44763f2989b75b7dc1a5 |
| internal/activator/cmd.go Service.RunCmd legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): admits one run against an awake entry under the agent's own lease, fence and swap checks; it starts nothing itself and root validates what it later names;rev3=census-ruling-edge-request-records;basis=passes nil for begin's new req parameter; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: a carlos run is refused with ErrCmdBusy while a release record of the host is open (a.releaseOps[rt.Host], in-memory), as a run already in flight refuses it; new site +registry:Host (that map lookup); adds a refusal only;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: AfterSettled honoured on every path (called before return on each path that starts no unit, else by the settle that proves the unit gone); a rootfs run is refused as a lost lease (CmdStoppedError StopLeaseLost) when its entry is not under the lease watch (residentWatchedLocked), and, off a.mu, when the replica's in-memory SafeUntil leaves less than oneShotStartLead (oneShotHeadroom); new sites are e.route.Rootfs() and a log line; adds refusals only Task 9 (PF-17): a session (spec.TTY) takes the entry's tty slot and a run its cmd slot (holdSlot), the hold carrying its role (newCmdHold); each is refused only for its own role (holdBusyLocked: ErrCmdBusy or ErrTTYBusy), so a run and a session coexist; a release command (a.releaseOps) refuses a run only, since the session's tty unit is its own; no read added, read sites unchanged Task 12 fix round 1 (Astra P1, incarnation binding): a session (spec.TTY) is refused with ErrCmdIncarnation, under a.mu, at admission (before the hold is attached, so nothing of it runs) and again at the last check before the start, unless the awake entry's row lifetime (e.route.Incarnation) equals spec.Incarnation, the lifetime the box's grant authorized; Task 12 fix round 2 (revised ruling): only a mismatch refuses, and 0 matches 0 (a record and row with no lifetime fields); a run is not checked; refuses more, starts nothing new, no read added beyond the in-memory e.route field (sessionIncarnationLocked);rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Take command/TTY mode from the actual serving generation alongside the existing captured environment; no authority comes from a route flag.;rev3=census-ruling-stateless-replicas-2;basis=Only a set command chains the existing exec gate to the current record membership recheck immediately before exec; preserves caller gate and legacy path. file:Prepare@2688,file:Prepare@2722,registry:FleetBoxes@9308,registry:Host@1502,registry:Host@2098,registry:Host@7932,registry:Host@9168,registry:Kind@437,registry:Stateless@5132,whole:Route@683,whole:Route@8336,whole:Route@869,whole:Route@8800,whole:Route@9497,whole:Route@9538 1c58059ab419d2a1fc1647c031f2e81647c1f892642656134cf1721b4d90d689 |
| @@ -71,7 +71,7 @@ internal/provision/reconcile.go RouteFor authority C,E3 rev3=census-ruling-self- |
| @coverage internal/appconfig 32d5f27628b319917ed88ac39e0b22e25292f8f16ba5ef4e69a57ea35471bf77 |
| @coverage internal/host 68d15300ba45ee8824cb450e15606035c450f815b7bc0e17f5f8b2f57f75a96d |
| @coverage internal/provision c4a69a96ab2cb84bb8f0405930fdb07fe4840893aeadac9f5c9906910f505d8f |
| -@coverage internal/registry 3889d5b74a40981731ec5543c6b9c3c87c20cb84249e72a6847ff4a0f2c985aa |
| +@coverage internal/registry e1e3f0d8614acc3c5f221a4e9705d5d109fa72e4dae211607f231832ace2a7b0 |
| @coverage internal/release 6c7784eb02f9c2b68045266dabf5a79fb656bcb11a06427787d74ca8f3f96dd6 |
| @coverage internal/replicas 6fbf542a6720e5b969b92f8401c7cc8b01f89a0b8b11141e7e7e99a3de612c73 |
| @fields A,Account,Accounts,AddedAt,Addr,Addrs,Alias,Aliases,Alive,AllowAbsent,App,Archives,Args,AssetGen,AssetsOff,Assigned,Assignment,At,Attempts,B,Backing,Bucket,BuildState,By,Callback,CallbackError,CallbackFailed,Canary,Caps,CertExpiresAt,Changed,Channel,CheckedAt,Claim,ClaimIncarnation,ClaimOwner,ClaimOwnership,ClaimRowID,ClaimStamp,Class,Column,Contents,Copies,CreatedAt,DBPath,DNSCheckedAt,DNSStatus,Deadline,Default,Demand,Digest,DoneBefore,DrainingSince,Due,DueAt,EgressAllow,Env,EnvBefore,Environment,Error,ErrorKind,ExcludeHosts,ExpectGood,ExpectOp,ExpectPair,Expected,F,Failed,FenceGen,Field,Fleet,FleetBox,FleetBoxes,FleetLabel,Fleets,From,FromDB,FromOp,FromSock,Gate,GoodDemand,GoodDigest,GoodVersion,HA,Hash,Health,Held,Hibernate,HoldOp,Host,Hosts,ID,Id,IdValue,Idle,IdleSeconds,ImportGate,Incarnation,Journal,Keep,KeyFP,Kind,Label,LabelledAt,LastAt,LastError,LastMs,LastStatus,Limit,MaxRun,MaxRunSeconds,Method,Moved,Ms,Name,Next,NextAt,NextDue,NextGood,NextValue,Now,Number,Number64,Observed,ObservedValue,Old,On,OnConflict,Op,Original,Owner,Ownership,P,Pair,Path,Paths,Platform,PolicyExpiresAt,Pool,Prefix,Prev,PrevVersion,Provisioned,Pub,RDs,RateLimit,RecordKey,Region,Regional,Registration,Replica,ReplicaIncarnation,ReplicaLife,ReplicaRevision,Replicas,Replication,Retirement,Route,Routes,Row,Rows,Runtime,SecretsKeyFP,SecretsKeySetAt,SecretsKeySetBy,SecretsPub,Seed,SeedID,SeedSource,ServingSeq,ServingVersion,Size,Slug,Socket,Spec,Sqid,State,Stateless,Status,StatusNamed,Steering,StringMap,T,TValue,Tags,Target,Targets,Text,Timer,Timers,Times,To,ToDB,ToOp,ToSock,TokenHash,Tunnel,Type,Unit,UpdateSettings,Ver,Version,W,WakeIncarnation,Wildcards,closed,conn,connect,ctx,d,dec,done,enc,full,input,mu,output,path,readOnly,remote,sql,wait |
diff --git a/internal/registry/forward_test.go b/internal/registry/forward_test.go| index bd05703c8..c6e23bd48 100644 |
| --- a/internal/registry/forward_test.go |
| +++ b/internal/registry/forward_test.go |
| @@ -275,9 +275,9 @@ func TestPutForwardSetsEveryColumnButHost(t *testing.T) { |
| case forwardShape[k.Field] == "declared": |
| want = "excluded." + k.Column |
| case k.Column == "fleet_box": |
| - // Managed fleets 1b rule 3: the call's label, else kept while |
| - // the region is unchanged. |
| - want = "CASE WHEN excluded.fleet_label <> '' THEN excluded.fleet_label" + |
| + // Replica sets clear the single-box binding. Otherwise use the |
| + // declared label, or retain the binding only in the same region. |
| + want = "CASE WHEN excluded.fleet_boxes <> '' THEN '' WHEN excluded.fleet_label <> '' THEN excluded.fleet_label" + |
| " WHEN routes.region = excluded.region THEN routes.fleet_box ELSE '' END" |
| } |
| if set[k.Column] != want { |
diff --git a/internal/registry/forward_writers_test.go b/internal/registry/forward_writers_test.go| index dbb5c060e..01cc3df66 100644 |
| --- a/internal/registry/forward_writers_test.go |
| +++ b/internal/registry/forward_writers_test.go |
| @@ -9,6 +9,8 @@ import ( |
| "sort" |
| "strings" |
| "testing" |
| + |
| + "github.com/carlosframework/platform/internal/replicas" |
| ) |
| // The writer rule (fleet public routes spec §4.2, R3-1): only PutForward, |
| @@ -271,9 +273,52 @@ func repointFixture(t *testing.T, r *Registry) { |
| mustUpsert(t, r, Route{Host: fwAlias, Kind: "instance", App: "shop", Account: "bah", Platform: true, Socket: fwSock}) |
| } |
| +func replicaWriterCase(name string) writerCase { |
| + encloses := name |
| + if name == "SetReplicaAssignment" || name == "SeedReplicaAssignment" { |
| + encloses = "setReplicaAssignment" |
| + } |
| + return writerCase{name: name, encloses: []string{encloses}, refuses: name == "SetReplicaAssignment" || name == "SeedReplicaAssignment", |
| + setup: func(t *testing.T, r *Registry) (string, writerCall) { |
| + host := plainRow(t, r, func(rt *Route) { |
| + rt.Region = "fleet/home" |
| + rt.Provisioned = true |
| + if name != "SeedReplicaAssignment" { |
| + rt.Stateless = true |
| + rt.FleetBoxes = `["a"]` |
| + rt.Copies = 1 |
| + rt.ReplicaRevision = 1 |
| + rt.ReplicaIncarnation = "life" |
| + rt.Incarnation = 1 |
| + } |
| + }) |
| + observed := mustRoute(t, r, host) |
| + next := observed |
| + next.Incarnation = 2 |
| + next.ReplicaIncarnation = "next-life" |
| + assignment := replicas.Assignment{Revision: 2, Desired: 2, Boxes: []string{"a", "b"}} |
| + return host, func(bool) (bool, error) { |
| + switch name { |
| + case "SetReplicaAssignment": |
| + return false, r.SetReplicaAssignment(host, "life", assignment, true) |
| + case "SeedReplicaAssignment": |
| + return false, r.SeedReplicaAssignment(observed, "life", assignment) |
| + case "DeleteReplicaAssignment": |
| + return r.DeleteReplicaAssignment(observed) |
| + default: |
| + return r.ReplaceReplicaAssignment(observed, next) |
| + } |
| + } |
| + }} |
| +} |
| + |
| func routeWriterCases() []writerCase { |
| ctx := context.Background() |
| cases := []writerCase{ |
| + replicaWriterCase("SetReplicaAssignment"), |
| + replicaWriterCase("SeedReplicaAssignment"), |
| + replicaWriterCase("DeleteReplicaAssignment"), |
| + replicaWriterCase("ReplaceReplicaAssignment"), |
| {name: "Upsert", encloses: []string{"upsertRoute"}, refuses: true, |
| setup: func(t *testing.T, r *Registry) (string, writerCall) { |
| host := plainRow(t, r, nil) |
| @@ -516,6 +561,7 @@ func routeWriterCases() []writerCase { |
| // boolWriters are the cases whose writer answers with a bool: the positive |
| // arm must see true. |
| var boolWriters = map[string]bool{ |
| + "DeleteReplicaAssignment": true, "ReplaceReplicaAssignment": true, |
| "InstallLifetimeIf": true, "SetHoldIf": true, "SetHoldIfSeq": true, "HandHold": true, "ReleaseHold": true, |
| "ReleaseHoldSeq": true, "DeleteIfHold": true, "DeleteIfHoldWithTimers": true, "DeleteIfUnchanged": true, |
| "RepointPlatformSocket (alias forward)": true, "RepointPlatformSocket (source forward)": true, |
diff --git a/internal/registry/registry.go b/internal/registry/registry.go| index 785c16323..a33ac47a8 100644 |
| --- a/internal/registry/registry.go |
| +++ b/internal/registry/registry.go |
| @@ -4280,32 +4280,36 @@ var snapshotClaimCols = map[string]bool{ |
| // snapshotWhenSetCols are the good-build columns (zero-downtime spec §8.5), |
| // the update-settings column, the runtime column, the rate-limit column and |
| -// the app policy columns (#328, #329). A restore has to reproduce them, so |
| +// the app policy columns (#328, #329), and replica set/lifetime strings. |
| +// A restore has to reproduce them, so |
| // they are hashed, but only when set and tagged, on the hold_op rule: a |
| // registry that has never recorded a good build, set update settings, |
| // minted a rootfs row, set a custom rate limit or converged a policy |
| // digests exactly as it did before the columns existed, so upgrading does |
| // not force a snapshot on every box. |
| var snapshotWhenSetCols = map[string]bool{ |
| - "good_version": true, |
| - "good_digest": true, |
| - "good_demand": true, |
| - "update_settings": true, |
| - "runtime": true, |
| - "rate_limit": true, |
| - "egress_allow": true, |
| - "size": true, |
| - "policy_expires_at": true, |
| - "fleet_assigned": true, |
| - "fleet_label": true, |
| + "good_version": true, |
| + "good_digest": true, |
| + "good_demand": true, |
| + "update_settings": true, |
| + "runtime": true, |
| + "rate_limit": true, |
| + "egress_allow": true, |
| + "size": true, |
| + "policy_expires_at": true, |
| + "fleet_assigned": true, |
| + "fleet_label": true, |
| + "fleet_boxes": true, |
| + "replica_incarnation": true, |
| } |
| -// snapshotPairCols are the lifetime pair's columns (self-serve moves plan 1 |
| -// Task 7), restore state hashed only when non-zero, so a registry whose rows |
| -// are all at (0, 0) digests as it did before the columns existed. |
| +// snapshotPairCols are the lifetime pair and replica count/revision columns. |
| +// Hash them only when nonzero, so legacy rows keep their original digest. |
| var snapshotPairCols = map[string]bool{ |
| - "incarnation": true, |
| - "serving_seq": true, |
| + "incarnation": true, |
| + "serving_seq": true, |
| + "copies": true, |
| + "replica_revision": true, |
| } |
| func (r *Registry) SnapshotFingerprint() (string, error) { |
diff --git a/internal/registry/replicas.go b/internal/registry/replicas.go| index 26cb8c232..90b3758d3 100644 |
| --- a/internal/registry/replicas.go |
| +++ b/internal/registry/replicas.go |
| @@ -90,7 +90,7 @@ func (r *Registry) setReplicaAssignment(host, incarnation string, assignment rep |
| if rt.ReplicaRevision == assignment.Revision && (rt.FleetBoxes != boxes || rt.Copies != assignment.Desired || rt.Stateless != stateless) { |
| return ErrReplicaAssignment |
| } |
| - _, err = tx.Exec(`UPDATE routes SET replica_incarnation=?, fleet_boxes=?, copies=?, replica_revision=?, stateless=?, fleet_box='', fleet_label='' WHERE host=?`, incarnation, boxes, assignment.Desired, assignment.Revision, b2iDB(stateless), host) |
| + _, err = tx.Exec(`UPDATE routes SET replica_incarnation=?, fleet_boxes=?, copies=?, replica_revision=?, stateless=?, fleet_box='', fleet_label='' WHERE host=? AND kind <> 'forward'`, incarnation, boxes, assignment.Desired, assignment.Revision, b2iDB(stateless), host) |
| return err |
| }) |
| } |
| @@ -114,7 +114,7 @@ func (r *Registry) DeleteReplicaAssignment(observed Route) (bool, error) { |
| if rt != observed { |
| return nil |
| } |
| - if _, err = tx.Exec(`DELETE FROM routes WHERE host=?`, observed.Host); err != nil { |
| + if _, err = tx.Exec(`DELETE FROM routes WHERE host=? AND kind <> 'forward'`, observed.Host); err != nil { |
| return err |
| } |
| deleted = true |
| @@ -142,7 +142,7 @@ func (r *Registry) ReplaceReplicaAssignment(observed, next Route) (bool, error) |
| if current == nil || *current != observed { |
| return nil |
| } |
| - if _, err := tx.Exec(`DELETE FROM routes WHERE host=?`, observed.Host); err != nil { |
| + if _, err := tx.Exec(`DELETE FROM routes WHERE host=? AND kind <> 'forward'`, observed.Host); err != nil { |
| return err |
| } |
| if err := upsertRoute(tx, next, ""); err != nil { |
diff --git a/internal/registry/replicas_test.go b/internal/registry/replicas_test.go| index 49aad7ec4..d80525c69 100644 |
| --- a/internal/registry/replicas_test.go |
| +++ b/internal/registry/replicas_test.go |
| @@ -208,3 +208,35 @@ func TestReplicaForwardReplacementCannotLoseNewerRow(t *testing.T) { |
| t.Fatal("replaced with older lifetime") |
| } |
| } |
| + |
| +func TestReplicaSnapshotColumnsOnlyWhenSet(t *testing.T) { |
| + r := openTestRegistry(t) |
| + defer r.Close() |
| + rt := Route{Host: "shop.example.com", Kind: "instance", Account: "bah", App: "shop"} |
| + if err := r.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + before, err := r.SnapshotFingerprint() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, col := range []struct { |
| + name string |
| + set, zero any |
| + }{{"fleet_boxes", `["a"]`, ""}, {"replica_incarnation", "life", ""}, {"copies", 1, 0}, {"replica_revision", 1, 0}} { |
| + if _, err := r.sql.Exec("UPDATE routes SET "+col.name+"=? WHERE host=?", col.set, rt.Host); err != nil { |
| + t.Fatal(err) |
| + } |
| + changed, err := r.SnapshotFingerprint() |
| + if err != nil || changed == before { |
| + t.Fatalf("%s not hashed: %s %v", col.name, changed, err) |
| + } |
| + if _, err := r.sql.Exec("UPDATE routes SET "+col.name+"=? WHERE host=?", col.zero, rt.Host); err != nil { |
| + t.Fatal(err) |
| + } |
| + cleared, err := r.SnapshotFingerprint() |
| + if err != nil || cleared != before { |
| + t.Fatalf("%s zero changed legacy digest: %s %v", col.name, cleared, err) |
| + } |
| + } |
| +} |