carlos / platform Public

restart gain seed: a lost known position is the leg's, not a first sight

Astra's fix check: restartScopePass also flags a position that fell out
of the bounded log as history, so gain retries re-handled its grants.
restartBaseline now applies legacy retries only for apps with no
narrowed position before the pass (every app at arming, as before).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 8fb53fab3f2d837a8e17f81a61c943249a75b930 parent cd4cd62
5 files changed, +64 −11
  • docs/superpowers/notes/census-proposal-restart-new-box-gap.md +1 −1
  • internal/host/restart.go +16 −6
  • internal/host/restartgain_test.go +43 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-restart-new-box-gap.tsv +3 −3

CI passed — run details

diff --git a/docs/superpowers/notes/census-proposal-restart-new-box-gap.md b/docs/superpowers/notes/census-proposal-restart-new-box-gap.md
index d45e79503..9361a7ee9 100644
--- a/docs/superpowers/notes/census-proposal-restart-new-box-gap.md
+++ b/docs/superpowers/notes/census-proposal-restart-new-box-gap.md
@@ -24,6 +24,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/host/restart.go:restartBaseline`: reads +whole:Route ×5; written legacy, accepted-legacy, frozen
- new `internal/host/restart.go:restartGainSeed`: reads +registry:App, +whole:Route ×7; written legacy, accepted-legacy, frozen
-Seal: `c55b4a022b3d42f40a05b727f93e57dc9f76b6dc2251f7d3b777c34d7ffdee09` → `b9e3f3200199930d966a2453fe7f151926446850c35cf9f5626b682558fc17ec`.
+Seal: `c55b4a022b3d42f40a05b727f93e57dc9f76b6dc2251f7d3b777c34d7ffdee09` → `18e4df5f599a48a881526fc2f85a9b591e3ea8677bb297d5944c9d935771f5e6`.
Overlay: `internal/provision/testdata/plan14-root-reads-restart-new-box-gap.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/host/restart.go b/internal/host/restart.go
index d7a997355..6d042b7d4 100644
--- a/internal/host/restart.go
+++ b/internal/host/restart.go
@@ -954,6 +954,15 @@ func restartBaseline(ctx context.Context, routes []registry.Route, store release
// both logs: they are not seed-skipped (Astra plan 9), so a grant
// written before this agent started, and not yet applied, is applied
// now. A grant spent or made stale since clears nothing.
+ //
+ // Which apps this pass is FIRST to see is taken before it runs: a
+ // position the memory already held is not a first sight, even when the
+ // pass reports its retries as history because that position fell out of
+ // the log. That case is the restart leg's (Astra fix check, 2026-11-06).
+ known := make(map[[2]string]bool, len(mem.scope))
+ for k := range mem.scope {
+ known[k] = true
+ }
scoped, scopeErrs := restartScopePass(ctx, routes, store, mem.scope)
readErrs = append(readErrs, scopeErrs...)
grants, grantErrs := hostRetryPass(ctx, routes, store, mem)
@@ -968,14 +977,15 @@ func restartBaseline(ctx context.Context, routes []registry.Route, store release
// retry at its start as history, silently, as it always has: its
// line would only say, at every start, that nothing is held.
//
- // History only: a baseline hands over what a FIRST sight finds.
- // At arming every entry is a first sight; restartGainSeed's
- // scratch memory carries the positions the agent already holds,
- // and movement past one of those is the restart leg's to handle,
- // once, on its serial move.
+ // First sights only: a baseline hands over what an app it has
+ // never seen holds. At arming every app is a first sight;
+ // restartGainSeed's scratch memory carries the positions the
+ // agent already holds, and anything past one of those (movement,
+ // or a position lost from the log) is the restart leg's to
+ // handle, once, on its serial move.
var history []scopedRestart
for _, w := range scoped {
- if w.history {
+ if w.history && !known[w.app] {
history = append(history, w)
}
}
diff --git a/internal/host/restartgain_test.go b/internal/host/restartgain_test.go
index 5d4c1143a..be43321a1 100644
--- a/internal/host/restartgain_test.go
+++ b/internal/host/restartgain_test.go
@@ -293,3 +293,46 @@ func TestRestartGainSeedHandlesEachRetryGrantOnce(t *testing.T) {
})
}
}
+
+// TestRestartGainSeedLeavesALostPositionToTheLeg is the Astra fix check's
+// residual case: the agent holds a narrowed position, the generation will
+// not read, and the log grows past its bound so that position falls out of
+// it, with a signed legacy retry among the new entries. The scope pass
+// reports that log as history, but it is not a first sight for this memory:
+// the gain retries must hand nothing over, and the restart leg handles the
+// grant exactly once.
+func TestRestartGainSeedLeavesALostPositionToTheLeg(t *testing.T) {
+ ctx, base := genKit(t)
+ dd := t.TempDir()
+ host := "a.example.com"
+ routes := []registry.Route{execRoute(host, "bab", "shop")}
+ mem, priv := retryMemory(t)
+ calls := 0
+ mem.retryHost = func(string, string, string, uint64) bool { calls++; return false }
+
+ askScoped(t, ctx, base, "bab", "shop", release.RestartScopeHost, host)
+ fs := &failingKeyStore{Store: base, failKey: release.RestartGenKey("bab", "shop"), err: errors.New("503 slow down")}
+ restartBaseline(ctx, routes, fs, dd, mem) // position recorded, generation not
+ if _, ok := mem.scope[[2]string{"bab", "shop"}]; !ok {
+ t.Fatal("no narrowed position after the baseline")
+ }
+
+ for i := 0; i < 31; i++ {
+ askScoped(t, ctx, base, "bab", "shop", release.RestartScopeHost, "other.example.com")
+ }
+ legacySignedRetry(t, ctx, base, priv, "bab", "shop", host, "v2", "bk", 5)
+ askScoped(t, ctx, base, "bab", "shop", release.RestartScopeHost, "other.example.com")
+
+ now := time.Now()
+ restartGainSeed(ctx, routes, fs, dd, mem, now)
+ restartGainSeed(ctx, routes, fs, dd, mem, now.Add(restartGainRetry))
+ if calls != 0 {
+ t.Fatalf("the gain seed handled %d grants past a position it already held, want 0 (the leg's)", calls)
+ }
+ bounce := func(string) bool { return true }
+ restartRequestLeg(ctx, routes, fs, dd, bounce, nil, mem)
+ restartRequestLeg(ctx, routes, fs, dd, bounce, nil, mem)
+ if calls != 1 {
+ t.Fatalf("handled the grant %d times in all, want once", calls)
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 8d0c25e6e..1768ce744 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -103,4 +103,4 @@ plan14-root-reads-agent-start-demo-analytics-fix.tsv 89841c50d08090185e24cb03c6b
plan14-root-reads-agent-start-demo-log-skip.tsv ed24b69243622fc702159e0b22c732f4f8297438b87f10c499887cd1a13f6fce
plan14-root-reads-demo-api-site-route.tsv 9bfd77d30d8e3deb5f3863cb6c272c2cb46ce32aa1370acbaa6e9181b71101b4
plan14-root-reads-region-ha-p3b2-rolls.tsv c55b4a022b3d42f40a05b727f93e57dc9f76b6dc2251f7d3b777c34d7ffdee09
-plan14-root-reads-restart-new-box-gap.tsv b9e3f3200199930d966a2453fe7f151926446850c35cf9f5626b682558fc17ec
+plan14-root-reads-restart-new-box-gap.tsv 18e4df5f599a48a881526fc2f85a9b591e3ea8677bb297d5944c9d935771f5e6
diff --git a/internal/provision/testdata/plan14-root-reads-restart-new-box-gap.tsv b/internal/provision/testdata/plan14-root-reads-restart-new-box-gap.tsv
index 4b1ef15ca..866426594 100644
--- a/internal/provision/testdata/plan14-root-reads-restart-new-box-gap.tsv
+++ b/internal/provision/testdata/plan14-root-reads-restart-new-box-gap.tsv
@@ -3,12 +3,12 @@
# 3 new dispositions: 0 reads re-frozen at their disposition with the claim, 3 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
@legacy f9901119aae0b7e5bc177c1075a6561e3fc15c272ce24c1156eda08bc471c8fd internal/host/agent.go fastTick legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=observes the change index before any pass (observeIndex), runs the backstop's requested full pass and a scoped pass for moved app scopes (indexTick), and arms the canary pointer gate on the sweep (canaryPointerGate) only on a tick whose own index observation succeeded; read site unchanged, offset moved;rev3=census-ruling-stateless-replicas-1;basis=Call coordinator Tick on the existing tick before convergence; client renews held terms only at the pinned interval. Existing registry read unchanged. Final review I3: signal the owned renewal worker instead of waiting for its sequential console HTTP calls. Existing convergence and record read unchanged.;rev3=census-ruling-region-ha-p3a;basis=Run the optional desired-role reader on the existing tick after observing the armed change index; no new root path or timer, nil reader is unchanged.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: signals the owned replica worker on the existing tick; coalesced asynchronous execution, no timer or bucket scan added. merge of origin/main 7920cccf: Retain main box-role reader pass on the existing tick alongside the replica worker signal; merge-only body change, unchanged read sites.;rev3=census-ruling-restart-new-box-gap;basis=calls the optional restartGain hook (restartGainSeed) once per existing tick before the serial read; no new root path, timer or read kind; nil hook is unchanged registry:Host@5265 139e8bee2561c0c4f5c5ff41594c87337f06904c9dc061ed647ffe506ae7f744
@legacy 88f3281650a151b50649d98a03ff403d00e6b85168782683b8f5974b730988d8 internal/host/restart.go armRestartLegs legacy accepted-legacy accepted-legacy;rev3=census-ruling-restart-new-box-gap;basis=agent-side closures over reg.List for the gain seed and the existing restart leg; same reads the old fastConvergeLoop closure made whole:Route@448,whole:Route@766 1a6e4782f8769840153ed55f2851bde005cdcdaa17a4666b57e82269a29d12a9
-@legacy 5c8a6c951d0ebba1d9e0149eaf5c2fb7259b5f7059c8cdf20ffa0fefd6844874 internal/host/restart.go restartBaseline legacy accepted-legacy accepted-legacy;rev3=census-ruling-restart-new-box-gap;basis=the former restartSeed body over a given route set (both logs, retry grants, seedRestartMarks/marker); legacy retries applied from first-sight history only (Astra r1 P2), which at arming is every entry whole:Route@157,whole:Route@1581,whole:Route@495,whole:Route@605,whole:Route@899 e268bdcbb18133d2db0c0c3a1efe0c685134ddf9f9db1f1d4095373cdf889bee
+@legacy ff9138a274d754572f76d22dccff3e11c0c10e6a9392e58353e168bc788de69d internal/host/restart.go restartBaseline legacy accepted-legacy accepted-legacy;rev3=census-ruling-restart-new-box-gap;basis=the former restartSeed body over a given route set (both logs, retry grants, seedRestartMarks/marker); legacy retries applied only for apps with no narrowed position before the pass (Astra r1 P2 + fix check), which at arming is every app whole:Route@1293,whole:Route@157,whole:Route@2055,whole:Route@889,whole:Route@999 642ef0cc4d27f87b59a3e52f9952dba1db6c7bd53533020331ff14777aae5584
@legacy 62b0eec4d5dd673a8ad1debb4e0c39270aeaa2707fe1d28d5898adfce1c94033 internal/host/restart.go restartGainSeed legacy accepted-legacy accepted-legacy;rev3=census-ruling-restart-new-box-gap;basis=baselines apps gained since arming via restartBaseline over those apps routes, into a scratch memory prefilled with the positions and handled retry ids already held (Astra r1 P2); merges only missing entries; throttles read errors; agent process, no root read registry:App@520,whole:Route@1246,whole:Route@212,whole:Route@463,whole:Route@515,whole:Route@534,whole:Route@547,whole:Route@552 be303c5bf5551ebcc9c45b5078d1b8e7b436c9008c07717bf0af3645575308cc
internal/host/agent.go fastTick legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=observes the change index before any pass (observeIndex), runs the backstop's requested full pass and a scoped pass for moved app scopes (indexTick), and arms the canary pointer gate on the sweep (canaryPointerGate) only on a tick whose own index observation succeeded; read site unchanged, offset moved;rev3=census-ruling-stateless-replicas-1;basis=Call coordinator Tick on the existing tick before convergence; client renews held terms only at the pinned interval. Existing registry read unchanged. Final review I3: signal the owned renewal worker instead of waiting for its sequential console HTTP calls. Existing convergence and record read unchanged.;rev3=census-ruling-region-ha-p3a;basis=Run the optional desired-role reader on the existing tick after observing the armed change index; no new root path or timer, nil reader is unchanged.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: signals the owned replica worker on the existing tick; coalesced asynchronous execution, no timer or bucket scan added. merge of origin/main 7920cccf: Retain main box-role reader pass on the existing tick alongside the replica worker signal; merge-only body change, unchanged read sites.;rev3=census-ruling-restart-new-box-gap;basis=calls the optional restartGain hook (restartGainSeed) once per existing tick before the serial read; no new root path, timer or read kind; nil hook is unchanged registry:Host@5265 139e8bee2561c0c4f5c5ff41594c87337f06904c9dc061ed647ffe506ae7f744
internal/host/restart.go armRestartLegs legacy accepted-legacy accepted-legacy;rev3=census-ruling-restart-new-box-gap;basis=agent-side closures over reg.List for the gain seed and the existing restart leg; same reads the old fastConvergeLoop closure made whole:Route@448,whole:Route@766 1a6e4782f8769840153ed55f2851bde005cdcdaa17a4666b57e82269a29d12a9
-internal/host/restart.go restartBaseline legacy accepted-legacy accepted-legacy;rev3=census-ruling-restart-new-box-gap;basis=the former restartSeed body over a given route set (both logs, retry grants, seedRestartMarks/marker); legacy retries applied from first-sight history only (Astra r1 P2), which at arming is every entry whole:Route@157,whole:Route@1581,whole:Route@495,whole:Route@605,whole:Route@899 e268bdcbb18133d2db0c0c3a1efe0c685134ddf9f9db1f1d4095373cdf889bee
+internal/host/restart.go restartBaseline legacy accepted-legacy accepted-legacy;rev3=census-ruling-restart-new-box-gap;basis=the former restartSeed body over a given route set (both logs, retry grants, seedRestartMarks/marker); legacy retries applied only for apps with no narrowed position before the pass (Astra r1 P2 + fix check), which at arming is every app whole:Route@1293,whole:Route@157,whole:Route@2055,whole:Route@889,whole:Route@999 642ef0cc4d27f87b59a3e52f9952dba1db6c7bd53533020331ff14777aae5584
internal/host/restart.go restartGainSeed legacy accepted-legacy accepted-legacy;rev3=census-ruling-restart-new-box-gap;basis=baselines apps gained since arming via restartBaseline over those apps routes, into a scratch memory prefilled with the positions and handled retry ids already held (Astra r1 P2); merges only missing entries; throttles read errors; agent process, no root read registry:App@520,whole:Route@1246,whole:Route@212,whole:Route@463,whole:Route@515,whole:Route@534,whole:Route@547,whole:Route@552 be303c5bf5551ebcc9c45b5078d1b8e7b436c9008c07717bf0af3645575308cc
internal/host/agent.go fastConvergeLoop authority B3 rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): every pass context carries the box's lifetime judge (provision.WithLifetimes) and the reconcile config is boxProvisionConfig's; read sites unchanged, offsets moved; B3 authority retained;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 12: its pass config is now BoxProvisionConfig(reg, os.Getenv, judge, configure) (BoxProvisionConfig replaces boxProvisionConfig: the hub predicate hubArmed and, on the hub, ReconcileConfig.FleetOwners from hubFleetOwners); a call, no read site; read sites unchanged (2); B3 authority retained.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: wire the coordinator's nonblocking SignalTick to the existing fast tick. No new timer, polling read or authority.;rev3=census-ruling-region-ha-p3b;basis=Bind systemLeg to the existing cached reader fold and handle a nil leg on groups; names-2 rollback gate runs before artifact/request/marker work. Agent-memory evidence only, no new direct or cloud read and no autonomous group update.;rev3=census-ruling-restart-new-box-gap;basis=restart leg closure moved into armRestartLegs (same reg.List + restartRequestLeg); also wires restartGain; read moved, not added whole:Route@8609 d10becd47ccedd2d01c6fdb3933882872932e6592410d7c318dbc1390685eb4c
internal/host/restart.go restartSeed authority E1,E3,J1,J4 fix1-merge-review;basis=Baselines both request logs without applying historical ordinary restarts; signed retry grants remain independently verified.;rev3=census-ruling-restart-new-box-gap;basis=body split: list routes then restartBaseline (the former body, unchanged); the route reads move with it whole:Route@298 b89f5767a539a57160f27d58f80ae2904c5993eeb1177563ed80aec63da632e1
-@coverage internal/host 447407effe468a4cc81726199ad9bccde4f5c24f1db20ede48fb1a36e1cc9f5a
+@coverage internal/host 53016f44b4a5f467b1c5a1c362dabbca557c3c4036cde8140ea7aaf3552b0af3