carlos / platform Public

system apply: a box with rootfs instances refuses a platform release that cannot run them

The rootfs half of spec §5.6's version floor, in the layout floor's shape:
a candidate that lacks carlos-instance-rootfs@.service, or whose version is
below release.RootfsLifecycleFloor (v0.29.0) or does not parse, is refused
before the journal while any row has a runtime (RFS-3-C25 names the hosts).
Plan 2's releases ship the template without the lifecycle, so the version
is required too [Astra R1 10]. A registry that will not open or list is the
reason. The registry is read only through the openRegistry seam
(openSystemRegistry by default); a go/ast test pins that systemapply.go
calls no registry.Open [pf 4.2].
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 8f05007abca35c858f2acef92f355856672d5500 parent 5ad94cb
6 files changed, +489 −7
  • approved_rootfs_copy_test.go +2 −0
  • internal/host/systemapply.go +76 −3
  • internal/host/systemapply_rootfs_test.go +365 −0
  • internal/host/systemapply_test.go +10 −4
  • internal/release/layoutintent.go +15 −0
  • internal/release/layoutintent_test.go +21 −0
diff --git a/approved_rootfs_copy_test.go b/approved_rootfs_copy_test.go
index cc615c67e..943ec21eb 100644
--- a/approved_rootfs_copy_test.go
+++ b/approved_rootfs_copy_test.go
@@ -190,6 +190,8 @@ var rootfsCopyBuilt = []string{
// Plan 3 Task 13: the move doors and carlos apps place refuse rootfs
// instances (internal/console/seedmove.go)
"RFS-3-C23", "RFS-3-C24",
+ // Plan 3 Task 15: the rootfs rollback floor (internal/host/systemapply.go)
+ "RFS-3-C25",
}
func mustParseRootfsRecord(t *testing.T) []copyRow {
diff --git a/internal/host/systemapply.go b/internal/host/systemapply.go
index c2dc55ac7..e2697a2f0 100644
--- a/internal/host/systemapply.go
+++ b/internal/host/systemapply.go
@@ -44,7 +44,8 @@ import (
// grants no new privilege. Root's adopt, stage and restart passes already
// open the same registry, the listing and the Lstats follow no symlink
// and read no journal's contents, and all the guard can do with what it
-// finds is refuse the install.
+// finds is refuse the install. The rootfs floor (rootfsRollbackReasons)
+// opens the same registry, through the same seam, and only lists it.
const (
systemEdgeUnit = "carlos-edge"
@@ -245,8 +246,9 @@ type systemApplier struct {
// openSystemStore for why that matters at boot.
openStore func(ctx context.Context) (release.Store, ed25519.PublicKey, error)
// openRegistry is called only when the candidate predates the instance
- // layout, to see whether anything on the box is still nested. Nil means
- // openSystemRegistry over dataDir.
+ // layout, to see whether anything on the box is still nested, or cannot
+ // run rootfs instances, to see whether any row has a runtime (and by the
+ // moves floor's hold check). Nil means openSystemRegistry over dataDir.
openRegistry func() (*registry.Registry, error)
channel string
optDir string
@@ -522,6 +524,18 @@ func (a *systemApplier) install(ctx context.Context, req systemRequest, p *relea
return a.record(req, fmt.Errorf("%w: "+systemApplyLayoutRefusal, errSystemRefused, target, strings.Join(reasons, ", ")))
}
}
+ // The rootfs floor has the same shape (rootfs apps spec §5.6): a box with
+ // a row that has a runtime never installs a release that cannot run it,
+ // refused here, before the journal. Plan 2's releases ship the rootfs
+ // templates without the lifecycle, so the unit set is half the evidence
+ // and release.RootfsLifecycleFloor the other half. Unlike the layout
+ // floor, a version that does not parse is refused too: its unit set
+ // says nothing about the lifecycle.
+ if !rootfsLifecycleCandidate(target, newUnits) {
+ if reasons := a.rootfsRollbackReasons(); len(reasons) > 0 {
+ return a.record(req, fmt.Errorf("%w: "+systemApplyRootfsRefusal, errSystemRefused, target, strings.Join(reasons, ", ")))
+ }
+ }
// Only the unit set is taken from the return: a rollback picks this
// staging up as it stands, plan.json and all, rather than exec'ing the
// previous binary again on a box that is already unhealthy.
@@ -1229,6 +1243,65 @@ const layoutMountUnit = "data-instances.mount"
// systemApplyLayoutRefusal takes the release and the rows in its way.
const systemApplyLayoutRefusal = "%s predates the instance layout, and this box still has: %s. revert the layout and wait for every row to report flat before installing it"
+// rootfsInstanceUnit is the contract's rootfs instance template. Its
+// presence in a candidate's staged set is half of the evidence that the
+// candidate runs rows with a runtime; release.RootfsLifecycleFloor is the
+// other half.
+const rootfsInstanceUnit = "carlos-instance-rootfs@.service"
+
+// systemApplyRootfsRefusal (RFS-3-C25) takes the release and the rows in
+// its way.
+const systemApplyRootfsRefusal = "%s cannot run rootfs instances, and this box still has: %s. delete those instances before installing it"
+
+// rootfsRowsPresent names, once each and sorted, every host whose row has
+// a runtime: rootfs-v1, or one this build does not know. reg is the
+// *Registry the openRegistry seam returned (openSystemRegistry, the
+// service-user child, by default), never one root opened itself. A
+// registry that cannot be listed is an error, never an empty box.
+func rootfsRowsPresent(reg *registry.Registry) ([]string, error) {
+ routes, err := reg.List()
+ if err != nil {
+ return nil, err
+ }
+ var hosts []string
+ for _, rt := range routes {
+ if rt.Runtime != "" {
+ hosts = append(hosts, rt.Host)
+ }
+ }
+ slices.Sort(hosts)
+ return slices.Compact(hosts), nil
+}
+
+// rootfsLifecycleCandidate reports whether a candidate runs rows with a
+// runtime: it ships rootfsInstanceUnit and its version parses at or above
+// release.RootfsLifecycleFloor.
+func rootfsLifecycleCandidate(version string, units []string) bool {
+ v, ok := release.ParseReleaseVersion(version)
+ return ok && v.Compare(release.RootfsLifecycleFloor) >= 0 && slices.Contains(units, rootfsInstanceUnit)
+}
+
+// rootfsRollbackReasons opens the registry through the openRegistry seam
+// and names the rows a release that cannot run rootfs instances would
+// strand. A registry that will not open or list cannot vouch that no row
+// has a runtime, so its error is itself a reason.
+func (a *systemApplier) rootfsRollbackReasons() []string {
+ open := a.openRegistry
+ if open == nil {
+ open = func() (*registry.Registry, error) { return openSystemRegistry(a.dataDir) }
+ }
+ reg, err := open()
+ if err != nil {
+ return []string{err.Error()}
+ }
+ defer reg.Close()
+ hosts, err := rootfsRowsPresent(reg)
+ if err != nil {
+ return []string{err.Error()}
+ }
+ return hosts
+}
+
// layoutReversalReasons opens the registry and lists what stands in the
// way of a release before the layout. A registry that will not open cannot
// vouch that nothing is nested, so its error is itself a reason.
diff --git a/internal/host/systemapply_rootfs_test.go b/internal/host/systemapply_rootfs_test.go
new file mode 100644
index 000000000..0df9de2e5
--- /dev/null
+++ b/internal/host/systemapply_rootfs_test.go
@@ -0,0 +1,365 @@
+package host
+
+// The rootfs rollback floor (rootfs apps Plan 3, Task 15; spec §5.6): a box
+// that has rows with a runtime never installs a platform release that
+// cannot run them. No t.Parallel(): the floor's tests share the applier's
+// seams with the layout floor's.
+
+import (
+ "context"
+ "errors"
+ "go/ast"
+ "go/parser"
+ "go/token"
+ "os"
+ "path/filepath"
+ "slices"
+ "strconv"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+// runtimeRow is a nested, always-on row with a runtime, as Plan 2 mints one.
+func runtimeRow(dataDir, host, runtime string) registry.Route {
+ rt := nestedRow(dataDir, host)
+ rt.Runtime, rt.Hibernate = runtime, false
+ return rt
+}
+
+// withRootfsUnit gives the fixture's candidate the rootfs instance template,
+// which every release from Plan 2 on ships.
+func (f *applyFixture) withRootfsUnit() {
+ staged := filepath.Join(f.a.stagingDir(), "carlos")
+ f.answer["units:"+staged] += " " + rootfsInstanceUnit
+}
+
+// countOpens wraps the fixture's openRegistry seam and counts its calls.
+func (f *applyFixture) countOpens() *int {
+ n := 0
+ open := f.a.openRegistry
+ f.a.openRegistry = func() (*registry.Registry, error) { n++; return open() }
+ return &n
+}
+
+// assertUntouched is what a refusal before the journal leaves: no journal,
+// the old binary, and systemd never stopped or restarted.
+func (f *applyFixture) assertUntouched() {
+ f.t.Helper()
+ if j, _ := readSystemJournal(f.a.optDir); j != nil {
+ f.t.Fatalf("a refused apply wrote a journal: %+v", j)
+ }
+ if bin, _ := os.ReadFile(systemBinaryPath(f.a.optDir)); !strings.Contains(string(bin), "carlos v1") {
+ f.t.Fatal("a refused apply swapped the binary")
+ }
+ if f.called("systemctl stop") || f.called("systemctl restart") {
+ f.t.Fatalf("a refused apply touched systemd: %v", f.calls)
+ }
+}
+
+func rootfsRefusalFor(version, hosts string) string {
+ return "refused: " + version + " cannot run rootfs instances, and this box still has: " + hosts +
+ ". delete those instances before installing it"
+}
+
+// A candidate at or above the floor that does not ship the rootfs template
+// cannot run a rootfs row, so the apply refuses it before the journal and
+// names the row. The binary row beside it is not named.
+func TestApplyRefusesACandidateWithoutRootfsUnits(t *testing.T) {
+ f, req := applyHappyVersion(t, "v0.29.0")
+ f.postLayout()
+ dd := f.a.dataDir
+ f.seedRoutes(flatRow(dd, "flat.example.com"), runtimeRow(dd, "shop.example.com", registry.RuntimeRootfsV1))
+ if err := f.a.Run(context.Background(), false); err != nil {
+ t.Fatal(err)
+ }
+ r := f.result()
+ if r == nil || r.Outcome != systemOutcomeRefused || !r.matches("stable", "v0.29.0", req.PromotedAt) {
+ t.Fatalf("result = %+v", r)
+ }
+ if want := rootfsRefusalFor("v0.29.0", "shop.example.com"); r.Reason != want {
+ t.Fatalf("reason = %q\nwant %q", r.Reason, want)
+ }
+ f.assertUntouched()
+}
+
+// The same candidates on a box with no row that has a runtime install as
+// they do on main: no unit set, version or registry content of a binary-only
+// box is a reason.
+func TestApplyAllowsWithoutRootfsRows(t *testing.T) {
+ for _, tc := range []struct {
+ name, version string
+ rootfsUnit bool
+ }{
+ {"no rootfs unit", "v0.29.0", false},
+ {"Plan 2's release", "v0.28.25", true},
+ {"an unparseable version", "v2", true},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ f, req := applyHappyVersion(t, tc.version)
+ f.postLayout()
+ if tc.rootfsUnit {
+ f.withRootfsUnit()
+ }
+ dd := f.a.dataDir
+ f.seedRoutes(flatRow(dd, "flat.example.com"), nestedRow(dd, "acme.example.com"))
+ if err := f.a.Run(context.Background(), false); err != nil {
+ t.Fatal(err)
+ }
+ if r := f.result(); r == nil || r.Outcome != systemOutcomeApplied || !r.matches("stable", tc.version, req.PromotedAt) {
+ t.Fatalf("result = %+v, want applied", r)
+ }
+ })
+ }
+}
+
+// A candidate that ships the rootfs template at or above the floor runs
+// rootfs rows, so the floor never even opens the registry for it.
+func TestApplyAllowsACandidateWithRootfsUnits(t *testing.T) {
+ for _, version := range []string{"v0.29.0", "v0.30.1", "v1.0.0"} {
+ t.Run(version, func(t *testing.T) {
+ f, req := applyHappyVersion(t, version)
+ f.postLayout()
+ f.withRootfsUnit()
+ f.seedRoutes(runtimeRow(f.a.dataDir, "shop.example.com", registry.RuntimeRootfsV1))
+ opened := f.countOpens()
+ if err := f.a.Run(context.Background(), false); err != nil {
+ t.Fatal(err)
+ }
+ if r := f.result(); r == nil || r.Outcome != systemOutcomeApplied || !r.matches("stable", version, req.PromotedAt) {
+ t.Fatalf("result = %+v, want applied", r)
+ }
+ if *opened != 0 {
+ t.Errorf("the floor opened the registry %d times for a candidate that runs rootfs rows", *opened)
+ }
+ })
+ }
+}
+
+// [Astra R1 10] The unit set alone cannot tell Plan 3's lifecycle from
+// Plan 2's: Plan 2's releases ship the rootfs templates without it. So a
+// candidate with the templates and a version below the floor is refused
+// while a row has a runtime, and so is one whose version does not parse (a
+// local build named by a sha), whose unit set says nothing here. A row
+// with a runtime this build does not know is named too, and every host is
+// named once, sorted.
+func TestApplyRefusesPlan2WithRootfsUnits(t *testing.T) {
+ for _, tc := range []struct {
+ name, version string
+ rows func(dd string) []registry.Route
+ hosts string
+ }{
+ {"Plan 2's release", "v0.28.25", func(dd string) []registry.Route {
+ return []registry.Route{flatRow(dd, "flat.example.com"), runtimeRow(dd, "shop.example.com", registry.RuntimeRootfsV1)}
+ }, "shop.example.com"},
+ {"just below the floor", "v0.28.99", func(dd string) []registry.Route {
+ return []registry.Route{runtimeRow(dd, "shop.example.com", registry.RuntimeRootfsV1)}
+ }, "shop.example.com"},
+ {"an unparseable version", "4f3c2a1", func(dd string) []registry.Route {
+ return []registry.Route{runtimeRow(dd, "shop.example.com", registry.RuntimeRootfsV1)}
+ }, "shop.example.com"},
+ {"a runtime this build does not know", "v0.28.25", func(dd string) []registry.Route {
+ return []registry.Route{
+ runtimeRow(dd, "shop.example.com", registry.RuntimeRootfsV1),
+ runtimeRow(dd, "bab.example.com", "rootfs-v9"),
+ nestedRow(dd, "acme.example.com"),
+ }
+ }, "bab.example.com, shop.example.com"},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ f, req := applyHappyVersion(t, tc.version)
+ f.postLayout()
+ f.withRootfsUnit()
+ f.seedRoutes(tc.rows(f.a.dataDir)...)
+ if err := f.a.Run(context.Background(), false); err != nil {
+ t.Fatal(err)
+ }
+ r := f.result()
+ if r == nil || r.Outcome != systemOutcomeRefused || !r.matches("stable", tc.version, req.PromotedAt) {
+ t.Fatalf("result = %+v", r)
+ }
+ if want := rootfsRefusalFor(tc.version, tc.hosts); r.Reason != want {
+ t.Fatalf("reason = %q\nwant %q", r.Reason, want)
+ }
+ f.assertUntouched()
+ })
+ }
+}
+
+// A registry the floor cannot open cannot vouch that no row has a runtime,
+// so its error is the reason and nothing on the box changes.
+func TestApplyRefusesWhenTheRegistryWillNotOpen(t *testing.T) {
+ f, _ := applyHappyVersion(t, "v0.29.0")
+ f.postLayout()
+ f.a.openRegistry = func() (*registry.Registry, error) { return nil, errors.New("registry.db: disk I/O error") }
+ if err := f.a.Run(context.Background(), false); err != nil {
+ t.Fatal(err)
+ }
+ r := f.result()
+ if r == nil || r.Outcome != systemOutcomeRefused {
+ t.Fatalf("result = %+v", r)
+ }
+ if want := rootfsRefusalFor("v0.29.0", "registry.db: disk I/O error"); r.Reason != want {
+ t.Fatalf("reason = %q\nwant %q", r.Reason, want)
+ }
+ f.assertUntouched()
+}
+
+// rootfsRowsPresent names every row with any non-empty runtime, once and
+// sorted, and a registry it cannot list is an error, never an empty box.
+func TestRootfsRowsPresentNamesEveryRuntimeRow(t *testing.T) {
+ dd := t.TempDir()
+ reg, err := registry.Open(filepath.Join(dd, "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, rt := range []registry.Route{
+ flatRow(dd, "flat.example.com"),
+ runtimeRow(dd, "shop.example.com", registry.RuntimeRootfsV1),
+ runtimeRow(dd, "bab.example.com", "rootfs-v9"),
+ nestedRow(dd, "acme.example.com"),
+ } {
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ }
+ hosts, err := rootfsRowsPresent(reg)
+ if err != nil || !slices.Equal(hosts, []string{"bab.example.com", "shop.example.com"}) {
+ t.Fatalf("rootfsRowsPresent = %v, %v", hosts, err)
+ }
+ // List reads through a fresh connection on the file, so a file that is
+ // no longer a database is a registry that cannot be listed.
+ reg.Close()
+ path := filepath.Join(dd, "registry.db")
+ for _, side := range []string{path + "-wal", path + "-shm"} {
+ if err := os.Remove(side); err != nil && !errors.Is(err, os.ErrNotExist) {
+ t.Fatal(err)
+ }
+ }
+ if err := os.WriteFile(path, []byte(strings.Repeat("not a database ", 512)), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ if hosts, err := rootfsRowsPresent(reg); err == nil {
+ t.Fatalf("an unreadable registry listed as %v", hosts)
+ }
+}
+
+// [pf 4.2] Root reads SQLite only through the service-user child. The
+// census stood in for that rule; this test does now. systemapply.go names
+// no registry opener of its own (registry.Open or OpenReadOnly, called or
+// passed as a value), and the one caller of rootfsRowsPresent hands it the
+// *Registry the openRegistry seam returned, whose default is
+// openSystemRegistry.
+func TestSystemApplyOpensNoRegistryItself(t *testing.T) {
+ fset := token.NewFileSet()
+ f, err := parser.ParseFile(fset, "systemapply.go", nil, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if problems := systemApplyRegistryProblems(fset, f); len(problems) > 0 {
+ t.Fatalf("systemapply.go:\n%s", strings.Join(problems, "\n"))
+ }
+ // The guard catches what it looks for.
+ for name, src := range map[string]string{
+ "a direct open": `package host
+import "github.com/carlosframework/platform/internal/registry"
+func (a *systemApplier) x() { registry.Open("p") }
+func (a *systemApplier) y() { open := a.openRegistry; reg, _ := open(); rootfsRowsPresent(reg) }`,
+ "a renamed import": `package host
+import reg "github.com/carlosframework/platform/internal/registry"
+var o = reg.OpenReadOnly
+func (a *systemApplier) y() { open := a.openRegistry; r, _ := open(); rootfsRowsPresent(r) }`,
+ "a registry from elsewhere": `package host
+func (a *systemApplier) y(r *registry.Registry) { rootfsRowsPresent(r) }`,
+ "no caller": `package host
+func (a *systemApplier) y() {}`,
+ } {
+ fx, err := parser.ParseFile(fset, name+".go", src, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(systemApplyRegistryProblems(fset, fx)) == 0 {
+ t.Errorf("%s: the guard reported nothing", name)
+ }
+ }
+}
+
+// systemApplyRegistryProblems is the guard's reading of one file.
+func systemApplyRegistryProblems(fset *token.FileSet, f *ast.File) []string {
+ const regPath = "github.com/carlosframework/platform/internal/registry"
+ var problems []string
+ regName := ""
+ for _, imp := range f.Imports {
+ if p, _ := strconv.Unquote(imp.Path.Value); p == regPath {
+ regName = "registry"
+ if imp.Name != nil {
+ regName = imp.Name.Name
+ }
+ }
+ }
+ ast.Inspect(f, func(n ast.Node) bool {
+ sel, ok := n.(*ast.SelectorExpr)
+ if !ok {
+ return true
+ }
+ if x, ok := sel.X.(*ast.Ident); ok && regName != "" && x.Name == regName && strings.HasPrefix(sel.Sel.Name, "Open") {
+ problems = append(problems, fset.Position(sel.Pos()).String()+": "+regName+"."+sel.Sel.Name)
+ }
+ return true
+ })
+ callers := 0
+ for _, d := range f.Decls {
+ fd, ok := d.(*ast.FuncDecl)
+ if !ok || fd.Body == nil {
+ continue
+ }
+ // Which identifiers hold the seam, and which hold what it returned.
+ seam, fromSeam := map[string]bool{}, map[string]bool{}
+ ast.Inspect(fd.Body, func(n ast.Node) bool {
+ as, ok := n.(*ast.AssignStmt)
+ if !ok || len(as.Rhs) != 1 {
+ return true
+ }
+ switch rhs := as.Rhs[0].(type) {
+ case *ast.SelectorExpr:
+ if rhs.Sel.Name == "openRegistry" {
+ for _, l := range as.Lhs {
+ if id, ok := l.(*ast.Ident); ok {
+ seam[id.Name] = true
+ }
+ }
+ }
+ case *ast.CallExpr:
+ if id, ok := rhs.Fun.(*ast.Ident); ok && seam[id.Name] && len(as.Lhs) > 0 {
+ if l, ok := as.Lhs[0].(*ast.Ident); ok {
+ fromSeam[l.Name] = true
+ }
+ }
+ }
+ return true
+ })
+ ast.Inspect(fd.Body, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+ if id, ok := call.Fun.(*ast.Ident); !ok || id.Name != "rootfsRowsPresent" {
+ return true
+ }
+ callers++
+ if len(call.Args) != 1 {
+ problems = append(problems, fset.Position(call.Pos()).String()+": rootfsRowsPresent takes one argument")
+ return true
+ }
+ if arg, ok := call.Args[0].(*ast.Ident); !ok || !fromSeam[arg.Name] {
+ problems = append(problems, fset.Position(call.Pos()).String()+": rootfsRowsPresent is not handed the openRegistry seam's *Registry")
+ }
+ return true
+ })
+ }
+ if callers != 1 {
+ problems = append(problems, "rootfsRowsPresent has "+strconv.Itoa(callers)+" callers, want 1")
+ }
+ return problems
+}
diff --git a/internal/host/systemapply_test.go b/internal/host/systemapply_test.go
index 3df36d191..971606826 100644
--- a/internal/host/systemapply_test.go
+++ b/internal/host/systemapply_test.go
@@ -1564,10 +1564,13 @@ func TestApplyInstallsAPreLayoutCandidateOverFlatRows(t *testing.T) {
}
// A candidate that ships the mount units understands nested rows, so the
-// guard never even opens the registry for it.
+// guard never even opens the registry for it. It also runs rootfs rows
+// (the rootfs template, at RootfsLifecycleFloor), so the rootfs floor
+// does not open it either.
func TestApplyInstallsAPostLayoutCandidateOverNestedRows(t *testing.T) {
- f, req := applyHappy(t)
+ f, req := applyHappyVersion(t, "v0.29.0")
f.postLayout()
+ f.withRootfsUnit()
f.seedRoutes(nestedRow(f.a.dataDir, "acme.example.com"))
opened := false
f.a.openRegistry = func() (*registry.Registry, error) {
@@ -1577,7 +1580,7 @@ func TestApplyInstallsAPostLayoutCandidateOverNestedRows(t *testing.T) {
if err := f.a.Run(context.Background(), false); err != nil {
t.Fatal(err)
}
- if r := f.result(); r == nil || r.Outcome != systemOutcomeApplied || !r.matches("stable", "v2", req.PromotedAt) {
+ if r := f.result(); r == nil || r.Outcome != systemOutcomeApplied || !r.matches("stable", "v0.29.0", req.PromotedAt) {
t.Fatalf("result = %+v", r)
}
if opened {
@@ -1715,7 +1718,10 @@ func floorFixture(t *testing.T, running, target string) (*applyFixture, systemRe
bin, staged, prev := systemBinaryPath(f.a.optDir), filepath.Join(f.a.stagingDir(), "carlos"), systemPrevPath(f.a.optDir)
f.answer["version:"+staged] = "carlos " + target + "\n"
f.answer["plan:"+staged] = f.answer["plan:"+bin]
- f.answer["units:"+staged] = f.answer["units:"+bin] + " " + layoutMountUnit
+ // The candidate is of the floor's era: it ships the layout and the rootfs
+ // lifecycle (every target here is at or above RootfsLifecycleFloor), so
+ // neither the layout floor nor the rootfs floor opens the registry.
+ f.answer["units:"+staged] = f.answer["units:"+bin] + " " + layoutMountUnit + " " + rootfsInstanceUnit
f.answer["plan:"+prev] = f.answer["plan:"+bin]
f.answer["units:"+prev] = f.answer["units:"+bin]
// Every binary answers `version` from its own bytes from here on.
diff --git a/internal/release/layoutintent.go b/internal/release/layoutintent.go
index f488f603a..f5d15450e 100644
--- a/internal/release/layoutintent.go
+++ b/internal/release/layoutintent.go
@@ -210,6 +210,21 @@ func AppendLayoutIntent(ctx context.Context, s Store, in LayoutIntent) (LayoutIn
// this floor. TestLayoutFloorIsTheFirstReleaseWhereNestedRowsWake pins it.
var LayoutFloor = SemVer{Major: 0, Minor: 25, Patch: 0}
+// RootfsLifecycleFloor is the first platform release that runs rootfs
+// instances' lifecycle (rootfs apps Plan 3, Group A: resident rows, the
+// rootfs swap, carlos run). Plan 2's releases (v0.28.17 on) already ship
+// the rootfs unit templates without it, so the unit set cannot tell the
+// two apart, as with LayoutFloor. The latest tag at the time of writing is
+// v0.28.25, and v0.28.x releases are still cut from a main without Group
+// A, so this names a minor bump: the first release cut from a main that
+// contains Group A MUST be v0.29.0, and no release without Group A may be
+// numbered v0.29.0 or later.
+//
+// The box-side guard (host/systemapply.go) refuses a candidate below this
+// floor, or whose version does not parse, while the box has a row with a
+// runtime. TestRootfsLifecycleFloorIsPinned pins it.
+var RootfsLifecycleFloor = SemVer{Major: 0, Minor: 29, Patch: 0}
+
// ParseReleaseVersion parses a release tag with or without its leading v.
func ParseReleaseVersion(version string) (SemVer, bool) {
return ParseSemVer(strings.TrimPrefix(version, "v"))
diff --git a/internal/release/layoutintent_test.go b/internal/release/layoutintent_test.go
index fdd32e88b..f8ef9ac26 100644
--- a/internal/release/layoutintent_test.go
+++ b/internal/release/layoutintent_test.go
@@ -130,6 +130,27 @@ func TestLayoutFloorIsTheFirstReleaseWhereNestedRowsWake(t *testing.T) {
}
}
+// TestRootfsLifecycleFloorIsPinned pins the first release that runs rootfs
+// instances' lifecycle (rootfs apps Plan 3, Group A). Plan 2's releases
+// (v0.28.17 on) already ship the rootfs unit templates, so the box-side
+// rollback floor (host/systemapply.go) needs a version as well as the unit
+// set. The latest tag at the time of writing is v0.28.25, and releases
+// were still being cut from a main without Group A, so the floor is a
+// minor bump: the first release cut from a main that contains Group A MUST
+// be v0.29.0, and no release without Group A may be numbered v0.29.0 or
+// later. Moving the constant means re-checking the tags, not editing this
+// test to match.
+func TestRootfsLifecycleFloorIsPinned(t *testing.T) {
+ if RootfsLifecycleFloor != (SemVer{Major: 0, Minor: 29, Patch: 0}) {
+ t.Fatalf("RootfsLifecycleFloor = %+v, want v0.29.0 (the first release carrying Plan 3's Group A)", RootfsLifecycleFloor)
+ }
+ for v, below := range map[string]bool{"v0.28.17": true, "v0.28.25": true, "v0.28.99": true, "v0.29.0": false, "v1.0.0": false, "dev": false} {
+ if got := BelowFloor(v, RootfsLifecycleFloor); got != below {
+ t.Errorf("BelowFloor(%q, RootfsLifecycleFloor) = %v, want %v", v, got, below)
+ }
+ }
+}
+
func TestRecordLayoutIntentAppendsWithForceAndScope(t *testing.T) {
s := NewDirStore(t.TempDir())
ctx := context.Background()