Skip to content

Hook accuracy: measure the hooks, fix what the measurement found - #7

Merged
DojoGenesis merged 13 commits into
mainfrom
fix/dgs-208-hook-accuracy
Oct 17, 2026
Merged

DojoGenesis merged 13 commits into
mainfrom
fix/dgs-208-hook-accuracy

Conversation

@DojoGenesis

Copy link
Copy Markdown
Owner

Fixes DGS-208

What this does

The suite's hooks fire on the tells in the Dojo Protocol. Nobody had measured how often they're right, or whether blocking on them changes what an agent does. This PR measures both, fixes what the measurement showed, and leaves a way for anyone to re-run all of it.

  • A fixture suite for the hooks. scripts/hook_accuracy.py feeds each hook script the payload Claude Code would send, on fixtures with known answers (plugins/<plugin>/fixtures/accuracy/), and prints precision and recall per hook with 95% intervals. --hooks-from measures another checkout against the same fixtures. Fixtures marked known_miss record errors the hooks still make: they count in the table but don't fail the run.
  • A field sample. Every firing of a dojo-verify or dojo-gates hook in one maintainer's sessions from 2 to 17 October 2026 (382 firings of nine checks) was labeled right or wrong against a written rubric by an independent labeler, with a second labeler on 30% (95% agreement, kappa 0.87). Firings were split in half before any fix; the fixes were developed on one half and scored once on the other.
  • dojo-verify 0.2.0 and dojo-gates 0.2.0, fixed against what the labels showed (details in CHANGELOG.md).
  • A pre-registered with/without eval of dojo-verify's Stop block. Hypothesis, metric, sample size, decision rule and cost cap were frozen before any agent ran (digest recorded in dfdff54); the results are below the marker in plugins/dojo-verify/evals/PREREG-2026-10-17-evidence.md.
  • A runtime health report. scripts/health_report.py replays local transcripts through the suite's own detector code and reports, per rule, what it counted and out of how many, with each finding's evidence and each detector's measured accuracy beside it. The same input gives byte-identical output.
  • A rule-by-rule table (ACCURACY.md §4): for each of the ten rules, what checks it at runtime, how accurate that check is, and what has measured the rule's effect.

Method, rubric and tables: ACCURACY.md.

Before and after

hook field precision before (all 382) held-out, old hooks → new hooks fixture suite before → after (in-sample)
dojo-verify (Stop) 3% (7 of 215) 4% → 8%; misfires 104 → 44, every real catch kept 32% → 62% precision, recall 100%
config-first 30% (22 of 73 kind-firings) path 29% → 50%; auth 86% → 100%; cmd 2 misfires → none path 62% → 86% (recall 100% → 75%); cmd 33% → 100%
secret-print 0% (0 of 22) 11 misfires → 2 41% → 88%
empty-probe, mac-timeout, big-read, staging 88–100% unchanged unchanged

The eval

80 runs on Claude Code 2.1.299: 8 held-out cases × 5 runs × 2 arms, executor Sonnet, judge Opus with three votes per verdict. $20.30 against an approved cap of $28.60.

without dojo-verify with dojo-verify
unbacked success claims, judge (6 cases with a check available) 5 of 30 4 of 30
unbacked, deterministic reference 12 of 30 8 of 30
mean cost per run on the 2 control cases $0.184 $0.237 (×1.29)
control cases failed by the judge 0 of 10 0 of 10
  • No benefit detected. The difference (without minus with) is +3 points, 95% interval −16 to +22, which includes zero. A run this size can detect a fall from about 40% to 10%, not 17% to 13%, so a small benefit could exist unseen.
  • The pre-registered rule outputs warn as the default: no detected benefit, and the control cost ratio (1.29) crosses the 1.25 harm bar.
  • When the hook fired, it did its job, but it missed the claims that mattered. It fired in 13 runs, each ended in a backed reply, at about one extra turn each. It fired on none of the four with-arm runs the judge rated unbacked: what's left are claims a phrase-and-command matcher can't see.

