Skip to content

perf(source-control): narrow hook filters and move PR waits off the foreground - #6653

Merged
kyle-sexton merged 7 commits into
mainfrom
perf/source-control-narrow-hooks-bg-waits
Oct 9, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
perf/source-control-narrow-hooks-bg-waits

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: performance change set approved in the fleet perf audit (items B5, W1, E1s source-control part, B15).

Summary

Four source-control changes that cut hook spawns and foreground waits:

  • B5: pr-body-linkage-gate now runs from three if entries, Bash(*pr create*), Bash(*pr new*) and Bash(*pr edit*), replacing Bash(*gh *). Both worktree gates now use Bash(*worktree add*) instead of Bash(*worktree*). In the audit, the old filters matched 62-70% of Bash calls.
  • W1: /source-control:worktree create says that with no user present it skips EnterWorktree outside .claude/worktrees/ and works by explicit path with git -C <literal path>. That call raises an approval ask, and headless runs deny it.
  • B15: /source-control:pull-request create writes the PR body with the Write tool. The §2.4.2 gates read that file, and gh pr create gets --body-file (the REST fallback sends -F body=@<file>). Inline --body calls had been rejected by the command length cap.
  • E1s (source-control part): the monitor.md §3.0.0 cloud "blocking loop" and the §3.1 per-push poll ("every 30s, max 15 minutes per cycle") now wait through the Monitor watch or a run_in_background poll, never a foreground sleep/until loop. The babysit loop already used Monitor, so it is unchanged.

Fix

  • Where the plan corrects the approved text. The brief's B5 text says "separate gh pr create and edit handlers". The gate parses gh <global flags> pr create|new|edit (pr-body-linkage-gate.sh:580-596), so a *gh pr create* filter would miss gh -R o/r pr create and the gh pr new alias. As the work plan says, this PR uses three entries: *pr create*, *pr new* and *pr edit*.
  • create.md. The $BODY shell-variable assembly (content_for_section, the TEMPLATE concat and the quoted-heredoc rationale) is replaced by one Write-tool step. The attribution footer is still appended only after the gates pass, now by printf '\n\n%s\n' "$ATTRIBUTION" >>"$BODY_FILE", so pull-request evals 9 and 11 (parameter-expansion splice; skipped when none) still describe the behavior.
  • One file outside the listed scope fence: skills/pull-request/scripts/check-body-sections.test.sh. It evals create.md's §2.4.2.2 block verbatim with a BODY variable, so its harness now writes each fixture body to a temp file and sets BODY_FILE. The 14 cases and their expected verdicts are unchanged. Before this harness edit the suite failed 7 of 14 against the new block; after it, 14 of 14 pass.
  • Changelog: one fragment, .changes/source-control/perf-source-control-narrow-hooks-bg-waits-4b2a3171.md, with bump: patch.

Verification

Run locally on this branch (base origin/main 51a781b):

  • scripts/affected-tests.sh --run --jobs 8: all 12 shell suites passed (2 optional Windows/version SKIPs). The 2 Python suites passed separately: test_guards.py and test_check_contract_clause_coverage.py, 48 passed.
  • Run directly: pr-body-linkage-gate.test.sh 178/0, pr-linkage-spawn-budget.test.sh 23/0, worktree-add-containment-gate.test.sh pass, pr-linkage-mcp-gate.test.sh 57/0. worktree-gates-spawn-budget.test.sh and worktree-add-claim-gate.test.sh ran through affected-tests.
  • scripts/check-changed-skills.sh origin/main: 2 skills checked, 0 failed (warnings only, pre-existing size).
  • scripts/check-purged-em-dashes.sh: no em dashes.
  • scripts/check-changelog-fragments.sh --check and --check-required origin/main: pass.
  • scripts/validate-plugins.sh, check-hooks-description.sh, check-hook-slow-shapes.sh, check-hook-wiring-liveness.sh: pass.
  • markdownlint-cli2 with .markdownlint-cli2.jsonc on the 5 changed Markdown files: 0 errors. typos on all changed files: clean. ShellCheck on the changed test: clean.
  • jq on hooks.json shows the five if values above.

