Skip to content

feat(git): review gate before git commit via cora hook verify - #540

Merged
ajianaz merged 1 commit into
developfrom
feat/review-gate-before-commit-v2
Nov 10, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/review-gate-before-commit-v2

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

What

While both cora review tools are attached, a git commit is refused until the staged diff has a validated review, and the refusal tells the model how to get one. Covers the git tool's commit op and run_command / job_start running git 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 --cached in tole. cora-code 0.20.0 already ships this (cora #674): review_finalize leaves a marker bound to a fingerprint of the exact change set, and cora hook verify answers whether the staged diff may be committed (exit 0 validated or nothing to review, 10 reviewed but blocking, 11 not validated). tole asks cora hook verify before 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

  • New review_gate.rs: Gate (inactive until both mcp_cora_cora_review_prepare and _finalize are registered; 15 s timeout, child-env scrub; tooling trouble fails open with one warning), Gated decorator (forwards everything, asks the gate only for a commit), Policy = off | warn | block (default block).
  • Commit recognition: git commit behind env, 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, or env -C/--chdir are refused under block.
  • tool_roster.rs wraps git, run_command, job_start when the policy is not off and MCP servers are attached; TOLE_REVIEW_GATE / global --review-gate; tole doctor prints a gate line.
  • README, CHANGELOG, docs/threat-model.md (new section). Not a config key yet: an untrusted project config could set off; 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 and merge / cherry-pick / am are not recognized; the review is self-review; a human git commit is not gated. Documented in the threat model.

Testing

  • cargo test --workspace, cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings
  • Local cora review --staged: not run (cora is not installed in this environment); the CI Cora Review job is the verdict.
  • 14 unit tests (commit-call parsing including -Cdir and env -C forms, policy, gate against a fake hook 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.
  • Not tested: a real cora 0.20 binary.

Related Issues

Closes #534. Supersedes #539.


Generated by Claude Code

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.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit c9d0f95 into develop Nov 10, 2026
15 of 16 checks passed
@ajianaz
ajianaz deleted the feat/review-gate-before-commit-v2 branch November 11, 2026 04:10
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.

feat(git): review gate before git commit (cora agent-as-reviewer, on by default when attached)

2 participants