fix: log an unchanged held release once per change (#511 F11)
An always-on start held by a release attempt this box knows never started (or any other no-backoff release step error) is retried on every 2 s resident tick. Each retry logged "starting it" and wrote a member error event, about 43k lines a day per host. The stateless preparation now carries the attempt ID on its error. noteHeldWake keeps, per host, the (attempt ID, error class) of the last held wake: the first occurrence and every change write one journal line and one member event; repeats write nothing, and "starting it" is skipped while the host's last start was held. A wake that works, or a failure of another kind, forgets the note. The retries keep no backoff. Witness: TestReplicaHeldAttemptLogsOncePerChange (10 resident attempts give one line of each kind; a change of attempt or class says it again).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/activator/activator.go+7 −0internal/activator/rootfs_service.go+5 −1internal/activator/stateless.go+2 −2internal/activator/stateless_heldlog_test.go+104 −0internal/activator/wakefaillog.go+99 −2
Intent
<task-notification> <task-id>a5315a07ea5309511</task-id> <tool-use-id>toolu_01QGsG34ksfUqdg4nsZ6m4GE</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/a5315a07ea5309511.output</output-file> <status>completed</status> <summary>Agent "Implement Plan 4 Task 3F (F11)" 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_WITH_CONCERNS - **Commit:** `c149fab7 fix: say when a release command never started (#511 F11 round 3)`, on top of `fa314626`, `0abaa0c0` and `8e0e9eab`. Local only, not pushed. - **What changed:** - The box keeps a mark per host in its failure book: the attempt ID and term, saved before the `releasing` write, and `Started`, saved just before the exec. - In the reviewer's sequence (the `releasing` write commits, its reply is lost, the exec is refused), the next wake still closes the record as unknown. It now says "the release command did not start, and its attempt is closed. deploy again to retry it" (SR-4-C59, provisional). A later adoption of that attempt says the same and still holds the deploy. Neither grows backoff. - "Result unknown" now appears only when this box started the command, or has no mark for that attempt and term. Retry semantics are unchanged. - If the mark cannot be saved, nothing is written or run (SR-4-C60, provisional). - **Tests:** - The reviewer's sequence failed against round 2 ("result unknown" on the close) and passes now. - The started case stays "unknown" on the in-call result, the next close and the adoption. - A new book test shows the mark survives a restart, survives a failed save, and is not read by another lifetime. - Targeted activator, rollout, host (including the F10 and F11 witnesses), root and provision tests pass, as do the grouproll and region HA guards, all three cross-builds, vet and gofmt. - **Census:** I re-proposed `stateless-replicas-4-task3f` over all four commits; the seal moved bd253671 → 45b27ac0, and `make census-card` reports clean. - **Mutation (not run):** I'd drop the term match in `knownNotStarted`. No current test isolates the case where another term wrote `releasing` for the same ID; that check is what stops the box claiming "did not start" for an attempt another coordinator ran. - **Concerns:** - SR-4-C59 asks the owner to deploy again. That is true, since the record is unknown, but it is the first line in this task that asks them to act. SR-4-C55 to C60 all need Paul's copy review. - A held not-started attempt now fails each always-on wake every 2 s with no backoff, as the round 2 ruling on refusals asked. Those wakes make no coordinator or bucket call, but they log a line each time. - `Started` is saved slightly before the last pre-exec checks, so a refusal at those checks still reads as unknown. That errs on the safe side. - **Report:** `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/stateless-replicas-4/.superpowers/sdd/2026-11-01-stateless-replicas-4-deploy-and-drill/task-3F-report.md` (fix round 3 appended)</result> <usage><subagent_tokens>472437</subagent_tokens><tool_uses>20</tool_uses><duration_ms>950606</duration_ms></usage> </task-notification>
<task-notification> <task-id>bmbimr3hj</task-id> <tool-use-id>toolu_01Af1RmQtmH5PcPLX6LnKJVL</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/bmbimr3hj.output</output-file> <status>completed</status> <summary>Background command "Astra final re-review of F11" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bw96bhn53</task-id> <tool-use-id>toolu_01XBSBRGbfBDokEo24pd4Fmz</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/bw96bhn53.output</output-file> <status>completed</status> <summary>Background command "Astra census review of Tasks 1-3 and F11" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 15.3 g CO₂e (2,036,753 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on stateless-replicas-4, 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/activator.go b/internal/activator/activator.go| index 04612ad58..f9cb8d55b 100644 |
| --- a/internal/activator/activator.go |
| +++ b/internal/activator/activator.go |
| @@ -1515,8 +1515,11 @@ type Service struct { |
| rootfsRefusedSeen map[string]string |
| // wakeFailMu guards wakeFailLogged, the journal's rate limit on failed |
| // wakes per host (logWakeFailure). A leaf lock, like rootfsGateMu. |
| + // heldSeen, under the same lock, is each host's last failed wake held |
| + // by a release attempt with no backoff (noteHeldWake, #511 F11). |
| wakeFailMu sync.Mutex |
| wakeFailLogged map[string]*wakeFailNote |
| + heldSeen map[string]heldSeen |
| // Residency (Plan 3 Task 8, rootfs_service.go). residentLister is the |
| // DueStore read as a ResidentLister at New (nil: no residents). |
| // residents is each listed resident's backoff and reservation, by host; |
| @@ -2172,10 +2175,14 @@ func (a *Service) wake(e *actEntry) { |
| // the generation detail is the operator's. |
| log.Printf("activator: %s: wake failed and its generation is not proven stopped: %v", e.host, err) |
| } |
| + said := a.noteHeldWake(e.host, err) |
| if errors.Is(err, errRootfsNotAdmitted) { |
| // Refused before the lease (Plan 3 Task 7): reported once per |
| // change, not on every attempt. |
| a.noteRootfsRefusal(e.route, err) |
| + } else if !said { |
| + // The same held release attempt as this host's last failed |
| + // wake, with the same class: said once already (#511 F11). |
| } else if msg, ok := a.wakeFailureEvent(e, err); ok && !errors.Is(err, ErrDutyDeferred) { |
| emitEvent(a.Logs, e.route, "error", msg) |
| } |
diff --git a/internal/activator/rootfs_service.go b/internal/activator/rootfs_service.go| index a95ed36ac..3b2fb5f22 100644 |
| --- a/internal/activator/rootfs_service.go |
| +++ b/internal/activator/rootfs_service.go |
| @@ -800,7 +800,11 @@ func (a *Service) residentJob(ctx context.Context, rt registry.Route, st *reside |
| rootfsAdmittedKey: rootfsGateKey(rt)} |
| a.putEntryLocked(rt.Host, e) |
| a.mu.Unlock() |
| - log.Printf("activator: %s: always-on rootfs instance is not running; starting it", rt.Host) |
| + if !a.heldNow(rt.Host) { |
| + // While its last start was held by a release attempt, a retry |
| + // says nothing until the attempt or its class changes (#511 F11). |
| + log.Printf("activator: %s: always-on rootfs instance is not running; starting it", rt.Host) |
| + } |
| a.wake(e) |
| } |
diff --git a/internal/activator/stateless.go b/internal/activator/stateless.go| index 6ff7a4af1..ad5839dbf 100644 |
| --- a/internal/activator/stateless.go |
| +++ b/internal/activator/stateless.go |
| @@ -481,7 +481,7 @@ func (a *Service) prepareStateless(ctx context.Context, rt registry.Route, id re |
| launch.Stateless = true |
| deployID, err := a.prepareStatelessRelease(observed, launch, id, a.ReplicaDeployID) |
| if err != nil { |
| - return ctx, err |
| + return ctx, withAttempt(deployID, err) |
| } |
| prepared.deployID = deployID |
| return context.WithValue(observed, statelessPreparedKey{}, prepared), nil |
| @@ -509,7 +509,7 @@ func (a *Service) prepareStateless(ctx context.Context, rt registry.Route, id re |
| // The book is consulted only after the coordinator term is held (R1). |
| deployID, err := a.prepareStatelessRelease(observed, launch, id, a.ReplicaDeployID) |
| if err != nil { |
| - return ctx, err |
| + return ctx, withAttempt(deployID, err) |
| } |
| prepared := &statelessPreparation{route: rt, id: id, digest: digest, deployID: deployID, observation: observation} |
| return context.WithValue(observed, statelessPreparedKey{}, prepared), nil |
diff --git a/internal/activator/stateless_heldlog_test.go b/internal/activator/stateless_heldlog_test.go| new file mode 100644 |
| index 000000000..0b8d1d7f4 |
| --- /dev/null |
| +++ b/internal/activator/stateless_heldlog_test.go |
| @@ -0,0 +1,104 @@ |
| +package activator |
| + |
| +import ( |
| + "strings" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/replicas" |
| +) |
| + |
| +// residentRows lists one row as the box's always-on instances. |
| +type residentRows struct{ rows *routeRows } |
| + |
| +func (r residentRows) ResidentInstances() ([]registry.Route, error) { |
| + r.rows.mu.Lock() |
| + defer r.rows.mu.Unlock() |
| + var out []registry.Route |
| + for _, rt := range r.rows.rows { |
| + out = append(out, rt) |
| + } |
| + return out, nil |
| +} |
| + |
| +// TestReplicaHeldAttemptLogsOncePerChange is the carried-over #511 F11 log |
| +// fix: an always-on start that meets a held release attempt, one this box |
| +// knows never started, is retried on every tick with no backoff. Ten such |
| +// attempts write one "starting it" line, one journal line for the held |
| +// attempt and one member event, not ten of each. A change of attempt, or |
| +// of the error's class, is said again; the retries stay without backoff. |
| +func TestReplicaHeldAttemptLogsOncePerChange(t *testing.T) { |
| + r := newWakeRelRig(t) |
| + store := wireStatelessRig(r) |
| + memoryMarks(r.a) |
| + r.rt.Hibernate = false |
| + r.routes.set(r.rt) |
| + r.setPlan(WakePlan{Boot: r.next, Mode: ModeOverlap, FirstWake: true, Token: 1}) |
| + r.a.residentLister = residentRows{r.routes} |
| + r.a.residentJitter = func() float64 { return 0 } |
| + facts, err := r.a.cfg.ReplicaRecord(r.rt) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + identity := facts.Identity |
| + hold := func(id, phase string) { |
| + store.mu.Lock() |
| + store.d = &replicas.Deploy{ID: id, Incarnation: identity.Incarnation, Target: replicas.Build{Version: r.next.Version, Digest: "canonical"}, Phase: phase} |
| + store.mu.Unlock() |
| + if err := r.a.MarkReplicaRelease(identity, replicas.ReleaseMark{ID: id, Closed: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + logs := captureLog(t) |
| + count := func() (starting, held, events int) { |
| + for _, line := range strings.Split(logs.String(), "\n") { |
| + if !strings.Contains(line, r.rt.Host) { |
| + continue |
| + } |
| + if strings.Contains(line, "starting it") { |
| + starting++ |
| + } |
| + if strings.Contains(line, "held by release attempt") { |
| + held++ |
| + } |
| + } |
| + for _, msg := range r.sink.msgs() { |
| + if strings.Contains(msg, "release") { |
| + events++ |
| + } |
| + } |
| + return |
| + } |
| + attempts := func(n int) { |
| + t.Helper() |
| + for i := 0; i < n; i++ { |
| + tickSettled(t, r.a) |
| + if r.a.hasEntry(r.rt.Host) { |
| + t.Fatal("a held attempt started the instance") |
| + } |
| + if d := retryIn(r.a, r.clk, r.rt.Host); d > 0 { |
| + t.Fatalf("held attempt backed off by %s", d) |
| + } |
| + } |
| + } |
| + hold("deploy-a", "unknown") |
| + attempts(10) |
| + if s, h, e := count(); s != 1 || h != 1 || e != 1 { |
| + t.Fatalf("ten attempts against one held attempt: starting=%d held=%d events=%d, want 1 each\n%s", s, h, e, logs) |
| + } |
| + // Another attempt, same class: said again, once. |
| + hold("deploy-b", "unknown") |
| + attempts(10) |
| + if s, h, e := count(); s != 1 || h != 2 || e != 2 { |
| + t.Fatalf("changed attempt: starting=%d held=%d events=%d, want 1/2/2\n%s", s, h, e, logs) |
| + } |
| + // The same attempt, another class (its release failed): said again. |
| + hold("deploy-b", "failed") |
| + attempts(10) |
| + if s, h, e := count(); s != 1 || h != 3 || e != 3 { |
| + t.Fatalf("changed class: starting=%d held=%d events=%d, want 1/3/3\n%s", s, h, e, logs) |
| + } |
| + if n := len(r.b.releaseStarts()); n != 0 { |
| + t.Fatalf("held attempts ran %d release commands", n) |
| + } |
| +} |
diff --git a/internal/activator/wakefaillog.go b/internal/activator/wakefaillog.go| index 4c2188d33..f2a6fd947 100644 |
| --- a/internal/activator/wakefaillog.go |
| +++ b/internal/activator/wakefaillog.go |
| @@ -81,10 +81,107 @@ func (a *Service) logWakeFailure(host string, err error) { |
| log.Printf("activator: %s: wake failed: %v", host, err) |
| } |
| -// clearWakeFailure forgets host's failure note after a wake that worked, |
| -// so its next failure is logged at once. |
| +// clearWakeFailure forgets host's failure and held notes after a wake |
| +// that worked, so its next failure is logged at once. |
| func (a *Service) clearWakeFailure(host string) { |
| a.wakeFailMu.Lock() |
| delete(a.wakeFailLogged, host) |
| + delete(a.heldSeen, host) |
| a.wakeFailMu.Unlock() |
| } |
| + |
| +// attemptError is a stateless preparation's failure with the release |
| +// attempt it acted on (prepareStateless), so a failed wake can tell one |
| +// held attempt from the next. Its text is the error's own. |
| +type attemptError struct { |
| + attempt string |
| + err error |
| +} |
| + |
| +func (e *attemptError) Error() string { return e.err.Error() } |
| +func (e *attemptError) Unwrap() error { return e.err } |
| + |
| +// withAttempt wraps err with attempt, when both are set. |
| +func withAttempt(attempt string, err error) error { |
| + if err == nil || attempt == "" { |
| + return err |
| + } |
| + return &attemptError{attempt: attempt, err: err} |
| +} |
| + |
| +// heldNote is a failed wake held by a release attempt: the attempt's ID |
| +// and the error's class. |
| +type heldNote struct{ attempt, class string } |
| + |
| +// heldSeen is a host's last heldNote and when a wake last met it. |
| +type heldSeen struct { |
| + note heldNote |
| + at time.Time |
| +} |
| + |
| +// heldClasses are the classes a held attempt's error is told apart by. |
| +// Anything else is its own text. |
| +var heldClasses = []error{errReplicaReleaseNotStarted, errReplicaRecordRefused, errReplicaTermLost, |
| + errReplicaStepUnconfirmed, errReplicaMarkUnsaved, errReleaseNotPassed, ErrReplicaReleaseUnknown} |
| + |
| +// heldBy reports the heldNote of a failed wake that a release attempt |
| +// held and that does not back off (residentFailure is false): an |
| +// always-on instance retries it on every tick. |
| +func heldBy(err error) (heldNote, bool) { |
| + var ae *attemptError |
| + if !errors.As(err, &ae) || residentFailure(err) { |
| + return heldNote{}, false |
| + } |
| + class := err.Error() |
| + for _, c := range heldClasses { |
| + if errors.Is(err, c) { |
| + class = c.Error() |
| + break |
| + } |
| + } |
| + return heldNote{attempt: ae.attempt, class: class}, true |
| +} |
| + |
| +// noteHeldWake is a failed wake's report for a held release attempt |
| +// (#511 F11): an always-on start held by one attempt is retried every |
| +// tick with no backoff, so its journal line and member event are written |
| +// for the first wake of each (attempt, class) on a host and not for the |
| +// repeats. It returns whether the caller still reports err: false only |
| +// for a repeat. Any other failure forgets the host's note, as a wake that |
| +// worked does (clearWakeFailure), so a later hold is said again. A note |
| +// no wake has met for wakeFailureForget is dropped. |
| +func (a *Service) noteHeldWake(host string, err error) bool { |
| + n, held := heldBy(err) |
| + now := a.now() |
| + a.wakeFailMu.Lock() |
| + for h, s := range a.heldSeen { |
| + if now.Sub(s.at) >= wakeFailureForget { |
| + delete(a.heldSeen, h) |
| + } |
| + } |
| + if !held { |
| + delete(a.heldSeen, host) |
| + a.wakeFailMu.Unlock() |
| + return true |
| + } |
| + last, seen := a.heldSeen[host] |
| + if a.heldSeen == nil { |
| + a.heldSeen = map[string]heldSeen{} |
| + } |
| + a.heldSeen[host] = heldSeen{note: n, at: now} |
| + a.wakeFailMu.Unlock() |
| + if seen && last.note == n { |
| + return false |
| + } |
| + log.Printf("activator: %s: held by release attempt %s: %v; said again only when it changes", host, n.attempt, err) |
| + return true |
| +} |
| + |
| +// heldNow reports whether host's last failed wake was held by a release |
| +// attempt (noteHeldWake). |
| +func (a *Service) heldNow(host string) bool { |
| + a.wakeFailMu.Lock() |
| + defer a.wakeFailMu.Unlock() |
| + _, ok := a.heldSeen[host] |
| + return ok |
| +} |