Related

  • Merge gate: CODEOWNERS covers plugins/source-control/**, so this needs a code-owner review or the owner's own merge.
  • Follow-up, not done here because it is outside this PR's scope fence: plugins/source-control/README.md:184-185 and :281 still describe the Bash(*gh *) and Bash(*worktree*) filters as supersets of each gate's first check.
  • SC-B (C11, arm auto-merge after AI review) also edits monitor.md and lands after this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VxGrZW26Qs1qeo3RFgmbvp

kyle-sexton and others added 2 commits October 9, 2026 01:27
…oreground

- pr-body-linkage-gate runs from Bash(*pr create*), Bash(*pr new*) and
  Bash(*pr edit*) instead of Bash(*gh *); both worktree gates run under
  Bash(*worktree add*) instead of Bash(*worktree*).
- worktree create: with no user present, skip EnterWorktree outside
  .claude/worktrees/ and work by explicit path with git -C.
- pull-request create writes the body with the Write tool, gates read the
  file, and gh gets --body-file (REST: -F body=@file).
- pull-request monitor: the cloud baseline poll and per-push CI wait run
  through Monitor or run_in_background, never a foreground loop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxGrZW26Qs1qeo3RFgmbvp
The README still named the old Bash(*gh *) and Bash(*worktree*) filters.
It now describes the pr-body gate's three entries (pr create, pr new,
pr edit) and the worktree gates' Bash(*worktree add*) filter.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxGrZW26Qs1qeo3RFgmbvp
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 9, 2026 12:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T12:49:43.441452Z 0a348e9 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Code review in progress

  • Gather context (PR body, diff, CLAUDE.md/AGENTS.md, REVIEW.md)
  • Run skip-gate check
  • Review changed files for correctness/maintainability
  • Adversarially verify candidate findings
  • Post inline comments and final summary

View job run

@claude

claude Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 5m 5s —— View job


Security review in progress

Running /review:security-review against PR #6653 (head 0a348e9).

  • Create todo list
  • Gather context (diff, changed files, instruction-exception register)
  • Apply skip gate — diff has security-relevant surface (hook if-filter narrowing on PreToolUse/PostToolUse gates, and a headless EnterWorktree approval-skip), so proceeding
  • Review hook filter narrowing (B5) for bypass risk — candidate found, verifying adversarially
  • Review worktree EnterWorktree bypass path (W1) — matches pre-existing accepted pattern for autonomous orchestration, likely not a new finding
  • Review PR body Write-tool / --body-file change (B15) — no issue found
  • Review monitor.md background-wait change (E1s) — doc-only, no security surface
  • Adversarially verify candidate finding (hook if-filter whitespace bypass)
  • Post final review

@claude

claude Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 7m 57s —— View job


Code review complete

  • Gather context (PR body, diff, CLAUDE.md/AGENTS.md, REVIEW.md)
  • Run skip-gate check
  • Review changed files for correctness/maintainability
  • Adversarially verify candidate findings
  • Post inline comments and final summary

Skip gate: none applied — PR is open, not a draft, and the diff has real review surface.

Scope: plugins/source-control/{README.md, hooks/hooks.json, SKILL.md, skills/pull-request/**, skills/worktree/SKILL.md} and the changelog fragment, diffed against origin/main. Security findings are out of scope for this lane (pr-review-security-hosted.yml runs here), so none are reported.

Findings

🔴 Important — two eval fixtures describe a mechanism this PR removed, and the PR's own claim that they "still describe the behavior" is incorrect.

plugins/source-control/skills/pull-request/evals/evals.json#L121 (eval 9, pr-body-attribution-default-present) still says: "The line is spliced as literal text via parameter-expansion concat, not embedded in the quoted heredoc."
...evals.json#L133 (eval 11, pr-body-attribution-opt-out-suppressed) still says: "...the ATTRIBUTION value resolves to empty and the trailing concat is skipped."

Both phrases ("parameter-expansion concat", "the quoted heredoc", "the trailing concat") name the old §2.4.1/§2.4.3 implementation that this PR deletes (see create.md — no heredoc exists anymore, and the attribution line is now appended with printf '\n\n%s\n' "$ATTRIBUTION" >>"$BODY_FILE", line 393). The PR description's Fix section explicitly asserts "pull-request evals 9 and 11 (parameter-expansion splice; skipped when none) still describe the behavior" — that claim is what's wrong here: the testable expectations arrays still hold, but the expected_output narrative text actively misdescribes the current implementation to anyone reading the eval (or an agent grading against it) after this change. Since evals.json wasn't touched in this diff, no changed line can carry this comment, hence reporting it here per the task's anchoring rule.

Fix: reword both expected_output strings to reference the file-append mechanism (e.g. "spliced into $BODY_FILE as a literal printf append after the gates pass, never re-evaluated") instead of the removed heredoc/concat language.

🟡 Suggestion (posted inline on hooks/hooks.json:28): the new if filters (*pr create*, *pr new*, *pr edit*, *worktree add*) are literal-space substrings, so unusual spacing (double space, tab, line continuation) between the two words would silently skip spawning the gate hook, where the old broader filters didn't depend on that specific spacing. Low likelihood/impact (CI's own pr-contract check is an independent backstop), so not a blocker — just worth a one-line addition to the README's existing "what the filter cannot see" caveat.

Everything else checked out

  • hooks.json's three pr-body-linkage-gate entries and the two worktree add filters match what pr-body-linkage-gate.sh (lines 580-596) and the worktree gates actually parse — verified by reading the scripts' own tokenizer logic, not just trusting the README prose.
  • create.md's switch from a shell-variable $BODY (heredoc + content_for_section + parameter-expansion concat) to a Write-tool $BODY_FILE is internally consistent: grepped the whole file for stray $BODY / TEMPLATE references and found none left over; the gate-ordering invariant (attribution appended only after both §2.4.2 gates pass) is preserved; -F body=@"$BODY_FILE" and --body-file are correct gh usage; this is also a net injection-safety improvement since the Write tool's JSON string is never shell-parsed.
  • check-body-sections.test.sh's harness rewrite (writing each fixture body to a temp file and setting BODY_FILE) correctly threads through eval "$GATE", and the verdict assignment happens outside the subshell so it isn't lost — no bug there.
  • monitor.md/SKILL.md background-wait wording changes are consistent with each other and with the "Waiting on a pending check" cadence table.
  • Changelog fragment accurately summarizes all four changes with correct bump: patch.

Not independently verified (no shell execution available in this environment): the PR's claimed local test runs (affected-tests.sh, the four gate *.test.sh files, markdownlint/typos/shellcheck). Those are author-claimed, not confirmed by this review.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a348e97aa

ℹ️ 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".

Comment thread plugins/source-control/hooks/hooks.json Resolved
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review has reviewed this pull request through fa4b02d; a later push is reviewed from there.

Comment thread plugins/source-control/hooks/hooks.json Resolved
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

claude-review has reviewed this pull request through fa4b02d; a later push is reviewed from there.

kyle-sexton and others added 3 commits October 9, 2026 08:56
check-test-tmp-cleanup fails a suite that calls mktemp without an EXIT
trap. Create the body file once and remove it on exit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxGrZW26Qs1qeo3RFgmbvp
A literal `pr create` or `worktree add` in an `if` filter skipped the gate
for `gh pr  create` or a tab between the words, which the gates' own
tokenizers accept. Use `*pr*create*`, `*pr*new*`, `*pr*edit*` and
`*worktree*add*`, which still skip `gh pr view` and `git worktree list`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxGrZW26Qs1qeo3RFgmbvp
…te.md

context/create.md step 3 still made EnterWorktree unconditional; it now
points at the no-user exception. The SKILL.md bullet records a docs
pointer, as-of date and recheck trigger and drops the timing figure.
Pull-request evals 9 and 11 describe the post-gate append to the body
file instead of the removed parameter-expansion concat.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxGrZW26Qs1qeo3RFgmbvp
@claude

claude Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 6m 48s —— View job


Code review complete

  • Gather context (PR body, incremental diff since ca459ea, CLAUDE.md/AGENTS.md, REVIEW.md)
  • Run skip-gate check
  • Review changed files for correctness/maintainability
  • Adversarially verify candidate findings
  • Post inline comments and final summary

Skip gate: none applied — PR is open, not a draft, and the incremental diff has real review surface.

Scope: incremental review since ca459ea, limited to .changes/source-control/perf-source-control-narrow-hooks-bg-waits-4b2a3171.md, plugins/source-control/README.md, plugins/source-control/hooks/hooks.json, plugins/source-control/skills/pull-request/evals/evals.json, plugins/source-control/skills/pull-request/scripts/check-body-sections.test.sh, plugins/source-control/skills/worktree/SKILL.md, and plugins/source-control/skills/worktree/context/create.md. Security findings are out of scope for this lane; none reported.

This increment is mostly a clean response to the two outstanding review threads: it rewords the pull-request evals.json cases 9/11 off the removed heredoc/concat language, hardens check-body-sections.test.sh's temp-file lifecycle, adds a pointer/as-of/recheck-trigger to the EnterWorktree headless-skip claim in worktree/SKILL.md (replacing the undated p50 of 209s figure), and propagates that headless-skip exception into worktree/context/create.md's step 3. One new issue, and one previously-flagged issue left half-fixed:

Findings

🔴 Important (posted inline on plugins/source-control/hooks/hooks.json:28): the *pr*create*/*pr*new*/*pr*edit*/*worktree*add* filters (replacing the prior literal-space form to tolerate double-spaces/tabs) use a bare * between the words. Per Claude Code's own hooks docs, * has no word-boundary restriction, so e.g. cp report.txt prod_create_backup/ now matches Bash(*pr*create*) and git commit -m "update worktree docs, then add tests" matches Bash(*worktree*add*) — neither is a gh pr or git worktree add call. That reopens the broad-spawn problem B5 set out to fix. See the inline comment for the full argument and a suggested revert.

