carlos / platform Public

ship --check: name the prepare helper outside the process names (R1 P1)

Astra round 1 (P1): the helper container <prefix>-prepare collided with a
valid worker named prepare (release.ValidWorkerName allows it), whose
container is also <prefix>-prepare; the runtime refused the duplicate
name and a healthy app failed its check. The helper is now
<prefix>_prepare: "_" is outside the worker grammar
(^[a-z][a-z0-9-]{0,15}$) and inside Docker's and Podman's container names.
Volumes and the image live in namespaces of their own.

Test first: the fake runtime now refuses a second container by a name in
use, and TestRootfsCheckWorkerNamedLikeTheHelper declares a worker named
prepare; with the old name it fails "the container name ... is already in
use".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 29e0c39a269321bf29e673ad14e420e5d5d29b6e parent 03e08f5
2 files changed, +58 −19
  • ship_check.go +6 −1
  • ship_check_test.go +52 −18

Intent

Human

<task-notification> <task-id>b0hm2csw9</task-id> <tool-use-id>toolu_01BF4WmkVxGNSuni2whr8T5z</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/b0hm2csw9.output</output-file> <status>completed</status> <summary>Background command "Run Astra review round 1 on the check fix" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>a816125b84bc05151</task-id> <tool-use-id>toolu_01JrLeuwuRje5J9tiPdQur3b</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a816125b84bc05151.output</output-file> <status>completed</status> <summary>Agent "Draft fleet public routes spec" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>I've written the Phase 1a spec and committed it on branch `design-fleet-public-routes` (tip `855b514e40a430b35b89d5018d28337b085096f6`, one commit on top of origin/main `1fa2a99b`). It is not pushed and nothing was posted on amadan. It has had no review rounds, and nothing was built or run beyond reading code and the dev deployment. - **Spec:** `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md` - **Git warning:** the commit landed and the tree is clean, but git printed an error about an empty `.git/packed-refs.lock` dated Oct 28. It isn't mine, so I left it alone. **How r10r connects today** - box-1 dials out to `tunnel.dev.carlosframework.com`. That name, `platform.dev.carlosframework.com` and `*.bab.dev.oncarlos.com` all resolve to 99.80.78.4, which is sophie, the dev console box. - The hub is in practice the console's box. Its edge has `CARLOS_TUNNEL_HOST` set and checks box tokens against the `fleet_boxes` table, and only the console writes that table, into its own `/data/registry.db`. - box-1 serves its whole edge back over the tunnel, so TLS for the public name ends at the hub. Sophie has no row for shop, so it refuses the name, which is the TLS alert. box-1's own certificate failure is harmless noise. - railsdemo already serves through a hand row (200, one `x-carlos-version: r3b`). The serving side works; only the row is missing. **Design summary** 1. The hub's own instance pass writes a new kind of row, `forward`. It already reads every record and currently skips fleet-placed ones at `inScope`. 2. The row holds the host, app, account and `Region=fleet/&lt;f&gt;`, and is `ready` and `Provisioned`. It has no socket, version, runtime, unit or database path, so nothing on the hub stages, starts or replicates the app. 3. A row is written only when the record's fleet is in the hub's local `fleets` table and owned by the record's account. 4. The edge checks the same rule when it reloads: any fleet-placed row whose account isn't the fleet owner gets no proxy and no certificate. This also covers hand rows and custom domains. 5. The existing `fleetProxy` serves the row. It uses the box the bindings name, else the first connected box, else 503 with Retry-After. 6. The pass removes the row when the record is deleted or moved, or the owner stops matching, but only on a pass where every read succeeded. A box that stops being the hub cleans up its own rows. 7. The `inScope` boundary stays: a platform box never runs a fleet record. 8. The new pass runs before the instance pass mints rows, so an app moving from a fleet to the hub's region sees its forward row gone first. 9. Certificates, custom domains, backhaul from other platform boxes and steering all follow from the row through the hub's edges file and the alias pass, with no new code. 10. The hub stamps no `X-Carlos-Version`, so the box's single header passes through. Analytics are already counted once. 11. Single-box fleets are fully correct. On multi-box fleets the box choice can lag about 5.5 minutes after an instance moves, which is 1b's problem. 12. Request cost: no new reads. Limiting the existing bindings pass to the hub saves `(Nāˆ’1) Ɨ 262 Ɨ (1+F+B)` requests a day, where N is the number of platform boxes, F the number of fleet folders in the bucket and B the number of binding files. 13. The root-read census fails as expected and needs a card. No root read is added, because root's passes select on kinds and columns a forward row doesn't carry. 14. The gating test, ahead of reviews, uses a real console, a real hub edge and a real fleet-box edge over the tunnel, with no hand-built rows. After the dev roll, the live check is the curl, plus the same request sent through leo. 15. There's no switch and no release floor. It goes live with the dev roll first. A rollback leaves rows the older binary still serves and never removes. **Open questions, with my recommendations** 1. **Row shape:** use the new `forward` kind rather than `instance` or the `Platform` flag. Yes: `instance` rows get staged and run by the hub's adopt pass (the hand rows dodge this with a made-up channel). `Platform` rows can be removed by the domains pass. 2. **Hub response cache:** forwarded responses should skip it in 1a. The app's `Carlos-Purge` header stops at the box, so the hub's cached copy could never be cleared. 3. **Hand rows:** leave them winning and don't adopt them. Convert only `Provisioned` placed rows. railsdemo's hand row comes out later, with your approval. 4. **Edge ownership refusal:** refuse any fleet-placed row whose account doesn't match the fleet owner. Mismatches only; rows with no account are served as today and logged. 5. **`apps place`:** it should stop re-stamping rows on the console box, so the passes set the hub's rows from records in both directions. **Where the code contradicts the #457 draft** - "The console never writes route rows" is not quite right. `apps place` re-stamps `Region` on the console box's existing rows (`internal/console/fleets.go:817-829`). It never adds a row, so it never helped apps placed at creation or rootfs apps, which can't be placed at all. - The bucket owner record isn't needed for the ownership check. The hub already has the console's `fleets` table locally, the same table its tunnel login and store door use. - The "hub" is specifically the console's box, sophie on dev. - The record doesn't name a box. The box comes from the existing bindings (`fleets/&lt;f&gt;/bindings/&lt;host&gt;.json`) via `ReconcileFleetBindings`, which today runs on every platform box. - `fleetProxy` is at `internal/edge/edge.go:3106` on main, not 3059. The `inScope` reference (`reconcile.go:487-499`) is correct. - "Custom domains and certificates follow from the row" is true, but the draft missed two things: the ownership check at the edge, and the hub cache that the app's purge header can't reach.</result> <usage><subagent_tokens>277948</subagent_tokens><tool_uses>118</tool_uses><duration_ms>1166659</duration_ms></usage> </task-notification>

