Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

docs: how to install the hook and run either tier of the eval set

Rach Pradhaneca109de8621
diff --git a/AGENTS.md b/AGENTS.md
index 1b523b18..859aa79c 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -6,3 +6,46 @@
- When a change would push a file past 600 LOC, split cohesive responsibilities into focused sibling modules as part of the same change.
- If a touched file is already over 600 LOC, do not grow it; move it toward the limit before adding more behavior.
- Generated files, vendored dependencies, lockfiles, and machine-produced artifacts are exempt; change their generator or source instead of hand-editing them.
+
+## Tests must be reachable
+
+- `zig build test` only runs the tests in files the test root pulls in. A new module's `test {}` blocks compile to nothing until something references it, and the suite still reports green.
+- A new test-bearing module needs a reference in `src/main.zig`'s `test {}` block: `_ = @import("your_module.zig");`.
+- Prove it with the count, not with hope: the suite total must go up by the number of tests you added. `scripts/eval-tier1.sh --only reach` fails on any file that declares tests nothing imports.
+
+## Before you push
+
+Install the tracked hooks once, and the checks run themselves:
+
+```bash
+scripts/install-hooks.sh
+```
+
+That points `core.hooksPath` at `.githooks/`, whose `pre-push` runs **tier 1** of the internal eval set: `zig fmt`, the 600-line ceiling, test reachability, `zig build`, the unit suite plus a count that may grow and never shrink, the named goal/loop/todo invariants, and SDK drift. It is deterministic and offline (no provider calls, no network, no spend) and takes about 20 seconds warm. A push that only touches docs skips it.
+
+```bash
+scripts/eval-tier1.sh # run it by hand
+scripts/eval-tier1.sh --only sdk # rerun one check
+scripts/eval-tier1.sh --list # the check names
+git push --no-verify # emergency skip (GRAFF_SKIP_PREPUSH=1 also works)
+```
+
+Failures name the invariant, say which regression it guards, and print the command that reruns only that check. The required invariants and the docs-only path list are data in `scripts/eval/tier1-manifest.json`.
+
+Two rules the hook enforces that are easy to trip:
+
+- **The suite count is a ratchet.** If it drops, either restore the tests or lower `test_count_baseline` in the manifest in the same commit, with a reason in the message.
+- **The SDKs are generated, not written.** Run `python3 sdk/generate.py --harness ./zig-out/bin/graff` after any change to the model catalog, tool schemas, or provider list, and commit the result.
+
+## Tier 2: model-backed behavior
+
+Behavior regressions do not show up in a unit suite. **Tier 2** runs the harness for real, so it is opt-in and never in the hook. Cases are data in `evals/harness_behavior.jsonl`, one line each, carrying the regression it guards. The model is scripted (`scripts/eval/mock_model.py`), so the default run is offline and free.
+
+```bash
+python3 scripts/eval-tier2.py # every case
+python3 scripts/eval-tier2.py --list # the cases and what they guard
+python3 scripts/eval-tier2.py --only <id>
+python3 scripts/eval-tier2.py --dump <id> # every event and request from one case
+```
+
+Add a case when you fix a behavior bug: script the model replies that provoke it, then assert on the events the harness emitted or on what it sent back to the model. Run it against a real provider with `--provider`/`--model` when you care how the model behaves rather than how the harness does.
diff --git a/README.md b/README.md
index c1ae4e68..7f247f0e 100644
--- a/README.md
+++ b/README.md
@@ -1174,6 +1174,66 @@ and the GitHub issues for what's in flight:
---
+## Working on codegraff
+
+Install the tracked git hooks once:
+
+```bash
+scripts/install-hooks.sh
+```
+
+From then on, every push runs **tier 1** of the internal eval set. It is
+deterministic and offline (no provider calls, no network, no spend) and takes
+about 20 seconds warm:
+
+| check | what it holds |
+| --- | --- |
+| `fmt` | `zig fmt --check src build.zig` |
+| `lines` | the 600-line ceiling on hand-written Zig |
+| `reach` | every file that declares tests is reachable from the test root |
+| `build` | `zig build` |
+| `tests` | `zig build test`, and a suite count that may grow but never shrink |
+| `invariants` | the named goal/loop/todo tests actually ran, not just compiled |
+| `sdk` | the committed SDKs still match `graff --schema` |
+
+A push that only touches docs skips the whole thing. When a check fails it names
+the invariant, says which regression it guards, and prints the one-liner that
+reruns only it:
+
+```bash
+scripts/eval-tier1.sh # everything
+scripts/eval-tier1.sh --only sdk # one check
+scripts/eval-tier1.sh --list # the check names
+```
+
+If you need to push past it, `git push --no-verify` (or `GRAFF_SKIP_PREPUSH=1
+git push`). CI runs the same checks and more, so the hook is a fast local
+opinion, not the last word.
+
+**Tier 2** is the model-backed half, and it is not in the hook because it runs
+the harness for real. The cases live in `evals/harness_behavior.jsonl`, one line
+each, carrying the regression it guards: a goal writes a checklist and finishes
+it, an empty `todo_write` changes nothing, a compaction keeps the items already
+completed, `--max-tool-calls` actually stops the run. The model is scripted, so
+the default run is offline and free:
+
+```bash
+python3 scripts/eval-tier2.py # every case, scripted model
+python3 scripts/eval-tier2.py --list # the cases and what they guard
+python3 scripts/eval-tier2.py --dump <id> # everything one case did
+python3 scripts/eval-tier2.py --provider anthropic --model claude-sonnet-4-6
+```
+
+Two checks exist because the unit suite could not see the failure. `reach` walks
+the `@import` graph: Zig only runs tests in files the root pulls in, so a
+split-out module nobody references compiles to nothing and the suite still
+reports green. `invariants` goes further, rerunning the suite under
+`-Dtest-filter` to prove the named tests executed, because a test can sit in the
+source and never run. Both are configured as data in
+`scripts/eval/tier1-manifest.json`.
+
+---
+
## License
codegraff is licensed under a **modified GNU AGPL-3.0** (see [`LICENSE`](LICENSE)).