What the measurement says

  • dojo-verify's Stop block is right about one time in twelve on sessions the fixes never saw. Most of what's left needs judgment a hook can't make: whether the check that ran is the one the claim depends on, whether a later edit could matter, whose work a sentence describes.
  • config-first now reads error lines by their shape and by which program printed them. It misses two real wrong-directory failures that showed only through ls, the price of treating ls as an existence check, which was its most common misfire.
  • secret-print blocked 22 commands in the field and none of them printed a secret.

Review notes

  • Two existing tests changed on purpose: ls nope no longer counts as a missing path (27 of 41 path firings in the field were ls checks). The tests now use cat, python3 and cd.
  • The shell parser records each command substitution's parent segment, so secret-print can tell captured output from printed output.
  • Two dojo-gates changes (33a6d8f) came after the held-out replay was scored, prompted by what it showed. The held-out figures predate them, and ACCURACY.md §2 says so.
  • The issue's three later cases are fixtures too. The conditional-advice case passes; the push compared with ls-remote and the pricing argument that uses "works" still misfire, so they're marked known_miss and tracked as a follow-up.
  • Ten older eval scaffolds (four in dojo-gates, four in dojo-protocol, two in dojo-verify) set scaffold_script to inline shell. Claude Code 2.1.299 reads that field as a path to a script file, so they'd fail at setup if run. Left as they are; the held-out cases use scaffold.sh.
  • scripts/release-check.sh passes in full on Claude Code 2.1.299 at the branch tip: 0 fail, 0 error, and plugin-lint's known warning baseline.

Not in this PR (needs a ruling)

  • Whether dojo-verify's default becomes warn, as the pre-registered rule says. This PR leaves it at block.
  • Whether the field-sample numbers in ACCURACY.md §2 stay public. They're from the maintainer's own sessions; only counts are published.

🤖 Generated with Claude Code

TresPies-source and others added 13 commits October 16, 2026 20:16
…s the output (DGS-208)

config-first matched any line containing 'command not found', 'No such file
or directory', 401/403 or 'connection refused', so printed docs, hook source
and memory files fired it, and so did ls answering whether a path exists.
It now counts a line only when a program this command ran reports its own
failure in a known shape, skips existence probes, a missing path that
follows a code error, unsplit-variable 'commands' and loops that try
candidates on purpose.

secret-print denied on the words it saw, not where the output went: values
captured by $(...) into an assignment or a non-printing program, piped into
grep -c, wc, cut -d= -f1, a sed mask or /dev/null, an env file being written
(cat > .env), and literal loop variables named like secrets. The lexer now
records each substitution's parent segment so the guard can tell.

staging no longer treats git add -N/--intent-to-add/-n as staging content.

Field replay on the dev split of labeled firings: config-first 9 of 42
right before, 9 of 11 after; secret-print 0 of 11 right before, 0 firing
after; the existing deny cases still deny.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cks people run (DGS-208)

Labeled field firings showed 3 of 107 stop blocks on the dev split were
right. Most misfires were one of two kinds: a check ran that the hook did
not know by name, or the flagged sentence was not a claim.

Evidence: a program run (not cat or echo) that exits clean and prints
PASS/ok lines, N passed, N/N pass, ALL PASS or 0 failed counts as a check;
gh pr checks and gh run view/watch are checks; opening a rendered image
counts for a visual change; the agent's own memory and notes (Write/Edit
or a Bash write that names them) no longer reset the evidence.

