Skip to content

docs(hooks): add the hook-performance-levers program plan - #3625

Closed
kyle-sexton wants to merge 2 commits into
mainfrom
perf/hook-performance-program
Closed

kyle-sexton wants to merge 2 commits into
mainfrom
perf/hook-performance-program

Conversation

@kyle-sexton

Copy link
Copy Markdown
Contributor

No related issue: this PR lands the program plan only; tracking issue #3623 stays open until phase 8 closes it.

Summary

Adds docs/topics/hook-performance-levers/PLAN.md and its design resolution. The plan covers phases 0 to 8 of the program that measures and cuts every hook and runtime-cost surface this marketplace ships on the Windows Git Bash host: the extended dotfiles harness, baseline capture, if gates and matcher scoping, async on non-deciding hooks, the guardrails dispatcher hot path, per-Write formatter hot path, Windows path-form fixes, the skill listing budget, statusline cost, and the final accounting.

Fix

Docs only. Two new files under docs/topics/hook-performance-levers/. No code, hooks, or plugin versions change.

Verification

  • scripts/affected-tests.sh --run on the branch (PLAN.md maps to the planning open-questions suite; the design file is on the no-suite allowlist).
  • The hardcoded-path guard run directly against the PLAN.md content exits 0.
  • No em dashes remain in either file.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_011boRpMmkKhritwmR4ZPMvP

…resolution

Plan for measuring and cutting every runtime-cost surface the marketplace
ships on the Windows Git Bash host: phases 0 to 8, scope fences, open
questions with their arbiters, and the per-phase design gate verdicts.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011boRpMmkKhritwmR4ZPMvP
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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-09-02T06:02:40.526680Z 6586e84 PR opened
ℹ️ 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 Sep 2, 2026

Copy link
Copy Markdown
Contributor

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


Claude finished the code review

  • Gather context (PR diff, changed files, CLAUDE.md/AGENTS.md conventions)
  • Understand the request (invoke /review:code-review CI lane)
  • Review docs/topics/hook-performance-levers/PLAN.md
  • Review docs/topics/hook-performance-levers/design/design-resolution.md
  • Post findings (inline + summary)

This is a docs-only PR (2 new files, 1010 lines) adding a program plan and its design-resolution gate for a hook-performance effort. No code, hooks, or plugin versions change, so the review focused on the plan's internal accuracy and consistency — the closest analogue to "correctness" for a document that many later PRs will be executed against.

Posted 3 inline comments:

  1. Central premise contradicted by the repo (PLAN.md:4): the plan states the guardrails dispatcher "already shipped" via PR perf(hooks): dispatch the guardrails guards through one process and if-gate the path-specific hooks #3621, and Phase 4a builds directly on that (editing plugins/guardrails/hooks/run-guards.sh, profiling with RUN_GUARDS_PROFILE=1, a Baseline values table citing "guardrails README 0.31.0"). I checked the actual tree: run-guards.sh doesn't exist anywhere in the repo, guardrails/hooks/hooks.json still declares 8 separate PreToolUse Bash guard commands, the plugin is at 0.30.0 (not 0.31.0), and neither the guardrails README nor CHANGELOG mentions a dispatcher. The same claim is restated in design/design-resolution.md lines 29-30.
  2. Inconsistent PR/phase count (PLAN.md:12): the TLDR and open question 1 both say "eight PRs," open question 10 says "nine PRs," and the [EXEC-SHAPE] table calls Phase 4c "a tenth PR" — three different totals for the same phase list, and a tracking-issue checklist and a turn budget would be built off different numbers.
  3. Constraint 9 vs. its own body (PLAN.md:72): constraint 9 says the PLAN uses ~/ and <placeholder> forms to avoid hardcoded paths, but the document hardcodes one operator's D:/worktrees/... layout 7 times. Doesn't trip the automated guard (it only matches Windows user-home paths, not arbitrary drive-root paths), but contradicts the constraint's stated intent — lower severity, flagged for awareness.

Everything else checked out against the repo: the file counts, line numbers (e.g. block-convention-violation.sh lines 99-100), the 17 hook-utils.sh carriers and their 2,139-line count, lib/resolve-convention-pattern.sh's existence, and the em-dash-free claim all matched. No security, test-coverage, or maintainability issues beyond the above — this is a planning document, so there's no code to test.
· branch

…tions log

The extended harness keeps max_ms absolute and appends cpu_x_s and max_x_s
(spawn-equivalents) instead of a byte-identical max_abs_ms twin.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011boRpMmkKhritwmR4ZPMvP
# hook-performance-levers

