carlos / platform Public

activator: bind a pre-deploy install wait to the first target (#1061)

Astra's final check, P2: a wait begun before any deploy was observed
(target "") covered every target, and observing a deploy did not bind
it. After v2's window expired with no further wake, a later v3 on the
same row lifetime inherited the expired start and answered kept after
32 s without its own ten-minute window.

SetReplicaDeploy now binds such a wait to the first target observed
(bindInstallTargetLocked), keeping its start; another target then
starts its own wait. Fixes the stale residentState comment too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev b523cb388403045de004a5bed89dfe90f3482f68 parent 923537b
3 files changed, +55 −8
  • internal/activator/replica_install_wait_test.go +33 −0
  • internal/activator/replicadeploy.go +1 −0
  • internal/activator/rootfs_service.go +21 −8

Intent

Human

<task-notification> <task-id>a9b3e2da465980c28</task-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2b517942-2259-467d-a8d0-994fd28c9e84/tasks/a9b3e2da465980c28.output</output-file> <status>completed</status> <summary>Agent "Implement #966 fix" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. Fleet boxes on the store door now write config acks under `fleets/&lt;fleet&gt;/`, relay status reads them from there, and the alias pass no longer sends the refused `status/boxes/` list (it still reports incomplete). Commit: 923537b1 `fleets: write config acks in the fleet corner; skip door snapshot list` on sr-followups. Tests: the three new tests failed before the fix and pass now. Edge full package passes, and console `-run 'Relay|ConfigAck|Fleet|Seal'` passes. The host full package has 21 failures, all `hostwrite: lifecycle provider unavailable`. The same error shows on a clean export of HEAD, so it is this machine, not the change; those tests need a CI run. Concerns: - **Different door test from the brief.** The brief said to reuse `resolveStatusPrefix`'s check. I used the deploy store's own rule instead (no deployment bucket, no deployment dir, a fleet set), because acks and the alias pass go through the deploy store. - **Extra console check.** An ack now counts only if the host in its key matches the host in its body. Without this, a box on one fleet could write an ack that marks another fleet's host as adopted. A test covers this case. - **Census.** `internal/host` changed; the census pass should decide whether `TestPlan14RootReadCensus` needs a card. - **Side findings, not fixed** (triage questions 3 and 4): door boxes can't read `control/host-incarnations/&lt;host&gt;.json`, and `control/relay-ack/&lt;box&gt;.json` would hit the same write refusal on a fleet box. - **Scratch.** I left `/tmp/g/sr966.k2Uw` because it holds the host test log; it is safe to delete. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/sr-followups/.superpowers/sdd/plan-966/task-1-report.md</result> <usage><subagent_tokens>153655</subagent_tokens><tool_uses>59</tool_uses><duration_ms>1990138</duration_ms></usage> </task-notification>

Attributed to this commit: 21.8 g CO₂e (2,637,307 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on sr-followups, 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/internal/activator/replica_install_wait_test.go b/internal/activator/replica_install_wait_test.go
index 3e16544ff..defdbe8a1 100644
--- a/internal/activator/replica_install_wait_test.go
+++ b/internal/activator/replica_install_wait_test.go
@@ -422,3 +422,36 @@ func TestInstallWaitRules(t *testing.T) {
t.Fatal("the install refusal and the outage are not told apart for the backoff")
}
}
+
+// TestInstallWaitBindsToFirstTarget (Astra final check, P2): a wait begun
+// before any deploy was observed binds to the first target observed, by
+// the observation itself. A later deploy of another target on the same
+// row lifetime starts its own wait, and never inherits the earlier
+// target's expired deadline.
+func TestInstallWaitBindsToFirstTarget(t *testing.T) {
+ r := newInstallRig(t)
+ rt := r.rt
+ wait := func() time.Time {
+ r.a.mu.Lock()
+ defer r.a.mu.Unlock()
+ return r.a.installWaitLocked(rt)
+ }
+ r.a.SetReplicaDeploy(rt.Host, replicas.Deploy{}, "b") // no deploy observed
+ r.refused("before any deploy")
+ first := wait()
+ r.a.SetReplicaDeploy(rt.Host, *installJoin(5)(r.inc), "b") // observe v2; no further wake
+ if got := wait(); !got.Equal(first) {
+ t.Fatalf("the first target observed did not take the wait: %s, want %s", got, first)
+ }
+ r.clk.advance(releaseInstallBound + time.Minute) // v2's window expires
+ v3 := *installJoin(6)(r.inc)
+ v3.ID, v3.Target, v3.LastGood = "deploy-v3", replicas.Build{Version: "v3", Digest: "canonical-v3"}, replicas.Build{Version: "v3", Digest: "canonical-v3"}
+ r.a.SetReplicaDeploy(rt.Host, v3, "b")
+ if got := wait(); !got.IsZero() {
+ t.Fatalf("v3 inherited v2's wait from %s", got)
+ }
+ r.refused("v3's first refusal")
+ if got := wait(); !got.Equal(r.clk.now()) {
+ t.Fatalf("v3's wait starts at %s, want its own first refusal (%s)", got, r.clk.now())
+ }
+}
diff --git a/internal/activator/replicadeploy.go b/internal/activator/replicadeploy.go
index 863ab02a0..26b9f7c5b 100644
--- a/internal/activator/replicadeploy.go
+++ b/internal/activator/replicadeploy.go
@@ -106,6 +106,7 @@ func (a *Service) SetReplicaDeploy(host string, deploy replicas.Deploy, box stri
a.replicaPolicies = make(map[string]replicaPolicy)
}
a.replicaPolicies[host] = replicaPolicy{deploy: deploy.Clone(), box: box}
+ a.bindInstallTargetLocked(host, deploy.Incarnation, deploy.Target.Version)
}
// replicaPolicyAllows is Allows over the observed policy for rt's lifetime
diff --git a/internal/activator/rootfs_service.go b/internal/activator/rootfs_service.go
index f0edce8c9..32fbf09b4 100644
--- a/internal/activator/rootfs_service.go
+++ b/internal/activator/rootfs_service.go
@@ -437,8 +437,9 @@ type residentState struct {
configSince time.Time
// install is the install wait (#1061): set by the first wake refused
// because no build is installed for it on this box yet, for one key
- // (row lifetime, deploy, target, permit). noteInstallWaitLocked alone
- // sets and clears it; installWaitLocked reads it.
+ // (row lifetime, target build; installKey). noteInstallWaitLocked
+ // alone sets and clears it, bindInstallTargetLocked gives a wait begun
+ // before any deploy its first target, and installWaitLocked reads it.
install installWait
}
@@ -1166,7 +1167,8 @@ func (a *Service) installKeyLocked(rt registry.Route) installKey {
// covers reports whether a wait of key w counts for key k: the same row
// lifetime, and the same target, or a wait begun before any target was
-// observed (w.target ""), which counts for the target observed since.
+// observed (w.target "") read while still none is (bindInstallTargetLocked
+// binds it to the first target observed, so it never spans two targets).
func (w installKey) covers(k installKey) bool {
return w.incarnation == k.incarnation && (w.target == "" || w.target == k.target)
}
@@ -1195,18 +1197,29 @@ const (
func (a *Service) noteInstallWaitLocked(st *residentState, rt registry.Route, ev installEvent) {
switch ev {
case installRefused:
- k := a.installKeyLocked(rt)
- switch {
- case st.install.since.IsZero() || !st.install.key.covers(k):
+ if k := a.installKeyLocked(rt); st.install.since.IsZero() || !st.install.key.covers(k) {
st.install = installWait{since: a.now(), key: k}
- default:
- st.install.key = k // a wait begun with no target takes this one
}
case installStarted, installCrashed:
st.install = installWait{}
}
}
+// bindInstallTargetLocked is a replica deploy of target observed for
+// host's row lifetime incarnation (SetReplicaDeploy): a wait begun before
+// any deploy was observed (target "") is for this target, the first one
+// observed, keeping its start (Astra final check, P2). A later deploy of
+// another target then finds a wait of another key, which is no wait, and
+// its own first refusal starts its own. The caller holds a.mu.
+func (a *Service) bindInstallTargetLocked(host, incarnation, target string) {
+ st := a.residents[host]
+ if st == nil || st.install.since.IsZero() || target == "" ||
+ st.install.key.target != "" || st.install.key.incarnation != incarnation {
+ return
+ }
+ st.install.key.target = target
+}
+
// installWaitLocked is since when rt's wakes have waited for its build's
// install, for rt's key now; zero when there is no such wait. The caller
// holds a.mu.