Sweep the directory it is given, not the one it looks up - #10
Merged
Conversation
The sweep called std::env::temp_dir() itself, so its test had no way to aim it anywhere but the shared %TEMP%, and two things followed from that. A dead driver's profile name has to carry a dead pid and can carry nothing else, so the fixture was the same name in every run. Two runs at once fought over that one name: 26 failures in 40 runs with a second process writing to it, against 0 in 20 sequential runs. That is the flake. The other half is worse and was not on the list. A test run swept the real %TEMP%, so it deleted whatever chrono-cdp-* leftovers happened to be sitting there - measured, one run removed two unrelated directories it had never created. In the field those are a real session's leftovers, which a tester may still be reading. The directory is a parameter now. Production passes std::env::temp_dir() on the line above unique_temp_dir(), so the pair stays visible at the call site, and the ownership logic is untouched. The test builds a root of its own, deliberately not in the chrono-cdp-* shape, and asserts inside it under the existing TempDirGuard so a failing assertion still cleans up. Verified by reverting each half of the sweep's decision in turn, on the full 187-test binary run: sparing nothing fails "a live driver's profile must survive the sweep", removing nothing fails "a dead driver's profile is what the sweep is for". Gates 11/11, Rust 419, C# 365, harness 146 PASS. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sweep_orphan_profilescalledstd::env::temp_dir()itself, so its test had no way to aim it anywhere but the shared%TEMP%. Two defects followed from that, and only the first one was known.The flake. A dead driver's profile name has to carry a dead pid and can carry nothing else, so the fixture was the same name in every run. Two runs at once fought over that one name: 26 failures in 40 runs with a second process writing to it, against 0 in 20 sequential runs.
The one that was not on the list. A test run swept the real
%TEMP%, so it deleted whateverchrono-cdp-*leftovers happened to be there. Measured: one run removed two unrelated directories it had never created. In the field those are a real session's leftovers, which a tester may still be reading - evidence, in a tool whose product is evidence.What changed
The directory is a parameter now. Production passes
std::env::temp_dir()on the line aboveunique_temp_dir(), so the pair stays visible at the call site, and the ownership logic is untouched - the stability audit marks it as the part not to touch.The test builds a root of its own, deliberately not in the
chrono-cdp-*shape so a real sweep running beside it leaves it alone, and asserts inside it under the existingTempDirGuardso a failing assertion still cleans up.Verification
Each half of the sweep's decision was reverted in turn, on the full 187-test binary run:
a live driver's profile must survive the sweepa dead driver's profile is what the sweep is forGates 12/12, Rust 419, C# 365, probe harness 146 PASS / 0 FAIL.
Known and out of scope
cargo teststill sweeps the real%TEMP%by another route: the flag-refusal test callslaunch_chromiumwith an argument that passes validation and reaches the production sweep. Closing that needs the directory injected into the publiclaunch_chromiumsignature, which has four call sites - a separate change.🤖 Generated with Claude Code