Skip to content

test(#1094): golden-corpus verdict snapshot for pre-tool.sh - #1128

Merged
admarble merged 6 commits into
mainfrom
feature/1094-test-hooks-golden-corpus-verdict-snapshot-for-pre-
Sep 21, 2026
Merged

admarble merged 6 commits into
mainfrom
feature/1094-test-hooks-golden-corpus-verdict-snapshot-for-pre-

Conversation

@admarble

@admarble admarble commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Golden corpus __tests__/fixtures/hook-corpus.jsonl (339 commands, verdict snapshot for pre-tool.sh) replayed through all three hook copies by __tests__/hook-corpus.integration.test.ts.
  • scripts/hook-corpus.ts: shared replay core, --diff <ref> (whole hooks/ dir extracted at the ref, verdict changes only) and --harvest (parallel replay, replay-twice flake exclusion, redaction).
  • exec skill (all three mirrors) gains §3c2: run --diff origin/main on any pre-tool.sh change and list changes under Hook verdicts changed:.

Acceptance criteria

Sources and redaction

Read: the 157 commands driven through runHook by pre-tool-hook.integration.test.ts (source #763/#981/#1064/manual, tagged by describe block), ~/.sequant/logs/claude-hook.log (hook-log), and Bash tool_use inputs from ~/.claude/projects/-Users-tony-Projects-sequant/*.jsonl (transcript, filtered to guard-relevant commands plus all blocked ones, exit-0 sample capped at 150). Redaction pass (redactCommand): Authorization/X-*-Token headers, gh/xox/sk/AKIA/AIza/npm/JWT token shapes, *TOKEN=/*SECRET=/--token values, emails, and /Users/<name> → /Users/user. Commands over 2,000 chars are dropped, and any command whose verdict differed between two replays is excluded.

Corpus states: replays run in a pinned repo, staged (default), clean or dirty (optional state field on a line), because commit and reset guards depend on git state.

Hook verdicts changed: none

Mutation-verified: AC-2 — re-applied the #1064 mutation in hooks/pre-tool.sh; the #1064 #62 -F - case failed; restored.

Closes #1094

🤖 Generated with Claude Code

Runner verification (guard-2026-09 wave 3, 2026-09-20)

  • qa: AC_NOT_MET twice, both real; AC_MET_BUT_NOT_A_PLUS on the third run (86ee3e8b). Round 1: AC-1's hook-log ≥ 50 was unreachable (42 eligible blocks on the maintainer host) and the log keeps only a multi-line command's first line, so fragments harvested as commands. Round 2: 26 of the 39 re-harvested hook-log cases were pinned as allow although the hook had blocked them — the replay harness cannot reproduce background-task, orchestrator-env or state-dependent guards — and three session links plus an unrelated project name had leaked into the fixture.
  • Runner fixes (58b15410, 86ee3e8b): extractHookLogCommands skips heredoc/operator/unbalanced first lines and rule-mismatched lines (gate-tested with verbatim log shapes, mutation-verified both ways); the harvester keeps hook-log candidates only when the replay reproduces the block; GUARD_RELEVANT anchors per line; redaction covers claude.ai/code/session_…, non-sequant /Users/*/Projects/* paths (both slash and scratchpad forms) and foreign --repo names, gate-tested; the corpus was rewritten through parseCorpus/serializeCase (339 cases, 13 hook-log, all exit: 2, zero leaks by grep).
  • AC-1 is rewritten on the issue (runner, D-22): ≥ 10 hook-log cases, every one a reproduced block, zero allow-pinned; the unreproducible 29 are test(hooks): the hook-corpus replay cannot reproduce background-task, orchestrator-env or state-dependent blocks — 29 of 42 logged blocks have no corpus coverage #1129.
  • Runner ran AC-2 (snapshot: 1019 cases green on all three copies), AC-3 (--diff origin/main → 0 verdict changes), AC-4 (redaction cases), AC-5 (grep 1 per copy), lint:skill-sync 44/44, no SKILL.md mentions relay.
  • Full npm test from a clean shell on 86ee3e8b: 335 files, 8320 passed, 1 expected fail, 3 skipped — 579 s. Note for the owner: the corpus snapshot (~1000 replays × 3 copies) adds roughly three minutes to the suite; if that is too much for the required test job, the snapshot could move to the canary project.

…t, skill step

Entire-Checkpoint: a1c329380392
Entire-Checkpoint: 100d0f54e3eb
… commands; GUARD_RELEVANT anchors per line; corpus re-harvested (39 real blocks)
…ule-mismatched first lines; redact session links, foreign projects and repos; corpus rewritten
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.

test(hooks): golden-corpus verdict snapshot for pre-tool.sh — every command form ever guarded, replayed on each change, verdict changes reviewed

1 participant