oficina / equipo Public

Review fixes: one-commit release build, pinned programs, honest retry

Astra round 1 on the certification sweep, three findings.

1. make release now builds in a fresh clone checked out at HEAD, under
   $TMPDIR (scripts/release-isolated.sh). The tree must be clean and at
   the commit before the build and after it, and staged-artifacts.py
   writes the provenance manifest only if every binary's own build
   information (go version -m) names that commit with vcs.modified=false.
   The tool proxy no longer builds with -buildvcs=false. A refusal leaves
   nothing in releases/. A clone, not a worktree: go stamps the commit
   only where .git is a directory.
2. containment.New checks bubblewrap's SHA-256 against its pin before
   running it, not only its version string. equipo-runner
   verify-installed holds all five programs in a runner's configuration
   to the release; staging runs it before enrolment and start, the
   production cutover before enrol and start.
3. A retry is green only when its process exits 0 and each test passed:
   a panic after PASS no longer reads as a flake.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev ca9262c9de9f0420ee8737edcb7f92b85cde676c parent 6794e80
19 files changed, +505 −49
  • Makefile +14 −8
  • cmd/equipo-runner/install.go +10 −1
  • cmd/equipo-runner/main.go +3 −1
  • cmd/equipo-runner/main_test.go +1 −1
  • cmd/equipo-runner/verify_installed_test.go +59 −0
  • internal/equipotest/release_test.go +1 −0
  • internal/equipotest/runner_release_test.go +26 −5
  • internal/release/cutover_test.go +30 −1
  • internal/release/staged_gate_test.go +23 −1
  • internal/runner/containment/bubblewrap_pin.go +22 −0
  • internal/runner/containment/bubblewrap_pin_test.go +86 −0
  • internal/runner/containment/linux.go +7 −0
  • internal/testci/flakes_test.go +46 −0
  • scripts/ci-test.py +16 −11
  • scripts/cutover-thin.sh +4 −0
  • scripts/release-isolated.sh +52 −0
  • scripts/runner-reference-allowlist.json +77 −14
  • scripts/staged-artifacts.py +24 −6
  • scripts/staging-thin.py +4 −0

CI cancelled — superseded by a newer push — run details