Claims: a leading negative scopes over its list ('Nothing is committed,
pushed or deployed'); blockquotes, quoted spans and list items under a
'says:' or 'wrote:' line are someone's words; 'a paid verified review' and
'Fixed scope' are adjectives; 'works in/for/when', 'Why it works', 'go to
Done' and 'Click Done' are other senses; 'the builder reports 1737 passed'
is attributed.

The mod mirrors every rule; the shared case table gains 19 claim rows and
9 sessions that both run. Dev-split replay: misfires 104 -> 51, true
catches 3 -> 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ep parent hides a substitution

Two cases from the held-out replay, fixed after it was scored: git printing
'warning: could not open directory ...: No such file or directory' is a
real path failure, and printf inside $(...) that only feeds grep -q never
reaches the conversation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dojo-gates 0.2.0 (2.4.0, unreleased)

scripts/hook_accuracy.py feeds each hook script the payload Claude Code
would send, on fixtures with known answers in plugins/*/fixtures/accuracy,
and prints precision and recall per hook with 95% Wilson intervals.
Fixtures marked known_miss record errors the hooks still make: they count,
but don't fail the run. ACCURACY.md holds the method, the labeling rubric,
the fixture table (before and after) and the field sample measured on the
maintainer's sessions. Test text no longer carries issue keys or home paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pre-registration digest (sha256 of everything above the marker):
d5cac861200cbb102150daa64bac28ccc4774bd5ea1cd8cfd133d21666c4feba

Eight held-out cases written by an independent model author from
evals/held-out-brief.md (six where a check exists, two controls), with the
evaluator's graders fixed: an Opus trace judge for unbacked success claims,
a deterministic claim-plus-check reference, and with-only indicators. No
run has happened; the run waits on the operator's cost and author go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt 1

claude plugin eval 2.1.299 reads context.scaffold_script as a file path, so
the inline scaffolds stopped every pilot run at setup (no agent ran, $0).
Each held-out case's scaffold, unchanged, moves to scaffold.sh. The
pre-registration digest above its marker is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…amendment 2

The pilot (16 runs, $4.40, excluded from analysis) showed reply-claims-success
throwing on every run: JavaScript regexes take no inline (?i). Measured cost
per graded run is $0.275, so the main run's cap under the pre-registered stop
rule is $28.60. The percent copy rule now skips pre-registrations and frozen
held-out task data, which state numbers as design parameters, not claims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/health_report.py replays local Claude Code transcripts through the
suite's own detector code (dojo-verify's claim and evidence functions,
dojo-gates' config-first, empty-probe and static guards, dojo-router's
unpinned-dispatch rule, dojo-tally's return counts) and reports, per Dojo
rule, what it counted and out of how many, with every finding's file, line
and a masked excerpt in evidence.jsonl. Each count sits beside its
detector's precision and recall from the fixture suite, and optionally a
field precision measured on real sessions. dojo-doctor's setup checks are
attached. Nothing depends on the clock: with a date window, the same
transcripts give byte-identical output; inputs are listed with digests.

Its fixture sessions have hand-derived answers in fixtures/health/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 runs, $20.30 of a $28.60 cap, Claude Code 2.1.299. Unbacked-claim rate
on the six check-available cases: without 5/30, with 4/30, D = +0.033
(95% CI -0.155 to +0.220); deterministic reference 12/30 vs 8/30. Control
cost ratio 1.29. Applied mechanically, the rule outputs: default to warn.
The hook fired on none of the with-arm runs the judge rated unbacked.
Digest above the marker unchanged: d5cac861200cbb102150daa64bac28ccc4774bd5ea1cd8cfd133d21666c4feba

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ws 1, 4, 8 and 9 of the rule table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…16 report; disclose the post-replay gates changes

Case 7 (conditional advice) passes. Cases 6 (a push compared with ls-remote)
and 8 (a pricing argument that uses 'works') still misfire and are marked
known_miss. ACCURACY.md now says the two dojo-gates changes in 33a6d8f came
after the held-out replay was scored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lists the eval, health report and rule table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DojoGenesis
DojoGenesis merged commit 5f2ae05 into main Oct 17, 2026
3 checks passed
@DojoGenesis
DojoGenesis deleted the fix/dgs-208-hook-accuracy branch October 17, 2026 03:21
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.

2 participants