Repository navigation
Description
What problem does this solve?
tole attaches the cora mcp surface automatically when cora is on PATH, and the system prompt of run / chat / tui tells the model how to review a diff (mcp_cora_cora_review_prepare, judge it itself, then mcp_cora_cora_review_finalize). But nothing makes the agent do it:
- The prompt text only says how ("To review a change: ..."); it is not an obligation.
--on-turnendstop gates are off by default, and mission--verifyis empty by default.- The
gittool'scommitop (Write) has no review precondition.
AGENTS.md makes cora review --staged mandatory before every commit for humans and agents alike, yet an agent session can commit without ever reviewing. There is no pre-commit hook by default either.
Proposed solution
A host-level precondition on the git tool's commit op (in tole-cli, not tole-core, which stays platform-agnostic):
- A commit is refused unless the session holds a recorded
review_finalizeverdict withshould_block == falsefor the current staged diff. - Binding: tole computes the hash of
git diff --cacheditself and compares it with the diff the model passed toreview_finalize(tole sees the call). The model cannot claim a verdict for a different diff, and any later change to the index invalidates it. - The refusal message tells the model exactly what to do: get
git diff --cached, callreview_prepare, judge, callreview_finalizewith the same diff, then retry the commit. - Verdicts are recorded as a session register (append-only JSONL stays untouched; a verdict is a new register write) and cached per diff hash, so recommitting the same index does not pay again.
- Policy:
--review-gate off|warn|block, config keyreview_gate. Defaultblockwhen both review tools are attached,offotherwise. Whencorais missing or older than 0.19, skip with one startup warning (probe-first, never a phantom gate), consistent with the "cora error is non-blocking" rule in AGENTS.md. - Headless missions use the same policy; a
should_block == trueverdict ends in a refused commit, not a hung turn. - Small diffs: open question whether docs-only or tiny diffs need the gate.
Honest limits
This is a review by the same model that wrote the change: the gate guarantees the process ran on this exact diff, not that the judgement is good. It adds token cost per commit. It does not replace the independent CI Cora Review job.
Open questions
- Default
blockvswarnfor the first release. - Threshold for skipping trivial diffs (docs-only, N lines).
- Should the gate also cover
ghwrite ops once they exist? - What if
review_finalizereturns findings butshould_block == false: surface them in the commit result so they are not lost?
Alternatives considered
- Rely on
cora hook install(a git pre-commit hook): works for human commits but uses the BYOK review, not agent-as-reviewer, and does not exist in agent sandboxes. - A generic
--on-turnendgate: fires at the end of the turn, after the commit already happened.
Acceptance criteria
- With the review tools attached, a
git commitwithout a verdict for the staged diff is refused with an actionable message (test with a fake review server). - A verdict for diff A does not unlock a commit of diff B; changing the index after finalize invalidates it (tests).
-
should_block == truerefuses the commit and shows the findings. -
offand missing/old cora behave as specified; one startup warning, no phantom tool. - The gate cannot be bypassed by a different tool path to
git commit(run_commandalready refuses git-shaped escapes; verify and test). - Docs: README,
docs/threat-model.md,tole doctorreports the gate state.
Related: #531 (run_command ergonomics) for the bypass check.
Activity
fix(git): verify a `git -C <dir> commit` in <dir>; refuse redirected …
fix(git): handle attached -C<dir> and env -C/--chdir when locating th…
feat(config): review_gate config key, project can only tighten (#534) (…