carlos / platform Public

feat: reconcile stateless instance box sets

Project canonical replica sets through registry SQL, remote RPC and inert
forward rows. Reconcile only verified managed stateless assignments, fence
membership and lifetime at admission, retirement, command pickup and exec,
and preserve local databases and outstanding stop-proof obligations.

Add guarded legacy-row projection and conditional local retirement. Keep
single-box binding writers from collapsing sets and refuse incompatible
label/region edits. Cover migration, forwarding, reconciliation and start
refusals, and refresh both census inventories for independent review.
Co-Authored-By: Codex (gpt-6-astra) <noreply@openai.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 73c11378613d181dfa47b1fc1eec979ae0bbf484 parent 1fa2688
26 files changed, +999 −37
  • docs/superpowers/notes/census-proposal-stateless-replicas-2.md +49 −5
  • internal/activator/cmd.go +9 −0
  • internal/activator/cmdunit.go +5 −0
  • internal/activator/startrule.go +12 −0
  • internal/activator/stateless_assignment_test.go +148 −0
  • internal/activator/wakeidentity.go +28 −1
  • internal/host/fleetbind.go +1 −1
  • internal/host/fleetidentity.go +14 −0
  • internal/host/runs.go +5 −0
  • internal/host/stateless_assignment_test.go +56 −0
  • internal/provision/fleetbox.go +3 −0
  • internal/provision/forward.go +5 −1
  • internal/provision/provision.go +3 −0
  • internal/provision/reconcile.go +62 −3
  • internal/provision/replicaassignment.go +25 −0
  • internal/provision/replicaassignment_test.go +1 −1
  • internal/provision/replicas_test.go +173 −0
  • internal/provision/stateless_placement_census_test.go +10 −6
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-stateless-replicas-2.tsv +65 −3
  • internal/registry/forward.go +16 −4
  • internal/registry/registry.go +26 −10
  • internal/registry/remote.go +1 −1
  • internal/registry/remote_dispatch.go +9 −0
  • internal/registry/replicas.go +124 −0
  • internal/registry/replicas_test.go +148 −0

CI failed — run details

Intent

Human

