Sensors
A sensor is one shell script that runs one project check. Yokai runs them after every coder turn and after Seal, stops at the first failure, and names the script that failed.
What a sensor is
A sensor is a script in .koi/sensors/ that wraps a check your project already has, such as npm run test or cargo clippy. Exit 0 means pass. Together the sensors form the gate, which is green only when every one passes.
Sensors are optional when you use Junji alone. Junji runs the commands in CONTEXT.md › Verification bar directly. Yokai needs reviewed sensors before it runs any phase. Verification on disk explains why.
Example
A Node project with lint, typecheck and tests:
.koi/sensors/
10-lint.sh
20-typecheck.sh
30-test.sh
#!/usr/bin/env bash
set -euo pipefail
# Source: package.json scripts.test; covers unit tests.
exec npm run test
Run one yourself from the repository root, the way Yokai does:
bash .koi/sensors/30-test.sh
The recipe library has scripts for common stacks.
How Yokai runs them
- From the repository root, in filename order. Number prefixes set the order.
- Fail fast during a run: the first non-zero exit stops the gate and is recorded as
failed_sensor, the file name without.sh. - Each script has a time limit,
sensor_timeout_secs(900 seconds by default). - If
.koi/sensors/has no scripts, the run stops before the first agent turn. - During setup's smoke review, Yokai runs every script even after a failure, so you see all results at once.
Getting sensors reviewed
In yokai setup, the Checks step proposes sensors or opens the ones you have.
- Yokai reads your verification bar, repository instructions, CI files and package scripts. For each proposed sensor it shows the source command, what it covers, its working directory and prerequisites.
- You read the exact scripts. Removing an existing sensor needs a stated reason; failing is not one.
- Approve and test runs temporary copies in the selected environment. If every check passes, Yokai saves the whole gate and records fingerprints under
gate_reviewin.koi/yokai.yml. - A script defect (bad syntax, wrong directory, missing tool) goes back for a new proposal. A real product failure stays as it is.
Replaced or removed scripts are kept as hidden .before-review-* backups in the folder. Yokai does not run them.
Editing the verification bar or any sensor invalidates the review. Changing the environment needs a new smoke run of the same scripts.
Rules for writing one
- Wrap a command that exists. Do not invent assertions with
grepor inline test programs, and never write a script that always passes. A missing check is a gap to fix in the project. - Rely on the working directory Yokai sets. Do not compute the root from
$0orBASH_SOURCE; temporary copies live at a different path. Usecd subprojectonly when the command needs it. - Observe, do not change. No installing dependencies, fetching databases, auto-fixing, rewriting snapshots, committing or pushing. Put prerequisites in the sandbox image or prepare the host before review.
- Keep to what the shell supports. macOS Bash 3.2 lacks
${value,,}and associative arrays. - One concern per script.
- No clean-tree sensor. The contract checks the tree, and Build leaves it dirty between turns on purpose.
- No sensors for commit message conventions over all history, or for things that need a human.
What can go wrong
gate red after phase P2 (sensor 30-test, exit Some(1)). Runbash .koi/sensors/30-test.shand fix what it reports.gate review changed or missing. A script or the bar changed. Review again inyokai setup.- A sensor passes on the host and fails in the sandbox. The image lacks a tool. Add it to the Dockerfile and rebuild.
- A sensor times out. Raise
sensor_timeout_secsin.koi/yokai.yml, or split the check.