diff --git a/ship_check.go b/ship_check.go
index 7c823f248..f3d6ce055 100644
--- a/ship_check.go
+++ b/ship_check.go
@@ -207,7 +207,12 @@ func (c *rootfsCheck) makeImageAndVolumes(ctx context.Context) bool {
// waits for it to exit 0. It is recorded like every container, so the
// cleanup removes it.
func (c *rootfsCheck) prepareData(ctx context.Context) bool {
- ctr := c.prefix + "-prepare"
+ // A process's container is <prefix>-<name>, and a worker may be named
+ // prepare (release.ValidWorkerName). The helper's "_" is outside that
+ // grammar, and inside the runtimes' container names
+ // ([a-zA-Z0-9][a-zA-Z0-9_.-]*), so the two never meet. Volumes and the
+ // image are named in namespaces of their own.
+ ctr := c.prefix + "_prepare"
args := []string{"run", "-d", "--name", ctr,
"--read-only", "--network", "none",
"--cap-drop", "ALL", "--cap-add", "CHOWN", "--security-opt", "no-new-privileges",
diff --git a/ship_check_test.go b/ship_check_test.go
index 8922a6a87..d9af4dbcf 100644
--- a/ship_check_test.go
+++ b/ship_check_test.go
@@ -27,7 +27,9 @@ import (
// objects the check made, which must end empty.
// checkName is the shape of every name the check gives the runtime.
-var checkName = regexp.MustCompile(`^carlos-check-[0-9a-f]{8}(-[a-z][a-z0-9-]*|:latest)$`)
+// A process's container is <prefix>-<process>; the check's own helper is
+// <prefix>_<helper>, a form no process name can take.
+var checkName = regexp.MustCompile(`^carlos-check-[0-9a-f]{8}(-[a-z][a-z0-9-]*|_[a-z]+|:latest)$`)
type fakeCheck struct {
t *testing.T
@@ -69,9 +71,10 @@ func newFakeCheck(t *testing.T) *fakeCheck {
func (f *fakeCheck) rt() containerRuntime { return containerRuntime{name: "docker", run: f.run} }
-// procOf is the process a container is named for.
+// procOf is the process a container is named for, or "_" and the helper's
+// name for one of the check's own (<prefix>_prepare is "_prepare").
func procOf(ctr string) string {
- return strings.TrimPrefix(ctr, ctr[:len("carlos-check-")+9])
+ return strings.TrimPrefix(ctr[len("carlos-check-")+8:], "-")
}
func flagValue(args []string, flag string) string {
@@ -131,9 +134,14 @@ func (f *fakeCheck) run(ctx context.Context, stdin io.Reader, args ...string) ([
makes = "container:" + ctr
}
if makes != "" {
- if name := makes[strings.IndexByte(makes, ':')+1:]; !checkName.MatchString(name) {
+ name := makes[strings.IndexByte(makes, ':')+1:]
+ if !checkName.MatchString(name) {
f.t.Errorf("%v names %q", args, name)
}
+ // Docker and Podman refuse a second container by a name in use.
+ if args[0] == "run" && f.made[makes] {
+ return nil, fmt.Errorf(`Error: creating container storage: the container name %q is already in use`, name)
+ }
f.made[makes] = true
}
if args[0] == "import" {
@@ -301,9 +309,9 @@ func TestRootfsCheckHappyPath(t *testing.T) {
want := []string{
"info", "import", "volume create data", "volume create run",
- "run prepare", "wait prepare",
+ "run _prepare", "wait _prepare",
"run release", "wait release", "run web", "exec web", "run jobs", "inspect jobs",
- "rm -f prepare", "rm -f release", "rm -f web", "rm -f jobs", "volume rm data", "volume rm run", "rmi",
+ "rm -f _prepare", "rm -f release", "rm -f web", "rm -f jobs", "volume rm data", "volume rm run", "rmi",
}
if got := f.summary(); !slices.Equal(got, want) {
t.Errorf("calls:\n got %q\nwant %q", got, want)
@@ -610,16 +618,16 @@ func TestRootfsCheckPreparesTheDataVolume(t *testing.T) {
t.Fatalf("report = %q", r.lines)
}
sum := f.summary()
- at := slices.Index(sum, "run prepare")
- if at < 0 || at+2 >= len(sum) || sum[at+1] != "wait prepare" || sum[at+2] != c.first {
- t.Fatalf("calls %q: want run prepare, wait prepare, then %s", sum, c.first)
+ at := slices.Index(sum, "run _prepare")
+ if at < 0 || at+2 >= len(sum) || sum[at+1] != "wait _prepare" || sum[at+2] != c.first {
+ t.Fatalf("calls %q: want run _prepare, wait _prepare, then %s", sum, c.first)
}
if create := slices.Index(sum, "volume create data"); create < 0 || create > at {
t.Errorf("calls %q: prepare before the data volume exists", sum)
}
- prep := f.runOf("prepare")
+ prep := f.runOf("_prepare")
name := flagValue(prep, "--name")
- prefix := strings.TrimSuffix(name, "-prepare")
+ prefix := strings.TrimSuffix(name, "_prepare")
id := strings.TrimPrefix(prefix, "carlos-check-")
want := []string{"run", "-d", "--name", name,
"--read-only", "--network", "none",
@@ -644,7 +652,7 @@ func TestRootfsCheckPreparesTheDataVolume(t *testing.T) {
if !slices.Equal(caps, []string{"CHOWN"}) {
t.Errorf("prepare adds %q, want CHOWN alone", caps)
}
- if !slices.Contains(sum, "rm -f prepare") {
+ if !slices.Contains(sum, "rm -f _prepare") {
t.Errorf("calls %q: the prepare container is never removed", sum)
}
f.checkLeftNothing(t)
@@ -652,6 +660,32 @@ func TestRootfsCheckPreparesTheDataVolume(t *testing.T) {
}
}
+// The helper's container is named outside the process names' grammar, so a
+// release may declare a worker named prepare, and it runs as any worker.
+func TestRootfsCheckWorkerNamedLikeTheHelper(t *testing.T) {
+ noSettle(t)
+ if !release.ValidWorkerName("prepare") {
+ t.Fatal("prepare is no longer a valid worker name; pick another of the helper's names")
+ }
+ f := newFakeCheck(t)
+ procs := shopProcs()
+ procs["prepare"] = release.Process{Command: []string{"/srv/jobs", "prepare"}}
+ r := runRootfsCheck(context.Background(), f.rt(), shopBuild(t, procs), "/probe/carlos", f.out)
+ if r.failed {
+ t.Fatalf("report = %q", r.lines)
+ }
+ if !slices.Contains(r.lines, "prepare is still running after 5.0 s") {
+ t.Errorf("report = %q, want the prepare worker running", r.lines)
+ }
+ if w := f.runOf("prepare"); w == nil || flagValue(w, "--entrypoint") != "/srv/jobs" {
+ t.Errorf("the prepare worker ran as %q", w)
+ }
+ if h := f.runOf("_prepare"); h == nil || flagValue(h, "--entrypoint") != "/opt/carlos/carlos" {
+ t.Errorf("the helper ran as %q", h)
+ }
+ f.checkLeftNothing(t)
+}
+
// A prepare that does not exit 0 fails the check before any process runs,
// and the check still removes everything it made.
func TestRootfsCheckPrepareFailureStopsTheCheck(t *testing.T) {
@@ -662,15 +696,15 @@ func TestRootfsCheckPrepareFailureStopsTheCheck(t *testing.T) {
want []string
}{
{"an exit", func(f *fakeCheck) {
- f.waitBy["prepare"] = "1\n"
- f.logs["prepare"] = "chown /data/instances/check: operation not permitted\n"
+ f.waitBy["_prepare"] = "1\n"
+ f.logs["_prepare"] = "chown /data/instances/check: operation not permitted\n"
}, []string{"docker run: __rootfs-check-prepare exited with status 1", " chown /data/instances/check: operation not permitted", checkC75}},
{"an amd64 probe", func(f *fakeCheck) {
- f.waitBy["prepare"] = "255\n"
- f.logs["prepare"] = `exec /opt/carlos/carlos: exec format error` + "\n"
+ f.waitBy["_prepare"] = "255\n"
+ f.logs["_prepare"] = `exec /opt/carlos/carlos: exec format error` + "\n"
}, []string{checkNoEmulation, checkC75}},
{"not an exit status", func(f *fakeCheck) {
- f.waitBy["prepare"] = "gone\n"
+ f.waitBy["_prepare"] = "gone\n"
}, []string{`docker wait: "gone" is not an exit status`, checkC75}},
} {
t.Run(c.name, func(t *testing.T) {
@@ -685,7 +719,7 @@ func TestRootfsCheckPrepareFailureStopsTheCheck(t *testing.T) {
t.Errorf("%q after prepare failed", s)
}
}
- if !slices.Contains(f.summary(), "rm -f prepare") {
+ if !slices.Contains(f.summary(), "rm -f _prepare") {
t.Errorf("calls %q: the prepare container is never removed", f.summary())
}
f.checkLeftNothing(t)