Repository navigation
feat(git): review gate before git commit via cora hook verify - #540
Merged
Merged
Conversation
Wrap git, run_command and job_start so a git commit is first asked of cora's own commit gate (hook verify). Policy off|warn|block via TOLE_REVIEW_GATE / --review-gate, default block; fails open on tooling trouble with one warning. Commits aimed at another repo (-C, --git-dir, env -C) are verified there or refused.
10 of 11 tasks
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
While both cora review tools are attached, a
git commitis refused until the staged diff has a validated review, and the refusal tells the model how to get one. Covers thegittool'scommitop andrun_command/job_startrunninggit commit. Supersedes #539 (same change, squashed to one commit because the old branch had a commit trailer the Message Standard check rejects and history cannot be rewritten here). Closes #534.Why
AGENTS.md makes a review of the staged diff mandatory before every commit, but an agent session could commit without ever reviewing; the review flow was guidance only.
Design change from the issue
#534 proposed hashing
git diff --cachedin tole.cora-code0.20.0 already ships this (cora #674):review_finalizeleaves a marker bound to a fingerprint of the exact change set, andcora hook verifyanswers whether the staged diff may be committed (exit 0 validated or nothing to review, 10 reviewed but blocking, 11 not validated). tole askscora hook verifybefore the commit runs instead of defining "this diff" a second time. Needs cora >= 0.20.0; with an older cora the gate fails open with one warning.Changes
review_gate.rs:Gate(inactive until bothmcp_cora_cora_review_prepareand_finalizeare registered; 15 s timeout, child-env scrub; tooling trouble fails open with one warning),Gateddecorator (forwards everything, asks the gate only for a commit),Policy=off | warn | block(defaultblock).git commitbehindenv,VAR=x, a path to git and git global options. The commit is verified in the repo it targets (-C dir,-Cdir); commits redirected by--git-dir,--work-tree,GIT_DIR-style env,core.worktree, orenv -C/--chdirare refused underblock.tool_roster.rswrapsgit,run_command,job_startwhen the policy is notoffand MCP servers are attached;TOLE_REVIEW_GATE/ global--review-gate;tole doctorprints a gate line.docs/threat-model.md(new section). Not a config key yet: an untrusted project config could setoff; follow-up to make it trust-gated.What it is not
A guardrail for a cooperating agent, not a security boundary (the approver is).
sh -c "git commit", scripts, aliases andmerge/cherry-pick/amare not recognized; the review is self-review; a humangit commitis not gated. Documented in the threat model.Testing
cargo test --workspace,cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warningscora review --staged: not run (cora is not installed in this environment); the CI Cora Review job is the verdict.-Cdirandenv -Cforms, policy, gate against a fakehook verify, decorator, real git tool in a temp repo) and 8 e2e tests with the real binary, scripted provider, fake cora and a real repo; mutation checked.Related Issues
Closes #534. Supersedes #539.
Generated by Claude Code