Repository navigation
fix(ci): enforce and test the subprocess gate's documented contract - #1913
Merged
Merged
Conversation
`ci/find_direct_subprocess.py` runs with `--fail` in `check-ubuntu.yml` and `lint-subprocess.yml`, but it had no test and its docstring promised two things the code did not do (#141): 1. "allow a site with `allow-direct-spawn: <one-line reason>`" -- a BARE marker was accepted as an allowlist entry with the reason `<no reason given>`, so an unexplained hold-out was indistinguishable from a forgotten migration and silently pre-authorised every future `Command::new` at that site. A reason is now mandatory. 2. "skip occurrences inside doc comments or string literals" -- only lines *starting* with `//`, `///`, `//!` or `*` were skipped. A trailing `// Command::new(` comment, a `/* ... */` block, or a fixture string failed the build; worse, the quote in a char literal (`let q = '"';`) opened a phantom string that blanked the rest of the line and HID a real spawn after it. Replace the line-start heuristic with a small Rust-aware line lexer that blanks `//` comments, nested `/* ... */` comments, escaped strings, raw strings (`r#"..."#`) and char literals while preserving columns. Reasoning moves into `unmigrated()`/`exit_code()`, and the pending list now explains why a reason-less marker did not work. The verdict on the current workspace is unchanged and was verified byte-for-byte: 36 sites, all allowlisted, 0 to migrate. Tests: new `ci/test_find_direct_subprocess.py` (17 cases: both allowlist directions, bare/colon/whitespace-only markers, trailing + nested block comments, string/raw-string/char literals, lifetimes, CRLF, `--fail` exit codes, and the live workspace scan). Registered in `ci/local_suites.py` and the drift workflow; documented in `ci/README.md`.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This was referenced Nov 5, 2026
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.
What
ci/find_direct_subprocess.pyis the gate that forbids directstd::process::Command::new/tokio::process::Command::newoutside thefbuild-core::subprocesswrappers (#141). It runs with--failfromcheck-ubuntu.ymlandlint-subprocess.yml— but it had no test at all,and its docstring promised two behaviours the code did not implement.
1. The allowlist accepted an unexplained marker
The docstring says a site is allowlisted by
// allow-direct-spawn: <one-line reason>A bare marker (
// allow-direct-spawn, or with a colon and nothing afterit) was accepted as an allowlist entry whose reason was literally
<no reason given>. An unexplained hold-out then looks exactly like aforgotten migration, and the site is pre-authorised forever. A reason after
the colon is now mandatory; without one the site is reported as unmigrated.
2. Commentary and fixtures failed the build — and a char literal hid a real spawn
The skip predicate only looked at how a line starts:
let x = 1; // e.g. Command::new("git")— trailing comment: false red./* ... Command::new("git") ... */block, including nested: false red.let s = "Command::new(x)";in a test fixture: false red.let q = '"'; let c = Command::new("git");— the quote inside the charliteral opened a phantom string that blanked the rest of the line, so the
real spawn was invisible to the gate.
The line-start heuristic is replaced with a small Rust-aware lexer that blanks
//comments, nested/* ... */comments, escaped strings, raw strings(
r#"..."#) and char literals, while preserving column positions (the markerlookup still reads the raw line, so markers remain comment-based).
Reasoning moves into
unmigrated()/exit_code(), and the pending list nowsays why a reason-less marker did not take effect.
Verdict on the current tree is unchanged
Compared old vs new in JSON mode over the real workspace: identical — 36
sites, all allowlisted with the same reasons, 0 to migrate. This PR is
therefore safe to merge without touching any source file under
crates/.Tests
ci/test_find_direct_subprocess.py— 17 cases, registered inci/local_suites.pyand.github/workflows/ci-workflow-drift.yml(the twoentry points that
ci/test_local_suites.pykeeps in parity)://, whole-line///+//!, nested/* */, string, raw string,char-literal and lifetime cases;
--faildecides the exit code;RED proof (old behaviour restored on top of the new file): 12 of 17 fail,
including
test_marker_without_a_reason_does_not_allowlist, the nested-blockcase and the workspace scan. Removing only the char-literal branch fails
test_char_literal_does_not_open_a_phantom_string— the escape hatch was real.Gates run locally:
ruff checkclean,ci/check_python_complexity.pyAll checks passed!, hosted self-test set 127 tests OK (110 before + 17),ci.find_direct_subprocesson the workspace0 to migrate.Closes nothing; #141 stays open until the remaining hold-outs migrate.