From 84086a423cadccab9767ea04177393c653d7f71b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 14 Nov 2026 22:47:05 -0800 Subject: [PATCH 1/2] quest: plan the TMPDIR leaks from harness runs and carla bridge tests Co-Authored-By: Claude Opus 5.5 --- quest/m1/carla-bridge-test-locks.md | 24 ++++++++++++++++ quest/m1/harness-runs-in-target.md | 43 +++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 quest/m1/carla-bridge-test-locks.md create mode 100644 quest/m1/harness-runs-in-target.md diff --git a/quest/m1/carla-bridge-test-locks.md b/quest/m1/carla-bridge-test-locks.md new file mode 100644 index 00000000000..8eaa64277e6 --- /dev/null +++ b/quest/m1/carla-bridge-test-locks.md @@ -0,0 +1,24 @@ +# [XS] The carla bridge's tests leave no lock files + +## Goal + +Running the carla bridge's tests (`demo/carla/bridge`) leaves no +`carla-bridge-*.sock.lock` file, or socket, behind in TMPDIR. + +## Plan + +Found 2026-11-14 by [kixel-ai/dotfiles#164](https://github.com/kixel-ai/dotfiles/pull/164)'s +trace of what moq leaves in TMPDIR. `Bridge::listen` (`src/lib.rs`) takes an +flock on `.lock` and never removes it. That is right in production: +unlinking a lock file another process may be opening lets two bridges lock +different inodes at one path. The tests in `src/lib.rs`, `src/server.rs`, and +`tests/gpu.rs` name sockets `std::env::temp_dir()/carla-bridge-*-.sock`, +so every run leaves a new lock file. + +Recommendation: each test puts its socket in a temporary directory it owns and +removes, such as with a `tempfile` dev-dependency, leaving `Bridge` unchanged. + +Fixes [moq-dev/moq#5621](https://github.com/moq-dev/moq/pull/5621), which added +the lock and the tests. + +Public API: none. Wire: none. diff --git a/quest/m1/harness-runs-in-target.md b/quest/m1/harness-runs-in-target.md new file mode 100644 index 00000000000..c4c4a24a382 --- /dev/null +++ b/quest/m1/harness-runs-in-target.md @@ -0,0 +1,43 @@ +# [S] Test-harness runs live under the cargo target directory + +## Goal + +A failed test-harness run (interop, smoke, and the other `test/lib/harness.sh` +callers) is kept under the cargo target directory, so its staged binaries are +hard links again and a kept run goes away with the worktree, instead of copying +about 4.3 GB of binaries into TMPDIR. `HARNESS_RUNS` still moves the root. How +interop runs are scheduled is out of scope. + +## Plan + +Found 2026-11-14 by [kixel-ai/dotfiles#164](https://github.com/kixel-ai/dotfiles/pull/164), +which made each agent session's TMPDIR a 12 GiB tmpfs on the NixOS host: fedora's +`/tmp/moq-test-1000` held 101 to 110 GB of kept runs. `harness_begin` roots runs +in `${TMPDIR:-/tmp}/moq-test-$UID`, and `harness_stage` hard-links each binary +into the run, falling back to a copy when TMPDIR is on another filesystem than +the target directory. A failing run keeps everything. + +Decided 2026-11-14 (maintainer, /quest-plan): ✅ stage and keep each run +directory under the target directory, so staging hard-links on the same +filesystem and a kept failed run, binaries included, is deleted with the +worktree (rejected: keep run directories in TMPDIR but delete staged binaries +on failure, keeping only logs). + +Guidance: + +- Resolve the root from `cargo metadata`'s `target_directory`, as + `test/interop/interop.sh` already does for `TARGET_BASE`, so a custom + `CARGO_TARGET_DIR` still shares a filesystem with the binaries. Port claims + stay in `/tmp`, which is shared across worktrees on purpose. +- AGENTS.md says scratch never goes in `target/`, because build output may be + wiped. A kept run is disposable evidence, so narrow that line in the same PR + rather than contradict it; say in the PR how a wipe during a live run behaves + (a hard-linked binary survives its source being unlinked, not its run + directory being removed). +- Update `test/README.md`, which documents the root. + +Fixes [moq-dev/moq#7715](https://github.com/moq-dev/moq/pull/7715), which began +staging binaries into run directories with a copy fallback, under the TMPDIR +root that [moq-dev/moq#3509](https://github.com/moq-dev/moq/pull/3509) chose. + +Public API: none. Wire: none. From 6fb586d42cbeffc938d6266936c5c043481ff0c0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 14 Nov 2026 23:40:55 -0800 Subject: [PATCH 2/2] quest: keep harness runs in the checkout's .tmp/, per the maintainer Co-Authored-By: Claude Opus 5.5 --- quest/m1/harness-runs-in-checkout.md | 46 ++++++++++++++++++++++++++++ quest/m1/harness-runs-in-target.md | 43 -------------------------- 2 files changed, 46 insertions(+), 43 deletions(-) create mode 100644 quest/m1/harness-runs-in-checkout.md delete mode 100644 quest/m1/harness-runs-in-target.md diff --git a/quest/m1/harness-runs-in-checkout.md b/quest/m1/harness-runs-in-checkout.md new file mode 100644 index 00000000000..02c63a9d771 --- /dev/null +++ b/quest/m1/harness-runs-in-checkout.md @@ -0,0 +1,46 @@ +# [S] Test-harness runs live in the checkout's .tmp/ + +## Goal + +A failed test-harness run (interop, smoke, and the other `test/lib/harness.sh` +callers) is kept under the checkout's `.tmp/` (such as `.tmp/harness/`), so a +kept run goes away with the worktree and never copies about 4.3 GB of staged +binaries into TMPDIR. `HARNESS_RUNS` still moves the root. How interop runs are +scheduled is out of scope. + +## Plan + +Found 2026-11-14 by [kixel-ai/dotfiles#164](https://github.com/kixel-ai/dotfiles/pull/164), +which made each agent session's TMPDIR a 12 GiB tmpfs on the NixOS host: fedora's +`/tmp/moq-test-1000` held 101 to 110 GB of kept runs. `harness_begin` roots runs +in `${TMPDIR:-/tmp}/moq-test-$UID`, and `harness_stage` hard-links each binary +into the run, falling back to a copy when the run is on another filesystem +than the binary. A failing run keeps everything. + +Decided 2026-11-14 (maintainer, on [moq-dev/moq#8793](https://github.com/moq-dev/moq/pull/8793)): +✅ keep each run directory, staged binaries included, in the checkout's `.tmp/` +(such as `.tmp/harness/`), beside TLC's `.tmp/tlc/`, so AGENTS.md's "scratch +never goes in `target/`" stands unchanged (rejected: the target directory, +narrowing that rule; keeping runs in TMPDIR but deleting staged binaries on +failure, keeping only logs). + +Hard links: mbx keeps build output outside the checkout, behind a `target` +link (`~/.cache/mbx/targets` on desktop, `/var/cache/mbx/targets` on fedora +and nixos). On 2026-11-14 each shared one XFS root filesystem with `~/work`, +so staging still hard-links on all three. Where they differ, `harness_stage` +falls back to `cp -L` into `.tmp/`: a full copy per run, but on the checkout's +disk and removed with the worktree, never in TMPDIR. `cp -L --reflink=auto` +makes that copy nearly free on btrfs or XFS; worth taking in the same change. + +Guidance: + +- Resolve the root from the checkout (`git rev-parse --show-toplevel`), since + harnesses change directory after `harness_begin`. Port claims stay in + `/tmp`, which is shared across worktrees on purpose. +- Update `test/README.md`, which documents the root. + +Fixes [moq-dev/moq#7715](https://github.com/moq-dev/moq/pull/7715), which began +staging binaries into run directories with a copy fallback, under the TMPDIR +root that [moq-dev/moq#3509](https://github.com/moq-dev/moq/pull/3509) chose. + +Public API: none. Wire: none. diff --git a/quest/m1/harness-runs-in-target.md b/quest/m1/harness-runs-in-target.md deleted file mode 100644 index c4c4a24a382..00000000000 --- a/quest/m1/harness-runs-in-target.md +++ /dev/null @@ -1,43 +0,0 @@ -# [S] Test-harness runs live under the cargo target directory - -## Goal - -A failed test-harness run (interop, smoke, and the other `test/lib/harness.sh` -callers) is kept under the cargo target directory, so its staged binaries are -hard links again and a kept run goes away with the worktree, instead of copying -about 4.3 GB of binaries into TMPDIR. `HARNESS_RUNS` still moves the root. How -interop runs are scheduled is out of scope. - -## Plan - -Found 2026-11-14 by [kixel-ai/dotfiles#164](https://github.com/kixel-ai/dotfiles/pull/164), -which made each agent session's TMPDIR a 12 GiB tmpfs on the NixOS host: fedora's -`/tmp/moq-test-1000` held 101 to 110 GB of kept runs. `harness_begin` roots runs -in `${TMPDIR:-/tmp}/moq-test-$UID`, and `harness_stage` hard-links each binary -into the run, falling back to a copy when TMPDIR is on another filesystem than -the target directory. A failing run keeps everything. - -Decided 2026-11-14 (maintainer, /quest-plan): ✅ stage and keep each run -directory under the target directory, so staging hard-links on the same -filesystem and a kept failed run, binaries included, is deleted with the -worktree (rejected: keep run directories in TMPDIR but delete staged binaries -on failure, keeping only logs). - -Guidance: - -- Resolve the root from `cargo metadata`'s `target_directory`, as - `test/interop/interop.sh` already does for `TARGET_BASE`, so a custom - `CARGO_TARGET_DIR` still shares a filesystem with the binaries. Port claims - stay in `/tmp`, which is shared across worktrees on purpose. -- AGENTS.md says scratch never goes in `target/`, because build output may be - wiped. A kept run is disposable evidence, so narrow that line in the same PR - rather than contradict it; say in the PR how a wipe during a live run behaves - (a hard-linked binary survives its source being unlinked, not its run - directory being removed). -- Update `test/README.md`, which documents the root. - -Fixes [moq-dev/moq#7715](https://github.com/moq-dev/moq/pull/7715), which began -staging binaries into run directories with a copy fallback, under the TMPDIR -root that [moq-dev/moq#3509](https://github.com/moq-dev/moq/pull/3509) chose. - -Public API: none. Wire: none.