Trust model
Why configuration is read at the trust anchor, where the anchor comes from, and what a change can and cannot do to its own review.
On this page
The problem
A reviewer that reads its configuration from the change it reviews can be switched off by that change. A pull request could add fail_on = "never", ignore its own files, or carry a comment telling an AI reviewer that the code is approved. CodeVeto is built so that none of this works: the change under review is only ever data.
The trust anchor
Every review has a trust anchor: a commit the reviewed change cannot have produced. CodeVeto reads the repository's .codeveto.toml, and the .gitignore rules of worktree mode, from Git objects at that commit. It never reads them from the working tree, the index or the change.
| Mode | Compared | Config read from |
|---|---|---|
range (--base, CI) |
merge base, or base with --comparison direct, to head |
the merge base or base, or --anchor |
commit (--commit) |
parent to commit | the parent, or --anchor |
staged (--staged) |
HEAD to a private copy of the index |
the local anchor |
| worktree (default) | the local anchor to the working tree | the local anchor |
The JSON report records target.anchor and target.anchor_source.
Where the anchor comes from
For staged and worktree reviews, CodeVeto takes the first of these that applies:
anchor_source |
Anchor |
|---|---|
explicit |
The commit given with --anchor: a full 40- or 64-character commit ID. |
upstream |
The merge base of HEAD with @{upstream}, when the upstream is a remote-tracking branch (refs/remotes/*). A local branch as upstream is skipped. |
origin-head |
The merge base of HEAD with the branch refs/remotes/origin/HEAD points to, when that lies in refs/remotes/origin/. |
head |
HEAD itself, with a note that repository config is unprotected. An unborn HEAD anchors at the empty tree. |
Range reviews report base and commit reviews parent, unless --anchor is given (explicit).
Only explicit resists a process that can write to .git. Remote-tracking branches are local files too, so an agent with a shell could move them. The report and the text header say so for upstream and origin-head anchors, and for head:
note: anchored at HEAD, which the change itself can produce: repository config and ignore rules are unprotected (pass --anchor with a commit captured earlier)Passing --anchor
Capture the commit before the work you want reviewed starts, and pass it as a full ID:
anchor=$(git rev-parse 'HEAD^{commit}')
# ... the agent or the work session changes the repository ...
codeveto review --anchor "$anchor"--anchor takes only a full commit ID. A branch name, a short ID, a tag or a tree is refused. codeveto mcp and the agent hook recipes capture the anchor once at session start and pass it on every review; no tool call can move it. See Local and agents.
What a change cannot do to its own review
- Change the configuration. Its
.codeveto.tomlis not applied. Editing it raisesagent/reviewer-config-changed; making it less strict raisesagent/reviewer-config-weakened, which blocks and cannot be waived by the repository. See Changing the config in a change. - Waive its own findings. An inline ignore counts only when its comment line is unchanged from the anchor and inline ignores are enabled by user config or the command line. An added or edited ignore is reported as proposed and raises
agent/suppression-added. - Hide files from the rules. Ignore rules in worktree mode come from the anchor's
.gitignorefiles. A change to.gitignoreorinfo/excluderaisesagent/ignore-rules-changed, and files ignored only by a changed rule are still reviewed.@generatedmarkers and.gitattributesnever change a file's class. - Instruct the reviewer. Repository text is evidence, never instructions. It is never put into the AI system prompt or used to choose behaviour. Comments aimed at AI reviewers raise
agent/reviewer-directive, hidden and reordering Unicode raisesagent/hidden-unicode, and an AI finding must quote a changed line exactly or it is dropped. - Run code. CodeVeto never executes project code, tests, builds, Git hooks, filters or package managers. Git runs with a scrubbed environment and no repository config, and objects are read through a private repository and hash-verified.
- Edit its own gate. In CI the workflow job comes from the base branch (
pull_request_target), and a change to a workflow that runs CodeVeto raisesagent/codeveto-workflow-changed. - Fake a clean result. Anything that could not be checked makes the review
incomplete(exit 2). Output is sanitized, so a hostile path or message cannot forge terminal colours, GitHub workflow commands or Markdown links.
Non-waivable rules
Six rules protect the review itself:
| Rule | Catches |
|---|---|
agent/reviewer-config-weakened |
A change that makes .codeveto.toml less strict. |
agent/reviewer-directive |
Instructions to an AI reviewer in comments or hidden text. |
agent/hidden-unicode |
Bidi controls, tag characters and other hidden or reordering characters. |
agent/suppression-added |
A suppression added by the change next to a finding. |
agent/codeveto-workflow-changed |
A change to a workflow, template or hook that runs CodeVeto. |
secrets/private-key |
A private key. |
Repository config cannot disable or downgrade them; trying is a config error. It may only path-ignore them for fixture paths that start with a literal directory or file name and match none of .codeveto.toml, workflow files, agent configuration files and CODEOWNERS. Every such ignore is listed in the report's config_notes and the text header. They can never be ignored inline. User config and command-line flags are not restricted: the person running the review decides.
Bypassable and enforcing
Local checks are conveniences. git commit --no-verify and git push --no-verify skip Git hooks, and an agent with a shell can edit or delete hooks, settings and scripts. Use them to catch problems early.
The enforcement point is the CI job, made a required check:
- the job definition comes from the base branch (
pull_request_targeton GitHub and Forgejo), so a pull request cannot edit its own gate; - it never checks out, installs or runs anything from the pull request; the head is fetched as Git data and verified against the event's head SHA;
codeveto / reviewis a required status check, and.github/workflows/is protected with CODEOWNERS or a ruleset.
Reviewing in CI has the setup.