Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 5.14 KB

VALIDATION.md

File metadata and controls

57 lines (40 loc) · 5.14 KB

HookProbe validation

Checked 2026-11-15 (Asia/Shanghai).

v0.2.0 — broader events, matcher evaluation, real CLI attempt

Environment: macOS arm64, Go 1.26.2, Claude Code CLI 2.1.323 installed at ~/.local/bin/claude.

Check Observed result
go test -race -count=1 ./... 45 top-level tests and 103 subtests passed, zero failures, no race report
go vet ./... Passed
Native build macOS arm64 executable built with -trimpath
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build Statically linked Linux x86-64 ELF built; not executed on Linux
Built-binary smoke checks --version (0.2.0), demo, check, all three example handlers, custom payload, events, absent Claude CLI (exit 3) and matcher mismatch (exit 3)
Real probe against Claude Code 2.1.323 UNKNOWN, exit 3, 1.16 s. See below

What the real CLI run established

This machine's shell is itself nested inside a Claude Code session, so probe first returned UNKNOWN with "Nested Claude session detected" — the documented guard, not a hook result.

The run was then repeated with the guard variable unset (env -u CLAUDECODE) from a normal shell. In that invocation:

  • Claude Code 2.1.323 accepted every flag the probe passes: --settings, --setting-sources "", --strict-mcp-config, --mcp-config, --no-session-persistence, --disable-slash-commands, --permission-mode dontAsk, --max-turns 4, --max-budget-usd 0.25, --tools Bash, --allowedTools, --output-format json, -p.
  • The injected SessionStart canary callback was observed by the private recorder. This is the first real-Claude evidence this project has: hooks supplied through a temporary settings file with --setting-sources "" do run, and the recorder's token, directory and file-permission handling work under the real CLI.
  • The model request was refused by the configured gateway (API status 429, terminal_reason: api_error). No tool call was attempted, so PreToolUse allow/deny and PostToolUse callbacks were not observed and the report stayed UNKNOWN.
  • Reported cost was $0.00 for the failed run.

The v0.2 cli-result check is what makes that distinction explicit. Without it the report only said "events missing", which is equally compatible with a broken hook setup and with a rate-limited account.

What remains unverified

  • PreToolUse deny enforcement and PostToolUse callbacks through a real model turn.
  • Behaviour of the canary under a working model, and therefore the allow-effect/deny-effect PASS path.
  • Any installed user hook in its native registration context. The canary proves HookProbe's own injected hooks ran; it says nothing about hooks already in ~/.claude/settings.json or plugins.
  • Windows execution, and Linux runtime behaviour beyond a successful static build.

v0.2.0 regression coverage

  • All 13 supported events have fixtures, a valid default test payload and documented exit-code-2 semantics; events outside the set stay UNKNOWN.
  • Exit code 2 is interpreted per event: deny on PreToolUse, prompt block on UserPromptSubmit, stopping blocks on Stop/SubagentStop, compaction block on PreCompact, and "not acted on" on Notification/Setup.
  • A top-level decision is only honored where the event honors it; continue: false is reported as ignored on events that discard it.
  • hookSpecificOutput fields are scoped per event, so permissionDecision on PostToolUse, updatedInput on PostToolUse, or additionalContext on PostCompact are never reported as working decisions.
  • Matcher rules are tested against exact values, |/, lists, anchored and unanchored regular expressions, MCP names, and patterns the RE2 engine cannot represent.
  • An uncompilable matcher fails check, is refused by test, and can never be reported as a valid hook.
  • A matcher that does not select the payload produces UNKNOWN with the handler still executed, so handler evidence is kept while registration is not implied.
  • Matchers on events without matcher support are reported as ignored, matching the documented behaviour.
  • --payload - reads the event document from stdin; a pipe test confirms it reaches the handler unchanged.
  • The scripted Claude transport reports an error envelope without copying the CLI conversation, and the JSON report is checked for absent prompt/auth text.

v0.1.0 — original delivery (2026-11-06)

Recorded as delivered: 29 top-level tests, go vet, macOS build, static Linux build, and 10 built-binary smoke checks. Claude Code was not installed on the machine at that time, so hookprobe probe returned UNKNOWN without starting a session. Read-only review found protocol/configuration and truncation issues; regression tests were added and the blockers were fixed before packaging. That release also stated plainly that no GitHub repository had been published from the local build.

Standing limits

Even a future PASS from probe covers only the disposable injected canary. Native registration of arbitrary pre-existing user hooks, installed-plugin discovery and effective managed-policy merging remain outside scope. Command hooks run as the current user: test is not a sandbox, and probe is not an OS sandbox either.