Draft for orchestrator review. Every phase is `[TODO]`. Branch: `perf/hook-fanout-consolidation`
(four commits ahead of `main` with the guardrails dispatcher, PR #3621, already shipped).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The plan's central premise ("guardrails dispatcher already shipped") does not match this repo's state.

This line, and Phase 4a/4b throughout, treat plugins/guardrails/hooks/run-guards.sh as an existing consolidated dispatcher that PR #3621 already shipped, replacing 8 per-Bash-call guard processes with 1. Checking the actual tree on this branch (and origin/main, one commit behind it):

  • run-guards.sh / run-guards.test.sh do not exist anywhere in the repository (grep -r run-guards . outside these two new docs returns nothing).
  • plugins/guardrails/hooks/hooks.json still declares 8 separate PreToolUse Bash guard commands individually (no dispatcher entry).
  • plugins/guardrails/.claude-plugin/plugin.json is at 0.30.0, not the 0.31.0 this PLAN cites twice (Baseline values table, lines 631-632) as the source of the "8 processes → 1 process" accounting.
  • Neither plugins/guardrails/README.md nor CHANGELOG.md mentions a dispatcher.

Phase 4a's file list, ALLOWED-files table, and Sanity Check (bash plugins/guardrails/hooks/run-guards.test.sh at PLAN.md:394) all assume this file exists today. The same false premise is restated in design/design-resolution.md lines 29-30 ("The dispatcher (plugins/guardrails/hooks/run-guards.sh) sources it once per event..."). If PR #3621 is still pending (its own PR body here calls it a "precursor," not the dispatcher itself), Phase 4a needs to either build the dispatcher itself or the plan needs a corrected baseline and an explicit precondition instead of asserting it's already in place.

Fix this →


Measure and cut every runtime-cost surface this marketplace ships on the binding host (Windows 11,
Git Bash, Claude Code 2.1.258): hook spawn count and critical-path time per event, Windows-only
production no-ops, the skill listing payload, and the statusline. Eight PR-sized phases, each with a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The PR/phase count is inconsistent across the document. This line states "Eight PR-sized phases," and open question 1 (line 816) repeats "a checklist of the eight PRs." But:

  • Open question 10 (line 851) says the goal condition caps the program at "60 turns across nine PRs."
  • The [EXEC-SHAPE] decision table (line 889) explicitly calls Phase 4c "A tenth PR."

Counting the actual phase list (1, 2, 3, 4a, 4b, 4c, 5, 6, 7, 8 — phase 0 is explicitly "Not a PR," and 4b is "promoted to its own topic" but still described here with its own PR-shaped Sanity Check and ALLOWED-files entry), none of "eight," "nine," or "tenth" is self-evidently the intended total. A tracking issue built off "eight PRs" (open question 1) and a turn budget built off "nine PRs" (open question 10) will disagree with each other and with the phase list itself.

Fix this →

9. **Tool-command guards on this host** block `cat >`, `printf >`, `echo >`, `python -c`, and any
literal disk-hygiene engine filename inside a Bash command string. Workers write files with the
Write tool. The hardcoded-path guard also blocks machine-specific paths in written files, so
this PLAN uses `~/` and `<placeholder>` forms.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Constraint 9 states "this PLAN uses ~/ and <placeholder> forms" to stay clear of the hardcoded-path guard, but the PLAN itself hardcodes D:/worktrees/dotfiles-perf-hooks and related D:/worktrees/... paths 7 times elsewhere (e.g. lines 82, 85-86, 122-124, 159-163, 196-197) — a specific operator's personal directory layout, not a placeholder. It won't trip the automated guard (hardcoded-path-check.sh's patterns match Windows user-home paths like C:\Users\<name>\, not arbitrary drive-root paths like D:/worktrees/...), but it does contradict this constraint's own stated intent, and bakes one operator's machine layout into a document other operators will execute against.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Claude has reviewed this PR 2 times. The lane skips further automatic reviews after 5; deleting this comment resets the count.

@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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


Claude finished the /review:code-review pass

  • Gather context (PR diff, changed files, repo conventions)
  • Run /review:code-review procedure (the Skill tool errored in this session, so I read plugins/review/skills/code-review/SKILL.md directly and followed its criteria/gotchas)
  • Read all three changed files in full
  • Post findings (3 inline comments)

Summary

This is a docs-only PR (no code/hooks/plugin changes) adding a large program plan (PLAN.md, 917 lines), its design/design-resolution.md, and a new DEVIATIONS.md log. Since the entire artifact is a planning document meant to be executed nearly mechanically by future phase workers, I focused the review on internal correctness — whether the plan is self-consistent and accurately reflects the state it claims — rather than prose style.

Found 3 internal-consistency issues, all inline:

  1. PLAN.md:3-4 — claims PR perf(hooks): dispatch the guardrails guards through one process and if-gate the path-specific hooks #3621 is "already shipped," but DEVIATIONS.md (added in this PR's own second commit) says it's still open and that phases must branch from perf/hook-fanout-consolidation until it merges. The stale claim wasn't corrected.
  2. PLAN.md:12 — "Eight PR-sized phases" (repeated at line 816) conflicts with Open question 10 at line 851, which says the turn budget spans "nine PRs." The actual phase list counts to nine.
  3. PLAN.md:815 — Open question 1 says "no issue number exists for this program," but the PR description itself cites tracking issue Hook performance program: measure and cut every runtime-cost surface on the Windows host #3623 as already existing.

None of these affect code correctness (there's no code in this PR), but since the plan's stated purpose is to be handed to sub-agent workers as authoritative brief material, factual drift like #1 (which repo/branch state to trust) is the kind of thing a careful reviewer would want resolved before the plan is executed.

Verification notes

  • Independently confirmed (ran directly): no em dashes in any of the three new files (grep -nP '\x{2014}' — no matches).
  • Not independently verified (author-claimed only, no permission to run in this sandbox): the hardcoded-path guard exiting 0 against PLAN.md, and the scripts/affected-tests.sh --run result — the sandbox declined approval to execute scripts/affected-tests.sh.
  • No security-relevant surface in this diff (docs only); no security lane findings to report.

Comment on lines +3 to +4
Draft for orchestrator review. Every phase is `[TODO]`. Branch: `perf/hook-fanout-consolidation`
(four commits ahead of `main` with the guardrails dispatcher, PR #3621, already shipped).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This states PR #3621 (the guardrails dispatcher) is "already shipped," but DEVIATIONS.md — added in this same PR's second commit — records the opposite: "PR #3621 is still open... code phases branch from perf/hook-fanout-consolidation until #3621 merges." This line wasn't corrected to match. Since this brief is meant to be handed to future phase workers as ground truth (Phase 0/3 reference "the guardrails dispatcher" and cache-delivery state built on this branch), leaving the stale "already shipped" claim here risks a later phase assuming the dispatcher is on main when it isn't.

Fix this →


Measure and cut every runtime-cost surface this marketplace ships on the binding host (Windows 11,
Git Bash, Claude Code 2.1.258): hook spawn count and critical-path time per event, Windows-only
production no-ops, the skill listing payload, and the statusline. Eight PR-sized phases, each with a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Eight PR-sized phases" here (and "checklist of the eight PRs" at line 816) doesn't match Open question 10 at line 851: "the goal condition caps the program at 60 turns across nine PRs and two repositories." Counting the actual phase list (1, 2, 3, 4a, 4c, 5, 6, 7, 8 — excluding 4b, which is promoted to its own topic/PR track) gives nine, not eight. Since this plan leans on exact counts elsewhere (e.g. the 66-skill count, the 41-script count) and the turn budget in question 10 is computed off the PR count, this mismatch should be reconciled to one number.


## Open questions

1. **Tracking issue.** No issue number exists for this program. Recommendation: one tracking issue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"No issue number exists for this program" appears to be stale: this PR's own description states "tracking issue #3623 stays open until phase 8 closes it," and the "Related" section links it. If #3623 already is the program's tracking issue, this open question is answered and should say so (and phase 8's final step, which closes the tracking issue, should name #3623 explicitly) rather than reading as an unresolved question for the operator.

@kyle-sexton

Copy link
Copy Markdown
Contributor Author

Closing: docs/topics// is the Contract tier per docs/conventions/topic-docs/README.md, committed on the task branch only and pruned before merge, so a docs-only PR that lands the slice on main is the wrong shape (contract-slice-prune-gate red-lines it by design). The plan stays on the program branch perf/hook-performance-program; each phase PR carries only its own changes and the slice is pruned with a pointer at the end of the program.

@kyle-sexton kyle-sexton closed this Sep 2, 2026

@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: 6586e8446b

ℹ️ 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 on lines +3 to +4
Draft for orchestrator review. Every phase is `[TODO]`. Branch: `perf/hook-fanout-consolidation`
(four commits ahead of `main` with the guardrails dispatcher, PR #3621, already shipped).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Base the plan on the dispatcher prerequisite

The reviewed commit is based directly on a34bd7d, and a repo-wide search of that tree finds no plugins/guardrails/hooks/run-guards.sh; plugins/guardrails/hooks/hooks.json still declares the eight guards separately. Consequently, the baseline assumptions and phases 4a/4b refer to a dispatcher, profiling mode, and tests that are unavailable when this plan is executed from its actual base. Land or rebase onto PR #3621 first, or make adding the dispatcher an explicit prerequisite phase rather than describing it as already shipped.

Useful? React with 👍 / 👎.

Comment on lines +577 to +579
discipline survive unchanged. Add a no-change skip: hash the extracted fields (excluding
`captured_at`) with a builtin-only digest or a cached copy of the last extracted string in the
same directory, and skip the write when equal, so an unchanged payload costs no rename.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve freshness when skipping identical statusline snapshots

When the extracted rate-limit fields remain unchanged for more than ten minutes, this no-change optimization would also stop refreshing captured_at. The authoritative reader contract in plugins/rate-limit-guard/reference/reader-contract.md treats a snapshot whose captured_at is older than ten minutes as stale, so active statusline refreshes would incorrectly push consumers into reactive-only mode. Any write-elision design must preserve a current observation timestamp or change the reader contract and freshness mechanism together.

Useful? React with 👍 / 👎.

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