With `CARGO_TARGET_DIR` exported, four to eight of the crate's 13 tests
failed. The tests build scratch crates in the temp directory and run the
harness over them, and the harness's `cargo` runs inherit the test process's
environment. Every scratch crate is a package named `scratch` at 0.1.0, and
cargo names its artifacts without the package's path, so under one exported
target directory the concurrent tests' crates built over each other's
artifacts and fingerprints: after one run the shared directory held three
`scratch-<hash>` builds for all thirteen tests' crates. Reproduced here at
7cf1f036 by running the test binary with `CARGO_TARGET_DIR` set to a scratch
directory: 9 passed, 4 failed (`l3_fix_passes_the_same_gates`,
`l3_garbage_is_caught_by_the_gate_and_reverted`,
`shipped_l3_fix_induces_a_skill_that_closes_the_recurrence_without_a_model`,
`failed_gate_reverts_and_never_ships`).
The fix is in test builds only. Under `cfg(test)`, `Harness` carries the
workspace's own `target/`, and every `cargo` run it makes (`clippy`, `clippy
--fix`, `test`, `build`) is handed `--target-dir <workspace>/target` after
the subcommand, which outranks an inherited `CARGO_TARGET_DIR`: each scratch
crate builds where it does with no `CARGO_TARGET_DIR` at all. Production
builds have neither the field nor the flag; `joule-fix` passes cargo its
arguments as before, and the user's environment, `CARGO_TARGET_DIR`
included, decides where it builds.
`verified_fix_end_to_end_ships_with_receipt` now checks both halves: the
arguments a test harness hands cargo carry the flag, and after the run the
scratch crate's own `target/debug` exists.
13/13, three runs each, with and without `CARGO_TARGET_DIR` exported to a
scratch directory, which stayed empty; and `CARGO_TARGET_DIR` exported to
the workspace's own target directory around `cargo test -p
joule-code-remediate`, 13/13. Falsified: compiling the flag out again fails
five with `CARGO_TARGET_DIR` exported (the four above and the end-to-end
test) and one without it (the end-to-end test's argument check). `cargo
clippy --all-targets -p joule-code-remediate` is clean.
Co-Authored-By: Claude Opus 5.5 <[email protected]>