Repository navigation
Session hooks that check: the fast checks after an edit, verify before a stop, the Maintainer's identity - #66
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 20
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…e a stop, the Maintainer's identity Three project hooks in .claude/settings.json, each a module under tools/hooks/ that installs nothing: - PostToolUse on Edit, Write, MultiEdit and NotebookEdit runs `make fast`, a new target: every check and every test module but the seeded simulation, about three seconds. A failure goes to the agent with exit 2; the edit stands. - Stop runs `make verify` and refuses to stop while it fails. It sends the session back once; if verify still fails at the next stop, the session ends and the person is told, so the hook never cycles without a bound. - PreToolUse on Bash refuses a command that commits or pushes unless git's author and committer, gh's active account, the remote and every commit being pushed are the Maintainer's. An identity set inside the command is refused, and so is anything the hook cannot read: no git or gh, a token in the environment, an SSH remote, a command it cannot split into words. The Maintainer's identity is data, config/hooks.json, with its schema and a counter-example. The machine user is the approver already in config/defaults.json. tests/test_hooks.py feeds each hook a violation and a clean case, and holds the wiring in the settings. make verify and tools.mutants pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The identity hook: - No option from the command reaches the hook's own git. A refspec is read after its +, and one starting with '-' is refused. Each source is resolved first with rev-parse --verify --end-of-options, and git log gets the commits it resolved to. - One deadline of 45 seconds covers every git and gh call. Running out refuses. - No credential is shown: a URL loses its user and password before it is printed, and the credential helper's value is never echoed. - A here-document's body is never read as commands, and a command substitution inside a quoted word is. A refspec with an expansion pushes the current branch, so `git push -u origin "$(git branch --show-current)"` passes. - gh pr merge, gh release create, and gh api with a writing method or fields need gh's active account to be the Maintainer. - Refused as unreadable: -c alias.* and -c http.*, an unknown git command or global option, text that names a commit or push in a command not read as one, and a write to .git/config in the same command. Every push URL is read (get-url --all). The hooks run as `python3 -I` on their files, so nothing where they run can shadow the standard library. make runs only in the project or a worktree under its .claude/worktrees/. An edit elsewhere runs nothing, and a branch with no fast target tells the person and does not fail. The Stop hook skips verify when the tree is clean and nothing is unpushed. Its message to the agent says only that verify fails, with the tail. tools/verify.py discovers every test file again and filters for fast. A test holds main([]) to the simulation, and holds both Makefile recipes word for word. make verify and tools.mutants pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After the rebase onto "Verify passes in a checkout that holds other worktrees", two of this story's tests walked the tree themselves. The test that holds `make verify` to every test file now finds them with walk.files. The hook tests make each repo with git clone instead of copying one, and make a repo only once for each configuration that no case changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erified rules After the rebase onto "How a platform trial is run and recorded", verify's main prints each unverified rule of the fake GitHub. The test that holds `make verify` to every test file calls main twice, and the list was printed into the middle of every run. It now captures that output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
don-petry
force-pushed
the
slice-0/session-hooks-check
branch
from
October 15, 2026 01:46
b6aaaaa to
8e33442
Compare
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Part of the epic "Epic: slice 0, foundations. The repo holds the line, its context is tested, and the platform facts are recorded". Until slice 2 every line is written in the Maintainer's sessions, and an instruction is a request; a hook is enforcement (§9.12, "Hooks hold the line").
What this story now holds:
make verifyfails on work it has not pushed; at the next stop the person is told.Three project hooks in
.claude/settings.json. Each is a script undertools/hooks/, run aspython3 -Iso nothing where it runs can shadow the standard library. They install nothing.Edit|Write|MultiEdit|NotebookEditmake fast, which is every check and every test but the seeded simulation, in the project or the worktree under.claude/worktrees/that holds the edit. An edit anywhere else runs nothingfasttarget tells the person and does not failmake verify, unless the tree is clean and nothing is ahead of its upstream ororigin/mainBashgh api: git's author and committer, gh's active account, every push URL, and every commit being pushed must be the Maintainer'scode: sentenceper problemThe identity hook reads what is configured, so an identity set inside the command is refused:
--author,-c user.*,-c alias.*,-c http.*,GIT_AUTHOR_*,git config,gh auth, or a write to.git/configin the same command. It refuses what it cannot read:It never hands its own git an option from the command, and it shows no credential. Here-document bodies are data. A refspec with an expansion, such as
"$(git branch --show-current)", pushes the current branch.The Maintainer is data,
config/hooks.json, with a schema and a counter-example. The machine user is the approver already inconfig/defaults.json(decision 0005).tools/hooks/shell.pyreads a shell command as words. The story "Session hooks that refuse: protected paths, merging, and the repo's own rules" can reuse it, and should add.claude/settings.json,tools/hooks/andconfig/hooks.jsonto its protected paths.The branch is rebased onto
mainafter "Verify passes in a checkout that holds other worktrees" and "How a platform trial is run and recorded".make verifykeepscheck_trialsand its list of unverified rules, and the hook tests walk the tree only throughtools/walk.py.What is given up
sedorawkscript whose text names a commit or a push is refused, since either program can run commands.Verification
make verify: 198 tests OK (2 expected failures), every check ok.python3 -m tools.mutants: 33 of 33 mutants killed.make verifypasses in a checkout that holds a nested worktree, which the Stop hook depends on.tests/test_hooks.py, 29 tests:json.pythat must not load;.claude/settings.json;tests/test_tools.pyholdsmake verifyto every test file, the simulation included, throughtools.verify.main([]), and holds both Makefile recipes word for word.git push -u origin "$(git branch --show-current)",gh pr createandgh pr mergeas the Maintainer pass;git -c user.email=… commitis refused; an edit outside the project runs nothing.Closes #7
🤖 Generated with Claude Code
Summary by CodeRabbit