🔴 Important — the Codex review comment on this PR ("Propagate the headless exception through the create contract") is only half-addressed. This increment correctly updates the spoke (context/create.md:123 now defers to SKILL.md's headless-skip rule), but the outcome eval that comment also named was not touched: plugins/source-control/skills/worktree/evals/evals.json#L8-L14, eval 1 (create-routing-enterworktree-last), still unconditionally requires EnterWorktree(path: ...) to be "called as the final action of the invocation — no steps are scheduled to run after it," with no headless/background/auto-mode exception. Since this file is untouched by the PR, no changed line can carry this comment. The PR already fixed the structurally identical problem for the pull-request skill's evals.json (cases 9/11, in scope of this increment) in response to the equivalent earlier finding; the same fix is still owed to the worktree skill's eval 1, or an agent graded against it in headless mode will be marked wrong for doing exactly what the new SKILL.md/create.md text now tells it to do.

Fix this →

Everything else checked out

  • evals.json cases 9/11 (pull-request skill) now describe the printf … >>"$BODY_FILE" append mechanism instead of the removed heredoc/parameter-expansion concat — matches create.md's current implementation.
  • check-body-sections.test.sh's body_file/trap hoisted to script scope: still single-threaded/sequential calls, no reuse hazard, rm -f on EXIT covers early exits too.
  • worktree/SKILL.md's rewritten EnterWorktree bullet carries a real pointer, as-of date, and recheck trigger per the skill-bodies-state-current-rules convention; spot-checked the linked docs section and it does describe the approval-prompt mechanism and what suppresses it, consistent with the claim.
  • worktree/context/create.md:123 and worktree/SKILL.md's #action-create-name anchor are consistent with each other (anchor matches the actual heading).
  • Changelog fragment's wording matches the actual code change (*pr*create* etc., not the stale *pr create* text from the prior revision).

Not independently verified (no shell execution available in this environment beyond static reads): the PR's claimed local test runs. Those remain author-claimed and unconfirmed by this review.

@claude

claude Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 44s —— View job


Security review complete

  • Create todo list
  • Gather context (.claude-lane/incremental.diff, custom instructions, prior review history)
  • Apply skip gate
  • Review the if-filter widening in hooks.json (whitespace-tolerance fix) for new bypass risk
  • Check instruction-surface deletions/softenings against the exception register
  • Review remaining incremental changes (evals.json text, test harness, docs)
  • Adversarially verify any candidate finding
  • Post final review

Skip gate: not applied — the diff touches hooks.json's if filters and a worktree-approval exception, both security-relevant surfaces, so I reviewed in full.

Scope (incremental, as instructed): only the files that changed since ca459ea59ab14b5f63e3c4a34bd11cfd66d9ab1e, read from .claude-lane/incremental.diff:
.changes/.../*.md, README.md, hooks/hooks.json, evals/evals.json, check-body-sections.test.sh, worktree/SKILL.md, worktree/context/create.md. No other file in this PR changed since that SHA.

No security issues found in this slice

  • hooks.json if filters (Bash(*pr create*) → Bash(*pr*create*), same for *pr new*/*pr edit*, and Bash(*worktree add*) → Bash(*worktree*add*)): this is a strict widening. Every command string matching the old literal-space pattern still matches the new wildcard-separated one (A + "pr create" + B always satisfies A + "pr" + "" + B1 + "create" + B2), so nothing that used to reach pr-body-linkage-gate.sh / the worktree-add gates stops reaching them. It closes the exact gap flagged in the prior review round (double-space/tab between the two words skipping the hook), without opening a new one — over-matching here (e.g. an unrelated command that happens to contain both substrings in order) only costs an extra no-op hook spawn, it doesn't weaken the gates' own tokenizer logic in pr-body-linkage-gate.sh:580-596, which was reviewed at the prior SHA and is unchanged here.
  • Instruction-surface lens (register read at docs/conventions/instruction-exception-register/README.md, present in this checkout): the one instruction change in this slice — worktree/context/create.md's step 3 gaining "with no user present ... skip this call: report <printed-path> and work by explicit path" — looks at first glance like narrowing an approval requirement (EnterWorktree's out-of-sandbox approval ask), a candidate for the agent-authority class. It doesn't qualify as a new weakening: the exception itself was already present in SKILL.md as of the prior-reviewed SHA (this diff only propagates it into the create.md spoke, which is exactly the consistency gap Codex's W1 comment asked for), the same mechanism was already documented for the non-interactive orchestration path in the unchanged "Orchestrated (autonomous) provisioning" section of SKILL.md, and skipping EnterWorktree doesn't remove any containment check — worktree-add-containment-gate/worktree-add-claim-gate (strengthened, not weakened, by this very PR) independently gate the worktree's location regardless of whether the session ever enters it.
  • check-body-sections.test.sh: hoisting body_file=$(mktemp) + trap 'rm -f "$body_file"' EXIT out of the per-call function is test-harness-only, still uses mktemp (no predictable path/symlink risk), and each case truncates-and-rewrites the same file before use, so no stale-fixture leakage between cases.
  • evals.json, README.md, changelog fragment, worktree/SKILL.md's dated pointer: prose-only; no behavior or control change.

