carlos / platform Public

fix: no request gap or false log on the switch to stateless (#511 F11)

A hold swap from a stateful build to a stateless one prepares and runs
the release on the route row it read before the incumbent stops. The
release's own build-state write changes that row's build_state column,
so the pinned wake's re-read row no longer equals the prepared row, and
statelessCurrent's whole-row check refused the wake with ErrFenced
("maintenance fence active"). The hold was abandoned and requests got
"instance failed to wake" until the always-on sweep started the build.

prepareStateless now moves a hold's preparation onto the row the pinned
wake read, after the prepared row passes statelessCurrent against the
registry, and checks the wake's row the same way. A launch field that
differs still refuses.

The request wake that followed read the reconcile index, which had not
yet seen the passed release, and asked the writer to begin a new
attempt. The writer refused, and that refusal was reported as "the
release command's result is unknown". A begin the writer refuses now
says nothing ran (SR-4-C55, provisional); a lost begin reply keeps the
unknown answer.

Witnesses: TestStatefulToStatelessSwitchProductionWiring and
TestStatefulToStatelessFailedReleaseHolds through the real activator,
rollout, build-state hook and reconcile-index observation;
TestStatelessHoldWakeRebasesPreparation and
TestReplicaReleaseBeginRefusalRanNothing. Census overlay
stateless-replicas-4-task3f and a record-write census layer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 8e0e9eab664a3dab882ee3559d0fe4bb70980ba1 parent 544b3b1
10 files changed, +579 −1
  • docs/superpowers/notes/census-proposal-stateless-replicas-4-task3f.md +21 −0
  • docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md +1 −0
  • internal/activator/stateless.go +19 −0
  • internal/activator/stateless_holdwake_test.go +118 −0
  • internal/activator/statelessrelease.go +11 −0
  • internal/host/stateless_switch_test.go +363 −0
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/stateless_replicas_4_task3f_census_test.go +37 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-stateless-replicas-4-task3f.tsv +7 −0

CI failed — run details

Intent

Human

<task-notification> <task-id>ac96b33e1c2a440a1</task-id> <tool-use-id>toolu_01YUne3WwfmKCPwtExoJCmvN</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/ac96b33e1c2a440a1.output</output-file> <status>completed</status> <summary>Agent "Implement Plan 4 Task 3 (trimmed)" 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 - Commit: 544b3b14 `fix: count unread copies as unknown; hold copies lock across restart` (on top of fb1d0904) - Tests: the 12 new replica tests pass, including 2 added this round; the related console, census, docsite and cross-compile checks pass. A mutation that removed the restart lock made the lock test fail. - Fix 1, false zero: when any copy has no reading, the overview now says "N of M copies unknown; K known running" (SR-4-C54, provisional) instead of "0 of 2 copies running". The test now checks the all-unknown and one-of-two-unknown cases. The CLI and API show state per copy only, with no total, so they couldn't show a false zero. - Fix 2, restart race: the copies check and the restart write now happen under the same app lock that copies changes take, on all three restart paths (CLI app-wide, `--environment`, and the app page button). A new test shows a copies change waits until the restart has been written. - Fix 3, root console: a console running as root can now read the socket, but only when the socket, its folder and the process serving it all belong to the agent user `carlos`. A test covers this, pretending to be root rather than running as root. Real root wasn't exercised. - Mutation-test hang: the first run of the lock mutation hung because the failing test left the restart blocked. I stopped it, restored the file, and changed the test so it releases on failure. - Concerns: the deployed console's user and namespace still need checking in the dev smoke test. The census proposal for this task still hasn't been posted on #280. - Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/stateless-replicas-4/.superpowers/sdd/2026-11-01-stateless-replicas-4-deploy-and-drill/task-3-report.md (fix round 1 section appended)</result> <usage><subagent_tokens>389734</subagent_tokens><tool_uses>19</tool_uses><duration_ms>1132347</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>bmzuxbzkm</task-id> <tool-use-id>toolu_015Pji9TPv7axacivu2NLm7x</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/bmzuxbzkm.output</output-file> <status>completed</status> <summary>Background command "Astra re-review of Task 3 fix" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 80.5 g CO₂e (5,497,280 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/docs/superpowers/notes/census-proposal-stateless-replicas-4-task3f.md b/docs/superpowers/notes/census-proposal-stateless-replicas-4-task3f.md
new file mode 100644
index 000000000..22c056c4e
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-stateless-replicas-4-task3f.md
@@ -0,0 +1,21 @@
+# Census approval: stateless-replicas-4-task3f
+
+Ruling `census-ruling-stateless-replicas-4-task3f`. 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/activator/statelessrelease.go` `Service.prepareStatelessRelease` | body | unchanged (17) | Task 3F (#511 F11): a begin the record writer refuses (replicas.ErrFenced or ErrInvalid) returns errReplicaObservationBehind (SR-4-C55) instead of ErrReplicaReleaseUnknown; nothing ran either way, and a begin with any other error keeps the unknown answer. Error mapping only; same calls, no read or write added. |
+| `internal/activator/stateless.go` `Service.prepareStateless` | sites | +whole:Route ×6 | Task 3F (#511 F11): a hold's pinned wake that carries the swap's preparation, when the row it re-read differs from the row the swap prepared on, moves the preparation onto the wake's row only after the prepared row passes statelessCurrent against the registry, and then checks the wake's row with statelessCurrent too; a launch field that differs still refuses. The added sites are whole-Route comparisons and copies of the handed and prepared routes (no new reader). No store read or write added; no new authority. |
+
+Envelopes re-pinned: `internal/activator`.
+
+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/activator/statelessrelease.go` `Service.prepareStatelessRelease`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-stateless-replicas-4-task1;basis=The former PrepareStatelessRelease body. R9: adopts the record's attempt for this lifetime and target in every phase before any coordination; otherwise acquires the term first and only then selects the ID (R1); a begin carries RetryOf only when consuming a durable retry. Same calls (ObserveReplicaRelease, coordinator, escrow initializer, actEntry, runReleaseAdmitted); same gates, proof and SafeUntil checks; no new store read or writer.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2: refuses with provision.ErrReplicaSwitchOpen (SR-4-C31) before term acquisition when the observed record already has an unresolved copy-switch permit, instead of a begin the writer refuses and that read as an unknown result. Refusal only; same calls, no read added.
+- `internal/activator/stateless.go` `Service.prepareStateless`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Capture RecordFacts from the existing record source, obtain the durable FailureBook deploy ID, and call Task 2 PrepareStatelessRelease with the canonical verdict/digest carrier. Carry a successful attempt through its hold only after another current-record check; no serving lease or polling loop. Fix 3a round 1 I2: preparation uses reconcile observations and records the successful deploy ID. Carry prepared evidence through hold; fresh backend read must confirm that same released deploy before web runs.;rev3=census-ruling-stateless-failed-release-held;basis=For recovery onto a different installed version's exact committed good version and artifact digest, retain recovery evidence without selecting or writing another deploy. Adds the existing committedGood registry read, with its route and incarnation check. Canonical storage declaration and observed lifetime gates remain.;rev3=census-ruling-stateless-replicas-4-task1;basis=R1: no longer calls ReplicaDeployID before preparation; hands the same a.ReplicaDeployID selector to prepareStatelessRelease, which calls it only after coordinator term acquisition. The ObservedReplicaRelease call stays as a validity check. Same read sites; no new read, write or authority.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2 (D4): for a set row, prepares the record baseline with no release, and refuses a build the row Version does not name before any release; reads the route it is handed (FleetBoxes, Version). No store read or write added.;rev3=census-ruling-stateless-replicas-4-task2-fix1;basis=Task 2 fix round 1: for a set row, a build its pointer does not name starts only as the record baseline or the committed permitted target, the latter adopted through prepareStatelessRelease durable path (never a new attempt); a named build, a rollback included, takes the release path. The added reads are the handed route (FleetBoxes, Version) and a copy of it with Stateless set for the adoption, as the release path already builds. No store read or write added.;rev3=census-ruling-stateless-replicas-4-task2-fix2;basis=Task 2 fix round 2: for a set row the no-release start is decided per box from the record (this box baseline, or its permitted target adopted through the durable path), whatever the pointer says; only a build that is neither and that the pointer names begins a new attempt. Same reads (the handed route and its copy); no store read or write added.;rev3=census-ruling-stateless-replicas-4-task2-fix3;basis=Task 2 fix round 3: this box baseline is checked before the adopt path, so a completed box restarts on the target while a retry is requested; for the passed target it calls the existing escrow initializer (prepareStatelessEscrow) that the adopt path ran, with the same route and identity. No new reader; no record write.
+
+Seal: `bd25367161555e8a9c5b0df079ad2d8eb648ebaeae3f407e6c638f2f7f01605b` → `58ffb8f3ce4de8ed75c9c52c33c72046f418638bb8148335c6a76e3a81b7b50d`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-stateless-replicas-4-task3f.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md
index 03821e689..5b35f1653 100644
--- a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md
+++ b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md
@@ -126,3 +126,4 @@ copy too. Internal wire enums are not an excuse to expose unreviewed text.
| SR-4-C52 | docs/site/cli.md | An instance with more than one copy keeps a separate page cache on each copy's box. A purge clears only the cache of the copy that sent it, so another copy can serve its own saved page until it expires or that copy purges it too. | pending (added by Plan 4 Task 3 per ruling D6; awaiting Paul's copy review) |
| SR-4-C53 | docs/site/cli.md | An app that runs more than one copy of an instance refuses `carlos restart --app` and `--environment`, because every copy would restart at the same time. Deploy a new build instead: its copies switch one box at a time. | pending (added by Plan 4 Task 3 for the F2 restart refusal; awaiting Paul's copy review) |
| SR-4-C54 | internal/console/templates/app_overview.html | <unknown> of <desired> copies unknown; <running> known running | pending (added by Plan 4 Task 3 fix round 1: the overview count when any copy has no live reading, so an unread copy is never counted as stopped; awaiting Paul's copy review) |
+| SR-4-C55 | internal/activator/statelessrelease.go | this box has not yet read the deploy's latest state, so nothing ran. it tries again after its next read | pending (added by Plan 4 Task 3F for F11: a release attempt whose begin the record refused, which ran nothing and was logged as an unknown result; awaiting Paul's copy review) |
diff --git a/internal/activator/stateless.go b/internal/activator/stateless.go
index 07464b72b..2933b6a0f 100644
--- a/internal/activator/stateless.go
+++ b/internal/activator/stateless.go
@@ -386,6 +386,25 @@ func (a *Service) prepareStateless(ctx context.Context, rt registry.Route, id re
if err := a.statelessCurrent(observed, prepared.route); err != nil {
return ctx, err
}
+ if rt == prepared.route {
+ return observed, nil
+ }
+ // A hold's pinned wake (#511 F11): the swap prepared, and ran, the
+ // release on the row it read before the incumbent stopped. The wake
+ // re-reads the row after that stop, and the release's own
+ // build-state write (and the stop's next-due write, when it changes
+ // the time) lands in between. The prepared row still matches the
+ // registry in every field statelessCurrent checks, so the
+ // preparation moves onto the row this wake read, and that row is
+ // checked the same way. Every later gate, the exec's fresh record
+ // read included, then reads one row.
+ rebased := *prepared
+ rebased.route = rt
+ observed = context.WithValue(observed, statelessRecordKey{}, rt)
+ observed = context.WithValue(observed, statelessPreparedKey{}, &rebased)
+ if err := a.statelessCurrent(observed, rt); err != nil {
+ return ctx, err
+ }
return observed, nil
}
diff --git a/internal/activator/stateless_holdwake_test.go b/internal/activator/stateless_holdwake_test.go
new file mode 100644
index 000000000..3dc226d0b
--- /dev/null
+++ b/internal/activator/stateless_holdwake_test.go
@@ -0,0 +1,118 @@
+package activator
+
+import (
+ "context"
+ "errors"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/replicas"
+)
+
+// TestStatelessHoldWakeRebasesPreparation is #511 F11 at the activator: a
+// hold's pinned wake carries the preparation its swap made on the row it
+// read before the incumbent stopped. The wake's own re-read differs from it
+// by the columns the release and the stop write (the build state, the next
+// due time), and the wake goes on, on the row it read. A launch field that
+// differs refuses it as before.
+func TestStatelessHoldWakeRebasesPreparation(t *testing.T) {
+ began := testRoute("shop.example.com")
+ began.Account, began.App, began.Runtime, began.Channel = "bab", "shop", registry.RuntimeRootfsV1, "edge"
+ facts, err := RecordFactsOf(provision.Record{Account: began.Account, App: began.App, Host: began.Host, CreatedAt: time.Unix(1, 0)})
+ if err != nil {
+ t.Fatal(err)
+ }
+ id := release.StagedIdentity{Version: "v2"}
+ prepare := func(now registry.Route) (*Service, *statelessPreparation) {
+ t.Helper()
+ a := &Service{Routes: startupRoutes{began.Host: began}}
+ a.cfg.ReplicaRecord = func(registry.Route) (RecordFacts, error) { return facts, nil }
+ observed, err := a.statelessObservation(context.Background(), began, id, "canonical")
+ if err != nil {
+ t.Fatal(err)
+ }
+ observation, _ := observed.Value(replicaObservationKey{}).(replicaObservation)
+ // The incumbent stops and the row moves on before the pinned wake.
+ a.Routes = startupRoutes{now.Host: now}
+ return a, &statelessPreparation{route: began, id: id, digest: "canonical", deployID: "deploy-v2", observation: observation}
+ }
+
+ t.Run("bookkeeping columns", func(t *testing.T) {
+ now := began
+ now.BuildState = `{"known":true,"state":{"last_executed":"v2"}}`
+ now.NextDue = 1
+ a, prepared := prepare(now)
+ ctx, err := a.prepareStateless(carryStatelessPreparation(context.Background(), prepared), now, id, "canonical")
+ if err != nil {
+ t.Fatalf("pinned wake refused: %v", err)
+ }
+ if got, _ := ctx.Value(statelessRecordKey{}).(registry.Route); got != now {
+ t.Fatalf("observed row %+v, want the wake's", got)
+ }
+ rebased, _ := ctx.Value(statelessPreparedKey{}).(*statelessPreparation)
+ if rebased == nil || rebased.route != now || rebased.deployID != prepared.deployID || rebased.observation != prepared.observation {
+ t.Fatalf("preparation %+v", rebased)
+ }
+ if prepared.route != began {
+ t.Fatal("the swap's own preparation was changed")
+ }
+ // The wake's gate and the exec's row checks read the same row.
+ if err := a.statelessCurrent(ctx, now); err != nil {
+ t.Fatalf("gate: %v", err)
+ }
+ })
+
+ for _, tc := range []struct {
+ name string
+ edit func(registry, wake *registry.Route)
+ }{
+ {"registry caps", func(r, w *registry.Route) { r.Caps, w.Caps = "net", "net" }},
+ {"registry channel", func(r, w *registry.Route) { r.Channel, w.Channel = "stable", "stable" }},
+ {"wake row caps", func(_, w *registry.Route) { w.Caps = "net" }},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ now, wake := began, began
+ now.BuildState, wake.BuildState = "moved", "moved"
+ tc.edit(&now, &wake)
+ a, prepared := prepare(now)
+ if _, err := a.prepareStateless(carryStatelessPreparation(context.Background(), prepared), wake, id, "canonical"); !errors.Is(err, ErrFenced) {
+ t.Fatalf("launch change admitted: %v", err)
+ }
+ })
+ }
+}
+
+// TestReplicaReleaseBeginRefusalRanNothing is #511 F11's log: a box whose
+// observation predates a release that passed asks the writer to begin an
+// attempt, and the writer refuses. No release command ran and none began,
+// so the result is not unknown. A begin whose reply is lost keeps the
+// unknown answer it had.
+func TestReplicaReleaseBeginRefusalRanNothing(t *testing.T) {
+ t.Run("stale observation", func(t *testing.T) {
+ r, s := replicaReleaseRig(t)
+ s.d = &replicas.Deploy{ID: "deploy", Incarnation: "life", Term: "term", Target: replicas.Build{Version: r.id.Version, Digest: "canonical-manifest"}, Phase: "released", Revision: 3}
+ r.a.ObserveReplicaRelease = func(context.Context, registry.Route) (replicas.Identity, replicas.Build, *replicas.Deploy, error) {
+ return replicas.Identity{Account: r.rt.Account, App: r.rt.App, Host: r.rt.Host, Incarnation: "life"}, replicas.Build{Version: r.id.Version, Digest: "canonical-manifest"}, nil, nil
+ }
+ err := r.a.PrepareStatelessRelease(context.Background(), r.rt, r.id, "deploy")
+ if !errors.Is(err, errReplicaObservationBehind) || errors.Is(err, ErrReplicaReleaseUnknown) {
+ t.Fatalf("refused begin: %v", err)
+ }
+ if r.b.startCount() != 0 || s.snapshot().Phase != "released" {
+ t.Fatalf("starts=%d record=%+v", r.b.startCount(), s.snapshot())
+ }
+ })
+ t.Run("lost begin reply", func(t *testing.T) {
+ r, s := replicaReleaseRig(t)
+ s.beginHook = func() error { return context.DeadlineExceeded }
+ if err := r.a.PrepareStatelessRelease(context.Background(), r.rt, r.id, "deploy"); !errors.Is(err, ErrReplicaReleaseUnknown) {
+ t.Fatalf("lost begin: %v", err)
+ }
+ if r.b.startCount() != 0 {
+ t.Fatal("ran after a lost begin")
+ }
+ })
+}
diff --git a/internal/activator/statelessrelease.go b/internal/activator/statelessrelease.go
index 745ef4f10..412aed5d4 100644
--- a/internal/activator/statelessrelease.go
+++ b/internal/activator/statelessrelease.go
@@ -16,6 +16,10 @@ import (
var errReplicaReleaseFailed = fmt.Errorf("release: %w", errReleaseNotPassed)
var errReplicaReleaseUnknown = fmt.Errorf("release: %w", ErrReplicaReleaseUnknown)
+// errReplicaObservationBehind is a release attempt whose begin the record's
+// writer refused: nothing ran. copy SR-4-C55 (provisional)
+var errReplicaObservationBehind = errors.New("this box has not yet read the deploy's latest state, so nothing ran. it tries again after its next read")
+
// PrepareStatelessRelease runs one release attempt named deployID. The
// production path is prepareStatelessRelease with the box's ID selector.
func (a *Service) PrepareStatelessRelease(ctx context.Context, rt registry.Route, id release.StagedIdentity, deployID string) error {
@@ -140,6 +144,13 @@ func (a *Service) prepareStatelessRelease(ctx context.Context, rt registry.Route
return deployID, ErrReplicaReleaseUnknown
}
if _, err := change("begin"); err != nil {
+ if errors.Is(err, replicas.ErrFenced) || errors.Is(err, replicas.ErrInvalid) {
+ // The writer refused the begin, so no release command ran and no
+ // attempt began here. Its usual cause is an observation older
+ // than the record: the reconcile index has not yet read a release
+ // that passed (#511 F11). Its result is not unknown.
+ return deployID, errReplicaObservationBehind
+ }
return deployID, ErrReplicaReleaseUnknown
}
// Only this path discards stateful good-build inference. The durable
diff --git a/internal/host/stateless_switch_test.go b/internal/host/stateless_switch_test.go
new file mode 100644
index 000000000..fb2fd5485
--- /dev/null
+++ b/internal/host/stateless_switch_test.go
@@ -0,0 +1,363 @@
+package host
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "fmt"
+ "log"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "path/filepath"
+ "slices"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "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/rollout"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// syncLog is the process log captured for a witness: the activator and
+// the rollout log their lines through the standard logger.
+type syncLog struct {
+ mu sync.Mutex
+ buf bytes.Buffer
+}
+
+func (l *syncLog) Write(p []byte) (int, error) {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ return l.buf.Write(p)
+}
+
+func (l *syncLog) String() string {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+ return l.buf.String()
+}
+
+// switchLease is plannedLease with the safety deadline a stateful
+// rootfs release runs under.
+type switchLease struct{ plannedLease }
+
+func (switchLease) Err() error { return nil }
+func (switchLease) Lost() <-chan struct{} { return nil }
+func (switchLease) SafeUntil() (time.Time, error) { return time.Now().Add(time.Hour), nil }
+
+type switchBackend struct{ *failedReleaseBackend }
+
+func (switchBackend) Acquire(context.Context, registry.Route) (activator.Lease, error) {
+ return switchLease{}, nil
+}
+
+func captureSyncLog(t *testing.T) *syncLog {
+ t.Helper()
+ l := &syncLog{}
+ prevOut, prevFlags := log.Writer(), log.Flags()
+ log.SetOutput(l)
+ t.Cleanup(func() { log.SetOutput(prevOut); log.SetFlags(prevFlags) })
+ return l
+}
+
+// TestStatefulToStatelessSwitchProductionWiring is F11 (#511): an
+// always-on rootfs app on a stateful build A switches to a stateless build
+// C whose release passes, while requests keep arriving. The box writes its
+// build state before every exec (the release's included), as the agent
+// wires it, and its replica record observation is the reconcile pass's
+// index (replicaRecordFacts), which has not yet read the release's
+// committed phase, as on a real box between two passes.
+func TestStatefulToStatelessSwitchProductionWiring(t *testing.T) {
+ statefulToStatelessSwitch(t, false)
+}
+
+// TestStatefulToStatelessFailedReleaseHolds is F11's negative case: B's
+// release fails, so A keeps serving (F10), the rollout holds B and says
+// why, and no wake is refused.
+func TestStatefulToStatelessFailedReleaseHolds(t *testing.T) {
+ statefulToStatelessSwitch(t, true)
+}
+
+func statefulToStatelessSwitch(t *testing.T, fail bool) {
+ prev := activator.GenerationsEnabled()
+ activator.SetGenerations(true)
+ t.Cleanup(func() { activator.SetGenerations(prev) })
+ resetRollout(t)
+ logs := captureSyncLog(t)
+ ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
+ defer cancel()
+ dir := t.TempDir()
+ opt := filepath.Join(dir, "opt")
+ t.Setenv("CARLOS_OPT_DIR", opt)
+ reg, err := registry.Open(filepath.Join(dir, "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer reg.Close()
+ store := release.NewDirStore(filepath.Join(dir, "store"))
+ hibernate := false
+ rec := provision.Record{Hibernate: &hibernate, Schema: 1, Account: "bab", App: "shop", Host: "shop.example.com", Channel: "edge", Runtime: registry.RuntimeRootfsV1, CreatedAt: time.Now().UTC()}
+ if err := provision.CreateRecord(ctx, store, rec); err != nil {
+ t.Fatal(err)
+ }
+ open := func(context.Context) (release.Store, error) { return store, nil }
+ facts := haRecordFacts(open, nil)
+ // The production observation: the reconcile pass's index, filled once
+ // here and not again while the switch runs.
+ index := &provision.LifetimeIndex{}
+ reconcile := func() {
+ t.Helper()
+ cur, err := provision.GetRecord(ctx, store, rec.Account, rec.App, rec.Host)
+ if err != nil {
+ t.Fatal(err)
+ }
+ index.Replace(map[string]provision.Record{rec.Host: *cur})
+ }
+ reconcile()
+ cfg := activator.Config{Bucket: "test", Idle: time.Hour, Record: facts, ReplicaRecord: replicaRecordFacts(index)}
+ eb := &activator.ExecBackend{ServedPools: testSharedPoolEvidence, Cfg: cfg, DataDir: dir, OptDir: opt, RunDirOverride: filepath.Join(dir, "run"), Control: &rootfsWireControl{}, NestedOK: func() error { return nil }, RootfsOK: func(context.Context) error { return nil }, RootfsPlacement: func(context.Context, registry.Route) error { return nil }}
+ be := switchBackend{&failedReleaseBackend{plannedBackend: &plannedBackend{socket: healthySocket(t)}, failedReleaseGates: failedReleaseGates{eb}}}
+ rt := registry.Route{Host: rec.Host, Account: rec.Account, App: rec.App, Kind: "instance", Status: "ready", Channel: rec.Channel, Runtime: rec.Runtime, CreatedAt: rec.CreatedAt.Unix(), Version: "A", DBPath: provision.NestedDBPath(dir, rec.Host), Socket: filepath.Join(eb.RunDirOverride, "instances", provision.InstanceID(rec.Host), "app.sock")}
+ target := "C" // the backend's release of C passes
+ if fail {
+ target = "B" // and B's exits 3
+ }
+ for _, ver := range []string{"A", target} {
+ data := []byte("rootfs " + ver)
+ if err := release.StageArtifact(opt, rec.Account, ver, rec.App, data); err != nil {
+ t.Fatal(err)
+ }
+ path := release.VersionPath(opt, rec.Account, ver, rec.App)
+ digest, err := release.FileSHA256(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ // A is the stateful build; the target declares itself stateless.
+ manifest := release.Manifest{Schema: 1, App: rec.App, Version: ver, Kind: "binary", Stateless: ver != "A", Artifacts: map[string]release.Artifact{release.BoxPlatform(): {File: "image.squashfs", SHA256: digest}}}
+ raw, err := json.Marshal(manifest)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := store.Put(ctx, release.ManifestKey(rec.Account, rec.App, ver), raw, ""); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(path+".manifest.json", raw, 0600); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.MkdirAll(filepath.Dir(rt.Socket), 0755); err != nil {
+ t.Fatal(err)
+ }
+ coordinator := newCoordinatorClient(store, "", "", "box", "")
+ defer closeReplicaCoordinator(coordinator)
+ _, pub, err := release.GenerateKey()
+ if err != nil {
+ t.Fatal(err)
+ }
+ events := &failedReleaseEvents{t: t}
+ svc := activator.New(cfg, be, reg)
+ svc.Routes = reg
+ svc.MarkRootfsSwept()
+ // As the agent wires it: renewed by its own worker, and shared with the
+ // backend's escrow check.
+ coordinator.Start(ctx)
+ svc.Coordinator = coordinator
+ eb.Coordination = coordinator
+ svc.ObserveReplicaRelease = activator.ObservedReplicaRelease
+ svc.StorageDeclaration = storageDeclaration(open)
+ svc.Logs = events
+ // The box's build-state hook: every exec, a release's included, first
+ // writes the build state, and with it the route's build-state column.
+ bs := &buildStates{hibBucket: cfg.Bucket, prefix: func(h string) string { return activator.HibernatePrefix("", h) },
+ storeFor: storesOf(map[string]release.Store{cfg.Bucket: release.NewDirStore(filepath.Join(dir, "hib"))}), reg: reg, optDir: opt, bakeDir: filepath.Join(dir, "bake"), now: time.Now}
+ svc.BeforeExec = buildStateHook(bs, nil)
+ m := armRollout(ctx, overlapEnv(pub), svc, reg, dir, events, open)
+ if m == nil {
+ t.Fatal("rollout did not arm")
+ }
+ defer func() {
+ cleanup, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ svc.Shutdown(cleanup)
+ m.Close(cleanup)
+ }()
+ wait := func(what string, pred func() bool) {
+ t.Helper()
+ deadline := time.Now().Add(25 * time.Second)
+ for time.Now().Before(deadline) {
+ if pred() {
+ return
+ }
+ time.Sleep(10 * time.Millisecond)
+ }
+ t.Fatalf("timed out: %s; builds=%v releases=%v status=%+v\nlog:\n%s", what, be.builds(), be.releaseBuilds(), m.Status(), logs.String())
+ }
+ request := func() (int, string) {
+ row, err := reg.Get(rt.Host)
+ if err != nil || row == nil {
+ return 0, fmt.Sprintf("route: %v", err)
+ }
+ w := httptest.NewRecorder()
+ req := httptest.NewRequest(http.MethodGet, "http://"+rt.Host+"/", nil).WithContext(ctx)
+ svc.ServeHTTP(w, req, *row, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
+ builds := be.builds()
+ if len(builds) == 0 {
+ http.Error(w, "no serving process", http.StatusBadGateway)
+ return
+ }
+ fmt.Fprint(w, builds[len(builds)-1])
+ }))
+ return w.Code, w.Body.String()
+ }
+ if code, body := request(); code != 200 || body != "A" {
+ t.Fatalf("first request: %d %s", code, body)
+ }
+ wait("A good", func() bool { row, _ := reg.Get(rt.Host); return row.GoodVersion == "A" })
+ svc.Start() // always-on: the sweep restarts an instance that is not running
+ // Requests run through the whole switch, as the edge's would.
+ var (
+ reqMu sync.Mutex
+ answers []string
+ )
+ stop := make(chan struct{})
+ done := make(chan struct{})
+ go func() {
+ defer close(done)
+ for {
+ select {
+ case <-stop:
+ return
+ default:
+ }
+ code, body := request()
+ reqMu.Lock()
+ answers = append(answers, fmt.Sprintf("%d %s", code, strings.TrimSpace(body)))
+ reqMu.Unlock()
+ time.Sleep(20 * time.Millisecond)
+ }
+ }()
+ if err := reg.SetVersions(rt.Host, target, ""); err != nil {
+ t.Fatal(err)
+ }
+ rows, err := reg.List()
+ if err != nil {
+ t.Fatal(err)
+ }
+ m.Pass(rows)
+ if fail {
+ wait("B held", func() bool {
+ h := m.Status().Hosts[rt.Host]
+ return h.HeldBy == "B" && h.Reason == status.ReasonRelease
+ })
+ // Past the hold: a later request still answers from A.
+ time.Sleep(500 * time.Millisecond)
+ } else {
+ wait("C serving", func() bool {
+ g, ok := svc.Current(rt.Host)
+ row, _ := reg.Get(rt.Host)
+ return ok && g.Build == "C" && g.Stateless && row.GoodVersion == "C"
+ })
+ }
+ close(stop)
+ <-done
+ code, body := request()
+ reqMu.Lock()
+ got := append(slices.Clone(answers), fmt.Sprintf("%d %s", code, body))
+ reqMu.Unlock()
+ serving := "C"
+ if fail {
+ serving = "A"
+ }
+ for _, a := range got {
+ if strings.Contains(a, "failed to wake") || !strings.HasPrefix(a, "200 ") {
+ t.Errorf("a request during the switch was answered %q", a)
+ }
+ }
+ if last := got[len(got)-1]; last != "200 "+serving {
+ t.Errorf("after the switch: %q, want 200 %s", last, serving)
+ }
+ // The instance's process exits (a crash, an OOM) and the always-on sweep
+ // starts it again. The serving build comes back with no new release.
+ exit := func(build string) {
+ t.Helper()
+ g, ok := svc.Current(rt.Host)
+ if !ok || g.Build != build {
+ t.Fatalf("current: %+v %v, want %s", g, ok, build)
+ }
+ be.mu.Lock()
+ be.procs[g.N].exited.Store(true)
+ be.mu.Unlock()
+ wait(build+" rewoken", func() bool { g2, ok := svc.Current(rt.Host); return ok && g2.N != g.N && g2.Build == build })
+ }
+ if fail {
+ // F10: the failed build's hold keeps A's intent.
+ exit("A")
+ if code, body := request(); code != 200 || body != "A" {
+ t.Errorf("after A's restart: %d %s", code, body)
+ }
+ if got := be.releaseBuilds(); !slices.Equal(got, []string{"A", "B"}) {
+ t.Errorf("releases: %v, want [A B]", got)
+ }
+ if slices.Contains(be.builds(), "B") {
+ t.Errorf("B started: %v", be.builds())
+ }
+ book, err := rollout.OpenFailureBook(dir)
+ if err != nil {
+ t.Fatal(err)
+ }
+ want := "release: " + (&activator.ReleaseError{Build: "B", Exit: 3}).Error()
+ if failure, ok := book.Lookup(rt.Account, rt.App, "B"); !ok || failure.Reason != want {
+ t.Errorf("failure: %+v %v; want %s", failure, ok, want)
+ }
+ if h := m.Status().Hosts[rt.Host]; h.HeldBy != "B" || h.Reason != status.ReasonRelease || h.Serving != "A" {
+ t.Errorf("status: %+v", h)
+ }
+ cur, err := provision.GetRecord(ctx, store, rec.Account, rec.App, rec.Host)
+ if err != nil || cur.ReplicaDeploy == nil || cur.ReplicaDeploy.Phase != "failed" || cur.ReplicaDeploy.Target.Version != "B" {
+ t.Errorf("record: %+v %v", cur, err)
+ }
+ } else {
+ // Still before the reconcile pass reads the passed release: the box's
+ // observation has no attempt, so a rewake may not begin one. It runs
+ // nothing and says so, then starts C once the pass has read it.
+ g, _ := svc.Current(rt.Host)
+ be.mu.Lock()
+ be.procs[g.N].exited.Store(true)
+ be.mu.Unlock()
+ wait("rewake refused", func() bool {
+ return strings.Contains(logs.String(), "has not yet read the deploy's latest state, so nothing ran")
+ })
+ reconcile()
+ wait("C rewoken", func() bool { g2, ok := svc.Current(rt.Host); return ok && g2.N != g.N && g2.Build == "C" })
+ if code, body := request(); code != 200 || body != "C" {
+ t.Errorf("after C's restart: %d %s", code, body)
+ }
+ exit("C")
+ if got := be.releaseBuilds(); !slices.Equal(got, []string{"A", "C"}) {
+ t.Errorf("releases: %v, want [A C]", got)
+ }
+ cur, err := provision.GetRecord(ctx, store, rec.Account, rec.App, rec.Host)
+ if err != nil || cur.ReplicaDeploy == nil || cur.ReplicaDeploy.Phase != "released" || cur.ReplicaDeploy.Target.Version != "C" {
+ t.Errorf("record: %+v %v", cur, err)
+ }
+ }
+ out := logs.String()
+ if strings.Contains(out, activator.ErrReplicaReleaseUnknown.Error()) {
+ t.Errorf("logged the unknown-result line")
+ }
+ if !fail && strings.Contains(out, "abandoned") {
+ t.Errorf("logged an abandoned attempt")
+ }
+ if t.Failed() {
+ t.Logf("answers: %v\nbuilds: %v\nlog:\n%s", got, be.builds(), out)
+ }
+}
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index 5abd155f6..874acc180 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) {
if len(got) < 100 {
t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root)
}
- inventory := statelessReplicas4Task3WriteCensusInventory()
+ inventory := statelessReplicas4Task3FWriteCensusInventory()
problems := append(censusDiff(inventory, got), censusPolicy(inventory)...)
if len(problems) > 0 {
t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n "))
diff --git a/internal/provision/stateless_replicas_4_task3f_census_test.go b/internal/provision/stateless_replicas_4_task3f_census_test.go
new file mode 100644
index 000000000..7878016fe
--- /dev/null
+++ b/internal/provision/stateless_replicas_4_task3f_census_test.go
@@ -0,0 +1,37 @@
+package provision
+
+// statelessReplicas4Task3FWriteCensusInventory is stateless replicas Plan 4
+// Task 3F's review of the record-write census (#511 F11), layered on Task
+// 3's. Self-review only; the independent #280 verdict is the controller's.
+//
+// - prepareStateless: a hold's pinned wake whose re-read row differs from
+// the row its swap prepared on (the release's build-state write and the
+// stop's next-due write land in between) moves the preparation onto the
+// wake's row, after the prepared row passes statelessCurrent and before
+// the wake's row is checked the same way. It writes no record; its
+// record reference is still the statelessRecordKey observation, now
+// also set to the wake's row.
+// - prepareStatelessRelease: a begin the writer refuses reads as
+// errReplicaObservationBehind (SR-4-C55), not as an unknown result. An
+// error mapping only; the same SetRecordReplicaRelease writes through
+// the coordinator client, and its source holds no record-write site of
+// its own.
+// - No new record writer.
+func statelessReplicas4Task3FWriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), statelessReplicas4Task3WriteCensusInventory()...)
+ for _, r := range []censusEntry{
+ {"internal/activator/stateless.go", "Service.prepareStateless", "reference", "key:statelessRecordKey", "c04761ad73532aaa699eb6efcce3b6786dcae5fa4fd6fab6f0768d82df0f51f1"},
+ } {
+ replaced := false
+ for i, e := range entries {
+ if e.File == r.File && e.Unit == r.Unit {
+ entries[i], replaced = r, true
+ break
+ }
+ }
+ if !replaced {
+ entries = append(entries, r)
+ }
+ }
+ return entries
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index e6d29f3c5..fcbd70d36 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -177,3 +177,4 @@ plan14-root-reads-stateless-replicas-4-task2-fix1.tsv 1a0605f79ac62c776bccc1ae8d
plan14-root-reads-stateless-replicas-4-task2-fix2.tsv 5f83de2e018b47543789a8dbe2cccb86b2d644fbe9ee5771e5d621704ae46e0b
plan14-root-reads-stateless-replicas-4-task2-fix3.tsv bd25367161555e8a9c5b0df079ad2d8eb648ebaeae3f407e6c638f2f7f01605b
plan14-root-reads-stateless-replicas-4-task3.tsv bd25367161555e8a9c5b0df079ad2d8eb648ebaeae3f407e6c638f2f7f01605b
+plan14-root-reads-stateless-replicas-4-task3f.tsv 58ffb8f3ce4de8ed75c9c52c33c72046f418638bb8148335c6a76e3a81b7b50d
diff --git a/internal/provision/testdata/plan14-root-reads-stateless-replicas-4-task3f.tsv b/internal/provision/testdata/plan14-root-reads-stateless-replicas-4-task3f.tsv
new file mode 100644
index 000000000..16c23d419
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-stateless-replicas-4-task3f.tsv
@@ -0,0 +1,7 @@
+# Census overlay stateless-replicas-4-task3f, written by census-propose (#369). census-ruling-stateless-replicas-4-task3f, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-stateless-replicas-4-task3f.md.
+# 1 body, 1 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy 16c56489908f62f227bfea6a318d78c839c814c7598c5c9748a71f8be5cfd517 internal/activator/statelessrelease.go Service.prepareStatelessRelease legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-4-task1;basis=The former PrepareStatelessRelease body. R9: adopts the record's attempt for this lifetime and target in every phase before any coordination; otherwise acquires the term first and only then selects the ID (R1); a begin carries RetryOf only when consuming a durable retry. Same calls (ObserveReplicaRelease, coordinator, escrow initializer, actEntry, runReleaseAdmitted); same gates, proof and SafeUntil checks; no new store read or writer.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2: refuses with provision.ErrReplicaSwitchOpen (SR-4-C31) before term acquisition when the observed record already has an unresolved copy-switch permit, instead of a begin the writer refuses and that read as an unknown result. Refusal only; same calls, no read added.;rev3=census-ruling-stateless-replicas-4-task3f;basis=Task 3F (#511 F11): a begin the record writer refuses (replicas.ErrFenced or ErrInvalid) returns errReplicaObservationBehind (SR-4-C55) instead of ErrReplicaReleaseUnknown; nothing ran either way, and a begin with any other error keeps the unknown answer. Error mapping only; same calls, no read or write added. registry:Account@634,registry:App@664,registry:GoodDemand@4427,registry:GoodDigest@4412,registry:GoodVersion@4396,registry:Host@1646,registry:Host@301,registry:Host@4483,registry:Host@4541,registry:Host@4757,registry:Host@4825,registry:Host@691,whole:Route@1093,whole:Route@4550,whole:Route@4557,whole:Route@5109,whole:Route@569 a4951691343e8ca2014832d2a25b6313d457d900dd492c2fcc6e74a61d007877
+@legacy 2b3cbccf8dacf981d010357a9cd2a8612ca825cd94ea5ebb7ea0456295cac135 internal/activator/stateless.go Service.prepareStateless legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Capture RecordFacts from the existing record source, obtain the durable FailureBook deploy ID, and call Task 2 PrepareStatelessRelease with the canonical verdict/digest carrier. Carry a successful attempt through its hold only after another current-record check; no serving lease or polling loop. Fix 3a round 1 I2: preparation uses reconcile observations and records the successful deploy ID. Carry prepared evidence through hold; fresh backend read must confirm that same released deploy before web runs.;rev3=census-ruling-stateless-failed-release-held;basis=For recovery onto a different installed version's exact committed good version and artifact digest, retain recovery evidence without selecting or writing another deploy. Adds the existing committedGood registry read, with its route and incarnation check. Canonical storage declaration and observed lifetime gates remain.;rev3=census-ruling-stateless-replicas-4-task1;basis=R1: no longer calls ReplicaDeployID before preparation; hands the same a.ReplicaDeployID selector to prepareStatelessRelease, which calls it only after coordinator term acquisition. The ObservedReplicaRelease call stays as a validity check. Same read sites; no new read, write or authority.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2 (D4): for a set row, prepares the record baseline with no release, and refuses a build the row Version does not name before any release; reads the route it is handed (FleetBoxes, Version). No store read or write added.;rev3=census-ruling-stateless-replicas-4-task2-fix1;basis=Task 2 fix round 1: for a set row, a build its pointer does not name starts only as the record baseline or the committed permitted target, the latter adopted through prepareStatelessRelease durable path (never a new attempt); a named build, a rollback included, takes the release path. The added reads are the handed route (FleetBoxes, Version) and a copy of it with Stateless set for the adoption, as the release path already builds. No store read or write added.;rev3=census-ruling-stateless-replicas-4-task2-fix2;basis=Task 2 fix round 2: for a set row the no-release start is decided per box from the record (this box baseline, or its permitted target adopted through the durable path), whatever the pointer says; only a build that is neither and that the pointer names begins a new attempt. Same reads (the handed route and its copy); no store read or write added.;rev3=census-ruling-stateless-replicas-4-task2-fix3;basis=Task 2 fix round 3: this box baseline is checked before the adopt path, so a completed box restarts on the target while a retry is requested; for the passed target it calls the existing escrow initializer (prepareStatelessEscrow) that the adopt path ran, with the same route and identity. No new reader; no record write.;rev3=census-ruling-stateless-replicas-4-task3f;basis=Task 3F (#511 F11): a hold's pinned wake that carries the swap's preparation, when the row it re-read differs from the row the swap prepared on, moves the preparation onto the wake's row only after the prepared row passes statelessCurrent against the registry, and then checks the wake's row with statelessCurrent too; a launch field that differs still refuses. The added sites are whole-Route comparisons and copies of the handed and prepared routes (no new reader). No store read or write added; no new authority. registry:Account@284,registry:Account@310,registry:App@324,registry:App@346,registry:Digest@4660,registry:FleetBoxes@1847,registry:FleetBoxes@4303,registry:Host@250,registry:Host@273,registry:Stateless@3385,registry:Stateless@3910,registry:Stateless@4958,registry:Version@4195,registry:Version@4340,registry:Version@4630,whole:Route@1309,whole:Route@1317,whole:Route@1383,whole:Route@1503,whole:Route@1617,whole:Route@1724,whole:Route@259,whole:Route@2758,whole:Route@2765,whole:Route@293,whole:Route@333,whole:Route@3377,whole:Route@3464,whole:Route@3904,whole:Route@3990,whole:Route@4580,whole:Route@4724,whole:Route@4731,whole:Route@4954,whole:Route@5108,whole:Route@5212,whole:Route@5219,whole:Route@540,whole:Route@597,whole:Route@646,whole:Route@661 c04761ad73532aaa699eb6efcce3b6786dcae5fa4fd6fab6f0768d82df0f51f1
+internal/activator/statelessrelease.go Service.prepareStatelessRelease legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-4-task1;basis=The former PrepareStatelessRelease body. R9: adopts the record's attempt for this lifetime and target in every phase before any coordination; otherwise acquires the term first and only then selects the ID (R1); a begin carries RetryOf only when consuming a durable retry. Same calls (ObserveReplicaRelease, coordinator, escrow initializer, actEntry, runReleaseAdmitted); same gates, proof and SafeUntil checks; no new store read or writer.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2: refuses with provision.ErrReplicaSwitchOpen (SR-4-C31) before term acquisition when the observed record already has an unresolved copy-switch permit, instead of a begin the writer refuses and that read as an unknown result. Refusal only; same calls, no read added.;rev3=census-ruling-stateless-replicas-4-task3f;basis=Task 3F (#511 F11): a begin the record writer refuses (replicas.ErrFenced or ErrInvalid) returns errReplicaObservationBehind (SR-4-C55) instead of ErrReplicaReleaseUnknown; nothing ran either way, and a begin with any other error keeps the unknown answer. Error mapping only; same calls, no read or write added. registry:Account@634,registry:App@664,registry:GoodDemand@4427,registry:GoodDigest@4412,registry:GoodVersion@4396,registry:Host@1646,registry:Host@301,registry:Host@4483,registry:Host@4541,registry:Host@4757,registry:Host@4825,registry:Host@691,whole:Route@1093,whole:Route@4550,whole:Route@4557,whole:Route@5109,whole:Route@569 a4951691343e8ca2014832d2a25b6313d457d900dd492c2fcc6e74a61d007877
+internal/activator/stateless.go Service.prepareStateless legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Task 3a: Capture RecordFacts from the existing record source, obtain the durable FailureBook deploy ID, and call Task 2 PrepareStatelessRelease with the canonical verdict/digest carrier. Carry a successful attempt through its hold only after another current-record check; no serving lease or polling loop. Fix 3a round 1 I2: preparation uses reconcile observations and records the successful deploy ID. Carry prepared evidence through hold; fresh backend read must confirm that same released deploy before web runs.;rev3=census-ruling-stateless-failed-release-held;basis=For recovery onto a different installed version's exact committed good version and artifact digest, retain recovery evidence without selecting or writing another deploy. Adds the existing committedGood registry read, with its route and incarnation check. Canonical storage declaration and observed lifetime gates remain.;rev3=census-ruling-stateless-replicas-4-task1;basis=R1: no longer calls ReplicaDeployID before preparation; hands the same a.ReplicaDeployID selector to prepareStatelessRelease, which calls it only after coordinator term acquisition. The ObservedReplicaRelease call stays as a validity check. Same read sites; no new read, write or authority.;rev3=census-ruling-stateless-replicas-4-task2;basis=Task 2 (D4): for a set row, prepares the record baseline with no release, and refuses a build the row Version does not name before any release; reads the route it is handed (FleetBoxes, Version). No store read or write added.;rev3=census-ruling-stateless-replicas-4-task2-fix1;basis=Task 2 fix round 1: for a set row, a build its pointer does not name starts only as the record baseline or the committed permitted target, the latter adopted through prepareStatelessRelease durable path (never a new attempt); a named build, a rollback included, takes the release path. The added reads are the handed route (FleetBoxes, Version) and a copy of it with Stateless set for the adoption, as the release path already builds. No store read or write added.;rev3=census-ruling-stateless-replicas-4-task2-fix2;basis=Task 2 fix round 2: for a set row the no-release start is decided per box from the record (this box baseline, or its permitted target adopted through the durable path), whatever the pointer says; only a build that is neither and that the pointer names begins a new attempt. Same reads (the handed route and its copy); no store read or write added.;rev3=census-ruling-stateless-replicas-4-task2-fix3;basis=Task 2 fix round 3: this box baseline is checked before the adopt path, so a completed box restarts on the target while a retry is requested; for the passed target it calls the existing escrow initializer (prepareStatelessEscrow) that the adopt path ran, with the same route and identity. No new reader; no record write.;rev3=census-ruling-stateless-replicas-4-task3f;basis=Task 3F (#511 F11): a hold's pinned wake that carries the swap's preparation, when the row it re-read differs from the row the swap prepared on, moves the preparation onto the wake's row only after the prepared row passes statelessCurrent against the registry, and then checks the wake's row with statelessCurrent too; a launch field that differs still refuses. The added sites are whole-Route comparisons and copies of the handed and prepared routes (no new reader). No store read or write added; no new authority. registry:Account@284,registry:Account@310,registry:App@324,registry:App@346,registry:Digest@4660,registry:FleetBoxes@1847,registry:FleetBoxes@4303,registry:Host@250,registry:Host@273,registry:Stateless@3385,registry:Stateless@3910,registry:Stateless@4958,registry:Version@4195,registry:Version@4340,registry:Version@4630,whole:Route@1309,whole:Route@1317,whole:Route@1383,whole:Route@1503,whole:Route@1617,whole:Route@1724,whole:Route@259,whole:Route@2758,whole:Route@2765,whole:Route@293,whole:Route@333,whole:Route@3377,whole:Route@3464,whole:Route@3904,whole:Route@3990,whole:Route@4580,whole:Route@4724,whole:Route@4731,whole:Route@4954,whole:Route@5108,whole:Route@5212,whole:Route@5219,whole:Route@540,whole:Route@597,whole:Route@646,whole:Route@661 c04761ad73532aaa699eb6efcce3b6786dcae5fa4fd6fab6f0768d82df0f51f1
+@coverage internal/activator 94ecfebefb3782e7de98f0d11e8012f4dae6392ac5c944cae37a1424cb672123