Merge origin/main into region-ha-p3b2-build
Chains the hosts-floor-release overlay before region-ha-p3b2 and re-pins the root package envelope over the merged tree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 files changed,
+1,423
−15
README.md+15 −2accounts_hostsused.go+17 −4accounts_record_sequence_test.go+26 −0cmd/console/hostsused.go+18 −1cmd/console/hostsused_floor_test.go+94 −0cmd/console/main.go+1 −1cmd/console/main_test.go+4 −3docs/superpowers/notes/census-proposal-hosts-floor-release.md+11 −0docs/superpowers/notes/copy/hosts-floor-names-a-release.md+78 −0docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r1.md+20 −0docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r2.md+29 −0docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r3.md+11 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release-R2.md+88 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release-R3.md+102 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release.md+75 −0docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md+113 −0internal/console/hostsused_activate.go+9 −2internal/console/hostsused_activate_test.go+1 −1internal/console/hostsused_floor.go+307 −0internal/console/hostsused_floor_test.go+399 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-hosts-floor-release.tsv+3 −0internal/provision/testdata/plan14-root-reads-region-ha-p3b2.tsv+1 −1
CI passed — run details
Intent
Human
<task-notification> <task-id>byljvgd4u</task-id> <tool-use-id>toolu_014DHht39uxfSKzuceuHYr2r</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/e47280e8-3e59-4dc1-95d2-11de7237d34c/tasks/byljvgd4u.output</output-file> <status>completed</status> <summary>Background command ".superpowers/sdd/2026-11-04-region-ha-p3b-group/run-astra.sh final" completed (exit code 0)</summary> </task-notification>
diff --git a/README.md b/README.md| index 25a9e7ca9..0c001bb43 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -247,7 +247,7 @@ step, and an unhurried one now that nothing resolves through them. |
| A release is a `vX.Y.Z` tag on this repo plus signed binaries on [carlosframework/releases](https://github.com/carlosframework/releases). Everything downstream reads that one set of files: `carlos update`, the Homebrew tap, apt, and every deployment's `carlos system update`. Cut it from a green `main` and verify it from the public side, never from your build directory. |
| 1. **Tag.** `git tag -a vX.Y.Z <sha> -m "carlos vX.Y.Z"` on the `main` commit you are releasing, then `git push origin vX.Y.Z` to the forge. |
| -2. **Build.** Six targets, darwin, linux and windows on amd64 and arm64, each with `make build GOOS=<os> GOARCH=<arch> SHA=vX.Y.Z` from a clean checkout of the tag. Build with `TMPDIR` and `GOCACHE` on a real disk: `/tmp` is a shared tmpfs, and a full one fails the link with "no space left on device". Zip each Windows binary as a lone `carlos.exe`. Build the console the same way, with `make build-console GOOS=linux GOARCH=<arch> SHA=vX.Y.Z` for amd64 and arm64, and name the two `carlos-console-linux-<arch>`. Both targets stamp the tag's full commit into the binary. The console writes that commit into the hostname history's floor, and the console roll script refuses a floor with no commit. `console hosts-used activate` refuses a console without a full commit. |
| +2. **Build.** Six targets, darwin, linux and windows on amd64 and arm64, each with `make build GOOS=<os> GOARCH=<arch> SHA=vX.Y.Z` from a clean checkout of the tag. Build with `TMPDIR` and `GOCACHE` on a real disk: `/tmp` is a shared tmpfs, and a full one fails the link with "no space left on device". Zip each Windows binary as a lone `carlos.exe`. Build the console the same way, with `make build-console GOOS=linux GOARCH=<arch> SHA=vX.Y.Z` for amd64 and arm64, and name the two `carlos-console-linux-<arch>`. Both targets stamp the tag's full commit into the binary. The console writes that commit into the hostname history's floor, and the console roll script refuses a floor with no commit. `console hosts-used activate` refuses a console that isn't a release build or doesn't name a full commit. |
| 3. **Debs.** One per architecture, built with `dpkg-deb --root-owner-group`, holding `usr/bin/carlos`. Copy the last release's `control` and change the version and the description's last sentence. Wrap the description without breaking on hyphens, or apt shows "step- by-step". |
| 4. **Sums and signature.** Write `SHA256SUMS.txt` over the eight files. Sign it with the ed25519 seed in SSM `/carlos/cli-update-key`, passed on stdin and never in argv, and write the signature base64-encoded to `SHA256SUMS.txt.sig`. Before signing, check that the key's public half equals `cliUpdatePubKey` in `update.go`. A mismatch publishes a release nobody can update to. Write `CONSOLE_SHA256SUMS.txt` over the two console binaries and sign it the same way, to `CONSOLE_SHA256SUMS.txt.sig`. Keep the console out of `SHA256SUMS.txt`: `carlos update` reads that file. The public self-host guide downloads the console and checks this signature, so a release without it leaves the guide on an older console. |
| 5. **Release notes.** Draft them, and put them through copy review before anything is published. Lead with what changed for people using the CLI. Add a short section for operators, taken from the release notes below this recipe, about anything to check before rolling. |
| @@ -390,11 +390,24 @@ add the box, then complete the history again. |
| **The history's floor.** Completing writes the floor to |
| `control/hosts-used/@floor`. The floor is the release that completed the |
| history and the commit it was built from, and `status` shows both. |
| -Completing refuses a console that doesn't name its commit. From then on, never run a console or |
| +Completing refuses a console that isn't a release build or doesn't name |
| +its commit. From then on, never run a console or |
| `carlos accounts migrate` older than the floor: an older build creates |
| records without recording them. The roll script refuses a console below |
| the floor, and `carlos accounts migrate` refuses to run below it. |
| +A floor written by a console that wasn't a release names only a commit. |
| +`carlos accounts migrate` can't tell whether a release contains a commit, |
| +so it refuses every release. Give the floor a release: with the deployment |
| +bucket's credentials and the vX.Y.Z release console, run `console |
| +hosts-used raise-floor -release vX.Y.Z -checkout <checkout>` in a platform |
| +checkout with its tags fetched. It accepts only the running console's |
| +release. The console's stamped commit identifies its source commit, and |
| +the checkout's tag must agree; a local tag alone isn't trusted because it |
| +can be moved. It checks that this commit contains the floor's commit, then |
| +writes the release and commit as the floor. Builds older than that release |
| +are refused from then on, so roll it out to every console and box first. |
| + |
| **Restores.** Restoring the console's database alone is safe. A restore of |
| the control bucket must keep every object under `control/hosts-used/`. If |
| any objects may have been dropped, stop the console, run `console |
diff --git a/accounts_hostsused.go b/accounts_hostsused.go| index 7bcf2f295..f7ae2ed0c 100644 |
| --- a/accounts_hostsused.go |
| +++ b/accounts_hostsused.go |
| @@ -30,19 +30,32 @@ func msgMigrateHoldsData(name string) string { |
| return name + ": not migrated. carlos accounts migrate doesn't move an instance that holds data." |
| } |
| +// msgMigrateFloorNoRelease is B11: a floor that names a commit and no |
| +// release, which no build but that commit's own can show it is above. |
| +func msgMigrateFloorNoRelease(floor string) string { |
| + return "the hostname history's floor, " + floor + ", names a commit and not a release, so this carlos can't tell whether it is at or above it. " + |
| + "give the floor a release with console hosts-used raise-floor, then run this again." |
| +} |
| + |
| // checkMigrationFloor reads the history's floor and refuses a build below |
| // it (B10). A build is at or above it when both are release tags and this |
| // one is not older, or when it is the floor's own commit; anything else (a |
| -// dev build, a bare commit) cannot show it is, and refuses. |
| +// dev build, a bare commit) cannot show it is, and refuses. A binary has no |
| +// git history, so against a floor that names only a commit every other |
| +// build refuses, and is told to give the floor a release (B11; design |
| +// 2026-11-05-hosts-floor-names-a-release) rather than to update. |
| func checkMigrationFloor(ctx context.Context, store release.Store, build, commit string) error { |
| floor, _, err := provision.ReadHostsFloor(ctx, store) |
| if err != nil { |
| return fmt.Errorf("accounts migrate: read the hostname history's floor: %w", err) |
| } |
| - if floor != nil && !buildMeetsFloor(*floor, build, commit) { |
| - return errors.New("this carlos is older than the hostname history's floor, " + floor.Version + ". update carlos, then run it again.") |
| + if floor == nil || buildMeetsFloor(*floor, build, commit) { |
| + return nil |
| } |
| - return nil |
| + if !releaseBuild(floor.Version) { |
| + return errors.New(msgMigrateFloorNoRelease(floor.Version)) |
| + } |
| + return errors.New("this carlos is older than the hostname history's floor, " + floor.Version + ". update carlos, then run it again.") |
| } |
| func buildMeetsFloor(floor provision.HostsFloor, build, commit string) bool { |
diff --git a/accounts_record_sequence_test.go b/accounts_record_sequence_test.go| index f3b6634a8..1aceff6ec 100644 |
| --- a/accounts_record_sequence_test.go |
| +++ b/accounts_record_sequence_test.go |
| @@ -379,3 +379,29 @@ func TestCLIRefusesBelowFloor(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// TestCLIBareCommitFloorSaysRaiseIt (hosts-floor-names-a-release design): |
| +// a floor that names a commit and no release still refuses every build but |
| +// its own commit, since a binary cannot tell whether it contains a commit, |
| +// and the refusal says how to give the floor a release instead of telling |
| +// a release that may well be newer to update. |
| +func TestCLIBareCommitFloorSaysRaiseIt(t *testing.T) { |
| + store := release.NewDirStore(t.TempDir()) |
| + ctx := context.Background() |
| + commit := "50c0cb14b429993b89bcb71dbf51a645580cc4aa" |
| + if _, err := provision.WriteHostsFloor(ctx, store, provision.HostsFloor{Version: "50c0cb14", Commit: commit}, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + want := "the hostname history's floor, 50c0cb14, names a commit and not a release, so this carlos can't tell whether it is at or above it. " + |
| + "give the floor a release with console hosts-used raise-floor, then run this again." |
| + for _, build := range []struct{ version, commit string }{ |
| + {"v0.34.3", "e047662751aaaedbad638d1ab9279d32f5860914"}, {"v0.1.0", ""}, {"dev", ""}, {"0123abc", "0123abcdef"}, |
| + } { |
| + if err := checkMigrationFloor(ctx, store, build.version, build.commit); err == nil || err.Error() != want { |
| + t.Errorf("%+v against a bare-commit floor = %v, want %q", build, err, want) |
| + } |
| + } |
| + if err := checkMigrationFloor(ctx, store, "50c0cb14", commit); err != nil { |
| + t.Errorf("the floor's own commit = %v, want allowed", err) |
| + } |
| +} |
diff --git a/cmd/console/hostsused.go b/cmd/console/hostsused.go| index ea2d790c0..e3665f367 100644 |
| --- a/cmd/console/hostsused.go |
| +++ b/cmd/console/hostsused.go |
| @@ -17,7 +17,7 @@ import ( |
| "github.com/carlosframework/platform/internal/provision" |
| ) |
| -// console hosts-used roster | activate | invalidate (nearest-region |
| +// console hosts-used roster | activate | invalidate | raise-floor (nearest-region |
| // never-reuse; Paul's cut on #404): the hostname history is made active, and |
| // invalidated by an operator, offline, on the console's box with the |
| // console stopped. roster, activate and invalidate take the console's serve |
| @@ -139,6 +139,23 @@ func runHostsUsed(args []string) { |
| log.Fatal(err) |
| } |
| fmt.Printf(msgActivated+"\n", n) |
| + case "raise-floor": |
| + // The floor names a release (hostsused_floor.go). No serve lock and |
| + // no database: only activate writes the floor besides this, under |
| + // the lock, and this write is conditional on the floor it read. So |
| + // it runs anywhere with the bucket and a platform checkout. |
| + fs := flag.NewFlagSet("hosts-used raise-floor", flag.ExitOnError) |
| + rel := fs.String("release", "", "the release the floor names from now on") |
| + checkout := fs.String("checkout", "", "a platform checkout that has the release's tag") |
| + fs.Parse(args[1:]) |
| + if *rel == "" || *checkout == "" || fs.NArg() != 0 { |
| + usage() |
| + } |
| + from, to, err := console.RaiseHostsFloor(ctx, openStore(nil), console.HostsFloorNow(), *rel, console.GitCheckout{Dir: *checkout}) |
| + if err != nil { |
| + log.Fatal(err) |
| + } |
| + fmt.Println(console.MsgFloorRaised(from, to)) |
| case "invalidate": |
| if len(args) != 1 { |
| usage() |
diff --git a/cmd/console/hostsused_floor_test.go b/cmd/console/hostsused_floor_test.go| new file mode 100644 |
| index 000000000..e3582039a |
| --- /dev/null |
| +++ b/cmd/console/hostsused_floor_test.go |
| @@ -0,0 +1,94 @@ |
| +//go:build !windows |
| + |
| +package main |
| + |
| +import ( |
| + "context" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// TestHostsUsedRaiseFloorThroughTheBinary (hosts-floor-names-a-release |
| +// design): a release console, run with a platform checkout, gives a floor |
| +// that names only a commit its own release when that release contains it, |
| +// and refuses another release, writing nothing. buildConsole is |
| +// servelock_test.go's, so this file shares its build constraint. It needs no console database and |
| +// no serve lock: it writes only the floor, conditionally. |
| +func TestHostsUsedRaiseFloorThroughTheBinary(t *testing.T) { |
| + if _, err := exec.LookPath("git"); err != nil { |
| + t.Skip("git is not installed") |
| + } |
| + repo := filepath.Join(t.TempDir(), "platform") |
| + git := func(args ...string) string { |
| + t.Helper() |
| + cmd := exec.Command("git", append([]string{"-C", repo, "-c", "user.name=t", "-c", "user.email=t@example.com", "-c", "commit.gpgsign=false", "-c", "tag.gpgsign=false"}, args...)...) |
| + cmd.Env = append(cmd.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null") |
| + out, err := cmd.CombinedOutput() |
| + if err != nil { |
| + t.Fatalf("git %v: %v\n%s", args, err, out) |
| + } |
| + return strings.TrimSpace(string(out)) |
| + } |
| + if out, err := exec.Command("git", "init", "-q", "-b", "main", repo).CombinedOutput(); err != nil { |
| + t.Fatalf("git init: %v\n%s", err, out) |
| + } |
| + commit := func(msg string) string { |
| + git("commit", "-q", "--allow-empty", "-m", msg) |
| + return git("rev-parse", "HEAD") |
| + } |
| + commit("before") |
| + git("tag", "-a", "v9.9.7", "-m", "carlos v9.9.7") |
| + floor := commit("the floor") |
| + commit("released") |
| + git("tag", "-a", "v9.9.8", "-m", "carlos v9.9.8") |
| + built := commit("this console") |
| + git("tag", "-a", "v9.9.9", "-m", "carlos v9.9.9") |
| + |
| + ld := "-X github.com/carlosframework/platform/internal/version.Build=v9.9.9 -X github.com/carlosframework/platform/internal/version.Commit=" + built |
| + bin, dir := buildConsole(t, "-buildvcs=false", "-ldflags", ld) |
| + store := release.NewDirStore(filepath.Join(dir, "bucket")) |
| + if err := os.MkdirAll(filepath.Join(dir, "bucket"), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + bare := provision.HostsFloor{Version: floor[:8], Commit: floor} |
| + if _, err := provision.WriteHostsFloor(context.Background(), store, bare, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + db := filepath.Join(dir, "no-console.db") |
| + // runConsole's environment, with PATH so the binary finds git. |
| + run := func(args ...string) string { |
| + t.Helper() |
| + cmd := exec.Command(bin, args...) |
| + cmd.Dir = dir |
| + cmd.Env = []string{"CONSOLE_DB=" + db, "CARLOS_DEPLOYMENT_DIR=" + filepath.Join(dir, "bucket"), |
| + "CARLOS_REGISTRY=" + filepath.Join(dir, "registry.db"), "HOME=" + dir, "PATH=" + os.Getenv("PATH")} |
| + out, _ := cmd.CombinedOutput() |
| + return string(out) |
| + } |
| + |
| + out := run("hosts-used", "raise-floor", "-release", "v9.9.8", "-checkout", repo) |
| + if !strings.Contains(out, "This console is v9.9.9, not v9.9.8.") { |
| + t.Fatalf("raise-floor to another release printed:\n%s", out) |
| + } |
| + if f, _, err := provision.ReadHostsFloor(context.Background(), store); err != nil || f == nil || *f != bare { |
| + t.Fatalf("floor after the refusal = %+v %v, want %+v", f, err, bare) |
| + } |
| + |
| + out = run("hosts-used", "raise-floor", "-release", "v9.9.9", "-checkout", repo) |
| + want := "The hostname history's floor is now v9.9.9 (" + built + "). It was " + floor[:8] + " (" + floor + ")." |
| + if !strings.Contains(out, want) { |
| + t.Fatalf("raise-floor printed:\n%s\nwant %q", out, want) |
| + } |
| + if f, _, err := provision.ReadHostsFloor(context.Background(), store); err != nil || f == nil || *f != (provision.HostsFloor{Version: "v9.9.9", Commit: built}) { |
| + t.Fatalf("floor = %+v %v, want v9.9.9 at %s", f, err, built) |
| + } |
| + if _, err := os.Stat(db); !os.IsNotExist(err) { |
| + t.Fatalf("raise-floor opened a console database: %v", err) |
| + } |
| +} |
diff --git a/cmd/console/main.go b/cmd/console/main.go| index 8f3f0395a..013660429 100644 |
| --- a/cmd/console/main.go |
| +++ b/cmd/console/main.go |
| @@ -239,7 +239,7 @@ func usage() { |
| log.Fatal("usage: console serve | grant [-operator] <address> [<app>] | revoke [-operator] <address> [<app>] | owners | " + |
| "member -add|-remove <address> <account-sqid> [-role owner|member] | member -list <account-sqid> | " + |
| "migrate-app -app <app> -to <sqid> [-from <sqid>] | " + |
| - "hosts-used roster -o <file> | hosts-used activate -roster <file> -listings <file> [-close-fleet <fleet>]... | hosts-used invalidate") |
| + "hosts-used roster -o <file> | hosts-used activate -roster <file> -listings <file> [-close-fleet <fleet>]... | hosts-used invalidate | hosts-used raise-floor -release <vX.Y.Z> -checkout <dir>") |
| } |
| // migrateApp completes the second half of `carlos accounts migrate`: that |
diff --git a/cmd/console/main_test.go b/cmd/console/main_test.go| index 086b7f6f6..d75081aa2 100644 |
| --- a/cmd/console/main_test.go |
| +++ b/cmd/console/main_test.go |
| @@ -36,10 +36,11 @@ func buildConsole(t *testing.T) string { |
| return |
| } |
| consoleBin = filepath.Join(buildDir, "console") |
| - // The commit is stamped as the release recipe stamps it: activation |
| - // refuses a console that names none (#442). |
| + // The release and the commit are stamped as the release recipe |
| + // stamps them: activation refuses a console that names no commit |
| + // (#442) or no release (hosts-floor-names-a-release design). |
| build := exec.Command(goBin, "build", "-ldflags", |
| - "-X github.com/carlosframework/platform/internal/version.Commit=0123456789abcdef0123456789abcdef01234567", |
| + "-X github.com/carlosframework/platform/internal/version.Build=v9.9.9 -X github.com/carlosframework/platform/internal/version.Commit=0123456789abcdef0123456789abcdef01234567", |
| "-o", consoleBin, ".") |
| build.Env = os.Environ() |
| if out, err := build.CombinedOutput(); err != nil { |
diff --git a/docs/superpowers/notes/census-proposal-hosts-floor-release.md b/docs/superpowers/notes/census-proposal-hosts-floor-release.md| new file mode 100644 |
| index 000000000..50923ed15 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-hosts-floor-release.md |
| @@ -0,0 +1,11 @@ |
| +# Census approval: hosts-floor-release |
| + |
| +Ruling `census-ruling-hosts-floor-release`. 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). |
| + |
| +Envelopes re-pinned: `.`. |
| + |
| +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. |
| + |
| +Seal: `1daafee8030f9d370adf5541b5e87313523073c4afdc022d4238c3a7bc1a60ba` → `1daafee8030f9d370adf5541b5e87313523073c4afdc022d4238c3a7bc1a60ba`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-hosts-floor-release.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/copy/hosts-floor-names-a-release.md b/docs/superpowers/notes/copy/hosts-floor-names-a-release.md| new file mode 100644 |
| index 000000000..f2dfa51cc |
| --- /dev/null |
| +++ b/docs/superpowers/notes/copy/hosts-floor-names-a-release.md |
| @@ -0,0 +1,78 @@ |
| +# The floor names a release: approved copy |
| + |
| +approved by delegated Luna pass on Paul's standing rule, 2026-11-05 (gpt-6-luna, `codex exec -s read-only`). Pass 1: every string approved as drafted except the README's new paragraph, rewritten by Luna. Pass 2, after Astra r1 restricted raise-floor to the running console's release: C14 (now names SHA=<tag>, Astra r1 P2-3) approved; R3 and the README paragraph rewritten by Luna. R10 was removed. Pass 3, after Astra r2: R14 (a grafted checkout) rewritten by Luna. All applied verbatim. Placeholders are in angle brackets. Design: docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md. |
| + |
| +## Strings |
| + |
| +C14 (`console hosts-used activate`, a console that isn't a release build, before anything is written): |
| +This console isn't a release build, so the history's floor can't name a release. Build it from a release tag with make build-console SHA=<tag>, then run this again. |
| + |
| +`console hosts-used raise-floor`: |
| +R1 <name> isn't a release tag. Name one like v0.34.4. |
| +R2 This console isn't a release build, so it can't vouch for a release. Run this with a release console. |
| +R3 This console is <build>, not <release>. Run this with the <release> console. Its stamped commit identifies the commit for that release. |
| +R4 The hostname history has no floor yet. Completing the history writes one. |
| +R5 The floor already names a release, <version>. |
| +R6 The floor doesn't name a full commit, so the checkout can't show that <release> contains it. |
| +R7 The checkout has no tag <release>. Fetch the platform repo's tags, then run this again. |
| +R8 The checkout doesn't have commit <commit>. Fetch the platform repo, then run this again. |
| +R9 The checkout's tag <release> names <tag commit>, but this console was built from <commit>. |
| +R11 <release> doesn't contain the floor's commit, <commit>. Name a later release. |
| +R12 The floor changed while this ran. Run this again. |
| +R13 The hostname history's floor is now <release> (<commit>). It was <old version> (<old commit>). |
| +R14 The checkout has a grafts file, which changes Git's commit history. Ancestry checks in this checkout cannot be trusted. Use a fresh clone of the platform repository. |
| + |
| +B11 (`carlos accounts migrate` against a floor that names only a commit): |
| +the hostname history's floor, <floor version>, names a commit and not a release, so this carlos can't tell whether it is at or above it. give the floor a release with console hosts-used raise-floor, then run this again. |
| + |
| +N9, appended to the console binary's usage line: |
| +hosts-used raise-floor -release <vX.Y.Z> -checkout <dir> |
| + |
| +README, "Releasing the platform" step 2, last sentence: |
| +`console hosts-used activate` refuses a console that isn't a release build or doesn't name a full commit. |
| + |
| +README, "The history's floor", replacing "Completing refuses a console that doesn't name its commit.": |
| +Completing refuses a console that isn't a release build or doesn't name its commit. |
| + |
| +README, "The history's floor", new paragraph (Luna's pass 2 rewrite): |
| +A floor written by a console that wasn't a release names only a commit. `carlos accounts migrate` can't tell whether a release contains a commit, so it refuses every release. Give the floor a release: with the deployment bucket's credentials and the vX.Y.Z release console, run `console hosts-used raise-floor -release vX.Y.Z -checkout <checkout>` in a platform checkout with its tags fetched. It accepts only the running console's release. The console's stamped commit identifies its source commit, and the checkout's tag must agree; a local tag alone isn't trusted because it can be moved. It checks that this commit contains the floor's commit, then writes the release and commit as the floor. Builds older than that release are refused from then on, so roll it out to every console and box first. |
| + |
| +## Luna's replies, whole |
| + |
| +Pass 1: |
| + |
| +``` |
| +C14 APPROVE |
| +R1 APPROVE |
| +R2 APPROVE |
| +R3 APPROVE |
| +R4 APPROVE |
| +R5 APPROVE |
| +R6 APPROVE |
| +R7 APPROVE |
| +R8 APPROVE |
| +R9 APPROVE |
| +R10 APPROVE |
| +R11 APPROVE |
| +R12 APPROVE |
| +R13 APPROVE |
| +B11 APPROVE |
| +N9 APPROVE |
| +README step 2 APPROVE |
| +README floor sentence APPROVE |
| +README new paragraph REWRITE: A floor written by a console that wasn't a release names only a commit. `carlos accounts migrate` can't tell whether a release contains a commit, so it refuses every release. Give the floor the oldest release that contains the commit. In a platform checkout with its tags fetched, `git tag --contains <commit>` lists tags that contain it; choose the oldest release by version. Then, with the deployment bucket's credentials and a release console at that release or later, run `console hosts-used raise-floor -release vX.Y.Z -checkout <checkout>`. It checks that the release contains the floor's commit and writes the release and its commit as the floor. |
| +``` |
| + |
| +Pass 2: |
| + |
| +``` |
| +C14 APPROVE |
| +R3 REWRITE: This console is <build>, not <release>. Run this with the <release> console. Its stamped commit identifies the commit for that release. |
| +README REWRITE: A floor written by a console that wasn't a release names only a commit. `carlos accounts migrate` can't tell whether a release contains a commit, so it refuses every release. Give the floor a release: with the deployment bucket's credentials and the vX.Y.Z release console, run `console hosts-used raise-floor -release vX.Y.Z -checkout <checkout>` in a platform checkout with its tags fetched. It accepts only the running console's release. The console's stamped commit identifies its source commit, and the checkout's tag must agree; a local tag alone isn't trusted because it can be moved. It checks that this commit contains the floor's commit, then writes the release and commit as the floor. Builds older than that release are refused from then on, so roll it out to every console and box first. |
| +``` |
| + |
| +Pass 3: |
| + |
| +``` |
| +R14 REWRITE: The checkout has a grafts file, which changes Git's commit history. Ancestry checks in this checkout cannot be trusted. Use a fresh clone of the platform repository. |
| +``` |
diff --git a/docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r1.md b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r1.md| new file mode 100644 |
| index 000000000..2bb148b72 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r1.md |
| @@ -0,0 +1,20 @@ |
| +1. **P1 — Raise-floor: a moved older tag can lower the effective floor.** |
| + [hostsused_floor.go:153](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/console/hostsused_floor.go:153) checks an older tag’s ancestry, but does not establish that it identifies the published release. If local `v0.28.28` is moved to `50c0cb14`, a newer release console passes both ancestry checks and writes that version as the floor. The published `v0.28.28` then passes [accounts_hostsused.go:65](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/accounts_hostsused.go:65), despite lacking the original floor commit. Read-only Git checks verified that published `v0.28.28` lacks `50c0cb14`, while `v0.34.3` contains it. |
| + **Fix:** require authenticated release-to-commit evidence for older releases; otherwise restrict raising to the running console’s own release and exact stamped commit. Add a regression covering an older tag moved to a valid ancestor. |
| + **Fault family:** release identity—the release comparison must never admit a build lacking the original floor commit. |
| + |
| +2. **P1 — Tests: the new binary test does not compile on Windows.** |
| + [hostsused_floor_test.go:51](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/cmd/console/hostsused_floor_test.go:51) calls `buildConsole`, whose same-package definition is in [servelock_test.go:46](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/cmd/console/servelock_test.go:46), behind `//go:build !windows`. The new file has no corresponding constraint. `GOOS=windows go list` confirms that it includes the caller and excludes the helper. The similarly named helper in `main_test.go` belongs to the separate `main_test` package. Windows test compilation therefore encounters an undefined identifier. |
| + **Fix:** add the matching build constraint, or move the helper into a portable test file and make the test portable. |
| + **Fault family:** platform-specific test dependency closure. |
| + |
| +3. **P2 — Activation refusal: the suggested build command does not produce a release stamp.** |
| + [hostsused_floor.go:28](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/console/hostsused_floor.go:28) instructs operators to build from a release tag with `make build-console`. However, [Makefile:1](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/Makefile:1) sets `SHA` to the short commit even when HEAD is a release tag. Following that instruction produces another build that activation refuses. |
| + **Fix:** specify `make build-console SHA=vX.Y.Z` from the corresponding tag, matching the README’s release recipe. |
| + **Fault family:** actionable refusal—the prescribed recovery must satisfy the failed check. |
| + |
| +Targeted Go tests could not start because the read-only sandbox prevented creation of Go’s temporary work directory. Formatting and diff checks passed. The 31-release ancestry claim was verified. |
| + |
| +**Census envelope `.`: APPROVE.** I read [accounts_hostsused.go:33](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/accounts_hostsused.go:33) through line 70 and [hostsused.go:205](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/provision/hostsused.go:205) through line 218. The root-package change preserves the acceptance predicate and existing read; it changes refusal text only. It introduces no new root access or weakened check. Independently recomputing the envelope matched [the proposed fingerprint](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/provision/testdata/plan14-root-reads-hosts-floor-release.tsv:3). |
| + |
| +**NOT READY** |
| \ No newline at end of file |
diff --git a/docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r2.md b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r2.md| new file mode 100644 |
| index 000000000..cd4ce7ea5 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r2.md |
| @@ -0,0 +1,29 @@ |
| +R1 P1-1 — **Resolved:** the requested release must equal the running console’s release, and its tag must match the stamped commit (`hostsused_floor.go:125–150`). |
| +R1 P1-2 — **Resolved:** the binary test now shares its helper’s `!windows` constraint; Windows `go list` excludes it. |
| +R1 P2-3 — **Resolved:** C14 specifies `make build-console SHA=<tag>`, matching the Makefile’s version stamping. |
| + |
| +1. **P1 — Raise-floor: Git grafts can falsify the ancestry proof.** |
| + |
| + **Evidence:** [hostsused_floor.go:177](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/console/hostsused_floor.go:177) inherits Git’s environment and repository configuration. [Line 226](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/console/hostsused_floor.go:226) accepts Git’s ancestry result without excluding grafts or replacement objects. |
| + |
| + **Failure scenario:** a release console’s genuine commit lacks the existing floor commit, but the operator’s checkout supplies rewritten ancestry. The tag still matches the stamped commit; `Contains` succeeds; the verb writes a release floor that admits a build lacking the old floor. Read-only reproduction confirmed the mechanism: ancestry of `50c0cb14` in `v0.28.28` returned exit 1 normally and exit 0 with an inherited `GIT_GRAFT_FILE`, without changing either object or tag. |
| + |
| + **Fix:** refuse grafted history before checking ancestry and disable replacement objects for every Git invocation. Cover repository-local grafts and inherited overrides, with a regression proving refusal leaves the floor unchanged. |
| + |
| + **Fault family:** authentic ancestry—the accepted release must contain the original floor commit. |
| + |
| +2. **P1 — Raise-floor: “full commit” validation permits ref substitution across hash formats.** |
| + |
| + **Evidence:** [hostsused_activate.go:302](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/console/hostsused_activate.go:302) accepts either 40 or 64 hex characters without checking the checkout’s object format. [hostsused_floor.go:217](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/console/hostsused_floor.go:217) passes these strings directly to `cat-file` and `merge-base`. Git treats a hexadecimal string as an exact object ID only when its length matches the repository’s hash format; otherwise ref lookup remains possible. Verified in Git’s resolver: [https://raw.githubusercontent.com/git/git/v2.43.0/object-name.c](https://raw.githubusercontent.com/git/git/v2.43.0/object-name.c). |
| + |
| + **Failure scenario:** a SHA-256 checkout contains a branch named after the old floor’s 40-character SHA-1 ID, pointing at an ancestor of the running console’s genuine 64-character commit. Both Git checks follow that branch and succeed, although the old floor object is absent. The tag/stamp equality check does not catch this substitution. |
| + |
| + **Fix:** require both commits to match the checkout’s object format and resolve them through object-only lookup, requiring exact identity before ancestry checking. Add SHA-256 and mismatched-format ref regressions. |
| + |
| + **Fault family:** object identity—a ref must never substitute for the stored floor commit. |
| + |
| +Targeted Go tests could not start: Go’s temporary work directory was denied by the read-only sandbox. Review proceeded by reading and read-only checks. The 31-release ancestry claim and changed Go files’ formatting were verified. HEAD `109c4f97` differs from reviewed implementation `c5a9a576` only by the round-2 brief. |
| + |
| +**Census envelope `.`: APPROVE.** I read [accounts_hostsused.go:33](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/accounts_hostsused.go:33) through line 70 and [hostsused.go:205](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/provision/hostsused.go:205) through line 218. Acceptance and reads remain unchanged; only refusal wording changes. No new root access or weakened check appears. The independently recomputed envelope matches `8d732496…bc5db3695` in the overlay, and its files are unchanged since round 1. |
| + |
| +**NOT READY** |
| \ No newline at end of file |
diff --git a/docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r3.md b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r3.md| new file mode 100644 |
| index 000000000..dea4997b6 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r3.md |
| @@ -0,0 +1,11 @@ |
| +R2 P1-1 — **Resolved:** Git invocations discard inherited `GIT_*` variables, disable replacement objects and commit graphs, and refuse repository grafts before checking ancestry ([hostsused_floor.go:197](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/console/hostsused_floor.go:197), lines 197–210 and 262–285). |
| + |
| +R2 P1-2 — **Resolved:** both commits must match the checkout’s hash format and resolve to their exact object IDs before ancestry checking ([hostsused_floor.go:287](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/console/hostsused_floor.go:287), lines 287–306). |
| + |
| +No outstanding or new P1, P2, or P3 findings. Within the stated operator-mistake threat model, I found no remaining unsafe acceptance. Conditional writes preserve conflict handling; activation refuses non-release builds before writes; the CLI’s acceptance predicate remains unchanged. The 31-release ancestry claim is verified, including exclusion of every earlier release tag. |
| + |
| +Targeted Go tests could not start: creating Go’s temporary work directory failed with `read-only file system`. Review proceeded by reading and read-only checks. Changed Go files pass formatting checks; Windows package listing excludes the constrained binary test. No repository files were changed. |
| + |
| +**Census envelope `.`: APPROVE.** I read [accounts_hostsused.go:33](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/accounts_hostsused.go:33), lines 33–70, and [internal/provision/hostsused.go:205](/home/paulca/amadan.net/carlos/platform-hosts-floor-release/internal/provision/hostsused.go:205), lines 205–218. The change affects refusal wording only, introducing no new root access or weakened check. The independently recomputed envelope matches `8d732496b55a5967e0f7328c1afe6a1466c1ff427d49ad73932b84cbc5db3695`; no census unit changed. |
| + |
| +**READY** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release-R2.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release-R2.md| new file mode 100644 |
| index 000000000..ade5245a2 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release-R2.md |
| @@ -0,0 +1,88 @@ |
| +# Review brief: branch hosts-floor-release (the floor names a release), round 2 of 3 |
| + |
| +Repo carlos/platform, branch `hosts-floor-release`, commit c5a9a576a68f3005bf0e3b913966c1c380e759cf. |
| +Under review: the diff `origin/main..c5a9a576` (main f86e9792), with the design note |
| +`docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md` and the census card |
| +`docs/superpowers/notes/census-proposal-hosts-floor-release.md`. |
| +Authorities: `docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md` §4 (the |
| +floor), README "The history's floor", AGENTS.md "The census" and "Stopping rules". |
| + |
| +You are an independent reviewer. Read the design note, then the code it names, and check every |
| +claim against that code. You are also the census reviewer for this branch (other model family |
| +than the Claude author). |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul approved fixing the floor check on 2026-11-05 (the design note's status line). The choice |
| + of changing the floor's data (a release floor) over teaching the CLI ancestry is the design; |
| + report only mechanisms that fail its stated invariant. |
| +- Copy is approved by a delegated Luna pass (`docs/superpowers/notes/copy/hosts-floor-names-a-release.md`); |
| + report a copy problem only if a sentence is false. |
| +- `ship-app.sh` (carloku-infrastructure) is out of scope (design §6). |
| + |
| +## What to check |
| + |
| +1. **Safety of raise-floor** (`internal/console/hostsused_floor.go`, `RaiseHostsFloor`, |
| + `GitCheckout`). Invariant: after a raise, every build the release comparison accepts contains |
| + the old floor commit, and a build genuinely older than the floor is still refused by every |
| + floor check (`checkMigrationFloor`, roll-console.sh's commit ancestry). Can a raise write a |
| + floor whose release does not contain the old floor commit? Can a ref, a moved/lightweight |
| + tag, an abbreviated or ambiguous object name, a SHA-256 repo, or git's exit codes make it |
| + accept wrongly? Is the check order such that every refusal writes nothing? |
| +2. **Conditional update.** The write is If-Match on the etag read; is there any path that writes |
| + blind (empty etag on an existing floor; ErrCASConflict mapping; a floor deleted meanwhile)? |
| +3. **No serve lock.** The verb takes neither the console's serve lock nor its database. Is it |
| + true that only `Activate` (under the lock) and this verb write `@floor`? |
| +4. **Activate.** The new release check (`hostsused_activate.go`) comes before any write; tests |
| + (`TestActivateRefusesABuildThatIsNotARelease`) prove nothing is written. Does any existing |
| + caller or test (cmd/console builds, scan test) still activate a non-release build? |
| +5. **CLI** (`accounts_hostsused.go`): B11 changes only the message for a floor whose version is |
| + not a release; is any build now accepted that was refused before? |
| +6. **Census card.** Only envelope `.` re-pinned, no unit changed. Verdict for envelope `.`: does |
| + the change let root open, run, query or follow anything new from a path or input a tenant, |
| + app or box agent can create, write or name, or weaken any check root relies on? |
| +7. **README and design note** claims true against the code (including "all 31 releases from |
| + v0.28.29 on contain 50c0cb14 and none before it does": `git tag --contains 50c0cb14`). |
| + |
| +## Round 2 |
| + |
| +Earlier rounds: round 1, `docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r1.md` |
| +(NOT READY: P1-1 moved older tag, P1-2 Windows test compile, P2-3 C14 build command; census |
| +envelope `.` APPROVED). The fixes are commit c5a9a576: raise-floor now accepts only the running |
| +console's own release (design note §4, "Only this console's release"), the binary test carries |
| +`//go:build !windows`, and C14 names `SHA=<tag>`. The root package (`.`) is unchanged since |
| +round 1, so the census fingerprint stands; confirm. |
| + |
| +First give one line per P1 and P2 from round 1: resolved, partly, or not. Carry every unresolved |
| +or partly resolved finding forward at its current severity, then add new findings. The verdict |
| +covers everything outstanding, earlier rounds included. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). Then the census verdict for envelope `.` (APPROVE or REJECT, citing lines read). End |
| +with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites (targeted `go test -run` is fine). |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release-R3.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release-R3.md| new file mode 100644 |
| index 000000000..7a1805d80 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release-R3.md |
| @@ -0,0 +1,102 @@ |
| +# Review brief: branch hosts-floor-release (the floor names a release), round 3 of 3 |
| + |
| +Repo carlos/platform, branch `hosts-floor-release`, commit 923067dc89df26dd42b05429d86dc578ce61b652. |
| +Under review: the diff `origin/main..923067dc89df26dd42b05429d86dc578ce61b652` (main f86e9792), with the design note |
| +`docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md` and the census card |
| +`docs/superpowers/notes/census-proposal-hosts-floor-release.md`. |
| +Authorities: `docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md` §4 (the |
| +floor), README "The history's floor", AGENTS.md "The census" and "Stopping rules". |
| + |
| +You are an independent reviewer. Read the design note, then the code it names, and check every |
| +claim against that code. You are also the census reviewer for this branch (other model family |
| +than the Claude author). |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul approved fixing the floor check on 2026-11-05 (the design note's status line). The choice |
| + of changing the floor's data (a release floor) over teaching the CLI ancestry is the design; |
| + report only mechanisms that fail its stated invariant. |
| +- Copy is approved by a delegated Luna pass (`docs/superpowers/notes/copy/hosts-floor-names-a-release.md`); |
| + report a copy problem only if a sentence is false. |
| +- `ship-app.sh` (carloku-infrastructure) is out of scope (design §6). |
| + |
| +## What to check |
| + |
| +1. **Safety of raise-floor** (`internal/console/hostsused_floor.go`, `RaiseHostsFloor`, |
| + `GitCheckout`). Invariant: after a raise, every build the release comparison accepts contains |
| + the old floor commit, and a build genuinely older than the floor is still refused by every |
| + floor check (`checkMigrationFloor`, roll-console.sh's commit ancestry). Can a raise write a |
| + floor whose release does not contain the old floor commit? Can a ref, a moved/lightweight |
| + tag, an abbreviated or ambiguous object name, a SHA-256 repo, or git's exit codes make it |
| + accept wrongly? Is the check order such that every refusal writes nothing? |
| +2. **Conditional update.** The write is If-Match on the etag read; is there any path that writes |
| + blind (empty etag on an existing floor; ErrCASConflict mapping; a floor deleted meanwhile)? |
| +3. **No serve lock.** The verb takes neither the console's serve lock nor its database. Is it |
| + true that only `Activate` (under the lock) and this verb write `@floor`? |
| +4. **Activate.** The new release check (`hostsused_activate.go`) comes before any write; tests |
| + (`TestActivateRefusesABuildThatIsNotARelease`) prove nothing is written. Does any existing |
| + caller or test (cmd/console builds, scan test) still activate a non-release build? |
| +5. **CLI** (`accounts_hostsused.go`): B11 changes only the message for a floor whose version is |
| + not a release; is any build now accepted that was refused before? |
| +6. **Census card.** Only envelope `.` re-pinned, no unit changed. Verdict for envelope `.`: does |
| + the change let root open, run, query or follow anything new from a path or input a tenant, |
| + app or box agent can create, write or name, or weaken any check root relies on? |
| +7. **README and design note** claims true against the code (including "all 31 releases from |
| + v0.28.29 on contain 50c0cb14 and none before it does": `git tag --contains 50c0cb14`). |
| + |
| +## Round 3 |
| + |
| +Earlier rounds: round 1, `docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r1.md` |
| +(P1-1 moved older tag, P1-2 Windows test compile, P2-3 C14; fixed in c5a9a576); round 2, |
| +`docs/superpowers/notes/reviews/ASTRA-FINDINGS-hosts-floor-release-r2.md` (r1 all resolved; P1-1 git |
| +grafts / replace objects, P1-2 object names of the other hash format resolved through refs; census |
| +envelope `.` APPROVED). Round 2's fixes are in the tip's last code commit: `GitCheckout` (one place) |
| +drops the caller's GIT_* environment, turns replace refs and the commit-graph off, refuses a grafts |
| +file (R14), and looks a commit up only as an object name of the checkout's own hash format that must |
| +resolve to itself; regressions in `internal/console/hostsused_floor_test.go` |
| +(`TestGitCheckoutIgnoresRewrittenHistory`, `TestGitCheckoutObjectNamesMatchItsFormat`, |
| +`TestRaiseFloorRefusesAGraftedCheckout`), each watched to fail on c5a9a576. The root package is |
| +unchanged since round 1. |
| + |
| +This is the last round in budget (AGENTS.md stopping rules). Rounds 1 and 2 both found P1s against |
| +one invariant ("the floor raise-floor writes must be a release whose every build contains the old |
| +floor commit"; trust boundary: the operator's checkout as evidence). Judge round 2's fixes and |
| +anything still outstanding against that invariant. Weigh the threat model plainly: the operator who |
| +runs raise-floor already holds write access to the bucket and could write any floor directly; the |
| +checks exist to stop a mistaken raise, not to defend against that operator. Say whether any |
| +remaining finding is a mistake an operator could plausibly make, or only a deliberate subversion. |
| + |
| +First give one line per P1 and P2 from round 2: resolved, partly, or not. Carry every unresolved |
| +or partly resolved finding forward at its current severity, then add new findings. The verdict |
| +covers everything outstanding. A NOT READY also says whether the P1s share one cause, and whether |
| +refusing the case up front or cutting the feature would remove them. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). Then the census verdict for envelope `.` (APPROVE or REJECT, citing lines read). End |
| +with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites (targeted `go test -run` is fine). |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release.md| new file mode 100644 |
| index 000000000..02fc55559 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-hosts-floor-release.md |
| @@ -0,0 +1,75 @@ |
| +# Review brief: branch hosts-floor-release (the floor names a release), round 1 of 3 |
| + |
| +Repo carlos/platform, branch `hosts-floor-release`, commit 5b5346a5840e4592513110eadb89644a42aec5ef. |
| +Under review: the diff `origin/main..5b5346a5` (main f86e9792), with the design note |
| +`docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md` and the census card |
| +`docs/superpowers/notes/census-proposal-hosts-floor-release.md`. |
| +Authorities: `docs/superpowers/specs/2026-10-26-nearest-region-without-claims-design.md` §4 (the |
| +floor), README "The history's floor", AGENTS.md "The census" and "Stopping rules". |
| + |
| +You are an independent reviewer. Read the design note, then the code it names, and check every |
| +claim against that code. You are also the census reviewer for this branch (other model family |
| +than the Claude author). |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul approved fixing the floor check on 2026-11-05 (the design note's status line). The choice |
| + of changing the floor's data (a release floor) over teaching the CLI ancestry is the design; |
| + report only mechanisms that fail its stated invariant. |
| +- Copy is approved by a delegated Luna pass (`docs/superpowers/notes/copy/hosts-floor-names-a-release.md`); |
| + report a copy problem only if a sentence is false. |
| +- `ship-app.sh` (carloku-infrastructure) is out of scope (design §6). |
| + |
| +## What to check |
| + |
| +1. **Safety of raise-floor** (`internal/console/hostsused_floor.go`, `RaiseHostsFloor`, |
| + `GitCheckout`). Invariant: after a raise, every build the release comparison accepts contains |
| + the old floor commit, and a build genuinely older than the floor is still refused by every |
| + floor check (`checkMigrationFloor`, roll-console.sh's commit ancestry). Can a raise write a |
| + floor whose release does not contain the old floor commit? Can a ref, a moved/lightweight |
| + tag, an abbreviated or ambiguous object name, a SHA-256 repo, or git's exit codes make it |
| + accept wrongly? Is the check order such that every refusal writes nothing? |
| +2. **Conditional update.** The write is If-Match on the etag read; is there any path that writes |
| + blind (empty etag on an existing floor; ErrCASConflict mapping; a floor deleted meanwhile)? |
| +3. **No serve lock.** The verb takes neither the console's serve lock nor its database. Is it |
| + true that only `Activate` (under the lock) and this verb write `@floor`? |
| +4. **Activate.** The new release check (`hostsused_activate.go`) comes before any write; tests |
| + (`TestActivateRefusesABuildThatIsNotARelease`) prove nothing is written. Does any existing |
| + caller or test (cmd/console builds, scan test) still activate a non-release build? |
| +5. **CLI** (`accounts_hostsused.go`): B11 changes only the message for a floor whose version is |
| + not a release; is any build now accepted that was refused before? |
| +6. **Census card.** Only envelope `.` re-pinned, no unit changed. Verdict for envelope `.`: does |
| + the change let root open, run, query or follow anything new from a path or input a tenant, |
| + app or box agent can create, write or name, or weaken any check root relies on? |
| +7. **README and design note** claims true against the code (including "all 31 releases from |
| + v0.28.29 on contain 50c0cb14 and none before it does": `git tag --contains 50c0cb14`). |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). Then the census verdict for envelope `.` (APPROVE or REJECT, citing lines read). End |
| +with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites (targeted `go test -run` is fine). |
diff --git a/docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md b/docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md| new file mode 100644 |
| index 000000000..9b1f1aa85 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md |
| @@ -0,0 +1,113 @@ |
| +# The hostname history's floor names a release |
| + |
| +Status: approved by Paul 2026-11-05 ("Yes" to fixing the floor check, then a |
| +patch release and roll). Branch `hosts-floor-release`. Amends the floor in |
| +`2026-10-26-nearest-region-without-claims-design.md` §4. |
| + |
| +## 1. The bug |
| + |
| +`carlos accounts migrate --app rastrillo --to bfu --dry-run` on annie |
| +(v0.34.3) refuses: "this carlos is older than the hostname history's floor, |
| +50c0cb14." Flagship's floor, `control/hosts-used/@floor`, is |
| +`{"version":"50c0cb14","commit":"50c0cb14b429…"}`. The console that completed |
| +flagship's history was rolled by `roll-console.sh`, which stamps the short |
| +sha as the version, so the floor names a commit and no release. |
| +`buildMeetsFloor` accepts a build whose commit is the floor's, or a release at |
| +or above a release floor. A release build is neither, so every release is |
| +refused, though 50c0cb14 is in every release from v0.28.29 on. The v0.34.3 |
| +roll checked the console against the floor by hand, because `ship-app.sh` |
| +does not. |
| + |
| +A binary has no git history, so "is 50c0cb14 an ancestor of my commit" cannot |
| +be answered at runtime. Only a checkout can answer it. |
| + |
| +## 2. The floor checks today |
| + |
| +| Check | Compares | Bare-commit floor | Release floor (with commit) | |
| +|---|---|---|---| |
| +| `carlos accounts migrate` (`checkMigrationFloor`) | release versions, or the floor's exact commit | refuses every release | works | |
| +| `roll-console.sh` (carloku-infrastructure) | `merge-base --is-ancestor` in the checkout | works | works (refuses a release with no commit) | |
| +| `ship-app.sh` (release console roll) | nothing | by hand | by hand | |
| + |
| +A floor that names a release and the commit its tag names satisfies both |
| +checks that exist. Dev's floor is already one (`v0.33.0`, 8294a520), so only |
| +flagship's is affected. |
| + |
| +## 3. Options |
| + |
| +1. **Teach the CLI ancestry.** Impossible without a checkout or the forge; a |
| + network call in a safety check is a new failure mode, and a list of |
| + "known ancestors" compiled into the binary goes stale. |
| +2. **Relax the CLI for bare-commit floors** (accept any release newer than |
| + some date, or than the release of the CLI that wrote the floor). Weakens |
| + the safety check on a guess. |
| +3. **Make the floor name a release** (chosen): change the data, not the |
| + check. Two parts: |
| + - `console hosts-used activate` refuses a console that is not a release |
| + build, so a new floor always names a release and its commit. It cannot |
| + recur. |
| + - `console hosts-used raise-floor -release vX.Y.Z -checkout <dir>` gives |
| + an existing commit floor the release of the console running it, when |
| + the operator's checkout shows that release contains the commit. |
| + |
| +## 4. raise-floor |
| + |
| +It accepts only when all hold, and writes nothing otherwise: |
| + |
| +- `-release` is a release tag, and it is the release of the console running |
| + the verb, which is a release build with a full stamped commit; |
| +- the floor exists, names no release, and names a full commit; |
| +- the checkout's `refs/tags/<release>` names (through an annotated tag) |
| + exactly this console's stamped commit; |
| +- this console's commit contains the floor's commit (`git merge-base |
| + --is-ancestor`). The answer is the commits' own history (Astra r2): git |
| + runs with the caller's `GIT_*` environment dropped (`GIT_GRAFT_FILE`, |
| + `GIT_DIR`, object directories), replace refs off and no commit-graph, and |
| + a checkout with a grafts file is refused (R14). A commit is looked up |
| + only as an object name of the checkout's hash format (40 hex for SHA-1, |
| + 64 for SHA-256) and must resolve to itself, so a ref named like one |
| + cannot stand in for it. |
| + |
| +It writes `{"version": "<release>", "commit": "<this console's commit>"}` |
| +with If-Match on the etag it read: a floor changed meanwhile is not |
| +overwritten (the history's conditional-update discipline). It takes no serve |
| +lock and no console database: only `activate` (under the lock) writes the |
| +floor besides it. So it runs where the checkout is, with the deployment |
| +bucket's credentials. |
| + |
| +**Only this console's release.** Round 1 allowed an older release named by |
| +the checkout's tag, which would keep the floor exactly where it was (for |
| +flagship, v0.28.29, the oldest of the 31 releases that contain 50c0cb14). |
| +Astra r1 P1-1: a local tag can be moved. With v0.28.28 moved onto 50c0cb14, |
| +both ancestry checks pass and the floor names v0.28.28, which the published |
| +v0.28.28 (without 50c0cb14) then meets. Only the binary's stamped commit |
| +vouches for which commit its own release is, so the verb names that release |
| +and no other. The cost: the floor rises to the release that runs it, and |
| +builds between the commit and that release are refused from then on. Roll |
| +the release everywhere first. Flagship's floor goes to the release carrying |
| +this change, which every flagship box and console runs before it is raised. |
| +A build genuinely older than the floor is still refused by every check. |
| + |
| +## 5. The CLI's message |
| + |
| +Against a floor that names no release, `carlos accounts migrate` still |
| +refuses every build but the floor's commit, but says what is wrong (B11): |
| +"the hostname history's floor, 50c0cb14, names a commit and not a release, |
| +so this carlos can't tell whether it is at or above it. give the floor a |
| +release with console hosts-used raise-floor, then run this again." B10 |
| +("older than the floor … update carlos") stays for a release floor. |
| + |
| +## 6. Out of scope |
| + |
| +`ship-app.sh` (carloku-infrastructure) still checks no floor; the release |
| +recipe's console roll is the README's, and with a release floor the check is |
| +one version comparison. Left as a follow-up for that repo, named in the |
| +branch description. |
| + |
| +## 7. Census and copy |
| + |
| +The root binary changes in `accounts_hostsused.go` only (B11, one branch in |
| +`checkMigrationFloor`): census card on the branch, Astra review. The console |
| +package and binary are out of census scope. New strings C14, R1-R13 and B11: |
| +`docs/superpowers/notes/copy/hosts-floor-names-a-release.md`, delegated Luna |
| +pass. |
diff --git a/internal/console/hostsused_activate.go b/internal/console/hostsused_activate.go| index fb544b236..df6f35e6f 100644 |
| --- a/internal/console/hostsused_activate.go |
| +++ b/internal/console/hostsused_activate.go |
| @@ -96,7 +96,7 @@ type HostsActivation struct { |
| MovesEnabled bool |
| // Floor is the build that completes the history, written as its floor: |
| // HostsFloorNow() for the console binary. Activate refuses one that does not |
| - // name a full commit. |
| + // name a full commit and a release. |
| Floor provision.HostsFloor |
| } |
| @@ -303,7 +303,8 @@ var fullCommit = regexp.MustCompile(`^(?:[0-9a-f]{40}|[0-9a-f]{64})$`) |
| // Activate makes the history active. scanned is the roster the adapter |
| // scanned, listings its output, closeFleets the fleets not scanned. It |
| -// refuses (each error is the operator's sentence) with claims or Phase 1 |
| +// refuses (each error is the operator's sentence) with a build that names |
| +// no full commit or no release, with claims or Phase 1 |
| // on, a history already active, any pending lifetime row, any unfinished |
| // move or seed, a roster changed since scanned, a closed name that is not a |
| // roster fleet, a listing of a target off the roster, a target with no good |
| @@ -314,6 +315,12 @@ func (a HostsActivation) Activate(ctx context.Context, scanned HostsRoster, list |
| if !fullCommit.MatchString(a.Floor.Commit) { |
| return 0, errors.New(msgHostsFloorNoCommit) |
| } |
| + // The floor names a release too, so every floor check can compare |
| + // versions (hostsused_floor.go): a binary cannot tell whether it |
| + // contains a bare commit. |
| + if !IsReleaseTag(a.Floor.Version) { |
| + return 0, errors.New(msgHostsFloorNotARelease) |
| + } |
| if a.HostClaim || a.MovesEnabled { |
| return 0, errors.New(msgHostsClaimsOn) |
| } |
diff --git a/internal/console/hostsused_activate_test.go b/internal/console/hostsused_activate_test.go| index 659342efa..6f3a736ee 100644 |
| --- a/internal/console/hostsused_activate_test.go |
| +++ b/internal/console/hostsused_activate_test.go |
| @@ -40,7 +40,7 @@ func invFx(t *testing.T) lifetimesFx { |
| } |
| // testFloor is the build the activation tests complete the history as. |
| -var testFloor = provision.HostsFloor{Version: "v0.0.0-test", Commit: "0123456789abcdef0123456789abcdef01234567"} |
| +var testFloor = provision.HostsFloor{Version: "v0.0.0", Commit: "0123456789abcdef0123456789abcdef01234567"} |
| func activation(l lifetimesFx) HostsActivation { |
| return HostsActivation{DB: l.fx.st, Releases: l.fx.rel, Registry: l.fx.srv.cfg.Registry, Floor: testFloor} |
diff --git a/internal/console/hostsused_floor.go b/internal/console/hostsused_floor.go| new file mode 100644 |
| index 000000000..233a81271 |
| --- /dev/null |
| +++ b/internal/console/hostsused_floor.go |
| @@ -0,0 +1,307 @@ |
| +package console |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "errors" |
| + "fmt" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "regexp" |
| + "strings" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// The floor names a release (design |
| +// docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md). |
| +// Every floor check but the console roll script compares release versions: |
| +// a binary has no git history, so it cannot tell whether it contains a |
| +// commit. A floor that names only a commit (flagship's, written by a console |
| +// rolled from a checkout) therefore refused every release. Activation now |
| +// writes a release floor only, and `console hosts-used raise-floor` gives an |
| +// existing commit floor the release of the console running it, when an |
| +// operator's platform checkout shows that release contains the commit. |
| + |
| +// The approved strings (docs/superpowers/notes/copy/hosts-floor-names-a-release.md). |
| +const ( |
| + msgHostsFloorNotARelease = "This console isn't a release build, so the history's floor can't name a release. Build it from a release tag with make build-console SHA=<tag>, then run this again." // C14 |
| + msgFloorBuildNotARelease = "This console isn't a release build, so it can't vouch for a release. Run this with a release console." // R2 |
| + msgFloorNone = "The hostname history has no floor yet. Completing the history writes one." // R4 |
| + msgFloorChanged = "The floor changed while this ran. Run this again." // R12 |
| +) |
| + |
| +func msgFloorNotARelease(name string) string { // R1 |
| + return name + " isn't a release tag. Name one like v0.34.4." |
| +} |
| + |
| +func msgFloorNotThisRelease(build, rel string) string { // R3 |
| + return "This console is " + build + ", not " + rel + ". Run this with the " + rel + " console. Its stamped commit identifies the commit for that release." |
| +} |
| + |
| +func msgFloorAlreadyARelease(v string) string { // R5 |
| + return "The floor already names a release, " + v + "." |
| +} |
| + |
| +func msgFloorNoFullCommit(rel string) string { // R6 |
| + return "The floor doesn't name a full commit, so the checkout can't show that " + rel + " contains it." |
| +} |
| + |
| +func msgFloorNoTag(rel string) string { // R7 |
| + return "The checkout has no tag " + rel + ". Fetch the platform repo's tags, then run this again." |
| +} |
| + |
| +func msgFloorCheckoutMissing(commit string) string { // R8 |
| + return "The checkout doesn't have commit " + commit + ". Fetch the platform repo, then run this again." |
| +} |
| + |
| +func msgFloorTagNotThisBuild(rel, tagged, built string) string { // R9 |
| + return "The checkout's tag " + rel + " names " + tagged + ", but this console was built from " + built + "." |
| +} |
| + |
| +// msgFloorGrafted is R14: a checkout whose history a grafts file rewrites. |
| +const msgFloorGrafted = "The checkout has a grafts file, which changes Git's commit history. Ancestry checks in this checkout cannot be trusted. Use a fresh clone of the platform repository." |
| + |
| +func msgFloorNotContained(rel, floor string) string { // R11 |
| + return rel + " doesn't contain the floor's commit, " + floor + ". Name a later release." |
| +} |
| + |
| +// MsgFloorRaised is R13, what raise-floor prints when it has written. |
| +func MsgFloorRaised(from, to provision.HostsFloor) string { |
| + return "The hostname history's floor is now " + to.Version + " (" + to.Commit + "). It was " + from.Version + " (" + from.Commit + ")." |
| +} |
| + |
| +// releaseTagShape is a release's version stamp ("v0.34.4"), as update.go's. |
| +var releaseTagShape = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+$`) |
| + |
| +// releaseTag parses a release tag; ok is false for anything else. |
| +func releaseTag(s string) (release.SemVer, bool) { |
| + if !releaseTagShape.MatchString(s) { |
| + return release.SemVer{}, false |
| + } |
| + return release.ParseSemVer(s[1:]) |
| +} |
| + |
| +// IsReleaseTag reports whether s is a release's version stamp. |
| +func IsReleaseTag(s string) bool { |
| + _, ok := releaseTag(s) |
| + return ok |
| +} |
| + |
| +// FloorCheckout answers what raise-floor asks of an operator's platform |
| +// checkout. Commits are full object names. |
| +type FloorCheckout interface { |
| + // TagCommit is the commit refs/tags/<tag> names, or ErrCheckoutNoTag. |
| + TagCommit(ctx context.Context, tag string) (string, error) |
| + // Contains reports whether ancestor is descendant or one of its |
| + // ancestors. A commit the checkout does not have is a |
| + // CheckoutMissingError. |
| + Contains(ctx context.Context, descendant, ancestor string) (bool, error) |
| +} |
| + |
| +// ErrCheckoutNoTag is a tag the checkout does not have. |
| +var ErrCheckoutNoTag = errors.New("console: the checkout has no such tag") |
| + |
| +// ErrCheckoutGrafted is a checkout with a grafts file, which gives commits |
| +// parents they do not have. |
| +var ErrCheckoutGrafted = errors.New("console: the checkout has a grafts file") |
| + |
| +// CheckoutMissingError is a commit the checkout does not have. |
| +type CheckoutMissingError struct{ Commit string } |
| + |
| +func (e CheckoutMissingError) Error() string { |
| + return "console: the checkout has no commit " + e.Commit |
| +} |
| + |
| +// RaiseHostsFloor gives a floor that names only a commit the release rel |
| +// and its commit, when build (this console) is rel and the checkout shows |
| +// that build's stamped commit contains the floor's. rel must be this |
| +// console's own release: its stamped commit is the only evidence of which |
| +// commit a release is, since a local tag can be moved (Astra r1 P1-1: an |
| +// older tag moved onto the floor's commit would name a published release |
| +// that lacks it). The checkout's tag must agree with the stamp. The write |
| +// is conditional on the floor read, so a floor changed meanwhile is not |
| +// overwritten. Every refusal writes nothing. |
| +func RaiseHostsFloor(ctx context.Context, store release.Store, build provision.HostsFloor, rel string, co FloorCheckout) (from, to provision.HostsFloor, err error) { |
| + if !IsReleaseTag(rel) { |
| + return from, to, errors.New(msgFloorNotARelease(rel)) |
| + } |
| + if !IsReleaseTag(build.Version) || !fullCommit.MatchString(build.Commit) { |
| + return from, to, errors.New(msgFloorBuildNotARelease) |
| + } |
| + if build.Version != rel { |
| + return from, to, errors.New(msgFloorNotThisRelease(build.Version, rel)) |
| + } |
| + floor, etag, err := provision.ReadHostsFloor(ctx, store) |
| + if err != nil { |
| + return from, to, fmt.Errorf("read the floor: %w", err) |
| + } |
| + if floor == nil { |
| + return from, to, errors.New(msgFloorNone) |
| + } |
| + from = *floor |
| + if IsReleaseTag(floor.Version) { |
| + return from, to, errors.New(msgFloorAlreadyARelease(floor.Version)) |
| + } |
| + if !fullCommit.MatchString(floor.Commit) { |
| + return from, to, errors.New(msgFloorNoFullCommit(rel)) |
| + } |
| + tagged, err := co.TagCommit(ctx, rel) |
| + if errors.Is(err, ErrCheckoutNoTag) { |
| + return from, to, errors.New(msgFloorNoTag(rel)) |
| + } |
| + if err != nil { |
| + return from, to, err |
| + } |
| + if tagged != build.Commit { |
| + return from, to, errors.New(msgFloorTagNotThisBuild(rel, tagged, build.Commit)) |
| + } |
| + if ok, err := co.Contains(ctx, build.Commit, floor.Commit); err != nil { |
| + return from, to, checkoutRefusal(err) |
| + } else if !ok { |
| + return from, to, errors.New(msgFloorNotContained(rel, floor.Commit)) |
| + } |
| + to = provision.HostsFloor{Version: rel, Commit: build.Commit} |
| + if _, err := provision.WriteHostsFloor(ctx, store, to, etag); errors.Is(err, release.ErrCASConflict) { |
| + return from, provision.HostsFloor{}, errors.New(msgFloorChanged) |
| + } else if err != nil { |
| + return from, provision.HostsFloor{}, fmt.Errorf("write the floor: %w", err) |
| + } |
| + return from, to, nil |
| +} |
| + |
| +func checkoutRefusal(err error) error { |
| + if errors.Is(err, ErrCheckoutGrafted) { |
| + return errors.New(msgFloorGrafted) |
| + } |
| + var missing CheckoutMissingError |
| + if errors.As(err, &missing) { |
| + return errors.New(msgFloorCheckoutMissing(missing.Commit)) |
| + } |
| + return err |
| +} |
| + |
| +// GitCheckout is a platform checkout on disk, read with git. Its answers |
| +// are the commits' own history (Astra r2): every git it runs ignores the |
| +// caller's GIT_* environment (GIT_GRAFT_FILE, GIT_DIR, object directories, |
| +// replace-ref bases) and replace refs, reads no commit-graph, and a |
| +// checkout with a grafts file is refused. A commit is looked up only as an |
| +// object name of the checkout's own hash format, so a ref named like one |
| +// never stands in for it. |
| +type GitCheckout struct{ Dir string } |
| + |
| +// gitEnv is the environment without GIT_* variables, with replace objects |
| +// off. |
| +func gitEnv() []string { |
| + var env []string |
| + for _, kv := range os.Environ() { |
| + if !strings.HasPrefix(kv, "GIT_") { |
| + env = append(env, kv) |
| + } |
| + } |
| + return append(env, "GIT_NO_REPLACE_OBJECTS=1") |
| +} |
| + |
| +func (g GitCheckout) git(ctx context.Context, args ...string) (string, int, error) { |
| + full := append([]string{"-C", g.Dir, "-c", "core.useReplaceRefs=false", "-c", "core.commitGraph=false"}, args...) |
| + cmd := exec.CommandContext(ctx, "git", full...) |
| + cmd.Env = gitEnv() |
| + var stderr bytes.Buffer |
| + cmd.Stderr = &stderr |
| + out, err := cmd.Output() |
| + var exit *exec.ExitError |
| + if errors.As(err, &exit) { |
| + return strings.TrimSpace(string(out)), exit.ExitCode(), fmt.Errorf("git %s: %s", strings.Join(args, " "), strings.TrimSpace(stderr.String())) |
| + } |
| + if err != nil { |
| + return "", -1, fmt.Errorf("git %s: %w", strings.Join(args, " "), err) |
| + } |
| + return strings.TrimSpace(string(out)), 0, nil |
| +} |
| + |
| +// TagCommit resolves refs/tags/<tag> to the commit it names, through an |
| +// annotated tag. Only a release tag is asked for. |
| +func (g GitCheckout) TagCommit(ctx context.Context, tag string) (string, error) { |
| + if !IsReleaseTag(tag) { |
| + return "", ErrCheckoutNoTag |
| + } |
| + if _, _, err := g.git(ctx, "rev-parse", "--git-dir"); err != nil { |
| + return "", err |
| + } |
| + out, code, err := g.git(ctx, "rev-parse", "--verify", "--quiet", "--end-of-options", "refs/tags/"+tag+"^{commit}") |
| + if code == 1 && out == "" { |
| + return "", ErrCheckoutNoTag |
| + } |
| + if err != nil { |
| + return "", err |
| + } |
| + if !fullCommit.MatchString(out) { |
| + return "", fmt.Errorf("git resolved %s to %q, not a commit", tag, out) |
| + } |
| + return out, nil |
| +} |
| + |
| +// hashLength is the length of a full object name in the checkout's hash |
| +// format. |
| +func (g GitCheckout) hashLength(ctx context.Context) (int, error) { |
| + format, _, err := g.git(ctx, "rev-parse", "--show-object-format") |
| + switch { |
| + case err != nil: |
| + return 0, err |
| + case format == "sha1": |
| + return 40, nil |
| + case format == "sha256": |
| + return 64, nil |
| + } |
| + return 0, fmt.Errorf("git: unknown object format %q", format) |
| +} |
| + |
| +// grafted reports whether the checkout has a grafts file. |
| +func (g GitCheckout) grafted(ctx context.Context) (bool, error) { |
| + path, _, err := g.git(ctx, "rev-parse", "--git-path", "info/grafts") |
| + if err != nil { |
| + return false, err |
| + } |
| + if !filepath.IsAbs(path) { |
| + path = filepath.Join(g.Dir, path) |
| + } |
| + if _, err := os.Lstat(path); err == nil { |
| + return true, nil |
| + } else if !errors.Is(err, os.ErrNotExist) { |
| + return false, err |
| + } |
| + return false, nil |
| +} |
| + |
| +// Contains is git merge-base --is-ancestor over two full object names of |
| +// the checkout's hash format, each resolved as that object and checked to |
| +// be a commit. A checkout with a grafts file is ErrCheckoutGrafted. |
| +func (g GitCheckout) Contains(ctx context.Context, descendant, ancestor string) (bool, error) { |
| + if grafted, err := g.grafted(ctx); err != nil { |
| + return false, err |
| + } else if grafted { |
| + return false, ErrCheckoutGrafted |
| + } |
| + n, err := g.hashLength(ctx) |
| + if err != nil { |
| + return false, err |
| + } |
| + for _, c := range []string{descendant, ancestor} { |
| + if len(c) != n || !fullCommit.MatchString(c) { |
| + return false, CheckoutMissingError{Commit: c} |
| + } |
| + if got, _, err := g.git(ctx, "rev-parse", "--verify", "--quiet", "--end-of-options", c+"^{commit}"); err != nil || got != c { |
| + return false, CheckoutMissingError{Commit: c} |
| + } |
| + } |
| + _, code, err := g.git(ctx, "merge-base", "--is-ancestor", ancestor, descendant) |
| + switch code { |
| + case 0: |
| + return true, nil |
| + case 1: |
| + return false, nil |
| + } |
| + return false, err |
| +} |
diff --git a/internal/console/hostsused_floor_test.go b/internal/console/hostsused_floor_test.go| new file mode 100644 |
| index 000000000..9307dfb21 |
| --- /dev/null |
| +++ b/internal/console/hostsused_floor_test.go |
| @@ -0,0 +1,399 @@ |
| +package console |
| + |
| +// The floor names a release (docs/superpowers/specs/2026-11-05-hosts-floor-names-a-release-design.md): |
| +// RaiseHostsFloor turns a floor that names only a commit into one that names |
| +// this console's release, when an operator checkout shows the release |
| +// contains it, and Activate writes a release floor only. |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// Commits of a fake history: c0 <- floorC <- c2 <- c3 <- c4, linear. |
| +const ( |
| + c0 = "1000000000000000000000000000000000000000" |
| + floorC = "2000000000000000000000000000000000000000" |
| + c2 = "3000000000000000000000000000000000000000" |
| + c3 = "4000000000000000000000000000000000000000" |
| + c4 = "5000000000000000000000000000000000000000" |
| + stray = "6000000000000000000000000000000000000000" // not in the checkout |
| +) |
| + |
| +// fakeCheckout is a linear history and its tags. |
| +type fakeCheckout struct { |
| + order []string |
| + tags map[string]string |
| + during func() // runs inside the first Contains, to race the write |
| +} |
| + |
| +func newFakeCheckout() *fakeCheckout { |
| + return &fakeCheckout{ |
| + order: []string{c0, floorC, c2, c3, c4}, |
| + tags: map[string]string{"v0.28.28": c0, "v0.28.29": c2, "v0.34.3": c3, "v0.34.4": c4}, |
| + } |
| +} |
| + |
| +func (f *fakeCheckout) TagCommit(_ context.Context, tag string) (string, error) { |
| + c, ok := f.tags[tag] |
| + if !ok { |
| + return "", ErrCheckoutNoTag |
| + } |
| + return c, nil |
| +} |
| + |
| +func (f *fakeCheckout) Contains(_ context.Context, descendant, ancestor string) (bool, error) { |
| + if f.during != nil { |
| + run := f.during |
| + f.during = nil |
| + run() |
| + } |
| + at := map[string]int{} |
| + for i, c := range f.order { |
| + at[c] = i |
| + } |
| + d, ok := at[descendant] |
| + if !ok { |
| + return false, CheckoutMissingError{Commit: descendant} |
| + } |
| + a, ok := at[ancestor] |
| + if !ok { |
| + return false, CheckoutMissingError{Commit: ancestor} |
| + } |
| + return a <= d, nil |
| +} |
| + |
| +var bareFloor = provision.HostsFloor{Version: floorC[:8], Commit: floorC} |
| + |
| +func floorStore(t *testing.T, f *provision.HostsFloor) release.Store { |
| + t.Helper() |
| + st := release.NewDirStore(t.TempDir()) |
| + if f != nil { |
| + if _, err := provision.WriteHostsFloor(context.Background(), st, *f, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + return st |
| +} |
| + |
| +func readFloor(t *testing.T, st release.Store) *provision.HostsFloor { |
| + t.Helper() |
| + f, _, err := provision.ReadHostsFloor(context.Background(), st) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return f |
| +} |
| + |
| +// TestRaiseFloorNamesThisConsolesRelease: a floor naming only a commit |
| +// becomes this console's release and its stamped commit, when the |
| +// checkout's tag for that release is that commit and it contains the |
| +// floor's commit. |
| +func TestRaiseFloorNamesThisConsolesRelease(t *testing.T) { |
| + build := provision.HostsFloor{Version: "v0.34.4", Commit: c4} |
| + st := floorStore(t, &bareFloor) |
| + from, to, err := RaiseHostsFloor(context.Background(), st, build, "v0.34.4", newFakeCheckout()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if from != bareFloor || to != build { |
| + t.Fatalf("raised %+v to %+v, want %+v to %+v", from, to, bareFloor, build) |
| + } |
| + if got := readFloor(t, st); got == nil || *got != build { |
| + t.Fatalf("floor = %+v, want %+v", got, build) |
| + } |
| +} |
| + |
| +// TestRaiseFloorRefuses: every refusal writes nothing, and says why. A |
| +// release other than this console's is refused whatever the checkout's |
| +// tags say: a local tag can be moved, and only this console's stamped |
| +// commit vouches for which commit its release is (Astra r1 P1-1). |
| +func TestRaiseFloorRefuses(t *testing.T) { |
| + release4 := provision.HostsFloor{Version: "v0.34.4", Commit: c4} |
| + releaseFloor := provision.HostsFloor{Version: "v0.33.0", Commit: c0} |
| + for _, c := range []struct { |
| + name string |
| + floor *provision.HostsFloor |
| + build provision.HostsFloor |
| + rel string |
| + edit func(*fakeCheckout) |
| + want string |
| + }{ |
| + {"a name that is not a release", &bareFloor, release4, "v0.34", nil, msgFloorNotARelease("v0.34")}, |
| + {"a branch name", &bareFloor, release4, "main", nil, msgFloorNotARelease("main")}, |
| + {"a dev console", &bareFloor, provision.HostsFloor{Version: "dev", Commit: c4}, "v0.34.4", nil, msgFloorBuildNotARelease}, |
| + {"a console stamped with a commit", &bareFloor, provision.HostsFloor{Version: c4[:8], Commit: c4}, "v0.34.4", nil, msgFloorBuildNotARelease}, |
| + {"a console with no full commit", &bareFloor, provision.HostsFloor{Version: "v0.34.4", Commit: c4[:12]}, "v0.34.4", nil, msgFloorBuildNotARelease}, |
| + {"a release newer than this console", &bareFloor, provision.HostsFloor{Version: "v0.34.3", Commit: c3}, "v0.34.4", nil, msgFloorNotThisRelease("v0.34.3", "v0.34.4")}, |
| + {"a release older than this console", &bareFloor, release4, "v0.28.29", nil, msgFloorNotThisRelease("v0.34.4", "v0.28.29")}, |
| + {"an older tag moved onto the floor", &bareFloor, release4, "v0.28.28", func(f *fakeCheckout) { f.tags["v0.28.28"] = floorC }, msgFloorNotThisRelease("v0.34.4", "v0.28.28")}, |
| + {"no floor", nil, release4, "v0.34.4", nil, msgFloorNone}, |
| + {"a floor that names a release", &releaseFloor, release4, "v0.34.4", nil, msgFloorAlreadyARelease("v0.33.0")}, |
| + {"a floor with no full commit", &provision.HostsFloor{Version: "50c0cb14", Commit: "50c0cb14"}, release4, "v0.34.4", nil, msgFloorNoFullCommit("v0.34.4")}, |
| + {"no such tag", &bareFloor, release4, "v0.34.4", func(f *fakeCheckout) { delete(f.tags, "v0.34.4") }, msgFloorNoTag("v0.34.4")}, |
| + {"the tag is not this console's commit", &bareFloor, release4, "v0.34.4", func(f *fakeCheckout) { f.tags["v0.34.4"] = c3 }, msgFloorTagNotThisBuild("v0.34.4", c3, c4)}, |
| + {"this console does not contain the floor", &bareFloor, release4, "v0.34.4", func(f *fakeCheckout) { f.order = []string{c0, c2, c3, c4, floorC} }, msgFloorNotContained("v0.34.4", floorC)}, |
| + {"this console's commit is not in the checkout", &bareFloor, provision.HostsFloor{Version: "v0.34.4", Commit: stray}, "v0.34.4", func(f *fakeCheckout) { f.tags["v0.34.4"] = stray }, msgFloorCheckoutMissing(stray)}, |
| + {"the floor's commit is not in the checkout", &provision.HostsFloor{Version: stray[:8], Commit: stray}, release4, "v0.34.4", nil, msgFloorCheckoutMissing(stray)}, |
| + } { |
| + t.Run(c.name, func(t *testing.T) { |
| + st := floorStore(t, c.floor) |
| + co := newFakeCheckout() |
| + if c.edit != nil { |
| + c.edit(co) |
| + } |
| + _, _, err := RaiseHostsFloor(context.Background(), st, c.build, c.rel, co) |
| + if err == nil || err.Error() != c.want { |
| + t.Fatalf("err = %v, want %q", err, c.want) |
| + } |
| + got := readFloor(t, st) |
| + if (got == nil) != (c.floor == nil) || (got != nil && *got != *c.floor) { |
| + t.Fatalf("floor = %+v, want it unchanged at %+v", got, c.floor) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// TestRaiseFloorLosesARace: a floor that changes between the read and the |
| +// write is not overwritten (the history's conditional update). |
| +func TestRaiseFloorLosesARace(t *testing.T) { |
| + st := floorStore(t, &bareFloor) |
| + other := provision.HostsFloor{Version: "v0.30.0", Commit: c2} |
| + co := newFakeCheckout() |
| + co.during = func() { |
| + _, etag, err := provision.ReadHostsFloor(context.Background(), st) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := provision.WriteHostsFloor(context.Background(), st, other, etag); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + _, _, err := RaiseHostsFloor(context.Background(), st, provision.HostsFloor{Version: "v0.34.4", Commit: c4}, "v0.34.4", co) |
| + if err == nil || err.Error() != msgFloorChanged { |
| + t.Fatalf("err = %v, want %q", err, msgFloorChanged) |
| + } |
| + if got := readFloor(t, st); got == nil || *got != other { |
| + t.Fatalf("floor = %+v, want the other writer's %+v", got, other) |
| + } |
| +} |
| + |
| +// TestActivateRefusesABuildThatIsNotARelease: the floor activation writes |
| +// names a release, so every floor check can compare versions. A console |
| +// that is not a release build refuses before anything is written. |
| +func TestActivateRefusesABuildThatIsNotARelease(t *testing.T) { |
| + for _, v := range []string{"dev", "50c0cb14", "v0.0.0-test", "0.34.4", ""} { |
| + t.Run("version "+v, func(t *testing.T) { |
| + l := invFx(t) |
| + a := activation(l) |
| + a.Floor = provision.HostsFloor{Version: v, Commit: testFloor.Commit} |
| + _, err := a.Activate(context.Background(), rosterOf(t, l), clean([]string{"kept.shop.example.com.db"}, nil), nil) |
| + refusedWith(t, err, msgHostsFloorNotARelease) |
| + if marked(t, l.fx.rel, "kept.shop.example.com") { |
| + t.Fatal("the refused activation marked a hostname") |
| + } |
| + if f, _, err := provision.ReadHostsFloor(context.Background(), l.fx.rel); err != nil || f != nil { |
| + t.Fatalf("floor = %+v %v, want none", f, err) |
| + } |
| + if st, _, err := provision.ReadHostsState(context.Background(), l.fx.rel); err != nil || st.Mode == provision.HostsModeActive { |
| + t.Fatalf("state = %+v %v, want not active", st, err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// gitRepo is a real checkout: a <- b <- c on main, d on a side branch off |
| +// a, tags on b and c, and a branch named like c's commit pointing at a. |
| +func gitRepo(t *testing.T) (dir string, a, b, c, d string) { |
| + t.Helper() |
| + if _, err := exec.LookPath("git"); err != nil { |
| + t.Skip("git is not installed") |
| + } |
| + dir = filepath.Join(t.TempDir(), "platform") |
| + git := func(args ...string) string { |
| + t.Helper() |
| + cmd := exec.Command("git", append([]string{"-C", dir, "-c", "user.name=t", "-c", "user.email=t@example.com", "-c", "commit.gpgsign=false", "-c", "tag.gpgsign=false"}, args...)...) |
| + cmd.Env = append(cmd.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null") |
| + out, err := cmd.CombinedOutput() |
| + if err != nil { |
| + t.Fatalf("git %v: %v\n%s", args, err, out) |
| + } |
| + return strings.TrimSpace(string(out)) |
| + } |
| + if out, err := exec.Command("git", "init", "-q", "-b", "main", dir).CombinedOutput(); err != nil { |
| + t.Fatalf("git init: %v\n%s", err, out) |
| + } |
| + commit := func(msg string) string { |
| + git("commit", "-q", "--allow-empty", "-m", msg) |
| + return git("rev-parse", "HEAD") |
| + } |
| + a = commit("a") |
| + b = commit("b") |
| + git("tag", "-a", "v1.0.0", "-m", "carlos v1.0.0") |
| + c = commit("c") |
| + git("tag", "v1.1.0") |
| + git("checkout", "-q", "-b", "side", a) |
| + d = commit("d") |
| + git("checkout", "-q", "main") |
| + git("branch", c, a) |
| + return dir, a, b, c, d |
| +} |
| + |
| +// TestGitCheckout: tags resolve to the commit they name, annotated or not; |
| +// commits are found by object name only, never through a ref named like |
| +// one; ancestry is git's. |
| +func TestGitCheckout(t *testing.T) { |
| + dir, a, b, c, d := gitRepo(t) |
| + co := GitCheckout{Dir: dir} |
| + ctx := context.Background() |
| + for tag, want := range map[string]string{"v1.0.0": b, "v1.1.0": c} { |
| + if got, err := co.TagCommit(ctx, tag); err != nil || got != want { |
| + t.Errorf("TagCommit(%s) = %q %v, want %s", tag, got, err, want) |
| + } |
| + } |
| + if got, err := co.TagCommit(ctx, "v2.0.0"); !errors.Is(err, ErrCheckoutNoTag) { |
| + t.Errorf("TagCommit(v2.0.0) = %q %v, want ErrCheckoutNoTag", got, err) |
| + } |
| + for _, x := range []struct { |
| + desc, anc string |
| + want bool |
| + }{{c, a, true}, {c, b, true}, {b, b, true}, {a, c, false}, {d, b, false}, {d, a, true}} { |
| + if got, err := co.Contains(ctx, x.desc, x.anc); err != nil || got != x.want { |
| + t.Errorf("Contains(%s, %s) = %v %v, want %v", x.desc[:7], x.anc[:7], got, err, x.want) |
| + } |
| + } |
| + // The branch named like c points at a: c is still the commit c. |
| + if got, err := co.Contains(ctx, c, b); err != nil || !got { |
| + t.Errorf("Contains(c, b) through a branch named c = %v %v, want true", got, err) |
| + } |
| + var missing CheckoutMissingError |
| + if _, err := co.Contains(ctx, stray, a); !errors.As(err, &missing) || missing.Commit != stray { |
| + t.Errorf("Contains(stray, a) = %v, want CheckoutMissingError for %s", err, stray) |
| + } |
| + if _, err := co.Contains(ctx, c, stray); !errors.As(err, &missing) || missing.Commit != stray { |
| + t.Errorf("Contains(c, stray) = %v, want CheckoutMissingError for %s", err, stray) |
| + } |
| + if _, err := (GitCheckout{Dir: filepath.Join(dir, "nope")}).TagCommit(ctx, "v1.0.0"); err == nil || errors.Is(err, ErrCheckoutNoTag) { |
| + t.Errorf("TagCommit in no checkout = %v, want a failure that is not 'no tag'", err) |
| + } |
| +} |
| + |
| +// TestGitCheckoutIgnoresRewrittenHistory (Astra r2 P1-1): the checkout's |
| +// ancestry is the commits' own parents. A grafts file in the repository is |
| +// refused; an inherited GIT_GRAFT_FILE, replace refs and a commit-graph are |
| +// not consulted. |
| +func TestGitCheckoutIgnoresRewrittenHistory(t *testing.T) { |
| + ctx := context.Background() |
| + t.Run("inherited GIT_GRAFT_FILE", func(t *testing.T) { |
| + dir, _, b, _, d := gitRepo(t) |
| + grafts := filepath.Join(t.TempDir(), "grafts") |
| + if err := os.WriteFile(grafts, []byte(d+" "+b+"\n"), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Setenv("GIT_GRAFT_FILE", grafts) |
| + if got, err := (GitCheckout{Dir: dir}).Contains(ctx, d, b); err != nil || got { |
| + t.Fatalf("Contains(d, b) with GIT_GRAFT_FILE = %v %v, want false", got, err) |
| + } |
| + }) |
| + t.Run("replace refs", func(t *testing.T) { |
| + dir, _, b, _, d := gitRepo(t) |
| + gitIn(t, dir, "replace", "--graft", d, b) |
| + if got, err := (GitCheckout{Dir: dir}).Contains(ctx, d, b); err != nil || got { |
| + t.Fatalf("Contains(d, b) with a replace ref = %v %v, want false", got, err) |
| + } |
| + }) |
| + t.Run("a grafts file in the repository", func(t *testing.T) { |
| + dir, a, b, c, d := gitRepo(t) |
| + path := gitIn(t, dir, "rev-parse", "--git-path", "info/grafts") |
| + if !filepath.IsAbs(path) { |
| + path = filepath.Join(dir, path) |
| + } |
| + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(path, []byte(d+" "+b+"\n"), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + co := GitCheckout{Dir: dir} |
| + if _, err := co.Contains(ctx, d, b); !errors.Is(err, ErrCheckoutGrafted) { |
| + t.Fatalf("Contains(d, b) with a grafts file = %v, want ErrCheckoutGrafted", err) |
| + } |
| + if _, err := co.Contains(ctx, c, a); !errors.Is(err, ErrCheckoutGrafted) { |
| + t.Fatalf("Contains(c, a) with a grafts file = %v, want ErrCheckoutGrafted", err) |
| + } |
| + }) |
| +} |
| + |
| +// TestGitCheckoutObjectNamesMatchItsFormat (Astra r2 P1-2): a commit name |
| +// whose length is not the checkout's hash format is never looked up, so a |
| +// ref named like it cannot stand in for it. |
| +func TestGitCheckoutObjectNamesMatchItsFormat(t *testing.T) { |
| + ctx := context.Background() |
| + dir, a, _, c, _ := gitRepo(t) |
| + sha256Name := strings.Repeat("ab", 32) |
| + gitIn(t, dir, "branch", sha256Name, a) |
| + var missing CheckoutMissingError |
| + if _, err := (GitCheckout{Dir: dir}).Contains(ctx, c, sha256Name); !errors.As(err, &missing) { |
| + t.Fatalf("Contains(c, a 64-hex branch) in a SHA-1 checkout = %v, want CheckoutMissingError", err) |
| + } |
| + |
| + dir256 := filepath.Join(t.TempDir(), "platform256") |
| + if out, err := exec.Command("git", "init", "-q", "--object-format=sha256", "-b", "main", dir256).CombinedOutput(); err != nil { |
| + t.Skipf("git can't make a SHA-256 repository: %v\n%s", err, out) |
| + } |
| + gitIn(t, dir256, "commit", "-q", "--allow-empty", "-m", "a") |
| + first := gitIn(t, dir256, "rev-parse", "HEAD") |
| + gitIn(t, dir256, "commit", "-q", "--allow-empty", "-m", "b") |
| + head := gitIn(t, dir256, "rev-parse", "HEAD") |
| + if len(head) != 64 { |
| + t.Fatalf("SHA-256 HEAD = %q", head) |
| + } |
| + sha1Name := strings.Repeat("cd", 20) |
| + gitIn(t, dir256, "branch", sha1Name, first) |
| + co := GitCheckout{Dir: dir256} |
| + if got, err := co.Contains(ctx, head, first); err != nil || !got { |
| + t.Fatalf("Contains(head, first) in a SHA-256 checkout = %v %v, want true", got, err) |
| + } |
| + if _, err := co.Contains(ctx, head, sha1Name); !errors.As(err, &missing) || missing.Commit != sha1Name { |
| + t.Fatalf("Contains(head, a 40-hex branch) in a SHA-256 checkout = %v, want CheckoutMissingError", err) |
| + } |
| +} |
| + |
| +// TestRaiseFloorRefusesAGraftedCheckout: the grafts refusal reaches the |
| +// operator as R14 and writes nothing. |
| +func TestRaiseFloorRefusesAGraftedCheckout(t *testing.T) { |
| + st := floorStore(t, &bareFloor) |
| + _, _, err := RaiseHostsFloor(context.Background(), st, provision.HostsFloor{Version: "v0.34.4", Commit: c4}, "v0.34.4", graftedCheckout{newFakeCheckout()}) |
| + if err == nil || err.Error() != msgFloorGrafted { |
| + t.Fatalf("err = %v, want %q", err, msgFloorGrafted) |
| + } |
| + if got := readFloor(t, st); got == nil || *got != bareFloor { |
| + t.Fatalf("floor = %+v, want it unchanged", got) |
| + } |
| +} |
| + |
| +type graftedCheckout struct{ *fakeCheckout } |
| + |
| +func (graftedCheckout) Contains(context.Context, string, string) (bool, error) { |
| + return false, ErrCheckoutGrafted |
| +} |
| + |
| +// gitIn runs git in dir with a fixed identity and no user configuration. |
| +func gitIn(t *testing.T, dir string, args ...string) string { |
| + t.Helper() |
| + cmd := exec.Command("git", append([]string{"-C", dir, "-c", "user.name=t", "-c", "user.email=t@example.com", "-c", "commit.gpgsign=false", "-c", "tag.gpgsign=false"}, args...)...) |
| + cmd.Env = append(cmd.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null") |
| + out, err := cmd.CombinedOutput() |
| + if err != nil { |
| + t.Fatalf("git %v: %v\n%s", args, err, out) |
| + } |
| + return strings.TrimSpace(string(out)) |
| +} |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index ac4c915f6..0ba9feb20 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -93,4 +93,5 @@ plan14-root-reads-static-markdown-twins.tsv ec831d3206622f34511bfbc2ec0cccb131fb |
| plan14-root-reads-agent-start-demo-1-followups.tsv ec831d3206622f34511bfbc2ec0cccb131fbd3861ec4c6a33a2dc6dff9a1791e |
| plan14-root-reads-region-ha-p3b1-f4.tsv 71bbbf68863266ffab90211a00aff2f1b694bf39bb4bd62ea565c168ba884564 |
| plan14-root-reads-agent-start-demo-2.tsv 1daafee8030f9d370adf5541b5e87313523073c4afdc022d4238c3a7bc1a60ba |
| +plan14-root-reads-hosts-floor-release.tsv 1daafee8030f9d370adf5541b5e87313523073c4afdc022d4238c3a7bc1a60ba |
| plan14-root-reads-region-ha-p3b2.tsv 1b5ef39b210f3c7db69e589da8a467ac4d4a4f218e1d97fb4706cd277a27eae1 |
diff --git a/internal/provision/testdata/plan14-root-reads-hosts-floor-release.tsv b/internal/provision/testdata/plan14-root-reads-hosts-floor-release.tsv| new file mode 100644 |
| index 000000000..fb2a41ef6 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-hosts-floor-release.tsv |
| @@ -0,0 +1,3 @@ |
| +# Census overlay hosts-floor-release, written by census-propose (#369). census-ruling-hosts-floor-release, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-hosts-floor-release.md. |
| +# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@coverage . 8d732496b55a5967e0f7328c1afe6a1466c1ff427d49ad73932b84cbc5db3695 |
diff --git a/internal/provision/testdata/plan14-root-reads-region-ha-p3b2.tsv b/internal/provision/testdata/plan14-root-reads-region-ha-p3b2.tsv| index 018d64848..000714d17 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-region-ha-p3b2.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-region-ha-p3b2.tsv |
| @@ -38,7 +38,7 @@ internal/host/group_maintenance_verbs_linux.go openMaintenanceLock legacy accept |
| internal/host/group_maintenance_verbs_linux.go replaceMaintenancePermit legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b2;basis=Reads back the temp permit it just wrote in the root 0700 directory (O_EXCL random name) before rename; root-only data. file:Openat2@288,file:Read@152 8a8f2a0ebf3766f7c0c3eacc459d016a9c16e0de9efb9b3e24868eebecdb7517 |
| @remove internal/host/group_maintenance.go systemApplier.requireGroupMaintenance |
| @removed internal/host/group_maintenance.go systemApplier.requireGroupMaintenance H3 census-ruling-region-ha-p3b2;basis=Its field checks, artifact check and used-marker Lstat moved verbatim into validateMaintenancePermit / validateMaintenanceArtifact / maintenanceUnconsumed (shared with the permit writer); acceptance, order and errors unchanged; it now reads nothing directly. |
| -@coverage . 4fb8f09da2bf4cbc701f049ea47d2d6fc3e7a045b1c869d938dd4c4216de183c |
| +@coverage . 296c725a3dc2573fca077b1f7727be7c168871b5573a492b613c97aaa1c34bb4 |
| @coverage infra/modules/region-host 2620a08b6d27984923c39383ec0e0904f4e6e3158efdbeac271a34102cf57ecd |
| @coverage infra/modules/region-host/tests c09ade29dece44b7a20b602abfd53c3a0e4bc1ae5d5f79efbfcb6c56a24f2c81 |
| @coverage internal/host a2b161cc27eedecc823db97bfe8670c8916d08e2aacdfb50af6ffebe0fce7599 |