Summary
Child of #3508. guardrails/hooks/block-dangerous-git.sh has the highest external-command call-site count of any hook in the marketplace (127) and timed out 59 times in the measured window.
This was initially left unfiled on the assumption a parallel session had claimed it. That session has confirmed it has not claimed this file and is not working it — its scope is two files in disk-hygiene. So this is unowned and is the largest single reduction opportunity in guardrails.
Measured
|
|
| Plugin |
guardrails |
| Hook |
hooks/block-dangerous-git.sh |
| Event(s) |
PreToolUse:Bash + PreToolUse:PowerShell |
| Timeouts in window |
59 |
| External-command call sites |
127 — highest in the set |
| Configured timeout |
15 s |
Durations are deliberately omitted as a ranking signal: spawn cost on the affected host is bimodal with a 15.7x spread (see #3508), so cross-hook duration comparisons are unreliable. The call-site count is the durable number.
Why this one matters most
At a measured 0.3-0.9 s per process spawn, every call site that executes is most of a second. 127 call sites is an upper bound (many sit in branches), but even a modest executed fraction dominates the hook's wall-clock. A completed fix on a comparable launcher went from 4 spawns to 1 and improved median wall-clock 3.71x.
Proposed work
- Count spawns first, before changing anything. Use a PATH shim directory of wrapper scripts that log their own name then exec the real tool; diff the count before and after. Deterministic, so it survives the host's drift, and cheap for a reviewer to verify.
- Collapse multi-
jq call sites into a single jq program per invocation.
- Replace
grep/sed/cut/tr/basename/dirname on the hot path with bash builtins.
- Watch for
x="$(f)" — command substitution forks a subshell, which on MSYS is a real process spawn. A builtins-only helper that reports on stdout still costs a full process; hot-path helpers must assign to a global.
- Early-exit before any spawn when the invocation is not a
git command at all — this guard fires on every Bash and PowerShell call but only acts on dangerous git forms.
Acceptance criteria
Summary
Child of #3508.
guardrails/hooks/block-dangerous-git.shhas the highest external-command call-site count of any hook in the marketplace (127) and timed out 59 times in the measured window.This was initially left unfiled on the assumption a parallel session had claimed it. That session has confirmed it has not claimed this file and is not working it — its scope is two files in
disk-hygiene. So this is unowned and is the largest single reduction opportunity inguardrails.Measured
guardrailshooks/block-dangerous-git.shPreToolUse:Bash+PreToolUse:PowerShellDurations are deliberately omitted as a ranking signal: spawn cost on the affected host is bimodal with a 15.7x spread (see #3508), so cross-hook duration comparisons are unreliable. The call-site count is the durable number.
Why this one matters most
At a measured 0.3-0.9 s per process spawn, every call site that executes is most of a second. 127 call sites is an upper bound (many sit in branches), but even a modest executed fraction dominates the hook's wall-clock. A completed fix on a comparable launcher went from 4 spawns to 1 and improved median wall-clock 3.71x.
Proposed work
jqcall sites into a singlejqprogram per invocation.grep/sed/cut/tr/basename/dirnameon the hot path with bash builtins.x="$(f)"— command substitution forks a subshell, which on MSYS is a real process spawn. A builtins-only helper that reports on stdout still costs a full process; hot-path helpers must assign to a global.gitcommand at all — this guard fires on every Bash and PowerShell call but only acts on dangerous git forms.Acceptance criteria
gitcommand exits before any spawn.