diff --git a/Makefile b/Makefile
index 11fde4bc..43617000 100644
--- a/Makefile
+++ b/Makefile
@@ -40,20 +40,25 @@ build:
CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o /dev/null ./cmd/equipo-runner
+# A release is built from one fixed commit in a tree of its own
+# (scripts/release-isolated.sh): a fresh clone at HEAD under $TMPDIR,
+# clean before the build and after it, each binary checked against the
+# commit by its own build information, and only then the provenance
+# manifest. An edit here while it builds cannot reach a binary.
+release:
+ scripts/release-isolated.sh $(RELEASE_GOOS) $(RELEASE_GOARCH)
+
+# release-in-tree is the build itself, run by release in its own tree.
# Stamp the clean commit so /api/version identifies the running release.
# Strip debug data to reduce the upload size; keep module build metadata.
-release: release-runner
+.PHONY: release-in-tree
+release-in-tree: release-runner
@test -z "$$(git ls-files --others --exclude-standard)"
@git diff --quiet && git diff --cached --quiet || \
{ echo "refusing to build a release from a dirty tree"; exit 1; }
@mkdir -p $(dir $(RELEASE_BIN))
scripts/build-instance-release.sh $(RUNNER_RELEASE_DIR) $(RELEASE_BIN) $(RELEASE_GOOS) $(RELEASE_GOARCH) "$$(git rev-parse --short HEAD)"
@git rev-parse HEAD > $(RELEASE_BIN).COMMIT
- python3 scripts/staged-artifacts.py manifest $(RELEASE_VERSION) --instance $(RELEASE_BIN)
- @echo "built $(RELEASE_BIN) stamped $$(git rev-parse --short HEAD)"
- @echo "stage it first (scripts/staging-thin.py build/deploy/runner/suite), then deploy only"
- @echo "the exact bytes staging passed, through the drained cutover:"
- @echo " make staged-check && scripts/cutover-thin.sh $(RELEASE_VERSION)"
# staged-check is the production gate: it refuses unless the artifacts
# are the ones this release's build recorded (its provenance manifest,
@@ -246,7 +251,8 @@ direct-release-check:
# its SHA-256 is linked into both runners and the instance
# (internal/release toolProxySHA256), so a runner installs, and an instance
# serves, only the tool proxy of its own build. Nothing here is typed in
-# after a live run, so raising GOTOOLCHAIN needs no one's sign-off.
+# after a live run, so raising GOTOOLCHAIN needs no one's sign-off. Every
+# binary carries its commit (go version -m), the tool proxy too.
TOOL_PROXY_SHA256 = $$(sha256sum $(RUNNER_RELEASE_DIR)/equipo-tool-proxy | cut -d ' ' -f 1)
RELEASE_LDFLAGS = -s -w -X amadan.net/rastrillo/rastrillo.BuildVersion=$$(git rev-parse --short HEAD) -X amadan.net/oficina/equipo/internal/release.toolProxySHA256=$(TOOL_PROXY_SHA256)
@@ -255,7 +261,7 @@ release-runner: copy-release-check direct-release-check
@git diff --quiet && git diff --cached --quiet || exit 1
@$(MAKE) --no-print-directory runner-prerequisites
@mkdir -p $(RUNNER_RELEASE_DIR)
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -buildvcs=false -ldflags "-s -w" -o $(RUNNER_RELEASE_DIR)/equipo-tool-proxy ./cmd/equipo-tool-proxy
+ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o $(RUNNER_RELEASE_DIR)/equipo-tool-proxy ./cmd/equipo-tool-proxy
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath \
-ldflags "$(RELEASE_LDFLAGS)" \
-o $(RUNNER_RELEASE_DIR)/equipo-runner ./cmd/equipo-runner
diff --git a/cmd/equipo-runner/install.go b/cmd/equipo-runner/install.go
index b94b606a..cdf83990 100644
--- a/cmd/equipo-runner/install.go
+++ b/cmd/equipo-runner/install.go
@@ -59,7 +59,7 @@ func installRunner(ctx context.Context, args []string, input io.Reader, out, err
if cfg.Origin != *origin || cfg.StateDir != filepath.Join(*root, "state") {
return fail("runner.install.config")
}
- if release.BuildManifest().VerifyInstalled(map[string]string{"bwrap": cfg.BwrapPath, "claude": cfg.ClaudePath, "codex": cfg.CodexPath, "codex-code-mode-host": cfg.CodexCodeModeHostPath, "equipo-tool-proxy": cfg.ToolProxyPath}) != nil {
+ if verifyInstalled(release.BuildManifest(), cfg) != nil {
return fail("runner.install.release")
}
cfg.MachineLabel = label
@@ -84,6 +84,15 @@ func installRunner(ctx context.Context, args []string, input io.Reader, out, err
fmt.Fprintln(out, equipo.RunnerSetupCopy("runner.install."+result.State))
return 0
}
+
+// verifyInstalled holds every program this runner starts, at the paths in
+// its configuration, to the digests of this release: bubblewrap, claude,
+// codex, its code mode host and the tool proxy built with this runner.
+// The installer runs it before enrolling, and staging and the production
+// cutover run it (equipo-runner verify-installed) before starting a unit.
+func verifyInstalled(m release.Manifest, cfg runner.Config) error {
+ return m.VerifyInstalled(map[string]string{"bwrap": cfg.Bwrap(), "claude": cfg.ClaudePath, "codex": cfg.CodexPath, "codex-code-mode-host": cfg.CodexCodeModeHostPath, "equipo-tool-proxy": cfg.ToolProxy()})
+}
func installManifest(args []string, out io.Writer) int {
if len(args) != 1 {
return 1
diff --git a/cmd/equipo-runner/main.go b/cmd/equipo-runner/main.go
index e96d732a..ea79a86f 100644
--- a/cmd/equipo-runner/main.go
+++ b/cmd/equipo-runner/main.go
@@ -86,7 +86,7 @@ func run(ctx context.Context, args []string, input io.Reader, output, errorOutpu
}
return 0
}
- if args[0] != "run" && args[0] != "enrol" && args[0] != "preflight" && args[0] != "reset" && args[0] != "probe" {
+ if args[0] != "run" && args[0] != "enrol" && args[0] != "preflight" && args[0] != "reset" && args[0] != "probe" && args[0] != "verify-installed" {
return fail(nil)
}
cfg, err := runner.LoadConfig(getenv)
@@ -131,6 +131,8 @@ func run(ctx context.Context, args []string, input io.Reader, output, errorOutpu
if err == nil {
err = json.NewEncoder(output).Encode(report.Probes)
}
+ case "verify-installed":
+ err = verifyInstalled(release.BuildManifest(), cfg)
case "preflight":
var reports any
reports, err = runner.Preflight(ctx, cfg)
diff --git a/cmd/equipo-runner/main_test.go b/cmd/equipo-runner/main_test.go
index fd002ab3..2fbcd25d 100644
--- a/cmd/equipo-runner/main_test.go
+++ b/cmd/equipo-runner/main_test.go
@@ -17,7 +17,7 @@ func TestToolVerbClosed(t *testing.T) {
}
func TestRunnerServiceVerbs(t *testing.T) {
- for _, verb := range []string{"run", "preflight", "enrol"} {
+ for _, verb := range []string{"run", "preflight", "enrol", "verify-installed"} {
var out, log bytes.Buffer
if run(context.Background(), []string{verb}, strings.NewReader(""), &out, &log, func(string) string { return "" }) != 1 {
t.Fatal("missing config accepted", verb)
diff --git a/cmd/equipo-runner/verify_installed_test.go b/cmd/equipo-runner/verify_installed_test.go
new file mode 100644
index 00000000..77b31ac9
--- /dev/null
+++ b/cmd/equipo-runner/verify_installed_test.go
@@ -0,0 +1,59 @@
+package main
+
+import (
+ "crypto/sha256"
+ "fmt"
+ "os"
+ "path/filepath"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/release"
+ "amadan.net/oficina/equipo/internal/runner"
+)
+
+// verify-installed is what staging and the production cutover run before
+// they start a runner: every program the runner will start, at the paths
+// in its own configuration, must be the bytes this release names. One
+// changed program, one missing, or a build that recorded no tool proxy
+// refuses.
+func TestVerifyInstalledHoldsEveryProgramToTheRelease(t *testing.T) {
+ dir := t.TempDir()
+ m := release.BuildManifest()
+ m.Binaries = nil
+ cfg := runner.Config{Executable: filepath.Join(dir, "equipo-runner")}
+ paths := map[string]*string{"bwrap": &cfg.BwrapPath, "claude": &cfg.ClaudePath, "codex": &cfg.CodexPath, "codex-code-mode-host": &cfg.CodexCodeModeHostPath, "equipo-tool-proxy": &cfg.ToolProxyPath}
+ for name, version := range map[string]string{"bwrap": m.BwrapVersion, "claude": m.Claude, "codex": m.Codex, "codex-code-mode-host": m.Codex, "equipo-tool-proxy": m.LauncherVersion} {
+ *paths[name] = filepath.Join(dir, name)
+ if err := os.WriteFile(*paths[name], []byte(name), 0700); err != nil {
+ t.Fatal(err)
+ }
+ m.Binaries = append(m.Binaries, release.BinaryDigest{Name: name, Version: version, SHA256: fmt.Sprintf("%x", sha256.Sum256([]byte(name)))})
+ }
+ if err := verifyInstalled(m, cfg); err != nil {
+ t.Fatalf("the release's own programs refused: %v", err)
+ }
+ for name, path := range paths {
+ if err := os.WriteFile(*path, []byte("another "+name), 0700); err != nil {
+ t.Fatal(err)
+ }
+ if verifyInstalled(m, cfg) == nil {
+ t.Fatal("verified with another", name)
+ }
+ if err := os.Remove(*path); err != nil {
+ t.Fatal(err)
+ }
+ if verifyInstalled(m, cfg) == nil {
+ t.Fatal("verified with no", name)
+ }
+ if err := os.WriteFile(*path, []byte(name), 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := verifyInstalled(m, cfg); err != nil {
+ t.Fatal(err)
+ }
+ // This test binary recorded no tool proxy, like any build but a release.
+ if verifyInstalled(release.BuildManifest(), cfg) == nil {
+ t.Fatal("a build that recorded no tool proxy verified an installation")
+ }
+}
diff --git a/internal/equipotest/release_test.go b/internal/equipotest/release_test.go
index 9596338e..701265d9 100644
--- a/internal/equipotest/release_test.go
+++ b/internal/equipotest/release_test.go
@@ -45,6 +45,7 @@ func TestReleaseStampContract(t *testing.T) {
set -eu
if [ "$1" = test ]; then exit 0; fi
if [ "$1" = env ]; then echo go1.26.11; exit 0; fi
+if [ "$1" = version ]; then printf '%s: go1.26.11\n\tbuild\tvcs.revision=%s\n\tbuild\tvcs.modified=false\n' "$3" "$(git rev-parse HEAD)"; exit 0; fi
printf '%s\n' "CGO_ENABLED=$CGO_ENABLED" "GOOS=$GOOS" "GOARCH=$GOARCH" "$@" > "$RELEASE_CAPTURE"
while [ $# -gt 0 ]; do
if [ "$1" = -o ]; then shift; printf 'built %s for %s\n' "$1" "$GOOS/$GOARCH" > "$1"; fi
diff --git a/internal/equipotest/runner_release_test.go b/internal/equipotest/runner_release_test.go
index 46efdef9..873977c3 100644
--- a/internal/equipotest/runner_release_test.go
+++ b/internal/equipotest/runner_release_test.go
@@ -69,6 +69,15 @@ func TestReleasePinsAndProvenance(t *testing.T) {
}
}
+// make release builds in a tree of its own, a checkout of one commit, and
+// records provenance only for what that commit built: a tree that was
+// dirty before, changed during the build, or a binary whose own build
+// information names another commit or a modified tree, records nothing
+// and leaves nothing in releases/.
+func TestReleaseBuildsFromOneCommit(t *testing.T) {
+ runnerPackagingScenarios(t, "release", []string{"dirty", "untracked", "changed_during_build", "vcs_revision", "vcs_modified", "vcs_missing"})
+}
+
func runnerPackagingScenarios(t *testing.T, target string, scenarios []string) {
for _, scenario := range scenarios {
t.Run(scenario, func(t *testing.T) {
@@ -77,9 +86,11 @@ func runnerPackagingScenarios(t *testing.T, target string, scenarios []string) {
executionMust(t, os.Mkdir(bin, 0700))
copyReleaseTrackedTree(t, root)
scripts := map[string]string{
- "git": "#!/bin/sh\ncase \"$1\" in diff) [ \"$SCENARIO\" != dirty ];; rev-parse) echo abc1234;; ls-files) if [ \"$SCENARIO\" = untracked ]; then echo unsafe.go; fi;; esac\n",
+ // git: one commit, abc1234. A clone of it is a copy of this tree.
+ "git": "#!/bin/sh\ncase \"$1\" in diff) [ \"$SCENARIO\" != dirty ];; rev-parse) echo abc1234;; ls-files) if [ \"$SCENARIO\" = untracked ]; then echo unsafe.go; fi;; status) if [ \"$SCENARIO\" = dirty ]; then echo ' M tracked'; fi; if [ \"$SCENARIO\" = untracked ]; then echo '?? unsafe.go'; fi; if [ -e changed-during-build ]; then echo '?? changed-during-build'; fi;; clone) for a; do last=$a; done; mkdir -p \"$last\" && cp -R . \"$last\";; esac\n",
// Each build writes its own bytes, so every artifact has its own digest.
- "go": "#!/bin/sh\ncase \"$1\" in env) echo go1.26.11;; test) [ \"$SCENARIO\" != copy ];; build) if [ \"$GOOS/$GOARCH\" = linux/arm64 ]; then test -f internal/release/bundled/install-manifest.json || exit 97; fi; printf '%s\\n' \"$GOOS/$GOARCH\" \"$@\" >> \"$CAPTURE\"; while [ $# -gt 0 ]; do if [ \"$1\" = -o ]; then shift; printf 'built %s for %s\\n' \"$1\" \"$GOOS/$GOARCH\" > \"$1\"; fi; shift; done;; esac\n",
+ // go version -m reports the commit a binary says it was built from.
+ "go": "#!/bin/sh\ncase \"$1\" in env) echo go1.26.11;; version) rev=abc1234; mod=false; if [ \"$SCENARIO\" = vcs_revision ]; then rev=def5678; fi; if [ \"$SCENARIO\" = vcs_modified ]; then mod=true; fi; if [ \"$SCENARIO\" != vcs_missing ]; then printf '%s: go1.26.11\\n\\tpath\\tfixture\\n\\tbuild\\tvcs.revision=%s\\n\\tbuild\\tvcs.modified=%s\\n' \"$3\" \"$rev\" \"$mod\"; fi;; test) [ \"$SCENARIO\" != copy ];; build) if [ \"$SCENARIO\" = changed_during_build ]; then touch changed-during-build; fi; if [ \"$GOOS/$GOARCH\" = linux/arm64 ]; then test -f internal/release/bundled/install-manifest.json || exit 97; fi; printf '%s\\n' \"$GOOS/$GOARCH\" \"$@\" >> \"$CAPTURE\"; while [ $# -gt 0 ]; do if [ \"$1\" = -o ]; then shift; printf 'built %s for %s\\n' \"$1\" \"$GOOS/$GOARCH\" > \"$1\"; fi; shift; done;; esac\n",
"codex": "#!/bin/sh\n[ \"$SCENARIO\" != codex ] && echo 'codex-cli 0.165.0'\n",
"bwrap": "#!/bin/sh\nif [ \"$SCENARIO\" = bwrap ]; then echo 'bubblewrap 0.10.0'; else echo 'bubblewrap 0.11.0'; fi\n",
"systemctl": "#!/bin/sh\nexit 98\n",
@@ -101,14 +112,20 @@ func runnerPackagingScenarios(t *testing.T, target string, scenarios []string) {
capture := filepath.Join(root, "build.args")
cmd := exec.Command("make", "--no-print-directory", target)
cmd.Dir = root
- cmd.Env = []string{"PATH=" + bin + ":/usr/bin:/bin", "SCENARIO=" + scenario, "CAPTURE=" + capture}
+ cmd.Env = []string{"PATH=" + bin + ":/usr/bin:/bin", "SCENARIO=" + scenario, "CAPTURE=" + capture, "TMPDIR=" + t.TempDir()}
cmd.Env = append(cmd.Env, installed...)
out, err := cmd.CombinedOutput()
if scenario != "clean" {
if err == nil {
t.Fatalf("unsafe release accepted %s: %s", scenario, out)
}
- if _, err = os.Stat(capture); !os.IsNotExist(err) {
+ // These are caught after the build, in its own tree: nothing
+ // of it reaches releases/, and no provenance is recorded.
+ if after := scenario == "changed_during_build" || strings.HasPrefix(scenario, "vcs_"); after {
+ if _, err = os.Stat(filepath.Join(root, "releases")); !os.IsNotExist(err) {
+ t.Fatalf("a refused build left artifacts in releases/: %s", out)
+ }
+ } else if _, err = os.Stat(capture); !os.IsNotExist(err) {
t.Fatal("built before release guards")
}
return
@@ -125,6 +142,10 @@ func runnerPackagingScenarios(t *testing.T, target string, scenarios []string) {
if !strings.Contains(string(raw), wantTarget) || !strings.Contains(string(raw), "BuildVersion=abc1234") {
t.Fatalf("wrong stamped build: %s", raw)
}
+ // No build turns off the commit a binary records about itself.
+ if strings.Contains(string(raw), "buildvcs") {
+ t.Fatalf("a release build hides its commit: %s", raw)
+ }
dir := filepath.Join(root, "releases/equipo-runner-linux-amd64-abc1234")
digest := func(path string) string {
t.Helper()
@@ -138,7 +159,7 @@ func runnerPackagingScenarios(t *testing.T, target string, scenarios []string) {
// the Mac worker is built beside the Linux runner, stamped the same).
flags := "-s -w -X amadan.net/rastrillo/rastrillo.BuildVersion=abc1234 -X amadan.net/oficina/equipo/internal/release.toolProxySHA256=" + proxy
for _, build := range []string{
- "linux/amd64\nbuild\n-trimpath\n-buildvcs=false\n-ldflags\n-s -w\n-o\nreleases/equipo-runner-linux-amd64-abc1234/equipo-tool-proxy\n./cmd/equipo-tool-proxy\n",
+ "linux/amd64\nbuild\n-trimpath\n-ldflags\n-s -w\n-o\nreleases/equipo-runner-linux-amd64-abc1234/equipo-tool-proxy\n./cmd/equipo-tool-proxy\n",
"linux/amd64\nbuild\n-trimpath\n-ldflags\n" + flags + "\n-o\nreleases/equipo-runner-linux-amd64-abc1234/equipo-runner\n",
"darwin/arm64\nbuild\n-trimpath\n-ldflags\n" + flags + "\n-o\nreleases/equipo-runner-linux-amd64-abc1234/darwin-arm64/equipo-runner\n",
} {
diff --git a/internal/release/cutover_test.go b/internal/release/cutover_test.go
index 64409a4c..cba89cf0 100644
--- a/internal/release/cutover_test.go
+++ b/internal/release/cutover_test.go
@@ -38,7 +38,8 @@ func newCutoverRig(t *testing.T) *cutoverRig {
r.write(filepath.Join(repo, "releases", "equipo-linux-arm64-"+cutoverVersion), "instance", 0600)
release := filepath.Join(repo, "releases", "equipo-runner-linux-amd64-"+cutoverVersion)
// The staged runner's enrol records the instance id it was given.
- r.write(filepath.Join(release, "equipo-runner"), "#!/bin/sh\necho \"$EQUIPO_INSTANCE_ID\" > "+filepath.Join(root, "enrolled")+"\necho new > \"$EQUIPO_RUNNER_STATE_DIR/credentials.json\"\n", 0700)
+ // It also answers verify-installed, with the tool proxy it was told to use.
+ r.write(filepath.Join(release, "equipo-runner"), "#!/bin/sh\nif [ \"$1\" = verify-installed ]; then echo \"equipo-runner verify-installed $EQUIPO_TOOL_PROXY_PATH\" >> "+r.log+"; [ ! -e "+filepath.Join(root, "verifyfail")+" ]; exit; fi\necho \"equipo-runner $1\" >> "+r.log+"\necho \"$EQUIPO_INSTANCE_ID\" > "+filepath.Join(root, "enrolled")+"\necho new > \"$EQUIPO_RUNNER_STATE_DIR/credentials.json\"\n", 0700)
r.write(filepath.Join(release, "equipo-tool-proxy"), "proxy", 0700)
r.serviceEnv = []byte("EQUIPO_ORIGIN=\"https://equipo.bds.oncarlos.com\"\nEQUIPO_INSTANCE_ID=\"" + oldInstanceID + "\"\nEQUIPO_TOOL_PROXY_PATH=\"/old/equipo-tool-proxy\"\nEQUIPO_RUNNER_STATE_DIR=\"" + filepath.Join(r.runner, "state") + "\"\nEQUIPO_SCRATCH_ROOT=\"/old/scratch\"\nEQUIPO_WORKSPACE_ROOT=\"/old/work\"\n")
r.unit = []byte("[Service]\nExecStart=/old/equipo-runner run\nRestart=on-failure\nRestartSec=5\n")
@@ -186,3 +187,31 @@ func TestCutoverStopsWhenASnapshotReadFails(t *testing.T) {
t.Fatal("a failed snapshot was recorded as complete")
}
}
+
+// Before the staged runner enrols or its unit starts, the runner itself
+// checks every program in its new configuration against the release
+// (equipo-runner verify-installed). A program that is not the pinned one
+// stops the cutover with nothing enrolled and nothing started.
+func TestCutoverVerifiesInstalledProgramsBeforeStarting(t *testing.T) {
+ r := newCutoverRig(t)
+ r.write(filepath.Join(r.root, "verifyfail"), "", 0600)
+ out, err := r.run(cutoverVersion, "--execute")
+ calls := r.read(r.log)
+ if err == nil || !strings.Contains(calls, "equipo-runner verify-installed") {
+ t.Fatalf("cutover went on with unverified programs: %v\n%s\n%s", err, out, calls)
+ }
+ if strings.Contains(calls, "equipo-runner enrol") || strings.Contains(calls, "systemctl --user start") || r.read(filepath.Join(r.root, "enrolled")) != "" {
+ t.Fatalf("enrolled or started after a refused verification:\n%s", calls)
+ }
+ // With the programs right, the same cutover resumes: verify, enrol, start.
+ r.must(os.Remove(filepath.Join(r.root, "verifyfail")))
+ if out, err = r.run(cutoverVersion, "--execute"); err != nil {
+ t.Fatalf("cutover: %v\n%s", err, out)
+ }
+ calls = r.read(r.log)
+ verify := strings.LastIndex(calls, "equipo-runner verify-installed "+filepath.Join(r.runner, "releases", cutoverVersion, "equipo-tool-proxy"))
+ enrol, start := strings.Index(calls, "equipo-runner enrol"), strings.Index(calls, "systemctl --user start")
+ if verify < 0 || enrol < verify || start < enrol {
+ t.Fatalf("want verify-installed with the staged tool proxy, then enrol, then start:\n%s", calls)
+ }
+}
diff --git a/internal/release/staged_gate_test.go b/internal/release/staged_gate_test.go
index 1bbb7ea9..e3ee73a8 100644
--- a/internal/release/staged_gate_test.go
+++ b/internal/release/staged_gate_test.go
@@ -51,7 +51,13 @@ func TestStagedArtifactsGate(t *testing.T) {
}
write(filepath.Join(runner, "COMMIT"), "abc1234full\n")
bin := t.TempDir()
- must(os.WriteFile(filepath.Join(bin, "go"), []byte("#!/bin/sh\necho go1.26.11\n"), 0700))
+ // go version -m: what each binary says it was built from.
+ vcs := filepath.Join(bin, "vcs")
+ built := func(revision, modified string) {
+ write(vcs, "\tbuild\tvcs.revision="+revision+"\n\tbuild\tvcs.modified="+modified+"\n")
+ }
+ built("abc1234full", "false")
+ must(os.WriteFile(filepath.Join(bin, "go"), []byte("#!/bin/sh\nif [ \"$1\" = version ]; then echo \"$3: go1.26.11\"; cat "+vcs+"; exit 0; fi\necho go1.26.11\n"), 0700))
t.Setenv("PATH", bin+string(os.PathListSeparator)+os.Getenv("PATH"))
// No provenance manifest: nothing verifies, records or deploys.
released("proxy", "runner", "mac runner")
@@ -77,6 +83,22 @@ func TestStagedArtifactsGate(t *testing.T) {
released("proxy", "runner", "mac runner")
write(filepath.Join(runner, "COMMIT"), "abc1234full\n")
}
+ // A binary that names another commit, a modified tree, or nothing at
+ // all about where it came from, records nothing.
+ for name, change := range map[string]func(){
+ "another commit's binaries": func() { built("def5678full", "false") },
+ "a modified tree": func() { built("abc1234full", "true") },
+ "no build information": func() { write(vcs, "") },
+ } {
+ change()
+ if gate("manifest") == nil {
+ t.Fatal("a provenance manifest written for " + name)
+ }
+ if _, err := os.Stat(instance + ".manifest.json"); !os.IsNotExist(err) {
+ t.Fatal("a refused manifest was written for " + name)
+ }
+ }
+ built("abc1234full", "false")
must(gate("manifest"))
must(gate("verify"))
var made struct {
diff --git a/internal/runner/containment/bubblewrap_pin.go b/internal/runner/containment/bubblewrap_pin.go
new file mode 100644
index 00000000..1e761d29
--- /dev/null
+++ b/internal/runner/containment/bubblewrap_pin.go
@@ -0,0 +1,22 @@
+package containment
+
+// BubblewrapSHA256 is the pinned bubblewrap 0.11.0 build for linux/amd64,
+// the only target a release runs on. It is the digest in
+// internal/release/manifest.json.
+const BubblewrapSHA256 = "0dfa36b98ada69568aaaa741fe210d2150a1441433bd13c428137d6a972a959c"
+
+// BubblewrapSHA256Arm64 is the same Debian package's arm64 build, so the
+// namespace tests can run on an arm64 CI machine. No release ships for it.
+const BubblewrapSHA256Arm64 = "ef2316fc741885e6d7b422661ea60c20cbe07ec7eb592a4c2370cbcb90843b59"
+
+// BubblewrapPin is the digest of the pinned bubblewrap built for goarch.
+// ok is false where there is no pinned build, and nothing starts there.
+func BubblewrapPin(goarch string) (pin string, ok bool) {
+ switch goarch {
+ case "amd64":
+ return BubblewrapSHA256, true
+ case "arm64":
+ return BubblewrapSHA256Arm64, true
+ }
+ return "", false
+}
diff --git a/internal/runner/containment/bubblewrap_pin_test.go b/internal/runner/containment/bubblewrap_pin_test.go
new file mode 100644
index 00000000..862abde0
--- /dev/null
+++ b/internal/runner/containment/bubblewrap_pin_test.go
@@ -0,0 +1,86 @@
+//go:build linux
+
+package containment
+
+import (
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/release"
+)
+
+// The version string is what a program says about itself. A bubblewrap
+// that says "0.11.0" and is other bytes than the pinned build is refused
+// before anything runs in it.
+func TestNamespaceBubblewrapDigest(t *testing.T) {
+ m, _ := fixture(t)
+ cfg := m.cfg
+ real, err := os.ReadFile(cfg.Binary)
+ if err != nil {
+ t.Fatal(err)
+ }
+ // The same program with one byte after it: it still runs and still
+ // reports its version, and it is not the pinned build.
+ other := filepath.Join(t.TempDir(), "bwrap")
+ if err = os.WriteFile(other, append(real, 0), 0700); err != nil {
+ t.Fatal(err)
+ }
+ cfg.Binary = other
+ if _, err = New(cfg); err == nil || !strings.Contains(err.Error(), "namespace_bubblewrap_digest") {
+ t.Fatalf("a bubblewrap with another digest started: %v", err)
+ }
+ if err = os.WriteFile(other, real, 0700); err != nil {
+ t.Fatal(err)
+ }
+ if _, err = New(cfg); err != nil {
+ t.Fatalf("the pinned build at another path refused: %v", err)
+ }
+}
+
+// The release pin is the manifest's: the amd64 build a release runs on.
+// The arm64 build is another digest, for tests on an arm64 machine, and
+// the CI box installs exactly these two (scripts/ci-box.json).
+func TestBubblewrapPins(t *testing.T) {
+ pinned := ""
+ for _, b := range release.BuildManifest().Binaries {
+ if b.Name == "bwrap" {
+ pinned = b.SHA256
+ }
+ }
+ if pin, ok := BubblewrapPin("amd64"); !ok || pin != pinned || pin != BubblewrapSHA256 {
+ t.Fatalf("amd64 pin %q, manifest %q", pin, pinned)
+ }
+ arm, ok := BubblewrapPin("arm64")
+ if !ok || arm == pinned || len(arm) != 64 {
+ t.Fatalf("arm64 pin %q", arm)
+ }
+ if _, ok := BubblewrapPin("riscv64"); ok {
+ t.Fatal("a pin for a machine with no pinned build")
+ }
+ raw, err := os.ReadFile("../../../scripts/ci-box.json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var box struct {
+ Tools map[string]map[string]json.RawMessage
+ }
+ if err = json.Unmarshal(raw, &box); err != nil {
+ t.Fatal(err)
+ }
+ for _, arch := range []string{"amd64", "arm64"} {
+ var tool struct{ SHA256 string }
+ if err = json.Unmarshal(box.Tools["bwrap"][arch], &tool); err != nil {
+ t.Fatal(err)
+ }
+ if pin, _ := BubblewrapPin(arch); tool.SHA256 != pin {
+ t.Fatalf("the CI box installs another %s bubblewrap than the pin: %s", arch, tool.SHA256)
+ }
+ }
+ if _, ok := BubblewrapPin(runtime.GOARCH); !ok {
+ t.Skip("no pinned bubblewrap for this machine")
+ }
+}
diff --git a/internal/runner/containment/linux.go b/internal/runner/containment/linux.go
index 75800e6e..ac544b4c 100644
--- a/internal/runner/containment/linux.go
+++ b/internal/runner/containment/linux.go
@@ -111,6 +111,13 @@ func New(cfg Config) (*Manager, error) {
if e != nil || !info.IsDir() || info.Mode().Perm() != 0700 {
return nil, errMount
}
+ // The pinned build, by its bytes, before it is run even to ask its
+ // version: a version string is only what a program says of itself.
+ want, pinned := BubblewrapPin(runtime.GOARCH)
+ raw, e := os.ReadFile(cfg.Binary)
+ if sum := sha256.Sum256(raw); e != nil || !pinned || hex.EncodeToString(sum[:]) != want {
+ return nil, errors.New("namespace_bubblewrap_digest")
+ }
cmd := exec.Command(cfg.Binary, "--version")
cmd.Env = []string{"LANG=C"}
version, e := cmd.Output()
diff --git a/internal/testci/flakes_test.go b/internal/testci/flakes_test.go
index 54236952..889549c0 100644
--- a/internal/testci/flakes_test.go
+++ b/internal/testci/flakes_test.go
@@ -137,3 +137,49 @@ print(m.flake_line("./internal/thintest", "TestOnce", "thintest", "unknown", "un
t.Errorf("two flakes: want the count and no repeat offender:\n%s", two)
}
}
+
+// A test process that prints PASS for every test and then exits non-zero
+// (a panic in a cleanup, a TestMain that fails after m.Run) has failed.
+// The retry is green only when its process exits 0 and every test it was
+// asked for passed; otherwise the test failed twice and the step is red.
+func TestRetryNeedsACleanExit(t *testing.T) {
+ testci.Files(t, "../../scripts/ci-test.py")
+ bin := t.TempDir()
+ // A fake go: every test passes, then the process dies as $FAKE_GO_EXIT says.
+ script := "#!/bin/sh\necho '=== RUN TestTeardown'\necho '--- PASS: TestTeardown (0.01s)'\necho PASS\nif [ \"$FAKE_GO_EXIT\" != 0 ]; then echo 'panic: cleanup failed after the test passed'; fi\nexit \"$FAKE_GO_EXIT\"\n"
+ if err := os.WriteFile(filepath.Join(bin, "go"), []byte(script), 0700); err != nil {
+ t.Fatal(err)
+ }
+ report := "--- FAIL amadan.net/oficina/equipo/internal/wire TestTeardown\n"
+ run := func(exit string) (int, string) {
+ out := python(t, []string{"PATH=" + bin + string(os.PathListSeparator) + os.Getenv("PATH"), "FAKE_GO_EXIT=" + exit}, "-c", loadCITest+`
+import contextlib, io
+buf = io.StringIO()
+with contextlib.redirect_stdout(buf):
+ status = m.retry_failures(sys.argv[1], dict(__import__("os").environ), "rest", [])
+ _, _, passed, failed, _ = m.go_test("./internal/wire", ["TestTeardown"], dict(__import__("os").environ), [])
+print(json.dumps({"status": status, "log": buf.getvalue(), "passed": sorted(passed), "failed": sorted(failed)}))
+`, report)
+ var got struct {
+ Status int
+ Log string
+ Passed, Failed []string
+ }
+ if err := json.Unmarshal([]byte(out), &got); err != nil {
+ t.Fatalf("%v: %s", err, out)
+ }
+ if exit != "0" && (len(got.Passed) != 0 || !reflect.DeepEqual(got.Failed, []string{"TestTeardown"})) {
+ t.Errorf("exit %s: go_test passed %v failed %v, want the test failed", exit, got.Passed, got.Failed)
+ }
+ return got.Status, got.Log
+ }
+ if status, log := run("0"); status != 0 || !strings.Contains(log, "FLAKE ./internal/wire:TestTeardown rest ") {
+ t.Fatalf("a clean retry is not a flake: status %d\n%s", status, log)
+ }
+ for _, exit := range []string{"1", "2"} {
+ status, log := run(exit)
+ if status == 0 || strings.Contains(log, "FLAKE ") || !strings.Contains(log, "FAILED TWICE ./internal/wire:TestTeardown rest") || !strings.Contains(log, "panic: cleanup failed after the test passed") {
+ t.Fatalf("exit %s: a retry whose process failed went green: status %d\n%s", exit, status, log)
+ }
+ }
+}
diff --git a/scripts/ci-test.py b/scripts/ci-test.py
index 973e1913..cc8ed033 100755
--- a/scripts/ci-test.py
+++ b/scripts/ci-test.py
@@ -441,8 +441,10 @@ def quarantined():
def go_test(package, tests, env, base, fresh=True):
"""go test -v of tests in package (all of it when tests is empty), with
- the flags in base. Returns the command, its output, and the tests that
- passed and that failed."""
+ the flags in base. Returns the command, its output, the tests that
+ passed and that failed, and whether the process itself exited 0. A
+ process that exits non-zero has failed whatever its tests printed: a
+ panic in a cleanup or a TestMain that fails comes after every PASS."""
cmd = ["go", "test"] + list(base) + ["-v"]
if tests:
cmd += ["-run", test_pattern(tests)]
@@ -454,12 +456,13 @@ def go_test(package, tests, env, base, fresh=True):
log.seek(0)
out = log.read()
if not tests:
- return shlex.join(cmd), out, {WHOLE} if code == 0 else set(), set() if code == 0 else {WHOLE}
+ return shlex.join(cmd), out, {WHOLE} if code == 0 else set(), set() if code == 0 else {WHOLE}, code == 0
passed = {t for t in tests if re.search(r"^\s*--- PASS: " + re.escape(t) + r" \(", out, re.M)}
failed = {t for t in tests if re.search(r"^\s*--- FAIL: " + re.escape(t) + r" \(", out, re.M)}
if code != 0 and not failed:
- failed = set(tests) - passed # the binary failed around them
- return shlex.join(cmd), out, passed, failed
+ # The process failed and no test says why: none of them passed.
+ passed, failed = set(), set(tests)
+ return shlex.join(cmd), out, passed, failed, code == 0
def tail(text, n=60):
@@ -525,7 +528,8 @@ def leaves(tests):
def retry_failures(out, env, lane, base):
"""Retry once, with go test, each test the failed run in out reported.
A pass on the retry is a flake and prints its line; returns 0 only when
- everything that failed passed on its retry."""
+ everything that failed passed on its retry and each retry's process
+ exited 0."""
found = {package: leaves(tests) for package, tests in failures(out).items()}
count = sum(max(1, len(tests)) for tests in found.values())
if re.search(r"^--- BUILD FAILED ", out, re.M):
@@ -540,11 +544,12 @@ def retry_failures(out, env, lane, base):
load = load_average()
status = 0
for package, tests in sorted(found.items()):
- cmd, retry_out, passed, failed = go_test(package, tests, env, base)
+ cmd, retry_out, passed, failed, clean = go_test(package, tests, env, base)
print(f"+ {cmd} (retry, once)", flush=True)
twice = []
for t in tests or [WHOLE]:
- if t in passed and t not in failed:
+ # Green needs both: the retry's process exited 0, and this test passed.
+ if clean and t in passed and t not in failed:
print(flake_line(package, t, lane, failed_seconds(out, t), load), flush=True)
else:
twice.append(t)
@@ -561,7 +566,7 @@ def run_group(package, tests, env):
"""Run one top-level test's quarantined entries; retry failures once."""
report = []
base = ["-tags", TAGS, "-timeout", TIMEOUT]
- cmd, out, passed, failed = go_test(package, tests, env, base, fresh=False)
+ cmd, out, passed, failed, _ = go_test(package, tests, env, base, fresh=False)
report.append(f"+ {cmd}")
missing = set(tests) - passed - failed
flaky, broken = [], sorted(missing)
@@ -571,10 +576,10 @@ def run_group(package, tests, env):
report.append(f"first attempt failed: {' '.join(sorted(failed))}; output tail:")
report.append(tail(out))
load = load_average()
- retry_cmd, retry_out, retry_passed, retry_failed = go_test(package, sorted(failed), env, base)
+ retry_cmd, retry_out, retry_passed, retry_failed, clean = go_test(package, sorted(failed), env, base)
report.append(f"+ {retry_cmd} (retry, once)")
for t in sorted(failed):
- if t in retry_passed and t not in retry_failed:
+ if clean and t in retry_passed and t not in retry_failed:
flaky.append(t)
report.append(flake_line(package, t, "quarantine", failed_seconds(out, t), load))
else:
diff --git a/scripts/cutover-thin.sh b/scripts/cutover-thin.sh
index b2601237..3c3b60e1 100755
--- a/scripts/cutover-thin.sh
+++ b/scripts/cutover-thin.sh
@@ -233,6 +233,10 @@ fi
step "8 enrol the runner with the new instance: open the printed link as the owner and enter the code"
if ! done_step enrol; then
+ # Before anything of the new runner starts, it holds every program in
+ # its new configuration (bubblewrap, claude, codex and its code mode
+ # host, the staged tool proxy) to the digests of its release.
+ run bash -c "set -a; . '$RUNNER_ROOT/service.env'; set +a; '$RUNNER_ROOT/releases/$version/equipo-runner' verify-installed"
run bash -c "set -a; . '$RUNNER_ROOT/service.env'; set +a; '$RUNNER_ROOT/releases/$version/equipo-runner' enrol"
run systemctl --user start "$UNIT"
finish enrol
diff --git a/scripts/release-isolated.sh b/scripts/release-isolated.sh
new file mode 100755
index 00000000..d613e6ae
--- /dev/null
+++ b/scripts/release-isolated.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# make release: build every release artifact from one fixed commit, in a
+# tree of its own, and record provenance only if that is what was built.
+#
+# scripts/release-isolated.sh <goos> <goarch>
+#
+# The checkout you run this from is only asked which commit HEAD is. The
+# build happens in a fresh clone checked out at exactly that commit, under
+# $TMPDIR, so an edit made here while it runs cannot reach a binary. (A
+# clone, not a git worktree: go stamps a binary with its commit only where
+# .git is a directory.) The
+# build tree must be clean and at that commit before the build and again
+# after it, and every binary must say so itself (go version -m:
+# vcs.revision is the commit, vcs.modified is false) before
+# scripts/staged-artifacts.py writes the provenance manifest. Anything
+# else refuses, and nothing is copied into releases/.
+set -eu
+goos=$1
+goarch=$2
+refuse() {
+ echo "refusing to release: $1" >&2
+ exit 1
+}
+commit=$(git rev-parse HEAD)
+version=$(git rev-parse --short HEAD)
+[ -z "$(git status --porcelain)" ] || refuse "refusing to build a release from a dirty tree"
+base=${TMPDIR:-${XDG_CACHE_HOME:-$HOME/.cache}/equipo}
+mkdir -p "$base"
+scratch=$(mktemp -d "$base/equipo-release.XXXXXX")
+tree=$scratch/src
+trap 'rm -rf "$scratch"' EXIT
+trap 'exit 1' HUP INT TERM
+git clone --quiet --no-hardlinks . "$tree"
+(cd "$tree" && git checkout --quiet --detach "$commit")
+# The build tree: at the commit, nothing changed, nothing untracked.
+# Build output (releases/, the instance's bundle) is ignored by git.
+pristine() {
+ (cd "$tree" && [ "$(git rev-parse HEAD)" = "$commit" ] && [ -z "$(git status --porcelain)" ])
+}
+pristine || refuse "the build tree is not a clean checkout of $commit"
+make -C "$tree" --no-print-directory release-in-tree RELEASE_GOOS="$goos" RELEASE_GOARCH="$goarch"
+pristine || refuse "the build tree changed during the build"
+# This checkout may have moved on meanwhile; a release of the commit it
+# named is still wanted only if it still names it, unchanged.
+[ "$(git rev-parse HEAD)" = "$commit" ] && git diff --quiet HEAD || refuse "this checkout changed during the build"
+(cd "$tree" && python3 scripts/staged-artifacts.py manifest "$version" --instance "releases/equipo-$goos-$goarch-$version")
+mkdir -p releases
+cp -R "$tree/releases/." releases/
+echo "built releases/equipo-$goos-$goarch-$version from $commit"
+echo "stage it first (scripts/staging-thin.py build/deploy/runner/suite), then deploy only"
+echo "the exact bytes staging passed, through the drained cutover:"
+echo " make staged-check && scripts/cutover-thin.sh $version"
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 8c4cc8cf..1c883722 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -8378,13 +8378,6 @@
"count": 1,
"reason": "Cutover script test: the stub runner root, unit and release the script installs and restores."
},
- {
- "path": "internal/release/cutover_test.go",
- "line_sha256": "b282177e47ab0566bdb761f170c022d47a0c9dc14bf4a3cb12ab12bef1d9bb54",
- "match": "equipo-runner",
- "count": 1,
- "reason": "Cutover script test: the stub runner root, unit and release the script installs and restores."
- },
{
"path": "internal/release/cutover_test.go",
"line_sha256": "472b0acacf49b3cea810162ad8a45a40ab50566eb5b8543bbc26c56f1d239397",
@@ -10926,13 +10919,6 @@
"count": 2,
"reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
},
- {
- "path": "internal/equipotest/runner_release_test.go",
- "line_sha256": "82807a6199446b4bd999dd032d4b517d7772b5cf4ebbe6437584a14c2c73a164",
- "match": "equipo-runner",
- "count": 1,
- "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
- },
{
"path": "internal/equipotest/runner_release_test.go",
"line_sha256": "a6432e63fc28f8f4e5a1bfa61ac10237b487957a863e5fd32575b4c5ee78440c",
@@ -10974,5 +10960,82 @@
"match": "equipo-runner",
"count": 1,
"reason": "Progress log: names the retained runner executable and its release directory."
+ },
+ {
+ "path": "cmd/equipo-runner/install.go",
+ "line_sha256": "53aed153ffaa020eb2d545011fbe36325022231cccdaa997a36e3d0a78a8afeb",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "cmd/equipo-runner/verify_installed_test.go",
+ "line_sha256": "fe1aaaad5f08861498ccdb8137a0a126c39f2e8d1d48dceef824294f47bda845",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "internal/equipotest/runner_release_test.go",
+ "line_sha256": "48de9a05445070aa3dd8ca7785b24baade04e1c71e1d1714cc27263f980d31c7",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "internal/release/cutover_test.go",
+ "line_sha256": "047b951cc56a369c43ce95d07c45d118bf575c7d08195b14c9a89970d4261027",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "internal/release/cutover_test.go",
+ "line_sha256": "407ba93fc146de63ddd7addb1c910324c2ddb4361ec35caf7dd08f937e87093e",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "internal/release/cutover_test.go",
+ "line_sha256": "6a2fc8108a185f77b6b07274ebb07d214a5a55190c8efafa9e4a353f7dc48449",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "internal/release/cutover_test.go",
+ "line_sha256": "a7ed104d1e654b92f78e48f6c92e96f05cadc9dc19cdeaae5235350d664ee071",
+ "match": "equipo-runner",
+ "count": 3,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "internal/release/cutover_test.go",
+ "line_sha256": "aa05fd8ee64cf50e79d4bfdc0ecb33eaf6c1c2d9018ada69c0da488d4e2defa8",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "internal/release/cutover_test.go",
+ "line_sha256": "d99fc590173f20ee4067bd3316554156661ee12fe0e0341fedd626b6bfc2f3e9",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "scripts/cutover-thin.sh",
+ "line_sha256": "6725844572a8fe8d6f783b394b09a240f3805d87dd4819b17c4efad199234eb2",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
+ },
+ {
+ "path": "scripts/staging-thin.py",
+ "line_sha256": "c128d541ba1ce5ce640a6d3bd1a8ac729e389a42aa6571aef7de9ce6c3e16788",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps."
}
]
diff --git a/scripts/staged-artifacts.py b/scripts/staged-artifacts.py
index 66ad117b..12175cbe 100755
--- a/scripts/staged-artifacts.py
+++ b/scripts/staged-artifacts.py
@@ -9,12 +9,14 @@
# hashes of what staging actually ran
scripts/staged-artifacts.py check <version> # before any production deploy
-`manifest` runs at the end of `make release`, on a clean tree at the
-release commit. It writes releases/equipo-linux-arm64-<version>.manifest.json:
-the commit, the Go that built it and the SHA-256 of every artifact. It
-refuses unless the runner release agrees with itself: the tool proxy the
-release manifest records and the runner digests in the install manifest
-are the bytes on disk.
+`manifest` runs at the end of `make release`, in the build's own tree, a
+clean checkout of the release commit (scripts/release-isolated.sh). It
+writes releases/equipo-linux-arm64-<version>.manifest.json: the commit,
+the Go version and the SHA-256 of every artifact. It refuses unless every
+binary says it was built from that commit, unmodified (go version -m:
+vcs.revision, vcs.modified=false), and the runner release agrees with
+itself: the tool proxy the release manifest records and the runner
+digests in the install manifest are the bytes on disk.
`verify` recomputes every hash and refuses unless the artifacts are the
ones the provenance manifest names, at the commit it names.
@@ -68,6 +70,18 @@ def commit_of(version, instance=None):
return Path(str(artifacts(version, instance)['instance']) + '.COMMIT').read_text().strip()
+def built_from(path, commit):
+ """Whether the binary at path says it was built from commit, with no
+ change to the tree: its embedded build information, read by go."""
+ try:
+ out = subprocess.run(['go', 'version', '-m', str(path)], capture_output=True, text=True, check=True).stdout
+ except (OSError, subprocess.CalledProcessError):
+ return False
+ info = dict(f[1].split('=', 1) for f in (line.split('\t')[1:] for line in out.splitlines())
+ if len(f) == 2 and f[0] == 'build' and '=' in f[1])
+ return bool(commit) and info.get('vcs.revision') == commit and info.get('vcs.modified') == 'false'
+
+
def self_consistent(version, sums, commit):
"""The runner release names its own bytes: one build, one set of digests."""
runner = ROOT / 'releases' / f'equipo-runner-linux-amd64-{version}'
@@ -122,6 +136,10 @@ def main():
if not consistent or not commit.startswith(version):
print(f'refused: the {version} runner release does not name its own bytes', file=sys.stderr)
return 1
+ for name, path in artifacts(version, instance).items():
+ if not built_from(path, commit):
+ print(f'refused: the {name} binary does not say it was built from {commit}, unmodified', file=sys.stderr)
+ return 1
go = subprocess.run(['go', 'env', 'GOVERSION'], capture_output=True, text=True, check=True).stdout.strip()
manifest_path(version, instance).write_text(json.dumps({
'version': version, 'commit': commit, 'go': go, 'release': release, 'sha256': sums}, indent=2) + '\n')
diff --git a/scripts/staging-thin.py b/scripts/staging-thin.py
index 4eed53eb..ac495899 100755
--- a/scripts/staging-thin.py
+++ b/scripts/staging-thin.py
@@ -320,6 +320,10 @@ def install(sha, release, root, unit_name, person, cookie_path, create):
EQUIPO_ACCOUNTS_ROOT=str(root / 'accounts'),
EQUIPO_RUNNER_CREATE_REPOS='1' if create else '0')
private(root / 'service.env', ''.join(f'{k}={json.dumps(v)}\n' for k, v in sorted(env.items())))
+ # Before enrolment or the unit starts anything: the runner holds every
+ # program in this configuration (bubblewrap, claude, codex and its code
+ # mode host, the tool proxy) to the digests of its release.
+ run([str(release / 'equipo-runner'), 'verify-installed'], env=dict(os.environ, **env))
unit.parent.mkdir(parents=True, exist_ok=True)
unit.write_text(MARKER + '\n[Unit]\nDescription=Equipo staging runner\n[Service]\nType=simple\n'
f'EnvironmentFile={root / "service.env"}\nExecStart={release / "equipo-runner"} run\n'