<task-notification> <task-id>bftwtyxyu</task-id> <tool-use-id>toolu_01RLxMD3WJt1GvzVjWXir7SC</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/7c5a7d70-0e28-42b9-896c-5d73b2d2a05d/tasks/bftwtyxyu.output</output-file> <status>completed</status> <summary>Background command "Wait for resumed 2a and CI" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 50.5 g CO₂e (6,072,750 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 9bc46840b..5234205fb 100644
--- a/docs/superpowers/notes/census-proposal-stateless-replicas-2.md
+++ b/docs/superpowers/notes/census-proposal-stateless-replicas-2.md
@@ -1,13 +1,57 @@
-# Census approval: stateless-replicas-2
+# Census proposal (independent approval pending): stateless-replicas-2
-Status: proposed. Independent review and recording on #280 remain outstanding.
+Ruling `census-ruling-stateless-replicas-2`. The independent reviewer approves or rejects every change below, 25 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
-Ruling `census-ruling-stateless-replicas-2`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/registry/forward.go` `Registry.SetFleetBoxIf` | body | unchanged (7) | Existing conditional SQL write refuses every replica projection; a binding cannot collapse a set. No new read source. |
+| `internal/registry/forward.go` `Route.InertForward` | body | unchanged (52) | Pure validation additionally refuses malformed set projections; all unrelated forbidden fields still must be zero. |
+| `internal/registry/registry.go` `Registry.Fingerprint` | body | unchanged (33) | Four additive projection columns join the existing routes SELECT and hash only when nonzero; no new query or file read. |
+| `internal/registry/registry.go` `upsertRoute` | body | unchanged (3) | Existing guarded SQL upsert carries four additive projection columns; no new read source or execution authority. |
+| `internal/host/runs.go` `runsWorker.pickup` | sites | +whole:Route | Passes the already-owned Route to the activator current-record recheck before pickup, only for set rows; legacy reads unchanged. |
+| `internal/provision/reconcile.go` `RouteFor` | sites | +whole:Route | Projects count, canonical boxes, revision, CreatedAt-derived lifetime and stateless hint from the supplied record. No store read; hint does not authorize a database bypass. |
-Envelopes re-pinned: `.`, `internal/appconfig`, `internal/provision`, `internal/release`, `internal/replicas`.
+Envelopes re-pinned: `.`, `internal/activator`, `internal/appconfig`, `internal/host`, `internal/provision`, `internal/registry`, `internal/release`, `internal/replicas`.
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.
-Seal: `df8bf8056d80b9d78edc957fe7f2adbc75885e15f581e58167768346c4e05771` → `df8bf8056d80b9d78edc957fe7f2adbc75885e15f581e58167768346c4e05771`.
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/registry/forward.go` `Registry.SetFleetBoxIf`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 1: one conditional UPDATE of fleet_box judging placement on the fleet (region = 'fleet/'||fleet), kind (not a sidecar) and ACTIVE membership in fleet_boxes at the write; returns whether a row changed (+file:Exec, +registry:Changed, +registry:remote x2, +registry:sql, +whole:remoteClient x2). Replaces SetFleetBox.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the one conditional UPDATE gains AND fleet_label = '', so a labelled forward row's fleet_box is never changed by a binding. Read sites unchanged (7). It writes less, never more. Agent hub's bindings pass, not root.
+- `internal/registry/forward.go` `Route.InertForward`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 2: true only when every one of the 50 forbidden columns of §4.2 is zero (one +registry:<field> site each, nothing else). Pure.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2): two more forbidden fields must be zero on a forward row, Assigned == "" and !Moved (fleet_assigned, fleet_moved in ForwardForbidden). Stricter, never looser.
+- `internal/registry/registry.go` `Registry.Fingerprint`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user); the remote arm, unchanged, in the process that holds a remote handle: census-ruling-seeded-instances's body with the row's lifetime pair (incarnation, serving_seq) folded into the edge's change poll, each only when non-zero, so a registry with no pair digests as before; self-serve moves 1 Task 7;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: hashes regional_domains (host, target, account, app, region; created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no regional rows digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; no file path read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): review R1 finding 1: the routes SELECT also reads host, kind, account, app, platform and fingerprintForwardInert (one CASE over the ForwardForbidden columns), and every row folds host, kind, account and app (tagged, quoted), platform when set, and forward_inert=0 for a forward row that is not inert, so a rowid reused by another hostname, an in-place account or app rewrite, or a stray forbidden column moves the edge's change poll. Same one SELECT per table on the same fresh connection to the box's own registry database, as carlos; no table, file or bucket read added; a digest, never a decision.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5): the SELECT also reads fleet_label and, only when it is set, hashes "fleet_label=<q>" into the digest, so labelling a row moves the edge's reload fingerprint. Read sites unchanged (33). Registry side, not root; an unlabelled registry's digest is byte-identical.;rev3=census-ruling-stateless-replicas-1;basis=Read the additive stateless projection in the existing registry SELECT and hash only when set; no new read source.
+- `internal/registry/registry.go` `upsertRoute`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-alias-socket-follow-338;basis=#338: Upsert's unchanged statement moved into a helper so it can run on the database or inside a transaction;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 2 (runtimeFixed in the registry): takes a guard appended to the ON CONFLICT WHERE (UpsertUnlessRootfs passes routes.runtime = ''); a stored row with a runtime keeps its region and hibernate unless the tenant changed; replication is cleared only when the effective runtime is empty; no new read source, same SQLite table;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 3: on a refused conflict, the forward check reads the host (+registry:Host) to answer ErrForwardRow; the statement carries kind <> 'forward'. A refusal only.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2): the conflict arm gains fleet_assigned (the excluded value on a re-tenanted host, else kept when the writer carries '') and fleet_moved (excluded on a re-tenanted host, else MAX of stored and excluded). Read sites unchanged (3). The same statement guard (claim ownership, kind <> 'forward') applies.;rev3=census-ruling-stateless-replicas-1;basis=Persist the stateless projection in the existing guarded upsert; no new read.
+- `internal/host/runs.go` `runsWorker.pickup`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), its runs worker: a picked run's detached execution runs under provision.WithLifetimes of the worker's judge, so execute's record writes refuse a stale record; read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 16 (ruling R7): on a fleet box a run already let go is skipped before any read; the pickup CAS moves behind the run's sink (sinkFor: the bucket's, as before, or on a fleet box the run door relay once a grant verifies); one more whole-Route site, the row this box already owns passed to sinkFor; nothing new opened, run or followed
+- `internal/provision/reconcile.go` `RouteFor`: authority, task C,E3. Basis: rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos); also root, in the claim root's landing registration (ClaimRootHTTP.rootLandingRoute) and the relocation install (relocationRecord): census-ruling-seeded-instances's body with two more fields from the record: the row's lifetime pair (rec.Incarnation, rec.MoveSeq), so a row minted outside a move takes the record's lifetime and its last move's sequence (0, 0 for a fieldless record with no move history); every caller gets it, the root ones included: the root callers (ClaimRootHTTP.rootLandingRoute, relocationRecord) now mint (0, move_seq) on a claims-on record, a non-zero sequence once that record has had an offline move (move_seq advances on claims-on offline moves too), which moves Fingerprint and SnapshotFingerprint once for that row; main's C,E3 authority retained; self-serve moves 1 Task 7 (fix round 1: root callers named);rev3=census-ruling-region-ha-p1a;basis=the agent's reconcile passes, and also root's callers (rootupdates.go, rootinventory_install.go and relocationinstall.go on HEAD): one more field copied from the record, HA: rec.HA, so a row minted from a record stamped HA carries the sticky born-HA mark; the record is the console-written instance record each caller already read; root's own code reads nothing of Route.HA, and Fingerprint does not include it (SnapshotFingerprint does, for a set mark); the same nine sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 2: the row is minted with the record's Runtime (the console-written instance record, guarded by WriteRecord's runtimeFixed); a rootfs row always gets the nested socket and db path under dataDir and no seed or seed source; the paths are computed from the host, not read from the record;rev3=census-ruling-fresh-box-446;basis=#446: a born-HA record mints the nested paths whatever nested says, as a rootfs row already does; same reads;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2, rule 6): the route also carries Assigned = rec.FleetBoxAt and Moved = rec.FleetBoxMoved, copied from the record it is handed. Read sites unchanged (13). In the agent; in root's claim landing registration (ClaimRootHTTP.rootLandingRoute, shelved claims code) the canonical route gains these two copied fields, which no root check compares (the comparison at rootinventory.go and ValidateAgentInventory read neither). No new input to root.
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- new `internal/activator/wakeidentity.go:Service.CheckReplicaAssignment`: reads +registry:FleetBoxes, +whole:Route; written legacy, accepted-legacy, frozen
+- new `internal/host/fleetidentity.go:recheckReplicaPickup`: reads +registry:FleetBoxes, +whole:Route; written legacy, accepted-legacy, frozen
+- new `internal/provision/forward.go:forwardRowFor`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen
+- new `internal/provision/replicaassignment.go:projectReplicaAssignment`: reads +registry:Copies, +registry:FleetBox, +registry:FleetBoxes, +registry:FleetLabel, +registry:ReplicaIncarnation, +registry:ReplicaRevision, +registry:Stateless; written legacy, accepted-legacy, frozen
+- new `internal/registry/replicas.go:Registry.DeleteReplicaAssignment`: reads +file:Exec, +file:QueryRow, +registry:Canary, +registry:Changed, +registry:FleetBoxes, +registry:Host ×2, +registry:Kind, +registry:Platform, +registry:Provisioned, +registry:remote ×2, +whole:Route ×4, +whole:remoteClient ×2; written legacy, accepted-legacy, frozen
+- new `internal/registry/replicas.go:Registry.SeedReplicaAssignment`: reads +registry:Copies, +registry:FleetBoxes, +registry:Host, +registry:ReplicaIncarnation, +registry:ReplicaRevision, +whole:Route; written legacy, accepted-legacy, frozen
+- new `internal/registry/replicas.go:Registry.setReplicaAssignment`: reads +file:Exec, +file:QueryRow, +registry:Backing, +registry:Canary, +registry:Copies, +registry:FleetBoxes, +registry:HA, +registry:Hibernate, +registry:Kind, +registry:Method, +registry:Observed, +registry:Platform, +registry:Provisioned, +registry:Region, +registry:ReplicaIncarnation, +registry:ReplicaRevision ×2, +registry:Stateless, +registry:Tunnel, +registry:Unit, +registry:remote ×2, +whole:Route ×7, +whole:remoteClient ×2, +whole:remoteRequest; written legacy, accepted-legacy, frozen
+- new `internal/registry/replicas.go:Route.ReplicaContains`: reads +registry:FleetBoxes ×2; written legacy, accepted-legacy, frozen
+- new `internal/registry/replicas.go:Route.ValidReplicaProjection`: reads +registry:Copies ×2, +registry:FleetBoxes ×3, +registry:Region, +registry:ReplicaIncarnation ×2, +registry:ReplicaRevision ×3, +registry:Stateless; written legacy, accepted-legacy, frozen
+- other `changed registry schema`: closed only if it is the registry schema (re-pinned)
+- reads `internal/activator/cmd.go:Service.RunCmd`: +registry:FleetBoxes, +whole:Route; keeps legacy, task accepted-legacy
+- reads `internal/activator/cmdunit.go:ExecBackend.StartCmd`: +registry:FleetBoxes; keeps legacy, task accepted-legacy
+- reads `internal/activator/startrule.go:ExecBackend.establishAssignment`: +registry:FleetBoxes; keeps legacy, task accepted-legacy
+- reads `internal/activator/startrule.go:ExecBackend.reconcileAssignment`: +registry:FleetBoxes; keeps legacy, task accepted-legacy
+- reads `internal/activator/startrule.go:ExecBackend.startAllowed`: +registry:FleetBoxes; keeps legacy, task accepted-legacy
+- reads `internal/activator/wakeidentity.go:Service.currentWakeRoute`: +registry:Account, +registry:App, +registry:Channel, +registry:Copies, +registry:Environment, +registry:FleetBoxes ×4, +registry:Host, +registry:Kind, +registry:Region ×2, +registry:ReplicaIncarnation, +registry:ReplicaRevision, +registry:Runtime, +whole:Route; keeps legacy, task accepted-legacy
+- reads `internal/activator/wakeidentity.go:leaseRouteChanged`: +registry:Copies ×2, +registry:FleetBoxes ×2, +registry:ReplicaIncarnation ×2, +registry:ReplicaRevision ×2; keeps legacy, task accepted-legacy
+- reads `internal/host/fleetbind.go:statelessBindingPublisher.publish`: +registry:FleetBoxes; keeps legacy, task accepted-legacy
+- reads `internal/provision/forward.go:forwardCurrent`: +registry:Copies ×2, +registry:FleetBox, +registry:FleetBoxes ×4, +registry:ReplicaIncarnation ×2, +registry:ReplicaRevision ×2, +registry:Stateless ×2; keeps legacy, task accepted-legacy
+- reads `internal/provision/reconcile.go:Reconcile`: +registry:Account ×2, +registry:App ×2, +registry:Canary, +registry:FleetBoxes ×3, +registry:Host ×2, +registry:Platform, +registry:ReplicaIncarnation ×2, +whole:Route; keeps legacy, task accepted-legacy
+- reads `internal/provision/reconcile.go:convergeOwned`: +registry:Copies ×2, +registry:FleetBoxes ×2, +registry:ReplicaIncarnation ×5, +registry:ReplicaRevision ×2, +registry:Stateless, +whole:Route; keeps legacy, task accepted-legacy
+- reads `internal/registry/forward.go:Registry.PutForward`: +registry:Copies, +registry:FleetBox, +registry:FleetBoxes ×2, +registry:FleetLabel, +registry:ReplicaIncarnation, +registry:ReplicaRevision; keeps legacy, task accepted-legacy
+- reads `internal/registry/registry.go:routeArgs`: +registry:Copies, +registry:FleetBoxes, +registry:ReplicaIncarnation, +registry:ReplicaRevision; keeps authority, task E3
+- 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, +registry:Host, +registry:Observed ×2, +registry:On, +registry:ReplicaLife ×2, +whole:Route ×2; keeps hint, task E2
+
+Seal: `df8bf8056d80b9d78edc957fe7f2adbc75885e15f581e58167768346c4e05771` → `9cb1ea34e6b84ba3f1b1340b9761cd7ea399db7ba65031bd40852276a81a80d7`.
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/activator/cmd.go b/internal/activator/cmd.go
index 90ad98c64..620ae59f0 100644
--- a/internal/activator/cmd.go
+++ b/internal/activator/cmd.go
@@ -966,6 +966,15 @@ func (a *Service) RunCmd(ctx context.Context, rt registry.Route, spec CmdSpec) (
if refused != nil {
return abandon(refused)
}
+ if rt.FleetBoxes != "" {
+ prior := sctx
+ sctx = withExecGate(sctx, func() error {
+ if err := askExecGate(prior); err != nil {
+ return err
+ }
+ return a.CheckReplicaAssignment(prior, rt)
+ })
+ }
u, err := cb.StartCmd(sctx, rt, spec)
h.unit = u
close(h.started)
diff --git a/internal/activator/cmdunit.go b/internal/activator/cmdunit.go
index 5fefd398e..dcd0e001a 100644
--- a/internal/activator/cmdunit.go
+++ b/internal/activator/cmdunit.go
@@ -459,6 +459,11 @@ func (b *ExecBackend) StartCmd(ctx context.Context, rt registry.Route, spec CmdS
if err := b.writeLaunch(p, role, rt.Host, argv, childEnv(vars)); err != nil {
return fail(err)
}
+ if rt.FleetBoxes != "" {
+ if err := runExecGate(ctx); err != nil {
+ return fail(err)
+ }
+ }
memMax := b.tier(rt).MemoryMax
var inv string
switch {
diff --git a/internal/activator/startrule.go b/internal/activator/startrule.go
index 3f746ead5..2f202458b 100644
--- a/internal/activator/startrule.go
+++ b/internal/activator/startrule.go
@@ -173,6 +173,10 @@ func localCopyNames(dir, base string) (present []string, data bool, err error) {
// .partial directory (which counts as set aside) and fails the wake.
// Nothing is ever removed. An unlabelled row is not touched.
func (b *ExecBackend) reconcileAssignment(rt registry.Route, dbPath string) error {
+ // Verified stateless generations bypass this database path entirely.
+ if rt.FleetBoxes != "" {
+ return ErrFenced
+ }
if rt.Assigned == "" {
return nil
}
@@ -330,6 +334,10 @@ func (b *ExecBackend) supersede(host, dir string, names []string) (string, error
// Every start path on a fleet box that would boot without a restored or
// kept copy calls it (TestEveryFreshBootPathConsultsTheRule).
func (b *ExecBackend) startAllowed(rt registry.Route, haveLocal, restored bool) error {
+ // Verified stateless generations bypass this database path entirely.
+ if rt.FleetBoxes != "" {
+ return ErrFenced
+ }
if rt.Assigned == "" || restored {
return nil
}
@@ -380,6 +388,10 @@ func (b *ExecBackend) startAllowed(rt registry.Route, haveLocal, restored bool)
// write that fails fails the wake, before anything runs. An unlabelled row
// writes nothing; HA hosts never reach it (restoreHA).
func (b *ExecBackend) establishAssignment(rt registry.Route, dbPath string) error {
+ // Verified stateless generations bypass this database path entirely.
+ if rt.FleetBoxes != "" {
+ return ErrFenced
+ }
if rt.Assigned == "" {
return nil
}
diff --git a/internal/activator/stateless_assignment_test.go b/internal/activator/stateless_assignment_test.go
new file mode 100644
index 000000000..ee547b8bc
--- /dev/null
+++ b/internal/activator/stateless_assignment_test.go
@@ -0,0 +1,148 @@
+package activator
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/replicas"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+)
+
+func TestStatelessAssignmentCurrentMembership(t *testing.T) {
+ rec := provision.Record{Schema: 1, Host: "shop.example.com", Account: "bab", App: "shop", Channel: "edge", Region: "fleet/pi", CreatedAt: time.Unix(1, 0), Hibernate: new(bool), ReplicaAssignment: &replicas.Assignment{Desired: 2, Revision: 1, Boxes: []string{"a", "b"}}}
+ rt := provision.RouteFor(rec, t.TempDir(), "", false, nil)
+ for _, tc := range []string{"member", "removed", "recreated", "revision", "unknown", "no-fleet", "sidecar", "stateful"} {
+ t.Run(tc, func(t *testing.T) {
+ current := rec
+ current.ReplicaAssignment = &replicas.Assignment{Desired: 2, Revision: 1, Boxes: []string{"a", "b"}}
+ route := rt
+ a := &Service{Routes: startupRoutes{rt.Host: rt}, Fleet: FleetWake{Mode: FleetWakeCheck, Fleet: "pi", Label: "a", Record: func(context.Context, registry.Route) (*provision.Record, error) { return &current, nil }}}
+ switch tc {
+ case "removed":
+ current.ReplicaAssignment.Boxes = []string{"b"}
+ case "recreated":
+ current.CreatedAt = current.CreatedAt.Add(time.Second)
+ case "revision":
+ current.ReplicaAssignment.Revision++
+ case "unknown":
+ a.Fleet.Mode = FleetWakeUnknown
+ case "no-fleet":
+ a.Fleet.Mode = FleetWakeNone
+ case "sidecar":
+ current.Kind = "sidecar"
+ case "stateful":
+ route.Stateless = false
+ a.Routes = startupRoutes{route.Host: route}
+ }
+ if err := a.routeCurrentUnderLease(context.Background(), route, false); (err == nil) != (tc == "member") {
+ t.Fatalf("check=%v", err)
+ }
+ })
+ }
+}
+
+func TestStatelessAssignmentFinalSpawnGate(t *testing.T) {
+ rec := provision.Record{Schema: 1, Host: "shop.example.com", Account: "bab", App: "shop", Channel: "edge", Region: "fleet/pi", CreatedAt: time.Unix(1, 0), Hibernate: new(bool), ReplicaAssignment: &replicas.Assignment{Desired: 2, Revision: 1, Boxes: []string{"a", "b"}}}
+ rt := provision.RouteFor(rec, t.TempDir(), "", false, nil)
+ facts, err := RecordFactsOf(rec)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, removed := range []bool{false, true} {
+ t.Run(fmt.Sprint(removed), func(t *testing.T) {
+ current := rec
+ reads := 0
+ a := &Service{Routes: startupRoutes{rt.Host: rt}, Fleet: FleetWake{Mode: FleetWakeCheck, Fleet: "pi", Label: "a", Record: func(context.Context, registry.Route) (*provision.Record, error) { reads++; return &current, nil }}}
+ ctx := WithReplicaReleaseObservation(context.Background(), facts, replicas.Build{Version: "v1", Digest: "canonical"}, true)
+ ctx = context.WithValue(ctx, statelessRecordKey{}, rt)
+ ctx = a.withStatelessFinalCheck(ctx, rt)
+ if removed {
+ current.ReplicaAssignment = &replicas.Assignment{Desired: 2, Revision: 1, Boxes: []string{"b"}}
+ }
+ starts := 0
+ if runExecGate(ctx) == nil {
+ starts++
+ }
+ if (starts == 0) != removed || reads != 1 {
+ t.Fatalf("starts=%d record reads=%d", starts, reads)
+ }
+ })
+ }
+}
+
+func TestStatelessAssignmentNeverSetsAsideLocalDatabase(t *testing.T) {
+ dir := t.TempDir()
+ path := filepath.Join(dir, "app.db")
+ body := []byte("old database")
+ if err := os.WriteFile(path, body, 0600); err != nil {
+ t.Fatal(err)
+ }
+ rt := registry.Route{Host: "shop.example.com", DBPath: path, Assigned: "new", FleetBoxes: `["a"]`, Stateless: true}
+ b := &ExecBackend{DataDir: dir}
+ for _, f := range []func() error{func() error { return b.reconcileAssignment(rt, path) }, func() error { return b.startAllowed(rt, true, false) }, func() error { return b.establishAssignment(rt, path) }} {
+ if f() == nil {
+ t.Fatal("set entered the SQLite assignment path")
+ }
+ }
+ after, err := os.ReadFile(path)
+ if err != nil || string(after) != string(body) {
+ t.Fatalf("database changed: %q %v", after, err)
+ }
+ if _, err := os.Stat(path + AssignedMarkerSuffix); !os.IsNotExist(err) {
+ t.Fatal("assignment marker written")
+ }
+}
+
+func TestStatelessAssignmentRemovedImmediatelyBeforeSpawn(t *testing.T) {
+ r := newWakeRelRig(t)
+ store := wireStatelessRig(r)
+ r.rt.Region = "fleet/pi"
+ r.rt.FleetBoxes = `["a","b"]`
+ r.rt.Copies = 2
+ r.rt.ReplicaRevision = 1
+ r.rt.Stateless = true
+ rec := provision.Record{Schema: 1, Host: r.rt.Host, Account: r.rt.Account, App: r.rt.App, Channel: r.rt.Channel, Environment: r.rt.Environment, Runtime: r.rt.Runtime, Region: r.rt.Region, CreatedAt: time.Unix(1, 0), Hibernate: new(bool), ReplicaAssignment: &replicas.Assignment{Desired: 2, Revision: 1, Boxes: []string{"a", "b"}}}
+ r.rt.ReplicaIncarnation, _ = provision.Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt)
+ r.routes.set(r.rt)
+ r.b.procs["v2"] = map[string]release.Process{release.ProcessWeb: {Command: []string{"serve"}}}
+ r.a.Fleet = FleetWake{Mode: FleetWakeCheck, Fleet: "pi", Label: "a", Record: func(context.Context, registry.Route) (*provision.Record, error) {
+ current := rec
+ current.ReplicaDeploy = store.snapshot()
+ return &current, nil
+ }}
+ r.a.BeforeExec = func(context.Context, string, string) error {
+ rec.ReplicaAssignment = &replicas.Assignment{Desired: 2, Revision: 1, Boxes: []string{"b"}}
+ return nil
+ }
+ if err := waitErr(t, r.wake(r.a)); err == nil {
+ t.Fatal("removed member served")
+ }
+ if starts := r.b.started(); len(starts) != 0 {
+ t.Fatalf("stale member started: %+v", starts)
+ }
+}
+
+func TestStatelessAssignmentBinaryCommandGate(t *testing.T) {
+ ctl := &fakeControl{cmdInv: "inv1"}
+ unit := &fakeUnit{}
+ b, rt := nestedBackend(t, ctl, unit)
+ b.layoutFn = func(registry.Route) (Layout, string) { return LayoutNested, "" }
+ rt.FleetBoxes = `["a"]`
+ rt.Stateless = true
+ ctx := withExecGate(context.Background(), func() error { return ErrFenced })
+ dir := filepath.Join(provision.InstanceDir(b.DataDir, rt.Host), CmdRunDirName, "run_a")
+ u, err := b.StartCmd(ctx, rt, CmdSpec{RunID: "run_a", Args: []string{"import"}, RunDir: dir, genEnv: map[string]string{"CARLOS_ADMIN_TOKEN": "tok"}})
+ if u != nil {
+ u.StopAndSettle(context.Background())
+ }
+ if !errors.Is(err, ErrFenced) || strings.Contains(ctl.joined(), "cmd "+rt.Host) {
+ t.Fatalf("fenced command launched: %v %s", err, ctl.joined())
+ }
+}
diff --git a/internal/activator/wakeidentity.go b/internal/activator/wakeidentity.go
index a6d71908c..5e25d7dc4 100644
--- a/internal/activator/wakeidentity.go
+++ b/internal/activator/wakeidentity.go
@@ -109,6 +109,8 @@ func leaseRouteChanged(began registry.Route, now *registry.Route, worker bool) e
return fmt.Errorf("%w: %w", errRouteChangedUnderLease, err)
}
switch {
+ case began.FleetBoxes != now.FleetBoxes || began.Copies != now.Copies || began.ReplicaRevision != now.ReplicaRevision || began.ReplicaIncarnation != now.ReplicaIncarnation:
+ return errRouteChangedUnderLease
case began.Assigned != now.Assigned || began.Moved != now.Moved:
return fmt.Errorf("%s: refusing to wake: %w: its fleet assignment is %q (moved %v) now, not %q (moved %v)",
began.Host, errRouteChangedUnderLease, now.Assigned, now.Moved, began.Assigned, began.Moved)
@@ -200,6 +202,9 @@ func (a *Service) routeCurrentUnderLease(ctx context.Context, rt registry.Route,
// reads. It neither acquires nor relies on a serving lease. The caller decides
// whether additional attempt-local launch evidence must still match.
func (a *Service) currentWakeRoute(ctx context.Context, rt registry.Route, worker bool) (*registry.Route, *provision.Record, error) {
+ if !rt.ValidReplicaProjection() {
+ return nil, nil, errRouteChangedUnderLease
+ }
current := rt
if a.Routes != nil {
now, err := a.Routes.Get(rt.Host)
@@ -211,12 +216,15 @@ func (a *Service) currentWakeRoute(ctx context.Context, rt registry.Route, worke
}
current = *now
}
- if rt.Assigned == "" {
+ if rt.Assigned == "" && rt.FleetBoxes == "" {
return &current, nil, nil
}
f := a.Fleet
switch f.Mode {
case FleetWakeNone:
+ if rt.FleetBoxes != "" {
+ return nil, nil, errFleetIdentityUnknown
+ }
return &current, nil, nil
case FleetWakeCheck:
case FleetWakeUnknown:
@@ -235,6 +243,17 @@ func (a *Service) currentWakeRoute(ctx context.Context, rt registry.Route, worke
if rec == nil {
return nil, nil, errRecordUnreadUnderLease
}
+ if rt.FleetBoxes != "" || rec.ReplicaAssignment != nil {
+ if worker || rt.Kind != "instance" || rec.Schema != 1 || provision.ValidateShape(*rec) != nil || !rt.ValidReplicaProjection() || !rt.ReplicaContains(f.Label) || rec.ReplicaAssignment == nil || !rec.ReplicaAssignment.Contains(f.Label) || rec.Retired || rec.Account != rt.Account || rec.App != rt.App || rec.Host != rt.Host || rec.Region != rt.Region || (f.Fleet != "" && rt.Region != registry.PlacementTarget(f.Fleet)) || rec.Channel != rt.Channel || rec.Runtime != rt.Runtime || rec.Environment != rt.Environment {
+ return nil, nil, errRouteChangedUnderLease
+ }
+ inc, e := provision.Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt)
+ boxes, e2 := registry.ReplicaBoxes(*rec.ReplicaAssignment)
+ if e != nil || e2 != nil || inc != rt.ReplicaIncarnation || boxes != rt.FleetBoxes || rec.ReplicaAssignment.Desired != rt.Copies || rec.ReplicaAssignment.Revision != rt.ReplicaRevision || rec.KindOrDefault() != "instance" || !rec.DerivesPaths() || rec.HibernateOrDefault() || rec.HA || rec.Pool != "" || rec.Role != "" || len(rec.Replicas) != 0 || rec.Unit != "" || rec.Move != nil || rec.Seed != nil {
+ return nil, nil, errRouteChangedUnderLease
+ }
+ return &current, rec, nil
+ }
if rec.FleetBox != f.Label || rec.FleetBoxAt != rt.Assigned {
return nil, nil, fmt.Errorf("%s: refusing to wake: %w: its record names box %q assigned %q, not this box %q at %q",
rt.Host, errRouteChangedUnderLease, rec.FleetBox, rec.FleetBoxAt, f.Label, rt.Assigned)
@@ -259,3 +278,11 @@ func FleetRecordFrom(s release.Store) func(ctx context.Context, rt registry.Rout
return provision.GetRecord(ctx, s, rt.Account, rt.App, rt.Host)
}
}
+
+// CheckReplicaAssignment is the command pickup recheck. Legacy rows read nothing.
+func (a *Service) CheckReplicaAssignment(ctx context.Context, rt registry.Route) error {
+ if rt.FleetBoxes == "" {
+ return nil
+ }
+ return a.routeCurrentUnderLease(ctx, rt, false)
+}
diff --git a/internal/host/fleetbind.go b/internal/host/fleetbind.go
index 988fe7969..c4c7b423e 100644
--- a/internal/host/fleetbind.go
+++ b/internal/host/fleetbind.go
@@ -460,7 +460,7 @@ type statelessBindingPublisher struct {
var armedStatelessBindings atomic.Pointer[statelessBindingPublisher]
func (p *statelessBindingPublisher) publish(ctx context.Context, rec provision.Record, rt registry.Route) error {
- if p == nil || p.coordinator == nil || !rt.Stateless || rt.IsSidecar() || rt.IsForward() || !rt.Provisioned || rt.Status != "ready" || rt.Host != rec.Host || rt.Account != rec.Account || rt.App != rec.App || rt.Assigned != rec.FleetBoxAt {
+ if rec.ReplicaAssignment != nil || rt.FleetBoxes != "" || p == nil || p.coordinator == nil || !rt.Stateless || rt.IsSidecar() || rt.IsForward() || !rt.Provisioned || rt.Status != "ready" || rt.Host != rec.Host || rt.Account != rec.Account || rt.App != rec.App || rt.Assigned != rec.FleetBoxAt {
return nil
}
fleet, ok := registry.FleetPlacement(rec.Region)
diff --git a/internal/host/fleetidentity.go b/internal/host/fleetidentity.go
index e91375c02..4e889d0c2 100644
--- a/internal/host/fleetidentity.go
+++ b/internal/host/fleetidentity.go
@@ -1,6 +1,7 @@
package host
import (
+ "context"
"errors"
"fmt"
"strings"
@@ -126,3 +127,16 @@ func fleetWakeFor(getenv func(string) string, identity FleetIdentity, identErr e
fleet := strings.TrimSpace(getenv("CARLOS_FLEET"))
return activator.FleetWakeIdentityUnknown(fleet, identErr)
}
+
+func recheckReplicaPickup(ctx context.Context, launch runLauncher, rt registry.Route) error {
+ if rt.FleetBoxes == "" {
+ return nil
+ }
+ check, ok := launch.(interface {
+ CheckReplicaAssignment(context.Context, registry.Route) error
+ })
+ if !ok {
+ return activator.ErrFenced
+ }
+ return check.CheckReplicaAssignment(ctx, rt)
+}
diff --git a/internal/host/runs.go b/internal/host/runs.go
index 502f11774..887fb220d 100644
--- a/internal/host/runs.go
+++ b/internal/host/runs.go
@@ -263,6 +263,11 @@ func (w *runsWorker) pickup(ctx context.Context, rec provision.Record, rt regist
}
return
}
+ if err := recheckReplicaPickup(ctx, w.launch, rt); err != nil {
+ sink.close()
+ w.forget(id)
+ return
+ }
got, err := sink.Pickup(ctx, rec, *req)
if err != nil {
sink.close()
diff --git a/internal/host/stateless_assignment_test.go b/internal/host/stateless_assignment_test.go
new file mode 100644
index 000000000..9b063924a
--- /dev/null
+++ b/internal/host/stateless_assignment_test.go
@@ -0,0 +1,56 @@
+package host
+
+import (
+ "context"
+ "encoding/json"
+ "github.com/carlosframework/platform/internal/activator"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/replicas"
+ "path/filepath"
+ "testing"
+ "time"
+)
+
+func TestStatelessAssignmentCommandPickup(t *testing.T) {
+ for _, member := range []bool{true, false} {
+ t.Run(map[bool]string{true: "member", false: "removed"}[member], func(t *testing.T) {
+ s := release.NewDirStore(t.TempDir())
+ rec, _ := queueRun(t, s, time.Now().Add(time.Minute))
+ rec.Region = "fleet/pi"
+ rec.Hibernate = new(bool)
+ rec.ReplicaAssignment = &replicas.Assignment{Desired: 2, Revision: 1, Boxes: []string{"a", "b"}}
+ raw, _ := json.Marshal(rec)
+ _, tag, _ := s.Get(context.Background(), provision.RecordKey(rec.Account, rec.App, rec.Host))
+ if _, err := s.Put(context.Background(), provision.RecordKey(rec.Account, rec.App, rec.Host), raw, tag); err != nil {
+ t.Fatal(err)
+ }
+ rt := provision.RouteFor(rec, t.TempDir(), "", true, nil)
+ reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer reg.Close()
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ current := rec
+ if !member {
+ current.ReplicaAssignment = &replicas.Assignment{Desired: 2, Revision: 1, Boxes: []string{"b"}}
+ }
+ reads := 0
+ svc := &activator.Service{Routes: reg, Fleet: activator.FleetWake{Mode: activator.FleetWakeCheck, Fleet: "pi", Label: "a", Record: func(context.Context, registry.Route) (*provision.Record, error) { reads++; return &current, nil }}}
+ var log execLog
+ w := testWorker(s, reg.Get, "a", "boot", &log)
+ w.launch = svc
+ w.consider(context.Background(), rec)
+ if (log.count() == 1) != member || reads != 1 {
+ t.Fatalf("launches=%d reads=%d", log.count(), reads)
+ }
+ if !member && currentRun(t, s).State != provision.RunQueued {
+ t.Fatal("stale member picked queued command")
+ }
+ })
+ }
+}
diff --git a/internal/provision/fleetbox.go b/internal/provision/fleetbox.go
index dbd9f6744..a5251f6d4 100644
--- a/internal/provision/fleetbox.go
+++ b/internal/provision/fleetbox.go
@@ -58,6 +58,9 @@ func SetRecordFleetBox(ctx context.Context, s release.Store, acct, app, host str
// doors, which also refuse rootfs records (rootfsRefusalCallers),
// and a relabel inside a fleet moves rootfs records by design.
if rec.FleetBox != label {
+ if rec.ReplicaAssignment != nil && !rec.ReplicaAssignment.Contains(label) {
+ return ErrFleetBoxMoved
+ }
if err := replicaAssignmentMoveRefusal(rec); err != nil {
return err
}
diff --git a/internal/provision/forward.go b/internal/provision/forward.go
index 4740de4f4..d4d0a5eb4 100644
--- a/internal/provision/forward.go
+++ b/internal/provision/forward.go
@@ -26,7 +26,7 @@ import (
// FleetBox is that label, which is what PutForward stores; an unlabelled
// row's FleetBox is the bindings pass's.
func forwardRowFor(rec Record) registry.Route {
- return registry.Route{
+ rt := registry.Route{
Host: rec.Host,
Kind: registry.KindForward,
Slug: rec.Slug,
@@ -40,6 +40,8 @@ func forwardRowFor(rec Record) registry.Route {
FleetLabel: rec.FleetBox,
FleetBox: rec.FleetBox,
}
+ projectReplicaAssignment(&rt, rec)
+ return rt
}
// forwardCurrent reports whether existing already is want: an inert forward
@@ -50,6 +52,8 @@ func forwardRowFor(rec Record) registry.Route {
// registry watcher).
func forwardCurrent(existing, want registry.Route) bool {
return existing.InertForward() &&
+ existing.FleetBoxes == want.FleetBoxes && existing.Copies == want.Copies && existing.ReplicaRevision == want.ReplicaRevision && existing.ReplicaIncarnation == want.ReplicaIncarnation && (want.FleetBoxes == "" || existing.Stateless == want.Stateless) &&
+ (want.FleetBoxes == "" || existing.FleetBox == "") &&
existing.Status == want.Status &&
existing.Provisioned == want.Provisioned &&
existing.Slug == want.Slug &&
diff --git a/internal/provision/provision.go b/internal/provision/provision.go
index 71c11bb79..2ab054728 100644
--- a/internal/provision/provision.go
+++ b/internal/provision/provision.go
@@ -1044,6 +1044,9 @@ func CreateRecord(ctx context.Context, s release.Store, rec Record) error {
func SetRecordRegion(ctx context.Context, s release.Store, acct, app, host, region string) error {
_, err := updateRecord(ctx, s, acct, app, host, func(rec *Record) error {
if rec.Region != region {
+ if rec.ReplicaAssignment != nil {
+ return ErrFleetBoxMoved
+ }
if err := replicaAssignmentMoveRefusal(rec); err != nil {
return err
}
diff --git a/internal/provision/reconcile.go b/internal/provision/reconcile.go
index 24f761168..73f9f62ac 100644
--- a/internal/provision/reconcile.go
+++ b/internal/provision/reconcile.go
@@ -148,6 +148,10 @@ type ReconcileConfig struct {
// StatelessBinding consumes an applied instance record and its serving
// projection. The host supplies the coordinator-gated existing-key writer.
StatelessBinding func(context.Context, Record, registry.Route) error
+ // ReplicaAssignmentManifest returns the already verified selected release.
+ // It must use the caller's existing inventory, never perform store reads.
+ // Missing evidence protects the record from admission and retirement.
+ ReplicaAssignmentManifest func(Record) *release.Manifest
// Seeds is the seeded-instances wiring (seedreconcile.go). Nil: every
// seeded record is left alone.
Seeds *SeedHooks
@@ -536,6 +540,9 @@ func (cfg ReconcileConfig) inScope(region, pool string, everywhere bool) bool {
// record this box no longer owns is never minted here and its row is
// removed, not kept on region alone (rule 9).
func (cfg ReconcileConfig) ownsRecord(rec Record) bool {
+ if rec.ReplicaAssignment != nil {
+ return rec.Region == cfg.Region && rec.ReplicaAssignment.Contains(cfg.FleetBox)
+ }
if _, onFleet := registry.FleetPlacement(cfg.Region); !onFleet {
return true
}
@@ -596,6 +603,7 @@ func RouteFor(rec Record, dataDir, seed string, nested bool, policy *UpdatePolic
Assigned: rec.FleetBoxAt,
Moved: rec.FleetBoxMoved,
}
+ projectReplicaAssignment(&rt, rec)
if rec.DerivesPaths() {
rt.Socket = DefaultSocket(rec.Host)
rt.DBPath = DefaultDBPath(dataDir, rec.Host)
@@ -878,6 +886,22 @@ func shapeMismatch(existing, want registry.Route) string {
// policyKnown false the update settings were not judged at all, which the
// caller has to count for itself. A dry run writes nothing and returns nil.
func convergeOwned(reg *registry.Registry, existing registry.Route, rec Record, policy *UpdatePolicy, policyKnown bool, ap appPolicyCols, dryRun bool) (policyMoved bool, err error) {
+ if rec.ReplicaAssignment != nil {
+ want := RouteFor(rec, "", "", false, nil)
+ if existing.FleetBoxes != want.FleetBoxes || existing.Copies != want.Copies || existing.ReplicaRevision != want.ReplicaRevision || existing.ReplicaIncarnation != want.ReplicaIncarnation || !existing.Stateless {
+ if !dryRun {
+ var err error
+ if existing.ReplicaIncarnation == "" {
+ err = reg.SeedReplicaAssignment(existing, want.ReplicaIncarnation, *rec.ReplicaAssignment)
+ } else {
+ err = reg.SetReplicaAssignment(rec.Host, want.ReplicaIncarnation, *rec.ReplicaAssignment, true)
+ }
+ if err != nil {
+ return false, err
+ }
+ }
+ }
+ }
var errs []error
if rec.Channel != "" && existing.Channel != rec.Channel {
if dryRun {
@@ -1091,6 +1115,7 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
// failedAccts the accounts whose manifest would not read; partial a
// listing that came back incomplete, which could hide any app's record.
type recordScan struct {
+ observed map[string]Record
recs map[string]Record
protect map[string]bool
readFailed bool
@@ -1141,6 +1166,7 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
// back — every other record still converges/removes normally the same
// pass.
protect := map[string]bool{}
+ observed := map[string]Record{}
var recordKeys []string
for _, key := range keys {
if _, _, _, ok := ParseRecordKey(key, known); ok {
@@ -1245,6 +1271,7 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
continue
}
rec := *obs.Rec
+ observed[rec.Host] = rec
// The record IS the authorization, and this pass turns its host into
// a socket path and a database path (DefaultSocket/DefaultDBPath)
// and a registry primary key. The console's create door enforces
@@ -1274,6 +1301,11 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
unread[acct+"/"+app] = true
continue
}
+ if rec.ReplicaAssignment != nil && !cfg.replicaAssignmentVerified(rec) {
+ protect[host] = true
+ unread[acct+"/"+app] = true
+ continue
+ }
// ValidateShape deliberately does not inspect Channel (it validates
// shape fields, and Channel is not one), but a channel-less record
// must not become — or converge — a route pinned to no channel:
@@ -1340,7 +1372,7 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
recs[rec.Host] = rec
}
}
- return recordScan{recs: recs, protect: protect, readFailed: readFailed, known: known, stale: stale,
+ return recordScan{observed: observed, recs: recs, protect: protect, readFailed: readFailed, known: known, stale: stale,
unread: unread, failedAccts: failedAccts, partial: partial, fleet: fleet, hosts: hosts, unreadHosts: unreadHosts}, nil
}
sc, err := scan(s)
@@ -2102,7 +2134,7 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
want.Socket, existing.Socket, want.DBPath, existing.DBPath, rec.Host)
}
}
- if applied && existing.Stateless && !cfg.DryRun && cfg.StatelessBinding != nil {
+ if applied && rec.ReplicaAssignment == nil && existing.Stateless && !cfg.DryRun && cfg.StatelessBinding != nil {
if err := cfg.StatelessBinding(ctx, rec, existing); err != nil {
log.Printf("provision: stateless binding %s: %v", rec.Host, err)
}
@@ -2276,6 +2308,18 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
neither := collides(sc)
removed = map[string]bool{}
for _, rt := range routes {
+ if rt.FleetBoxes != "" && (rt.Platform || rt.Canary) {
+ continue
+ }
+ if rec, ok := sc.observed[rt.Host]; ok && (rec.ReplicaAssignment != nil || rt.FleetBoxes != "") {
+ inc, e := Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt)
+ if e != nil || rt.Account != rec.Account || rt.App != rec.App || rt.ReplicaIncarnation != inc || rec.ReplicaAssignment == nil || !cfg.replicaAssignmentVerified(rec) {
+ continue
+ }
+ if cfg.inScope(rec.Region, rec.Pool, everywhereClass(rec)) && cfg.ownsRecord(rec) && !trashFor(rec.Account, rec.App).removable {
+ continue
+ }
+ }
// gone is the judge's evidence that the row's OWN record is
// absent or stale (claims-off only, below): it also outranks a
// keep view, which keys by hostname and cannot vouch for a row
@@ -2331,6 +2375,12 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
// A record labelled for another fleet box is out of
// this box's scope (managed fleets 1b, rule 9): its
// region alone does not keep the row.
+ if obs.Rec.ReplicaAssignment != nil {
+ inc, e := Incarnation(obs.Rec.Account, obs.Rec.App, obs.Rec.Host, obs.Rec.CreatedAt)
+ if e != nil || inc != rt.ReplicaIncarnation || !cfg.replicaAssignmentVerified(*obs.Rec) {
+ continue
+ }
+ }
if cfg.inScope(obs.Rec.Region, obs.Rec.Pool, everywhereClass(*obs.Rec)) && cfg.ownsRecord(*obs.Rec) {
// A valid record in this pass's scope defeats the
// record-gone reason only: the row still meets the
@@ -2409,6 +2459,15 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
}
continue
}
+ if rt.FleetBoxes != "" && !cfg.ClaimEnabled {
+ deleted, err := reg.DeleteReplicaAssignment(rt)
+ if err != nil || !deleted {
+ pr.fail(rt.Account, rt.App)
+ continue
+ }
+ removed[rt.Host] = true
+ continue
+ }
if err := cfg.claimRetire(ctx, reg, rt); err != nil {
log.Printf("provision: remove retired %s route %s: %v", rt.Kind, rt.Host, err)
pr.fail(rt.Account, rt.App)
@@ -2433,7 +2492,7 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg
keep(recs, nil) // no removal this pass
return pr.fill(cfg.Report, recs)
}
- cur := recordScan{recs: recs, protect: protect, known: sc.known, stale: sc.stale, fleet: sc.fleet}
+ cur := recordScan{observed: sc.observed, recs: recs, protect: protect, known: sc.known, stale: sc.stale, fleet: sc.fleet}
if !onSnapshot(s) {
retire(cur, trashFor, true)
return pr.fill(cfg.Report, recs)
diff --git a/internal/provision/replicaassignment.go b/internal/provision/replicaassignment.go
index 3a23029a6..c8adc31d9 100644
--- a/internal/provision/replicaassignment.go
+++ b/internal/provision/replicaassignment.go
@@ -166,3 +166,28 @@ func replicaAssignmentMoveRefusal(rec *Record) error {
}
return nil
}
+
+func (cfg ReconcileConfig) replicaAssignmentVerified(rec Record) bool {
+ if rec.ReplicaAssignment == nil {
+ return true
+ }
+ if !RouteFor(rec, "", "", false, nil).ValidReplicaProjection() || cfg.ReplicaAssignmentManifest == nil {
+ return false
+ }
+ _, err := WithReplicaAssignmentManifest(context.Background(), rec, cfg.ReplicaAssignmentManifest(rec))
+ return err == nil
+}
+
+func projectReplicaAssignment(rt *registry.Route, rec Record) {
+ if rec.ReplicaAssignment == nil {
+ return
+ }
+ boxes, err := registry.ReplicaBoxes(*rec.ReplicaAssignment)
+ inc, e := Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt)
+ if err != nil || e != nil {
+ return
+ }
+ rt.FleetBoxes, rt.Copies, rt.ReplicaRevision, rt.ReplicaIncarnation = boxes, rec.ReplicaAssignment.Desired, rec.ReplicaAssignment.Revision, inc
+ rt.Stateless = true
+ rt.FleetBox, rt.FleetLabel = "", ""
+}
diff --git a/internal/provision/replicaassignment_test.go b/internal/provision/replicaassignment_test.go
index dbdad3cde..2bcf84dcd 100644
--- a/internal/provision/replicaassignment_test.go
+++ b/internal/provision/replicaassignment_test.go
@@ -265,7 +265,7 @@ func TestReplicaAssignmentEligibilityAndLegacyGuards(t *testing.T) {
} else {
err = SetRecordFleetBox(ctx, s, id.Account, id.App, id.Host, FleetBoxExpect{Region: rec.Region, Label: "a", CreatedAt: rec.CreatedAt}, "c", time.Now())
}
- active := a != nil && (len(a.Boxes) > 1 || len(a.Retiring) > 0)
+ active := a != nil
if active && (err == nil || !bytes.Equal(before, assignmentBytes(t, s, id))) {
t.Fatal("single-label writer changed active set")
}
diff --git a/internal/provision/replicas_test.go b/internal/provision/replicas_test.go
new file mode 100644
index 000000000..e4213da79
--- /dev/null
+++ b/internal/provision/replicas_test.go
@@ -0,0 +1,173 @@
+package provision
+
+import (
+ "encoding/json"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/replicas"
+ "testing"
+ "time"
+)
+
+func replicaReconcileFixture(t *testing.T) (*release.DirStore, Record, ReconcileConfig) {
+ t.Helper()
+ s := dirStore(t)
+ acct := writeAccountManifest(t, s, acctID, "shop")
+ rec := Record{Schema: 1, Account: acct, App: "shop", Host: "shop.example.com", Slug: "shop", Channel: "edge", Region: "fleet/pi", CreatedAt: time.Now().UTC(), Hibernate: new(bool), ReplicaAssignment: &replicas.Assignment{Revision: 1, Desired: 2, Boxes: []string{"a", "b"}}}
+ raw, _ := json.Marshal(rec)
+ if _, err := s.Put(ctx, RecordKey(acct, rec.App, rec.Host), raw, ""); err != nil {
+ t.Fatal(err)
+ }
+ cfg := ReconcileConfig{Region: rec.Region, DataDir: t.TempDir(), ReplicaAssignmentManifest: func(Record) *release.Manifest {
+ return &release.Manifest{Schema: 1, App: "shop", Version: "v1", Kind: "binary", Stateless: true}
+ }}
+ return s, rec, cfg
+}
+func TestReplicaReconcileMembership(t *testing.T) {
+ s, rec, cfg := replicaReconcileFixture(t)
+ regs := map[string]*registry.Registry{}
+ for _, box := range []string{"a", "b", "c"} {
+ reg := regWith(t)
+ defer reg.Close()
+ regs[box] = reg
+ cfg.FleetBox = box
+ if err := Reconcile(ctx, s, reg, cfg); err != nil {
+ t.Fatal(err)
+ }
+ got, _ := reg.Get(rec.Host)
+ if (got != nil) != (box != "c") {
+ t.Fatalf("%s: %+v", box, got)
+ }
+ if got != nil && (got.FleetBoxes != `["a","b"]` || !got.Stateless || got.Copies != 2) {
+ t.Fatalf("projection: %+v", got)
+ }
+ }
+ rec.ReplicaAssignment = &replicas.Assignment{Revision: 2, Desired: 2, Boxes: []string{"a"}, Retiring: []string{"b"}}
+ raw, _ := json.Marshal(rec)
+ putReplace(t, s, RecordKey(rec.Account, rec.App, rec.Host), raw)
+ for box, reg := range regs {
+ cfg.FleetBox = box
+ if err := Reconcile(ctx, s, reg, cfg); err != nil {
+ t.Fatal(err)
+ }
+ got, _ := reg.Get(rec.Host)
+ if (got != nil) != (box == "a") {
+ t.Fatalf("removal %s: %+v", box, got)
+ }
+ }
+ cfg.FleetBox = "a"
+ cfg.ReplicaAssignmentManifest = nil
+ if err := Reconcile(ctx, s, regs["a"], cfg); err != nil {
+ t.Fatal(err)
+ }
+ mustGet(t, regs["a"], rec.Host)
+ raw = []byte(`{"schema":1,"host":"shop.example.com","replica_assignment":{"desired":2,"boxes":["a","a"]}}`)
+ putReplace(t, s, RecordKey(rec.Account, rec.App, rec.Host), raw)
+ if err := Reconcile(ctx, s, regs["a"], cfg); err != nil {
+ t.Fatal(err)
+ }
+ mustGet(t, regs["a"], rec.Host)
+}
+func TestReplicaRemovalOnlyOwnsItsKindAndLifetime(t *testing.T) {
+ for _, kind := range []string{"sidecar", "platform", "canary", "unrelated", "recreated"} {
+ t.Run(kind, func(t *testing.T) {
+ s, rec, cfg := replicaReconcileFixture(t)
+ cfg.FleetBox = "c"
+ rt := RouteFor(rec, cfg.DataDir, "", false, nil)
+ switch kind {
+ case "sidecar":
+ rt.Kind = "sidecar"
+ rt.Socket = ""
+ case "platform":
+ rt.Platform = true
+ case "canary":
+ rt.Canary = true
+ case "unrelated":
+ rt.Account = "other"
+ case "recreated":
+ rt.ReplicaIncarnation = "new-life"
+ }
+ reg := regWith(t, rt)
+ defer reg.Close()
+ if err := Reconcile(ctx, s, reg, cfg); err != nil {
+ t.Fatal(err)
+ }
+ mustGet(t, reg, rt.Host)
+ })
+ }
+}
+func TestReplicaScaleDownRequiresStopProof(t *testing.T) {
+ ctx, s, rec, id, want := assignmentFixture(t)
+ got, err := SetRecordReplicaAssignment(ctx, s, id, want, replicas.Assignment{Desired: 3, Boxes: []string{"a", "b", "c"}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ want.RecordSeq, want.Revision = got.RecordSeq, got.ReplicaAssignment.Revision
+ current := *got.ReplicaAssignment
+ current.Desired = 1
+ next, err := replicas.Place(current, []replicas.Candidate{{Label: "a", Eligible: true}, {Label: "b", Eligible: false}})
+ if err != nil {
+ t.Fatal(err)
+ }
+ got, err = SetRecordReplicaAssignment(ctx, s, id, want, next)
+ if err != nil {
+ t.Fatal(err)
+ }
+ revision := got.ReplicaAssignment.Revision
+ // Further down/lost inventory observations cannot discharge either box.
+ next, err = replicas.Place(*got.ReplicaAssignment, []replicas.Candidate{{Label: "a", Eligible: true}})
+ if err != nil || len(next.Retiring) != 2 {
+ t.Fatal("lost reports erased retirement", err)
+ }
+ if _, err := RecordReplicaRetired(ctx, s, id, revision-1, "b"); err == nil {
+ t.Fatal("stale proof accepted")
+ }
+ got, err = RecordReplicaRetired(ctx, s, id, revision, "b")
+ if err != nil || len(got.ReplicaAssignment.Retiring) != 1 || got.ReplicaAssignment.Retiring[0] != "c" {
+ t.Fatal("one proof cleared another box", err)
+ }
+ if _, err := RecordReplicaRetired(ctx, s, id, revision, "c"); err == nil {
+ t.Fatal("old revision accepted for second proof")
+ }
+ if _, err := RecordReplicaRetired(ctx, s, id, got.ReplicaAssignment.Revision, "c"); err != nil {
+ t.Fatal(err)
+ }
+ got, err = GetRecord(ctx, s, rec.Account, rec.App, rec.Host)
+ if err != nil || len(got.ReplicaAssignment.Retiring) != 0 {
+ t.Fatal("all proven retirements did not clear", err)
+ }
+}
+
+func TestReplicaForwardProjection(t *testing.T) {
+ s, rec, cfg := replicaReconcileFixture(t)
+ cfg.Region = "ie"
+ cfg.FleetOwners = func() (map[string]string, error) { return map[string]string{"pi": rec.Account}, nil }
+ reg := regWith(t)
+ defer reg.Close()
+ if err := Reconcile(ctx, s, reg, cfg); err != nil {
+ t.Fatal(err)
+ }
+ rt := mustGet(t, reg, rec.Host)
+ if !rt.InertForward() || rt.FleetBoxes != `["a","b"]` || rt.Copies != 2 || rt.ReplicaRevision != 1 || rt.ReplicaIncarnation == "" || !rt.Stateless {
+ t.Fatalf("forward projection: %+v", rt)
+ }
+ if !forwardCurrent(*rt, forwardRowFor(rec)) {
+ t.Fatal("fresh forward projection drifts")
+ }
+}
+
+func TestReplicaReconcileConvertsExistingRoute(t *testing.T) {
+ s, rec, cfg := replicaReconcileFixture(t)
+ cfg.FleetBox = "a"
+ legacy := rec
+ legacy.ReplicaAssignment = nil
+ reg := regWith(t, RouteFor(legacy, cfg.DataDir, "", false, nil))
+ defer reg.Close()
+ if err := Reconcile(ctx, s, reg, cfg); err != nil {
+ t.Fatal(err)
+ }
+ rt := mustGet(t, reg, rec.Host)
+ if !rt.ValidReplicaProjection() || rt.FleetBoxes != `["a","b"]` {
+ t.Fatalf("legacy row conversion: %+v", rt)
+ }
+}
diff --git a/internal/provision/stateless_placement_census_test.go b/internal/provision/stateless_placement_census_test.go
index adb82c437..024d05fd2 100644
--- a/internal/provision/stateless_placement_census_test.go
+++ b/internal/provision/stateless_placement_census_test.go
@@ -1,10 +1,14 @@
package provision
-// Plan 2 Tasks 1 and 2a author review; independent approval is controller-owned.
+// Plan 2 Tasks 1, 2a and 2b author review; independent approval is controller-owned.
// These notes explain each re-digest. Independent approval is controller-owned.
func statelessPlacementWriteCensusInventory() []censusEntry {
entries := append([]censusEntry(nil), statelessReplicasWriteCensusInventory()...)
for _, next := range []censusEntry{
+ // Slice 2b: author-inspected instance pass uses only existing record reads,
+ // protects unverifiable assignments, and conditionally retires its own local
+ // projection without changing Retiring or claiming a stop proof.
+ {"internal/provision/reconcile.go", "Reconcile", "key-site", "key:ParseRecordKey,key:RecordKey,lit:instances", "c805d2205410d9f54f1243c137e9388321a384b1093d23d27588033e7cbc62a9"},
// Slice 2a: typed assignment CAS checks lifetime, region, RecordSeq and
// assignment revision on every attempt. Manifest evidence is supplied
// under caller publication exclusion; no new store read. Retirement
@@ -14,12 +18,12 @@ func statelessPlacementWriteCensusInventory() []censusEntry {
// and assignment revision again on CAS retry; removes only the named
// retiring member and advances revision/sequence. Caller verifies proof.
{"internal/provision/replicaassignment.go", "RecordReplicaRetired", "record-writer", "key:RecordReplicaRetired,key:updateRecord", "a6eb73e1a1c71beb5e41fb63076c0a4dcac0dcbb0468272358708ce97660b4f6"},
- // Slice 2a: same region writer and read; before a move, refuse a set
- // whose desired count exceeds one or whose members still need retiring.
- {"internal/provision/provision.go", "SetRecordRegion", "record-writer", "key:SetRecordRegion,key:updateRecord", "778f4887cbd8f23211768f7858ac0b5a862c13f802076b99e30b04973b9f6606"},
- // Slice 2a: same label CAS; the shared set guard runs only on relabel.
+ // Slice 2b: same region CAS/read, now refuse a region change while any
+ // set remains. A region-only edit cannot move the set or prove termination.
+ {"internal/provision/provision.go", "SetRecordRegion", "record-writer", "key:SetRecordRegion,key:updateRecord", "beae6f23aadb7625e9fc85ec35b35efa5e55cb29bc803359ccd3f091a12d3e28"},
+ // Slice 2b: same label CAS; a changed label must already be in the set.
// Records without an assignment keep the previous read/write path.
- {"internal/provision/fleetbox.go", "SetRecordFleetBox", "record-writer", "key:SetRecordFleetBox,key:updateRecord", "3a1de2c9d59325ff9e6d3734382e6c459db2a2dd457cbc49732ac327adb85b9f"},
+ {"internal/provision/fleetbox.go", "SetRecordFleetBox", "record-writer", "key:SetRecordFleetBox,key:updateRecord", "44a7facbc2de04197c584a0e1f30f104ead59844b2ed88554e6869a6b90548b2"},
// P7: sidecar create keeps the existing app lock and typed writer, pins the admitted name, and refuses counts above one before hostname marks or record creation. This also covers a fleet that shrank after count admission.
{"internal/console/hostsused.go", "Server.createSidecarMarked", "record-writer", "key:CreateSidecarRecord,key:SidecarRecordKey", "228da907d8e1f8cebc691c2eb728f2b8d80251f10f51e9da9673a278392f1faa"},
// P7: the default-bundle CAS preserves all fields and retains an explicit count after a decrease. It writes only config.json and its existing generation signal, never an instance record.
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index d8ae97bc2..7f43e4c99 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 df8bf8056d80b9d78edc957fe7f2adbc75885e15f581e58167768346c4e05771
+plan14-root-reads-stateless-replicas-2.tsv 9cb1ea34e6b84ba3f1b1340b9761cd7ea399db7ba65031bd40852276a81a80d7
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 85bb43a0d..d0cba0248 100644
--- a/internal/provision/testdata/plan14-root-reads-stateless-replicas-2.tsv
+++ b/internal/provision/testdata/plan14-root-reads-stateless-replicas-2.tsv
@@ -1,7 +1,69 @@
-# Census overlay stateless-replicas-2, written by census-propose (#369). census-ruling-stateless-replicas-2, independent approval on #280 is required before the merge; the approval card is docs/superpowers/notes/census-proposal-stateless-replicas-2.md.
-# 0 body, 0 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# Census overlay stateless-replicas-2, written by census-propose (#369). census-ruling-stateless-replicas-2, independent approval on #280 required before the merge; the approval card is docs/superpowers/notes/census-proposal-stateless-replicas-2.md.
+# 4 body, 2 sites, 8 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 25 new dispositions: 15 reads re-frozen at their disposition with the claim, 9 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 1 other.
+@legacy 79055c0f7e0c310deb5796a2b8bce0410f5de648d69b7d919e211d3a4273facb internal/registry/forward.go Registry.SetFleetBoxIf legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 1: one conditional UPDATE of fleet_box judging placement on the fleet (region = 'fleet/'||fleet), kind (not a sidecar) and ACTIVE membership in fleet_boxes at the write; returns whether a row changed (+file:Exec, +registry:Changed, +registry:remote x2, +registry:sql, +whole:remoteClient x2). Replaces SetFleetBox.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the one conditional UPDATE gains AND fleet_label = '', so a labelled forward row's fleet_box is never changed by a binding. Read sites unchanged (7). It writes less, never more. Agent hub's bindings pass, not root.;rev3=census-ruling-stateless-replicas-2;basis=Existing conditional SQL write refuses every replica projection; a binding cannot collapse a set. No new read source. file:Exec@259,registry:Changed@225,registry:remote@112,registry:remote@80,registry:sql@259,whole:remoteClient@114,whole:remoteClient@82 3ce7adcfb074126b83a93efbd284d9063a62ac0ed8bece4561283705bfdba4f3
+@legacy 2341d52700480b570ac5c809280fb50ad29154a11856912c7613c3239ed6351a internal/registry/forward.go Route.InertForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 2: true only when every one of the 50 forbidden columns of §4.2 is zero (one +registry:<field> site each, nothing else). Pure.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2): two more forbidden fields must be zero on a forward row, Assigned == "" and !Moved (fleet_assigned, fleet_moved in ForwardForbidden). Stricter, never looser.;rev3=census-ruling-stateless-replicas-2;basis=Pure validation additionally refuses malformed set projections; all unrelated forbidden fields still must be zero. registry:Addr@114,registry:Addrs@132,registry:Args@819,registry:AssetGen@304,registry:AssetsOff@287,registry:Assigned@1172,registry:Backing@745,registry:BuildState@1009,registry:Canary@666,registry:Caps@579,registry:ClaimIncarnation@1071,registry:ClaimOwner@1124,registry:ClaimRowID@1148,registry:ClaimStamp@1101,registry:DBPath@349,registry:EgressAllow@937,registry:Environment@534,registry:Gate@647,registry:GoodDemand@464,registry:GoodDigest@440,registry:GoodVersion@415,registry:HA@616,registry:Health@151,registry:Hibernate@598,registry:HoldOp@171,registry:IdleSeconds@837,registry:ImportGate@262,registry:Incarnation@191,registry:LastError@326,registry:MaxRunSeconds@861,registry:Moved@1195,registry:NextDue@705,registry:Platform@785,registry:PolicyExpiresAt@980,registry:Pool@516,registry:PrevVersion@390,registry:Replica@1056,registry:Replicas@1033,registry:Replication@680,registry:Runtime@626,registry:Seed@801,registry:SeedSource@238,registry:ServingSeq@215,registry:ServingVersion@488,registry:Size@962,registry:Socket@94,registry:StatusNamed@726,registry:Steering@887,registry:Tunnel@559,registry:Unit@766,registry:UpdateSettings@909,registry:Version@369 9f79218887204b816bca2d371e96b7a175033136070104a84d8618ef27b2b2da
+@legacy 7e6da4ae0835f902bbbe42b971e9681493463ddc31461b733f015a489af10c11 internal/registry/registry.go Registry.Fingerprint legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user); the remote arm, unchanged, in the process that holds a remote handle: census-ruling-seeded-instances's body with the row's lifetime pair (incarnation, serving_seq) folded into the edge's change poll, each only when non-zero, so a registry with no pair digests as before; self-serve moves 1 Task 7;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: hashes regional_domains (host, target, account, app, region; created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no regional rows digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; no file path read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): review R1 finding 1: the routes SELECT also reads host, kind, account, app, platform and fingerprintForwardInert (one CASE over the ForwardForbidden columns), and every row folds host, kind, account and app (tagged, quoted), platform when set, and forward_inert=0 for a forward row that is not inert, so a rowid reused by another hostname, an in-place account or app rewrite, or a stray forbidden column moves the edge's change poll. Same one SELECT per table on the same fresh connection to the box's own registry database, as carlos; no table, file or bucket read added; a digest, never a decision.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5): the SELECT also reads fleet_label and, only when it is set, hashes "fleet_label=<q>" into the digest, so labelling a row moves the edge's reload fingerprint. Read sites unchanged (33). Registry side, not root; an unlabelled registry's digest is byte-identical.;rev3=census-ruling-stateless-replicas-1;basis=Read the additive stateless projection in the existing registry SELECT and hash only when set; no new read source.;rev3=census-ruling-stateless-replicas-2;basis=Four additive projection columns join the existing routes SELECT and hash only when nonzero; no new query or file read. file:Exec@284,file:Open@188,file:Query@10297,file:Query@368,file:Query@6167,file:Query@6646,file:Query@7632,file:Query@8328,file:Query@9240,registry:ClaimIncarnation@1598,registry:ClaimIncarnation@5075,registry:ClaimIncarnation@5152,registry:ClaimOwner@1642,registry:ClaimOwner@5276,registry:ClaimOwner@5341,registry:ClaimRowID@1661,registry:ClaimRowID@5368,registry:ClaimRowID@5434,registry:ClaimStamp@1623,registry:ClaimStamp@5185,registry:ClaimStamp@5249,registry:Incarnation@1706,registry:Incarnation@5655,registry:Incarnation@5719,registry:ServingSeq@1725,registry:ServingSeq@5746,registry:ServingSeq@5809,registry:Text@158,registry:path@207,registry:remote@55,registry:remote@87,whole:remoteClient@57,whole:remoteClient@89 892ed6fd3faa8afd814643d8ddc1b757587892d43981db456d8b09cec08d07fe
+@legacy 2798f16cd866e84221c3c5f2e3cb130afcd7c61bf1eccae3e7f0dc87a563e4be internal/registry/registry.go upsertRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-alias-socket-follow-338;basis=#338: Upsert's unchanged statement moved into a helper so it can run on the database or inside a transaction;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 2 (runtimeFixed in the registry): takes a guard appended to the ON CONFLICT WHERE (UpsertUnlessRootfs passes routes.runtime = ''); a stored row with a runtime keeps its region and hibernate unless the tenant changed; replication is cleared only when the effective runtime is empty; no new read source, same SQLite table;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 3: on a refused conflict, the forward check reads the host (+registry:Host) to answer ErrForwardRow; the statement carries kind <> 'forward'. A refusal only.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2): the conflict arm gains fleet_assigned (the excluded value on a re-tenanted host, else kept when the writer carries '') and fleet_moved (excluded on a re-tenanted host, else MAX of stored and excluded). Read sites unchanged (3). The same statement guard (claim ownership, kind <> 'forward') applies.;rev3=census-ruling-stateless-replicas-1;basis=Persist the stateless projection in the existing guarded upsert; no new read.;rev3=census-ruling-stateless-replicas-2;basis=Existing guarded SQL upsert carries four additive projection columns; no new read source or execution authority. file:Exec@116,registry:Host@4876,whole:Route@4752 83400279ca15f879933151b6b8fa03c2b6e24051172b69b52fa6c511ee96ab11
+@legacy c2884b0d5b53dc03c9be18f949be500c2cf8a6be869b99c6f63a8bcf6dda68a6 internal/activator/wakeidentity.go Service.CheckReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Only set rows invoke existing registry/instance-record wake recheck. Legacy returns without reading; not a new polling loop. registry:FleetBoxes@93,whole:Route@169 43e922e015b61f736ed118ad44113802ca1944b676e9586388d6f9e00d691eba
+@legacy 0209cc9c5299a0027e5a4334ddf745b648e911ef89850656f8d596cb621ef7e2 internal/host/fleetidentity.go recheckReplicaPickup legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Only set rows require a launcher with the activator current-membership check; missing check refuses pickup. Reads supplied Route only. registry:FleetBoxes@98,whole:Route@322 7af336690a854d75b8a68b2f8031f8fb2cbd8441117e73c30610307d8f0dd7ca
+@legacy 9ee0215e87836c375afd79bb0afd249425eaf6ae649f80003172ef145f960e79 internal/provision/forward.go forwardRowFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Projects declarative set fields from supplied record; keeps socket, database, execution and all other forbidden fields zero. whole:Route@436,whole:Route@453 9ba6c562aa2b720af029d069b5855b8d1dc32ff76c742c90ad13604f8f19970d
+@legacy 21e8fd1f758eb29f88a54d4c6f2b1e5e09b11698ac49be92af24fa09d51626f3 internal/provision/replicaassignment.go projectReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Pure canonical projection of supplied assignment and record lifetime; no read outside arguments, no launch authority. registry:Copies@299,registry:FleetBox@450,registry:FleetBoxes@284,registry:FleetLabel@463,registry:ReplicaIncarnation@330,registry:ReplicaRevision@310,registry:Stateless@429 4b10be064d363d2d810908521e497f07b0c577b0bd618d17ab7464f1f4198063
+@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 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 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
+@legacy dfb973413e87bb5bb88322163377956d199442b4ca9df87126c8ec3c51f10256 internal/activator/cmdunit.go ExecBackend.StartCmd legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): writes launch.cmd.json in the instance's own directory and asks instance control to start the cmd unit; root validates the staged executable it names (refuseStagedExe) and decides the start;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: after the layout and run-directory checks, a rootfs row returns startRootfsRun (backend_rootfs.go) before nestedGate; the binary path is byte-identical (TestBinaryStartCmdLaunchGolden); new site +whole:Route is rt.Rootfs(); Plan 6 Task 8: a session (spec.TTY): checkCmdLaunch refuses before anything is listened on or written a launch shape (errCmdLaunchShape: process and argv both or neither, a process other than console, a run naming a process, a session with a run directory or streams, an id that is not one path element) and a process on a binary row (errBinaryProcess); then the session verbs (TTYControl) or ErrNoTTY; on a binary row the same nested gate, live link or staged build, launch environment and replica gate as a run; prepare(rt, RoleTTY); the pty and its handoff socket (openTTY) in place of the two streams; launch.tty.json with argv [live link, args...] and childEnv(ttyVars); then TTYControl.TTY, or TTYExe naming the staged build (POST /tty; root Task 6 handler validates it); the run path is unchanged (TestBinaryStartCmdLaunchGolden); new sites are rt to checkCmdLaunch and rt.Host in its error;rev3=census-ruling-stateless-replicas-2;basis=Only a set row invokes the caller's exec gate after binary command launch preparation and before any Cmd/TTY control call. Existing single-copy/stateful command path is unchanged; rootfs commands already invoke the gate. registry:FleetBoxes@2475,registry:Host@1092,registry:Host@1201,registry:Host@1972,registry:Host@2176,registry:Host@218,registry:Host@2404,registry:Host@2693,registry:Host@2767,registry:Host@2841,registry:Host@2915,registry:Host@3299,registry:Host@3432,registry:Host@3468,registry:Host@367,registry:Host@473,registry:Host@685,registry:Host@983,whole:Route@130,whole:Route@1788,whole:Route@1895,whole:Route@2220,whole:Route@2313,whole:Route@2585,whole:Route@298,whole:Route@3233,whole:Route@3237,whole:Route@3519,whole:Route@3523,whole:Route@414,whole:Route@755,whole:Route@792 cf3e3d38b9143532a9821578987c84e0d7dcea85e97a36a6d2aaba585f8081d7
+@legacy 2fdba081c7b8c93c93a77d81d5640be1b269d92137360e531879cfdd1cbd9d80 internal/activator/startrule.go ExecBackend.establishAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-managed-fleets-1b;basis=new (Task 3, rule 6): on a labelled row (rt.Assigned set), MkdirAll the instance directory (0700) and write rt.Assigned to <db>.assigned via writeDurable. Unlabelled rows write nothing. Agent as carlos, not root.;rev3=census-ruling-stateless-replicas-2;basis=A set projection refuses this SQLite marker path; verified stateless launches already bypass it. Legacy behavior unchanged. registry:Assigned@207,registry:Assigned@543,registry:FleetBoxes@159,registry:Host@348,registry:Host@463,registry:Host@679 084270cbed04e3ae3d69dd3d0796aad58bb2e1c9a4c57a0a7a9f0e66caebfa21
+@legacy a4a4c60476a1ef167f17d08b452d61b6e23a3bb7775b088b6460279064bf5958 internal/activator/startrule.go ExecBackend.reconcileAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-managed-fleets-1b;basis=new (Task 3, rule 6): on a labelled row, Lstat the instance dir, read the <db>.assigned marker with instancefs.ReadBeneathLimitOrAbsent (no symlink follow, 128 bytes max), Lstat the database; a copy not kept under rt.Assigned is moved by supersede into <DataDir>/.superseded/<host>/<nanos> (RenameBetweenNoReplace, fsync barriers), never deleted. Any read failure refuses the wake. Agent as carlos in the instance directory, not root.;rev3=census-ruling-stateless-replicas-2;basis=A set projection refuses this SQLite set-aside path before any filesystem read or move. Verified stateless launches bypass it; legacy unchanged. file:Lstat@379,file:Lstat@804,registry:Assigned@1332,registry:Assigned@1429,registry:Assigned@1463,registry:Assigned@207,registry:Assigned@777,registry:FleetBoxes@159,registry:Host@1022,registry:Host@1192,registry:Host@1547,registry:Host@1677,registry:Host@1803,registry:Host@348,registry:Host@542,registry:Host@727 2d3c4b0dc36bc1dee209f00a80c6871543a2b07cfe8f2acef5c2bd8b6ab26782
+@legacy be13da7e0d2a07dee196e48ef757c031984dca615586f773f1349e8ae6b41af8 internal/activator/startrule.go ExecBackend.startAllowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-managed-fleets-1b;basis=new (Task 3, rule 6): the start rule: an unlabelled or restored start is allowed; a kept local copy must match rt.Assigned in its marker; an empty start of a labelled row is refused (ErrNothingToRestore) when a set-aside entry exists for the host or rt.Moved is set. Only refuses. Agent, not root.;rev3=census-ruling-stateless-replicas-2;basis=A set projection refuses this SQLite empty-start rule; does not turn a route hint into bypass authority. Legacy rule unchanged. registry:Assigned@211,registry:Assigned@668,registry:Assigned@820,registry:FleetBoxes@163,registry:Host@268,registry:Moved@1407,whole:Route@315 c0576b3af038f2a714e43ae6263d259110825f3ea18f5c9798214d7baf6958e4
+@legacy 8a1cdcb513d1b84a59949d90b575f60448a6010d2ffb38381e6d82cf4b1bcbeb internal/activator/wakeidentity.go Service.currentWakeRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Extract existing registry and labelled fleet record recheck for reuse without a serving lease; return the observed row and record and refuse a nil record. No writer or new path.;rev3=census-ruling-stateless-replicas-2;basis=Existing registry/record recheck validates canonical set, membership, lifetime, revision, owner and managed stateless shape. Reuses the one wake record read; unknown fleet and malformed projection refuse. registry:Account@1846,registry:App@1871,registry:Assigned@2821,registry:Assigned@3031,registry:Assigned@510,registry:Channel@2015,registry:Copies@2407,registry:Environment@2077,registry:FleetBoxes@1523,registry:FleetBoxes@2357,registry:FleetBoxes@531,registry:FleetBoxes@641,registry:Host@1114,registry:Host@1243,registry:Host@1410,registry:Host@1893,registry:Host@281,registry:Host@2956,registry:Host@379,registry:Host@971,registry:Kind@1592,registry:Region@1918,registry:Region@1949,registry:ReplicaIncarnation@2323,registry:ReplicaRevision@2454,registry:Runtime@2044,whole:Route@1327,whole:Route@229,whole:Route@2751,whole:Route@3056,whole:Route@427,whole:Route@431,whole:Route@488,whole:Route@499,whole:Route@563,whole:Route@721 abf3135d80b76a02b2047a9bcedc85852d38625eab20f550848878485b4d2e16
+@legacy 82e2db3ec3ff76eedea214649dba1a3ce0f2824d358cf46bf1bf0415534bf262 internal/activator/wakeidentity.go leaseRouteChanged legacy accepted-legacy accepted-legacy;rev3=census-ruling-managed-fleets-1b;basis=new (branch review R1 P1-1): a pure comparison of the row a wake began from (began) with the row doWake read under the lease (now): nil now is a row that is gone; then wakeRouteChanged's identity checks; then Assigned and Moved; then Region. It answers an error naming the change, wrapping errRouteChangedUnderLease, or nil. No read beyond its arguments. Agent, not root; it only refuses.;rev3=census-ruling-stateless-replicas-2;basis=Pure comparison adds set/count/revision/lifetime changes to existing wake fence; no new input source. registry:Assigned@559,registry:Assigned@577,registry:Assigned@771,registry:Assigned@796,registry:Copies@388,registry:Copies@404,registry:FleetBoxes@350,registry:FleetBoxes@370,registry:Host@164,registry:Host@732,registry:Host@940,registry:Moved@593,registry:Moved@608,registry:Moved@785,registry:Moved@812,registry:Region@831,registry:Region@847,registry:Region@979,registry:Region@991,registry:ReplicaIncarnation@466,registry:ReplicaIncarnation@494,registry:ReplicaRevision@418,registry:ReplicaRevision@443,whole:Route@234,whole:Route@242,whole:Route@91 692ba8509b2b5dc40a1bd39bf5038b68c5d8c41e8fdc264a1f4041892d300210
+@legacy 65ed263d8b271d4034ed07e82186409e2b68c86ff1ea12dd7bb89cda90e5e65e internal/host/fleetbind.go statelessBindingPublisher.publish legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Task 3b: consume the applied record and serving route already read by reconcile, check instance/account/app/assignment/status/fleet/box and exact held coordinator lifetime, then publish the existing binding key. A per-host state cache excludes expiry-only renewals and avoids unchanged binding I/O. No instance-record scan or root exec; no typed record writer added.;rev3=census-ruling-stateless-replicas-2;basis=Refuses record or route set assignments before the single-box binding writer; no new read. registry:Account@328,registry:App@357,registry:Assigned@378,registry:FleetBoxes@150,registry:Host@305,registry:Provisioned@263,registry:ServingVersion@1067,registry:Stateless@210,registry:Status@281 46ba5abc35a4c59b6ab66e6d3691663ce4f2f9ae0e70b6ac56d2df91127cd24c
+@legacy 122fa7f57714580041b4e16316fc152a4156a94f1caf344f19a385a1a12d5021 internal/provision/forward.go forwardCurrent legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: compares the existing forward row's declared fields with the wanted one (+registry:Account, App, Channel, Provisioned, RateLimit, Region, Slug, Status, each x2). Pure.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5): the forward row is current only if FleetLabel also matches and, for a labelled want, FleetBox equals the label (+registry:FleetBox x2, +registry:FleetLabel x3). The hub's forward phase in the agent, not root; it may write a row it skipped before, never fewer checks.;rev3=census-ruling-stateless-replicas-2;basis=Pure comparison covers explicit count/set/revision/lifetime and assigned mode; legacy nil-assignment mode comparison remains unchanged. registry:Account@550,registry:Account@570,registry:App@520,registry:App@536,registry:Channel@624,registry:Channel@644,registry:Copies@137,registry:Copies@156,registry:FleetBox@376,registry:FleetBox@774,registry:FleetBox@795,registry:FleetBoxes@118,registry:FleetBoxes@282,registry:FleetBoxes@351,registry:FleetBoxes@95,registry:FleetLabel@704,registry:FleetLabel@727,registry:FleetLabel@749,registry:Provisioned@442,registry:Provisioned@466,registry:RateLimit@662,registry:RateLimit@684,registry:Region@588,registry:Region@607,registry:ReplicaIncarnation@223,registry:ReplicaIncarnation@254,registry:ReplicaRevision@171,registry:ReplicaRevision@199,registry:Slug@488,registry:Slug@505,registry:Stateless@307,registry:Stateless@329,registry:Status@406,registry:Status@425 35f2010c3c11b810e2a7f06c0575c2d08cf1777b71b091d9c432f1835f187c5a
+@legacy 3c66e18360145f5b51424c046007e4c04faa94d0b2bed1e75af88fe2b58bfd5a internal/provision/reconcile.go Reconcile legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 4, rules 2 and 9): after inScope, a record failing cfg.ownsRecord (on a fleet box, labelled for another box: rec.FleetBox != "" and != cfg.FleetBox) is skipped as out of scope, so it is never minted here; in the removal phase such a record no longer keeps the row (inScope && ownsRecord), so the row goes as record gone. Off a fleet ownsRecord is always true. Read sites unchanged (178). The agent's reconcile loops, not root; it mints less, never more.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 3: in the per-record loop, beside the RunSeen call, calls cfg.InteractiveSeen(rec) when the hook is set and the in-scope record carries an interactive-session marker (rec.Interactive != nil), once per record per pass, before the pass acts on it; the hook is the box worker's non-blocking note (Task 12). Same record keys and literal; no read added (registry read sites unchanged, 178); nothing written by the call; merge of origin/main 6f1f6ca6: main's fleet-box ownsRecord skip in the record scan and in the removal phase is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (178);rev3=census-ruling-stateless-replicas-1;basis=Task 3b: call the optional binding callback only for applied, owned stateless rows outside dry run. Reuses this pass record and route reads after existing collision, scope, hold, policy and shape checks; no new record read or typed writer. Fix 3b round 1 I1: binding callback failure is logged and falls through to pr.applied; same per-host callback, record writers, scope and removal gates. TestStatelessBindingFailureContinuesReconcile covers second-record convergence, removal, applied bookkeeping and next-pass retry.;rev3=census-ruling-stateless-replicas-2;basis=Uses already-scanned records plus read-free verified manifest hook; unverifiable sets are protected. Admission and removal check membership; retirement checks owner/lifetime and conditional local deletion, never ACKs Retiring. No extra bucket reads. registry:Account@36926,registry:Account@38191,registry:Account@56541,registry:Account@56587,registry:Account@57278,registry:Account@58030,registry:Account@58407,registry:Account@58633,registry:Account@58700,registry:Account@58746,registry:Account@58839,registry:Account@58881,registry:Account@59529,registry:Account@59787,registry:Account@60785,registry:Account@60833,registry:Account@61242,registry:Account@61288,registry:Account@61533,registry:Account@61958,registry:Account@62446,registry:Account@63182,registry:Account@63375,registry:Account@63715,registry:Account@63953,registry:Account@64518,registry:App@36899,registry:App@38164,registry:App@56561,registry:App@56599,registry:App@57307,registry:App@58042,registry:App@58419,registry:App@58645,registry:App@58720,registry:App@58758,registry:App@58859,registry:App@59541,registry:App@59799,registry:App@60797,registry:App@60845,registry:App@61262,registry:App@61300,registry:App@61545,registry:App@61970,registry:App@62458,registry:App@63194,registry:App@63387,registry:App@63727,registry:App@63965,registry:App@64530,registry:Canary@57054,registry:ClaimOwnership@37513,registry:DBPath@46370,registry:DBPath@46385,registry:DBPath@46631,registry:DBPath@47234,registry:DBPath@47247,registry:EgressAllow@36012,registry:FleetBoxes@57015,registry:FleetBoxes@57163,registry:FleetBoxes@63575,registry:Gate@42715,registry:Gate@42855,registry:Gate@43142,registry:Hibernate@41387,registry:Hibernate@41585,registry:Hibernate@41650,registry:Hibernate@41989,registry:Hibernate@42340,registry:Hibernate@42650,registry:HoldOp@62927,registry:HoldOp@63018,registry:HoldOp@63153,registry:HoldOp@63529,registry:Host@27020,registry:Host@56520,registry:Host@57114,registry:Host@58006,registry:Host@58383,registry:Host@58547,registry:Host@58653,registry:Host@59549,registry:Host@59755,registry:Host@61125,registry:Host@61397,registry:Host@61512,registry:Host@61835,registry:Host@61932,registry:Host@62323,registry:Host@62420,registry:Host@62634,registry:Host@63009,registry:Host@63144,registry:Host@63348,registry:Host@63421,registry:Host@63520,registry:Host@63767,registry:Host@63927,registry:Host@64002,registry:Host@64088,registry:Host@64495,registry:Kind@37655,registry:Kind@37918,registry:Kind@46288,registry:Kind@46301,registry:Kind@46411,registry:Kind@46424,registry:Kind@47145,registry:Kind@47156,registry:Kind@55644,registry:Kind@62625,registry:Kind@63135,registry:Kind@63511,registry:Kind@63918,registry:Kind@64079,registry:Platform@57039,registry:PolicyExpiresAt@36037,registry:Pool@55730,registry:Provisioned@36875,registry:Provisioned@38140,registry:Provisioned@55689,registry:RateLimit@43228,registry:RateLimit@43379,registry:RateLimit@43666,registry:Region@55719,registry:ReplicaIncarnation@57328,registry:ReplicaIncarnation@60225,registry:Replication@42074,registry:Replication@42201,registry:Runtime@29677,registry:Runtime@29855,registry:Runtime@32060,registry:Runtime@40754,registry:Runtime@40808,registry:Runtime@41012,registry:Seed@44768,registry:SeedSource@44251,registry:Size@36028,registry:Socket@46336,registry:Socket@46351,registry:Socket@46648,registry:Socket@47204,registry:Socket@47217,registry:Stateless@47337,registry:Unit@46254,registry:Unit@46267,registry:Unit@47171,registry:Unit@47182,whole:ClaimOwnership@37516,whole:ClaimOwnership@37533,whole:Route@27002,whole:Route@27013,whole:Route@27031,whole:Route@28312,whole:Route@30172,whole:Route@30179,whole:Route@30219,whole:Route@30580,whole:Route@30918,whole:Route@31365,whole:Route@31416,whole:Route@31453,whole:Route@33125,whole:Route@33334,whole:Route@33673,whole:Route@33682,whole:Route@33728,whole:Route@35961,whole:Route@36520,whole:Route@36991,whole:Route@37001,whole:Route@37358,whole:Route@37365,whole:Route@37433,whole:Route@37756,whole:Route@38789,whole:Route@41740,whole:Route@46480,whole:Route@47450,whole:Route@48337,whole:Route@48382,whole:Route@48392,whole:Route@49262,whole:Route@50289,whole:Route@55755,whole:Route@55903,whole:Route@57000,whole:Route@57958,whole:Route@58340,whole:Route@63666,whole:Route@63840,whole:Route@64425,whole:Route@64475 c805d2205410d9f54f1243c137e9388321a384b1093d23d27588033e7cbc62a9
+@legacy 6b946f3390ebc1f5c37960d4ba1f6d9c3869f149866ddf93360a61c948fe9600 internal/provision/reconcile.go convergeOwned legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the owned-converge arm gains the asset pair beside steering: when the row's assets_off or asset_gen differs from the record's (Record.AssetsOn, Record.AssetGen), Registry.SetAssets converges both in one UPDATE (dry-run logs only); the new kinds are registry:AssetsOff and registry:AssetGen, three sites each, all existing.AssetsOff and existing.AssetGen (the comparison and the two log lines); it now also returns the converge errors it already logged, joined, so Reconcile's completeness report can tell an applied record from one that was not; no other read is added; the agent's own pass, no root decision;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the owned-converge arm gains the app policy: when the row's egress_allow, size or policy_expires_at differs from the pass's columns (ap, only when Known), Registry.SetPolicy writes all three in one UPDATE (dry run logs only), and it reports whether the allow or size moved so Reconcile can call PolicyChanged. New kinds registry:EgressAllow (three sites), registry:Size (three) and registry:PolicyExpiresAt (one), all existing.* of the agent's own row: the comparison and the two log lines; no other read added; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: when the record says HA and the existing row does not, marks the row with reg.SetHA (a dry run logs instead; an error is appended to the pass's errors); converges one way only, nothing clears the mark; +registry:HA is existing.HA; keeps legacy;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2): when the row's Assigned or Moved differs from the record's FleetBoxAt or FleetBoxMoved, one reg.SetFleetAssignment call (dry-run logs instead); a failure is logged and counted. Agent provision pass, not root.;rev3=census-ruling-stateless-replicas-2;basis=Converges set projection through typed lifetime/revision writer; first seed compares entire observed SQL row. Reads supplied record and existing registry only. registry:Addr@3137,registry:Addr@3359,registry:Addr@3786,registry:Addrs@3164,registry:Addrs@3380,registry:Addrs@3807,registry:AssetGen@4644,registry:AssetGen@4830,registry:AssetGen@5221,registry:AssetsOff@4614,registry:AssetsOff@4804,registry:AssetsOff@5195,registry:Assigned@7927,registry:Assigned@8131,registry:Assigned@8580,registry:Channel@1002,registry:Channel@1333,registry:Channel@872,registry:Copies@309,registry:Copies@328,registry:EgressAllow@10102,registry:EgressAllow@10524,registry:EgressAllow@9846,registry:Environment@1375,registry:Environment@1517,registry:Environment@1876,registry:FleetBoxes@267,registry:FleetBoxes@290,registry:HA@7304,registry:Health@3191,registry:Health@3403,registry:Health@3830,registry:Moved@7966,registry:Moved@8150,registry:Moved@8599,registry:PolicyExpiresAt@9927,registry:Replica@6663,registry:Replica@6791,registry:Replica@7123,registry:ReplicaIncarnation@395,registry:ReplicaIncarnation@426,registry:ReplicaIncarnation@516,registry:ReplicaIncarnation@599,registry:ReplicaIncarnation@707,registry:ReplicaRevision@343,registry:ReplicaRevision@371,registry:Replicas@5794,registry:Replicas@5919,registry:Replicas@6241,registry:Size@10140,registry:Size@10562,registry:Size@9888,registry:Stateless@454,registry:StatusNamed@1952,registry:StatusNamed@2096,registry:StatusNamed@2460,registry:Steering@3866,registry:Steering@3999,registry:Steering@4337,registry:UpdateSettings@8904,registry:UpdateSettings@9044,registry:UpdateSettings@9404,whole:Route@589 549fb3f0a2ea5fcae27c03dedb3f855c75a26d32a183a49056114bdea99313c6
+@legacy 0488f5b1e5085bd4a355c1726dca26aa6189486c20ebf3ff2ecb88ec938de1aa internal/registry/forward.go Registry.PutForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 2: the only writer of a forward row's declared columns: refuses an argument whose kind is not forward; copies only the declared fields from its argument (Status ready, Provisioned true; no forbidden column is ever written); inside one IMMEDIATE transaction refuses a host a non-forward row holds (ErrHostHeld); keeps FleetBox while Region is unchanged; preserves the observational columns (+file:Exec, +file:QueryRow, +registry:Account, App, Channel, RateLimit, Region, Slug, +registry:Host x3, +registry:Kind, +registry:remote x2, +whole:Route x3, +whole:remoteClient x2).;rev3=census-ruling-fleet-routes-followups;basis=refuses up front, with the new sentinel ErrNotForward and before any read or write, an rt that is not a forward row (as before, now a sentinel), has an empty Host, or whose Region is not a fleet placement (registry.FleetPlacement); +registry:Host x2 and +registry:Region x2 read only the argument in those checks; the transaction and statement are unchanged;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3), merged with main's ErrNotForward refusals (kept unchanged): the written row also carries FleetLabel = rt.FleetLabel and FleetBox = rt.FleetLabel; its conflict arm (forwardKept) writes fleet_label from the call and fleet_box as the call's label when set, else kept while the region is unchanged. The hub's forward phase in the agent, not root.;rev3=census-ruling-stateless-replicas-1;basis=Carry declarative Stateless into forward rows under existing transaction and shape guards; projection only.;rev3=census-ruling-stateless-replicas-2;basis=Validates canonical set projection, writes explicit declarative columns and clears single-box binding; all forbidden columns zero. Same transaction/read source. file:Exec@1509,file:QueryRow@1285,registry:Account@754,registry:App@731,registry:Channel@807,registry:Copies@1054,registry:FleetBox@1175,registry:FleetBoxes@1031,registry:FleetBoxes@1152,registry:FleetLabel@1187,registry:FleetLabel@942,registry:FleetLabel@972,registry:Host@1339,registry:Host@197,registry:Host@234,registry:Host@419,registry:Host@655,registry:Kind@206,registry:RateLimit@834,registry:Region@428,registry:Region@781,registry:Region@84,registry:ReplicaIncarnation@1122,registry:ReplicaRevision@1082,registry:Slug@707,registry:Stateless@1002,registry:remote@507,registry:remote@537,whole:Route@1542,whole:Route@592,whole:Route@600,whole:remoteClient@509,whole:remoteClient@539 cf547d7bae134b9ca326bd111378d02214373e65e6107ec809eac5e3aef5e7e7
+@legacy 4bc653a2811cb1340e1c5ae87403e3cef0ce97105977adef72ea0e09556e5d9c internal/registry/registry.go scanRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user): main's body with the two new columns scanned;rev3=census-ruling-design-edge-rate-limit-358;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user): main's body with the rate_limit column scanned into Route.RateLimit; the new kind is registry:RateLimit, one site; no other read;rev3=census-ruling-rootfs-apps-2;identity=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user);basis=main's body with the runtime column scanned into Route.Runtime, before rate_limit; the new kind is registry:Runtime, one site; no other read; re-digested at the merge of origin/main 3c33f2eb: main's assets_off and asset_gen (edge asset cache plan 1) scanned beside runtime and rate_limit; routeColCount 59; re-digested again at the merge of origin/main 953b9fda: main's incarnation and serving_seq (self-serve moves plan 1) scanned after asset_gen; routeColCount 61;rev3=census-ruling-instance-egress-sizes-328-329;identity=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user);basis=#328/#329 plan 1 Task 4: main's body with egress_allow, size and policy_expires_at scanned into Route.EgressAllow, Route.Size and Route.PolicyExpiresAt after serving_seq; the new kinds are registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each; routeColCount 64; no other read;rev3=census-ruling-region-ha-p1a;basis=scans one more column, ha, into Route.HA (+registry:HA); routeColCount 64 to 65; keeps legacy;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Tasks 2 and 5): scans three more columns, fleet_assigned, fleet_moved and fleet_label, into Route.Assigned, Moved and FleetLabel. Any root caller of Registry.Get sees three more fields, which no root decision reads (grep: only the activator start rule, edge, provision and registry read them).;rev3=census-ruling-stateless-replicas-1;basis=Decode the additive stateless registry column; no launch authority.;rev3=census-ruling-stateless-replicas-2;basis=Existing row scanner reads four additive SQL columns from the same row and connection. registry:Account@426,registry:Addr@194,registry:Addrs@516,registry:App@269,registry:Args@575,registry:AssetGen@885,registry:AssetsOff@1166,registry:Assigned@981,registry:Backing@351,registry:BuildState@800,registry:Canary@1220,registry:Caps@456,registry:CertExpiresAt@408,registry:Channel@299,registry:ClaimIncarnation@637,registry:ClaimOwner@673,registry:ClaimRowID@688,registry:ClaimStamp@658,registry:Copies@1044,registry:CreatedAt@559,registry:DBPath@230,registry:DNSCheckedAt@391,registry:DNSStatus@377,registry:EgressAllow@931,registry:Environment@440,registry:FleetBox@501,registry:FleetBoxes@1029,registry:FleetLabel@1002,registry:Gate@550,registry:GoodDemand@747,registry:GoodDigest@732,registry:GoodVersion@716,registry:HA@1128,registry:Health@526,registry:Hibernate@1196,registry:HoldOp@703,registry:Host@156,registry:IdleSeconds@584,registry:ImportGate@832,registry:Incarnation@898,registry:Kind@174,registry:LastError@216,registry:MaxRunSeconds@600,registry:Moved@1144,registry:NextDue@339,registry:Platform@1266,registry:PolicyExpiresAt@956,registry:Pool@277,registry:PrevVersion@253,registry:Provisioned@1290,registry:RateLimit@859,registry:Region@288,registry:Replica@1317,registry:ReplicaIncarnation@1075,registry:ReplicaRevision@1055,registry:Replicas@618,registry:Replication@323,registry:Runtime@847,registry:Seed@483,registry:SeedSource@817,registry:ServingSeq@914,registry:ServingVersion@762,registry:Size@947,registry:Slug@165,registry:Socket@183,registry:Stateless@1098,registry:Status@203,registry:StatusNamed@1241,registry:Steering@537,registry:Tunnel@465,registry:Unit@492,registry:UpdateSettings@781,registry:Version@241,whole:Route@1346 a0f26864ffc4267e026c166b681990dad201ce9059b4496c1c6ec0a33f7c8be0
+@legacy f4f316e743a54ab85328a1ebb455fe4ad775a71ee8e1401e14502b44a9d870e7 internal/host/runs.go runsWorker.pickup legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), its runs worker: a picked run's detached execution runs under provision.WithLifetimes of the worker's judge, so execute's record writes refuse a stale record; read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 16 (ruling R7): on a fleet box a run already let go is skipped before any read; the pickup CAS moves behind the run's sink (sinkFor: the bucket's, as before, or on a fleet box the run door relay once a grant verifies); one more whole-Route site, the row this box already owns passed to sinkFor; nothing new opened, run or followed;rev3=census-ruling-stateless-replicas-2;basis=Passes the already-owned Route to the activator current-record recheck before pickup, only for set rows; legacy reads unchanged. whole:Route@1195,whole:Route@1807,whole:Route@951 5f7199c119298d7cb374ec5d77b1478e91dcb7ca3f82106739662cd0b7e635db
+internal/registry/forward.go Registry.SetFleetBoxIf legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 1: one conditional UPDATE of fleet_box judging placement on the fleet (region = 'fleet/'||fleet), kind (not a sidecar) and ACTIVE membership in fleet_boxes at the write; returns whether a row changed (+file:Exec, +registry:Changed, +registry:remote x2, +registry:sql, +whole:remoteClient x2). Replaces SetFleetBox.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the one conditional UPDATE gains AND fleet_label = '', so a labelled forward row's fleet_box is never changed by a binding. Read sites unchanged (7). It writes less, never more. Agent hub's bindings pass, not root.;rev3=census-ruling-stateless-replicas-2;basis=Existing conditional SQL write refuses every replica projection; a binding cannot collapse a set. No new read source. file:Exec@259,registry:Changed@225,registry:remote@112,registry:remote@80,registry:sql@259,whole:remoteClient@114,whole:remoteClient@82 3ce7adcfb074126b83a93efbd284d9063a62ac0ed8bece4561283705bfdba4f3
+internal/registry/forward.go Route.InertForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 2: true only when every one of the 50 forbidden columns of §4.2 is zero (one +registry:<field> site each, nothing else). Pure.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2): two more forbidden fields must be zero on a forward row, Assigned == "" and !Moved (fleet_assigned, fleet_moved in ForwardForbidden). Stricter, never looser.;rev3=census-ruling-stateless-replicas-2;basis=Pure validation additionally refuses malformed set projections; all unrelated forbidden fields still must be zero. registry:Addr@114,registry:Addrs@132,registry:Args@819,registry:AssetGen@304,registry:AssetsOff@287,registry:Assigned@1172,registry:Backing@745,registry:BuildState@1009,registry:Canary@666,registry:Caps@579,registry:ClaimIncarnation@1071,registry:ClaimOwner@1124,registry:ClaimRowID@1148,registry:ClaimStamp@1101,registry:DBPath@349,registry:EgressAllow@937,registry:Environment@534,registry:Gate@647,registry:GoodDemand@464,registry:GoodDigest@440,registry:GoodVersion@415,registry:HA@616,registry:Health@151,registry:Hibernate@598,registry:HoldOp@171,registry:IdleSeconds@837,registry:ImportGate@262,registry:Incarnation@191,registry:LastError@326,registry:MaxRunSeconds@861,registry:Moved@1195,registry:NextDue@705,registry:Platform@785,registry:PolicyExpiresAt@980,registry:Pool@516,registry:PrevVersion@390,registry:Replica@1056,registry:Replicas@1033,registry:Replication@680,registry:Runtime@626,registry:Seed@801,registry:SeedSource@238,registry:ServingSeq@215,registry:ServingVersion@488,registry:Size@962,registry:Socket@94,registry:StatusNamed@726,registry:Steering@887,registry:Tunnel@559,registry:Unit@766,registry:UpdateSettings@909,registry:Version@369 9f79218887204b816bca2d371e96b7a175033136070104a84d8618ef27b2b2da
+internal/registry/registry.go Registry.Fingerprint legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user); the remote arm, unchanged, in the process that holds a remote handle: census-ruling-seeded-instances's body with the row's lifetime pair (incarnation, serving_seq) folded into the edge's change poll, each only when non-zero, so a registry with no pair digests as before; self-serve moves 1 Task 7;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: hashes regional_domains (host, target, account, app, region; created_at not) over the same fresh connection, with a section marker written only when a row exists, so a registry with no regional rows digests as before; the one added site is that SELECT (+file:Query) on the box's own registry database, as carlos; no file path read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): review R1 finding 1: the routes SELECT also reads host, kind, account, app, platform and fingerprintForwardInert (one CASE over the ForwardForbidden columns), and every row folds host, kind, account and app (tagged, quoted), platform when set, and forward_inert=0 for a forward row that is not inert, so a rowid reused by another hostname, an in-place account or app rewrite, or a stray forbidden column moves the edge's change poll. Same one SELECT per table on the same fresh connection to the box's own registry database, as carlos; no table, file or bucket read added; a digest, never a decision.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5): the SELECT also reads fleet_label and, only when it is set, hashes "fleet_label=<q>" into the digest, so labelling a row moves the edge's reload fingerprint. Read sites unchanged (33). Registry side, not root; an unlabelled registry's digest is byte-identical.;rev3=census-ruling-stateless-replicas-1;basis=Read the additive stateless projection in the existing registry SELECT and hash only when set; no new read source.;rev3=census-ruling-stateless-replicas-2;basis=Four additive projection columns join the existing routes SELECT and hash only when nonzero; no new query or file read. file:Exec@284,file:Open@188,file:Query@10297,file:Query@368,file:Query@6167,file:Query@6646,file:Query@7632,file:Query@8328,file:Query@9240,registry:ClaimIncarnation@1598,registry:ClaimIncarnation@5075,registry:ClaimIncarnation@5152,registry:ClaimOwner@1642,registry:ClaimOwner@5276,registry:ClaimOwner@5341,registry:ClaimRowID@1661,registry:ClaimRowID@5368,registry:ClaimRowID@5434,registry:ClaimStamp@1623,registry:ClaimStamp@5185,registry:ClaimStamp@5249,registry:Incarnation@1706,registry:Incarnation@5655,registry:Incarnation@5719,registry:ServingSeq@1725,registry:ServingSeq@5746,registry:ServingSeq@5809,registry:Text@158,registry:path@207,registry:remote@55,registry:remote@87,whole:remoteClient@57,whole:remoteClient@89 892ed6fd3faa8afd814643d8ddc1b757587892d43981db456d8b09cec08d07fe
+internal/registry/registry.go upsertRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-alias-socket-follow-338;basis=#338: Upsert's unchanged statement moved into a helper so it can run on the database or inside a transaction;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 2 (runtimeFixed in the registry): takes a guard appended to the ON CONFLICT WHERE (UpsertUnlessRootfs passes routes.runtime = ''); a stored row with a runtime keeps its region and hibernate unless the tenant changed; replication is cleared only when the effective runtime is empty; no new read source, same SQLite table;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 3: on a refused conflict, the forward check reads the host (+registry:Host) to answer ErrForwardRow; the statement carries kind <> 'forward'. A refusal only.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2): the conflict arm gains fleet_assigned (the excluded value on a re-tenanted host, else kept when the writer carries '') and fleet_moved (excluded on a re-tenanted host, else MAX of stored and excluded). Read sites unchanged (3). The same statement guard (claim ownership, kind <> 'forward') applies.;rev3=census-ruling-stateless-replicas-1;basis=Persist the stateless projection in the existing guarded upsert; no new read.;rev3=census-ruling-stateless-replicas-2;basis=Existing guarded SQL upsert carries four additive projection columns; no new read source or execution authority. file:Exec@116,registry:Host@4876,whole:Route@4752 83400279ca15f879933151b6b8fa03c2b6e24051172b69b52fa6c511ee96ab11
+internal/activator/wakeidentity.go Service.CheckReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Only set rows invoke existing registry/instance-record wake recheck. Legacy returns without reading; not a new polling loop. registry:FleetBoxes@93,whole:Route@169 43e922e015b61f736ed118ad44113802ca1944b676e9586388d6f9e00d691eba
+internal/host/fleetidentity.go recheckReplicaPickup legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Only set rows require a launcher with the activator current-membership check; missing check refuses pickup. Reads supplied Route only. registry:FleetBoxes@98,whole:Route@322 7af336690a854d75b8a68b2f8031f8fb2cbd8441117e73c30610307d8f0dd7ca
+internal/provision/forward.go forwardRowFor legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Projects declarative set fields from supplied record; keeps socket, database, execution and all other forbidden fields zero. whole:Route@436,whole:Route@453 9ba6c562aa2b720af029d069b5855b8d1dc32ff76c742c90ad13604f8f19970d
+internal/provision/replicaassignment.go projectReplicaAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-2;basis=Pure canonical projection of supplied assignment and record lifetime; no read outside arguments, no launch authority. registry:Copies@299,registry:FleetBox@450,registry:FleetBoxes@284,registry:FleetLabel@463,registry:ReplicaIncarnation@330,registry:ReplicaRevision@310,registry:Stateless@429 4b10be064d363d2d810908521e497f07b0c577b0bd618d17ab7464f1f4198063
+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.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 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
+internal/activator/cmdunit.go ExecBackend.StartCmd legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): writes launch.cmd.json in the instance's own directory and asks instance control to start the cmd unit; root validates the staged executable it names (refuseStagedExe) and decides the start;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: after the layout and run-directory checks, a rootfs row returns startRootfsRun (backend_rootfs.go) before nestedGate; the binary path is byte-identical (TestBinaryStartCmdLaunchGolden); new site +whole:Route is rt.Rootfs(); Plan 6 Task 8: a session (spec.TTY): checkCmdLaunch refuses before anything is listened on or written a launch shape (errCmdLaunchShape: process and argv both or neither, a process other than console, a run naming a process, a session with a run directory or streams, an id that is not one path element) and a process on a binary row (errBinaryProcess); then the session verbs (TTYControl) or ErrNoTTY; on a binary row the same nested gate, live link or staged build, launch environment and replica gate as a run; prepare(rt, RoleTTY); the pty and its handoff socket (openTTY) in place of the two streams; launch.tty.json with argv [live link, args...] and childEnv(ttyVars); then TTYControl.TTY, or TTYExe naming the staged build (POST /tty; root Task 6 handler validates it); the run path is unchanged (TestBinaryStartCmdLaunchGolden); new sites are rt to checkCmdLaunch and rt.Host in its error;rev3=census-ruling-stateless-replicas-2;basis=Only a set row invokes the caller's exec gate after binary command launch preparation and before any Cmd/TTY control call. Existing single-copy/stateful command path is unchanged; rootfs commands already invoke the gate. registry:FleetBoxes@2475,registry:Host@1092,registry:Host@1201,registry:Host@1972,registry:Host@2176,registry:Host@218,registry:Host@2404,registry:Host@2693,registry:Host@2767,registry:Host@2841,registry:Host@2915,registry:Host@3299,registry:Host@3432,registry:Host@3468,registry:Host@367,registry:Host@473,registry:Host@685,registry:Host@983,whole:Route@130,whole:Route@1788,whole:Route@1895,whole:Route@2220,whole:Route@2313,whole:Route@2585,whole:Route@298,whole:Route@3233,whole:Route@3237,whole:Route@3519,whole:Route@3523,whole:Route@414,whole:Route@755,whole:Route@792 cf3e3d38b9143532a9821578987c84e0d7dcea85e97a36a6d2aaba585f8081d7
+internal/activator/startrule.go ExecBackend.establishAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-managed-fleets-1b;basis=new (Task 3, rule 6): on a labelled row (rt.Assigned set), MkdirAll the instance directory (0700) and write rt.Assigned to <db>.assigned via writeDurable. Unlabelled rows write nothing. Agent as carlos, not root.;rev3=census-ruling-stateless-replicas-2;basis=A set projection refuses this SQLite marker path; verified stateless launches already bypass it. Legacy behavior unchanged. registry:Assigned@207,registry:Assigned@543,registry:FleetBoxes@159,registry:Host@348,registry:Host@463,registry:Host@679 084270cbed04e3ae3d69dd3d0796aad58bb2e1c9a4c57a0a7a9f0e66caebfa21
+internal/activator/startrule.go ExecBackend.reconcileAssignment legacy accepted-legacy accepted-legacy;rev3=census-ruling-managed-fleets-1b;basis=new (Task 3, rule 6): on a labelled row, Lstat the instance dir, read the <db>.assigned marker with instancefs.ReadBeneathLimitOrAbsent (no symlink follow, 128 bytes max), Lstat the database; a copy not kept under rt.Assigned is moved by supersede into <DataDir>/.superseded/<host>/<nanos> (RenameBetweenNoReplace, fsync barriers), never deleted. Any read failure refuses the wake. Agent as carlos in the instance directory, not root.;rev3=census-ruling-stateless-replicas-2;basis=A set projection refuses this SQLite set-aside path before any filesystem read or move. Verified stateless launches bypass it; legacy unchanged. file:Lstat@379,file:Lstat@804,registry:Assigned@1332,registry:Assigned@1429,registry:Assigned@1463,registry:Assigned@207,registry:Assigned@777,registry:FleetBoxes@159,registry:Host@1022,registry:Host@1192,registry:Host@1547,registry:Host@1677,registry:Host@1803,registry:Host@348,registry:Host@542,registry:Host@727 2d3c4b0dc36bc1dee209f00a80c6871543a2b07cfe8f2acef5c2bd8b6ab26782
+internal/activator/startrule.go ExecBackend.startAllowed legacy accepted-legacy accepted-legacy;rev3=census-ruling-managed-fleets-1b;basis=new (Task 3, rule 6): the start rule: an unlabelled or restored start is allowed; a kept local copy must match rt.Assigned in its marker; an empty start of a labelled row is refused (ErrNothingToRestore) when a set-aside entry exists for the host or rt.Moved is set. Only refuses. Agent, not root.;rev3=census-ruling-stateless-replicas-2;basis=A set projection refuses this SQLite empty-start rule; does not turn a route hint into bypass authority. Legacy rule unchanged. registry:Assigned@211,registry:Assigned@668,registry:Assigned@820,registry:FleetBoxes@163,registry:Host@268,registry:Moved@1407,whole:Route@315 c0576b3af038f2a714e43ae6263d259110825f3ea18f5c9798214d7baf6958e4
+internal/activator/wakeidentity.go Service.currentWakeRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Extract existing registry and labelled fleet record recheck for reuse without a serving lease; return the observed row and record and refuse a nil record. No writer or new path.;rev3=census-ruling-stateless-replicas-2;basis=Existing registry/record recheck validates canonical set, membership, lifetime, revision, owner and managed stateless shape. Reuses the one wake record read; unknown fleet and malformed projection refuse. registry:Account@1846,registry:App@1871,registry:Assigned@2821,registry:Assigned@3031,registry:Assigned@510,registry:Channel@2015,registry:Copies@2407,registry:Environment@2077,registry:FleetBoxes@1523,registry:FleetBoxes@2357,registry:FleetBoxes@531,registry:FleetBoxes@641,registry:Host@1114,registry:Host@1243,registry:Host@1410,registry:Host@1893,registry:Host@281,registry:Host@2956,registry:Host@379,registry:Host@971,registry:Kind@1592,registry:Region@1918,registry:Region@1949,registry:ReplicaIncarnation@2323,registry:ReplicaRevision@2454,registry:Runtime@2044,whole:Route@1327,whole:Route@229,whole:Route@2751,whole:Route@3056,whole:Route@427,whole:Route@431,whole:Route@488,whole:Route@499,whole:Route@563,whole:Route@721 abf3135d80b76a02b2047a9bcedc85852d38625eab20f550848878485b4d2e16
+internal/activator/wakeidentity.go leaseRouteChanged legacy accepted-legacy accepted-legacy;rev3=census-ruling-managed-fleets-1b;basis=new (branch review R1 P1-1): a pure comparison of the row a wake began from (began) with the row doWake read under the lease (now): nil now is a row that is gone; then wakeRouteChanged's identity checks; then Assigned and Moved; then Region. It answers an error naming the change, wrapping errRouteChangedUnderLease, or nil. No read beyond its arguments. Agent, not root; it only refuses.;rev3=census-ruling-stateless-replicas-2;basis=Pure comparison adds set/count/revision/lifetime changes to existing wake fence; no new input source. registry:Assigned@559,registry:Assigned@577,registry:Assigned@771,registry:Assigned@796,registry:Copies@388,registry:Copies@404,registry:FleetBoxes@350,registry:FleetBoxes@370,registry:Host@164,registry:Host@732,registry:Host@940,registry:Moved@593,registry:Moved@608,registry:Moved@785,registry:Moved@812,registry:Region@831,registry:Region@847,registry:Region@979,registry:Region@991,registry:ReplicaIncarnation@466,registry:ReplicaIncarnation@494,registry:ReplicaRevision@418,registry:ReplicaRevision@443,whole:Route@234,whole:Route@242,whole:Route@91 692ba8509b2b5dc40a1bd39bf5038b68c5d8c41e8fdc264a1f4041892d300210
+internal/host/fleetbind.go statelessBindingPublisher.publish legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Task 3b: consume the applied record and serving route already read by reconcile, check instance/account/app/assignment/status/fleet/box and exact held coordinator lifetime, then publish the existing binding key. A per-host state cache excludes expiry-only renewals and avoids unchanged binding I/O. No instance-record scan or root exec; no typed record writer added.;rev3=census-ruling-stateless-replicas-2;basis=Refuses record or route set assignments before the single-box binding writer; no new read. registry:Account@328,registry:App@357,registry:Assigned@378,registry:FleetBoxes@150,registry:Host@305,registry:Provisioned@263,registry:ServingVersion@1067,registry:Stateless@210,registry:Status@281 46ba5abc35a4c59b6ab66e6d3691663ce4f2f9ae0e70b6ac56d2df91127cd24c
+internal/provision/forward.go forwardCurrent legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: compares the existing forward row's declared fields with the wanted one (+registry:Account, App, Channel, Provisioned, RateLimit, Region, Slug, Status, each x2). Pure.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5): the forward row is current only if FleetLabel also matches and, for a labelled want, FleetBox equals the label (+registry:FleetBox x2, +registry:FleetLabel x3). The hub's forward phase in the agent, not root; it may write a row it skipped before, never fewer checks.;rev3=census-ruling-stateless-replicas-2;basis=Pure comparison covers explicit count/set/revision/lifetime and assigned mode; legacy nil-assignment mode comparison remains unchanged. registry:Account@550,registry:Account@570,registry:App@520,registry:App@536,registry:Channel@624,registry:Channel@644,registry:Copies@137,registry:Copies@156,registry:FleetBox@376,registry:FleetBox@774,registry:FleetBox@795,registry:FleetBoxes@118,registry:FleetBoxes@282,registry:FleetBoxes@351,registry:FleetBoxes@95,registry:FleetLabel@704,registry:FleetLabel@727,registry:FleetLabel@749,registry:Provisioned@442,registry:Provisioned@466,registry:RateLimit@662,registry:RateLimit@684,registry:Region@588,registry:Region@607,registry:ReplicaIncarnation@223,registry:ReplicaIncarnation@254,registry:ReplicaRevision@171,registry:ReplicaRevision@199,registry:Slug@488,registry:Slug@505,registry:Stateless@307,registry:Stateless@329,registry:Status@406,registry:Status@425 35f2010c3c11b810e2a7f06c0575c2d08cf1777b71b091d9c432f1835f187c5a
+internal/provision/reconcile.go Reconcile legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 4, rules 2 and 9): after inScope, a record failing cfg.ownsRecord (on a fleet box, labelled for another box: rec.FleetBox != "" and != cfg.FleetBox) is skipped as out of scope, so it is never minted here; in the removal phase such a record no longer keeps the row (inScope && ownsRecord), so the row goes as record gone. Off a fleet ownsRecord is always true. Read sites unchanged (178). The agent's reconcile loops, not root; it mints less, never more.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 3: in the per-record loop, beside the RunSeen call, calls cfg.InteractiveSeen(rec) when the hook is set and the in-scope record carries an interactive-session marker (rec.Interactive != nil), once per record per pass, before the pass acts on it; the hook is the box worker's non-blocking note (Task 12). Same record keys and literal; no read added (registry read sites unchanged, 178); nothing written by the call; merge of origin/main 6f1f6ca6: main's fleet-box ownsRecord skip in the record scan and in the removal phase is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (178);rev3=census-ruling-stateless-replicas-1;basis=Task 3b: call the optional binding callback only for applied, owned stateless rows outside dry run. Reuses this pass record and route reads after existing collision, scope, hold, policy and shape checks; no new record read or typed writer. Fix 3b round 1 I1: binding callback failure is logged and falls through to pr.applied; same per-host callback, record writers, scope and removal gates. TestStatelessBindingFailureContinuesReconcile covers second-record convergence, removal, applied bookkeeping and next-pass retry.;rev3=census-ruling-stateless-replicas-2;basis=Uses already-scanned records plus read-free verified manifest hook; unverifiable sets are protected. Admission and removal check membership; retirement checks owner/lifetime and conditional local deletion, never ACKs Retiring. No extra bucket reads. registry:Account@36926,registry:Account@38191,registry:Account@56541,registry:Account@56587,registry:Account@57278,registry:Account@58030,registry:Account@58407,registry:Account@58633,registry:Account@58700,registry:Account@58746,registry:Account@58839,registry:Account@58881,registry:Account@59529,registry:Account@59787,registry:Account@60785,registry:Account@60833,registry:Account@61242,registry:Account@61288,registry:Account@61533,registry:Account@61958,registry:Account@62446,registry:Account@63182,registry:Account@63375,registry:Account@63715,registry:Account@63953,registry:Account@64518,registry:App@36899,registry:App@38164,registry:App@56561,registry:App@56599,registry:App@57307,registry:App@58042,registry:App@58419,registry:App@58645,registry:App@58720,registry:App@58758,registry:App@58859,registry:App@59541,registry:App@59799,registry:App@60797,registry:App@60845,registry:App@61262,registry:App@61300,registry:App@61545,registry:App@61970,registry:App@62458,registry:App@63194,registry:App@63387,registry:App@63727,registry:App@63965,registry:App@64530,registry:Canary@57054,registry:ClaimOwnership@37513,registry:DBPath@46370,registry:DBPath@46385,registry:DBPath@46631,registry:DBPath@47234,registry:DBPath@47247,registry:EgressAllow@36012,registry:FleetBoxes@57015,registry:FleetBoxes@57163,registry:FleetBoxes@63575,registry:Gate@42715,registry:Gate@42855,registry:Gate@43142,registry:Hibernate@41387,registry:Hibernate@41585,registry:Hibernate@41650,registry:Hibernate@41989,registry:Hibernate@42340,registry:Hibernate@42650,registry:HoldOp@62927,registry:HoldOp@63018,registry:HoldOp@63153,registry:HoldOp@63529,registry:Host@27020,registry:Host@56520,registry:Host@57114,registry:Host@58006,registry:Host@58383,registry:Host@58547,registry:Host@58653,registry:Host@59549,registry:Host@59755,registry:Host@61125,registry:Host@61397,registry:Host@61512,registry:Host@61835,registry:Host@61932,registry:Host@62323,registry:Host@62420,registry:Host@62634,registry:Host@63009,registry:Host@63144,registry:Host@63348,registry:Host@63421,registry:Host@63520,registry:Host@63767,registry:Host@63927,registry:Host@64002,registry:Host@64088,registry:Host@64495,registry:Kind@37655,registry:Kind@37918,registry:Kind@46288,registry:Kind@46301,registry:Kind@46411,registry:Kind@46424,registry:Kind@47145,registry:Kind@47156,registry:Kind@55644,registry:Kind@62625,registry:Kind@63135,registry:Kind@63511,registry:Kind@63918,registry:Kind@64079,registry:Platform@57039,registry:PolicyExpiresAt@36037,registry:Pool@55730,registry:Provisioned@36875,registry:Provisioned@38140,registry:Provisioned@55689,registry:RateLimit@43228,registry:RateLimit@43379,registry:RateLimit@43666,registry:Region@55719,registry:ReplicaIncarnation@57328,registry:ReplicaIncarnation@60225,registry:Replication@42074,registry:Replication@42201,registry:Runtime@29677,registry:Runtime@29855,registry:Runtime@32060,registry:Runtime@40754,registry:Runtime@40808,registry:Runtime@41012,registry:Seed@44768,registry:SeedSource@44251,registry:Size@36028,registry:Socket@46336,registry:Socket@46351,registry:Socket@46648,registry:Socket@47204,registry:Socket@47217,registry:Stateless@47337,registry:Unit@46254,registry:Unit@46267,registry:Unit@47171,registry:Unit@47182,whole:ClaimOwnership@37516,whole:ClaimOwnership@37533,whole:Route@27002,whole:Route@27013,whole:Route@27031,whole:Route@28312,whole:Route@30172,whole:Route@30179,whole:Route@30219,whole:Route@30580,whole:Route@30918,whole:Route@31365,whole:Route@31416,whole:Route@31453,whole:Route@33125,whole:Route@33334,whole:Route@33673,whole:Route@33682,whole:Route@33728,whole:Route@35961,whole:Route@36520,whole:Route@36991,whole:Route@37001,whole:Route@37358,whole:Route@37365,whole:Route@37433,whole:Route@37756,whole:Route@38789,whole:Route@41740,whole:Route@46480,whole:Route@47450,whole:Route@48337,whole:Route@48382,whole:Route@48392,whole:Route@49262,whole:Route@50289,whole:Route@55755,whole:Route@55903,whole:Route@57000,whole:Route@57958,whole:Route@58340,whole:Route@63666,whole:Route@63840,whole:Route@64425,whole:Route@64475 c805d2205410d9f54f1243c137e9388321a384b1093d23d27588033e7cbc62a9
+internal/provision/reconcile.go convergeOwned legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-edge-asset-cache-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the owned-converge arm gains the asset pair beside steering: when the row's assets_off or asset_gen differs from the record's (Record.AssetsOn, Record.AssetGen), Registry.SetAssets converges both in one UPDATE (dry-run logs only); the new kinds are registry:AssetsOff and registry:AssetGen, three sites each, all existing.AssetsOff and existing.AssetGen (the comparison and the two log lines); it now also returns the converge errors it already logged, joined, so Reconcile's completeness report can tell an applied record from one that was not; no other read is added; the agent's own pass, no root decision;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the owned-converge arm gains the app policy: when the row's egress_allow, size or policy_expires_at differs from the pass's columns (ap, only when Known), Registry.SetPolicy writes all three in one UPDATE (dry run logs only), and it reports whether the allow or size moved so Reconcile can call PolicyChanged. New kinds registry:EgressAllow (three sites), registry:Size (three) and registry:PolicyExpiresAt (one), all existing.* of the agent's own row: the comparison and the two log lines; no other read added; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: when the record says HA and the existing row does not, marks the row with reg.SetHA (a dry run logs instead; an error is appended to the pass's errors); converges one way only, nothing clears the mark; +registry:HA is existing.HA; keeps legacy;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2): when the row's Assigned or Moved differs from the record's FleetBoxAt or FleetBoxMoved, one reg.SetFleetAssignment call (dry-run logs instead); a failure is logged and counted. Agent provision pass, not root.;rev3=census-ruling-stateless-replicas-2;basis=Converges set projection through typed lifetime/revision writer; first seed compares entire observed SQL row. Reads supplied record and existing registry only. registry:Addr@3137,registry:Addr@3359,registry:Addr@3786,registry:Addrs@3164,registry:Addrs@3380,registry:Addrs@3807,registry:AssetGen@4644,registry:AssetGen@4830,registry:AssetGen@5221,registry:AssetsOff@4614,registry:AssetsOff@4804,registry:AssetsOff@5195,registry:Assigned@7927,registry:Assigned@8131,registry:Assigned@8580,registry:Channel@1002,registry:Channel@1333,registry:Channel@872,registry:Copies@309,registry:Copies@328,registry:EgressAllow@10102,registry:EgressAllow@10524,registry:EgressAllow@9846,registry:Environment@1375,registry:Environment@1517,registry:Environment@1876,registry:FleetBoxes@267,registry:FleetBoxes@290,registry:HA@7304,registry:Health@3191,registry:Health@3403,registry:Health@3830,registry:Moved@7966,registry:Moved@8150,registry:Moved@8599,registry:PolicyExpiresAt@9927,registry:Replica@6663,registry:Replica@6791,registry:Replica@7123,registry:ReplicaIncarnation@395,registry:ReplicaIncarnation@426,registry:ReplicaIncarnation@516,registry:ReplicaIncarnation@599,registry:ReplicaIncarnation@707,registry:ReplicaRevision@343,registry:ReplicaRevision@371,registry:Replicas@5794,registry:Replicas@5919,registry:Replicas@6241,registry:Size@10140,registry:Size@10562,registry:Size@9888,registry:Stateless@454,registry:StatusNamed@1952,registry:StatusNamed@2096,registry:StatusNamed@2460,registry:Steering@3866,registry:Steering@3999,registry:Steering@4337,registry:UpdateSettings@8904,registry:UpdateSettings@9044,registry:UpdateSettings@9404,whole:Route@589 549fb3f0a2ea5fcae27c03dedb3f855c75a26d32a183a49056114bdea99313c6
+internal/registry/forward.go Registry.PutForward legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 2: the only writer of a forward row's declared columns: refuses an argument whose kind is not forward; copies only the declared fields from its argument (Status ready, Provisioned true; no forbidden column is ever written); inside one IMMEDIATE transaction refuses a host a non-forward row holds (ErrHostHeld); keeps FleetBox while Region is unchanged; preserves the observational columns (+file:Exec, +file:QueryRow, +registry:Account, App, Channel, RateLimit, Region, Slug, +registry:Host x3, +registry:Kind, +registry:remote x2, +whole:Route x3, +whole:remoteClient x2).;rev3=census-ruling-fleet-routes-followups;basis=refuses up front, with the new sentinel ErrNotForward and before any read or write, an rt that is not a forward row (as before, now a sentinel), has an empty Host, or whose Region is not a fleet placement (registry.FleetPlacement); +registry:Host x2 and +registry:Region x2 read only the argument in those checks; the transaction and statement are unchanged;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3), merged with main's ErrNotForward refusals (kept unchanged): the written row also carries FleetLabel = rt.FleetLabel and FleetBox = rt.FleetLabel; its conflict arm (forwardKept) writes fleet_label from the call and fleet_box as the call's label when set, else kept while the region is unchanged. The hub's forward phase in the agent, not root.;rev3=census-ruling-stateless-replicas-1;basis=Carry declarative Stateless into forward rows under existing transaction and shape guards; projection only.;rev3=census-ruling-stateless-replicas-2;basis=Validates canonical set projection, writes explicit declarative columns and clears single-box binding; all forbidden columns zero. Same transaction/read source. file:Exec@1509,file:QueryRow@1285,registry:Account@754,registry:App@731,registry:Channel@807,registry:Copies@1054,registry:FleetBox@1175,registry:FleetBoxes@1031,registry:FleetBoxes@1152,registry:FleetLabel@1187,registry:FleetLabel@942,registry:FleetLabel@972,registry:Host@1339,registry:Host@197,registry:Host@234,registry:Host@419,registry:Host@655,registry:Kind@206,registry:RateLimit@834,registry:Region@428,registry:Region@781,registry:Region@84,registry:ReplicaIncarnation@1122,registry:ReplicaRevision@1082,registry:Slug@707,registry:Stateless@1002,registry:remote@507,registry:remote@537,whole:Route@1542,whole:Route@592,whole:Route@600,whole:remoteClient@509,whole:remoteClient@539 cf547d7bae134b9ca326bd111378d02214373e65e6107ec809eac5e3aef5e7e7
+internal/registry/registry.go routeArgs authority E3 rev3=census-ruling-seeded-instances;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user), wherever a route is inserted: Upsert, the cold handover restore and the import journal's inserts: the bind list from Registry.Upsert's body (and RestoreClaimRows'), with seed_source and import_gate added; E3, the same family as Registry.Upsert, whose body it came from;rev3=census-ruling-design-edge-rate-limit-358;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user), wherever a route is inserted: the bind list gains t.RateLimit for the new rate_limit column (routeCols and Upsert's conflict clause gain it too); the new kind is registry:RateLimit, one site; it binds the value and decides nothing; E3, as before;rev3=census-ruling-rootfs-apps-2;identity=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user);basis=the bind list gains t.Runtime for the new runtime column (routeCols, routeColCount 57 with main's rate_limit, and Upsert's conflict clause gain it too); the new kind is registry:Runtime, one site; it binds the value and decides nothing; E3, as before; re-digested at the merge of origin/main 3c33f2eb: main's assets_off and asset_gen (edge asset cache plan 1) bound beside runtime and rate_limit; routeColCount 59; re-digested again at the merge of origin/main 953b9fda: main's incarnation and serving_seq (self-serve moves plan 1) bound after asset_gen; routeColCount 61;rev3=census-ruling-instance-egress-sizes-328-329;identity=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user);basis=#328/#329 plan 1 Task 4: the bind list gains t.EgressAllow, t.Size and t.PolicyExpiresAt for the three new columns (routeCols, routeColCount 64, and Upsert's conflict clause gain them too); the new kinds are registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each; it binds the values and decides nothing; E3, as before;rev3=census-ruling-region-ha-p1a;basis=binds one more column, ha, as an integer from Route.HA (+registry:HA); keeps authority E3;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Tasks 2 and 5): binds three more columns, t.Assigned, b2iDB(t.Moved) and t.FleetLabel (routeColCount 65 to 68).;rev3=census-ruling-stateless-replicas-1;basis=Encode the additive Stateless flag in the shared SQL insert argument list; no launch authority.;rev3=census-ruling-stateless-replicas-2;basis=Supplied Route contributes four additive declarative SQL values; no external read or new executable path. registry:Account@355,registry:Addr@83,registry:Addrs@451,registry:App@152,registry:Args@505,registry:AssetGen@818,registry:AssetsOff@804,registry:Assigned@916,registry:Backing@253,registry:BuildState@730,registry:Canary@216,registry:Caps@381,registry:CertExpiresAt@338,registry:Channel@177,registry:ClaimIncarnation@577,registry:ClaimOwner@611,registry:ClaimRowID@625,registry:ClaimStamp@597,registry:Copies@992,registry:CreatedAt@492,registry:DBPath@116,registry:DNSCheckedAt@320,registry:DNSStatus@307,registry:EgressAllow@861,registry:Environment@366,registry:FleetBox@439,registry:FleetBoxes@978,registry:FleetLabel@944,registry:Gate@484,registry:GoodDemand@680,registry:GoodDigest@666,registry:GoodVersion@651,registry:HA@909,registry:Health@460,registry:Hibernate@196,registry:HoldOp@639,registry:Host@49,registry:IdleSeconds@513,registry:ImportGate@760,registry:Incarnation@830,registry:Kind@65,registry:LastError@101,registry:MaxRunSeconds@528,registry:Moved@934,registry:NextDue@242,registry:Platform@294,registry:PolicyExpiresAt@884,registry:Pool@159,registry:PrevVersion@137,registry:Provisioned@407,registry:RateLimit@785,registry:Region@167,registry:Replica@565,registry:ReplicaIncarnation@1021,registry:ReplicaRevision@1002,registry:Replicas@547,registry:Replication@227,registry:Runtime@774,registry:Seed@423,registry:SeedSource@746,registry:ServingSeq@845,registry:ServingVersion@694,registry:Size@876,registry:Slug@57,registry:Socket@73,registry:Stateless@964,registry:Status@91,registry:StatusNamed@272,registry:Steering@472,registry:Tunnel@389,registry:Unit@431,registry:UpdateSettings@712,registry:Version@126 aac8acafa9ee736e00f8b3071f02589c74c7b6a167ec9f2b3fb94abc85181ac6
+internal/registry/registry.go scanRoute legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user): main's body with the two new columns scanned;rev3=census-ruling-design-edge-rate-limit-358;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user): main's body with the rate_limit column scanned into Route.RateLimit; the new kind is registry:RateLimit, one site; no other read;rev3=census-ruling-rootfs-apps-2;identity=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user);basis=main's body with the runtime column scanned into Route.Runtime, before rate_limit; the new kind is registry:Runtime, one site; no other read; re-digested at the merge of origin/main 3c33f2eb: main's assets_off and asset_gen (edge asset cache plan 1) scanned beside runtime and rate_limit; routeColCount 59; re-digested again at the merge of origin/main 953b9fda: main's incarnation and serving_seq (self-serve moves plan 1) scanned after asset_gen; routeColCount 61;rev3=census-ruling-instance-egress-sizes-328-329;identity=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user);basis=#328/#329 plan 1 Task 4: main's body with egress_allow, size and policy_expires_at scanned into Route.EgressAllow, Route.Size and Route.PolicyExpiresAt after serving_seq; the new kinds are registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each; routeColCount 64; no other read;rev3=census-ruling-region-ha-p1a;basis=scans one more column, ha, into Route.HA (+registry:HA); routeColCount 64 to 65; keeps legacy;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Tasks 2 and 5): scans three more columns, fleet_assigned, fleet_moved and fleet_label, into Route.Assigned, Moved and FleetLabel. Any root caller of Registry.Get sees three more fields, which no root decision reads (grep: only the activator start rule, edge, provision and registry read them).;rev3=census-ruling-stateless-replicas-1;basis=Decode the additive stateless registry column; no launch authority.;rev3=census-ruling-stateless-replicas-2;basis=Existing row scanner reads four additive SQL columns from the same row and connection. registry:Account@426,registry:Addr@194,registry:Addrs@516,registry:App@269,registry:Args@575,registry:AssetGen@885,registry:AssetsOff@1166,registry:Assigned@981,registry:Backing@351,registry:BuildState@800,registry:Canary@1220,registry:Caps@456,registry:CertExpiresAt@408,registry:Channel@299,registry:ClaimIncarnation@637,registry:ClaimOwner@673,registry:ClaimRowID@688,registry:ClaimStamp@658,registry:Copies@1044,registry:CreatedAt@559,registry:DBPath@230,registry:DNSCheckedAt@391,registry:DNSStatus@377,registry:EgressAllow@931,registry:Environment@440,registry:FleetBox@501,registry:FleetBoxes@1029,registry:FleetLabel@1002,registry:Gate@550,registry:GoodDemand@747,registry:GoodDigest@732,registry:GoodVersion@716,registry:HA@1128,registry:Health@526,registry:Hibernate@1196,registry:HoldOp@703,registry:Host@156,registry:IdleSeconds@584,registry:ImportGate@832,registry:Incarnation@898,registry:Kind@174,registry:LastError@216,registry:MaxRunSeconds@600,registry:Moved@1144,registry:NextDue@339,registry:Platform@1266,registry:PolicyExpiresAt@956,registry:Pool@277,registry:PrevVersion@253,registry:Provisioned@1290,registry:RateLimit@859,registry:Region@288,registry:Replica@1317,registry:ReplicaIncarnation@1075,registry:ReplicaRevision@1055,registry:Replicas@618,registry:Replication@323,registry:Runtime@847,registry:Seed@483,registry:SeedSource@817,registry:ServingSeq@914,registry:ServingVersion@762,registry:Size@947,registry:Slug@165,registry:Socket@183,registry:Stateless@1098,registry:Status@203,registry:StatusNamed@1241,registry:Steering@537,registry:Tunnel@465,registry:Unit@492,registry:UpdateSettings@781,registry:Version@241,whole:Route@1346 a0f26864ffc4267e026c166b681990dad201ce9059b4496c1c6ec0a33f7c8be0
+internal/registry/remote_dispatch.go Registry.dispatchRemote hint E2 rev3=census-ruling-self-serve-moves-1;basis=the registry child (carlos __registry-child, the service user a root pass forks): plan14-root-reads-e's mixed declaration (E2 adds only the ArtifactHosts read; every other arm is the local method of the same name), with three more write arms, SetHoldIfSeq, ReleaseHoldSeq and InstallLifetimeIf, each calling the local setter; no read operation added; self-serve moves 1 Task 7;rev3=census-ruling-instance-egress-sizes-328-329;identity=the registry child (carlos __registry-child, the service user a root pass forks);basis=#328/#329 plan 1 Task 4: one more write arm, SetPolicy, calling the local Registry.SetPolicy with the request's Host, EgressAllow, Size and PolicyExpiresAt (remoteRequest fields sent by the remote handle's holder); the new kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, plus one more registry:Host site, all of the request; no read operation added; the read-only worker never reaches it (serveRemote's method gate); no production root pass sends SetPolicy;rev3=census-ruling-region-ha-p1a;basis=the registry child (carlos __registry-child, the service user a root pass forks): one more write arm, SetHA, calling the local Registry.SetHA with the request's Host (+registry:Host); no read operation added; only the provision pass sends it;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 8: two new remote methods, UpsertUnlessRootfs (carlos add's guarded write) and ResidentInstances (the residency sweep's list), each calling the same-named Registry method;rev3=census-ruling-regional-domains-447;basis=#447 Task 4: two more methods on the existing remote registry transport, ListRegional and ReplaceRegionalSet (request field RDs, response field Regional), each calling the local method of the same name, which validates its own input; no new kind of read;rev3=census-ruling-fleet-secrets-key;basis=one new case, SetFleetSecretsKey, reading the request's Name, Pub, KeyFP, By and At fields and calling SetFleetSecretsKey;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 1-2: three new cases (SetFleetBoxIf reads the request's Fleet and answers Changed; PutForward reads TValue, a whole Route; DeleteForward reads Host and answers Changed); SetFleetBox gone (+registry:Changed x2, +registry:Fleet, +registry:Host, +registry:TValue, +whole:Route). Each case calls the local writer with its own guards.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Tasks 2 and 6b): three more remote methods dispatched to their local forms, SetFleetBoxDraining (q.Fleet, q.Label, q.At, answering Number64), MarkFleetBoxLabelled (q.Fleet, q.Label, q.At) and SetFleetAssignment (q.Host, q.Assigned, q.Moved); remoteRequest gains Assigned and Moved. The registry child, not root.;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Add SetServingMode dispatch using the existing remote request Host, Ver and On fields; the same local narrow writer handles it. No new transport or root path. Task 4 R24: dispatch SeedStateless with the existing Observed Route and On carriers to its symmetric guarded local method. No new transport; the existing read-only service gate still refuses writes.;rev3=census-ruling-stateless-replicas-2;basis=Dispatches typed seed/update/conditional-retire operations; same registry RPC transport, validation delegated to local methods. registry:A@7954,registry:Account@4416,registry:Accounts@3078,registry:Addr@4993,registry:Addrs@5001,registry:Alias@8002,registry:Alias@8066,registry:Alias@8154,registry:Aliases@7876,registry:Alive@9829,registry:Args@7578,registry:AssetGen@5143,registry:AssetsOff@5130,registry:Assigned@5621,registry:Assignment@6848,registry:Assignment@6946,registry:At@2232,registry:At@2621,registry:At@2706,registry:At@6515,registry:At@8085,registry:At@8163,registry:At@9577,registry:Attempts@9599,registry:B@2281,registry:Backing@4812,registry:BuildState@5380,registry:By@2226,registry:Changed@1996,registry:Changed@3501,registry:Changed@3588,registry:Changed@3677,registry:Changed@3748,registry:Changed@3852,registry:Changed@3939,registry:Changed@4032,registry:Changed@4114,registry:Changed@5968,registry:Changed@6105,registry:Changed@6701,registry:Changed@9509,registry:Channel@4476,registry:Channel@5811,registry:Channel@6360,registry:CheckedAt@6441,registry:Class@4931,registry:DoneBefore@9838,registry:Due@7279,registry:Due@7343,registry:Due@9621,registry:EgressAllow@5283,registry:Env@5879,registry:Env@6271,registry:Env@6371,registry:ExcludeHosts@9304,registry:ExcludeHosts@9399,registry:ExpectGood@6640,registry:ExpectOp@3556,registry:ExpectOp@3806,registry:ExpectPair@3986,registry:Expected@1250,registry:Expected@289,registry:Expected@762,registry:Expected@939,registry:F@1968,registry:F@2029,registry:Fleet@2054,registry:Fleet@2339,registry:Fleet@2421,registry:Fleet@2502,registry:Fleet@2603,registry:Fleet@2688,registry:Fleet@2777,registry:Fleet@6011,registry:FleetBoxes@2738,registry:Fleets@2112,registry:From@4587,registry:From@4648,registry:FromDB@4723,registry:FromOp@3644,registry:FromSock@4733,registry:Hash@5685,registry:Health@5010,registry:Host@1024,registry:Host@1135,registry:Host@272,registry:Host@3262,registry:Host@3303,registry:Host@3456,registry:Host@3532,registry:Host@3618,registry:Host@3710,registry:Host@3782,registry:Host@3888,registry:Host@3978,registry:Host@4066,registry:Host@4158,registry:Host@4408,registry:Host@4468,registry:Host@4526,registry:Host@4579,registry:Host@4640,registry:Host@4715,registry:Host@4804,registry:Host@4858,registry:Host@4923,registry:Host@4985,registry:Host@5063,registry:Host@5122,registry:Host@5210,registry:Host@5275,registry:Host@5372,registry:Host@5437,registry:Host@5498,registry:Host@5548,registry:Host@5613,registry:Host@5677,registry:Host@5738,registry:Host@5871,registry:Host@5925,registry:Host@6003,registry:Host@6140,registry:Host@6193,registry:Host@6423,registry:Host@6507,registry:Host@6564,registry:Host@6632,registry:Host@6923,registry:Host@7080,registry:Host@7156,registry:Host@7216,registry:Host@7271,registry:Host@7335,registry:Host@7519,registry:Host@7570,registry:Host@7637,registry:Host@7712,registry:Host@7775,registry:Host@8372,registry:Host@8498,registry:Host@8652,registry:Host@8940,registry:Host@9004,registry:Host@9063,registry:Host@9146,registry:Host@9229,registry:Host@9460,registry:Host@9545,registry:Host@9677,registry:Host@9758,registry:Host@9921,registry:Hosts@187,registry:Hosts@3141,registry:Hosts@5802,registry:Hosts@6262,registry:Hosts@6351,registry:Id@1244,registry:Id@1555,registry:Id@1654,registry:Id@1734,registry:Id@1885,registry:IdValue@2897,registry:Idle@7645,registry:Journal@1262,registry:Journal@1561,registry:Journal@1740,registry:Journal@442,registry:Keep@9937,registry:KeyFP@2217,registry:Kind@9766,registry:Kind@9929,registry:Label@2348,registry:Label@2430,registry:Label@2511,registry:Label@2612,registry:Label@2697,registry:Label@6020,registry:Limit@9295,registry:Limit@9390,registry:MaxRun@7653,registry:Method@151,registry:Moved@5633,registry:Ms@9593,registry:Name@1032,registry:Name@1143,registry:Name@2082,registry:Name@2202,registry:Name@2916,registry:Name@9012,registry:Name@9071,registry:Name@9154,registry:Name@9468,registry:Name@9553,registry:Name@9685,registry:Next@301,registry:NextAt@9611,registry:NextGood@6654,registry:NextValue@1814,registry:NextValue@1912,registry:Now@1167,registry:Now@7846,registry:Now@9288,registry:Now@9383,registry:Now@9476,registry:Number64@2561,registry:Number64@3004,registry:Number@9726,registry:Number@9797,registry:Number@9882,registry:Observed@365,registry:Observed@6746,registry:Observed@6821,registry:Observed@7013,registry:ObservedValue@643,registry:Old@1807,registry:Old@1905,registry:On@6960,registry:On@7025,registry:On@7095,registry:On@7224,registry:On@7720,registry:On@7783,registry:Op@3474,registry:Op@3550,registry:Op@3718,registry:Op@3800,registry:Op@3896,registry:Op@4074,registry:Op@4166,registry:Owner@280,registry:Owner@377,registry:Owner@660,registry:P@8606,registry:Pair@3818,registry:Pair@3902,registry:Pair@4000,registry:Path@8837,registry:Paths@8534,registry:PolicyExpiresAt@5306,registry:Prefix@8660,registry:Prev@6579,registry:Pub@2210,registry:RDs@8506,registry:RateLimit@5746,registry:Regional@8404,registry:Registration@1040,registry:Registration@1151,registry:Registration@9162,registry:Registration@9561,registry:Replica@5506,registry:ReplicaLife@6833,registry:ReplicaLife@6931,registry:Replicas@5445,registry:Retirement@1891,registry:Route@3239,registry:Routes@3197,registry:Routes@4192,registry:Routes@7377,registry:Routes@7444,registry:Routes@7813,registry:Rows@8948,registry:Seed@7527,registry:Size@5298,registry:Sqid@2908,registry:Sqid@2971,registry:Sqid@3050,registry:Status@1056,registry:Status@2520,registry:Status@3464,registry:Status@3540,registry:Status@3626,registry:Status@3790,registry:Status@4534,registry:Status@6431,registry:Status@8075,registry:Status@9583,registry:Status@9693,registry:Steering@5071,registry:StringMap@2814,registry:T@757,registry:T@851,registry:T@8888,registry:T@934,registry:TValue@3344,registry:TValue@3411,registry:TValue@6070,registry:Tags@2439,registry:Target@6201,registry:Targets@453,registry:Text@1460,registry:Text@1607,registry:Text@3018,registry:Text@8693,registry:Text@8756,registry:Timer@709,registry:Timer@891,registry:Timer@8976,registry:Timers@9199,registry:Timers@9258,registry:Timers@9347,registry:Times@9971,registry:To@4595,registry:To@4656,registry:ToDB@4745,registry:ToOp@3636,registry:ToSock@4753,registry:TokenHash@2357,registry:Tunnel@5933,registry:Unit@4866,registry:UpdateSettings@5218,registry:Ver@6572,registry:Ver@7088,registry:Ver@7164,registry:W@8306,registry:Wildcards@8200,whole:Account@3082,whole:ClaimOwnership@282,whole:ClaimOwnership@379,whole:ClaimOwnership@662,whole:ClaimRow@455,whole:ClaimRowArchive@561,whole:ClaimRowArchive@571,whole:ColdRows@1809,whole:ColdRows@1816,whole:ColdRows@1907,whole:ColdRows@1914,whole:Fleet@1970,whole:Fleet@2031,whole:Fleet@2058,whole:Fleet@2116,whole:FleetBox@2283,whole:FleetBox@2742,whole:GoodBuild@6642,whole:GoodBuild@6656,whole:Pair@3820,whole:Pair@3904,whole:Pair@3988,whole:Pair@4002,whole:RegionalDomain@8408,whole:RegionalDomain@8508,whole:Route@3201,whole:Route@3243,whole:Route@3346,whole:Route@3413,whole:Route@367,whole:Route@4196,whole:Route@4351,whole:Route@4357,whole:Route@6072,whole:Route@6748,whole:Route@6823,whole:Route@7015,whole:Route@7381,whole:Route@7448,whole:Route@7817,whole:RouteAlias@7880,whole:RouteAlias@7956,whole:RoutePath@8538,whole:RoutePath@8608,whole:Timer@645,whole:Timer@713,whole:Timer@759,whole:Timer@853,whole:Timer@8890,whole:Timer@895,whole:Timer@8950,whole:Timer@8980,whole:Timer@9203,whole:Timer@9262,whole:Timer@9351,whole:Timer@936,whole:WildcardDomain@8204,whole:WildcardDomain@8308 4dfa9bf66861b8cfeb4897c1a2c46559165f39a481c4f99817071fef4ce64759
+internal/host/runs.go runsWorker.pickup legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), its runs worker: a picked run's detached execution runs under provision.WithLifetimes of the worker's judge, so execute's record writes refuse a stale record; read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 16 (ruling R7): on a fleet box a run already let go is skipped before any read; the pickup CAS moves behind the run's sink (sinkFor: the bucket's, as before, or on a fleet box the run door relay once a grant verifies); one more whole-Route site, the row this box already owns passed to sinkFor; nothing new opened, run or followed;rev3=census-ruling-stateless-replicas-2;basis=Passes the already-owned Route to the activator current-record recheck before pickup, only for set rows; legacy reads unchanged. whole:Route@1195,whole:Route@1807,whole:Route@951 5f7199c119298d7cb374ec5d77b1478e91dcb7ca3f82106739662cd0b7e635db
+internal/provision/reconcile.go RouteFor authority C,E3 rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos); also root, in the claim root's landing registration (ClaimRootHTTP.rootLandingRoute) and the relocation install (relocationRecord): census-ruling-seeded-instances's body with two more fields from the record: the row's lifetime pair (rec.Incarnation, rec.MoveSeq), so a row minted outside a move takes the record's lifetime and its last move's sequence (0, 0 for a fieldless record with no move history); every caller gets it, the root ones included: the root callers (ClaimRootHTTP.rootLandingRoute, relocationRecord) now mint (0, move_seq) on a claims-on record, a non-zero sequence once that record has had an offline move (move_seq advances on claims-on offline moves too), which moves Fingerprint and SnapshotFingerprint once for that row; main's C,E3 authority retained; self-serve moves 1 Task 7 (fix round 1: root callers named);rev3=census-ruling-region-ha-p1a;basis=the agent's reconcile passes, and also root's callers (rootupdates.go, rootinventory_install.go and relocationinstall.go on HEAD): one more field copied from the record, HA: rec.HA, so a row minted from a record stamped HA carries the sticky born-HA mark; the record is the console-written instance record each caller already read; root's own code reads nothing of Route.HA, and Fingerprint does not include it (SnapshotFingerprint does, for a set mark); the same nine sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 2: the row is minted with the record's Runtime (the console-written instance record, guarded by WriteRecord's runtimeFixed); a rootfs row always gets the nested socket and db path under dataDir and no seed or seed source; the paths are computed from the host, not read from the record;rev3=census-ruling-fresh-box-446;basis=#446: a born-HA record mints the nested paths whatever nested says, as a rootfs row already does; same reads;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 2, rule 6): the route also carries Assigned = rec.FleetBoxAt and Moved = rec.FleetBoxMoved, copied from the record it is handed. Read sites unchanged (13). In the agent; in root's claim landing registration (ClaimRootHTTP.rootLandingRoute, shelved claims code) the canonical route gains these two copied fields, which no root check compares (the comparison at rootinventory.go and ValidateAgentInventory read neither). No new input to root.;rev3=census-ruling-stateless-replicas-2;basis=Projects count, canonical boxes, revision, CreatedAt-derived lifetime and stateless hint from the supplied record. No store read; hint does not authorize a database bypass. registry:Addr@2736,registry:Addrs@2745,registry:DBPath@1709,registry:DBPath@2232,registry:DBPath@2654,registry:Health@2755,registry:Hibernate@2176,registry:Seed@2700,registry:SeedSource@2709,registry:Socket@1671,registry:Socket@2194,registry:Socket@2617,whole:Route@1635,whole:Route@2793 996c873399acd5b3ced960e82b699abd8400f89b09877d0522c310710132a6e9
@coverage . 9857cb346182ee701b2dff653cee0c4b7ed36b038975d3eeaea75cc85da938b7
+@coverage internal/activator 5d59ed7352852631d4b965796ba75145869de6fea347343d8dab6f2a5bd65883
@coverage internal/appconfig 32d5f27628b319917ed88ac39e0b22e25292f8f16ba5ef4e69a57ea35471bf77
-@coverage internal/provision b6684c18c0775437dc7d395706bd837ec31b32d087e66ccf805d0e169f8138f9
+@coverage internal/host 68d15300ba45ee8824cb450e15606035c450f815b7bc0e17f5f8b2f57f75a96d
+@coverage internal/provision f40daaeaeb3932edeb972770df44b3e8e097651c4d35e05698ad81e061a217bd
+@coverage internal/registry 51663cade94530e191d95470e3ca50544717696e1d7a946a838710acd6cb0888
@coverage internal/release 6c7784eb02f9c2b68045266dabf5a79fb656bcb11a06427787d74ca8f3f96dd6
@coverage internal/replicas d449179f2fe033691dd65005fd3bc80dc6f96f40d7e6b0dde1e6137b14c9b17e
+@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.go b/internal/registry/forward.go
index a0d4d9184..79272b944 100644
--- a/internal/registry/forward.go
+++ b/internal/registry/forward.go
@@ -42,7 +42,7 @@ UPDATE routes SET fleet_box = ?
WHERE host = ?
AND region = 'fleet/' || ?
AND kind <> 'sidecar'
- AND fleet_label = ''
+ AND fleet_label = '' AND fleet_boxes = '' AND copies = 0 AND replica_revision = 0 AND replica_incarnation = ''
AND EXISTS (SELECT 1 FROM fleet_boxes
WHERE fleet = ? AND label = ? AND status = 'active')`,
label, host, fleet, fleet, label)
@@ -104,7 +104,8 @@ var forwardShape = map[string]string{
"RateLimit": "declared", "Status": "declared", "Provisioned": "declared",
"CreatedAt": "declared", "FleetLabel": "declared", "Stateless": "declared",
- "FleetBox": "binding",
+ "FleetBox": "binding",
+ "FleetBoxes": "declared", "Copies": "declared", "ReplicaRevision": "declared", "ReplicaIncarnation": "declared",
"DNSStatus": "observational", "DNSCheckedAt": "observational", "CertExpiresAt": "observational",
@@ -199,7 +200,7 @@ var ForwardForbidden = []ForwardColumn{
// forward row admits only an inert one; one that is not inert is served by
// nobody and published by nobody.
func (t Route) InertForward() bool {
- return t.IsForward() &&
+ return t.IsForward() && t.ValidReplicaProjection() &&
t.Socket == "" &&
t.Addr == "" &&
t.Addrs == "" &&
@@ -298,7 +299,11 @@ var forwardKept = []forwardKeptColumn{
{"CreatedAt", "created_at", "routes.created_at"},
{"FleetLabel", "fleet_label", "excluded.fleet_label"},
{"Stateless", "stateless", "excluded.stateless"},
- {"FleetBox", "fleet_box", "CASE WHEN excluded.fleet_label <> '' THEN excluded.fleet_label" +
+ {"FleetBoxes", "fleet_boxes", "excluded.fleet_boxes"},
+ {"Copies", "copies", "excluded.copies"},
+ {"ReplicaRevision", "replica_revision", "excluded.replica_revision"},
+ {"ReplicaIncarnation", "replica_incarnation", "excluded.replica_incarnation"},
+ {"FleetBox", "fleet_box", "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"},
{"DNSStatus", "dns_status", "routes.dns_status"},
{"DNSCheckedAt", "dns_checked_at", "routes.dns_checked_at"},
@@ -357,6 +362,9 @@ func (r *Registry) PutForward(rt Route) error {
case !placed:
return fmt.Errorf("%w: PutForward(%q): region %q is not a fleet placement", ErrNotForward, rt.Host, rt.Region)
}
+ if !rt.ValidReplicaProjection() {
+ return ErrNotForward
+ }
if r.remote != nil {
_, err := r.remote.call(nil, remoteRequest{Method: "PutForward", TValue: rt}, nil)
return err
@@ -377,6 +385,10 @@ func (r *Registry) PutForward(rt Route) error {
FleetLabel: rt.FleetLabel,
FleetBox: rt.FleetLabel,
Stateless: rt.Stateless,
+ FleetBoxes: rt.FleetBoxes, Copies: rt.Copies, ReplicaRevision: rt.ReplicaRevision, ReplicaIncarnation: rt.ReplicaIncarnation,
+ }
+ if w.FleetBoxes != "" {
+ w.FleetBox, w.FleetLabel = "", ""
}
return r.inImmediateTx(func(tx txer) error {
var kind string
diff --git a/internal/registry/registry.go b/internal/registry/registry.go
index 3228385d3..a0618967d 100644
--- a/internal/registry/registry.go
+++ b/internal/registry/registry.go
@@ -124,10 +124,14 @@ type Route struct {
LastError string
// Stateless projects the serving generation mode; it never authorizes a launch.
- Stateless bool `json:"stateless,omitempty"`
- DBPath string
- Version string
- PrevVersion string
+ Stateless bool `json:"stateless,omitempty"`
+ FleetBoxes string `json:"fleet_boxes,omitempty"`
+ Copies int `json:"copies,omitempty"`
+ ReplicaRevision uint64 `json:"replica_revision,omitempty"`
+ ReplicaIncarnation string `json:"replica_incarnation,omitempty"`
+ DBPath string
+ Version string
+ PrevVersion string
// GoodVersion, GoodDigest and GoodDemand are the good build (zero-downtime
// spec §8.5): the last build that served for this instance after passing
// its health check, the sha256 of its staged executable, and the
@@ -691,6 +695,10 @@ var routeAddedColumns = []addedColumn{
{Name: "channel", Type: "TEXT", Default: "''"},
{Name: "hibernate", Type: "INTEGER", Default: "0"},
{Name: "stateless", Type: "INTEGER", Default: "0"},
+ {Name: "fleet_boxes", Type: "TEXT", Default: "''"},
+ {Name: "copies", Type: "INTEGER", Default: "0"},
+ {Name: "replica_revision", Type: "INTEGER", Default: "0"},
+ {Name: "replica_incarnation", Type: "TEXT", Default: "''"},
{Name: "canary", Type: "INTEGER", Default: "0"},
{Name: "replication", Type: "TEXT", Default: "''"},
{Name: "next_due", Type: "INTEGER", Default: "0"},
@@ -1087,10 +1095,10 @@ provisioned, seed, unit, fleet_box, addrs, health, steering, gate, created_at,
args, idle_seconds, max_run_seconds, replicas, replica, claim_incarnation, claim_stamp, claim_owner, claim_row_id, hold_op,
good_version, good_digest, good_demand, serving_version, update_settings, build_state,
seed_source, import_gate, runtime, rate_limit, assets_off, asset_gen, incarnation, serving_seq,
-egress_allow, size, policy_expires_at, ha, fleet_assigned, fleet_moved, fleet_label, stateless`
+egress_allow, size, policy_expires_at, ha, fleet_assigned, fleet_moved, fleet_label, stateless, fleet_boxes, copies, replica_revision, replica_incarnation`
// routeColCount is the number of names in routeCols.
-const routeColCount = 69
+const routeColCount = 73
// placeholders is n comma-joined bind parameters.
func placeholders(n int) string {
@@ -1109,7 +1117,7 @@ func scanRoute(scan func(...any) error) (Route, error) {
&t.Args, &t.IdleSeconds, &t.MaxRunSeconds, &t.Replicas, &rep, &t.ClaimIncarnation, &t.ClaimStamp, &t.ClaimOwner, &t.ClaimRowID, &t.HoldOp,
&t.GoodVersion, &t.GoodDigest, &t.GoodDemand, &t.ServingVersion, &t.UpdateSettings, &t.BuildState,
&t.SeedSource, &t.ImportGate, &t.Runtime, &t.RateLimit, &assetsOff, &t.AssetGen, &t.Incarnation, &t.ServingSeq,
- &t.EgressAllow, &t.Size, &t.PolicyExpiresAt, &ha, &t.Assigned, &moved, &t.FleetLabel, &stateless)
+ &t.EgressAllow, &t.Size, &t.PolicyExpiresAt, &ha, &t.Assigned, &moved, &t.FleetLabel, &stateless, &t.FleetBoxes, &t.Copies, &t.ReplicaRevision, &t.ReplicaIncarnation)
t.Stateless = stateless != 0
t.HA = ha != 0
t.Moved = moved != 0
@@ -1562,6 +1570,8 @@ ON CONFLICT(host) DO UPDATE SET
channel=excluded.channel,
hibernate=CASE WHEN routes.runtime != '' AND NOT (`+tenantChangedSQL+`) THEN routes.hibernate ELSE excluded.hibernate END,
stateless=excluded.stateless,
+ fleet_boxes=excluded.fleet_boxes, copies=excluded.copies,
+ replica_revision=excluded.replica_revision, replica_incarnation=excluded.replica_incarnation,
canary=excluded.canary,
next_due=excluded.next_due,
backing=excluded.backing, status_named=excluded.status_named,
@@ -1679,7 +1689,7 @@ func routeArgs(t Route) []any {
t.Replicas, b2iDB(t.Replica), t.ClaimIncarnation, t.ClaimStamp, t.ClaimOwner, t.ClaimRowID, t.HoldOp,
t.GoodVersion, t.GoodDigest, t.GoodDemand, t.ServingVersion, t.UpdateSettings, t.BuildState,
t.SeedSource, t.ImportGate, t.Runtime, t.RateLimit, b2iDB(t.AssetsOff), t.AssetGen, t.Incarnation, t.ServingSeq,
- t.EgressAllow, t.Size, t.PolicyExpiresAt, b2iDB(t.HA), t.Assigned, b2iDB(t.Moved), t.FleetLabel, b2iDB(t.Stateless),
+ t.EgressAllow, t.Size, t.PolicyExpiresAt, b2iDB(t.HA), t.Assigned, b2iDB(t.Moved), t.FleetLabel, b2iDB(t.Stateless), t.FleetBoxes, t.Copies, t.ReplicaRevision, t.ReplicaIncarnation,
}
}
@@ -3944,7 +3954,7 @@ SELECT rowid, status, socket, addr, version, hibernate, channel, backing, tunnel
db_path, region, fleet_box, addrs, health, gate, hold_op, import_gate, rate_limit,
claim_incarnation, claim_stamp, claim_owner, claim_row_id,
assets_off, asset_gen, incarnation, serving_seq,
- host, kind, account, app, platform, fleet_label, stateless,
+ host, kind, account, app, platform, fleet_label, stateless, fleet_boxes, copies, replica_revision, replica_incarnation,
` + fingerprintForwardInert + `
FROM routes ORDER BY rowid`)
if err != nil {
@@ -3955,6 +3965,9 @@ FROM routes ORDER BY rowid`)
n := 0
for rows.Next() {
var rowid, hibernate, assetsOff, platform, forwardInert, stateless int64
+ var fleetBoxes, replicaIncarnation string
+ var copies int
+ var replicaRevision uint64
var pair Pair
var claim ClaimOwnership
var assetGen string
@@ -3964,7 +3977,7 @@ FROM routes ORDER BY rowid`)
&channel, &backing, &tunnel, &dbPath, &region, &fleetBox, &addrs, &health, &gate, &holdOp, &importGate, &rateLimit,
&claim.ClaimIncarnation, &claim.ClaimStamp, &claim.ClaimOwner, &claim.ClaimRowID,
&assetsOff, &assetGen, &pair.Incarnation, &pair.ServingSeq,
- &host, &kind, &account, &app, &platform, &fleetLabel, &stateless, &forwardInert); err != nil {
+ &host, &kind, &account, &app, &platform, &fleetLabel, &stateless, &fleetBoxes, &copies, &replicaRevision, &replicaIncarnation, &forwardInert); err != nil {
return "", err
}
fmt.Fprintf(h, "%d\x1f%s\x1f%s\x1f%s\x1f%s\x1f%d\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s\x1f%s",
@@ -3978,6 +3991,9 @@ FROM routes ORDER BY rowid`)
fmt.Fprintf(h, "\x1fhost=%q\x1fkind=%q\x1faccount=%q\x1fapp=%q", host, kind, account, app)
// The platform mark decides the platform-alias fold (PlatformAliasFold),
// and a refused source refuses its alias with it; folded only when set.
+ if fleetBoxes != "" || copies != 0 || replicaRevision != 0 || replicaIncarnation != "" {
+ fmt.Fprintf(h, "\x1freplicas=%s/%d/%d/%s", fleetBoxes, copies, replicaRevision, replicaIncarnation)
+ }
if stateless != 0 {
fmt.Fprint(h, "\x1fstateless=1")
}
diff --git a/internal/registry/remote.go b/internal/registry/remote.go
index 481c1e2c8..f283835b1 100644
--- a/internal/registry/remote.go
+++ b/internal/registry/remote.go
@@ -14,7 +14,7 @@ import (
var errRemoteMethod = errors.New("registry: unsupported remote operation")
-var remoteErrors = []error{os.ErrNotExist, os.ErrPermission, sql.ErrNoRows, ErrClaimOwnership, ErrTimerChanged, ErrTimerKind, ErrPathsChanged, ErrFleetBoxActive, context.Canceled, context.DeadlineExceeded, ErrGoodBuildChanged, ErrRuntimeFixed, ErrRootfsRow, ErrRuntimePlacement, ErrFleetKeyInUse, ErrForwardRow, ErrHostHeld, ErrNotForward}
+var remoteErrors = []error{os.ErrNotExist, os.ErrPermission, sql.ErrNoRows, ErrClaimOwnership, ErrTimerChanged, ErrTimerKind, ErrPathsChanged, ErrFleetBoxActive, context.Canceled, context.DeadlineExceeded, ErrGoodBuildChanged, ErrRuntimeFixed, ErrRootfsRow, ErrRuntimePlacement, ErrFleetKeyInUse, ErrForwardRow, ErrHostHeld, ErrNotForward, ErrReplicaAssignment}
func responseError(out remoteResponse) error {
if !out.Failed {
diff --git a/internal/registry/remote_dispatch.go b/internal/registry/remote_dispatch.go
index 101613252..c00bbbd80 100644
--- a/internal/registry/remote_dispatch.go
+++ b/internal/registry/remote_dispatch.go
@@ -3,9 +3,12 @@ package registry
import (
"context"
"encoding/json"
+ "github.com/carlosframework/platform/internal/replicas"
)
type remoteRequest struct {
+ Assignment replicas.Assignment
+ ReplicaLife string
Method string
Deadline int64
CallbackError string
@@ -320,6 +323,12 @@ func (r *Registry) dispatchRemote(ctx context.Context, q remoteRequest, callback
err = r.SetVersions(q.Host, q.Ver, q.Prev)
case "SetGoodBuild":
err = r.SetGoodBuild(q.Host, q.ExpectGood, q.NextGood)
+ case "DeleteReplicaAssignment":
+ out.Changed, err = r.DeleteReplicaAssignment(q.Observed)
+ case "SeedReplicaAssignment":
+ err = r.SeedReplicaAssignment(q.Observed, q.ReplicaLife, q.Assignment)
+ case "SetReplicaAssignment":
+ err = r.SetReplicaAssignment(q.Host, q.ReplicaLife, q.Assignment, q.On)
case "SeedStateless":
err = r.SeedStateless(q.Observed, q.On)
case "SetServingMode":
diff --git a/internal/registry/replicas.go b/internal/registry/replicas.go
new file mode 100644
index 000000000..5f25adfaf
--- /dev/null
+++ b/internal/registry/replicas.go
@@ -0,0 +1,124 @@
+package registry
+
+import (
+ "encoding/json"
+ "errors"
+ "math"
+ "slices"
+
+ "github.com/carlosframework/platform/internal/replicas"
+)
+
+var ErrReplicaAssignment = errors.New("registry: invalid or stale replica assignment")
+
+func ReplicaBoxes(a replicas.Assignment) (string, error) {
+ if err := replicas.ValidateAssignment(a); err != nil {
+ return "", err
+ }
+ boxes := a.Boxes
+ if boxes == nil {
+ boxes = []string{}
+ }
+ raw, err := json.Marshal(boxes)
+ return string(raw), err
+}
+
+func (t Route) ValidReplicaProjection() bool {
+ if t.FleetBoxes == "" {
+ return t.Copies == 0 && t.ReplicaRevision == 0 && t.ReplicaIncarnation == ""
+ }
+ var boxes []string
+ if json.Unmarshal([]byte(t.FleetBoxes), &boxes) != nil || boxes == nil {
+ return false
+ }
+ canonical, err := ReplicaBoxes(replicas.Assignment{Desired: t.Copies, Boxes: boxes})
+ _, fleet := FleetPlacement(t.Region)
+ return err == nil && canonical == t.FleetBoxes && t.ReplicaIncarnation != "" && t.ReplicaRevision > 0 && t.ReplicaRevision <= math.MaxInt64 && t.Stateless && fleet
+}
+
+func (t Route) ReplicaContains(box string) bool {
+ if !t.ValidReplicaProjection() || t.FleetBoxes == "" {
+ return false
+ }
+ var boxes []string
+ if json.Unmarshal([]byte(t.FleetBoxes), &boxes) != nil {
+ return false
+ }
+ return slices.Contains(boxes, box)
+}
+
+func (r *Registry) SetReplicaAssignment(host, incarnation string, assignment replicas.Assignment, stateless bool) error {
+ return r.setReplicaAssignment(host, incarnation, assignment, stateless, nil)
+}
+
+// SeedReplicaAssignment converts only the exact legacy row the pass observed.
+func (r *Registry) SeedReplicaAssignment(observed Route, incarnation string, assignment replicas.Assignment) error {
+ if observed.ReplicaIncarnation != "" || observed.FleetBoxes != "" || observed.ReplicaRevision != 0 || observed.Copies != 0 {
+ return ErrReplicaAssignment
+ }
+ return r.setReplicaAssignment(observed.Host, incarnation, assignment, true, &observed)
+}
+
+func (r *Registry) setReplicaAssignment(host, incarnation string, assignment replicas.Assignment, stateless bool, observed *Route) error {
+ boxes, err := ReplicaBoxes(assignment)
+ if err != nil || incarnation == "" || !stateless || assignment.Revision == 0 || assignment.Revision > math.MaxInt64 {
+ return ErrReplicaAssignment
+ }
+ if r.remote != nil {
+ q := remoteRequest{Method: "SetReplicaAssignment", Host: host, ReplicaLife: incarnation, Assignment: assignment, On: stateless}
+ if observed != nil {
+ q.Method = "SeedReplicaAssignment"
+ q.Observed = *observed
+ }
+ _, err := r.remote.call(nil, q, nil)
+ return err
+ }
+ return r.inImmediateTx(func(tx txer) error {
+ rt, err := scanRoute(tx.QueryRow(`SELECT `+routeCols+` FROM routes WHERE host=?`, host).Scan)
+ if err != nil {
+ return err
+ }
+ if rt.IsForward() {
+ return ErrForwardRow
+ }
+ if _, ok := FleetPlacement(rt.Region); !ok {
+ return ErrReplicaAssignment
+ }
+ if rt.Kind != "instance" || !rt.Provisioned || rt.Platform || rt.Canary || rt.HA || rt.Hibernate || rt.Unit != "" || rt.Backing != "" || rt.Tunnel != "" || (observed == nil && rt.ReplicaIncarnation != incarnation) || (observed != nil && rt != *observed) || rt.ReplicaRevision > assignment.Revision {
+ return ErrReplicaAssignment
+ }
+ 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)
+ return err
+ })
+}
+
+// DeleteReplicaAssignment retires only the unchanged local projection. It
+// does not acknowledge termination or alter the assignment record.
+func (r *Registry) DeleteReplicaAssignment(observed Route) (bool, error) {
+ if observed.Kind != "instance" || observed.Platform || observed.Canary || !observed.Provisioned || observed.FleetBoxes == "" {
+ return false, ErrReplicaAssignment
+ }
+ if r.remote != nil {
+ out, err := r.remote.call(nil, remoteRequest{Method: "DeleteReplicaAssignment", Observed: observed}, nil)
+ return out.Changed, err
+ }
+ deleted := false
+ err := r.inImmediateTx(func(tx txer) error {
+ rt, err := scanRoute(tx.QueryRow(`SELECT `+routeCols+` FROM routes WHERE host=?`, observed.Host).Scan)
+ if err != nil {
+ return err
+ }
+ if rt != observed {
+ return nil
+ }
+ if _, err = tx.Exec(`DELETE FROM routes WHERE host=?`, observed.Host); err != nil {
+ return err
+ }
+ deleted = true
+ return nil
+ })
+ return deleted, err
+}
diff --git a/internal/registry/replicas_test.go b/internal/registry/replicas_test.go
new file mode 100644
index 000000000..80739c6b5
--- /dev/null
+++ b/internal/registry/replicas_test.go
@@ -0,0 +1,148 @@
+package registry
+
+import (
+ "github.com/carlosframework/platform/internal/replicas"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestReplicaForwardRemainsInert(t *testing.T) {
+ for _, remote := range []bool{false, true} {
+ t.Run(map[bool]string{false: "sql", true: "remote"}[remote], func(t *testing.T) {
+ var r *Registry
+ if remote {
+ r, _ = remoteTestRegistry(t)
+ } else {
+ var err error
+ r, err = Open(filepath.Join(t.TempDir(), "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { r.Close() })
+ }
+ rt := validForward("shop.example.com", "pi")
+ rt.FleetBoxes = `["a","b"]`
+ rt.Copies = 2
+ rt.ReplicaRevision = 1
+ rt.ReplicaIncarnation = "life"
+ rt.Stateless = true
+ rt.Socket = "forbidden"
+ rt.DBPath = "forbidden"
+ if err := r.PutForward(rt); err != nil {
+ t.Fatal(err)
+ }
+ got, err := r.Get(rt.Host)
+ if err != nil || got == nil || !got.InertForward() || got.FleetBoxes != rt.FleetBoxes || got.Copies != 2 || got.ReplicaRevision != 1 || got.ReplicaIncarnation != "life" || !got.Stateless {
+ t.Fatalf("projection: %+v %v", got, err)
+ }
+ for _, col := range ForwardForbidden {
+ corrupt := *got
+ setNonZero(t, &corrupt, col.Field)
+ if corrupt.InertForward() {
+ t.Fatalf("forward admitted %s", col.Field)
+ }
+ }
+ if err := r.SetReplicaAssignment(rt.Host, "life", replicas.Assignment{Desired: 1, Revision: 2, Boxes: []string{"a"}}, true); err == nil {
+ t.Fatal("ordinary writer changed forward")
+ }
+ if err := r.UpsertFleet(Fleet{Name: "pi", Account: "bah"}); err != nil {
+ t.Fatal(err)
+ }
+ if err := r.AddFleetBox(FleetBox{Fleet: "pi", Label: "a", TokenHash: strings.Repeat("a", 64), Status: "active"}); err != nil {
+ t.Fatal(err)
+ }
+ if changed, err := r.SetFleetBoxIf(rt.Host, "pi", "a"); err != nil || changed {
+ t.Fatalf("set collapsed: %v %v", changed, err)
+ }
+ live := Route{Host: "local.example.com", Kind: "instance", Account: "bah", App: "shop", Region: "fleet/pi", Provisioned: true, ReplicaIncarnation: "life"}
+ if err := r.Upsert(live); err != nil {
+ t.Fatal(err)
+ }
+ a := replicas.Assignment{Desired: 2, Revision: 3, Boxes: []string{"a", "b"}}
+ if err := r.SetReplicaAssignment(live.Host, "life", a, true); err != nil {
+ t.Fatal(err)
+ }
+ got, err = r.Get(live.Host)
+ if err != nil || got.FleetBoxes != rt.FleetBoxes || got.ReplicaRevision != 3 {
+ t.Fatalf("set RPC: %+v %v", got, err)
+ }
+ if err := r.SetReplicaAssignment(live.Host, "old", a, true); err == nil {
+ t.Fatal("old lifetime accepted")
+ }
+ a.Revision = 2
+ if err := r.SetReplicaAssignment(live.Host, "life", a, true); err == nil {
+ t.Fatal("revision rollback accepted")
+ }
+ })
+ }
+ t.Run("classification", TestForwardShapeClassesEveryField)
+ t.Run("schema", TestForwardForbiddenMatchesTheTable)
+}
+
+func TestReplicaForwardMigration(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "registry.db")
+ r, err := Open(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ legacy := validForward("shop.example.com", "pi")
+ if err := r.PutForward(legacy); err != nil {
+ t.Fatal(err)
+ }
+ before, _ := r.Get(legacy.Host)
+ r.Close()
+ dropRouteColumns(t, path, "fleet_boxes", "copies", "replica_revision", "replica_incarnation")
+ r, err = Open(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer r.Close()
+ after, err := r.Get(legacy.Host)
+ if err != nil || *after != *before {
+ t.Fatalf("legacy migration: %+v %v", after, err)
+ }
+ for _, boxes := range []string{`["b","a"]`, `["a","a"]`, `null`, `["a", "b"]`} {
+ bad := legacy
+ bad.FleetBoxes = boxes
+ bad.Copies = 2
+ bad.ReplicaIncarnation = "life"
+ bad.ReplicaRevision = 1
+ bad.Stateless = true
+ if err := r.PutForward(bad); err == nil {
+ t.Fatalf("accepted noncanonical set %s", boxes)
+ }
+ }
+}
+
+func TestReplicaForwardConditionalLocalWriters(t *testing.T) {
+ r, _ := remoteTestRegistry(t)
+ rt := Route{Host: "shop.example.com", Kind: "instance", Account: "bah", App: "shop", Region: "fleet/pi", Provisioned: true}
+ if err := r.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ observed, _ := r.Get(rt.Host)
+ a := replicas.Assignment{Revision: 1, Desired: 2, Boxes: []string{"a", "b"}}
+ if err := r.SeedReplicaAssignment(*observed, "life", a); err != nil {
+ t.Fatal(err)
+ }
+ assigned, _ := r.Get(rt.Host)
+ if err := r.SeedReplicaAssignment(*observed, "old", a); err == nil {
+ t.Fatal("stale seed changed current row")
+ }
+ if !assigned.ValidReplicaProjection() {
+ t.Fatalf("invalid seed: %+v", assigned)
+ }
+ newer := *assigned
+ newer.ReplicaIncarnation = "recreated"
+ if err := r.Upsert(newer); err != nil {
+ t.Fatal(err)
+ }
+ if changed, err := r.DeleteReplicaAssignment(*assigned); err != nil || changed {
+ t.Fatalf("old retirement deleted successor: %v %v", changed, err)
+ }
+ current, _ := r.Get(rt.Host)
+ if changed, err := r.DeleteReplicaAssignment(*current); err != nil || !changed {
+ t.Fatalf("own retirement: %v %v", changed, err)
+ }
+}