feat: coordinate stateless release and secret work
Add the provider-neutral coordinator contracts, fenced lease decisions and typed record coordinator writer. Protect coordination and deploy fields from unrelated record mutations, with CAS race and compatibility coverage. This is partial Task 2 progress: durable release transitions, fleet API adapters, runtime authority handling and rollout integration still need implementation before the plan can land.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-proposal-stateless-replicas-1.md+7 −3internal/provision/plan9_b8_census_test.go+2 −2internal/provision/provision.go+3 −0internal/provision/record_sequence.go+3 −0internal/provision/replicacoordinator.go+65 −0internal/provision/replicacoordinator_test.go+194 −0internal/provision/stateless_replicas_census_test.go+24 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv+6 −1internal/replicas/coordinator.go+52 −0internal/replicas/coordinator_test.go+42 −0internal/replicas/types.go+73 −0
Intent
<task-notification> <task-id>b7x8mykts</task-id> <tool-use-id>toolu_01YNR2XiES3ewcjaNYQEDSMK</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/412bbef6-9468-4e8d-b9fe-5343bad21de8/tasks/b7x8mykts.output</output-file> <status>completed</status> <summary>Background command "Wait for Task 1 context round" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a07c05a0763a8696a</task-id> <tool-use-id>toolu_016jgcixTzgFGMqyQYVo5x4p</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/412bbef6-9468-4e8d-b9fe-5343bad21de8/tasks/a07c05a0763a8696a.output</output-file> <status>completed</status> <summary>Agent "Review Task 1 (spec + quality)" 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>### Spec Compliance - ✅ Spec compliant. All four named tests exist, and the interfaces match the brief: `Manifest.Stateless` (`stateless,omitempty`), `ValidateStateless`, `CanonicalStateless`, `CanonicalManifestDigest`, `shipStatelessRefusal`, and both floor constants pinned at v0.34.0 / v0.35.0. - **Binary path:** `--stateless` reaches direct and API ship. - **Rootfs path:** it reaches direct ship, API ship and `--check`. - **Echo:** the console echoes `stateless`, and the client refuses a missing echo. - **Version conflicts:** the console (binary and rootfs) and `claimRawShip`/`claimRawShipSpooled` refuse a changed declaration on an existing version. - **Static:** refused in the CLI, at the console door and in `validateManifest`. - **Copy:** C01, C02, C03, C09, C10 and C13 equal the deck's text column. I checked the deck rows against `ship_stateless.go:12-13`, `internal/release/stateless.go:12-13` and `docs/site/cli.md:358-360`. - **`internal/release/rootfs.go`:** not touched. The report's reason (one shared `Manifest`/`validateManifest` path) is plausible, and `TestStatelessRootfsCompatibility` covers rootfs staging. - ⚠️ Cannot verify from the diff: - An older box or console that predates the field ignores `stateless` and runs the release with SQLite. The floor and refusal for that (SR-1-C08) belong to later tasks. - `CanonicalStateless` and `CanonicalManifestDigest` have no callers yet, so how they are wired in is unverified. - The report's claim that the provision census passes; I did not re-run it. ### Strengths - `CanonicalStateless` returns an error when evidence is missing, unreadable or mismatched. It does not quietly return stateful, which is what spec §6.1 requires. - Unlike `CanonicalDemand`, it checks the retained file (`VerifyStaged`) and also the canonical artifact digest. - `TestCanonicalStatelessRefusesUnverifiedEvidence` covers a missing store, an unreadable store, a wrong digest, a missing path, and retained bytes that differ from the canonical artifact. - `CanonicalManifestDigest` hashes the exact stored bytes rather than re-marshalling them. - Legacy wire and manifest bytes stay unchanged. Every new field is omitempty, and the client checks the echo only when it sent `true`, so older consoles keep working for ordinary ships. - The stateless `--check` is thorough: - it skips the data volume, skips the prepare container and omits the data mount; - it deletes even a `CARLOS_DB` the user supplied; - mount indexing stays correct when only the run volume exists (`volumeMount(0, checkRunDir)`); - the legacy argv order (data, run, probe) is kept. - `TestStatelessCheckCreatesNoDatabase` drives the fake runtime from start to finish and checks cleanup. - The `checkStorageDeclaration` read in `internal/release/stateless.go:23` handles "not found" correctly. I checked the named risk that an S3 miss might not match `os.ErrNotExist`: `GetQualified` keeps the wrap (`%w`), and the `Store` contract requires a wrapped `os.ErrNotExist` (`store.go:45`). ### Issues #### Critical (Must Fix) None. #### Important (Should Fix) None. #### Minor (Nice to Have) 1. **`ship_check.go:497` gives wrong advice in a stateless check.** - The read-only failure message tells the user to "write under /data/instances/… or /tmp". A stateless check no longer mounts that path, so following the advice fails again. - Fix: branch on `c.b.stateless` and name only `/tmp` (or the run dir). That needs a new reviewed copy row; alternatively, record it for the task that defines the stateless instance directory on a box. 2. **`internal/console/apiship_rootfs.go:706` takes `stateless ...bool` as a variadic.** That is a hidden optional parameter, and both callers always pass it. The echo is also written inline three times (`apicli.go:562-564`, `586-588`, and inside `rootfsShipAnswer`), while the neighbouring fields use `addSwapEcho`/`addAssetsEcho`. Fix: make it a plain `bool` parameter and add an `addStatelessEcho(body, bool)` helper. 3. **`internal/release/stateless_test.go:1113-1116`: the immutable-version conflict assertion is weak.** It only checks `err == nil`, and the manifest `putImmutable` conflict would fail that ship anyway. Removing `checkStorageDeclaration` would therefore still pass. Fix: assert `errors.Is(err, ErrStorageDeclarationConflict)`. The console tests have the same gap: they check for a 409 but not the message. 4. **`cli.go:280`: the `usage` string lists `--swap`, `--assets` and the other flags but not `--stateless`.** 5. **`docs/site/cli.md:358-360`: the two stateless paragraphs sit before the section's own first sentence, "Publishes a release."** A reader meets a niche option before learning what the command does. Move them below the general description, keeping the text verbatim. 6. **`approved_stateless_replicas_copy_test.go:203` patches the deck before parsing.** Rewriting `"\n\n| SR-"` into `"\n| SR-"` works around the shared parser's table context, which is fragile. It is acceptable for test-only code, but a comment pointing at the deck layout it depends on, or a parser fix, would be better. 7. **`CanonicalStateless` fixes the platform to the package variable `adoptPlatform`** (`stateless.go:57`), where `CanonicalDemand` takes `platform` as a parameter. The brief mandated this signature, so it is fine on a box. Keep it in mind if the console ever calls this function. 8. **Verification gaps in the report:** - The targeted `-race` run was not repeated after the final argv-order fix. - The commit printed a `packed-refs.lock` contention warning (environment noise, not code). - The `TestPlan14GenerationPinsPrivateMount` failure (permission denied on a `/usr/bin` mount) and the `TestRunOnBehalfOfShape` timeout have no link to this diff. None of the changed functions touches mount proofs or on-behalf-of runs. ### Census - **`cli.go` `runShip`: approve.** It parses one boolean flag and carries it into the manifest and API meta. The CLI runs as the person, and there is no new file read: the read sites are still the two `ReadFile`s. - **`ship_check.go` `rootfsCheck.runArgs`: approve.** The check only gets narrower: the data-volume mount is dropped for stateless releases, and the run volume and probe mounts are unchanged. It runs on the person's machine, opens nothing new, and weakens no check. - **Envelope `.`: approve.** The new code is `shipStatelessRefusal` (a pure kind check), `checkStatelessEcho` (JSON decode of the console response), and the `--check` volume, prepare and env changes, all of which subtract. Nothing new is opened or run, and no root reach is added. - **Envelope `internal/release`: approve.** - `checkStorageDeclaration` reads the bucket manifest at a key built from the already-validated app and version, the same key `putImmutable` writes. - `CanonicalManifestDigest` reads the bucket only. - `CanonicalStateless` hashes `id.StagedPath` through the existing `VerifyStaged` (`FileSHA256Cached`), the same retained root-staged path that `CanonicalDemand` already hashes. - None of these has a box caller yet. The future caller must pass a root-staged retained identity, never a path a tenant names. - `ValidateStateless` inside `validateManifest` only adds a refusal. ### Assessment **Task quality:** Approved **Reasoning:** The declaration works on every ship and manifest path the brief names. Unverifiable evidence is refused rather than treated as stateful, legacy bytes are unchanged, and the copy matches the deck exactly. The remaining items are minor polish: misleading check advice, a variadic parameter, and one weak conflict assertion.</result> <usage><subagent_tokens>99455</subagent_tokens><tool_uses>6</tool_uses><duration_ms>120824</duration_ms></usage> </task-notification>
Attributed to this commit: 10.6 g CO₂e (1,220,063 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on stateless-replicas-1-runtime, 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-1.md b/docs/superpowers/notes/census-proposal-stateless-replicas-1.md| index 3a1417af6..c1efa9a07 100644 |
| --- a/docs/superpowers/notes/census-proposal-stateless-replicas-1.md |
| +++ b/docs/superpowers/notes/census-proposal-stateless-replicas-1.md |
| @@ -1,13 +1,13 @@ |
| # Census approval: stateless-replicas-1 |
| -Ruling `census-ruling-stateless-replicas-1`. 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). |
| +Ruling `census-ruling-stateless-replicas-1`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| | `cli.go` `runShip` | body | unchanged (2) | Carry --stateless into binary/API and rootfs ship options; same two read sites, no new read. | |
| | `ship_check.go` `rootfsCheck.runArgs` | body | unchanged (2) | Stateless local checks mount only the run volume and omit the database mount; same probe read, no new read. | |
| -Envelopes re-pinned: `.`, `internal/release`. |
| +Envelopes re-pinned: `.`, `internal/provision`, `internal/release`, `internal/replicas`. |
| 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. |
| @@ -16,6 +16,10 @@ Recorded dispositions, which each change must still satisfy: |
| - `cli.go` `runShip`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-1;basis=rootfs Plan 1 Task 9: takes --rootfs, --processes, --hibernate, --jit and --check and hands a rootfs ship to runShipRootfs (ship_rootfs.go) before the binary path; the --notes-file ReadFile moved into shipNoteText (its own row, the same read of the file the person named) and the direct-mode version mint into mintDirectVersion; one read site fewer, none added; Task 12: the --hibernate flag help is RFS-1-C32's new text, the same reads;rev3=census-ruling-edge-asset-cache-1;basis=takes --assets (repeatable), checks the folders with checkShipAssets (release.ValidAssetPaths; refused on a static site) before the mode split, carries them into the API meta (sess.shipAssets) and the direct-mode manifest (shipAssetsBlock), and passes them to runShipRootfs (rootfsShipOpts.assets), which runs the same check and carries them the same two ways; after a direct-mode ship has stored a release declaring folders, directShipAssetGens runs the console ship door's backfill (provision.MintMissingAssetGens: lists the app's record keys and gives each record without an asset generation one, a CAS write in the deployment bucket as the person running the CLI) and fails naming any record it could not mint; read sites unchanged (2), none added;rev3=census-ruling-rootfs-apps-4;basis=adds the repeatable --env flag and refuses it before anything else unless --check is given (shipEnvRefusal, parseShipCheckEnv); the parsed values go into rootfsShipOpts.checkEnv. --env values reach the check's local container runtime as -e argv only, never root, never a box. No read added; read sites unchanged (2). |
| - `ship_check.go` `rootfsCheck.runArgs`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-1;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (rootfs Plan 1), builds the docker or podman run argv for one check container; the scanner matches the word Command, here a field of release.Process (a process's argv), not os/exec; reads no file; decides nothing for root;rev3=census-ruling-rootfs-check-volumes;basis=R2 P1: the data and run volume mounts (-v) now carry :nocopy through rootfsCheck.volumeMount, so Docker and Podman never fill an empty check volume from the image directory at the mount point (which would reset the prepared owner and mode); same volumes, same paths, same probe mount, nothing else in the argv changed. Runs on the person's machine as the person; no box unit; no read added. |
| -Seal: `5f805400717bad7726bd9d62744b8103a40eb5f5823b0ab7c960a5c0965cb3bc` → `cb000550f056e23ae31351912eae687bd0d7f7beb9108657246faeb44626cfb7`. |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `internal/replicas/coordinator.go:ChangeCoordinator`: reads +file:Read; written legacy, accepted-legacy, frozen |
| + |
| +Seal: `5f805400717bad7726bd9d62744b8103a40eb5f5823b0ab7c960a5c0965cb3bc` → `09734aa86f42e64d772722a19bb0a6aed7519e7cccfb7b18320b5855b0b4bb11`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go| index 5fd42a764..b8d25cd0a 100644 |
| --- a/internal/provision/plan9_b8_census_test.go |
| +++ b/internal/provision/plan9_b8_census_test.go |
| @@ -53,7 +53,7 @@ var censusMethods = map[string]bool{ |
| // typed-record-writer touchpoint. Keep these names aligned with the APIs above. |
| var ( |
| censusKeySuffixes = []string{"recordkey", "recordsprefix", "sidecarsprefix", "sidecarkey", "sidecarmanifestkey", "writerecord", "sequencedrecord"} |
| - censusKeyExact = map[string]bool{"createrecord": true, "updaterecord": true, "setrecordregion": true, "setrecordmove": true, "setrecordrun": true, "setrecordinteractive": true, "setrecordseed": true, "setrecordfleetbox": true, "setrecordassetgen": true, "mintrecordassetgen": true, "createsidecarrecord": true, "claimrawupdaterecord": true} |
| + censusKeyExact = map[string]bool{"createrecord": true, "updaterecord": true, "setrecordregion": true, "setrecordmove": true, "setrecordrun": true, "setrecordinteractive": true, "setrecordseed": true, "setrecordfleetbox": true, "setrecordcoordinator": true, "setrecordassetgen": true, "mintrecordassetgen": true, "createsidecarrecord": true, "claimrawupdaterecord": true} |
| censusLitWords = []string{"instances", "sidecars"} |
| ) |
| @@ -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 := consoleFiestaWriteCensusInventory() |
| + inventory := statelessReplicasWriteCensusInventory() |
| 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/provision.go b/internal/provision/provision.go| index db6152035..aee65eb33 100644 |
| --- a/internal/provision/provision.go |
| +++ b/internal/provision/provision.go |
| @@ -30,6 +30,7 @@ import ( |
| "github.com/carlosframework/platform/internal/ratelimit" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/replicas" |
| "golang.org/x/crypto/bcrypt" |
| ) |
| @@ -39,6 +40,8 @@ import ( |
| // Account vs the key's segments); GetRecord and ListRecords enforce that, a |
| // record that lies about identity is never guessed at (design §3.2). |
| type Record struct { |
| + Coordinator *replicas.Coordinator `json:"coordinator,omitempty"` |
| + ReplicaDeploy *replicas.Deploy `json:"replica_deploy,omitempty"` |
| // RecordSeq is advanced by every record writer once present; absent is legacy zero. |
| RecordSeq uint64 `json:"record_seq,omitempty"` |
| Acquisition string `json:"acq,omitempty"` |
diff --git a/internal/provision/record_sequence.go b/internal/provision/record_sequence.go| index b97bffeed..e5c5ca584 100644 |
| --- a/internal/provision/record_sequence.go |
| +++ b/internal/provision/record_sequence.go |
| @@ -140,6 +140,9 @@ func WriteRecord(ctx context.Context, s release.Store, key string, before, body |
| if err != nil { |
| return "", 0, err |
| } |
| + if err := replicaFieldsFixed(ctx, before, body); err != nil { |
| + return "", 0, err |
| + } |
| if err := runtimeFixed(before, body); err != nil { |
| return "", 0, err |
| } |
diff --git a/internal/provision/replicacoordinator.go b/internal/provision/replicacoordinator.go| new file mode 100644 |
| index 000000000..9db43f20e |
| --- /dev/null |
| +++ b/internal/provision/replicacoordinator.go |
| @@ -0,0 +1,65 @@ |
| +package provision |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "reflect" |
| + "strings" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/replicas" |
| +) |
| + |
| +type replicaWriteKey struct{} |
| + |
| +func replicaIdentity(rec *Record, id replicas.Identity) error { |
| + incarnation, err := Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt) |
| + if err != nil || rec.Retired || id.Account != rec.Account || id.App != rec.App || id.Host != rec.Host || id.Incarnation != incarnation { |
| + return replicas.ErrFenced |
| + } |
| + return nil |
| +} |
| + |
| +func SetRecordCoordinator(ctx context.Context, s release.Store, id replicas.Identity, change replicas.CoordinatorChange, now time.Time) (*Record, error) { |
| + started := time.Now() |
| + var result *Record |
| + err := release.WithAppMutation(ctx, s, id.Account, id.App, "provision.SetRecordCoordinator", func(ctx context.Context) error { |
| + var err error |
| + ctx = context.WithValue(ctx, replicaWriteKey{}, "coordinator") |
| + result, err = updateRecord(ctx, s, id.Account, id.App, id.Host, func(rec *Record) error { |
| + if err := replicaIdentity(rec, id); err != nil { |
| + return err |
| + } |
| + if (strings.HasPrefix(rec.Region, "fleet/") && rec.FleetBox == "") || (rec.FleetBox != "" && rec.FleetBox != change.Box) { |
| + return replicas.ErrFenced |
| + } |
| + next, err := replicas.ChangeCoordinator(rec.Coordinator, change, now.Add(time.Since(started))) |
| + if err != nil { |
| + return err |
| + } |
| + rec.Coordinator = &next |
| + return nil |
| + }) |
| + return err |
| + }) |
| + return result, err |
| +} |
| + |
| +func replicaFieldsFixed(ctx context.Context, before, body []byte) error { |
| + var old, next struct { |
| + Coordinator *replicas.Coordinator `json:"coordinator"` |
| + ReplicaDeploy *replicas.Deploy `json:"replica_deploy"` |
| + } |
| + if json.Unmarshal(before, &old) != nil || json.Unmarshal(body, &next) != nil { |
| + return ErrRecordSequence |
| + } |
| + field, _ := ctx.Value(replicaWriteKey{}).(string) |
| + if field != "coordinator" && !reflect.DeepEqual(old.Coordinator, next.Coordinator) { |
| + return replicas.ErrFenced |
| + } |
| + if field != "replica_deploy" && !reflect.DeepEqual(old.ReplicaDeploy, next.ReplicaDeploy) { |
| + return replicas.ErrFenced |
| + } |
| + return nil |
| +} |
diff --git a/internal/provision/replicacoordinator_test.go b/internal/provision/replicacoordinator_test.go| new file mode 100644 |
| index 000000000..477b248d1 |
| --- /dev/null |
| +++ b/internal/provision/replicacoordinator_test.go |
| @@ -0,0 +1,194 @@ |
| +package provision |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/release" |
| + "github.com/carlosframework/platform/internal/replicas" |
| +) |
| + |
| +func replicaFixture(t *testing.T) (context.Context, replicas.Identity) { |
| + t.Helper() |
| + return context.Background(), replicas.Identity{Account: "acme", App: "shop", Host: "web.shop.example.com"} |
| +} |
| + |
| +func TestCoordinatorCASRechecksLifetimeAndExpiry(t *testing.T) { |
| + ctx, id := replicaFixture(t) |
| + s, rec := fleetBoxFixture(t) |
| + id.Incarnation, _ = Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt) |
| + if err := SetRecordFleetBox(ctx, s, id.Account, id.App, id.Host, FleetBoxExpect{Region: rec.Region, CreatedAt: rec.CreatedAt}, "local", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + now := time.Now() |
| + got, err := SetRecordCoordinator(ctx, s, id, replicas.CoordinatorChange{Op: "acquire", Box: "local", BootID: "boot-a"}, now) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + lease := *got.Coordinator |
| + for _, op := range []string{"renew", "release"} { |
| + change := replicas.CoordinatorChange{Op: op, Term: lease.Term, Box: lease.Box, BootID: lease.BootID} |
| + stale := id |
| + stale.Incarnation = "recreated" |
| + if _, err := SetRecordCoordinator(ctx, s, stale, change, now); err == nil { |
| + t.Fatal("stale lifetime accepted") |
| + } |
| + change.BootID = "boot-b" |
| + if _, err := SetRecordCoordinator(ctx, s, id, change, now); err == nil { |
| + t.Fatal("new boot accepted") |
| + } |
| + change.BootID = lease.BootID |
| + if _, err := SetRecordCoordinator(ctx, s, id, change, lease.ExpiresAt); err == nil { |
| + t.Fatal("expired authority accepted") |
| + } |
| + } |
| +} |
| + |
| +func TestCoordinatorRequiresAssignment(t *testing.T) { |
| + ctx, id := replicaFixture(t) |
| + s, rec := fleetBoxFixture(t) |
| + id.Incarnation, _ = Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt) |
| + change := replicas.CoordinatorChange{Op: "acquire", Box: "local", BootID: "boot-a"} |
| + if _, err := SetRecordCoordinator(ctx, s, id, change, time.Now()); err == nil { |
| + t.Fatal("unassigned fleet instance acquired") |
| + } |
| + if err := SetRecordFleetBox(ctx, s, id.Account, id.App, id.Host, FleetBoxExpect{Region: rec.Region, CreatedAt: rec.CreatedAt}, "other", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := SetRecordCoordinator(ctx, s, id, change, time.Now()); err == nil { |
| + t.Fatal("wrong assigned box acquired") |
| + } |
| +} |
| + |
| +func TestCoordinatorUnrelatedWritersPreserveFields(t *testing.T) { |
| + ctx, id := replicaFixture(t) |
| + s, rec := fleetBoxFixture(t) |
| + id.Incarnation, _ = Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt) |
| + if err := SetRecordFleetBox(ctx, s, id.Account, id.App, id.Host, FleetBoxExpect{Region: rec.Region, CreatedAt: rec.CreatedAt}, "local", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + got, err := SetRecordCoordinator(ctx, s, id, replicas.CoordinatorChange{Op: "acquire", Box: "local", BootID: "boot-a"}, time.Now()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := updateRecord(ctx, s, id.Account, id.App, id.Host, func(r *Record) error { r.Coordinator = nil; return nil }); err == nil { |
| + t.Fatal("ordinary writer erased coordinator") |
| + } |
| + before := *got.Coordinator |
| + if _, err := updateRecord(ctx, s, id.Account, id.App, id.Host, func(r *Record) error { r.Coordinator.Term = "spoofed"; return nil }); err == nil { |
| + t.Fatal("ordinary writer replaced term") |
| + } |
| + current := fleetBoxGet(t, s) |
| + if current.Coordinator.Term != before.Term || current.Coordinator.Box != before.Box || current.Coordinator.BootID != before.BootID || !current.Coordinator.ExpiresAt.Equal(before.ExpiresAt) { |
| + t.Fatal("refused writer changed record") |
| + } |
| +} |
| + |
| +type replicaConflictStore struct { |
| + release.Store |
| + hook func(context.Context, string, []byte, string) |
| +} |
| + |
| +func (s *replicaConflictStore) Put(ctx context.Context, key string, body []byte, etag string) (string, error) { |
| + if s.hook != nil { |
| + hook := s.hook |
| + s.hook = nil |
| + hook(ctx, key, body, etag) |
| + return "", release.ErrCASConflict |
| + } |
| + return s.Store.Put(ctx, key, body, etag) |
| +} |
| + |
| +func TestCoordinatorCASRetryRejudgesRecord(t *testing.T) { |
| + for _, kind := range []string{"expiry", "lifetime", "boot", "assignment"} { |
| + t.Run(kind, func(t *testing.T) { |
| + ctx, id := replicaFixture(t) |
| + base, rec := fleetBoxFixture(t) |
| + id.Incarnation, _ = Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt) |
| + if err := SetRecordFleetBox(ctx, base, id.Account, id.App, id.Host, FleetBoxExpect{Region: rec.Region, CreatedAt: rec.CreatedAt}, "local", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + now := time.Now() |
| + got, err := SetRecordCoordinator(ctx, base, id, replicas.CoordinatorChange{Op: "acquire", Box: "local", BootID: "boot-a"}, now) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + s := &replicaConflictStore{Store: base} |
| + var raced []byte |
| + s.hook = func(ctx context.Context, key string, body []byte, etag string) { |
| + raw, tag, err := base.Get(ctx, key) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var current Record |
| + if err := json.Unmarshal(raw, ¤t); err != nil { |
| + t.Fatal(err) |
| + } |
| + switch kind { |
| + case "expiry": |
| + current.Coordinator.ExpiresAt = now.Add(-time.Second) |
| + case "lifetime": |
| + current.CreatedAt = current.CreatedAt.Add(time.Second) |
| + case "boot": |
| + current.Coordinator.BootID = "boot-b" |
| + case "assignment": |
| + current.FleetBox = "other" |
| + } |
| + raced, err = json.Marshal(current) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := base.Put(ctx, key, raced, tag); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if _, err := SetRecordCoordinator(ctx, s, id, replicas.CoordinatorChange{Op: "renew", Term: got.Coordinator.Term, Box: "local", BootID: "boot-a"}, now); err == nil { |
| + t.Fatal("CAS retry revived fenced authority") |
| + } |
| + raw, _, err := base.Get(ctx, RecordKey(id.Account, id.App, id.Host)) |
| + if err != nil || string(raw) != string(raced) { |
| + t.Fatalf("fenced retry wrote: %v", err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestCoordinatorPreservesDurableDeploy(t *testing.T) { |
| + ctx, id := replicaFixture(t) |
| + s, rec := fleetBoxFixture(t) |
| + id.Incarnation, _ = Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt) |
| + rec.ReplicaDeploy = &replicas.Deploy{ID: "deploy-a", Incarnation: id.Incarnation, Target: replicas.Build{Version: "v1", Digest: "digest"}, Previous: replicas.Build{Version: "v0", Digest: "previous"}, Phase: "released", Term: "old-term", Order: []string{"local"}, Completed: []string{"local"}, ActiveBox: "local", Revision: 4} |
| + rec.FleetBox = "local" |
| + key := RecordKey(id.Account, id.App, id.Host) |
| + _, tag, err := s.Get(ctx, key) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, err := json.Marshal(rec) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := s.Put(ctx, key, raw, tag); err != nil { |
| + t.Fatal(err) |
| + } |
| + got, err := SetRecordCoordinator(ctx, s, id, replicas.CoordinatorChange{Op: "acquire", Box: "local", BootID: "boot-a"}, time.Now()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + want, _ := json.Marshal(rec.ReplicaDeploy) |
| + actual, _ := json.Marshal(got.ReplicaDeploy) |
| + if string(actual) != string(want) { |
| + t.Fatal("coordinator write changed durable deploy") |
| + } |
| + if _, err := updateRecord(ctx, s, id.Account, id.App, id.Host, func(r *Record) error { r.ReplicaDeploy.Term = "spoofed"; return nil }); err == nil { |
| + t.Fatal("ordinary writer changed durable deploy") |
| + } |
| + if _, err := updateRecord(ctx, s, id.Account, id.App, id.Host, func(r *Record) error { r.ReplicaDeploy = nil; return nil }); err == nil { |
| + t.Fatal("ordinary writer erased durable deploy") |
| + } |
| + if _, err := updateRecord(ctx, s, id.Account, id.App, id.Host, func(r *Record) error { r.FleetBoxAt = "unchanged-authority"; return nil }); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
diff --git a/internal/provision/stateless_replicas_census_test.go b/internal/provision/stateless_replicas_census_test.go| new file mode 100644 |
| index 000000000..fb49cffb8 |
| --- /dev/null |
| +++ b/internal/provision/stateless_replicas_census_test.go |
| @@ -0,0 +1,24 @@ |
| +package provision |
| + |
| +// Self-review only: the new writer uses the existing judged CAS scaffold |
| +// under WithAppMutation. WriteRecord now refuses unrelated replica edits. |
| +// The controller still needs an independent verdict before landing. |
| +func statelessReplicasWriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), consoleFiestaWriteCensusInventory()...) |
| + for _, next := range []censusEntry{ |
| + {"internal/provision/record_sequence.go", "WriteRecord", "record-primitive", "key:IsRecordKey,key:WriteRecord,key:preparedRecordKey,sel:Put", "6bcdf4c07e3c583c013c396c5d02770eab83459b0eb5256a1e8c68c4240f31e8"}, |
| + {"internal/provision/replicacoordinator.go", "SetRecordCoordinator", "record-writer", "key:SetRecordCoordinator,key:updateRecord", "096a002b9fd3a81955c571831a51f5690f7b272db8ec356dd0364d7e2aecc7db"}, |
| + } { |
| + found := false |
| + for i, old := range entries { |
| + if old.File == next.File && old.Unit == next.Unit { |
| + entries[i] = next |
| + found = true |
| + } |
| + } |
| + if !found { |
| + entries = append(entries, next) |
| + } |
| + } |
| + return entries |
| +} |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 570c73f7a..4ade7b3df 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -56,4 +56,4 @@ plan14-root-reads-fix-set-aside-exdev.tsv f9d3016cc6803338f9db19311f3f598e20c37c |
| plan14-root-reads-durability-3a-escrow.tsv 03a92257beb9b8aac421559e247d191bd69f28a0b26243397a1344a90d59fc2a |
| plan14-root-reads-rootfs-default-home.tsv 7a0a3da3d6fe7e3c77abb22676db000af2a276c3d13ccae0f038190f51287ed5 |
| plan14-root-reads-probe-burst-limit.tsv 5f805400717bad7726bd9d62744b8103a40eb5f5823b0ab7c960a5c0965cb3bc |
| -plan14-root-reads-stateless-replicas-1.tsv cb000550f056e23ae31351912eae687bd0d7f7beb9108657246faeb44626cfb7 |
| +plan14-root-reads-stateless-replicas-1.tsv 09734aa86f42e64d772722a19bb0a6aed7519e7cccfb7b18320b5855b0b4bb11 |
diff --git a/internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv b/internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv| index 78702770b..79323c1c0 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-stateless-replicas-1.tsv |
| @@ -1,8 +1,13 @@ |
| # Census overlay stateless-replicas-1, written by census-propose (#369). census-ruling-stateless-replicas-1, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-stateless-replicas-1.md. |
| -# 2 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 2 body, 0 sites, 4 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| @legacy 8532ad0b6523e01bb6548e7a0ff565615b99e39a8921c338db522812368899a3 cli.go runShip legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-1;basis=rootfs Plan 1 Task 9: takes --rootfs, --processes, --hibernate, --jit and --check and hands a rootfs ship to runShipRootfs (ship_rootfs.go) before the binary path; the --notes-file ReadFile moved into shipNoteText (its own row, the same read of the file the person named) and the direct-mode version mint into mintDirectVersion; one read site fewer, none added; Task 12: the --hibernate flag help is RFS-1-C32's new text, the same reads;rev3=census-ruling-edge-asset-cache-1;basis=takes --assets (repeatable), checks the folders with checkShipAssets (release.ValidAssetPaths; refused on a static site) before the mode split, carries them into the API meta (sess.shipAssets) and the direct-mode manifest (shipAssetsBlock), and passes them to runShipRootfs (rootfsShipOpts.assets), which runs the same check and carries them the same two ways; after a direct-mode ship has stored a release declaring folders, directShipAssetGens runs the console ship door's backfill (provision.MintMissingAssetGens: lists the app's record keys and gives each record without an asset generation one, a CAS write in the deployment bucket as the person running the CLI) and fails naming any record it could not mint; read sites unchanged (2), none added;rev3=census-ruling-rootfs-apps-4;basis=adds the repeatable --env flag and refuses it before anything else unless --check is given (shipEnvRefusal, parseShipCheckEnv); the parsed values go into rootfsShipOpts.checkEnv. --env values reach the check's local container runtime as -e argv only, never root, never a box. No read added; read sites unchanged (2).;rev3=census-ruling-stateless-replicas-1;basis=Carry --stateless into binary/API and rootfs ship options; same two read sites, no new read. file:ReadFile@7899,file:ReadFile@8123 d6f244d2c3bcae95eb8ec0fa7e57c52e9b50c7e9e2e00dda85f930b643731a51 |
| @legacy 1e4efb560a06cb532c8d4caf719ff375c27a03a5651b26c59d81f271c70da628 ship_check.go rootfsCheck.runArgs legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-1;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (rootfs Plan 1), builds the docker or podman run argv for one check container; the scanner matches the word Command, here a field of release.Process (a process's argv), not os/exec; reads no file; decides nothing for root;rev3=census-ruling-rootfs-check-volumes;basis=R2 P1: the data and run volume mounts (-v) now carry :nocopy through rootfsCheck.volumeMount, so Docker and Podman never fill an empty check volume from the image directory at the mount point (which would reset the prepared owner and mode); same volumes, same paths, same probe mount, nothing else in the argv changed. Runs on the person's machine as the person; no box unit; no read added.;rev3=census-ruling-stateless-replicas-1;basis=Stateless local checks mount only the run volume and omit the database mount; same probe read, no new read. file:Command@887,file:Command@971 e684fd3273527a209460ed81e5bcd472a4282f46830fe580e5f07f0b0d876684 |
| +@legacy 1861ee20fec27c99526b8095d2b82598367595db4fcdbf2bc47ba40a269ec37f internal/replicas/coordinator.go ChangeCoordinator legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Generate a fresh 128-bit coordinator term using crypto/rand.Read; no file path or process input added. file:Read@472 e50ce5a352b3022a1ee6375fbfee315a5d2fcaeb4f4a25f4e33a5a10e3000a67 |
| cli.go runShip legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-1;basis=rootfs Plan 1 Task 9: takes --rootfs, --processes, --hibernate, --jit and --check and hands a rootfs ship to runShipRootfs (ship_rootfs.go) before the binary path; the --notes-file ReadFile moved into shipNoteText (its own row, the same read of the file the person named) and the direct-mode version mint into mintDirectVersion; one read site fewer, none added; Task 12: the --hibernate flag help is RFS-1-C32's new text, the same reads;rev3=census-ruling-edge-asset-cache-1;basis=takes --assets (repeatable), checks the folders with checkShipAssets (release.ValidAssetPaths; refused on a static site) before the mode split, carries them into the API meta (sess.shipAssets) and the direct-mode manifest (shipAssetsBlock), and passes them to runShipRootfs (rootfsShipOpts.assets), which runs the same check and carries them the same two ways; after a direct-mode ship has stored a release declaring folders, directShipAssetGens runs the console ship door's backfill (provision.MintMissingAssetGens: lists the app's record keys and gives each record without an asset generation one, a CAS write in the deployment bucket as the person running the CLI) and fails naming any record it could not mint; read sites unchanged (2), none added;rev3=census-ruling-rootfs-apps-4;basis=adds the repeatable --env flag and refuses it before anything else unless --check is given (shipEnvRefusal, parseShipCheckEnv); the parsed values go into rootfsShipOpts.checkEnv. --env values reach the check's local container runtime as -e argv only, never root, never a box. No read added; read sites unchanged (2).;rev3=census-ruling-stateless-replicas-1;basis=Carry --stateless into binary/API and rootfs ship options; same two read sites, no new read. file:ReadFile@7899,file:ReadFile@8123 d6f244d2c3bcae95eb8ec0fa7e57c52e9b50c7e9e2e00dda85f930b643731a51 |
| ship_check.go rootfsCheck.runArgs legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-1;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (rootfs Plan 1), builds the docker or podman run argv for one check container; the scanner matches the word Command, here a field of release.Process (a process's argv), not os/exec; reads no file; decides nothing for root;rev3=census-ruling-rootfs-check-volumes;basis=R2 P1: the data and run volume mounts (-v) now carry :nocopy through rootfsCheck.volumeMount, so Docker and Podman never fill an empty check volume from the image directory at the mount point (which would reset the prepared owner and mode); same volumes, same paths, same probe mount, nothing else in the argv changed. Runs on the person's machine as the person; no box unit; no read added.;rev3=census-ruling-stateless-replicas-1;basis=Stateless local checks mount only the run volume and omit the database mount; same probe read, no new read. file:Command@887,file:Command@971 e684fd3273527a209460ed81e5bcd472a4282f46830fe580e5f07f0b0d876684 |
| +internal/replicas/coordinator.go ChangeCoordinator legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-1;basis=Generate a fresh 128-bit coordinator term using crypto/rand.Read; no file path or process input added. file:Read@472 e50ce5a352b3022a1ee6375fbfee315a5d2fcaeb4f4a25f4e33a5a10e3000a67 |
| @coverage . d8abf32baa39f05d1e9d4e9b8a24e7113c58f42f8735e7a62e217eb39e7a4bf7 |
| +@coverage internal/provision 0de8deb0811673f6c9223d0cca375435326dc8bb1fa077afd6a305d61c0f0acb |
| @coverage internal/release 4f591204ea68e1c2f3c686ea07ace804bd91bbab7f6ca9942ff6ea6d88ff07d8 |
| +@coverage internal/replicas 53b94eb040154539a0a977498b4b8bc1d53d82f67c1c6233667a0b823dd30d8a |
diff --git a/internal/replicas/coordinator.go b/internal/replicas/coordinator.go| new file mode 100644 |
| index 000000000..72b281701 |
| --- /dev/null |
| +++ b/internal/replicas/coordinator.go |
| @@ -0,0 +1,52 @@ |
| +package replicas |
| + |
| +import ( |
| + "crypto/rand" |
| + "encoding/hex" |
| + "time" |
| +) |
| + |
| +const ( |
| + CoordinatorTTL = 15 * time.Minute |
| + CoordinatorRenewAfter = 5 * time.Minute |
| + CoordinatorSafetyMargin = 30 * time.Second |
| +) |
| + |
| +func CheckAuthority(current *Coordinator, term, box, boot string, now time.Time) error { |
| + if current == nil || term == "" || box == "" || boot == "" || current.Term != term || current.Box != box || current.BootID != boot || !now.Before(current.ExpiresAt) { |
| + return ErrFenced |
| + } |
| + return nil |
| +} |
| + |
| +func ChangeCoordinator(current *Coordinator, change CoordinatorChange, now time.Time) (Coordinator, error) { |
| + if change.Box == "" || change.BootID == "" || now.IsZero() { |
| + return Coordinator{}, ErrInvalid |
| + } |
| + if change.Op == "acquire" { |
| + if change.Term != "" { |
| + return Coordinator{}, ErrInvalid |
| + } |
| + if current != nil && now.Before(current.ExpiresAt) { |
| + return Coordinator{}, &CoordinatorHeldError{RetryAt: current.ExpiresAt} |
| + } |
| + var term [16]byte |
| + if _, err := rand.Read(term[:]); err != nil { |
| + return Coordinator{}, err |
| + } |
| + return Coordinator{Term: hex.EncodeToString(term[:]), Box: change.Box, BootID: change.BootID, ExpiresAt: now.Add(CoordinatorTTL)}, nil |
| + } |
| + if err := CheckAuthority(current, change.Term, change.Box, change.BootID, now); err != nil { |
| + return Coordinator{}, err |
| + } |
| + next := *current |
| + switch change.Op { |
| + case "renew": |
| + next.ExpiresAt = now.Add(CoordinatorTTL) |
| + case "release": |
| + next.ExpiresAt = now |
| + default: |
| + return Coordinator{}, ErrInvalid |
| + } |
| + return next, nil |
| +} |
diff --git a/internal/replicas/coordinator_test.go b/internal/replicas/coordinator_test.go| new file mode 100644 |
| index 000000000..659c2f5fa |
| --- /dev/null |
| +++ b/internal/replicas/coordinator_test.go |
| @@ -0,0 +1,42 @@ |
| +package replicas |
| + |
| +import ( |
| + "testing" |
| + "time" |
| +) |
| + |
| +func TestCoordinatorTermFencesLateResults(t *testing.T) { |
| + now := time.Date(2026, 11, 1, 12, 0, 0, 0, time.UTC) |
| + old := Coordinator{Term: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Box: "box-a", BootID: "boot-a", ExpiresAt: now} |
| + next, err := ChangeCoordinator(&old, CoordinatorChange{Op: "acquire", Box: old.Box, BootID: old.BootID}, now) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + _, lateRenewErr := ChangeCoordinator(&next, CoordinatorChange{Op: "renew", Term: old.Term, Box: old.Box, BootID: old.BootID}, now) |
| + lateSuccessErr := CheckAuthority(&next, old.Term, old.Box, old.BootID, now) |
| + if old.Term == next.Term || lateSuccessErr == nil || lateRenewErr == nil { |
| + t.Fatal("expired term remained authoritative") |
| + } |
| +} |
| + |
| +func TestCoordinatorTimingAndBootFence(t *testing.T) { |
| + now := time.Date(2026, 11, 1, 12, 0, 0, 0, time.UTC) |
| + lease, err := ChangeCoordinator(nil, CoordinatorChange{Op: "acquire", Box: "box-a", BootID: "boot-a"}, now) |
| + if err != nil || lease.ExpiresAt != now.Add(15*time.Minute) { |
| + t.Fatalf("lease: %+v %v", lease, err) |
| + } |
| + for _, change := range []CoordinatorChange{ |
| + {Op: "acquire", Box: "box-a", BootID: "boot-b"}, |
| + {Op: "renew", Term: lease.Term, Box: lease.Box, BootID: "boot-b"}, |
| + {Op: "release", Term: lease.Term, Box: lease.Box, BootID: "boot-b"}, |
| + } { |
| + if _, err := ChangeCoordinator(&lease, change, now); err == nil { |
| + t.Fatalf("accepted %+v", change) |
| + } |
| + } |
| + for _, op := range []string{"renew", "release"} { |
| + if _, err := ChangeCoordinator(&lease, CoordinatorChange{Op: op, Term: lease.Term, Box: lease.Box, BootID: lease.BootID}, lease.ExpiresAt); err == nil { |
| + t.Fatal("expired authority accepted") |
| + } |
| + } |
| +} |
diff --git a/internal/replicas/types.go b/internal/replicas/types.go| new file mode 100644 |
| index 000000000..c0f738ef6 |
| --- /dev/null |
| +++ b/internal/replicas/types.go |
| @@ -0,0 +1,73 @@ |
| +package replicas |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "time" |
| +) |
| + |
| +type Identity struct { |
| + Account string `json:"account,omitempty"` |
| + App string `json:"app,omitempty"` |
| + Host string `json:"host,omitempty"` |
| + Incarnation string `json:"incarnation,omitempty"` |
| +} |
| + |
| +type Build struct { |
| + Version string `json:"version,omitempty"` |
| + Digest string `json:"digest,omitempty"` |
| +} |
| + |
| +type Coordinator struct { |
| + Term string `json:"term,omitempty"` |
| + Box string `json:"box,omitempty"` |
| + BootID string `json:"boot_id,omitempty"` |
| + ExpiresAt time.Time `json:"expires_at,omitempty"` |
| +} |
| + |
| +type CoordinatorChange struct { |
| + Op string `json:"op,omitempty"` |
| + Term string `json:"term,omitempty"` |
| + Box string `json:"box,omitempty"` |
| + BootID string `json:"boot_id,omitempty"` |
| +} |
| + |
| +type CoordinatorReply struct { |
| + Lease Coordinator `json:"lease,omitempty"` |
| + RemainingMS int64 `json:"remaining_ms,omitempty"` |
| +} |
| + |
| +type CoordinatorHeldError struct{ RetryAt time.Time } |
| + |
| +func (e *CoordinatorHeldError) Error() string { return "replicas: coordinator held" } |
| + |
| +var ErrFenced = errors.New("replicas: fenced") |
| +var ErrInvalid = errors.New("replicas: invalid transition") |
| + |
| +type Authority interface { |
| + Err() error |
| + Lost() <-chan struct{} |
| + SafeUntil() (time.Time, error) |
| + Release(context.Context) error |
| +} |
| + |
| +type Deploy struct { |
| + ID string `json:"id,omitempty"` |
| + Incarnation string `json:"incarnation,omitempty"` |
| + Target Build `json:"target,omitempty"` |
| + Previous Build `json:"previous,omitempty"` |
| + Phase string `json:"phase,omitempty"` |
| + Term string `json:"term,omitempty"` |
| + Order []string `json:"order,omitempty"` |
| + Completed []string `json:"completed,omitempty"` |
| + ActiveBox string `json:"active_box,omitempty"` |
| + Revision uint64 `json:"revision,omitempty"` |
| +} |
| + |
| +type ReleaseChange struct { |
| + Op string `json:"op,omitempty"` |
| + ID string `json:"id,omitempty"` |
| + Term string `json:"term,omitempty"` |
| + Revision uint64 `json:"revision,omitempty"` |
| + Target Build `json:"target,omitempty"` |
| +} |