Repository navigation
Conversation
While both cora review tools are attached, a `git commit` is refused until the staged diff has a validated review. tole records and hashes nothing itself: it asks cora >= 0.20.0's own commit gate (`cora hook verify`: 0 validated, 10 blocking, 11 not validated), whose marker is bound to the exact change set. Covers the `git` tool's commit op and run_command / job_start running `git commit` (behind env, VAR=x, a path to git, -C/-c). TOLE_REVIEW_GATE or --review-gate = off|warn|block (default block; the flag wins; invalid fails startup; no config key yet so a cloned project cannot weaken it). No review tools attached means no gate; a cora without `hook verify` or one that cannot run fails open with one warning. tole doctor reports it.
|
CI:
If the re-run is green I will leave it at that; if it fails again I will treat it as real and dig in. Generated by Claude Code |
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
…commits (#534) `cora hook verify` reads the staged diff of the repository it runs in, but the gate always ran it in the session directory while recognizing `git -C sub commit`, `--git-dir=...` and `GIT_DIR=...` commits: a validated session repo (or "nothing to review") could unlock a commit into another repository. - `-C <dir>` (each relative to the previous) is now verified in <dir>. - A commit that redirects git's git dir or work tree (--git-dir, --work-tree, GIT_DIR / GIT_WORK_TREE / GIT_INDEX_FILE / ..., -c core.worktree=) has no directory cora can be asked about: refused under block, noted under warn, without asking cora.
|
Cora Review (blocking,
The earlier Generated by Claude Code |
…e commit repo (#534) Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP
|
Superseded by #540: the same change squashed to one commit with no trailers. Message Standard rejected the Generated by Claude Code |
## 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 - [x] `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. - [x] 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](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
…pproval round trip (#543) ## What Fixes the flaky `serve_approvals::approval_allow_round_trip_executes_the_work` (it failed on CI for #539 and #542, both times unrelated to the PR's diff). ## Why After `POST /approvals/{id}/decision` returns `202 resuming`, the test waited for the resumed turn by polling `GET /sessions/{sid}/status` until `busy != true`. Right after the 202 the resume may not have set `busy` yet, so the very first read says "not busy", the loop exits at once, the queue entry already reads `approved`, and the file assertion runs before the replayed `write_file` has landed ("the approved write must have executed"). A "not busy" read proves nothing at that moment. ## Changes - `crates/tole-cli/tests/serve_approvals.rs`: poll for the effect itself (`approved.txt`, up to 10 s), then keep the existing wait for the session to settle. No production code and no assertion weakened: the same checks run, after the condition they depend on. ## Testing - [x] Reproduced under CPU load (6 busy loops on 4 cores), `approval_allow_round_trip` run 25 times in a row: **old code failed 9/25, the fix 0/25**. - [x] `cargo fmt --check`, `cargo clippy -p tole-cli --all-targets -D warnings`, `cargo test -p tole-cli --test serve_approvals` (3 passed). - [ ] Local `cora review --staged`: not run (cora is not installed in this environment); the CI Cora Review job is the verdict. ## Not included: the `tui_e2e` /quit race An earlier CI failure suggested tests send `/quit\r` before the turn is idle (the text would be queued as steering input instead of running as a command), and adding `t.idle()` before `/quit` looked like the fix. I could not reproduce it: 23 runs of the old `tui_e2e` binary under heavier load (8 busy loops, 8 test threads) all passed, so that change is not in this PR. It should be revisited if it fails on CI again, with the failing test name in hand. ## Related Issues Related to #539 and #542 (CI failures that were not theirs). --- _Generated by [Claude Code](https://claude.ai/code/session_01GwJr9GzLbDFeXo3HZHZpyP)_ Co-authored-by: Claude <[email protected]>
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.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 (#536 made sure missions at least see it). Closes #534.
Design change from the issue (please read)
#534 proposed that tole compute a hash of
git diff --cachedand compare it with the diff the model passes toreview_finalize. While readingcora-code0.20.0 (the published crate) I found cora already ships exactly this: its commit gate (cora #674).mcp_cora_cora_review_finalizeleaves a marker bound to a fingerprint of the exact change set under<git-dir>/cora/validations/, andcora hook verifyanswers "may this staged diff be committed?" with an exit code (0 validated or nothing to review, 10 reviewed but blocking, 11 not validated). So tole does not hash or record anything: it askscora hook verifybefore the commit runs. Reimplementing it would have given two definitions of "this diff" that can disagree (cora's fingerprint ignores context size andindexlines; a text hash of the model-passed diff would not).Consequence: the gate needs cora >= 0.20.0 (the general supported floor stays 0.19.0). With an older cora,
hook verifyis a usage error and the gate fails open with one warning.Changes
review_gate.rs(lib):Gate: shared per session, inactive until bothmcp_cora_cora_review_prepareand_finalizeare registered (a gate with no way to get a review would only lock the agent out).check_commit()runscora hook verify --quietin the repo (15 s timeout, child-env scrub) and maps 0 / 10 / 11; anything else (old cora, missing binary, timeout) is "unavailable": one warning, commits proceed.Gated: aTooldecorator that forwards everything and asks the gate only for a commit.Kind::Gitreads{"op":"commit"};Kind::Commandsplits{"command": "..."}with the existingRunCommandTool::split_argvand recognizesgit commitbehindenv,VAR=x, a path to git and git's global options (-C,-c,--git-dir, ...).Policy=off | warn | block(defaultblock).warnlets the commit through with areview_gatenote in the result.tool_roster.rs: when the policy is notoffand MCP servers are attached,git,run_commandandjob_startare wrapped; the gate is activated after the MCP tools register. Server faces have no MCP servers, so no gate.TOLE_REVIEW_GATE/ global--review-gate(the flag sets the env var at startup, so child agents inherit it); an invalid value fails startup. Not a config key yet: a cloned project's.tole/config.tomlis untrusted input andreview_gate = "off"there would switch the gate off; it should join the trust-gated keys in a follow-up.tole doctorprints one line about the gate (policy, whether cora hashook verify).docs/threat-model.md(new section).What it is not
A guardrail for a cooperating agent, not a security boundary (the approver is).
sh -c "git commit", a script, a git alias andmerge/cherry-pick/amare not recognized; the review is self-review by the model that wrote the change; a direct humangit commitis not gated by tole. All documented in the threat model.Testing
cargo test --workspacepassescargo fmt --all -- --checkpassescargo clippy --workspace --all-targets -- -D warningspasses (also theshell-toolsprofile;cargo check -p tole-cli --no-default-featurespasses)corais not installed where this was written); the CI Cora Review job is the verdict.is_git_commitfor 13 spellings that must match and 10 near-misses that must not; policy parsing; the gate against a fakehook verify(inactive or off never runs cora; block refuses 10 and 11 and passes 0; warn notes; old or missing cora fails open once); the decorator gates only commits in both input shapes; the realgittool in a real temp repo refuses an unreviewed staged diff and commits once cora validates it.cora(MCP server for the two review tools plushook verifyfrom an exit-code file) and a real repo: an unreviewed diff is not committed and the model is told why; it commits after validation; a blocking verdict refuses;offandwarndo not refuse and the flag beats the env; no review tools (--no-auto-mcp) means no gate; an invalid policy fails startup;run_command/job_startrunninggit -C . commit --no-verifyare refused (control: the same call commits with the gate off);doctorreports the gate. Mutation checked twice: never activating the gate, and never wrapping the tools, each fail 4 of the e2e tests.cora0.20 (the fake speaksinitialize,tools/listand thehook verifyexit codes documented in cora's source), and cora's marker being written by a realreview_finalizein the repo.Related Issues
Closes #534. Related: #536 and #535 (merged).
Checklist
feat/)developGenerated by Claude Code