No CRITICAL/IMPORTANT/SUGGESTION findings to report for this incremental slice.

Comment thread plugins/source-control/hooks/hooks.json Resolved
…st word

A bare `*` between the words let `*pr*create*` match `pr` and `create`
inside unrelated words, such as `cp report.txt prod_create/`, since the
`if` glob has no word boundaries. `*pr *create*` and `*worktree *add*`
still accept extra spaces between the words; a tab or line continuation
right after the first word skips the hook, as the README now says.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxGrZW26Qs1qeo3RFgmbvp
@claude

claude Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 3m 15s —— View job


Code review complete

  • Gather context (PR body, incremental diff since 1a13e548a, CLAUDE.md/AGENTS.md, REVIEW.md)
  • Run skip-gate check
  • Review changed files for correctness/maintainability
  • Adversarially verify candidate findings
  • Post inline comments and final summary

Skip gate: none applied — PR is open, not a draft, and the incremental diff has real review surface.

Scope: incremental review since 1a13e548ab7411ea6aceda4ce4544d5951dd2236, limited to the three files this lane was assigned: .changes/source-control/perf-source-control-narrow-hooks-bg-waits-4b2a3171.md, plugins/source-control/README.md, plugins/source-control/hooks/hooks.json, read from .claude-lane/incremental.diff. Security findings are out of scope for this lane; none reported.

