carlos / platform Public

release: the repair judges its program on history alone (Astra R2)

Astra R2 #1: on an unstamped row's repair (cur == ver) the D2 seed read
the candidate's own staged path, so a link left by another app's row
under the same version made a wrong program look already run. The seed
now skips the repair; the candidate is judged on the history alone, as a
first install is.

R2 #2: guard tests for the repair's rules (no self-seeded history, kept
PrevVersion, named unit / awake exec / unit backed left alone, plus the
existing refusal-under-pin test), each mutation-checked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev ea27dcd85bc1be340d3ee2856bea4722030b4d7a parent 736d51a
3 files changed, +85 −4
  • internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv +2 −2
  • internal/release/adopt.go +7 −2
  • internal/release/unstamped_live_test.go +76 −0

CI cancelled — superseded by a newer push — run details

diff --git a/internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv b/internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv
index e10d6a81b..822cc9ec2 100644
--- a/internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv
+++ b/internal/provision/testdata/plan14-root-reads-dr1-left-link.tsv
@@ -3,6 +3,6 @@
# 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; its stamp keeps PrevVersion and its refusal clear keeps the up-to-date rule. No new read kind registry:App@11580,registry:App@11734,registry:App@13088,registry:App@14014,registry:App@15612,registry:App@21107,registry:App@26583,registry:App@3144,registry:App@34363,registry:App@6791,registry:App@8092,registry:App@8286,registry:Backing@20823,registry:GoodVersion@20862,registry:Hibernate@35836,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@14104,registry:Host@14890,registry:Host@15365,registry:Host@15598,registry:Host@15940,registry:Host@16575,registry:Host@20283,registry:Host@20391,registry:Host@2105,registry:Host@21075,registry:Host@21895,registry:Host@22053,registry:Host@22515,registry:Host@22567,registry:Host@22714,registry:Host@22801,registry:Host@2294,registry:Host@2375,registry:Host@23907,registry:Host@24151,registry:Host@24811,registry:Host@25196,registry:Host@25337,registry:Host@26551,registry:Host@26678,registry:Host@28020,registry:Host@28670,registry:Host@3157,registry:Host@31903,registry:Host@32521,registry:Host@32846,registry:Host@32920,registry:Host@33167,registry:Host@33318,registry:Host@34535,registry:Host@34820,registry:Host@34933,registry:Host@35371,registry:Host@35427,registry:Host@35531,registry:Host@35678,registry:Host@36537,registry:Host@36663,registry:Host@36751,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@20779,registry:Kind@554,registry:PrevVersion@34722,registry:Runtime@11244,registry:Runtime@12648,registry:ServingVersion@20886,registry:Socket@20804,registry:Stateless@20763,registry:Stateless@21014,registry:Tunnel@20843,registry:Unit@33066,registry:Unit@579,whole:Route@10106,whole:Route@10460,whole:Route@11575,whole:Route@11729,whole:Route@13078,whole:Route@14004,whole:Route@15580,whole:Route@16145,whole:Route@16551,whole:Route@17751,whole:Route@18054,whole:Route@18210,whole:Route@20540,whole:Route@20684,whole:Route@20960,whole:Route@21097,whole:Route@2206,whole:Route@23636,whole:Route@24035,whole:Route@26573,whole:Route@3139,whole:Route@31474,whole:Route@34511,whole:Route@3595,whole:Route@4347,whole:Route@4587,whole:Route@6786 616941c4a66df12330c768682235f14d84b854f0b4a05bedb10d7e782d627aff
+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 d1354d1a98de9d4b9018e6df0b65ac1f4e6c5a1d2dd922100fe316d592c7be22
-@coverage internal/release 1b89f7d27b8547a80de782facb25f48ff9a36d17ae5cf1346ac580e347b439f9
+@coverage internal/release ed09cbbff76338cf9a5fe15dd1bc2316e4540bf4d882b0736ea6a49067922b85
diff --git a/internal/release/adopt.go b/internal/release/adopt.go
index 8834c409f..824fdee3a 100644
--- a/internal/release/adopt.go
+++ b/internal/release/adopt.go
@@ -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)
diff --git a/internal/release/unstamped_live_test.go b/internal/release/unstamped_live_test.go
index f5b9a0f4f..0eb61ca5b 100644
--- a/internal/release/unstamped_live_test.go
+++ b/internal/release/unstamped_live_test.go
@@ -2,6 +2,7 @@ package release
import (
"context"
+ "os"
"testing"
"time"
@@ -91,3 +92,78 @@ func mustRow(t *testing.T, env *matFixture, host string) registry.Route {
}
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)
+ }
+ })
+ }
+}