Merge commit 'b389c347' into claim-source
# Conflicts: # internal/provision/testdata/plan14-root-reads-chain.tsv
docs/superpowers/notes/census-proposal-claim-source.md+1 −1docs/superpowers/notes/census-proposal-dr1-left-link.md+16 −0internal/host/agent.go+6 −1internal/host/coldwake_leftlink_test.go+57 −0internal/provision/testdata/plan14-root-reads-chain.tsv+2 −1internal/provision/testdata/plan14-root-reads-claim-source.tsv+5 −5internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv+8 −0internal/release/adopt.go+36 −5internal/release/unstamped_live_test.go+196 −0
CI passed — run details
Intent
<task-notification> <task-id>b5v52j29t</task-id> <tool-use-id>toolu_01GPDXKDhQqiqptVedmG8yNx</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/b5v52j29t.output</output-file> <status>completed</status> <summary>Background command "sleep 45; until amadan ci status carlos/platform -branch claim-source 2>&1 | head -1 | grep -q '@ 531f997f'; do sleep 30; done; while amadan ci status carlos/platform -branch claim-source 2>&1 | head -1 | grep -q 'running\|queued\|pending'; do sleep 60; done; amadan ci status carlos/platform -branch claim-source 2>&1 | head -1" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bn2c40cv9</task-id> <tool-use-id>toolu_01B3Cns5i7HE9RpgGBL71qoH</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bn2c40cv9.output</output-file> <status>completed</status> <summary>Background command "git diff --stat 432135ae 531f997f -- internal/edge | tail -1; amadan ci rerun carlos/platform -commit 531f997f 2>&1 | tail -1; sleep 30; while amadan ci status carlos/platform -branch claim-source 2>&1 | head -1 | grep -q 'running\|queued\|pending'; do sleep 60; done; amadan ci status carlos/platform -branch claim-source 2>&1 | head -1" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 28.7 g CO₂e (3,786,660 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on claim-source, 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-claim-source.md b/docs/superpowers/notes/census-proposal-claim-source.md| index 97d3523ca..800ac2d34 100644 |
| --- a/docs/superpowers/notes/census-proposal-claim-source.md |
| +++ b/docs/superpowers/notes/census-proposal-claim-source.md |
| @@ -12,6 +12,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - new `internal/demobuild/source.go:validateSource`: reads +file:ReadAll ×3; written legacy, accepted-legacy, frozen |
| - quiet `internal/demobuild/source.go:ValidateSource`: reads nothing now; retired while it reads nothing (or its row keeps no sites) |
| -Seal: `7247af7f4de84593d83c6f60c0147d0a04836146197dd60c2ed2bf78919cad22` → `9d909e0157aba52540f0cdb71a9f3cf8140abf95203b5a2b3f826d77ee83e0bd`. |
| +Seal: `160744b3062d0ab9a0cb3c7be3a391ae38cf89ffe410ddd5d179e0c3cb509b66` → `9cdff432a5de2ffeaa147fdafd6a486c61c27a0c38f77466bddc86b149332c7d`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-claim-source.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/census-proposal-dr1-left-link.md b/docs/superpowers/notes/census-proposal-dr1-left-link.md| new file mode 100644 |
| index 000000000..4fd104e19 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-dr1-left-link.md |
| @@ -0,0 +1,16 @@ |
| +# Census approval: dr1-left-link |
| + |
| +Ruling `census-ruling-dr1-left-link`. The independent reviewer approves or rejects every change below, 2 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +Envelopes re-pinned: `internal/host`, `internal/release`. |
| + |
| +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. |
| + |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `internal/release/adopt.go:unstampedPlannedRow`: reads +registry:Backing, +registry:Unit, +registry:Version; written legacy, accepted-legacy, frozen |
| +- reads `internal/release/adopt.go:adoptHost`: +registry:Host ×2, +registry:PrevVersion, +whole:Route; keeps authority, task B3,E1,E2,E3,E4,J1 |
| + |
| +Seal: `7247af7f4de84593d83c6f60c0147d0a04836146197dd60c2ed2bf78919cad22` → `160744b3062d0ab9a0cb3c7be3a391ae38cf89ffe410ddd5d179e0c3cb509b66`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index f2eeab8c0..15811bbe9 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -1664,7 +1664,12 @@ func materializeHook(reg *registry.Registry, dd string) func(context.Context, st |
| log.Printf("agent: cold-wake materialize disabled: %v", err) |
| return nil |
| } |
| - optDir := release.OptDir() |
| + return coldWakeInstall(reg, store, pub, release.OptDir(), dd) |
| +} |
| + |
| +// coldWakeInstall is the install a planned wake runs before it plans |
| +// (rollout.Deps.Materialize): one host's pass, with this process's options. |
| +func coldWakeInstall(reg *registry.Registry, store release.Store, pub ed25519.PublicKey, optDir, dd string) func(context.Context, string) error { |
| stageReq := stageRequester(dd) |
| return func(ctx context.Context, host string) error { |
| // The process's one proof gate (proofask.go), so a cold wake cannot |
diff --git a/internal/host/coldwake_leftlink_test.go b/internal/host/coldwake_leftlink_test.go| new file mode 100644 |
| index 000000000..fd1503778 |
| --- /dev/null |
| +++ b/internal/host/coldwake_leftlink_test.go |
| @@ -0,0 +1,57 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "runtime" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// DR-1 (2026-11-07 dev rehearsal), through the install the edge runs before |
| +// it plans a wake (coldWakeInstall, materializeHook's closure, with its real |
| +// options). An HA host left this box, which removed its row and kept its |
| +// live link, and came back: the row was minted again with no Version and |
| +// every later wake was refused as "no build is installed for this instance |
| +// yet". The install must stamp the returning row from the link it left. |
| +func TestColdWakeInstallStampsAReturningHostFromItsLeftLink(t *testing.T) { |
| + env := newFastFixture(t) |
| + ctx := context.Background() |
| + plat := runtime.GOOS + "-" + runtime.GOARCH |
| + host := "hapair.test" |
| + m := release.Manifest{App: "hapair", Version: "hc1", Kind: "binary", Artifacts: map[string]release.Artifact{plat: {}}} |
| + if err := release.Ship(ctx, env.store, "bab", m, map[string][]byte{plat: []byte("build hc1")}); err != nil { |
| + t.Fatalf("Ship: %v", err) |
| + } |
| + if err := release.Promote(ctx, env.store, env.priv, "bab", "hapair", "edge", "hc1"); err != nil { |
| + t.Fatalf("Promote: %v", err) |
| + } |
| + row := registry.Route{Host: host, Kind: "instance", App: "hapair", Account: "bab", Channel: "edge", |
| + Status: "ready", Hibernate: true, Pool: "hapair"} |
| + if err := env.reg.Upsert(row); err != nil { |
| + t.Fatalf("Upsert: %v", err) |
| + } |
| + install := coldWakeInstall(env.reg, env.store, env.pub, env.optDir, env.dataDir) |
| + if err := install(ctx, host); err != nil { |
| + t.Fatalf("first install: %v", err) |
| + } |
| + if rt, _ := env.reg.Get(host); rt == nil || rt.Version != "hc1" { |
| + t.Fatalf("first install: row = %+v; want Version hc1", rt) |
| + } |
| + |
| + if err := env.reg.Delete(host); err != nil { |
| + t.Fatalf("Delete: %v", err) |
| + } |
| + // minted again, its link left in place |
| + if err := env.reg.Upsert(row); err != nil { |
| + t.Fatalf("Upsert again: %v", err) |
| + } |
| + if err := install(ctx, host); err != nil { |
| + t.Fatalf("install on return: %v", err) |
| + } |
| + rt, err := env.reg.Get(host) |
| + if err != nil || rt == nil || rt.Version != "hc1" { |
| + t.Fatalf("on return: row = %+v, %v; want Version hc1, the build its left link names", rt, err) |
| + } |
| +} |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 7e67d2ef7..bca61cb2b 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -118,4 +118,5 @@ plan14-root-reads-claim-ux-edge.tsv 889ce9f72f93b581b29527e5c5d4410b47732424ce8c |
| plan14-root-reads-region-ha-g3-fixes.tsv cd001bf3a9a8871f12d1ca9cfa0a925760c1fc345dc911246ffaabc235dfabf6 |
| plan14-root-reads-claim-countdown.tsv 5b31785441c6a48ddae93e9f3c0f8962f7983b55d89b3acb90d9a6b505647b36 |
| plan14-root-reads-region-ha-dr2.tsv 7247af7f4de84593d83c6f60c0147d0a04836146197dd60c2ed2bf78919cad22 |
| -plan14-root-reads-claim-source.tsv 9d909e0157aba52540f0cdb71a9f3cf8140abf95203b5a2b3f826d77ee83e0bd |
| +plan14-root-reads-dr1-left-link.tsv 160744b3062d0ab9a0cb3c7be3a391ae38cf89ffe410ddd5d179e0c3cb509b66 |
| +plan14-root-reads-claim-source.tsv 9cdff432a5de2ffeaa147fdafd6a486c61c27a0c38f77466bddc86b149332c7d |
diff --git a/internal/provision/testdata/plan14-root-reads-claim-source.tsv b/internal/provision/testdata/plan14-root-reads-claim-source.tsv| index 88bcfcb4a..323ef293f 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-claim-source.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-claim-source.tsv |
| @@ -1,11 +1,11 @@ |
| # Census overlay claim-source, written by census-propose (#369). census-ruling-claim-source, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-claim-source.md. |
| # 0 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| # 3 new dispositions: 0 reads re-frozen at their disposition with the claim, 2 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other. |
| -@legacy 23488c3daf17a026e331999b5389879bc3f7262018b0a5f4ac506e0548067297 apps_source.go pullAppSource legacy accepted-legacy accepted-legacy;rev3=census-ruling-claim-source;basis=CLI-only download checks the operator-selected output with Lstat before HTTP, creates an exclusive mode-0600 temporary file in the same directory, validates bounded response bytes, then links without overwriting; no archive extraction or execution. New reads: Lstat and CreateTemp replace direct output OpenFile; response ReadAll sites unchanged. file:CreateTemp@353,file:Lstat@184,file:ReadAll@1211,file:ReadAll@1791 02308bb42402538daf2374f6e6843700e5e71d2dd1434bdeba014ddd371fdac5 |
| -@legacy 0d4248779bccad094b2b7093f67727ed213cd82ec79faa44173d18d0fd266c0e internal/demobuild/source.go validateSource legacy accepted-legacy accepted-legacy;rev3=census-ruling-claim-source;basis=Shared bounded parser accepts the same gzip framing for publish and retrieval, including FEXTRA; structural archive validation retains path, type, duplicate, expansion, framing and size checks. Publish-only forbiddenFile policy is skipped for historical downloads; publish validation remains unchanged. Existing ReadAll sites only. file:ReadAll@2025,file:ReadAll@430,file:ReadAll@733 4676f3aecb28adbda6fdb84d909ba2f5448ac3e763a9024a50afc419481d145f |
| -apps_source.go pullAppSource legacy accepted-legacy accepted-legacy;rev3=census-ruling-claim-source;basis=CLI-only download checks the operator-selected output with Lstat before HTTP, creates an exclusive mode-0600 temporary file in the same directory, validates bounded response bytes, then links without overwriting; no archive extraction or execution. New reads: Lstat and CreateTemp replace direct output OpenFile; response ReadAll sites unchanged. file:CreateTemp@353,file:Lstat@184,file:ReadAll@1211,file:ReadAll@1791 02308bb42402538daf2374f6e6843700e5e71d2dd1434bdeba014ddd371fdac5 |
| -internal/demobuild/source.go validateSource legacy accepted-legacy accepted-legacy;rev3=census-ruling-claim-source;basis=Shared bounded parser accepts the same gzip framing for publish and retrieval, including FEXTRA; structural archive validation retains path, type, duplicate, expansion, framing and size checks. Publish-only forbiddenFile policy is skipped for historical downloads; publish validation remains unchanged. Existing ReadAll sites only. file:ReadAll@2025,file:ReadAll@430,file:ReadAll@733 4676f3aecb28adbda6fdb84d909ba2f5448ac3e763a9024a50afc419481d145f |
| +@legacy ce662056de8337479a7f03ed10e81e1b05baddd2673bf72330422e4a36f93c03 apps_source.go pullAppSource legacy accepted-legacy accepted-legacy;rev3=census-ruling-claim-source;basis=New CLI command carlos apps source pull: reads the HTTPS response body from the console (bounded, digest-checked), refuses an existing output path or symlink before any request, writes a CreateTemp file (0600) in the operator-chosen directory and links it into place without overwriting; never extracts or executes the archive. file:CreateTemp@353,file:Lstat@184,file:ReadAll@1211,file:ReadAll@1791 02308bb42402538daf2374f6e6843700e5e71d2dd1434bdeba014ddd371fdac5 |
| +@legacy 87697f10fe185506553dc8bd6b6e5badcf4ba7b44e00327257a0692c3eff1356 internal/demobuild/source.go validateSource legacy accepted-legacy accepted-legacy;rev3=census-ruling-claim-source;basis=Shared archive validator split out of ValidateSource: reads only the in-memory gzip/tar stream (bounded), rejects traversal, absolute paths, links, special files, duplicates and oversized expansion; the archive-only re-read path skips publish-time file-name exclusions; no filesystem paths opened. file:ReadAll@2025,file:ReadAll@430,file:ReadAll@733 4676f3aecb28adbda6fdb84d909ba2f5448ac3e763a9024a50afc419481d145f |
| +apps_source.go pullAppSource legacy accepted-legacy accepted-legacy;rev3=census-ruling-claim-source;basis=New CLI command carlos apps source pull: reads the HTTPS response body from the console (bounded, digest-checked), refuses an existing output path or symlink before any request, writes a CreateTemp file (0600) in the operator-chosen directory and links it into place without overwriting; never extracts or executes the archive. file:CreateTemp@353,file:Lstat@184,file:ReadAll@1211,file:ReadAll@1791 02308bb42402538daf2374f6e6843700e5e71d2dd1434bdeba014ddd371fdac5 |
| +internal/demobuild/source.go validateSource legacy accepted-legacy accepted-legacy;rev3=census-ruling-claim-source;basis=Shared archive validator split out of ValidateSource: reads only the in-memory gzip/tar stream (bounded), rejects traversal, absolute paths, links, special files, duplicates and oversized expansion; the archive-only re-read path skips publish-time file-name exclusions; no filesystem paths opened. file:ReadAll@2025,file:ReadAll@430,file:ReadAll@733 4676f3aecb28adbda6fdb84d909ba2f5448ac3e763a9024a50afc419481d145f |
| @remove internal/demobuild/source.go ValidateSource |
| -@removed internal/demobuild/source.go ValidateSource H3 census-ruling-claim-source;basis=Publication delegates to validateSource with archiveOnly=false; all publish-time file exclusions and dependency checks remain enforced. No direct reads. |
| +@removed internal/demobuild/source.go ValidateSource H3 census-ruling-claim-source;basis=Now a thin wrapper over validateSource with the full publish-time checks; reads nothing itself. |
| @coverage . 53a314c86fbc8de278a574d7a54a65a01a7c85629739a50740ec5c31f1e71330 |
| @coverage internal/demobuild 43b41e2ef861a0bced6f3cc11eaf25ae1949c8d9d8b9961ca768a2c58eeda78d |
diff --git a/internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv b/internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv| new file mode 100644 |
| index 000000000..50267e7f2 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv |
| @@ -0,0 +1,8 @@ |
| +# Census overlay dr1-left-link, written by census-propose (#369). census-ruling-dr1-left-link, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-dr1-left-link.md. |
| +# 0 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 2 new dispositions: 1 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 5b6bf96a9b163865e5e064f584de49f3c5c28a115d32a2ae0b9669babb6cd859 internal/release/adopt.go unstampedPlannedRow legacy accepted-legacy accepted-legacy;rev3=census-ruling-dr1-left-link;basis=new pure predicate over the route row (Version, Unit, Backing, sidecar, ActivatorOwned) and the live version already read; no file, store or process access registry:Backing@121,registry:Unit@104,registry:Version@71 e8eecc0ea0215995b49a66f3a9eb833d95d9364f152ee491ea085d03ff55eee9 |
| +internal/release/adopt.go unstampedPlannedRow legacy accepted-legacy accepted-legacy;rev3=census-ruling-dr1-left-link;basis=new pure predicate over the route row (Version, Unit, Backing, sidecar, ActivatorOwned) and the live version already read; no file, store or process access registry:Backing@121,registry:Unit@104,registry:Version@71 e8eecc0ea0215995b49a66f3a9eb833d95d9364f152ee491ea085d03ff55eee9 |
| +internal/release/adopt.go adoptHost authority B3,E1,E2,E3,E4,J1 E16: root first-registration creation evidence under release exclusion; exact installation identity is required for first-program adoption and is consumed before an attempt. Installed-program history comes from the verified claim launch. Fixtures: TestPlan14FreshInstallRegistration, TestPlan14FreshInstallProgramGate, TestPlan14FreshInstallCanonicalIdentity, TestPlan14FreshInstallLaunchObservation, TestPlan14InstalledLaunchProgramEvidence, TestPlan14FreshInstallProcessCrash, TestPlan14FreshInstallVisibleSync, TestClaimControlUnitInstallers. E22: root generation pins guard existing-tree artifact and manifest writes in adoption and moves-held staging/publication. Held snapshot is read under release exclusion before the leaf held-stage lock; failures remain restrictive for writes. Claims-off source returns no root pins. Fresh wholly absent version trees retain signed staging. Fixtures: TestPlan14GenerationSiblingWrites, TestPlan14GenerationVerifiedSiblingWrites, TestPlan14GenerationHeldStage (production source assembly, both flag values without census, lock order, pin/error/fresh cases). Production completeness remains unavailable; no new completeness grant.;rev3=PROPOSED-p3;run=8;identity=carlos adopt uid 0; legacy agent pass uid carlos;basis=applies root settings to canonically resolved routes including named units while legacy settings eligibility remains unchanged;rev3=PROPOSED-p3;run=16;basis=P3-R11 approved punctuation edit only; authority and reads unchanged;rev3=census-ruling-315;identity=legacy agent pass uid carlos (RootRestartsUnits; never set on carlos adopt);basis=a non-root agent pass hands a route its named unit serves (unitServed) to root through the stage relay before staging or repointing; root adopt reads unchanged;rev3=census-ruling-rootfs-apps-2;identity=the root adopt pass (carlos adopt, carlos-adopt.service, root);basis=the row's runtime (Runtime) rides on a copy of the stage check, so stageFrom stages only the kind the row runs (runtimeMatches) before any download, and the manifest the pass ends up holding is checked again; the artifact sha comes from Manifest.BoxArtifact (the rootfs key for an image); the new kind is registry:Runtime, two sites, and one more Host site in the refusal's line. A runtime the agent forges can make the pass refuse a release, and can also admit a rootfs release to staging for a row it marks rootfs. The evidence paths that can then hand back a staged identity, exhaustively: (1) the signed channel pointer with a manifest digest (ensureStagedDigest, then stageFrom: a fresh download or the staged copy reused); (2) a signed pointer with no digest (the digest marker off), through ensureStagedChecked: with the manifest fetched, stageFrom as in (1); with the fetch failing, a binary's sibling on disk is handed back as before, and a rootfs sibling is refused (controller ruling R-a, task 11 fix E5); (3) a signed promotion record's manifest digest (stageAuthorized, then ensureStagedDigest and stageFrom); (4) retained-copy recovery when (3) fails (stageAuthorized, RetainedStaged: the copy's bytes must hash to its sibling's digest). For a rootfs version every path that hands back an identity yields a sibling byte-equal to the manifest just authorised: stageFrom reads the sibling back after a fresh stage or a reuse and refuses otherwise; (2)'s fallback never yields one; recovery refuses a sibling whose bytes do not hash to the digest a readable record names (retainedRootfsAuthorised, task 11 fix E1), and with no record readable takes the copy root itself verified, as for a binary. Every path is for the row's own account and app. The held stage (materializeheld.go) and signedhead.go stage through ensureStagedDigest with a zero stage check (a binary row's), so they never stage a rootfs release, and their no-digest fallback refuses a rootfs sibling too;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3: comment only, the Hibernate check is left as is for a resident;rev3=census-ruling-stateless-replicas-1;basis=Task 4 R19: reuse the manifest verified by existing staging and signed selection; within withReleaseWork after history, proof and staging gates, seed or unseed the exec mode before PointLive (R24), under the same full-row compare and no ServingVersion/GoodVersion/running build guard. Version stamps staging and is not serving evidence. All existing root admission, credentials, quotas, proof, restart and rollback checks retained; no additional manifest or bucket read.;rev3=census-ruling-dr1-left-link;basis=the up-to-date return is skipped for an unstamped planned row (unstampedPlannedRow), which takes the existing install path with all its gates; on that repair (cur == ver) the D2 history is not seeded from the candidate path, the stamp keeps PrevVersion, and the refusal clear keeps the up-to-date rule. No new read kind registry:App@11580,registry:App@11734,registry:App@13088,registry:App@14336,registry:App@15934,registry:App@21429,registry:App@26905,registry:App@3144,registry:App@34685,registry:App@6791,registry:App@8092,registry:App@8286,registry:Backing@21145,registry:GoodVersion@21184,registry:Hibernate@36158,registry:Host@10517,registry:Host@11460,registry:Host@11493,registry:Host@11593,registry:Host@11747,registry:Host@11843,registry:Host@11875,registry:Host@11940,registry:Host@12390,registry:Host@12730,registry:Host@12854,registry:Host@13301,registry:Host@13410,registry:Host@13612,registry:Host@14426,registry:Host@15212,registry:Host@15687,registry:Host@15920,registry:Host@16262,registry:Host@16897,registry:Host@20605,registry:Host@20713,registry:Host@2105,registry:Host@21397,registry:Host@22217,registry:Host@22375,registry:Host@22837,registry:Host@22889,registry:Host@2294,registry:Host@23036,registry:Host@23123,registry:Host@2375,registry:Host@24229,registry:Host@24473,registry:Host@25133,registry:Host@25518,registry:Host@25659,registry:Host@26873,registry:Host@27000,registry:Host@28342,registry:Host@28992,registry:Host@3157,registry:Host@32225,registry:Host@32843,registry:Host@33168,registry:Host@33242,registry:Host@33489,registry:Host@33640,registry:Host@34857,registry:Host@35142,registry:Host@35255,registry:Host@35693,registry:Host@35749,registry:Host@35853,registry:Host@36000,registry:Host@36859,registry:Host@36985,registry:Host@37073,registry:Host@4469,registry:Host@4616,registry:Host@5579,registry:Host@5684,registry:Host@6903,registry:Host@6951,registry:Host@7068,registry:Host@7100,registry:Host@7978,registry:Host@8146,registry:Host@8272,registry:Host@8391,registry:Host@8869,registry:Host@9256,registry:Host@9482,registry:Host@9578,registry:Host@9669,registry:Kind@21101,registry:Kind@554,registry:PrevVersion@35044,registry:Runtime@11244,registry:Runtime@12648,registry:ServingVersion@21208,registry:Socket@21126,registry:Stateless@21085,registry:Stateless@21336,registry:Tunnel@21165,registry:Unit@33388,registry:Unit@579,whole:Route@10106,whole:Route@10460,whole:Route@11575,whole:Route@11729,whole:Route@13078,whole:Route@14326,whole:Route@15902,whole:Route@16467,whole:Route@16873,whole:Route@18073,whole:Route@18376,whole:Route@18532,whole:Route@20862,whole:Route@21006,whole:Route@21282,whole:Route@21419,whole:Route@2206,whole:Route@23958,whole:Route@24357,whole:Route@26895,whole:Route@3139,whole:Route@31796,whole:Route@34833,whole:Route@3595,whole:Route@4347,whole:Route@4587,whole:Route@6786 b89abf1c8a4e23cbcea7c35ee2c4653b2a97dbcafb38cb33907901c34b5e19f2 |
| +@coverage internal/host 99af3938fef7bc05f9c970ed39a37d3731a98886020150af2c5ffdffa257b493 |
| +@coverage internal/release ed09cbbff76338cf9a5fe15dd1bc2316e4540bf4d882b0736ea6a49067922b85 |
diff --git a/internal/release/adopt.go b/internal/release/adopt.go| index b776ae376..824fdee3a 100644 |
| --- a/internal/release/adopt.go |
| +++ b/internal/release/adopt.go |
| @@ -1485,7 +1485,7 @@ func adoptHost(ctx context.Context, work hostwrite.Work, reg *registry.Registry, |
| return |
| } |
| } |
| - if cur == ver { |
| + if cur == ver && !unstampedPlannedRow(rt, cur) { |
| cfg.proof.clear(rt.Host) // live on its target: nothing left to wait for |
| // A refusal that no longer blocks the pointer is stale even though |
| // nothing moves: v2 was refused and rolled back to v1, then the |
| @@ -1686,8 +1686,13 @@ func adoptHost(ctx context.Context, work hostwrite.Work, reg *registry.Registry, |
| // The live binary is what the route is running, so its program belongs |
| // in the history whatever the file already says: a history of [A] on a |
| // route that is live on B (a change made before this check existed, or |
| - // a record lost) must not refuse the next B build. |
| - if cur != "" && !cfg.requireRootHistory { |
| + // a record lost) must not refuse the next B build. Not for an |
| + // unstamped row's repair (cur == ver, unstampedPlannedRow): the |
| + // program at that path is the candidate just staged, and a link |
| + // left by an earlier row is no evidence it was ever admitted here, |
| + // so the candidate is judged on the history alone, as a first |
| + // install is (Astra R2). |
| + if cur != "" && cur != ver && !cfg.requireRootHistory { |
| if live := FileProgram(VersionPath(optDir, RouteAccount(rt), cur, rt.App)); live != "" && !slices.Contains(hist, live) { |
| _ = RecordProgram(cfg.bakeDir, rt.Host, live) |
| hist = append(slices.Clone(hist), live) |
| @@ -2148,14 +2153,25 @@ func adoptHost(ctx context.Context, work hostwrite.Work, reg *registry.Registry, |
| return |
| } |
| } |
| - if err := withReleaseWork(ctx, work, id, func() error { return reg.SetVersions(rt.Host, ver, cur) }); err != nil { |
| + stampPrev := cur |
| + if cur == ver { // an unstamped row's repair (unstampedPlannedRow) |
| + stampPrev = rt.PrevVersion |
| + } |
| + if err := withReleaseWork(ctx, work, id, func() error { return reg.SetVersions(rt.Host, ver, stampPrev) }); err != nil { |
| fmt.Printf(" %s: repointed but recording the version failed: %v\n", rt.Host, err) |
| return |
| } |
| // A record left from an older promotion is stale once a build is live. |
| // Best-effort: the agent cannot remove root's file, the root pass can. |
| + // An unstamped row's repair installed what was already live, so it |
| + // clears only what the up-to-date return above would: a record that |
| + // blocks neither the selected build nor the head. |
| if cfg.bakeDir != "" { |
| - _ = ClearRefusal(cfg.bakeDir, rt.Host) |
| + if cur != ver { |
| + _ = ClearRefusal(cfg.bakeDir, rt.Host) |
| + } else if r, err := ReadRefusal(cfg.bakeDir, rt.Host); err == nil && r != nil && !r.Blocks(sel) && !r.Blocks(ptr) { |
| + _ = ClearRefusal(cfg.bakeDir, rt.Host) |
| + } |
| } |
| if rt.IsSidecar() { |
| fmt.Printf(" %s: repointed %s -> %s (%s; sidecar, its worker moves onto it on the agent's drift check)\n", rt.Host, cur, ver, channel) |
| @@ -2844,3 +2860,18 @@ func retainedRootfsAuthorised(optDir, acct, app, ver string, m *Manifest, author |
| } |
| return nil |
| } |
| + |
| +// unstampedPlannedRow reports whether rt is a row the rollout planner wakes |
| +// (exec-backed, the activator's) that records no installed build while its |
| +// live link names cur (DR-1, 2026-11-07). A box keeps a host's link after |
| +// the host's row goes, and the row minted when the host comes back has no |
| +// Version; the up-to-date return left it unstamped for good, and the |
| +// planner refuses every wake of such a row. It takes the whole install |
| +// instead, every gate included, as a first install does: a link alone is |
| +// no evidence that its build was admitted (Astra R1). A named unit, or an |
| +// always-awake instance, execs its link without the planner, so its row is |
| +// left as it was and nothing restarts it. |
| +func unstampedPlannedRow(rt registry.Route, cur string) bool { |
| + return rt.Version == "" && cur != "" && rt.Unit == "" && rt.Backing != registry.BackingUnit && |
| + !rt.IsSidecar() && rt.ActivatorOwned() |
| +} |
diff --git a/internal/release/unstamped_live_test.go b/internal/release/unstamped_live_test.go| new file mode 100644 |
| index 000000000..bf18f7702 |
| --- /dev/null |
| +++ b/internal/release/unstamped_live_test.go |
| @@ -0,0 +1,196 @@ |
| +package release |
| + |
| +import ( |
| + "context" |
| + "os" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +// DR-1 (2026-11-07 dev rehearsal): a box that served a host once keeps the |
| +// host's live link after the row goes (an HA host moving to another box). |
| +// When the host comes back the row is minted again with no Version, the |
| +// link already names the channel head, and the pass's up-to-date return |
| +// left the row unstamped for good. The rollout planner refuses a wake for a |
| +// row with no installed build, so the host could never wake on that box |
| +// again. Such a row takes the whole install, gates included, and is stamped. |
| +func remintedRow(t *testing.T) *matFixture { |
| + t.Helper() |
| + env := newMatFixture(t) |
| + ctx := context.Background() |
| + shipRelease(t, env.store, "bab", "matapp", "abc1234", adoptPlatform, []byte("ha build")) |
| + if err := Promote(ctx, env.store, env.priv, "bab", "matapp", "canary/dev", "abc1234"); err != nil { |
| + t.Fatalf("Promote: %v", err) |
| + } |
| + addRoute(t, env.reg, "mat.test", "matapp", "canary/dev", true) |
| + if err := MaterializeHost(ctx, env.reg, env.store, env.pub, env.optDir, env.dataDir, "mat.test"); err != nil { |
| + t.Fatalf("first MaterializeHost: %v", err) |
| + } |
| + if rt := mustRow(t, env, "mat.test"); rt.Version != "abc1234" { |
| + t.Fatalf("first install: row = %+v; want Version abc1234", rt) |
| + } |
| + // The host leaves this box (its row goes, its link stays) and comes back. |
| + if err := env.reg.Delete("mat.test"); err != nil { |
| + t.Fatalf("Delete: %v", err) |
| + } |
| + addRoute(t, env.reg, "mat.test", "matapp", "canary/dev", true) |
| + if v, _ := LiveVersion(env.optDir, "mat.test"); v != "abc1234" { |
| + t.Fatalf("live = %q, want the link left at abc1234", v) |
| + } |
| + return env |
| +} |
| + |
| +func TestMaterializeHostStampsARemintedRowWhoseLinkWasLeft(t *testing.T) { |
| + env := remintedRow(t) |
| + if err := MaterializeHost(context.Background(), env.reg, env.store, env.pub, env.optDir, env.dataDir, "mat.test"); err != nil { |
| + t.Fatalf("MaterializeHost: %v", err) |
| + } |
| + if rt := mustRow(t, env, "mat.test"); rt.Version != "abc1234" { |
| + t.Fatalf("row = %+v; want Version abc1234", rt) |
| + } |
| +} |
| + |
| +func TestPassStampsARemintedRowWhoseLinkWasLeft(t *testing.T) { |
| + env := remintedRow(t) |
| + if err := Pass(context.Background(), env.reg, env.store, env.pub, env.optDir, nil, BakeDir(env.dataDir)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if rt := mustRow(t, env, "mat.test"); rt.Version != "abc1234" { |
| + t.Fatalf("row = %+v; want Version abc1234", rt) |
| + } |
| +} |
| + |
| +// Astra R1 #1: a left link is no evidence its build was admitted. A build |
| +// this box refused (its rollback could not move the link off it) stays |
| +// refused when the row comes back: the install's gates still run. |
| +func TestARemintedRowOnARefusedLeftLinkStaysUnstamped(t *testing.T) { |
| + env := remintedRow(t) |
| + ptr, err := Channel(context.Background(), env.store, env.pub, "bab", "matapp", "canary/dev") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := WriteRefusal(env.dataDir, Refusal{Host: "mat.test", App: "matapp", Version: ptr.Version, |
| + PointerPromotedAt: ptr.PromotedAt, RefusedAt: time.Now().UTC(), Reason: "exited: status=2", |
| + RecoveryError: "could not roll the symlink back"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := Pass(context.Background(), env.reg, env.store, env.pub, env.optDir, nil, BakeDir(env.dataDir)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if rt := mustRow(t, env, "mat.test"); rt.Version != "" { |
| + t.Fatalf("row = %+v; a refused build was stamped from its left link", rt) |
| + } |
| +} |
| + |
| +func mustRow(t *testing.T, env *matFixture, host string) registry.Route { |
| + t.Helper() |
| + rt, err := env.reg.Get(host) |
| + if err != nil || rt == nil { |
| + t.Fatalf("Get %s: %+v, %v", host, rt, err) |
| + } |
| + return *rt |
| +} |
| + |
| +// Astra R2 #1: the repair judges the candidate's program on the history |
| +// alone. A link left by another app's row under the same version name must |
| +// not seed the history with the candidate itself: history [A], candidate B |
| +// with no --program-change, so B is refused and the row stays unstamped. |
| +func TestARemintedRowCannotSeedItsOwnProgramHistory(t *testing.T) { |
| + env := newMatFixture(t) |
| + ctx := context.Background() |
| + host := "mat.test" |
| + progA, progB := tinyProgram(t, "example.com/a"), tinyProgram(t, "example.com/b") |
| + shipRelease(t, env.store, "bab", "matapp", "v1", adoptPlatform, progB) |
| + if err := Promote(ctx, env.store, env.priv, "bab", "matapp", "canary/dev", "v1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := StageArtifact(env.optDir, "bab", "v1", "otherapp", progA); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := PointLive(env.optDir, host, "bab", "v1", "otherapp"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := RecordProgram(env.dataDir, host, "example.com/a"); err != nil { |
| + t.Fatal(err) |
| + } |
| + addRoute(t, env.reg, host, "matapp", "canary/dev", true) |
| + if err := Pass(ctx, env.reg, env.store, env.pub, env.optDir, nil, BakeDir(env.dataDir)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if rt := mustRow(t, env, host); rt.Version != "" { |
| + t.Fatalf("row = %+v; a wrong program was stamped on its own say-so", rt) |
| + } |
| + if target, _ := os.Readlink(LiveLink(env.optDir, host)); target != VersionPath(env.optDir, "bab", "v1", "otherapp") { |
| + t.Fatalf("link = %q; the refused candidate was pointed live", target) |
| + } |
| +} |
| + |
| +// Astra R2 #2: the repair keeps the row's install history. |
| +func TestARemintedRowsRepairKeepsItsPrevVersion(t *testing.T) { |
| + env := remintedRow(t) |
| + if err := env.reg.SetVersions("mat.test", "", "v0"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := Pass(context.Background(), env.reg, env.store, env.pub, env.optDir, nil, BakeDir(env.dataDir)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if rt := mustRow(t, env, "mat.test"); rt.Version != "abc1234" || rt.PrevVersion != "v0" { |
| + t.Fatalf("row = %s/%s; want abc1234 over v0", rt.Version, rt.PrevVersion) |
| + } |
| +} |
| + |
| +// Astra R2 #2: rows the planner does not wake keep the up-to-date return, |
| +// so nothing restarts them: a named unit, and an awake (non-hibernating) |
| +// exec instance. |
| +func TestUnstampedRowsThePlannerDoesNotWakeAreLeftAlone(t *testing.T) { |
| + for name, edit := range map[string]func(*registry.Route){ |
| + "named unit": func(r *registry.Route) { r.Unit = "matapp.service" }, |
| + "awake exec": func(r *registry.Route) { r.Hibernate = false }, |
| + "unit backed": func(r *registry.Route) { r.Backing = registry.BackingUnit }, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + env := remintedRow(t) |
| + rt := mustRow(t, env, "mat.test") |
| + edit(&rt) |
| + if err := env.reg.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + restart := func(h string) error { t.Fatalf("restart consulted for %s", h); return nil } |
| + if err := Pass(context.Background(), env.reg, env.store, env.pub, env.optDir, restart, BakeDir(env.dataDir)); err != nil { |
| + t.Fatalf("Pass: %v", err) |
| + } |
| + if rt := mustRow(t, env, "mat.test"); rt.Version != "" { |
| + t.Fatalf("row = %+v; want it left unstamped", rt) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// Astra R3 P2: a retained link is no exemption from the proof gate. The |
| +// app requires a proof, the row is unstamped and hibernating, its left link |
| +// names the selected build, and there is neither a proof nor a healthy run |
| +// of it here: the row stays unstamped and nothing restarts. |
| +func TestARemintedRowNeedsItsProof(t *testing.T) { |
| + e := newProofEnv(t) |
| + e.requireDev(t) |
| + if err := StageArtifact(e.opt, "bab", "new", "console", []byte("bad build")); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := PointLive(e.opt, proofHost, "bab", "new", "console"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := e.reg.Delete(proofHost); err != nil { |
| + t.Fatal(err) |
| + } |
| + addRoute(t, e.reg, proofHost, "console", "canary/x", true) |
| + out := e.passWith(t, e.store, func(h string) error { t.Fatalf("restart consulted for %s", h); return nil }) |
| + if rt, _ := e.reg.Get(proofHost); rt == nil || rt.Version != "" { |
| + t.Fatalf("row = %+v; an unproven left build was stamped", rt) |
| + } |
| + if !strings.Contains(out, "is not proven on dev") { |
| + t.Fatalf("printed %q, want the not-proven line", out) |
| + } |
| +} |