This increment responds to the two outstanding hooks.json threads (Codex's whitespace-tolerance finding and this lane's own prior CRITICAL finding about the bare-* wildcard matching substrings inside unrelated words) by changing the five if filters from Bash(*pr*create*) / Bash(*worktree*add*) style to Bash(*pr *create*) / Bash(*worktree *add*): a literal single space is now required immediately after the first word, with the wildcard moved to after it.

No blocking findings

  • hooks.json:28,39,50,61,94 — all five if values match the diff and are internally consistent (*pr *create*, *pr *new*, *pr *edit*, *worktree *add* ×2). Verified the JSON is well-formed and the strings are exactly what the README/changelog describe.
  • Re-verified the prior CRITICAL finding is actually fixed, not just narrowed to look fixed: the adversarial example from that finding, prod_create_backup/, contains pr immediately followed by o (from prod), never by a space, so it no longer matches *pr *create*. Traced the gate's own tokenizer (pr-body-linkage-gate.sh:580-596, word-array split on ${w[i]}/${w[i+1]}/${w[i+2]}, matching gh/pr/create|new|edit by position) against the README's claims: the gate itself is whitespace-insensitive (any run of IFS whitespace between words still parses as separate array elements), so the new filter's "tolerates extra spaces, not a tab or line continuation" claim is accurate — confirmed by reading the tokenizer, not just trusting the prose.
  • Residual over-matching is narrower and benign, not reopened: a token ending in literal pr (or worktree ) followed later by a substring like new/create/edit/add embedded in another word (e.g. a command containing renew or additional) can still over-match and spawn a gate unnecessarily. This is the same class of issue the README already discusses and accepts ("the if glob has no word boundaries"), and its effect is an extra harmless hook spawn, not a validation bypass — the inverse of the original CRITICAL finding's risk profile. Given three rounds of review have already converged on this documented tradeoff, not re-flagging it here.
  • Changelog fragment and README prose both match the actual hooks.json strings and the gate script's real behavior (gh pr new alias still recognized at pr-body-linkage-gate.sh:594); no stale wording left over from the earlier *pr*create* (no-space) revision.

