Skip to content

perf(guardrails): block-no-verify.sh averages 76.1s and timed out 44x - reduce process spawns #3518

Description

@kyle-sexton

Summary

Child of #3508 (Windows process-creation tax). This issue covers one hook: block-no-verify.sh in the guardrails plugin.

Measured

Plugin guardrails
Hook block-no-verify.sh
Event(s) PreToolUse:Bash + PreToolUse:PowerShell
Timeouts in window 44
Average duration 76.1s
Worst observed 134.1s
Configured timeout 15 s

Every recorded run exceeded the 15 s timeout, so this guard is killed before it renders a verdict. It currently costs wall-clock without providing protection on this platform.

Context from the parent

Process creation on the affected host costs 0.3-0.9 s per spawn (bash -c true = 661 ms, jq -n 1 = 908 ms, cmd.exe /c exit = 872 ms, against ~3-5 ms on a healthy host). User CPU time is ~1% of wall-clock, so the fix is reducing the number of process spawns, not optimizing script logic. See #3508 for the full measurement and environment detail.

Specific guidance

30 external call sites. Detection is a simple substring match on the command; should be achievable with bash builtins and zero subprocesses.

Acceptance criteria

  • This hook makes no more than 2 external process spawns on its common path (its own shell plus at most one jq).
  • Subprocess calls to grep/sed/cut/tr/basename/dirname on the hot path are replaced with bash builtins.
  • Where the guard only applies to a subset of commands, the matcher or an early guard clause exits before any spawn for non-matching invocations.
  • Existing behavioural tests still pass; the guard still blocks what it blocked before.
  • Measured on a Windows host, a single run of this hook completes in under 2 s.

Method

Counts from ~/.claude/projects/**/*.jsonl hook_cancelled attachments with timedOut: true, across 236 sessions, 2026-08-23 to 2026-08-31.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.priority: highSignificant impact, or blocks an imminent release; staff this cycle.work-class: scopedA briefed fix or small feature; blast radius bounded by the brief, tests exist.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions