Repository navigation
perf(guardrails): resolve delete targets with fewer processes - #13441
Conversation
block-root-delete-target bounds realpath, cygpath and git inside the shell instead of under timeout: the bound runs in the command substitution, a spare descriptor on a process substitution reaches end of file when the command exits, and read -t waits on it. That removes the 3 timeout processes on every host and the no-timeout branch. On Windows Git Bash, rdt_phys_to and rdt_win_to answer realpath -m and cygpath -l -m in the shell for paths with no symlink, junction, short name, non-ASCII name, trailing dot or space, or network drive; every other path still takes the process. The temp roots are read without their drive spellings, which named candidates the guard resolves itself. An ordinary rm -rf ./build now starts 1 process (git) on Git Bash instead of 8. block-root-delete-target-resolve.test.sh checks the bound against $(...) and its kill, the too-slow refusal through the whole guard, and on Git Bash the in-shell answers against the processes. It runs as a step of the Windows guards job. Refs: #13276 Co-Authored-By: Claude Opus 5.5 <[email protected]>
On Git Bash the shell now resolves an ordinary operand, so the slow realpath case, its resolve-suite twin and the judgment-error case named paths that never reached the realpath batch. Each now names a parent or target with a `~`, which the in-shell resolver declines on every host. rdt_bounded_to reaps the command it kills, so no zombie outlives the call. Refs: #13276 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Hook budget accounting gains the #13276 entry. On Windows Git Bash, `rm -rf ./build` now starts 1 process instead of 8. Every judged payload is 126 to 152 ms faster, lower in all 5 alternating blocks, and the common call is unchanged. The entry also states the remaining overage and that the Windows differential lane is informational. A portability-ok note marks a literal backslash in the resolve suite's printf data. Refs: #13276 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both files start with a shebang, which the exec-bit check requires to carry mode 755. The suite's Windows comparison now takes the helper's status directly instead of through a subshell variable. Refs: #13276 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f1903f909
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
claude-review reviewed Code review (incremental, 3f1903f → 47b64d9): no blocking findingsI read every hunk of both files in the incremental scope: What changed
Prior findings
Notes (non-blocking, not counted)
No plugin manifest changed in this push. No embedded instructions were found in the PR context, settled-threads or prior-findings files. Spend: the two new suite cases add about 1 to 3 s to the Windows |
|
claude-security-review reviewed Security review: PR #13441, incremental since
|
…ves off the shell Review findings on #13441: - An expired rdt_bounded_to now stops the command, then kills it and every process under it (rdt_kill_tree, from /proc/<pid>/stat parent ids). A child started without exec had kept the substitution open: a 1 s bound over `bash -c 'sleep 3'` returned after 3 s. - rdt_phys_to and rdt_win_to check that a path's drive is a local fixed one before any disk access: from its /x/ or X:/ spelling, or from the longest /proc/mounts mount point holding it. A network drive goes to the bounded process without being touched in the guard's own shell. - The resolve suite pins the link declines only where `ln -s` made a link (the Windows runner's Git Bash makes a copy), adds a declined path on an unmapped drive, and adds a wrapper whose child is not exec'd. Refs: #13276 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes #13276
Summary
On Windows, a judged delete in
block-root-delete-target(rm -rf,mv,find | xargs rm,eval/watch/wsl/cmd /c, a shell fed byechoor a heredoc) started 8 processes. This cuts it to 1 and leaves every verdict the guard returns unchanged. The measured saving is 126 to 152 ms per call.Fix
timeout.rdt_bounded_to(newblock-root-delete-target-resolve.sh) puts the bound inside the command substitution. The command holds a spare descriptor on a process substitution, which reaches end of file only when the command exits.read -twaits on it, and on expiry the command is killed and reaped. The guard refuses astoo-slow, as before. This removes the 3timeoutprocesses and the no-timeoutbranch (owner answer Q6 in the interview).rdt_phys_tostands in forrealpath -m: a lexical collapse, valid only when no part of the path is a symlink or junction.rdt_win_tostands in forcygpath -l -m: onecd -Pinto the nearest existing ancestor.~(8.3 name), a non-ASCII byte, a component ending in.or a space, a UNC path, a drive/proc/mountsdoes not list as local NTFS or ReFS, and a..below a missing part.rdt_win_toalso declines any path holding a link, becausecygpathdoes not follow a link in the middle of a path (measured).cd -Pper path instead of per component, plus the extra fallbacks.--no-drive. The drive spellings only named candidates the guard already resolves; on Git Bash the 3 candidates resolve to one set.test-windows-guardsinpr-test-platforms.yml, with the pinnedshfmtinstall it needs.Test changes the PR reviewer should know about:
timeout-stub cases inblock-root-delete-target.test.shnow use slowrealpathandgitstand-ins started withSECONDS=44in the guard's environment. Bash importsSECONDS, so the hook starts 44 s into its 50 s bound and the case refuses in about 6 s, with no test switch in the guard.timeoutbranch, which Q6 removed: "with no timeout an ordinary delete in the tree is allowed", "with no timeout an escape from the tree still blocks", and "with no timeout the deadline is checked after the batch call". The first two verdicts are still covered by ordinary in-tree and escape cases in the same suite.realpathcase and the judgment-error case now name a path with a~(./x~1/build,build~1). Otherwise Git Bash resolves the path in the shell and the batch they test never runs. The expected verdicts are unchanged.Verification
rm -rf ./buildfrom a repository logsgitalone. Main logged 8: twocygpath, thengit,realpathandcygpath, each undertimeout.3bb182755) and the branch staged side by side, each payload timed in onehyperfine -Nsession, 5 alternating blocks of 40 runs per arm. Every judged payload was lower in all 5 blocks, by 126.4 to 152.4 ms;rm -rf ./buildwent from 369.9 to 221.1 ms. The common call moved +0.6 ms (branch lower in 2 of 5 blocks). The figures are in the README's Hook budget accounting entry. All 20 verdicts matched (exit 0 on both arms for every payload).block-root-delete-target.test.shPASS=1568 FAIL=0 and-ePASS=789 FAIL=0.-b,-cand-dfail 87, 8 and 16 cases; main at3bb182755fails the same sets on this host. Those are the fake-HOMEfixtures, where themiseshim forshfmtcannot read its config.run-guards.test.shPASS=729.block-root-delete-target-resolve.test.shPASS=28 SKIP=1 (the differential needs Git Bash).block-root-delete-target.test.shPASS=1582 FAIL=0;-b,-cand-d0 failures.-efails the same 2 message-text cases main fails on Windows ("attended: the reason names the outside-tree delete", "unwatched: the reason names the target").block-root-delete-target-resolve.test.shPASS=115 FAIL=0. That includes the comparison againstrealpath/cygpathover symlink, junction, 8.3,--named, trailing-dot, non-ASCII, mixed-case, drive-spelled,/tmpand UNC paths, and the temp-root set check.read -d ''form cost about 46 µs per byte on Git Bash (3 s against 0.6 s at 512 paths), so the bound moved inside$(...). That form is level with a bare$(realpath …)and never slower than$(timeout …).scripts/plan-test-lanes.test.shPASS=58,check-silent-skips.shandcheck-discriminating-test-skips.shexit 0,check-shell-portability.sh0 hits, shellcheck and shfmt clean on the new files, markdownlint clean on the README.Related
🤖 Generated with Claude Code