Not independently verified: the PR's claimed local test runs (affected-tests.sh, gate *.test.sh files, markdownlint/typos/shellcheck) — those remain author-claimed and are outside this lane's file scope regardless.

@claude

claude Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 56s —— View job


Security review complete

  • Create todo list
  • Gather context (.claude-lane/incremental.diff, custom instructions, prior review history)
  • Apply skip gate
  • Review incremental changes to .changes/source-control/perf-source-control-narrow-hooks-bg-waits-4b2a3171.md, README.md, hooks/hooks.json
  • Adversarially verify any candidate finding
  • Post final review

Skip gate: not applied — this increment edits the if filters that gate the PR-body-linkage and worktree-add-containment/claim hooks, which is exactly the security-relevant surface from the two prior rounds.

Scope (incremental, as instructed): only the three files named in the task, diffed from 1a13e548ab7411ea6aceda4ce4544d5951dd2236 to fa4b02d: the changelog fragment, plugins/source-control/README.md, and plugins/source-control/hooks/hooks.json.

No security issues found in this slice

This commit is the fix for the prior round's 🔴 Important finding (bare * between pr/create/new/edit and worktree/add matching free substrings inside unrelated words). It changes the separator from a bare * to " *" (a literal space, then wildcard):

I re-ran the exact adversarial example from the prior finding against the new pattern: cp report.txt prod_create_backup/. Requiring a literal space right after pr means the match needs the substring "pr " (p-r-space); report.txt has no adjacent p,r at all, and prod_create has pr followed by o, not a space, so this string no longer matches Bash(*pr *create*). The fix is effective for that case, and I didn't find a real gh pr create/pr new/pr edit spelling (wrapped, double-spaced, -R o/r, etc.) that the new pattern fails to catch — under-matching (an actual gh pr create-type call silently skipping its gate) is the property that matters for security here, since over-matching only costs an extra no-op hook spawn and doesn't touch the gate scripts' own tokenizer/containment logic (unchanged in this diff).

One residual gap, already disclosed rather than hidden: the new README text itself states that a tab or line continuation landing immediately after pr/worktree (no space) still skips the hook, trading the already-known tab/whitespace gap (previously raised as a non-blocking 🟡 Suggestion, not a blocker) for closing the substring-over-match problem. That's a conscious, documented, low-likelihood trade-off consistent with the earlier review's own conclusion that no single glob pattern can satisfy both constraints at once — not a new or silent regression.

I also checked whether the same fix closes the match as tightly for worktree/add as it does for pr/create: it doesn't (git commit -m "update worktree docs, then add tests" still matches Bash(*worktree *add*), since worktree is a whole word almost always followed by a space in ordinary text, unlike pr which is often embedded mid-word). That's a real residual over-match, but it's a spawn-frequency/performance question — already the code-review lane's domain, not a security weakening, since it only makes the containment/claim gates fire more often than necessary, never less.

  • README.md's two updated paragraphs and the changelog fragment's wording both match the actual hooks.json patterns and the behavior I verified above; no documentation/implementation drift.

Not independently verified (no shell execution available in this environment beyond static reads): the PR's claimed local test runs.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit 9f35446 Oct 9, 2026
23 checks passed
@kyle-sexton
kyle-sexton deleted the perf/source-control-narrow-hooks-bg-waits branch October 9, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant