fix(harness, seat): the pi fit check gives one verdict whatever the temp directory is; a scratch under /tmp no longer hides itself (#1873) #2020

Merged
jason.woltje merged 5 commits from pi-fit-tmp into refactor 2026-11-20 19:26:55 +00:00
Owner

What changes

Lane pi-fit-tmp: the pi fit check gives one verdict whatever the temp directory is. Before this, a check whose temp directory was /tmp answered can't be checked: --help failed, so scripts/build.sh and scripts/release.sh package failed from a plain shell, every pi session launch on such a host refused, and the harness watch showed pi as unknown.

  • Cause. A fit run binds the pi's root, then its scratch directory, then the scratch's tmp/ over /tmp. bwrap mounts in the order given, and a mount hides earlier mounts under its target. With the scratch under /tmp the last bind hid the scratch, bwrap failed its chdir, and pi never started. The /tmp bind entered the fit check at eac42663b (pi-unpin S3 re-check 6).
  • Fix. New mountOrder(list) in packages/seat/src/sandbox.mjs moves each bind ahead of the first bind whose target lies under its own. Only checkArgv, the fit check's argv builder, uses it. The session sandbox (sandboxArgv, hostedArgv) is unchanged. Scratch directories go under the temp directory's real path, so a TMPDIR that links into /tmp works too.
  • A pi or node under /tmp is undecided. A session's sandbox mounts its private /tmp last and would cover such a pi, so a fit pass there would be wrong. The line is "can't be checked: the pi's package sits under the system temp directory, which a session's sandbox covers".
  • The --help failed line says how the run ended: exit status, signal, timed out, stopped, or did not start. No path and no env value.
  • Tests. Stand-in pis are built outside /tmp through a new fixtureDir() in packages/harness/tests/pi-stand-in.mjs, under /var/tmp when the temp directory is /tmp. One test runs a check with its temp directory under /tmp and removes its one directory in a finally.

No new verb, refusal code, grant, role, schema or config format.

What the check writes

One full check of pi 0.85.1 writes about 120 KB in total, with a peak of about 33 KB of file data at one time (roughly 1.4 MB of ext4 blocks), freed when each run ends. A killed check can leave that much until the next check sweeps it.

Tests

  • Lane proof on e035b6dea: 211 files under harness, plugins, conversation and cli plus the files that read pi-fit, 2958 pass, 2 fail, 33 skipped. The 2 fails are flows.test.mjs and reader.test.mjs, which import Python's jsonschema. This host lacks it and both are red at base.
  • Revert check: each new test fails with its change removed.
  • By hand at the tip: env -u TMPDIR node scripts/pi-fit-image.mjs answers pi 0.85.1 (the lock's pi) passed the fit check, exit 0, and /tmp holds nothing named mosaic after.
  • Lead check in a clean environment on e035b6dea: 344 files, 4195 pass, 2 fail, 32 skipped. The 2 fails are the same flows and reader jsonschema reds.

Review

Three rounds by fresh claude-opus-5-5 reviewers. The first approved with three minor findings, all fixed. The re-check asked for changes: with TMPDIR unset the new guard made test stand-in pis under /tmp undecided. Fixed in the fixtures, guard kept. Re-check 2 approved with two test-only findings, fixed as proposed.

Left for later

  • A session sandbox with a data root under /tmp has the same mount order. Not a default, and the session sandbox's mounts are a security boundary this lane did not have.
  • With TMPDIR unset, cli/tests/launcher.test.mjs and cli/tests/harness-watch-host.test.mjs fail with broker refused to start: startup-refused, at base too. Not this cause.
  • With TMPDIR unset, one W1 redaction test in plugins/tests/harness-watch.test.mjs fails at base and tip. It expects /tmp redacted, and the redactor keeps one-segment paths by design.
  • A run the OOM killer ends reads as "timed out".
  • scripts/verify.sh's health check failure is a separate cause.
## What changes Lane pi-fit-tmp: the pi fit check gives one verdict whatever the temp directory is. Before this, a check whose temp directory was `/tmp` answered `can't be checked: --help failed`, so `scripts/build.sh` and `scripts/release.sh package` failed from a plain shell, every pi session launch on such a host refused, and the harness watch showed pi as unknown. - **Cause.** A fit run binds the pi's root, then its scratch directory, then the scratch's `tmp/` over `/tmp`. bwrap mounts in the order given, and a mount hides earlier mounts under its target. With the scratch under `/tmp` the last bind hid the scratch, bwrap failed its chdir, and pi never started. The `/tmp` bind entered the fit check at eac42663b (pi-unpin S3 re-check 6). - **Fix.** New `mountOrder(list)` in `packages/seat/src/sandbox.mjs` moves each bind ahead of the first bind whose target lies under its own. Only `checkArgv`, the fit check's argv builder, uses it. The session sandbox (`sandboxArgv`, `hostedArgv`) is unchanged. Scratch directories go under the temp directory's real path, so a TMPDIR that links into `/tmp` works too. - **A pi or node under /tmp is undecided.** A session's sandbox mounts its private `/tmp` last and would cover such a pi, so a fit pass there would be wrong. The line is "can't be checked: the pi's package sits under the system temp directory, which a session's sandbox covers". - **The `--help failed` line says how the run ended**: exit status, signal, timed out, stopped, or did not start. No path and no env value. - **Tests.** Stand-in pis are built outside `/tmp` through a new `fixtureDir()` in `packages/harness/tests/pi-stand-in.mjs`, under `/var/tmp` when the temp directory is `/tmp`. One test runs a check with its temp directory under `/tmp` and removes its one directory in a finally. No new verb, refusal code, grant, role, schema or config format. ## What the check writes One full check of pi 0.85.1 writes about 120 KB in total, with a peak of about 33 KB of file data at one time (roughly 1.4 MB of ext4 blocks), freed when each run ends. A killed check can leave that much until the next check sweeps it. ## Tests - Lane proof on e035b6dea: 211 files under harness, plugins, conversation and cli plus the files that read pi-fit, 2958 pass, 2 fail, 33 skipped. The 2 fails are `flows.test.mjs` and `reader.test.mjs`, which import Python's `jsonschema`. This host lacks it and both are red at base. - Revert check: each new test fails with its change removed. - By hand at the tip: `env -u TMPDIR node scripts/pi-fit-image.mjs` answers `pi 0.85.1 (the lock's pi) passed the fit check`, exit 0, and `/tmp` holds nothing named mosaic after. - Lead check in a clean environment on e035b6dea: 344 files, 4195 pass, 2 fail, 32 skipped. The 2 fails are the same flows and reader jsonschema reds. ## Review Three rounds by fresh claude-opus-5-5 reviewers. The first approved with three minor findings, all fixed. The re-check asked for changes: with TMPDIR unset the new guard made test stand-in pis under `/tmp` undecided. Fixed in the fixtures, guard kept. Re-check 2 approved with two test-only findings, fixed as proposed. ## Left for later - A session sandbox with a data root under `/tmp` has the same mount order. Not a default, and the session sandbox's mounts are a security boundary this lane did not have. - With TMPDIR unset, `cli/tests/launcher.test.mjs` and `cli/tests/harness-watch-host.test.mjs` fail with `broker refused to start: startup-refused`, at base too. Not this cause. - With TMPDIR unset, one W1 redaction test in `plugins/tests/harness-watch.test.mjs` fails at base and tip. It expects `/tmp` redacted, and the redactor keeps one-segment paths by design. - A run the OOM killer ends reads as "timed out". - `scripts/verify.sh`'s health check failure is a separate cause.
jason.woltje added 5 commits 2026-11-20 19:26:52 +00:00
jason.woltje merged commit e035b6dea9 into refactor 2026-11-20 19:26:55 +00:00
Sign in to join this conversation.