Verification on disk
An agent can say a phase is finished when it is not. Koi decides with commands that exit 0 or not, a commit that exists or not, and a board card that says done or not.
Why not trust the agent
Agents report success they did not achieve. They skip a failing test, forget to commit, or say "all checks pass" after running half of them. Koi does not argue with the report. It looks at the repository.
Junji and Yokai check the same bar in different ways.
- Junji's
nextruns every command listed underCONTEXT.md › Verification bar, from the directory listed there. Every command must exit 0. If one fails, the phase stays open. The bar is never weakened to pass. - Yokai turns that bar into sensor scripts that a human reviews once, then runs them itself after every coder turn and again after Seal. It never asks the agent whether the checks passed.
The verification bar
/junji plan writes the bar into .koi/run/CONTEXT.md. For Daylist it reads like this:
## Verification bar
Run from the repository root. Every command must exit 0.
- npm run lint
- npm run typecheck
- npm run test
- npm run build
This is the method's definition of done for every phase. Junji needs nothing else. Sensor scripts are optional when you work with Junji alone.
Sensors and the gate
A sensor is one shell script in .koi/sensors/. Exit 0 means pass. A sensor wraps a command your project already has; it does not invent its own assertions.
#!/usr/bin/env bash
set -euo pipefail
# Source: package.json scripts.test; covers unit tests.
exec npm run test
The gate is the combined result: green only when every sensor passes. Yokai runs the scripts in filename order (10-lint.sh, 20-typecheck.sh, 30-test.sh) and stops at the first failure. If there are no scripts at all, the run stops before the first agent turn.
Gate review
Yokai does not run scripts nobody has looked at. During setup it proposes sensors from your bar, CI and package scripts, or opens the ones you already have. You read each script, then choose Approve and test. Yokai runs temporary copies in the selected environment (host or sandbox) and saves the whole gate only if every check passes.
Approval is stored as fingerprints in .koi/yokai.yml:
gate_review:
version: 2
bar_sha256: 3f1c…
scripts:
10-lint.sh: 9ab2…
30-test.sh: 41de…
environment_sha256: c07e…
Yokai checks these fingerprints again when it runs the gate. Editing the verification bar, or adding, editing or removing a sensor, invalidates the review and sends you back to setup. Changing the environment (host or sandbox, the image, the Dockerfile, the setup hook) needs a fresh smoke run of the same scripts, not new scripts. Unrelated edits to other CONTEXT.md sections do not invalidate anything.
What closes a phase
After Seal, the supervisor checks the contract. All four facts must hold.
The order matters. A card that did not advance is retried once; a second miss is a stall. A missing commit, a red gate or a dirty tree goes to recovery or halts. "Clean" counts only paths that were dirty before the supervisor ran the gate, so a test that rewrites a cache file does not break the contract.
What a failing check means
A red sensor is information about the product, not a broken setup. Yokai keeps failing checks as they are.
- Setup never weakens or deletes a check to get a green result. Removing a sensor needs a stated reason, and failing is not a reason. Replaced or removed scripts are kept as hidden
.before-review-*backups. - A required check the repository does not have is reported as a gap. Add the real check as separate work, often as a bootstrap phase, then return to setup.
- Approving a gate that runs correctly but is red records your review. It does not make readiness green and does not let any phase complete.
Rules for sensor scripts
- Run from the repository root. Yokai sets the working directory; do not derive it from
$0orBASH_SOURCE, because temporary copies live elsewhere. - Observe and fail. A sensor must not install dependencies, fetch databases, fix code, update snapshots, commit or push.
- One concern per script. Prefix with numbers when order matters.
- Mind the shell. macOS ships Bash 3.2, which lacks
${value,,}and associative arrays. - Do not add a clean-tree sensor. The contract already checks the tree, and Build legitimately leaves it dirty between turns.
What can go wrong
- Every phase halts with a red gate. Run each script by hand, for example
bash .koi/sensors/30-test.sh, and fix the failure it shows. gate review changed or missing. Someone edited the bar or a script. Openyokai setupand review the checks again.- A check passes on your machine and fails in the sandbox. The image lacks a tool the command needs. Add it to
.koi/Dockerfile.sandbox, rebuild, and run the smoke review again. - The agent edited a sensor to make it pass. Turn prompts forbid changing the bar, sensors or review metadata during unattended work, and the fingerprint check catches the edit at the gate.
See Sensors for writing scripts and the recipe library for examples.