# Verification

Source: https://www.zerd.si/docs/verification

zerd verifies an AI code change by running the project's own checks on the files that changed, telling you whose failure it is, and catching breakage your tests cannot see.

## Checks on the files that changed

After edits, zerd picks checks for the changed files only, never a whole build:

- `pytest` for the tests that import the changed module, found through an import graph
- `go vet`, `cargo check`, `eslint`, `promtool`
- `docker compose config` for infra YAML
- your own `verify_commands` and per-path `[[verify_rules]]`

## Whose failure is it?

When a check fails, zerd swaps in the pre-run copy of your files, runs the same check again, and puts the agent's files back.

If the same error shows up on the clean copy, zerd reports "was already failing before your change; leaving it alone". The agent is not sent to fix what it didn't break, and the run ends `unverified` instead of `verified`.

If the failure is new, it goes back to the agent as a repair request, up to 2 rounds, and then escalates to the strong model.

```mermaid
flowchart TB
    E["Agent edited files"] --> S["Snapshot diff: what THIS run changed<br/>not edits you already had in flight"]
    S --> P["Pick checks for only those files"]
    P --> RUN["Run checks"]
    RUN -->|all pass| OK(["verified"])
    RUN -->|some fail| BASE["Swap in the pre-run copy of the files,<br/>run the failing checks again,<br/>put the agent's files back"]
    BASE --> Q{"Same errors on the<br/>clean tree?"}
    Q -->|"yes, and they don't name a changed file"| OLD["Already broken before you started<br/>leave it alone, say so, end unverified"]
    Q -->|no| NEW["The run broke it"]
    NEW --> REP["Repair request with the real output<br/>do not weaken a test to pass"]
    REP --> RUN
```

## The signature guard

Checks show that the code runs, but they can't see a caller outside this repo. The guard compares each changed Python and JS/TS file with `HEAD` and flags:

- a dropped parameter
- a newly required parameter
- reordered positionals
- a removed `*args` or `**kwargs`
- a function that is no longer exported

For example, if `unique_by()` stops accepting `seen`, the agent is sent back once to keep old calls working. It was added after a real miss in [round 1 of the benchmarks](/docs/benchmarks).

## Every edit is checked as it lands

Each edit result lists any problems that edit introduced. Old and new text are both checked, and anything already there is ignored. The checks are:

- Python syntax and `ruff`
- JSON and TOML parsing
- `node --check`
- `gofmt`
- TypeScript: your project's own `tsserver`, kept running, so type errors show up in the same turn, under a second after the first call

## Edits need a fresh read

An edit is refused if the file:

- exists but the agent hasn't read it this session, or
- changed on disk since the agent read it.

A small file comes back inside the refusal, so the retry needs no extra round.

If you edit a file in your editor mid-run, the agent is told and re-reads rather than overwriting you.

## Citation check

Every `path` and `path:line` in the final answer is looked up in the real tree. An invented file, or a line past the end of one, goes back for one correction, and whatever is left is shown as a warning. The check is a few dozen lines of code with no model call.

It produces the `citations: 4 checked, 0 unverified` part of the final status line.
