Fix StopFailure Hook Uninstall Testing

can you review this trail? https://entire.io/gh/entireio/cli/trails/1480/end-a-claude-code-turn-on-stopfailure-not-only-on-stop
I'd approve trail #1480 once two things are done: commit the uncommitted test change in your worktree, and add a description to the trail (it has none). I found no bugs. The new stop-failure hook goes through the same code as Stop and ends the turn. It's also included everywhere the other hooks are: install, uninstall, the outdated-config check in status/doctor, the hook-name list the CLI registers commands from, the repo's own .claude/settings.json, and the docs.
Trail status: 17/17 checks pass and the agent review has no findings. The only gate still failing is approvals, which needs a reviewer.
Before approving
- Uncommitted test. Your worktree has an edit to
hooks_test.gothat checks uninstall removes theStopFailurehook. It matters becauseAreHooksInstalledonly looks atStop, so a leftoverstop-failurehook would go unnoticed. The package tests pass with it; commit and push it. - Older Claude Code versions. Entire now writes a
StopFailurekey into users'.claude/settings.json. I can't confirm from the repo how a Claude Code release that predates this hook handles a key it doesn't know: it might ignore just that hook, or reject the whole settings file. If it rejects the file, every Entire hook would stop working for people on old versions. The repo doesn't check the Claude Code version anywhere. Worth confirming which version addedStopFailureand whether that risk is acceptable.
Smaller points
- Transcript wait matches by accident. When a turn ends, Entire waits for Claude Code to finish writing the transcript. It does that by looking for the text
"hooks claude-code stop"in the file (lifecycle.go:275), and"hooks claude-code stop-failure"contains that text. So if Claude Code logs the failure hook there, the wait ends early as it does forStop. If it doesn't, the wait falls back to "file size stopped changing". Either way works, but the match is accidental. A comment or test would stop someone later tightening the check and quietly losing this. - Test coverage. Only the parsing is unit-tested. One integration test that fires
stop-failureafter a prompt and checks the session goes back to idle would cover the real bug being fixed. - Checkpoint summary. A failed turn's saved step may take the API error message as its summary. That's acceptable, just worth knowing.
- Nits:
docs/architecture/agent-guide.mdpacks an explanation into a table cell (stop+stop-failure(StopFailure: …)), which reads awkwardly. The newTestCheckHookConfig_Outdated_MissingStopFailurerepeats most of the setup in theMissingSubagentStoptest right above it; a shared helper would remove the duplication.