carlos / platform Public

set-aside test: the child dies with the parent's deadline (review P3)

Opus review READY (no P1/P2). P3 1: the namespaced child now runs under
the test's deadline and Pdeathsig, so a hang can't outlive the run on
a CI worker. P3 2 (the mount unit's comment) is left alone: an edited
unit would be rewritten on every box at the next roll for a comment.
startrule.go notes that its raw path is layout.RawInstanceDir's, which
activator cannot import.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev b092dcdeafe8f0e1e4fadfa16c4ad8a3d8773fa9 parent 606b37f
2 files changed, +12 −1
  • internal/activator/startrule.go +2 −0
  • internal/activator/startrule_bind_linux_test.go +10 −1

CI failed — run details

Intent

Human

<task-notification> <task-id>ad0bf2efbc85cb6fc</task-id> <tool-use-id>toolu_01XCXKWsvVSnhU371TchQw3u</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/3bbea1fd-996b-42f3-b651-0add5a8ac1d5/tasks/ad0bf2efbc85cb6fc.output</output-file> <status>completed</status> <summary>Agent "Review set-aside EXDEV fix" 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>**Verdict: READY.** I found no P1 or P2 issues. I checked that the new test fails without the fix: I reverted the one line through a `go test -overlay` copy in `$TMPDIR`, and the worktree was not touched. The reverted run hits the box's error, `renameat2 .../instances/shop.example.com/shop.example.com.db .../.superseded/.../&lt;n&gt;.partial/...: invalid cross-device link`. With the fix, the targeted set-aside, interrupted-move and durability-order tests all pass. The bind test really ran here and was not skipped. No temp dirs or mounts were left behind, after either the passing or the failing run. **1. Correctness on a nested box.** - `carlos-edge.service` has `ReadWritePaths=/data`, so in the agent's namespace `/data/.instances` and `/data/.superseded` sit on one mount and only `/data/instances` is a separate bind. The raw path therefore shares `.superseded`'s mount and the rename succeeds. - No other rename or link in the start-rule flow crosses the bind. Each of these stays inside one directory: - the marker write (`writeDurable` → `WriteAtomic`, in `dir`) - the `.partial` → final rename (inside `hostDir`) - the seed placement (`seedplace.go:433`) - the litestream restore into `dbPath` - the corrupt-restore quarantine (`backend_exec.go:957`) - the HA renames (`hawake.go:559,635`) - `seedplace.go:186` reuses `reconcileAssignment`, so it gets the fix too. **2. Safety.** - A tenant cannot steer which path is used. The `id` comes from the host name, and `/data`, `/data/.instances` and `/data/instances` belong to `carlos` (mode 0700). An isolated unit sees only its own directory (`TemporaryFileSystem=/data:ro`). A flat child already shares the agent's uid and could do anything anyway. - A symlink at the raw path fails `IsDir`, so the code falls back to `dir`. - Moving through the raw path (no nosymfollow) loses no protection: `openDir` refuses symlinks (`RESOLVE_NO_SYMLINKS`), and `renameat2` never follows its last path component. - The time-of-check race fails closed in both directions. If the bind appears after the check, the rename gets EXDEV and the wake is refused, as before. If the bind disappears, the raw path is still on the same mount. - Durability holds: both paths name the same inode, so syncing the directory through the raw path covers it. **3. Flat layout and boxes without `.instances`.** These behave exactly as before. A flat `dir` of `/data` gives `Rel` = `..`. A missing or different raw directory fails the Lstat or `SameFile` check. A relative path makes `Rel` error. All three return `dir`. **4. The test.** It reproduces the box's condition, and it checks that the rename really gets EXDEV first. It is safe to run in CI: - From an unprivileged user namespace, the new mount namespace already turns shared mounts into slaves, and the `MS_PRIVATE` call adds a second guard. - The unmount cleanup runs before `TempDir` removal (cleanups run last-in, first-out). - The namespace dies with the child process. - Blocked user namespaces cause a skip (the start error is not an `ExitError`), and so does an AppArmor mount `EPERM` (via `SKIP-BIND`). **Findings:** - **P3** `internal/activator/startrule_bind_linux_test.go:45,52`: the child gets no `-test.timeout` and runs under plain `CombinedOutput`, with no context and no `Pdeathsig`. If `Restore` ever blocks inside the child, `go test -timeout` panics the parent and leaves the namespaced child orphaned on the CI worker. Fix: pass the parent's deadline through, using `exec.CommandContext` with `t.Deadline()` or `-test.timeout`. - **P3** `internal/host/units/data-instances.mount` (header comment): it still says `/data/.instances` is "opened by the layout pass only". That statement is now false. Someone reasoning about the nosymfollow guarantee from it would miss the set-aside path. **5. Possible follow-ups (same EXDEV risk; not changed here).** - `internal/host/movesoffline_land.go:550-557` → `ensureAbsent` → `parkInto` (`os.Rename` at `:294`). `warmPaths` includes `rt.DBPath`. On a nested row with a warm copy, that renames `/data/instances/&lt;id&gt;/&lt;host&gt;.db` into `&lt;DataDir&gt;/.offline-moves/...`, which would get EXDEV. - `internal/host/claimretire_local.go:91` → `park.Local.RetireSuperseded` (`internal/park/local_linux.go:341`, `Renameat2`). Worth checking whether its database path can be nested. Claims are shelved, so this is low priority. - Already correct, and a precedent for this fix: `movesoffline.go` `retirePaths` moves through `layout.RawInstanceDir`. The layout pass also works on the raw path. `movesinstall`, `movesfinal` and `movesrollback` move only flat paths.</result> <usage><subagent_tokens>101855</subagent_tokens><tool_uses>36</tool_uses><duration_ms>287658</duration_ms></usage> </task-notification>

Attributed to this commit: 10.6 g CO₂e (1,237,834 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on fix-set-aside-exdev, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/activator/startrule.go b/internal/activator/startrule.go
index 09eda92aa..50a447c0c 100644
--- a/internal/activator/startrule.go
+++ b/internal/activator/startrule.go
@@ -236,6 +236,8 @@ func (b *ExecBackend) setAsideSource(dir string) string {
if err != nil || id == "." || id == ".." || strings.HasPrefix(id, ".."+string(filepath.Separator)) || strings.ContainsRune(id, filepath.Separator) {
return dir
}
+ // The same path as layout.RawInstanceDir, which this package cannot
+ // import (layout imports activator).
raw := filepath.Join(data, ".instances", id)
viaBind, errB := os.Lstat(dir)
viaRaw, errR := os.Lstat(raw)
diff --git a/internal/activator/startrule_bind_linux_test.go b/internal/activator/startrule_bind_linux_test.go
index 998c29544..3c642543c 100644
--- a/internal/activator/startrule_bind_linux_test.go
+++ b/internal/activator/startrule_bind_linux_test.go
@@ -41,12 +41,21 @@ func TestSetAsideCrossesTheNestedBindMount(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- cmd := exec.Command(self, "-test.run=^TestSetAsideCrossesTheNestedBindMount$", "-test.count=1", "-test.v")
+ // The child dies with the parent's deadline, so a hang in it can never
+ // outlive the test run on a CI worker.
+ ctx := context.Background()
+ if dl, ok := t.Deadline(); ok {
+ var cancel context.CancelFunc
+ ctx, cancel = context.WithDeadline(ctx, dl)
+ defer cancel()
+ }
+ cmd := exec.CommandContext(ctx, self, "-test.run=^TestSetAsideCrossesTheNestedBindMount$", "-test.count=1", "-test.v")
cmd.Env = append(os.Environ(), bindChildEnv+"=1")
cmd.SysProcAttr = &syscall.SysProcAttr{
Cloneflags: syscall.CLONE_NEWUSER | syscall.CLONE_NEWNS,
UidMappings: []syscall.SysProcIDMap{{ContainerID: 0, HostID: os.Getuid(), Size: 1}},
GidMappings: []syscall.SysProcIDMap{{ContainerID: 0, HostID: os.Getgid(), Size: 1}},
+ Pdeathsig: syscall.SIGKILL,
}
out, err := cmd.CombinedOutput()
if i := strings.Index(string(out), bindSkipPrefix); i >= 0 {