Repository navigation
Description
Problem
On one Windows 11 machine, /harness-config:audit's engine ran for about 20 minutes without
printing anything and was stopped. The root cause is not known. This issue is a diagnosis: measure
where the time goes, name the cause with a measurement, then fix it or file the fix.
What happened (2026-10-04 Windows performance audit, Claude Code 2.1.289, Git for Windows):
audit-engine.sh --tableprinted nothing in 280 s in the foreground, nor in about 15 more
minutes in the background. It was stopped by hand. Whether it hung or was still working is not
known.- The run was rooted in the home directory, not a repository. 84 plugins were enabled at user
scope, with 254 to 256 hook registrations. The audit counted "507 permission deny rules (42 ask,
137 allow)" in the settings file; the 507 may count the whole permissions block, so read it as
roughly 500 to 700 rules. The melodic-software marketplace was a local directory source, and 77 plugins
diverged between the loaded directory and the registry cache. - The engine's hook-inventory step,
check-hook-coverage.sh --json, ran on its own and finished.
Its timing was not recorded.
Paths are relative to plugins/harness-config/skills/audit/scripts/. Line numbers are on
origin/main 5779559.
Evidence
Verified this pass by reading code only. The engine was not run.
- Silence does not tell a hang from a slow run. The engine prints nothing until it finishes.
Rows collect in shell arrays (audit-engine.sh:340-377), and the--tabletext is printed only
in the assemble step (:2104-2186). Only fatal errors go to stderr earlier. A run 1 second from
done and a run stuck forever look the same. - The network calls are time-bounded, so the network is unlikely to be the cause.
- The docs fetcher uses
curl --connect-timeout 15 --max-time 120
(plugins/harness-config/scripts/fetch-docs.sh:193). - The plugin drift check's curl uses
--max-time 15(check-plugin-drift.sh:237). claude --versionruns undertimeout 30whentimeoutexists (audit-engine.sh:645-650).
- The docs fetcher uses
- A home-rooted run audits one file twice. With no git toplevel, the project root falls back to
CLAUDE_PROJECT_DIRor$PWD(plugins/harness-config/lib/resolve-scopes.sh:37-39). In the
home directory, the project settings path$PROJECT_ROOT/.claude/settings.json
(audit-engine.sh:310) is the same file as the user settings, so every per-rule and per-key
check runs once per scope.
Code-level suspects. Each is a hypothesis; none was measured.
- Per-row process spawning.
- Every finding row starts about 10 processes:
anchor_for_excerptruns sed and two
sha256/cut pipelines (:130-137),finding_idruns sort, sha256 and cut (:139-156), and
rowruns twojq -cncalls (:364-370). - A non-finding row still starts one jq (
:373-375). There are 102rowcall sites, many
inside loops over hooks (:1408-1484), permission patterns (:1245onward) and plugins. - The audit measured process start cost on this host at bash 53 ms, node 95 ms and python
85 ms (medium confidence). Thousands of spawns at that rate take minutes, more while other
sessions load the machine.
- Every finding row starts about 10 processes:
- Per-key greps over the claude binary.
- For each settings key not documented on settings-reference, the engine runs
grep -aqEover the whole installed claude binary (:1043-1056). A miss reads the entire
file. - For each hit,
bin_describerunsgrep -aoEwith a[^;{}]{0,800}tail over the whole
binary (:1029-1040). That bounded repetition can be slow in GNU grep. How many keys this
machine sent down this path is not known.
- For each settings key not documented on settings-reference, the engine runs
- The plugin drift check (
check-plugin-drift.sh, 653 lines, called at:1700-1710) over 84
plugins with 77 divergent. - The hook loop over about 256 hooks (
:1408-1484). It runs path resolution and several
rows per hook, on top of the inventorycheck-hook-coverage.shalready built.
What the item claimed and this pass did not confirm: nothing beyond the facts above. The item gave
no cause, and none is asserted here.
Proposed approach
Step 1, reproduce and measure. Do this before changing any engine code.
- Build a synthetic fixture the size of the observed config: a settings file with about 700
permission rules, about 250 hook registrations across 80 or more plugin directories, some
undocumented keys, and a home-rooted layout where project and user settings are the same file.
Point the engine at it through its test seams (audit-engine.sh:61-75):SETTINGS_AUDIT_ENGINE_FIXTURE_DIRSETTINGS_AUDIT_ENGINE_USER_DIRSETTINGS_AUDIT_ENGINE_INSTALLED_JSONFETCH_DOCS_FIXTURE_DIR, for offline docs
- Time the phases without editing the script:
PS4='+ $EPOCHREALTIME $LINENO ' BASH_XTRACEFD=3 bash -x audit-engine.sh --json 3>trace.log >/dev/null.
The trace goes to its own descriptor, apart from the engine's stderr. Writetrace.logto a
scratch directory, then sum the elapsed time per section, using the# ---section headers as
boundaries. Tracing adds its own overhead, so compare sections with each other rather than
reading absolute times. - Bisect with the existing switches:
SETTINGS_AUDIT_ENGINE_SKIP_DRIFT=1removes the drift check.SETTINGS_AUDIT_ENGINE_CLAUDE_BIN=''skips the binary greps (:637-641,:1043).- Compare a run where the claude binary is present against one where it is absent.
- If the fixture does not reproduce a run of several minutes, run step 2 once on a real
home-rooted machine of that size. Record the per-section times, not the trace, because the
trace holds settings values.
Step 2, fix by measured cause. The likely remedies, matched to the suspects above. Pick one only
after step 1 names the cause.
- Suspect 1: build rows in one jq pass per category instead of per row, and hash identities in
one batched pass. - Suspect 2: read the binary once (one
grep -aoEover the alternation of all leaf names, or a
stringspass cached per run) instead of once per key. - Suspect 3: cap or parallelize per-plugin work in the drift check.
- Home-rooted runs: skip the project scope when it is the same file as the user scope. The
engine already compares file identity forsettings.local.json(:406).
Independent of the cause, recommended: write one progress line per category to stderr, for
example audit-engine: D hooks (256). A slow run then shows where it is, and an operator can
tell slow from stuck. The SKILL.md Phase 1 block (SKILL.md:112-121) should also say how long a
large config takes and that a long run belongs in the background.
Acceptance criteria
- Per-section wall times are recorded on this issue for a home-rooted run with at least 700
permission rules and 250 hooks (fixture or real), each with the configuration that produced
it. - A named root cause is stated with the measurement that shows it, or the issue records that
the run completes in under N minutes on that config and only the silence was the defect. - The engine writes at least one stderr progress line per category during a
--tableor
--jsonrun, and a test asserts it without changing stdout. - The fix for the named cause lands here, or is filed as its own issue and linked.
- On the same fixture, the full
--tablerun finishes within a budget recorded in SKILL.md,
or SKILL.md tells the agent to run it in the background with a stated expected duration.
Constraints and gotchas
- Do not run the real engine against a person's live settings to diagnose this without asking.
The trace and the--jsonoutput hold settings values; keep them in a scratch directory and
publish only timings. - The engine's contract is to never execute a hook (
audit-engine.sh:49-54). Keep it. - Git Bash on Windows: jq appends CR to stdout lines (
:83-86). Any batching change must keep the
tr -d '\r'handling. - Row identities (
finding_id) are a contract with/harness-config:audit-passand with
suppression records. A batched rewrite must produce byte-identical ids. Prove it against the
existing tests inaudit-engine.test.sh. - Bump the harness-config version and add a CHANGELOG line, per the repo's release convention.
Context
Part of the 2026-10-04 performance audit, parent #6244.
Source: local handoff item 20261004-152632-claude-perf-audit-tooling-bugs.md, bug 5 (retired into
this issue). Related history: #4206 (Windows defects in this engine), #3989 (engine made
script-first), #6090 (drift reads the marketplace renames map).
Activity
github-actions commentedon Oct 4, 2026
Thanks for this. I understand the problem as: on a home-rooted run with a large config (~84 plugins, ~255 hooks, ~500-700 permission rules),
audit-engine.sh --tableproduced no output for well over 20 minutes and was stopped, with the root cause (slow vs. hung) unconfirmed. The report already lists concrete suspects (per-row process spawning, per-key greps over the claude binary, the plugin drift check, the hook loop, and double-auditing when project/user settings resolve to the same file), a reproduction plan using the engine's existing fixture env vars, and acceptance criteria requiring measured per-section timings, a named cause, and a stderr progress line per category.Nothing appears missing to start the work: the proposed approach already specifies how to build a synthetic fixture and bisect with existing switches (
SETTINGS_AUDIT_ENGINE_SKIP_DRIFT,SETTINGS_AUDIT_ENGINE_CLAUDE_BIN). I didn't find an existing issue duplicating this specific diagnosis; it links its own related history (#6244 parent, #4206, #3989, #6090).Automated triage. A maintainer reviews it.
kyle-sexton commentedon Oct 4, 2026
Timed reproduction and cause
Reproduced on a real configuration, Windows 11, Git for Windows bash 5.3.15, jq 1.8.2, Claude Code 2.1.289 (a 249 MB binary). The host was busy with other sessions. Only timings and counts are published here; every trace and output stayed in a scratch directory.
Configuration. 83 enabled plugins at user scope (8 more at project scope in the repo-rooted run), 79 resolved for the hook inventory, 259 hook registrations, 72 plugins diverging between a directory marketplace and the registry cache. User settings hold 512 deny, 43 ask and 141 allow rules (696; the repo-rooted run adds 7 project denies, 703). A 56-entry user suppression record.
It does not hang. Every phase finished. The silence was the engine printing nothing until assembly.
Before: per-phase wall time, repo-rooted,
bash -xtraceTraced total 584 s (tracing adds overhead; compare phases with each other).
check-hook-coverage.sh, child)check-plugin-drift.sh, child)The hook inventory alone, run standalone: 147 s (plugin loop 99 s for 79 plugins, JSON output 45 s for about 420
jqcalls).Untraced, with docs read from disk (
--docs-dir) and drift skipped: 400 s and 411 s repo-rooted, 344 s home-rooted (SETTINGS_AUDIT_ENGINE_FIXTURE_DIR=$HOME, so the project and user scopes are the same file).Cause: one or more processes per row, per hook and per plugin
Process starts on this host:
jq -cn 1140 ms,printf | sha256sum160 ms, a$( )subshell 40 ms when idle; 545 ms, 525 ms and 130 ms while an engine run was in progress.Counted with PATH shims on the repo-rooted run (docs from disk, drift skipped): 4,247 external process starts: 1,435
jq, 1,163tr, 545cut, 310base64, 292grep, 274sha256sum, 127sort, 72sed, the rest under 20. Subshell forks are on top of that.Where they came from: every row ran 1 to 3
jqcalls, and every finding row about 10 more processes for its anchor and id; the hook inventory ran about 15 processes per plugin and onejqper hook, plugin and divergence node it printed; each category E row decoded 7 fields with 7base64calls; each plugin'splugin.jsonwas read with its owntr | jq.Ruled out by the numbers: the network (docs 13.7 s, all bounded), the binary greps (1.9 s; one undocumented key here), the drift check (4.5 s repo-rooted, 13 s in the home-rooted default run).
After: commit fe1d087 on
perf/6258-audit-engine-timingjq, 202sha256sum, 278tr).--tablerun (network docs fetch and drift check included): 106 s.--jsondocuments and--outfindings files are byte-identical to the old engine's, repo-rooted and home-rooted. The standalone hook inventory output is byte-identical too (147 s to 20 s).audit-engine: <category> ... (<seconds>s)line per category to stderr. Home-rooted full run: docs 10 s, A 20 s, D inventory 25 s, B 58 s, D checks 61 s, E 75 s, E drift 79 s, F 92 s, assemble 101 s.SETTINGS_AUDIT_ENGINE_PROGRESS=0turns the lines off.audit-engine.test.shcase 55): it countsjqstarts through a PATH shim on configs with 5 and 60 hooks, deny rules and disabled plugins, and asserts the counts are equal. On the old engine it fails with 135 against 301; on the new one both are 87. It also asserts a progress line per category and stdout unchanged with progress on.Residual: each finding row still costs two
sha256sumstarts (about 200 on this config, roughly double for a home-rooted run with many findings). The home-rooted double audit of one file under two scope labels is unchanged; it now costs seconds, not minutes.