host: only the pinned box that serves the pool lands an offline move
A box in the target region takes the offline target role only when its pools (CARLOS_POOLS, through provision.ParseBoxPools) admit the record and it is the box the start pinned, or the move pins none. A pool-only box beside the target writes no target report and lands nothing (amadan #413). TestOfflineMoveE2E gains "a pool box beside the target": uk-pool serving only cohort1 ticks beside uk-box. On the old code the move stopped at offline-landed, as on dev. The census overlay re-pins internal/host and internal/provision and claims armOffline's change (no read added).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+138
−8
docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md+19 −0internal/host/movesoffline.go+14 −1internal/host/movesoffline_e2e_test.go+38 −6internal/host/movesoffline_land_test.go+4 −0internal/host/movesoffline_test.go+48 −1internal/host/movespass.go+8 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv+6 −0
diff --git a/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md b/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md| new file mode 100644 |
| index 000000000..72ad6c49b |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md |
| @@ -0,0 +1,19 @@ |
| +# Census approval: offline-move-pool-target-413 |
| + |
| +Ruling `census-ruling-offline-move-pool-target-413`. 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/host/movespass.go` `armOffline` | body | unchanged (1) | sets moveCfg.OfflinePools from CARLOS_POOLS through provision.ParseBoxPools (an env string the agent already reads for reconcile; no file read), so offlineTargetHere keeps a box whose pools do not admit the record out of the offline target role (amadan #413); no read added | |
| + |
| +Envelopes re-pinned: `internal/host`, `internal/provision`. |
| + |
| +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. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/host/movespass.go` `armOffline`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route (J1, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): census-ruling-moves-offline's body, which also arms moveCfg.ReleaseHoldSeq (releaseHeldSeq over the registry, touching the stage-requested marker after a release that landed); closes over the registry and reads nothing itself; self-serve moves 1 Task 7 |
| + |
| +Seal: `3f43afa4b0c18ad678a952b48b511e74e849992cd629b9aa1442bbe0055d5631` → `022a33f457a0684b499f118b8d475bd4aa3c0f04395727c3e8c090863daaff89`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/host/movesoffline.go b/internal/host/movesoffline.go| index 0859e78b7..7e5cff9f1 100644 |
| --- a/internal/host/movesoffline.go |
| +++ b/internal/host/movesoffline.go |
| @@ -421,7 +421,7 @@ func (w *movesWorker) offlineRound(ctx context.Context, s release.Store, rec pro |
| } |
| here := cfg.parkRegion() |
| source := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.From, here) |
| - target := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.To, here) |
| + target := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.To, here) && cfg.offlineTargetHere(rec) |
| sealer := cfg.Box != "" && cfg.Box == m.Sealer |
| if !cfg.OfflineCapable { |
| if source || target || sealer { |
| @@ -450,6 +450,19 @@ func (w *movesWorker) offlineRound(ctx context.Context, s release.Store, rec pro |
| return errors.Join(errs...) |
| } |
| +// offlineTargetHere says whether this box, in the region the move goes to, |
| +// is the move's target (amadan #413): its pools admit the record, and it is |
| +// the box the start pinned (move.target_box), or the move pins none (one |
| +// started before the pin). Any other box in that region never gets the row |
| +// from reconcile, or is not the box the doors wait on, so it writes no |
| +// target report and lands nothing. |
| +func (c moveCfg) offlineTargetHere(rec provision.Record) bool { |
| + if !c.OfflinePools.Serves(rec.Pool) { |
| + return false |
| + } |
| + return rec.Move.TargetBox == "" || rec.Move.TargetBox == c.Box |
| +} |
| + |
| // offlineReassertEvery is how often a box that takes part in an offline move |
| // rewrites the reports a door judges by age (harness Run 9, finding 7). The |
| // doors believe a report for two minutes (offlineReportFresh, internal/ |
diff --git a/internal/host/movesoffline_e2e_test.go b/internal/host/movesoffline_e2e_test.go| index a663ec804..7fa9b0dae 100644 |
| --- a/internal/host/movesoffline_e2e_test.go |
| +++ b/internal/host/movesoffline_e2e_test.go |
| @@ -210,6 +210,18 @@ type e2eWorld struct { |
| srcFiles, srcEnv, cfg string |
| srcTimers map[string]registry.Timer |
| rows int |
| + // pool is uk-pool when the world has one (landOpts.poolBox): a box in |
| + // uk that serves only cohort1, ticked beside the others. |
| + pool *offBox |
| +} |
| + |
| +// boxes are the world's boxes in the order they tick. |
| +func (w *e2eWorld) boxes() []*offBox { |
| + out := []*offBox{w.ie, w.uk} |
| + if w.pool != nil { |
| + out = append(out, w.pool) |
| + } |
| + return out |
| } |
| func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld { |
| @@ -338,6 +350,10 @@ func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld { |
| lw.ukEB = &activator.ExecBackend{ServedPools: testSharedPoolEvidence, DataDir: lw.uk.dd, OptDir: lw.uk.opt, Region: "uk"} |
| lw.arm(lw.uk) |
| w := &e2eWorld{landWorld: lw, t: t, rs: rs, base: ts.URL + "/api/cli/apps/" + wd.acct + "/app/instances/" + offHost + "/move/offline", token: token} |
| + if opts.poolBox { |
| + w.pool = sw.box("uk-pool", "uk", map[string]string{"CARLOS_HIBERNATE_BUCKET": sealUK, "CARLOS_SECRETS_KEY": keyB64, |
| + "CARLOS_HIBERNATE_REGION": sealUKRegion, "CARLOS_RELEASE_PUBKEY": pubB64, "CARLOS_POOLS": "cohort1"}) |
| + } |
| // The source box's production build-state carry, and each box's launch |
| // composer under its own agent environment. |
| @@ -379,7 +395,7 @@ func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld { |
| // Both boxes published as their loops publish them, and their status |
| // snapshots. |
| w.tickAll() |
| - for _, b := range []*offBox{ie, lw.uk} { |
| + for _, b := range w.boxes() { |
| if err := status.WriteBox(ctx, rs, status.Box{Label: b.name, GeneratedAt: time.Now(), Metrics: &status.BoxMetrics{}}); err != nil { |
| t.Fatal(err) |
| } |
| @@ -443,8 +459,9 @@ func (w *e2eWorld) setBoxClock(at time.Time) { |
| func (w *e2eWorld) tickAll() { |
| w.t.Helper() |
| - w.tick(w.ie) |
| - w.tick(w.uk) |
| + for _, b := range w.boxes() { |
| + w.tick(b) |
| + } |
| } |
| // door posts to one of the doors (verb "" is start). |
| @@ -1104,6 +1121,10 @@ func TestOfflineMoveE2E(t *testing.T) { |
| // minutes of belief in a report. |
| t.Run("doors back to back", func(t *testing.T) { offlineMoveDoorsApart(t, 0) }) |
| t.Run("doors three minutes apart", func(t *testing.T) { offlineMoveDoorsApart(t, 3*time.Minute) }) |
| + // amadan #413, seen on dev 2026-10-26: uk also holds a box that serves |
| + // only a named pool. Reconcile never gives it the row, so it must not |
| + // report as the target, and no step may wait on it. |
| + t.Run("a pool box beside the target", func(t *testing.T) { offlineMoveDone(t, landOpts{poolBox: true}) }) |
| } |
| // e2eLoops are what acts on the two boxes between door calls in production, |
| @@ -1123,7 +1144,7 @@ type e2eLoops struct { |
| func (w *e2eWorld) loops() *e2eLoops { |
| l := &e2eLoops{w: w, fast: map[*offBox]*fastDeps{}, tickAt: time.Now()} |
| - for _, b := range []*offBox{w.ie, w.uk} { |
| + for _, b := range w.boxes() { |
| // The sweep's registry is empty: the sweep stages releases and is |
| // not what this test is about. The serial leg is. |
| l.fast[b] = &fastDeps{reg: restartTestRegistry(w.t), store: w.rs, fullPass: func(context.Context) { |
| @@ -1139,7 +1160,7 @@ func (w *e2eWorld) loops() *e2eLoops { |
| func (l *e2eLoops) round() bool { |
| before := l.passes |
| l.tickAt = l.tickAt.Add(fastFullClamp + time.Second) |
| - for _, b := range []*offBox{l.w.ie, l.w.uk} { |
| + for _, b := range l.w.boxes() { |
| fastTick(context.Background(), l.fast[b], l.tickAt) |
| } |
| return l.passes > before |
| @@ -1173,7 +1194,7 @@ func (l *e2eLoops) after(gap time.Duration) { |
| func (l *e2eLoops) reassert(at time.Time) { |
| l.w.setBoxClock(at) |
| - for _, b := range []*offBox{l.w.ie, l.w.uk} { |
| + for _, b := range l.w.boxes() { |
| b.w.offlineReassert(context.Background(), l.w.rs) |
| } |
| l.again++ |
| @@ -1298,6 +1319,17 @@ func offlineMoveDone(t *testing.T, opts landOpts) { |
| if r := w.wd.reportFor(w.id, moves.OfflineRoleTarget, "uk-box"); !r.Items["env-pin"].OK { |
| t.Fatalf("env-pin across the two agent environments: %+v", r.Items["env-pin"]) |
| } |
| + if w.pool != nil { |
| + if rec := w.wd.record(); rec.Move.TargetBox != "uk-box" { |
| + t.Fatalf("the start pinned target %q, want uk-box", rec.Move.TargetBox) |
| + } |
| + if rt := w.pool.row(offHost); rt != nil { |
| + t.Fatalf("uk-pool holds a row for the host: %+v", rt) |
| + } |
| + if _, _, err := w.wd.s.Get(ctx, moves.OfflineReportKey(offHost, w.id, moves.OfflineRoleTarget, "uk-pool")); !errors.Is(err, os.ErrNotExist) { |
| + t.Fatalf("uk-pool reported as a target: %v", err) |
| + } |
| + } |
| w.requireStopped("after the landing") |
| w.open() |
| if opts.lifetime { |
diff --git a/internal/host/movesoffline_land_test.go b/internal/host/movesoffline_land_test.go| index 3954d3c2e..615d1a324 100644 |
| --- a/internal/host/movesoffline_land_test.go |
| +++ b/internal/host/movesoffline_land_test.go |
| @@ -93,6 +93,10 @@ type landOpts struct { |
| // incarnation creates the record at that incarnation with no slot, as |
| // a claims-on box (no judge) sees one; only without judged or lifetime. |
| incarnation uint64 |
| + // poolBox adds uk-pool beside uk-box in uk, a capable box that serves |
| + // only the named pool cohort1 (CARLOS_POOLS=cohort1), as leo did on dev |
| + // (amadan #413). Only the end-to-end world reads it. |
| + poolBox bool |
| } |
| // landWorld is offHost at home (ie-a, data-ie) moving to uk (uk-box, |
diff --git a/internal/host/movesoffline_test.go b/internal/host/movesoffline_test.go| index 73d84ec62..d226ac12f 100644 |
| --- a/internal/host/movesoffline_test.go |
| +++ b/internal/host/movesoffline_test.go |
| @@ -215,7 +215,7 @@ func (b *offBox) restart() { |
| func (b *offBox) reconcile() { |
| b.wd.t.Helper() |
| - cfg := provision.ReconcileConfig{Region: b.region, DataDir: b.dd, Judge: b.wd.judge} |
| + cfg := provision.ReconcileConfig{Region: b.region, Pools: provision.ParseBoxPools(b.getenv("CARLOS_POOLS")), DataDir: b.dd, Judge: b.wd.judge} |
| if b.nested { |
| cfg.Layout = func(context.Context, release.Store) (string, error) { return release.LayoutModeNested, nil } |
| } else { |
| @@ -285,6 +285,53 @@ func writeFile(t *testing.T, p, body string) { |
| // --- the hold --------------------------------------------------------------- |
| +// amadan #413: in the region a move goes to, only the box whose pools admit |
| +// the record and that the start pinned takes the target role. armOffline |
| +// reads the pools from CARLOS_POOLS the way reconcile does, so a box serving |
| +// only cohort1 (leo on dev) never lands a shared-pool record nor reports for |
| +// it, and a shared box beside the pinned one waits too. A move from before |
| +// the pin names no box: any box whose pools admit the record is a target, |
| +// as before. |
| +func TestOfflineTargetIsThePinnedBoxThatCanHoldTheRow(t *testing.T) { |
| + armed := func(box, pools string) moveCfg { |
| + cfg := moveCfg{Region: "uk", Box: box} |
| + armOffline(&cfg, t.TempDir(), nil, nil, nil, hostwrite.Config{}, func(k string) string { |
| + switch k { |
| + case "CARLOS_POOLS": |
| + return pools |
| + case "CARLOS_HIBERNATE_BUCKET": |
| + return "data-uk" |
| + } |
| + return "" |
| + }) |
| + return cfg |
| + } |
| + rec := func(pool, pinned string) provision.Record { |
| + return provision.Record{Host: offHost, Pool: pool, Region: "uk", Move: &provision.MoveState{Kind: provision.MoveKindOffline, ID: offID, To: "uk", State: provision.OfflineLanding, TargetBox: pinned}} |
| + } |
| + for _, c := range []struct { |
| + name string |
| + cfg moveCfg |
| + rec provision.Record |
| + want bool |
| + }{ |
| + {"the pinned shared box", armed("uk-box", ""), rec("", "uk-box"), true}, |
| + {"the pinned box serving the shared pool beside a named one", armed("uk-box", "@shared,cohort1"), rec("", "uk-box"), true}, |
| + {"a pool box beside the pinned one", armed("uk-pool", "cohort1"), rec("", "uk-box"), false}, |
| + {"a shared box that is not the pinned one", armed("uk-other", ""), rec("", "uk-box"), false}, |
| + {"a pool box named as the target of a shared-pool record", armed("uk-pool", "cohort1"), rec("", "uk-pool"), false}, |
| + {"no pin, a shared box", armed("uk-box", ""), rec("", ""), true}, |
| + {"no pin, a pool box", armed("uk-pool", "cohort1"), rec("", ""), false}, |
| + {"a box with no pools armed", moveCfg{Region: "uk", Box: "uk-box"}, rec("", ""), false}, |
| + } { |
| + t.Run(c.name, func(t *testing.T) { |
| + if got := c.cfg.offlineTargetHere(c.rec); got != c.want { |
| + t.Fatalf("offlineTargetHere = %v, want %v", got, c.want) |
| + } |
| + }) |
| + } |
| +} |
| + |
| // offlineHold's table: a pure function of the record and the box's |
| // placement. The home's "" and a named region; every state. |
| func TestOfflineHoldIsAFunctionOfTheRecord(t *testing.T) { |
diff --git a/internal/host/movespass.go b/internal/host/movespass.go| index c74154783..d4f2fe74b 100644 |
| --- a/internal/host/movespass.go |
| +++ b/internal/host/movespass.go |
| @@ -22,6 +22,7 @@ import ( |
| "github.com/carlosframework/platform/internal/cgroup" |
| "github.com/carlosframework/platform/internal/controlsock" |
| "github.com/carlosframework/platform/internal/dbverify" |
| + "github.com/carlosframework/platform/internal/edgesfile" |
| "github.com/carlosframework/platform/internal/hostbox" |
| "github.com/carlosframework/platform/internal/hostclaim" |
| "github.com/carlosframework/platform/internal/hostguard" |
| @@ -365,6 +366,7 @@ func armMovesPass(hib activator.Config, dataDir string, reg *registry.Registry, |
| // for a record with an offline move. |
| func armOffline(cfg *moveCfg, dataDir string, reg *registry.Registry, svc *activator.Service, eb *activator.ExecBackend, writes hostwrite.Config, getenv func(string) string) { |
| cfg.OfflineCapable = offlineCapable(getenv, hibernationConfigured(getenv)) |
| + cfg.OfflinePools = provision.ReconcileConfig{Pools: provision.ParseBoxPools(getenv("CARLOS_POOLS"))}.ServedPools() |
| cfg.Offline = newOfflineView(*cfg, holdStageRequester(dataDir)) |
| if svc != nil { |
| cfg.FenceAs = fenceAsWith(svc) |
| @@ -1009,6 +1011,12 @@ type moveCfg struct { |
| // keep view reconcile reads (offlineView.keep); the hold needs none. |
| OfflineCapable bool |
| Offline *offlineView |
| + // OfflinePools are the pools this box serves, from CARLOS_POOLS through |
| + // provision.ParseBoxPools, the parse reconcile and the edges file use. |
| + // A box whose pools do not admit a record never takes the target role |
| + // for it (offlineTargetHere): reconcile never gives it the row. Nil |
| + // serves no pool. |
| + OfflinePools edgesfile.PoolEvidence |
| // FenceAs installs, or meets again, an owned activator fence |
| // (activator.Service.FenceAndStopAs under a 2 s deadline, |
| // ErrStopUnproven counted as installed: fenceAsWith); LiftFenceAs lifts |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 6420219f5..1e432b26a 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -208,3 +208,4 @@ plan14-root-reads-instance-gomemlimit-991.tsv 19c9f395547d998f4b5e87e89c0dfa3b5f |
| plan14-root-reads-ppv2-operator-copy.tsv 19c9f395547d998f4b5e87e89c0dfa3b5f012d177a87eb5010a8c4defac305dc |
| plan14-root-reads-same-box-edge-fence.tsv 76c986ad534d23071100a9a573ffb38afc60b26c8942baf218436bf6a3ff03b3 |
| plan14-root-reads-g6-fence.tsv 3f43afa4b0c18ad678a952b48b511e74e849992cd629b9aa1442bbe0055d5631 |
| +plan14-root-reads-offline-move-pool-target-413.tsv 022a33f457a0684b499f118b8d475bd4aa3c0f04395727c3e8c090863daaff89 |
diff --git a/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv b/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv| new file mode 100644 |
| index 000000000..b4b4b7934 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv |
| @@ -0,0 +1,6 @@ |
| +# Census overlay offline-move-pool-target-413, written by census-propose (#369). census-ruling-offline-move-pool-target-413, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md. |
| +# 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy 1c7bd4ba117b1b09a161422e9344a24460fddd7418477fdca993d513254791b3 internal/host/movespass.go armOffline legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route (J1, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): census-ruling-moves-offline's body, which also arms moveCfg.ReleaseHoldSeq (releaseHeldSeq over the registry, touching the stage-requested marker after a release that landed); closes over the registry and reads nothing itself; self-serve moves 1 Task 7;rev3=census-ruling-offline-move-pool-target-413;basis=sets moveCfg.OfflinePools from CARLOS_POOLS through provision.ParseBoxPools (an env string the agent already reads for reconcile; no file read), so offlineTargetHere keeps a box whose pools do not admit the record out of the offline target role (amadan #413); no read added whole:Route@2258 9a021c1f9794e1e55b785db0117059bb5e1d0775286d914ce155b7eb01b259dd |
| +internal/host/movespass.go armOffline legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route (J1, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): census-ruling-moves-offline's body, which also arms moveCfg.ReleaseHoldSeq (releaseHeldSeq over the registry, touching the stage-requested marker after a release that landed); closes over the registry and reads nothing itself; self-serve moves 1 Task 7;rev3=census-ruling-offline-move-pool-target-413;basis=sets moveCfg.OfflinePools from CARLOS_POOLS through provision.ParseBoxPools (an env string the agent already reads for reconcile; no file read), so offlineTargetHere keeps a box whose pools do not admit the record out of the offline target role (amadan #413); no read added whole:Route@2258 9a021c1f9794e1e55b785db0117059bb5e1d0775286d914ce155b7eb01b259dd |
| +@coverage internal/host 409447883edc805e3667a85bfa4244aaef442c8c84deb61d73dfd8b7f0d60900 |
| +@coverage internal/provision 2384ec8d80a2f83455602ebec1d84b8793d9f2691df2ecbd7c3a283f42d52857 |