greenbelay
A guard that reads a shell command before Claude Code runs it, and can observe it, advise against it, or refuse it.
It exists because of a class of mistake no git hook can see, since the mistake is in the command string and never reaches a hook at all:
git push origin main 2>&1 | tail -5
A pipeline's exit status is the status of its last command. tail succeeds
at tailing an error message, so a rejected push, a push killed by a timeout,
and a push that never left the machine all report success — and the trimming
discards the error text too, so the failure is silent in both channels.
greenbelay (formerly amont-agent) is a PreToolUse hook. It is a single binary, it is opt-in, and
it phones nothing home.
The shape of it
Three stances, and the middle one is the point:
| stance | effect |
|---|---|
observe | records the firing and says nothing at all |
advise | puts the reason into the model's context; refuses nothing |
deny | refuses the tool call, with the reason and the remedy |
Of the 40 rules, three ship as deny, twenty-four as advise and thirteen as
observe. A rule is promoted only once your own transcripts say it should be
— see measuring and graduating — and greenbelay rules shows
the stance in force on your machine.
Start here
greenbelay install # prints the settings block, writes nothing
greenbelay install --write # merges it into ~/.claude/settings.json
greenbelay doctor # is it installed, runnable, and actually firing?
greenbelay status # every rule, its stance, and what it has seen
# (last 4 weeks + this week once the roll-up covers them)
greenbelay rollup # firings per week and rule, kept past the journal
The inbox read contract
At a session start with source startup or clear, greenbelay's session
notice reads <git-common-dir>/greenharness/inbox.md and every
inbox.*.filing file beside it (an abandoned take), and moves nothing.
Documentation version token: inbox-read/1 (lines carry no token).
Each line is <YYYY-MM-DD> <session8> [due=YYYY-MM-DD] <text>. An orphan is a
line dated two or more local calendar days before today, or any line of a take
whose modification time is more than 24 hours old. The filer moves the inbox to
inbox.<id>.filing and then touches the take, so its modification time is
the time of the move: a take moved without that touch keeps the time of the
inbox's last append, and may be read as abandoned too early. A younger take is
counted as lines being filed and not shown. Only orphan and fresh lines count
as unfiled. Other lines, malformed ones included (session
?), are fresh. The block follows the clear-at-boundary stance: observe
journals the counts and prints nothing.
When the session's directory is not inside a git repository (neither it nor
any ancestor holds a .git entry), the notice looks instead at the directories directly under it whose .git is a real directory
(symlinked children and linked worktrees are skipped) holding
.git/greenharness/. Each match is journalled under the child's name. At most
three children with unfiled lines (orphans or fresh; a child with only lines
being filed is neither shown nor counted) are printed in name order, each
notice preceded by in <name>: cd <path>, followed by one line,
greenbelay/inbox: N more repositories hold unfiled lines: a, b, c, …; start a session in one to see them (1 more repository holds when N is 1), for the
rest. A child whose name is not valid UTF-8 or contains a control character is
skipped. Inside a repository, or below a .git entry, nothing changes.
Relationship to amont
amont is a git-hook manager by the
same author. The two are independent: neither needs the other, they share no
code, and cargo tree here shows serde and serde_json and nothing else.
They meet in exactly one place, and it is optional. If amont is installed and
this repository carries its generated AGENTS.md block, a session opening on
a stale block is told so — see the session notice. With
no amont on PATH, that check says nothing.
Relationship to greensummit
greensummit is the CI end of the same story: amont signs a note at pre-push naming the gates that really ran, and greensummit verifies it so CI can skip them. It has no connection to this guard beyond the author and the conviction all three share — trust what was verified, never what was reported. The masked push at the top of this page is what that looks like when it fails.
Installing
The binary first, then the wiring. They are separate acts on purpose: a
program that can refuse the commands your agent runs should not install itself
into your settings.json as a side effect of you fetching it.
The binary
curl -fsSL https://raw.githubusercontent.com/greenharness/greenbelay/main/install/install.sh | sh
irm https://raw.githubusercontent.com/greenharness/greenbelay/main/install/install.ps1 | iex
Either one downloads a release binary, verifies it against the published
SHA256SUMS, and puts it in ~/.local/bin. Neither wires anything in.
Or: brew install fredericrous/tap/greenbelay, cargo install greenbelay,
or a binary straight from
Releases — Linux
x86_64 (gnu and static musl) and aarch64 (gnu), macOS (Intel and Apple
silicon), and Windows x86_64.
Upgrading from amont-agent
greenbelay was called amont-agent until 4.0.0. The installers and the
formula also place amont-agent beside greenbelay, as a copy of the same
binary, so hook entries written for the old name keep firing after the
upgrade. With Homebrew, the upgrade goes through the tap's rename, and
Homebrew trusts only the formula you named, so trust greenbelay first:
brew trust --formula fredericrous/tap/greenbelay
brew upgrade fredericrous/tap/amont-agent
Without the brew trust, Homebrew stops with "Refusing to load formula
fredericrous/tap/greenbelay from untrusted tap". Then move the hook entries
to the new name once:
greenbelay install --write # replaces the amont-agent entries, adds no second set
greenbelay doctor
cargo install greenbelay places no amont-agent copy. The amont-agent
crates stay at 3.35.0. Release 5.0.0 also renames the names the tool reads
and writes (the ~/.claude/greenbelay/ directory, greenbelay.* git config
keys, GREENBELAY_* variables) and moves this machine's data once; see
migrating to the new data names.
The installers read GREENBELAY_BIN_DIR and GREENBELAY_VERSION; the old
AMONT_AGENT_BIN_DIR and AMONT_AGENT_VERSION still work, with a warning.
Why there is no npm package
There was one, briefly, and removing it is the more useful answer than listing install methods.
install bakes the ABSOLUTE path of the running binary into
settings.json, deliberately: a PATH-resolved command exits 127 into
Claude Code's non-blocking bucket the moment PATH differs, which disables
the guard with nothing to notice it. npm cannot supply a stable absolute
path. Under npx the binary lives in npm's _npx cache, which npm garbage-
collects; under a project-local npm i -D it lives in one project's
node_modules, while the guard it configures is machine-global — so
rm -rf node_modules in one repository would silently disable the guard for
every session on the machine.
amont has an npm package for a reason that does not transfer: it is a
per-repository tool, and npm i -D amont plus a prepare script means the
hooks travel with the repository. This is per-developer machine
configuration — ~/.claude/settings.json, global git config, a journal in
~/.claude/. Nothing about it belongs to a project.
Every channel above hands install a path that stays put.
The wiring
greenbelay install # prints the settings block, writes nothing
greenbelay install --write # merges it into ~/.claude/settings.json
install refuses to guess. It will not patch a settings.json it could not
parse, and it will not write one whose formatting it cannot reproduce — a diff
full of reformatting hides the one line it added — so it prints the block and
changes nothing unless --reformat says otherwise. uninstall removes exactly
what it wrote and leaves everything else byte-identical.
greenbelay install --write --project # .claude/settings.json instead
greenbelay install --write --local # .claude/settings.local.json
Four kinds of entry are written: the guard on PreToolUse, for Bash and for
the file tools; the assertions on PostToolUse for Bash, which check what a
command that reported success actually did; a PostToolUse entry for Read,
which remembers a file only once it has actually been read; a
PostToolUse entry for the LSP tool, which records the files each agent asked
LSP about (code-read-not-lsp stays silent on a later Read of them); and a
SessionStart entry that leaves a heartbeat and states where the checkout
stands against the remote. Without the heartbeat, doctor cannot tell "nothing
fired this week" from "the guard has been dead since Tuesday".
Your settings.json keeps the mode it already had, and a file created here
starts at 0600: it can hold MCP environment blocks, and those hold
credentials.
Knowing it is alive
Claude Code hooks fail open quietly: a command that cannot be resolved exits
127, which is a non-blocking status, and nothing tells you. doctor exits
non-zero when the guard is inert, so it can run from cron:
✓ installed in /Users/you/.claude/settings.json
✓ greenbelay 4.0.0 at /Users/you/.local/bin/greenbelay
✓ a refused command produces a valid decision document
✓ last ran 4m ago
✓ acting on pipe-to-tail
greenbelay doctor --json prints one JSON document on stdout instead:
healthy (the same verdict as the exit status), findings (a list of ok,
advisory, line and detail), and integration, which is reported apart
from health: state is present, partial, absent or unknown (a settings
file exists and could not be read), with settings_file and binary (null
when no entry was found) and missing, the hook entries this version installs
that are not there. doctor --help prints its usage and exits 0.
Where no plan-review-* or implementation-review agent is installed (not in
the Claude config agents/, the repository's .claude/agents/, or any
installed plugin), the plan-panel and implementation-review rules cannot be
satisfied. They then say so once, with grh install workflow as the remedy,
instead of holding the call, and only where they would otherwise have refused:
a review found in the transcript or already remembered is honoured as before.
An agents directory or plugin manifest that cannot be read counts as installed.
Turning it off
GREENBELAY_OFF=1 # this shell only
git config --global greenbelay.enabled false # everywhere
greenbelay uninstall --write # remove the settings entries
Demoting one rule is almost always the better move than switching the guard off — see stances. A guard that is hard to back out of is one people uninstall instead of demoting, and uninstalling takes every rule with it.
Migrating to the new data names
greenbelay 5.0.0 renames its data names: the GREENBELAY_* variables, the
greenbelay.* git config keys, the greenbelay state directories, the
greenbelay-*-v1 schemas and the clear-relay@greenbelay plugin.
The first greenbelay command after upgrading (a hook, or any subcommand except
migrate and doctor) migrates the machine once, under a lock. A hook never
waits for the lock and is never blocked or refused by the migration.
What moves
- The two state roots,
~/.claude/amont-agentand<state home>/amont-agent, are each renamed togreenbelay, with a symlink left at the old path. - The
amont.agent.*git config keys are renamed in the files that hold them. Includes are followed whether or not their condition holds. Each key is copied, verified and only then removed. - The clear-relay plugin registration in
settings.jsonand its marketplace file.
Markers
Three files in the Claude config directory record the state:
| file | meaning |
|---|---|
greenbelay-migrated | the migration finished; hooks stop checking |
greenbelay-migrate-reversed | --reverse ran; a hook never migrates forward while it exists |
greenbelay-migrate-failed | a step failed; it holds the step and what to fix |
The command
greenbelay migrate [--reverse] [--dry-run]
An explicit run waits up to 30 s for the lock. --dry-run changes nothing.
--reverse puts everything back, rewriting 5.0 journal and ledger rows to the
old names, and leaves nothing at the new paths.
Until the migration is done
- Until the done-marker exists, a hook still reads an old
amont.agent.*key when its new twin is absent. The new key wins when both exist. After the marker exists the old keys are ignored. - Old environment variables are no longer read.
greenbelay doctorlists each one that is set, with the name to set instead. - Old journal rows, review rows and committed
.casesfiles are still read until the old names are retired. - The installers accept
AMONT_AGENT_BIN_DIRandAMONT_AGENT_VERSIONwith a warning; the new names areGREENBELAY_BIN_DIRandGREENBELAY_VERSION.
Claude Code keeps its own plugin registry (plugins/installed_plugins.json and
plugins/known_marketplaces.json under the Claude config directory).
greenbelay never changes it and never runs claude; migrate, install and
doctor read it, and when it does not match the clear-relay plugin that
settings.json registers they print the claude plugin commands to run
(doctor as a failing finding, since the plugin stays off until they are run).
The commands always go to stderr; migrate --dry-run and install without
--write print them as would then need: lines, and a dry run with nothing
to move but a registry to fix says nothing to move rather than nothing to do.
Stances
A rule does one of three things, and the middle one is the point:
| stance | effect |
|---|---|
observe | records the firing and says nothing at all |
advise | puts the reason into the model's context; refuses nothing |
deny | refuses the tool call, with the reason and the remedy |
observe and advise are not two ways of saying "not blocking yet".
additionalContext enters the model's context and therefore changes its
behaviour, which contaminates the rate the observation exists to measure. A
rule that talks is intervening. That is why the two are named differently
and why backtest numbers from an advise rule are not comparable with the
numbers that justified promoting it.
That contamination is also what makes it measurable. greenbelay backtest --compliance reads the two stances against each other: what a model did
after an advise fired, beside what it did after an observe fired and
said nothing. The second is the rate the habit corrects on its own, and an
advise that does not beat it is costing context tokens for nothing. See
measuring and graduating.
Changing one
Takes effect on the next command; nothing to restart.
git config --global greenbelay.pipe-to-tail.stance observe
git config --global greenbelay.stance observe # every rule
The ladder, most specific first:
rule.default_stance < greenbelay.stance < greenbelay.<id>.stance
then capped at the rule's own ceiling, and clamped to observe if the guard
is switched off.
Ceilings
Every rule declares the loudest stance it may ever take. For most rules that
is deny, and the ceiling changes nothing. A rule whose finding is an
estimate — "this loop may make hundreds of requests" — is capped at
advise: refusing a command on an estimate would claim a certainty the
analysis does not have.
The cap is applied after every configured key, so neither
greenbelay.stance deny nor the rule's own key can pass it, and
graduate --to deny refuses a capped rule with the reason. greenbelay rules prints each rule's ceiling beside its stance.
push-browser-check ships at advise with a ceiling of deny; where the
browser-check agent is not installed, under deny it says so as advice
and holds nothing (the push browser check).
Raising a stance for named agents
greenbelay.<id>.denyAgents lifts one rule from advise to deny for the
subagent types it lists, and leaves every other agent, the main conversation
included, at the configured stance. It never raises observe (a switched-off
guard, a shadow session, a rule set to observe), and the rule's ceiling still
applies. symbol-grep-not-lsp is the only rule that reads it.
The refusal is told once per pattern and agent (grep <pattern> @<agent id>),
so a parent session that was already advised on a pattern does not stop its
worker's refusal. Every other stance keeps the session's grep <pattern> key
unchanged. A refusal whose record cannot be written falls back to advise and
is journalled unrecorded, because refusing every retry would break the
promise in the refusal text: the same search again runs.
Why git config and not a committed file
Promotion power stays on the machine, with the person. A rule that a committed
file could promote to deny would mean cloning a repository hands it the
power to refuse your shell commands.
This is enforced three times, because neither of the first two was enough.
greengate.conf's parser will not name these rules, so a committed manifest cannot reach them.- amont's config reader lets a repository's committed policy
setlines outrank system and global git config — right for a hook manager, wrong for a guard — so this project reads git config itself, without that ladder. - Git's own search order ends at
--localand--worktree, and the last file wins. A.git/configtherefore outranked your--globalanswer without any of amont's machinery being involved — and the agent whose command was just refused can write one, sincegit configis not a command any rule here objects to. So the reader takes--global, then--system, and nothing else.
A stance answers to your own git config and to nothing a repository carries or
a process standing in one can write. A file your global config includes or
includeIfs counts as your own: git skips those for a scoped read unless asked,
and this reader asks. graduate and demote write --global
for the same reason.
One consequence worth stating plainly: git config greenbelay.<rule>.stance
run inside a repository writes --local by default, and this tool will not
read it. Pass --global, which is what every example here does.
The rules
| rule | ships as | what it catches |
|---|---|---|
pipe-to-tail | deny | a mutating command whose status is swallowed by a pipe |
bare-stash-pop | observe | git stash pop with no ref, where refs/stash is shared across worktrees |
cd-carries-over | advise | a Bash call that runs in a directory an earlier call of its own parallel batch moved the shell to with a top-level cd or pushd (the shell is no longer where the batch's first call ran, and the harness does not announce a carry between siblings); use (cd X && …), git -C X or absolute paths |
gh-pr-merge-auto | observe | --auto on a repository with no required checks, which merges immediately |
block-reinstate | deny | an agent running greenbelay block reinstate, which lifts the revocation of a reviewed block and re-admits its copies; the person runs it in their own shell |
publish-without-skill | advise | a v* tag pushed or a pull request merged with no call of the tag-release / merge-when-green skill in this turn or the one before, so the procedure ran from memory |
forge-merge-by-hand | advise | merging a pull request by POSTing to the forge's merge endpoint, which answers 200 whether the checks passed, failed or never started |
no-verify | observe | turning the whole commit gate off rather than one check |
git-add-broad | observe | staging the tree instead of the change |
stale-base | advise | a branch or worktree started from a checkout the remote has moved past |
push-preflight | advise | a git push whose slow pre-push test gate has not been rehearsed with amont rehearse --wait |
push-preview | advise | a push that would publish interface changes no approved localhost preview covers, unless the plan the person approved declares the evidence is enough (preview approval) |
plan-review-panel | deny | a plan presented at ExitPlanMode before its expert review panel ran (the review panel) |
plan-names-no-paths | advise (max advise) | a plan presented at ExitPlanMode whose ## Phases name no file in backticks, so its panel was seated from every area of its repositories instead of the file types it touches; the advice names each phase that names no file (the review panel) |
clear-at-boundary | advise (max deny) | a turn ending at a boundary (a worktree removed, a sweep.py --apply, a plan commit) with nothing in flight and the main chain's context past 200k tokens; deny sends a Stop continuation asking for the handoff and one line starting with the marker safe to /clear, advise sends a note to the person naming the reply that asks for the handoff line, except at a lone plan commit, where plan-phases-open carries the plan on, observe journals only; a boundary under background work, relais in flight or an unclean repository is kept as pending and advised at the first idle Stop after it; at most 3 advices per session, then silence journalled watched cap. Its size kind (ADR-0083): past size-tokens (400k) a Stop with nothing in flight hands off mid-phase at the size stance (size-stance, default observe until live evidence graduates it), at any phase fact and in a continued turn, held only by background work or relais in flight; a command boundary past 400k is answered at the stricter of the rule's stance and the size stance; once per turn and per 100k step, at most 3 per session, journalled size fired <N>k, size held background|relais, size cap |
plan-phases-open | deny | a turn ending while the plan this branch carries still has an open phase that is not a 🧑 decision: — the agent is sent on to it |
implementation-review | advise | a push of a branch that carries a plan, whose diff no independent reviewer has read for the tree being pushed (the implementation review) |
push-browser-check | advise (max deny) | a push of interface changes whose tree no browser-check agent of this session, or of one of its side transcripts, has looked at; a landed approved plan declaring ## Browser check → none: <reason> passes (the push browser check) |
ask-unopened-page | deny | an AskUserQuestion naming a local page (localhost URL, file:// URL, .html path) that no greenbelay open showed the person since the last answered question about it; without a readable transcript it advises |
foreground-poll | advise | a polling loop or gh run watch in the foreground, where the tool's ten-minute clock will kill it one poll short |
unbounded-background-push | advise | a git push sent to the background with its output kept in a file and no timeout, so the pre-push gate inside it can run for as long as it likes with nothing ending it or reporting it |
gui-open-unbounded | advise | a macOS app launch (open -a <App>, open <x>.app) with no timeout, sent in the background; silent on platforms where open is not a launcher: measured to hang twice on 2026-10-14, and the chain after it never ran |
sed-in-place | advise | sed -i spelled for the other sed (-i '' on GNU, bare -i on BSD) |
kubectl-gitops | advise | an imperative kubectl write in a repository Flux or Argo reconciles |
tag-after-commit | advise | git tag chained onto a git commit that a hook may have refused |
chain-with-and | observe | an edit, add or test joined by ; to a commit, push or test that runs even when it fails |
release-tag-push | observe | pushing a v* tag, which publishes: the tag may name the wrong commit, and a green workflow does not mean the artefact is right |
worktree-remove-force | advise | git worktree remove --force on a worktree that still holds uncommitted work |
amend-pushed | advise | git commit --amend on a commit the remote already has |
branch-force-delete | observe | git branch -D on a branch whose commits are on no remote and not merged |
worktree-isolation | observe | a branch created, or git reset --hard, in the primary checkout of a repository that already has linked worktrees |
stdin-hang | observe | a command that will read standard input with nothing on it — cat > file, a bare interpreter, tee outside a pipe — which blocks silently until the tool's clock runs out |
glob-in-flag-value | advise | an unquoted glob inside a flag value (--include=*.ts), which zsh expands — or fails on — before the program sees it |
glob-no-match | advise | an unquoted glob operand that matches nothing, which under zsh aborts the clause before it starts while a later clause reports success |
equals-separator | observe | a bare word beginning with = (echo ===, [ x == y ]), which zsh reads as a command lookup and whose failure aborts the whole command list |
unsplit-expansion | observe | an unquoted $var under set -- or for … in, which zsh leaves as one word: the positionals or the loop get the whole string and the command runs wrong while reporting success |
path-operand-missing | advise | a read of a path that is not there — under the grep shim a warning in mid-stream, for the coreutils one line and carry on — which the chain then reports as success |
workspace-root-write | deny | an output redirect or tee target that lands directly in a workspace root (a directory in no git tree that holds several repositories), where the file belongs to no repository, is never shown by git and is never swept; the refusal names the linked worktree this session works in, or its scratch directory |
stat-bsd-format | advise | stat -f '%…' on GNU stat (or -c on BSD), which prints a filesystem report where a timestamp was wanted |
pkill-option-after-pattern | deny | an option after pkill/pgrep's pattern (pkill -f "x" -n), which BSD pkill reads as another pattern and signals everything it matches — on 2026-11-25 every terminal tab; silent where pgrep -V names procps, which permutes its arguments |
whole-file-dump | advise (ceiling deny) | a file poured whole into the tool result by cat/sed -n/head — 31% of all result bytes measured — where the Read tool would have windowed it. At deny only a whole dump of a regular file over 8 KB is refused, once per agent and file (normalised path), saying the same command repeated will pass, and that retry is let through, journalled allowed-after-feedback; a bounded read or a smaller file stays advised, and a refusal that cannot be remembered advises instead (unrecorded). Feedback to the agent, never a prompt |
persisted-output-dump | advise | reading back whole a tool result the harness saved to a file for being too large, paying for it twice |
file-reread | advise | a Read, or a cat, of a file this session already has in context and that is unchanged on disk since — answered from the session's own record (one per agent, exact windows, certain or uncertain; a compaction clears the main one), not the command |
read-unbounded-large | advise (ceiling deny) | a Read with no offset/limit of a file over 8 KB, where the whole file lands in the context and every later turn carries it; plan files, diffs and every read by a reviewer agent (implementation-review, code-review-*, plan-review-*, interface-review, relais reviewers) are exempt. At deny it refuses once per agent and file (normalised path), saying the same Read repeated will pass, and lets that retry through, journalled allowed-after-feedback; when the refusal cannot be remembered (no usable session or agent id, a failed write) it advises instead, journalled unrecorded, so the promised retry is never refused. Feedback to the agent, never a prompt |
code-read-not-lsp | advise (ceiling deny) | a Read with no offset/limit of a code file over 4 KB (.rs .go .py .ts/.js) that fleet-lsp serves, where documentSymbol and goToDefinition answer in a few lines; once per file per agent per session (every time at deny, until LSP is asked), and read-unbounded-large stays quiet while it speaks. A Read of a file the same agent already asked LSP about (a PostToolUse LSP hook records each call, and the files its answer names, per session and agent; an Error performing answer counts) gets no LSP advice and is journalled lsp-first (read-unbounded-large still speaks past 8 KB); at deny the refusal names documentSymbol and says the Read passes once LSP was asked or if LSP errors. Silent without fleet-lsp on PATH, with the plugin off, outside a git working tree, for an agent whose tools lack LSP, and on files read-unbounded-large exempts |
secret-read | advise (max advise) | a read of a secret file by a reader (cat head tail sed bat more less nl grep rg ugrep awk xxd od strings base64 jq, or a cp whose source it is), by the Read tool, or by a Grep in content mode: ~/.ssh/* but not *.pub, known_hosts or config; ~/.netrc, ~/.npmrc, ~/.aws/credentials, ~/.docker/config.json, ~/.kube/config, ~/.config/mtls/*.key, ~/.claude/.credentials*; .env and .env.* (not .example, .sample, .template), .envrc; and a .key or .pem that holds a PRIVATE KEY. The file must exist. Advised once per path and agent across the three tools, and the call still runs: the rule never denies and graduate refuses to raise it. A pipe or redirect does not exempt a reader; quiet forms (grep -q, -l, -c, rg --files), curl, ssh, ls and sed -i are silent, and so is a reader whose stdout goes to /dev/null; a reader redirected to another path is advised as a copy. Limits: with two secret operands only the first is advised; a directory (grep -r token ~/.ssh) is silent; an unreadable file fails open and is not advised; a nested $(cat …) is not covered. The journal holds the kind and the path, never the command |
symbol-grep-not-lsp | advise (ceiling deny) | grep/rg/git grep, or the Grep tool, searching code for an identifier-shaped pattern (camelCase, PascalCase, snake_case, or after fn/def/class…), where workspaceSymbol and findReferences find the definition and its uses; once per pattern per session. Silent on a pipe filter, -c, -v, -i, -f, several -e, comment markers (TODO), text files, $VAR paths, and in the same places as code-read-not-lsp |
screenshot-in-main-session | advise (ceiling advise) | a chrome-devtools take_screenshot from the main conversation with no filePath: the image (~126 KB) enters the main context, so the advice is to delegate the check to the browser-check subagent; once per session. Silent for a subagent (any agent_id) and for a call with a filePath (the image is saved, not attached); observe journals take_screenshot @main and stays silent; a deny stance still advises |
relais-run-forks | advise (ceiling deny) | a relais run change run that would fork a worktree of its own: cwd is the primary checkout (workspace absent, auto, fork or isolated), or a linked worktree with fork or isolated; the advice is to start a worktree-task worktree and leave workspace unset in it. Advises every time. Silent for kind inspect/verify or a task the hook cannot read (journalled kind_unknown), workspace: "in-place" or an unknown workspace, and a cwd outside a repository or missing (not_a_repo), bare (bare), or a failed probe (probe_failed); observe journals relais run <primary|second> <workspace> and stays silent |
agent-preferred-model | advise (ceiling deny) | an Agent or Task launch of a bare subagent_type whose definition (<repo>/.claude/agents/<type>.md, else <config dir>/agents/<type>.md) says model: inherit and preferred-model: X, when the call carries no model and the prompt's first line does not start with model-fallback:; the advice is to pass model: "X". Silent for a namespaced plugin:name type, an explicit model of any value, and a definition that is missing, not a regular file, over 8 KiB or without closed frontmatter; plugin directories are never read |
lint-suppression-added | advise (ceiling deny) | an Edit, MultiEdit or Write that adds a lint suppression (# type: ignore, # noqa, eslint-disable, @ts-ignore, #[allow], //nolint) or loosens a lint configuration (tsconfig, eslint, pyright, ruff, Cargo [lints], golangci), where general.no-disabled-safety says to fix the finding instead; the file is compared before and after by marker, not by line |
agent-guidance-written | advise (ceiling advise) | an Edit, MultiEdit or Write to agent guidance (SKILL.md, CLAUDE.md, CLAUDE.md.tmpl, AGENTS.md, MEMORY.md, .claude/agents/*.md, dot_claude/agents/*.md), where the guidance.* and prose.* rules apply (ADR-0026, ADR-0032) and greentopo relevant --path <file> lists them; told once per session and file (per agent), later writes are journalled only. Other memory files are exempt |
agent-guidance-shape | advise (ceiling advise) | a write that leaves a SKILL.md without disable-model-invocation: true and without a one-line description: that says when to use it — a Use <word> … or whenever … clause (guidance.pointer-names-when), or grows a CLAUDE.md, CLAUDE.md.tmpl, AGENTS.md or MEMORY.md past 8,192 bytes (guidance.always-on-is-an-index; a ratchet: shrinking or equal size passes). Judged on the rebuilt whole file only; a fragment is journalled and silent; told once per session and file |
work-overlap | advise (ceiling advise) | a session's first Edit, MultiEdit, Write or NotebookEdit in a repository, when another session's latest activity line names the same repository and that session was last seen less than the window ago (2 h; git config greenbelay.work-overlap.window, e.g. 90m). Names the other session, its worktree, its branch, the title of the active plan its branch added when there is one (none for a peer on the default branch), and how long ago it was last seen, and the remedy greenbelay board --repo <repo>; told once per session and repository, counted only once a live peer is found (a first write that meets nobody does not use it up; under observe the journalled firing counts), silent for the session's own activity. Answered from the session activity records, not the command (the board). The other session is named by its owner record when it has one: name and ref beside the UUID, SendMessage to that name when it is live, "cleared since, do not credit it" when its process has cleared |
work-owner | advise (ceiling advise) | never from a command: the owner records (owners). A session's first write claims its worktree, an observed relais programme claim its ticket; a resume <repo> <programme> <ticket> prompt is told who owns the ticket, whether that owner is live or cleared, and the owner's own process after a /clear takes it over; a push or land is credited to its session only on publication evidence. Journals each lookup with its state |
greenspotter-written | advise (ceiling advise) | an Edit, MultiEdit or Write (a PostToolUse, once it has succeeded) of a .rs, .ts, .tsx, .go or .py file in a repository that vendors greenspotter's check row (decisions ADR-0044). The repository is the git root of the FILE's directory, not the payload cwd; the gate is open only when amont list --json run there prints amont-list-v1 listing the check id pre-commit-greenspotter-check, trusted or not (amont lists an untrusted row with no command), asked once per session and repository, with a 5 s deadline. It then runs greenspotter check --json -- <path> (GREENBELAY_GREENSPOTTER names another program), killed at 1 s, and advises each finding as path:line:col: rule-id: message with one greentopo rule <id> line per rule and how to waive (greenspotter: allow <rule-id> -- <reason>). Journal: each finding as rule path text (advised, or watched under observe, which says nothing); greenspotter-slow on each kill; greenspotter-unavailable, greenspotter-exit-2, greenspotter-exit-3, greenspotter-exit-other, greenspotter-unparsed, amont-list-failed and amont-list-unexpected once per session, never shown to the agent |
test-output-trimmed | advise (ceiling deny) | a test, lint or typecheck runner (cargo test, pytest, npm run test, tsc, …) piped into tail/head/grep while pipefail is not definitely on, so a failing run exits 0 and the trimming can cut the failure off. The shell analysis tracks pipefail as yes/no/maybe, including zsh setopt/unsetopt and set -o nopipefail; only a definite yes exempts. Evidence: 33.7 per 1000 calls (2,790 of 82,857, greenbelay backtest --rule test-output-trimmed --since 2026-09-11, measured 2026-10-11; weekly 20.1 to 53.4, flat 4 weeks) |
heavy-build-unqueued | advise (ceiling advise) | a readable Bash clause that runs a heavy build or test (the test-output-trimmed runners, plus cargo build, cargo check, xcodebuild, swift build) outside the host slot queue: not wrapped as amont slot run -- <cmd>, amont run <check> or amont rehearse, and slot run --now (greengate 5.0; the older --on-timeout=run too) counts as unqueued. Confirmed only when GREENHARNESS_HOST_SLOT is unset (greengate 3.x's AMONT_HOST_SLOT is not read) and amont --version on PATH is 1.62.0 or newer (probed once per session, 1.5 s deadline). The advice names amont slot run -- <cmd>, its 90 s --max-wait, exit 75 (not launched), --now as the deliberate way past a stalled line, and amont slots; amont's slot files are never read |
Two more checks run after a command rather than before it, on PostToolUse:
push-landed and push-published verify what a push that reported success
actually did, and home-fingerprint-drift (advise) says which watched home or
repository config file a test or build run changed. See
the assertions.
greenbelay rules prints this with each rule's measured firing rate, and
with the stance in force on this machine rather than the shipped one: a rule
you promoted in ~/.gitconfig reads deny (ships as observe), and a rule
with a ceiling names it, (max advise).
Why only four of them deny
pipe-to-tail blocks because seven consecutive weeks of measurement showed no
downward trend while every other habit halved. That is the bar: a rule earns
deny from your own transcripts, not from an argument about how bad the
mistake is. A habit the model is already correcting does not need a deny.
See measuring and graduating.
plan-review-panel is the other kind of deny, and the person's choice
rather than a measurement: it fires on ExitPlanMode, not on a shell command,
and checks a fact — whether the review panel the plan calls for ran on the plan
being presented — naming the missing roles when it did not. After two refusals
of the same plan, or whenever it cannot check, it hands the call to the person
as ask instead. See the review panel.
plan-phases-open is the third, also the person's choice. It fires on
Stop, the moment the agent ends its turn. ADR-0022 makes a plan one branch
and one pull request with its phases as commits, so a turn that ends with
a phase still open is a stall, not a handoff. The rule reads only the
active plans changed on the current branch (against the merge-base with
the remote default branch), never one already on main, and sends the agent
on to the first open - [ ] under ## Phases. It is silent when that
phase is a 🧑 decision:, in plan mode, while background tasks are still
running, and when the agent's last message has a line starting with
WAITING: <reason> (a preview awaiting approval, a deferred phase, a
blocker). After three continuations on the same phase in one session it lets
the turn end and tells the person, with a note only they see; their next
prompt resets the count. Anything it cannot establish — no repository, a git
failure, an unreadable plan, a session id it will not use as a file name —
lets the turn end. To turn it off without uninstalling:
git config --global greenbelay.plan-phases-open.stance observe.
clear-at-boundary fires on the same Stop. A turn that reached a boundary
(git worktree remove, sweep.py --apply, or a docs(plan): commit that is
not a closing one) with the transcript's last main-chain context at 200,000
tokens or more, no relais run still waiting on the session (read from the
transcript only; greenbelay never runs relais), clean repositories and
nothing unpushed outside docs/plans/, gets one note to the person with the
reply to give: "hand off now". The note says the agent hands off by itself at a
boundary (the worktree-task skill's Handoff section) and ends with that line.
At deny, the agent is sent on once, pointed at that Handoff section, to end
with safe to /clear; next: <the first prompt>; without the skill, the message
still spells out that line. It ships at advise: its
backtest advised 25 of 31 compacted sessions before their first compaction
(the bar was 28), and 46 of 140 advices were followed by an editing turn (the
bar was at most 10%). deny waits on the Outcome counts. It stays silent in
plan mode, with background tasks, when the last message asks a question, has a
WAITING: line or already says safe to /clear, and once per boundary. At a
lone plan commit past 200k its Continue comes before plan-phases-open, which
then stays silent for the rest of the turn; at advise it is silent there and
plan-phases-open carries the plan on. To send the agent on:
git config --global greenbelay.clear-at-boundary.stance deny. Rollback:
git config --global greenbelay.clear-at-boundary.stance observe.
The size kind (ADR-0083) hands off mid-phase. A Stop whose context is at
greenbelay.clear-at-boundary.size-tokens or more (default 400,000; a value
below 200,000 or one that does not parse is reported on stderr and reads as
400,000), with no background task and no relais run in flight, is answered at
the size stance even when the turn reached no command boundary, in a Working
phase, and on a Stop of a turn a hook continued. The clean-repository and
nothing-unpushed tests do not apply: mid-phase, uncommitted edits in the task
worktree are the normal state and the handoff lists them. The size stance,
greenbelay.clear-at-boundary.size-stance, ships at observe: the 30-day
replay (greenbelay size-replay, 2026-11-24) fired 2.71 times a day, but 13
of 84 fires (15.5%, the bar is at most 10%) came while a task launched
outside the replayed transcript was still running, which a transcript alone
cannot show. To send the agent on:
git config --global greenbelay.clear-at-boundary.size-stance deny. At deny the agent is sent on
once, to open its answer with a line for the person, write a ## Handoff that
starts mid-phase at <N>k, commit it alone as docs(plan): handoff <phase>
(which is never a command boundary), file no inbox lines, and end with
safe to /clear; next: \resume …`; plan-phases-openthen stays silent for the rest of the turn, at any phase. Atadvisethe person gets a note; atobserveit journals only. It fires once per turn, again only at each further 100k, at most 3 times per session. Past the size, a command boundary is answered at the stricter of the rule's stance and the size stance, so a size kind atobservenever quiets it; below it the command kind is unchanged.$GREENBELAY_OFF, greenbelay.enabled=false, the shadow arm and an explicit observeingreenbelay.stanceorgreenbelay.clear-at-boundary.stanceforce the size stance toobserve; the rule's compiled advisedoes not lower it. Each size decision is also kept, for 30 days and apart from the journal's rotation, insize-evidence/beside the journal;greenbelay size-evidence
[--days pairs each handoff request with the clear-relay'ssubmitline within 2 h: a session with no relay log is an unheeded request (the relay writes one only once it arms), and only an unreadable relay directory or log counts as missing evidence. A day file that cannot be written is journalledwatched size-evidence-unwritable. Rollback: git config --global greenbelay.clear-at-boundary.size-stance observe`.
The clear-relay Claude Code plugin, which install --write places, acts on
that line. When the main agent's answer ends with
safe to /clear; next: `<prompt>` (one line, at most 2,000 characters), it
shows a toast and a status line and waits 10 seconds. If nothing is typed, no
prompt is submitted and no turn starts, it runs /clear and submits the
prompt in the new session. Typing anything or running /stay keeps the
session. It relays at most once per 2 minutes and never retries: a refused
step shows a toast with the prompt, for pasting. Each arm, disarm, clear,
submit and failure goes as one JSON line to
<state dir>/greenbelay/clear-relay/<session>.jsonl, the plugin's
stateDir setting, which install sets. A submit line carries named:
the ticket a resume <repo> <programme> <ticket>: … prompt names, as
{repo, programme, ticket} (the ticket as relais prints it, the stem of its
file), or null for any other prompt. Lines written before 2026-11-19 have no
named key. A safe to /clear; parked: … line has no prompt and is never
relayed. To turn the relay off, set the plugin's
enabled setting to false; at stance observe no continuation asks for the
line, so the relay has nothing to act on; at advise it acts only when the
person asked for the handoff.
workspace-root-write is the fourth, and ships at deny straight away
instead of walking the observe, advise ladder. The evidence is on disk, not in a
rate: 86 *.log and *.err files in ~/Developer/Perso, none of them in a
repository, none swept, none traceable to a task, and the refusal carries a
one-word fix. examine reads only the shape (a write redirect or a tee
operand with a literal target); confirm establishes the fact, that the
directory the clause runs in, after its cds, is in no git tree and has at
least two children with a .git. The system temp directories are never roots.
The remedy names the linked worktree the session touched last, but only when
git check-ignore says a file of that name is ignored there (an untracked log
would hold worktree-sweep forever), and otherwise the session's scratch
directory, which worktree-sweep --scratch clears. To demote it to a record:
git config --global greenbelay.workspace-root-write.stance observe.
stale-base advises from the start because it refuses nothing, speaks only
after measuring a real gap, and names a failure no correcting loop can see —
nothing fails when you build on stale code. The work is correct against
the code it can see, and the conflict arrives later, from somewhere else. So a
session opening in a checkout the remote has moved past is told — see
the session notice for why it fetches and never pulls.
push-preflight advises for the same reason. git opens its connection to the
remote before it runs pre-push and holds it idle for as long as the test
gate takes; a remote that closes idle sessions kills the push after the gate
has already passed, and the model reads "the network" where the cause was the
gate's placement. With amont ≥ 1.28, amont rehearse --wait runs the same
gate on a snapshot of HEAD with no connection open — or follows the
rehearsal amont.rehearseOnCommit already started — and stamps the tree, so
the push that follows skips the suite (amont run pre-push on 1.27). The rule
speaks only when confirm finds all three facts: amont guards this
repository's pushes, a test gate would run for this push, and HEAD's tree
carries no stamp yet.
Shape, then the world
Most rules after the first handful came out of the transcripts the same way —
tens of thousands of Bash calls, sorted by what failed, was killed, or drew a
correction (see mine).
Each fires on shape and, where the fact lives in the world, confirms it first:
whether the call already runs in the background, which sed is on PATH,
whether the repository holds a Flux or Argo resource, whether the worktree is
dirty, whether the remote has the commit, whether any other branch has the
commits. A rule that fires on shape alone, like tag-after-commit, names a
failure every command in the chain reports as success.
pipe-to-tail in full
git push origin main 2>&1 | tail -5
A pipeline's exit status is its last command's. tail succeeds at tailing
an error message, so a rejected push, a push killed by a timeout, and a push
that never left the machine all report success — and the trimming discards the
error text, so the failure is silent in both channels.
The remedy the rule prints is not "don't use tail": it is to run the mutating
command on its own, read its output afterwards, and then verify the effect
(git ls-remote origin refs/heads/<branch>) rather than the exit code.
set -o pipefail first, or writing to a file and tailing the file, are also
accepted — the rule fires on the shape, and the reason names all three ways
out.
Asking about one command
greenbelay check 'git push | tail -1'
No stdin, no session, no journal entry — just the rules over one string, with whatever they would have said.
The assertions
A rule reads a command before it runs. An assertion checks what a command that already reported success actually did.
The two halves are not the same job. pipe-to-tail can refuse
git push … | tail -5 because the mistake is visible in the command string.
Nothing in a command string tells you that the push you just ran reported
Everything up-to-date about a branch you were not on.
| id | fires on | asks |
|---|---|---|
push-landed | git push | is the branch on the remote, at the commit you have? |
push-published | git push to a UI repository | did it publish a new commit, and was it an approved preview? (records only; see preview approval) |
land-retry | amont land, successful or failed | did the land push the commit the review and preview judged, or a retry nobody judged? Read from the land's receipt, never the tracking ref |
bug-nudge | a check runner that failed (PostToolUseFailure), or printed a failure while exiting 0 | did the agent load diagnosing-bugs before it ran more commands? Advise only, once per session |
home-fingerprint-drift | a test, lint or build run (cargo test, pnpm test, cargo build, …, also behind amont slot run -- or greenbelay quiet --) or a binary run out of target/debug/ or target/release/, successful or failed; --help, --version, --list and --no-run are exempt | did it leave the watched home and repository config files as they were? Advise; see below |
Successful calls, with three exceptions
Claude Code sends a failed tool call to PostToolUseFailure. Everything the
other assertions see claimed to work, which is the whole point: a command that
returned an error is already in front of the model, and there is nothing
invisible left to point out.
bug-nudge is the second. A red check runner is the one failure the model may
not read as a bug to diagnose, so it runs on PostToolUseFailure too. It asks
for the diagnosing-bugs skill once per session, and never blocks.
land-retry is the first exception. An amont land retries once when its pre-push
hook moves HEAD, and a land that then ends unverified or not-observed exits
non-zero after the remote accepted the push, so it also runs on
PostToolUseFailure. It compares the sha PreToolUse judged (recorded for every
repository) with the land's receipt (amont 1.54.0): another sha landed is said
as an unreviewed push, another sha unverified or not-observed as a possibly
unreviewed one; a refused, unreachable or interrupted land published nothing.
No record, no receipt or more than one is journalled as retry-check skipped.
home-fingerprint-drift is the third: a red test run can change a home file
as surely as a green one.
Home fingerprint
Before a command home-fingerprint-drift fires on runs in the foreground,
PreToolUse takes a fingerprint of a few files and keeps it under the
journal's directory, in previews/home/<tool_use_id> (private, pruned after
24 hours: an interrupted command gets no PostToolUse). The PostToolUse, or
PostToolUseFailure, of the same call takes it again and names each file that
changed:
greenbelay/home-fingerprint-drift: Changed while `cargo test` ran:
/Users/me/repo/.git/config (modified)
An edit made at the same time, by you or another session, shows too.
Inspect each file (`git config --list --show-origin` for git config);
the snapshot keeps hashes, not contents, so compare with your dotfiles
source or a backup. If this command changed them, restore them and rerun
it with HOME and XDG_CONFIG_HOME set to a scratch directory.
When every entry is not checked, the heading reads Could not check while … ran: instead. A record left by a command that got no PostToolUse (it was
interrupted, or refused at a prompt) stays up to a day.
The watched set is the one relais watches around a run (its homeprint.rs;
no code is shared): ~/.gitconfig, $XDG_CONFIG_HOME/git/config (else
~/.config/git/config), ~/.netrc (and ~/_netrc on Windows),
~/.claude/settings*.json, ~/.claude/plugins/installed_plugins.json and
known_marketplaces.json, every file under ~/.ssh but known_hosts*, and
the repository's shared .git/config (found on disk as git finds it: the
nearest .git, a .git file's gitdir:, then commondir, so a linked
worktree watches its main repository's; outside a repository it is not
watched). ~ is HOME, else
USERPROFILE; ~/.claude is CLAUDE_CONFIG_DIR when set. ~/.config as a
whole is not watched: caches rewrite it all day.
A fingerprint holds hashes, never contents: sha256, size and (on unix) mode
bits of each regular file, a symlink by its target (never followed). A file
over 1 MiB is fingerprinted by its size and modification time, never read. FIFOs,
sockets and devices are never opened. A directory counts at most 500 files in
byte order; past that the change list ends with (not checked: over 500 files), shown only beside a real change. A file readable on one side only
prints (not checked: unreadable). A record another greenbelay version wrote
is not compared. Paths under HOME print as ~/… on unix,
others as absolute paths.
It is advise-only and cannot refuse. It prevents nothing and restores nothing: it is the detection net for the 2026-11-15 test run that rewrote the real home's git config and Claude plugin files, and nothing failed.
An assertion cannot refuse
The tool has already run. A deny stance therefore speaks exactly like
advise, the same way it does at a session opening.
What an assertion can do is state a fact:
greenbelay/push-landed: `git push` exited 0, but origin/main is at d0765d4f9
while the local branch is at 8970c7ffb. The push did not land. Run the push
again on its own and read its output, then confirm with `git ls-remote`.
That is not advice to weigh. It is the remote's answer.
What it refuses to judge
push-landed handles the unambiguous shapes and nothing else. A
HEAD:refs/heads/other refspec, a tag push, several refspecs at once,
--delete, --mirror, --all: each needs a different question asked of the
remote, and a confidently wrong accusation costs the channel its credibility —
which is the only thing the channel has.
The same goes for everything it cannot establish: a detached HEAD, a remote given as a URL, a working directory that has gone, a remote that cannot be reached without a password. All silence.
It can never prompt
Hooks run with no controlling terminal, so a credential prompt does not fail —
it hangs, and it hangs the session rather than this process. Every child runs
with GIT_TERMINAL_PROMPT=0, GIT_ASKPASS/SSH_ASKPASS disabled, ssh in
BatchMode, and a five-second deadline. A guard installed to make pushing safer
must never be the reason a push becomes impossible.
Measuring
examine is pure, so the backtester replays it like any rule:
$ greenbelay backtest push-landed --since 2026-07-06
push-landed 1007 38.7 routine observe
Read that number correctly. For a rule, a firing is a mistake caught. For an
assertion, a firing is a question asked — 1,007 pushes in 29,758 Bash calls,
about one call in twenty-six paying for one git ls-remote. It speaks only when
the answer disagrees, which is far rarer.
How often a claim is actually broken is not backtestable at all: verify
touches the world, and the world has moved since those commands ran. That number
accumulates forward, in the journal:
$ grep push-landed ~/.claude/greenbelay/journal.log
held is a push that landed, broken one that did not, unverified one this
crate declined to judge.
Measuring and graduating
This is the part that makes the rest defensible. Every rule's stance is a claim about your own behaviour, and the claim is checked against your own transcripts rather than asserted.
The loop is: mine → backtest → explain → review → compliance → graduate.
0. Mine — what is going wrong that no rule names?
Every step below prices a rule somebody already thought of. mine is the
step before that: it groups the transcripts by command shape and ranks the
shapes that went wrong.
greenbelay mine --since 2026-08-15
greenbelay mine --min-support 10 --min-rate 0.4
greenbelay mine --format cases >> crates/greenbelay-guard/tests/corpus/<new-rule>.cases
A shape is the parsed command with its literals masked — the branch, the path, the line number and the commit message taken out, the program, the verbs and the flag set kept:
git push origin feat/mine 2>&1 | tail -5 ─┐
git push origin fix/lint 2>&1 | tail -20 ─┴→ git push origin <word> 2>&1 | tail -5
A call counts as gone wrong when either of two things the transcript records is true:
- failed — the tool result carried
is_error: a non-zero exit, a refused permission, a run the harness killed; - corrected — a near-identical command followed within a few tool calls. A model that re-issues the same shape is a model whose first attempt did not land, and that is the interesting half: the mistakes worth a rule are the ones nothing reports.
Only the HEAD of a run of near-identical calls counts as a correction. A
polling loop is one decision repeated twenty times, not nineteen mistakes —
before that rule existed, the top line of the real report was echo waiting.
bad and rate are suspicion, not verdict. A shape re-run for good
reasons carries a high rate and names no mistake at all. That is why every
row prints its samples and why the next step is a person reading them.
Shapes an existing rule already fires on are listed apart, covered by <rule>, rather than proposed — and a covered shape that is still going wrong
is a rule that is observing when it should be advising.
What mine does not do is write the rule. Nothing learned here reaches
the hook: the path is mine → write the rule by hand → cases → corpus check → graduate, and what ships is the hand-written rule with its reason, its
remedy and its reviewed corpus. A guard that refused a command because a
clustering run found it suspicious could not explain itself to the person
whose work it just refused.
1. Backtest — what would this have cost me?
backtest replays your Claude Code transcripts through the rules and reports
firings per 1,000 tool calls per week, so a rule's cost is a number rather
than an impression.
greenbelay backtest --since 2026-07-06
greenbelay backtest --rule pipe-to-tail --json
greenbelay backtest --transcripts ~/.claude/projects # where they live
The roll-up: firings the journal no longer holds
The journal keeps about three days. greenbelay rollup prints what survived
rotation: one row per week and rule, week rule firings calls rate/1000, for
the current week and the last closed one; --weeks <n> widens it and --json
prints every week (format greenbelay-rollup-v1; retro reads it for the rules
whose replay is none).
greenbelay rollup
greenbelay rollup --weeks 4 --json
greenbelay rollup --transcripts ~/.claude/projects -q
calls is the week's count of the tool the rule fires on (Bash, Read, or all
tools for a rule that fires on several), counted from the transcripts,
subagents included. A closed week's calls are stored the first time they are
computed, within a week of closing, and never rescanned, because Claude Code
prunes old transcripts. A rule with no honest tool (a Stop event, an
assertion) and a week not stored print -: unknown is not zero. Counts start
at the first fold; nothing before it comes back, so the first week may be
marked (partial).
A weekly series is the thing to read, not a total. A habit that is halving on
its own does not need a deny; the model is already correcting. A flat line
over weeks is a habit that will not correct itself, and that is what promotion
is for.
A replay counts what a rule's examine matches in Bash calls, and that is a
rule's live count only for some rules. --json labels each rule:
"replay": "exact": the replay counts what the hook would have counted;"replay": "none", withreplay_why:not-shell: the rule fires on another tool or event, which the replay does not read, so it shows 0;live: only the live session decides, so it shows 0;confirmorverify: the hook checks the world at the time, so the replay counts every shape match, confirmed or not.
Only an exact row is a weekly count. To recount one week of one rule, give
the week's Monday (UTC):
greenbelay backtest --rule pipe-to-tail --since 2026-11-09 --json \
| jq -r '.version as $v | .rules[] | select(.replay=="exact") | .id as $r
| .weeks[] | select(.week=="2026-11-09")
| "\(.week) \($r) \(.fires) \(.calls) \(.per_1000) v\($v)"'
The matchers are today's (version): the same week recounted after a
release may differ.
2. Explain — look at the actual matches
A rate is only trustworthy if the matches behind it are real. explain prints
every match for one rule so you can read them.
greenbelay explain pipe-to-tail
greenbelay explain pipe-to-tail --sample 20
greenbelay explain pipe-to-tail --sample 20 --rank novelty
--rank novelty changes WHICH twenty. The default is the first twenty the
walk met — the oldest project, the oldest session, and, because a habit
repeats, very often twenty spellings of one command. Novelty picks the
twenty least like each other and least like the cases already in
crates/greenbelay-guard/tests/corpus/<rule>.cases, by greedy max-min over the shape distance, so
an hour of labelling buys as much of the precision estimate as an hour can.
It is deterministic: the same transcripts and the same corpus pick the same
cases, and a second pass does not hand back the first pass's.
3. Review — turn matches into reviewed judgements
Precision is kept as a corpus of judgements, not as a metric, because a metric charts a regression and a test prevents one.
greenbelay explain pipe-to-tail --format cases >> crates/greenbelay-guard/tests/corpus/pipe-to-tail.cases
$EDITOR crates/greenbelay-guard/tests/corpus/pipe-to-tail.cases # each `?` becomes match or nomatch
greenbelay corpus check # and this runs in the test suite
Include the cases that should not match. A corpus of positives alone measures recall and says nothing about how often the rule is wrong, which is the number that decides whether it can be allowed to refuse anything.
A rule answered from the Read tool's payload, not a command, never fires on a command line, so its file can only hold negatives that way. Its cases are Read calls instead, one per line:
match Read full 18425 relais:relais-worker-sonnet-medium src/graph.rs
nomatch Read full 20480 implementation-review src/graph.rs
The fields are the window (full, or <offset>:<limit> as the hook records
it), the file's size in bytes, the agent (main, - for a subagent of
unknown type, or its agent_type) and the path, to the end of the line. The
corpus judges each one with the decision the hook makes, on a regular file of
that size. Only read-unbounded-large has a Read judge today; a Read case in
any other rule's file, or a malformed one, counts as a disagreement.
4. Compliance — is the advice worth its tokens?
advise buys its place in the model's context with tokens, every session,
forever. The backtest says what that costs. This says what it buys.
greenbelay backtest --compliance
greenbelay backtest --compliance --rule glob-in-flag-value --json
greenbelay backtest --compliance --window 40
For every firing it looks at what the model did next. If the next
equivalent command — same shape, within the window — no longer matches the
rule, the habit changed (complied). If it matches again, the advice was
read and ignored, or never reached the model (ignored). If nothing
equivalent followed, the firing is unanswered and counts towards neither.
Three things make the number readable:
- Per model. Models differ, and a pooled figure hides which one is
listening.
claude-opus-5andclaude-fable-5do not answer the same way to the same sentence. observerules are the control. They said nothing, so their share is the rate the habit corrects on its own. Advice is worth its tokens only where the advised share beats the silent one — the same argument the stance ladder rests on, measured instead of assumed.denyrules are left out. A refused command never ran, so there is no next command to compare it against.
What it cannot see: a transcript records what the model ran, not whether the hook spoke. A firing here means "the rule as it stands today would fire on this command", replayed. Where a rule has been widened since, or was observing then and advises now, the number is a reconstruction — and it is still the only evidence there is.
The Read tier from transcripts
The Read tool never reaches the backtester, so read-unbounded-large is
measured from the transcripts directly:
tools/read-rate.py
tools/read-rate.py --weeks 8
For each ISO week it prints the tool calls, the Reads over 16 KB with no
offset/limit after the same exemptions the rule makes (plans, diffs,
media, tool-results/), that count per 1000 calls, and the characters. Run
it to recount the rule's per_1000 and again two weeks after a release, to
compare against the weeks before.
The write tier from transcripts
lint-suppression-added never reaches the backtester either: an Edit or Write
is not a command. It is measured from the transcripts with
tools/suppression-rate.py:
tools/suppression-rate.py
tools/suppression-rate.py --weeks 8
tools/suppression-rate.py --until 2026-10-06
For each ISO week it prints the tool calls, the Edit, MultiEdit and Write calls
that add a suppression or loosen a lint setting, and that count per 1000 calls.
Run it to recount the rule's per_1000 and again two weeks after a release.
The script sees fragments only: a transcript holds what the model sent,
never the file, so it compares old_string with new_string, as the hook's
fragment fallback does. With no section around the text it undercounts the
config rows that need one ([tool.pyright], [tool.ruff*], [lints.*],
.golangci.yml disable: and exclude*), unless the edit carries the header
itself. --self-test classifies tests/fixtures/suppressions.txt, which a
Rust unit test classifies too; tests/suppression_rate.rs runs it.
Guidance writes from transcripts
agent-guidance-written and agent-guidance-shape are write-tier rules too.
tools/agent-guidance-rate.py counts the Edit, MultiEdit and Write calls to
SKILL.md, CLAUDE.md, CLAUDE.md.tmpl, AGENTS.md, MEMORY.md and agent
definitions per 1000 tool calls, per kind of file:
tools/agent-guidance-rate.py
tools/agent-guidance-rate.py --weeks 8
It counts writes to the paths. A transcript never holds the file, so it cannot
size it. Run it to recount the rules' per_1000 and again two weeks after a
release.
What came before a publish, from transcripts
publish-without-skill asks a question the backtester cannot: whether the
tag-release or merge-when-green skill was called in this turn or the one
before. Its confirm reads the transcript, and the backtester never runs
confirm. It is measured with tools/skill-rate.py:
tools/skill-rate.py
tools/skill-rate.py --since 2026-10-07 --list
It prints the publishing Bash calls per 1000 (a v* tag pushed, gh pr merge, a merge sent to /pulls/<n>/merge), split by what preceded them:
no-skill, stale (called two or more prompts back), allowance (covered only
by the one prompt the window allows) and covered. It prints the same counts per
unique command per session, since a refused command is retried. Then it prints
how old the covering call was, and the uncovered rate by week. The matcher is a
regular expression. Against the Rust lexer it overcounts by about 6% (1,551
against 1,461 on 2026-10-07), so backtest --rule publish-without-skill remains
the count of matches. Run it again two weeks after a release.
Fingerprinting a dated measure
A count that is re-run over weeks and compared to an earlier number is only
comparable if the recipe is the same. tools/measure_fingerprint.py hashes
the recipe, never the data: the script's git blob id, the tool version, the
source, the schema marker, the filters and the window rule. Coverage (files
seen, files unreadable, weeks printed) is stored beside the fingerprint, not
in it.
tools/read-rate.py --fingerprint ~/.local/state/read-rate.fp.json
The first run writes the sidecar file as the baseline; later runs with the
same recipe append a run. A different recipe is refused before the table is
printed (exit 3), naming the changed keys with old and new values and the
exact command to accept it. --rebaseline accepts it and records both
recipes in the sidecar's rebaselines. A sidecar whose stored fingerprint
does not match its recipe is corrupt: exit 1, even with --rebaseline.
A measure captured in pieces (a day each) writes one stamp per piece with
stamp(); measure_fingerprint.py compare FILE... [--rebaseline] refuses
mixed recipes when the pieces are summed. A relais ticket's front matter
refuses a fingerprint key, so the ticket body names the sidecar file.
4b. Harness review - which part still earns its place on this model?
greenbelay harness-review (ADR-0042, harness.retire-on-evidence) prints
one row per rule and assertion: its id, the failure it prevents, its stance,
whether it is irreversible, and from the journal its per_1000 (live rows
over the transcripts' Bash calls) and the date it last fired. Shadow rows
(arm=shadow) are the experiment, not the part, and are never counted as live.
Each row adds the compliance replay of section 4, grouped by message.model.
Where any journal row for the part has arm=shadow, it also gives the
ignored share per arm. A transcript does not record whether the hook spoke,
so each session's arm comes from the journal row's arm field, joined to the
transcript session id by the journal's eight-character session prefix. A part
guarding an irreversible action is never dropped live; its row carries a
replay count instead: how many of the reviewed model's Bash calls its
examine matches.
A deny rule has no live compliance (its refused command never ran); when it
is shadowed, its shadow rows are replayed as observe and give the shadow arm a
share, with the live share left empty.
--json emits the same rows. Each run also writes <YYYY-MM-DD>.json into
--out <dir>, by default <journal dir>/harness-review, with the date, the model
the review is for, the newest_model and the rows. --model <id> names the
reviewed model; without it the review is for the model with the most Bash
calls in the transcripts (not the newest, which may have barely started), and
the output says which. Compliance rows, the shadow arm shares and the replay
count cover that model's calls only (a session that also holds another
model's calls is left out of the arm shares). The newest model is the one
first seen on the latest day in the transcripts' Bash calls.
greenbelay harness-review [--json] [--model <id>] [--transcripts <dir>] [--since <date>] [--out <dir>]
greenbelay harness-review --check
--check reads the newest review file and takes the default model (most
Bash calls) of the transcripts. It prints one line and exits 1 in three cases:
that model is not the review's model, no review exists, or the newest review file cannot be read
or parsed (the line names the file). Otherwise it prints nothing and exits 0. The weekly retro runs it (harness.revisit-on-a-new-model): a new model
starts a harness review, and running harness-review records it. Keeping or
retiring a part stays the person's decision.
5. Graduate — promote on the evidence
greenbelay graduate bare-stash-pop --to advise
greenbelay graduate bare-stash-pop --to deny
Promotion is gated on the corpus: a rule cannot be promoted past a corpus that does not support it.
Demotion is not gated at all
greenbelay demote bare-stash-pop
No questions, no evidence required, effective on the next command. This asymmetry is deliberate. A guard that is hard to back out of is one people uninstall instead of demoting — and uninstalling takes every rule with it, including the ones that were working.
Preview approval
push-preview and push-published carry ADR-0028 (work.preview-approval,
fleet decision corpus, replacing ADR-0023): a commit that changes a user
interface is published only after the person approved that commit, seen
on localhost — unless the plan the person approved declares the evidence
is enough (below, rule
work.preview-unless-planned-evidence).
The rule exists because interface regressions kept reaching pull requests and deployed sites after the agent had checked its own screen. The person's eyes are the check that does not share the agent's blind spots, and localhost is where rejecting a screen costs one sentence instead of a fix pull request and a release.
The flow
The person works on several projects at once and does not remember where
this one stood. A bare "[preview f0223d3] Ship website-builder@f0223d3?"
gives them nothing to decide with, so a preview reaches them as a guide
(fleet rule work.preview-is-guided), three ways at once: the brief in the
terminal, a local page, and the app already open in their browser.
-
Verify. The agent drives the changed route in a real browser, checks the console and network, and takes before and after screenshots.
-
Write the guide — markdown, outside the worktree (
~/.claude/greenbelay/attestations/<sha>/guide.mdby convention, the screenshots beside it), because a file inside it, or the page rendered beside it, would dirty the commit it describes. The format is below.Evidence under
attestations/lasts 30 days unless a plan cites it (attestations/<name>in a Markdown file under a repository'sdocs/) or it holds a.keep; a removed directory sits in.trash-<secs>-<name>for 7 days (mvit back to undo).greenbelay attestationsshows what would go. -
Serve and register. From the clean worktree, at the commit to be pushed:
greenbelay preview register --url http://localhost:5173/settings \ --guide ~/.claude/greenbelay/attestations/abc1234/guide.mdRun it in the foreground as the last command of its line. Anything may come before it, joined by
&∨:cd ~/Developer/app-wt-settings && npm run build && greenbelay preview register --url … --guide …It refuses a dirty tree, a non-commit
HEAD, a guide inside the worktree and a guide missing a required section (exit 1; stderr lists exactly what is missing). Otherwise it renders the guide toindex.htmlbeside it and prints one JSON object, compact on one line:field what it is idthe registration; it starts with the commit's sha7 repo,committhe checkout's top level and its full HEADurlwhere the clean worktree is served guide,page,page_urlthe guide, its rendered index.html(absolute), and that page as afile://URLlabel,aliasesthe names a person knows the commit by: the checkout's directory, then the main worktree's directory and the origin repository's name, each @sha7question_prefix[preview <id>] <label>: what the marked question starts with, verbatimattestationguideagain, for hooks older than 2.21.0--openalso opens the page through the machine's opener (greenbelay.opener, see configuration; the platform opener by default) and prints the JSON after the attempt with"opened": trueor"opened": false; failing to open never fails the command.The
PostToolUsehook binds that output to the session and to the person's current prompt, in the repository the command ran in — the leadingcds followed — which must still be the printed repository at the printedHEAD; the journal line names the page. The JSON is read from the last non-empty line of stdout, so what earlier clauses print does not matter. The register must be the last clause: one that is followed by anything (register && echo), piped (| tee), redirected, inside$(…), after||, or in the background is not bound, and the journal says why.A line an earlier clause printed cannot pass for the register's own (
printf '<json>'; greenbelay preview register --bad): thePreToolUsehook stamps when the call started, inpreviews/registers/<tool_use_id>, and the bind requires that the id starts with the commit's sha7 and that the page exists, names the full commit and was written after that stamp. A call with no stamp is not bound. Stamps nobody came back for are swept after a day. -
Open the app and the page. Before asking, the agent opens the app in the person's browser at the state the first step reaches (the panel already open, the form already filled) and the rendered page beside it. That is the agent's job — the
worktree-taskskill's F7, with Claude in Chrome — not this binary's:registeronly renders the page and, with--open, opens it. -
Ask, in the same turn. The brief first — the guide's sections, in the terminal — then one
AskUserQuestionwhose text starts with the register'squestion_prefix([preview <id>] <label>), with options exactlyApprove,Request changes,Hold— no "(Recommended)" suffix. -
Push after
Approve. The approval is keyed by content: it covers that commit, and any commit whose content id equals the approved one's (the tree withdocs/plans/left out, as the implementation review reads it). A reword, a same-tree amend, and a commit that changes onlydocs/plans/keep the approval; a commit that changes anything else needs a new preview.approvalsstores the tree as a fifth tab-separated field; an older four-field line matches only its own commit. A match by tree is journalled asapproved-by-tree <old7>→<new7>. The 24 h lapse, the registration pin and the question prefix are unchanged.
--attestation <file> is accepted for 2.21.0 only, as a deprecated alias of
--guide: the file is read as the guide and refused unless it is one.
The guide
Markdown with these five H2 sections. Headings match with emoji,
punctuation and case aside (## 📍 Where we are: is Where we are); the
page shows them in this order, then any other section the guide adds.
| section | what it carries | checked |
|---|---|---|
Where we are | project, branch and plan, and why the person is asked. Its first line is the page's title | present, not empty |
What you should see | in their words; "nothing new" when that is the point | present, not empty |
Try it | numbered steps: the exact URL, each click named by its visible label and position, and after each step what should appear | at least one numbered step (1.) and one http(s) URL |
Reference | before and after screenshots | present, not empty |
Already checked | what the agent verified, and what to look at especially | present, not empty |
A full example (guide.md, with before.png, after.png and panel.png
beside it):
# Settings: Save moves to the header
## 📍 Where we are
duro-app, branch `feat/settings-save`, plan **Settings panel** (phase 2 of 3).
You are asked because the Save button moved; nothing else on the page changed.
## What you should see
The **Save** button now sits in the header, top right, instead of at the
bottom of the form. Saving works exactly as before.
## 👉 Try it
1. Open http://localhost:5173/settings
- You should see the Settings form, with **Save** in the header, top right.
2. Change **Display name** (first field) to anything.
- **Save** turns from grey to blue.
3. Click **Save**, top right.
- A green toast "Saved" appears bottom left, and **Save** is grey again.

## Reference


## Already checked
- `/settings` at 1280 and 390 px wide: no console error, no failed request.
- Keyboard: Tab reaches **Save** right after the page title.
- Look especially at the narrow window: the button must not cover the title.
The page is one self-contained file: inline CSS readable in light and dark
(prefers-color-scheme), no script, no external asset. Its title is
repo@shortsha — <first line of Where we are>; under it, a large Open the
app link to --url, then the sections. Images (,
relative to the guide's directory) render inline; a missing one is a warning
on stderr, not a refusal. When one image's file name says before and
another's says after, the two show side by side (class="pair") at the top
of Reference. The converter is hand-rolled for this subset — headings,
paragraphs, bullet and numbered lists with one nested level, fenced code,
quotes, bold, code, links, images and bare URLs — and escapes
everything else; a link whose scheme is not http(s), mailto or file is text.
No markdown crate: greenbelay is on a trust path and a page only the person
reads does not clear change.dependency-bar.
Mockup mode
When the previewed branch commits a picked mockup — a *.dc.html artboard
under docs/mockups/<screen>/ (or the directory git config greenbelay.preview.mockups names; the application-landscape ui-handoff
PR check reads the same key) — the guide must prove fidelity
(handoff.prove-fidelity, ADR-0016). Added to the five sections:
- under
## Reference: the screen's path, aViewport: 1120px · lightline (the width and theme both images were taken at), and the picked artboard beside the built screen as image files next to the guide:artboard.pngandafter.png(mockupandliveare read the same; states pair by suffix,artboard-empty.pngwithafter-empty.png); - a section
## Differences from the mockup:None, or one bullet per difference, each- fixed: …or- deliberate: <reason>.
The range is the branch's own commits, from its merge base with the default
branch — never from its upstream, which after a first push already holds the
artboards. Artboards on a branch whose base cannot be resolved are a refusal,
not a skip. A later branch that only edits a screen whose artboards are
already on main is not in mockup mode; the PR check asks it for the
side-by-side or Mockup: none — <reason>.
The images are copies of the proof PNGs committed next to the artboards, so
copying them beside the guide comes first, as its own command: a
register chained after a cp is not bound (see below). Two PNGs whose widths
differ by more than a tenth are a warning. On the page, each pair shows full
width at the same scale, each image links to its full-size file, and an
Overlay toggle lays the built screen over the mockup at half opacity.
A branch in mockup mode that is pushed without a bound approval is held
(deny) rather than advised, unless the rule is set to observe.
What approves
| the person… | result |
|---|---|
picks Approve on the marked question | every pending registration whose id the marker lists is approved |
picks Request changes or Hold | the previews are dropped |
| does not answer (a timeout) | still pending |
types approve, ship, lgtm or looks good as the next prompt, after a marked question was asked | approved |
types anything else next — including yes, go, ok, continue | the previews lapse |
| is not asked: the guide's before and after are byte-identical (below) | approved unchanged when the hook binds the registration |
The id in the marker is what approves: it begins with the commit's sha7,
which the person sees, and the registration it names is already bound to
the session, the prompt and the question. The label is for the person; a
question without it still approves (it did not before 2.30.0, and the
person was asked twice). A marker that names no pending id approves
nothing. A register that did not bind — not the last command, run in the
background, with no PreToolUse stamp, or whose output does not match
HEAD or this call — says so right after it runs, with the command to run
and the question to ask.
An unchanged screen
A screen that renders byte for byte as it did before leaves the person
nothing to judge (ADR-0057). When preview register is bound, the hook
compares the guide's images itself. It approves the commit with channel
unchanged, and asks nothing, when all hold:
- the guide has exactly one before image and one built image (
after,live) whose names share the same state once the role word is removed (before.pngwithafter.png,before-empty.pngwithafter-empty.png); more candidates, or a mismatched state, are asked; - both are relative paths that resolve inside the guide's directory, to two different files (a symlink of one to the other is one file);
- the two files are byte-identical;
- the branch commits no picked mockup: mockup mode always asks;
- the guide is the one the page was rendered from: beside the page this call wrote, outside the repository, no larger than a guide may be.
A hard link of one file to the other is one file, as a symlink is.
register prints "unchanged": true, and on stderr: greenbelay: before and after are byte-identical; the hook approves this preview as unchanged when it binds it, if they still are. The flag only informs: the hook
compares the files again and never approves on what the command printed.
When the comparison cannot run (an unreadable guide, a guide that is not
beside its page, mockup screens that cannot be listed), the hook journals
unchanged-skipped with the reason and the person is asked.
Each approval is journalled unchanged with the image's sha256 and both
file names, so a retro can check it against the commit's UI diff. The agent
takes both screenshots, so the pair is self-certified; the person chose to
trust it (2026-11-02).
Unmarked questions are ignored, so a release question answered "Approve" approves no preview, even in the same turn. Another session's answers never touch this session's previews. Registrations and approvals lapse after a day, checked whenever they are read.
AskUserQuestion accepts answers in its input, so a model could pre-answer
its own question. The PreToolUse hook records, per tool_use_id, whether a
marked question arrived pre-answered; such a question never marks its
previews as asked (so no answer to it can approve), the PostToolUse side
checks the same record again, and under deny the question is refused before
it runs.
When the rule speaks
push-preview fires on a push only when all of these hold:
- the repository has a user interface: a
devscript inpackage.jsonat the root or inweb/, orgit config greenbelay.push-preview.ui true(falseopts a repository out); - a pushed branch carries an interface change (below);
- the plan the branch landed does not declare the evidence (below);
- that commit has no approval.
Planned evidence
Some previews leave the person nothing to judge: they already decided the only visible change when they approved the plan (ADR-0028). The exemption is declared in the plan's body, so the person decides it when they approve the plan:
## Preview
evidence: the only visible change is the 28px small controls, decided in this plan.
Two hooks make it checkable:
-
The approval record. A
PostToolUsehook onExitPlanModereadstool_input.planFilePathwhen it runs (the person may have edited the plan) and, when the result has the approve shape (tool_responsean object carryingplan, nois_error), writes the plan's canonical body sha (plan review: front matter and review sections left out) to~/.claude/greenbelay/plan-approved/<sha>, journalledplan-approved. -
The check, at the push. For a branch whose interface change carries no picked mockup (mockup mode always asks; a screen list that cannot be taken is held as before), the evidence stands when all hold:
- the default branch is known (
checkout.defaultRemoteor the single remote, then itsHEAD,mainormaster) and shares a merge base with the pushed commit; - the branch adds a plan under
docs/plans/since that merge base (the first one added), and it is not a pointer (canonical:); - that plan, read at the commit that added it, has its canonical sha
in
plan-approved/; - its
## Previewsection (outside any code fence) has a first non-empty line starting withevidence:and a reason. The template's<…>placeholder, left unedited, is not a reason.
A pass is journalled
evidence, with the plan's path, the commit and the sha. Any miss — no plan, a plan onmainbefore the branch, a section added in a later commit, an unapproved body — falls through to the approval path, unchanged. - the default branch is known (
The record has the trust of the approvals file: a workflow aid an agent
could write to, not proof. That is why every pass is journalled. The
exemption lapses when the screenshots show a visible change the plan did
not decide; that part is the skill's (worktree-task F7) to enforce: the
hook can only see that the person approved the declaration.
The base of a branch push
A branch push publishes what it adds over what the remote already has. Its
files are diffed from the branch's remote-tracking ref when there is one,
else from the merge base with the remote's HEAD. A tracking ref that the
pushed commit descends from, and that the remote's default branch already
contains, is a stale name: an old branch of the same name, merged and
deleted on the remote but never pruned here. So is a tracking ref the pushed
commit does not descend from, as after a squash merge, where the old
commit is in neither branch. The push is then diffed from
its merge base with the remote's HEAD, journalled base=merge-base. On
2026-11-02 such a ref made a one-file pack refresh in duro-app look like
months of main's UI work. A tracking ref with commits of its own that the
default branch lacks, and that the pushed commit descends from, stays the
base, so work already pushed is not asked about again. A rewritten branch
(force-pushed) is diffed from main: every file it carries over main is
judged. Without refs/remotes/<remote>/HEAD there is no merge base, so the
tracking ref stays the base, journalled base=tracking reason=no-default
with the command that sets it (git remote set-head <remote> -a).
What counts as an interface change
The repository-level decision above says whether a repository is gated at all. Within a gated repository, one changed file counts only when all hold:
- The path. It is under
app/,src/orweb/(at any depth), or it is a.tsx,.jsx,.cssor.htmlfile. - The package. Its nearest
package.json— walking up from the file to the repository root, read from the pushed commit (git show <commit>:<path>), not the working tree — has adevscript, or listsreact,react-dom,react-nativeorreact-strict-domindependenciesor as a required peer dependency.devDependenciesand optional peers (peerDependenciesMeta.<name>.optional) do not count: a component library's CLI carries its renderer exactly there, and renders nothing. A monorepo whose root has adevscript is therefore judged package by package. Nopackage.jsonat all on the way up, or one that does not parse: the path decides. - Not comments only. For a
.ts,.tsx,.js,.jsxor.cssfile, the diff (git diff -U0 <base>..<commit> -- <file>; on a new branch with no base, each unpublished commit against its first parent) is read. When every added and removed line that is not blank is a comment line — starting with//,/*,*,*/, or a JSX{/* … */}— the file does not count. A line with code after a closed comment (/* a */ foo()), a*line that reads like code (CSS* {), a binary file or a diff that cannot be taken all count. Any doubt counts.
git config greenbelay.push-preview.ui still overrides the repository
decision; it does not change how files are judged.
A push to main or master is left to amont's branch-protect.
Supported push shapes
v1 reads an explicit remote plus explicit refspecs — git push -u origin feat/x, git push origin HEAD:feat/x, several refspecs — with -C <dir>
and a leading cd honoured. A destination under refs/tags/ is excluded;
one under refs/heads/ is judged, including a tag's commit pushed onto a
branch.
Everything else is unresolvable and journalled with its shape: a bare
git push, a remote with no refspec (git's push.default would decide),
--all, --mirror, --tags, deletes, glob refspecs, a URL as the remote,
a word from a substitution, an unknown flag. Under advise an unresolvable
push passes with a journal note; under deny a push to a UI repository is
held — --all is not the way around the gate. The shapes the journal
collects decide what the next version reads.
What push-published records
It never speaks. Before a push to a UI repository the hook remembers where
each branch destination stood (keyed by tool_use_id); after it, one
git ls-remote per destination, and one journal line:
| outcome | meaning |
|---|---|
published-approved | the remote now holds an approved UI commit it did not hold before |
published-unapproved | the same, without an approval — the gap advise leaves |
published-no-ui | published, nothing a person could preview |
already-present | the remote held the commit before the push |
unverified | the remote does not hold it, or could not be asked |
What this is not
A registration is the agent's attestation of worktree, commit and URL, and its guide is the agent's account of what it checked. Nothing here proves the browser served that commit or that the person looked. It covers pushes made through Claude Code, not pushes typed in a shell, and it is a workflow aid, not a Git enforcement boundary.
Reading the soak
grep -E 'push-(preview|published)' ~/.claude/greenbelay/journal.log
Every line names the repository the push ran in or the registration belongs to — never the session's working directory, which may be another worktree.
The rule's own lines (registered, replaced, approved, dropped,
unanswered, expired, prefilled, unbound, plan-approved,
evidence) carry the answer latency on
approvals and drops: option,184s,dur=0ms. The latency is the first
number (184s): the hook's own clock, from the PreToolUse of the marked
question to its PostToolUse. dur= is the payload's raw duration_ms,
kept only for comparison — it is not the person's answer time (a
minutes-long approval arrived as 0). A - in place of the seconds means
the question's PreToolUse record was written by an older release. A median
under about ten seconds after a week says the approval is a rubber stamp;
the evidence lines say how often a plan made the question unnecessary.
The review panel
Every plan passes a panel of expert reviewers before the person is asked to
approve it (ADR-0022, fleet rule work.plan-review-panel). The skill
/plan-review runs the panel. The plan-review-panel rule checks, at
ExitPlanMode, that it did.
Who reviews
The panel follows the files the plan's ## Phases name (ADR-0061,
work.review-seats): each backticked span with no space that has a /, a
known extension or a known file name (Cargo.toml, Dockerfile, …), a
:<line> suffix dropped. Context and evidence do not count: they cite files
the plan does not change. Each path is attributed to the repository of the
machine comment whose default tree holds it, a file under it, or a file in
its parent directory (a new file in an existing directory); a path no
repository holds counts for every one.
| the named files | class | reviewers (plan-review-<role> agents) |
|---|---|---|
| always | backend | |
.rs, Cargo.toml, Cargo.lock; .go, go.mod; .py, pyproject.toml; .ts, .js and their variants, package.json, tsconfig.json | lang:<x> | language, with lang=<l> in its review block |
.tsx, .jsx, .css, .html, .vue, .svelte, *.stories.* | ui | react and ui-design |
Kubernetes, Helm, Flux and Terraform files (kustomization.yaml, Chart.yaml, *.tf, *.tf.json), Dockerfile, CI workflows, and any other .yaml or .yml | ops | platform |
| any code file in a repository with a command line | cli | unix and tui |
| markdown and anything else | none beyond backend |
YAML that names no manifest still counts as ops, on purpose: a missed
platform seat costs more than an extra one. Only tool configuration
(.adr.yaml, pnpm-lock.yaml, pnpm-workspace.yaml,
.pre-commit-config.yaml) is left out.
What no path shows, the plan declares with adds=: screen seats
ux-research and game-ux (the Behaviour adds a screen or a flow), and
contract seats po and architect (the plan adds a module, crate or
repository, or changes a contract another repository consumes). large is
the old name of contract and reads as it.
A plan whose Phases name no file is seated as before 3.22.0, from every area
of its repositories, with ui seating all four interface reviewers; the
plan-names-no-paths rule (advise, at most) says so at ExitPlanMode and
plan-panel says it on stderr: name the files each phase touches in
backticks under ## Phases. Paths seat the panel only when every phase
names one: when some phases name files and others none, the areas seat it
too, and the advice names each phase without one (Phase 5 names no file).
On the review ledger, plans seated from the files of only some phases had
dropped seats that made 95 accepted serious findings.
| area (when no file is named) | reviewers |
|---|---|
| always | language for each language, and backend |
| ops | platform |
| a command line | unix and tui |
| large (500 or more files or own commits) | po and architect |
| an interface | react, ui-design, ux-research and game-ux |
Areas are read from each repository's default tree, never from keywords in
the plan; the same read lists the files paths are attributed to, so naming
paths costs no extra git call. The tree is the first of origin/HEAD, origin/main,
origin/master and HEAD that exists, with no fetch. Each signal:
- Languages:
Cargo.toml,go.mod,package.jsonortsconfig.json,pyproject.toml. - Interface: the
uitrait in.adr.yamlareas:, or apackage.jsonwith adevscript or a runtime React dependency. - Ops: a kustomization,
Chart.yaml, aHelmReleaseor FluxKustomization, or*.tf. - Command line: the
clitrait,src/main.rs,[[bin]], apackage.jsonbin, orpackage main.
Vendored, lock and dist/ paths do not count. A fork's commits are counted
past its upstream, and a shallow clone is judged on files alone.
What the plan carries
-
A
## Review panelsection, at most 5 lines, under the H1. -
The full reviews under a final
## Full reviews (reference). -
A machine comment as its last line:
<!-- panel: repos=amont-agent,decisions adds=ui reviewers=… body-sha=<12 hex> -->
repos= names each repository. A name resolves to
git config greenbelay.plan-review.<name>.path when that is set, for a
repository kept elsewhere; otherwise to <plan root>/<name>. The plan root is
$GREENBELAY_PLAN_ROOT, else git config --global greenbelay.plan-review.root
(git config --global greenbelay.plan-review.root ~/Developer/Perso keeps the
old default); with neither, the session's directory when it is not in a git
repository, else the parent of the repository's main worktree. The attestations
sweep uses only the explicit setting. adds= declares classes no named
file shows: cli, ui, screen, ops, contract (or its old name
large), or lang:<language>. A repository that does not exist yet needs a
lang: entry.
Which agents to launch
greenbelay plan-panel <plan.md> answers with the hook's own code:
repos=greenbelay areas=cli,lang:rust body=cf3f43c938c4 panel=full seats=paths counts=repos:1,phases:2,prs:1,releases:1,person:0,words:640,steps:0,merge-candidates:-
plan-review-backend
plan-review-language --lang rust
plan-review-tui
plan-review-unix
areas= lists the classes the panel is seated from, seats= where they came
from: paths (the named files) or areas (the repositories, when no file is
named; the advice is then on stderr). panel=delta lists only the reviews
needed since the plan's last accepted body. panel=current lists none. A
baseline stored before 3.22.0 reads in today's class names (large as
contract, ui with screen), so a plan it covered stays current.
counts= ends line 1 as one comma-separated token with no spaces, so a
reader that splits line 1 on spaces still finds every other key=value,
and agent lines still start on line 2. Readers take keys by name. A new key
goes before merge-candidates, which stays the last comma field:
repos: the machine comment's list;phases: the phases under## Phases;prs: the repositories the machine comment declares;releases: phases naming a version file (Cargo.toml,package.json,plugin.json,pyproject.toml,greenharness.toml) or the word "release" (CHANGELOG.mdalone does not count);person: 🧑 items under Phases;words: the body's words, aswords:<now>/<round 1>once the plan's round 1 differs;steps: actions only the person can run, the plain-bullets of a### 🧑 Your stepsblock inside## Phases; decisions stay inperson. It is printed even when zero, and sits afterwordsand beforemerge-candidates. A heading outside## Phasescounts nothing andplan-panelsays so on stderr with its line;merge-candidates: adjacent phase pairs (2+3;5+6) naming files in the same repositories with the same file-type classes, and no 🧑 item between them;-when there are none.
The plan id
plan-panel gives the plan file a plan-id: p-<26-char ULID> front-matter
line when it has none, before it prints anything. The front matter is
outside the body sha, so no review goes stale. The write resolves a symlinked
plan file first, takes the ledger lock (waiting up to 5 s: ledger busy; nothing written. Run again: greenbelay plan-panel <path>, exit 1), re-reads
the file and refuses one changed since it was read
(plan changed under plan-panel; nothing written. Re-read <path>, then run: greenbelay plan-panel <path>), then renames a temp file into place; a file
it cannot write prints cannot write plan-id: <path>: <error>. Both exit 1
with nothing on stdout. A second run leaves the file byte-identical.
When the person approves ExitPlanMode (PostToolUse, approved: true), the
hook writes plan-review/approved/<id>.json
({"schema": "greenbelay-plan-approval-v1", "plan_id", "body_sha", "approved_at"}), before it takes the ledger lock and without it. The next
plan-panel on another body replaces the retired id
(replaced plan-id p-… (approved) with p-… on stderr); a rejection retires
nothing, so a revised plan stays one plan. A file's id is live until it
was approved with another body: the ExitPlanMode hook and record read the
id through that rule, so a plan edited over an approved one never inherits
its id, even when plan-panel did not run in between.
Each body plan-panel sees is mapped to its id in
plan-review/ids/<body_sha>.json (greenbelay-plan-id-v1). record reads
a row's plan_id from that map (on a miss, the file's own id when the file
still holds that body), and numbers round and first_round_sha within
the id. The baseline's older-body lookups (by path, by title) serve only
the same plan_id, so a new plan in a reused file is a full panel for both
plan-panel and the ExitPlanMode hook.
Binding a review to the plan
greenbelay plan-sha --block [--lang <l>] [--slice <role>] <plan.md> prints the review
block that each reviewer's prompt carries:
<<<PLAN path=/Users/me/.claude/plans/p.md sha=<64 hex>>>>
The sha is that of what the canonical body says: the plan without its
front matter, its review section, its full reviews and its machine comment,
read as CommonMark. Every word, number and operator counts, code blocks and
code spans count exactly as written, and so do link destinations and the
kind of each block (list item, quote, heading, table cell, an ordered
list's start). Blank lines, line wrapping, indentation outside code, table
padding, list-marker and emphasis style and escapes do not. A landed copy in
docs/plans/, which gains front matter and may pass through a formatter
such as prettier, therefore hashes like the approved plan, unless the
formatter rewrites code. Writing the review results into the plan never
makes a review stale. Editing the body does.
The Markdown parser is pulldown-cmark, pinned exactly: a new version may
read a plan differently, so a bump is its own change, and a fixture test
fails when it re-hashes.
Until the transition ends (2.25 onward), a review or a baseline bound
to the byte sha that 2.24 and earlier computed still counts. The hook's
journal line for a pass starts match=legacy when it rested on one, and
plan-sha --legacy prints that sha, for a plan whose machine comment was
written before. Both go once the journal shows no match=legacy for
14 days.
A seat bound to its slice (3.23.0, ADR-0061 work.review-slices). On
a plan whose every phase names a file, a seat that a file type earned
(lang:<x>, react, ui-design, platform) and that has a phase of its
own is bound to its slice: the lines before the first ##, the Goal,
Non-goals, Behaviour and Code review sections, the ## Phases text before
its first item, every 🧑 decision, and the phases that name a file of its
types. A reference definition that kept text uses travels with the slice.
Every other section (Context, Tests, Decision log, Verification, Outcome)
is outside every slice: backend, which binds the whole body, reviews it.
Backend, architect, product owner, unix, tui, ux-research and game-ux always
bind the whole body, and so does every seat on a plan seated from areas.
greenbelay plan-sha --block --slice <role> <plan.md> prints two lines:
<<<PLAN path=… sha=<body sha> lang=rust slice=<64 hex>>>>
Your slice: Phase 1, Phase 3 and the shared sections. The other phases belong to other seats: …
Paste both, stdout only. sha= stays the body sha, so plan-apply and the
outcome ledger keep working; slice= is what a later delta compares. For a
seat with no slice the command prints the plain block and says why on
stderr (binds the whole body (<why>): seats=areas, no phases, no phase of its own), exit 0. --slice=<role> and --lang=<l> work too. plan-panel prints
--slice <role> on each sliced seat's line.
A sliced review counts when it reviewed this body, or when its slice= is
the role's slice as it stands. In a delta the hook also requires every
sliced seat whose slice moved since the last pass, and names the moved span
with the command to re-run:
stale (its slice changed: Phase 2) for repos=…: lang:typescript; re-run: `greenbelay plan-sha --block --lang typescript --slice lang:typescript <plan.md>`
(the command is in backticks, so it copies alone; a path with a space is
quoted).
A seat that was whole-body at the last pass and is sliced now (it has a new slice), or the reverse (it now binds the whole body), is required
too; a slice whose spans only changed order says the order of its phases. The
baseline keeps each sliced seat's slice sha and one sha per span. A baseline
written before 3.23.0 has none, and its delta keeps the old rule
(slices=unknown in the journal); a pass on it records none either, so the
old rule holds until a fresh panel. The journal line carries sliced= and,
on a refusal, slice-stale=.
This tightens the hook: it saves no seat, since a delta already asked only backend, and it adds re-runs where a seat's own phase changed. A 14-day measure (due 2026-11-21) counts them and the findings they make.
A delta in a new session. A plan's baseline is found by its path, by
its body, and, last, by its H1 and repos=: the same plan presented from a
new session has a new file name, and after an edit only its title still
names it. Two plans with the same H1 and repositories therefore share a
baseline; backend still reviews the body. If the sha cannot be computed
(the parser panicked), the hook asks the person instead of passing.
A review counts only when Claude Code recorded it as completed:
- in the foreground, a result with
status: completedand the agent'sagentType; - in the background, a task notification that Claude Code queued itself.
Notification text inside a tool result, or in a message, is never read.
The declared sha stops a skipped review and a review of an older body. It does not stop a model that deliberately declares a sha for a body it did not have reviewed.
What the hook answers
| situation | answer |
|---|---|
| first presentation | the whole panel, each role bound to this plan's path; backend bound to this body |
| body changed since the last pass | backend plus every area new since then, bound to this body, plus every sliced seat whose slice moved, bound to this body or its current slice |
| same body, no new area | passes (a re-presentation, or a metadata-only write) |
no machine comment, bad repos=, no review section | refused |
| no transcript, no plan path, git failed | the person is asked (ask) |
| refused twice already | the person is asked, with UNREVIEWED: refused N× |
⚠ unreviewed: … in the review section | the person is asked |
A pass is remembered under ~/.claude/greenbelay/plan-review/, which is
0700 with 0600 files, by plan path and by body. The same plan presented from
a new session, under a new file name, is therefore recognised.
The default stance is deny. Set greenbelay.plan-review-panel.stance to
advise to be told without being refused, or to observe to only journal.
Recording what the panel did
greenbelay plan-review record <plan.md> [--transcript <path>] appends one
JSON row per completed plan-review reviewer of the plan to
~/.claude/greenbelay/plan-review/outcomes.jsonl, so the panel can later be
judged on its own record. Without --transcript it reads the transcript under
~/.claude/projects (modified in the last 7 days) that reviewed this plan's
path: the one that reviewed its current body first, then the newest. A long
session still being written to can have reviewed an older body days ago.
stdin is a JSON array of findings (empty stdin is []):
{"role", "severity": blocking|high|medium|low, "disposition": accepted|rejected|decision, "section"?, "area"?}. They are attached to the
rows this call writes for the highest round it writes, matched by role.
A row has: schema (greenbelay-review-outcome-v1), recorded_at (unix
seconds), role, agent_id, model, tokens, seconds, round (1-based,
in the order distinct bodies first appear), body_sha, first_round_sha,
plan_path, plan (areas, the repositories' areas whatever seated the
panel; seat_source, paths or areas, null when the repositories could
not be read, and read as areas on a row written before 3.22.0;
seat_classes, the classes the panel was seated from; repos; body_lines
of the body that round reviewed; null when that body was never saved), with
first_round_sha the
first body any call recorded for this plan path, across sessions, verdict (rework,
approve-with-changes, approve or null), remit (the areas the role is
asked for; * for backend) and findings.
findings is what stdin gave for the row's role, as given. Otherwise it is
what the reviewer wrote: findings_of(result) reads only the lines between
Findings: and the next of What I would measure: / Patches: (or the end),
matches N. [blocking|high|medium|low] at the start of a line (a leading **
or spaces tolerated) and gives {n, severity} with no disposition. The count
of numbered lines that did not match is the row's findings_unparsed; a line
is skipped, never guessed. None. gives no findings.
record reads the launches as plan-apply does, so a round resumed with
SendMessage counts. Rows are deduped on (agent_id, body_sha): a resumed
round on a changed body gets its own row, on an unchanged body nothing. A
manual call with stdin findings (each may carry n) for a reviewer already on
record writes no outcome row; it appends one
greenbelay-review-disposition-v1 row {agent_id, body_sha, role, n, disposition} per finding, exempt from that dedupe.
Outcome rows are deduped as above under an exclusive lock, so a second run, or two
at once, writes nothing twice. Each round written also saves the plan body
once as plan-review/bodies/<sha>.md, if the plan file still has that body
(otherwise a note on stderr); bodies older than 90 days are deleted. The
directories are 0700 and the files 0600.
The hook records on its own
The PostToolUse ExitPlanMode hook runs this record for the plan when the
person answers it, on approval and on rejection alike, reading the session
transcript from the payload (transcript_path). It never fails the call:
nothing goes to stdout, and an error (an unreadable transcript, no completed
review, a ledger that cannot be written) is journalled as outcome error of
the rule plan-review-record. A repeat run is safe, by the dedupe above. The
hook takes the ledger lock with LOCK_NB and retries for at most 2 s; if
another process still holds it, it journals one skipped entry (body sha and
plan path) and returns. plan-review stats lists such a plan as
record-skipped until the ledger has a row for that body (or any row for the
plan recorded after the skip); running greenbelay plan-review record <plan.md> by hand catches up.
Its status line (wrote N rows (round R, plan <sha12>), already recorded round R of <sha12>; nothing written, or no rows written … when every
reviewer lacked an agent id) goes to stderr; stdout stays empty.
--transcript=<path> works too, and -- ends the options.
Exit codes: 0 when the ledger is up to date; 1 when no transcript names the plan, a reviewer has no agent id (the other rows are still written) or the ledger cannot be written; 2 on a usage error or malformed findings.
Applying the reviewers' patches
A reviewer that proposes an edit ends its result with a Patches: section: a
fenced JSON array of {"finding": n, "old_string": "...", "new_string": "..."},
one object per edit, old_string copied from the plan and unique in it.
greenbelay plan-apply <plan.md> applies them with no model. The accepted
findings come on stdin, [{"role": "tui", "finding": 1}, ...]; a finding may
carry "patch": {"old_string", "new_string"} to supply an edit the main
session wrote itself. Stdin on a terminal is a usage error.
The patches are read from the session transcript (--transcript <path>, or
else the one under ~/.claude/projects that reviewed the plan), from the
latest completion of each role, launch or SendMessage resume, that reviewed
the plan body as it was before the apply. Each old_string must occur exactly
once and must not overlap another patch; an empty one is a usage error. A patch
that does not match is listed as unmatched <role>#<n>: <reason> (absent,
absent (whitespace), N occurrences, overlaps <role>#<n>, no patches block, patches block is not JSON), never guessed. The matched ones are
written once, atomically, to the file a symlink points to; if the plan changed
between the read and the write, nothing is written. A patch inside the front
matter, ## Review panel or ## Full reviews is applied and labelled
outside the body.
stdout is data: one line per patch, applied tui#1 <section> or unmatched tui#3: absent, then applied A, unmatched U, sha <sha12>. When some patch is
unmatched, a next: line follows and the last thing on stdout is the block
the fallback subagent's prompt must start with:
<<<APPLY path=<plan> sha=<sha12 of the body before the apply>>>>.
Patch lines stay within 80 columns; the next: line and the block carry the
plan's path unclipped, since one is copied and the other is machine-read.
Diagnostics go to stderr. Every real run appends one
greenbelay-review-merge-v1 row to outcomes.jsonl (recorded_at,
plan_path, body_sha_before, body_sha_after, round, accepted,
applied, unmatched, mode: "command"); merge rows are not review rows and
never count as a recorded reviewer.
| flag | effect |
|---|---|
--dry-run | report what would change; write nothing, no row |
--check [--before <sha>] | write nothing; a patch is verified when its new_string occurs once and its old_string is gone (a new_string that contains its old_string skips the absence test; a patch the apply step recorded as overlaps is verified on its old_string being gone alone, since the one merged edit that resolves two overlapping patches holds neither new_string). Patches resolve by the body before the apply: --before (12 to 64 hex), else the latest command row of this plan, else the current body |
--record-fallback | after a subagent applied the unmatched edits: find its launch by the <<<APPLY block its prompt starts with, check the findings on stdin, and write one mode: "subagent" row (agent_id, model, tokens, seconds, verified); a rerun writes nothing |
| exit | meaning |
|---|---|
| 0 | every patch applied (or verified) |
| 3 | some patch unmatched or not verified; the matched ones are written |
| 1 | file I/O, the plan changed under the apply (nothing written), or no transcript holds the reviewer's result |
| 2 | usage error, including an empty old_string |
Judging a seat: plan-review stats
greenbelay plan-review stats [--json] [--model <id>]
Reads ~/.claude/greenbelay/plan-review/outcomes.jsonl and, for the
implementation review, ~/.claude/greenbelay/implementation-review-outcomes/outcomes.jsonl,
through the one ledger reader in review_outcomes.rs; rows of another schema
(merge rows) are not reviews. It prints one row per (role, model): reviews,
findings by severity (blocking/high/medium/low), accepted findings by
severity, accepted findings by severity, unresolved findings by severity
(shown when there are any) and accepted-plus-unresolved high-or-blocking
findings per review. A finding is accepted when its disposition is accepted
(plan review) or fixed (implementation review, role implementation-review).
A parsed plan-review finding (one record wrote as {n, severity}) has its
disposition derived when stats are read, so a merge or a disposition row
appended after the review rows still counts. In order: the latest
greenbelay-review-disposition-v1 row for its agent_id, body_sha and n
wins; else it is accepted when any greenbelay-review-merge-v1 row whose
body_sha_before equals the review row's body_sha lists role#n in
applied_labels (the union over every such row); else unresolved. Findings
given on stdin keep the disposition they were given.
A row with 20 or more reviews and under 0.05 accepted-plus-unresolved
high-or-blocking findings per review ends in retire-candidate (ADR-0042): an
unresolved finding is not evidence that the seat caught nothing. Retiring the
seat stays the person's decision. Stats also print predate-change=N for the
reviews recorded before findings were parsed (findings empty and no
findings_unparsed; the ledger is not backfilled, so the 20-review bar counts
from the new rows), a no-parsed-findings line per seat with reviews that
closed approve-with-changes or rework yet have 0 parsed findings, and a
record-skipped line per plan whose hook record was skipped and not caught up.
--json prints one array of objects instead (the skipped plans as extra
record_skipped objects), --model keeps one model. Exit
0, or 1 when a ledger cannot be read, 2 on a usage error.
Time to done: plan-review stats --time
greenbelay plan-review stats --time [--since <YYYY-MM-DD>] [--json] reports
each landed plan's time to done (ADR-0070 work.plan-time-to-done; the
contract is the time-to-done programme's t01 ticket in decisions). It reads
the transcripts under ~/.claude/projects, this ledger and git, and nothing
else (harness.cross-tool-reads). Run hours come from relais's own query,
which retro-weekly joins on the sessions field.
- Plans: every
docs/plans/*.mdwithbranch:in its front matter andstatus: activeordone, in the repositories under the plan root. Pointer files (canonical:) and.reviews.mdsidecars are skipped, and a plan withoutbranch:is counted underexclusions. - Start: the earliest round-1 row of the plan's first-round body. That body
is found from the
body-sha=of the machine comment (in the plan or its sidecar), else from the sha of the body as first committed, following plan-apply merge rows back. A plan the ledger does not know isunreviewed. It starts at its first commit and is left out of every median. - Done: the first commit that adds
status: done. A plan without one is unfinished, listed with its age so far. - Attribution: an entry belongs to the plan whose branch its
cwdis on, read from the transcripts'git worktree add,removeandswitch -ccommands (by time, so a reused path changes plans) andgit worktree list.gitBranchis not read, because it stays at the session's first branch. The session that runs the add also belongs to the plan from the plan's start up to the add, whatever itscwd. Each entry counts for one plan, the latest-started. - Blocked: the union of foreground gate, test and build calls, foreground
agents, relais calls, and gaps over 10 minutes ended by a background
notification.
resource_h(JSON) is their plain sum. Person: gaps over 10 minutes ended by the person.
The text output fits 80 columns: one row per finished plan (u marks an
unreviewed one), the ten newest unfinished plans, the unattributed time, the
exclusions, and a summary. The summary gives the medians of the reviewed
plans, the share whose words grew past ×1.25, the unattributed share and,
within it, the unmapped share (attribution failures: a worktree no surviving
transcript adds, a detached or removed one, an entry without cwd), and
done check: insufficient when fewer than four finished plans have a saved
round-1 body. --json prints one object with schema (1), plans,
unfinished, unattributed, exclusions and summary. Per plan it also
gives prs, releases, questions, resource_h, words and phases from
round 1 to final, and sessions ([{id, from, to}]). --since keeps the
plans done on or after that day, plus every unfinished one. Progress goes to
stderr only when stderr is a terminal and --json is off.
Exit 0 on a report, 1 when the plan root, the ledger or the transcripts cannot be read, 2 on a usage error. A closed stdout pipe ends the process quietly: by SIGPIPE on unix, exit 0 where the write fails instead.
The plan's code reviewers
A plan declares who reviews its code in a ## Code review section (after
## Non-goals), one line per repository:
- <repo>: backend, lang:rust, unix (tui: no screens)
- <repo>: none — <reason>
A profile is backend, platform, unix, tui, react, ui-design,
architect or lang:<x>; a parenthesised reason for the profiles left out
is kept as text. greenbelay plan-panel --code-review <plan.md> proposes
the list: one line <repo>\t<profiles comma-separated>, or
<repo>\tnone\t<reason>, per repository of the machine comment, from the
files the Phases name in it (backend always, each lang:<x>; ops adds
platform, cli adds unix and tui, ui adds react and ui-design,
contract adds architect). A repository whose files are not code is
proposed none, with the reason markdown only, no reviewed file type or no file named; cut -f2 reads none, and the line pastes as - <repo>: none — <reason>. When the Phases name no file, the proposal comes from the areas as
before (none — no language area). Plain plan-panel prints what it always did; if the plan
has no ## Code review section it says so on stderr and still exits 0. A
section that does not parse (unknown profile, no colon, empty list, none
without a reason, a repository twice) exits 1 with or without the flag.
plan-panel --code-review <plan.md> -C <dir> --base <ref> also reads the
branch in <dir> (the base defaults to the merge base with origin/HEAD).
When its diff is an exact copy of a registered, unrevoked block whose pin
check passed, and the implementation-review hook enforces, the proposal is
<repo>\tnone\tcopy of fp:<12 hex>; otherwise the profiles are proposed as
before. Either flag without --code-review exits 2.
The pin check reads one marker line in the added lines of the block:
# release-pin: <owner/repo> <tag-template> <asset-template> <ENV_KEY>
review-brief reads the pin <ENV_KEY> from the same file, expands the two
templates and runs gh release view for that tag; a missing gh (gh not found; install GitHub CLI and run gh auth login), marker or
asset means the match does not count and the profiles are required.
What a code-review profile reads
review-brief --profile <p> gives lang:<x>, react, ui-design and
platform only their file types' part of the diff (ADR-0061,
work.review-slices), with the table above: the changed paths are listed
with git diff --no-renames --name-only -z, so a move across languages is a
deletion one language reads and an addition the other reads, and the patch
is taken for the kept paths alone, as literal pathspecs in batches that fit
one git call each (git diff has no --pathspec-from-file). No kept path
is an empty patch, never the whole diff. The brief keeps the whole
--stat, lists the rest under ## Not in this brief, and says on stderr how
many of the changed files it carries and the patch's bytes. backend,
architect, unix and tui read the whole diff. Every profile brief
carries the plan's Goal and Behaviour beside its Non-goals. A delta brief
(--interdiff) filters each patch it compares on that patch's own paths.
shipped
greenbelay shipped <plan.md> [--json] says what shipped under a plan. It
is read-only and derives everything from git (decisions ADR-0036), plus gh
for the head of a GitHub squash.
What it reads
For each repository in the plan's front matter repos: list (resolved as
plan-panel resolves them: git config greenbelay.plan-review.<name>.path,
else <plan root>/<name>, the plan root resolving exactly as plan review's
does, working-directory fallback included: see
plan-review.md), it looks for docs/plans/<the plan's file name> on origin/main (the plan or a pointer file). A repository without it
is reported as no plan file.
It fetches the provenance and attest notes refs of both name sets
(refs/notes/greengate-{provenance,attest}, refs/notes/amont-{provenance,attest};
one git ls-remote, then one fetch of those origin lists) into local refs of
the same name. A ref origin does not list is skipped silently; an
ls-remote or fetch that fails is said on stderr, naming the refs, and the
command goes on with the notes it has. Gate stamps are never fetched. Nothing
else is written.
For each first-parent commit on origin/main that touched the file:
- PR: the last
(#n)anywhere in the subject (GitHub's... (#n)and Forgejo'sMerge pull request '...' (#n) from ... into main). - head: the second parent of a merge commit; for a squash,
gh pr view <n> --json headRefOidwhenghis available and origin is github.com, else unknown. - release: the first
v*tag by version that contains the commit, elsenot released.
Lookup order for the provenance record
The record is a greengate-provenance-v1 (or legacy amont-provenance-v1)
payload followed by an armored SSH signature; one note may hold several blocks.
A block counts only under the header of its own name set, and its signature is
checked under that set's namespace. The lookup tries, in order:
- the PR head commit,
refs/notes/greengate-provenancefirst, thenrefs/notes/amont-provenance; - the same two refs on the merge commit's tree;
- every note in those refs, read in one
git cat-file --batchpass, for a block whosepatchequals the merge commit's own patch id (the writer's own function,implementation_review::branch_patch, with the merge's first parent as base).
The object order wins: a legacy note on the head beats a green note on the tree. Per object, the green ref comes first.
A block whose commit is neither reachable from an origin ref nor the merge's
PR head (its second parent, or gh's headRefOid) is ignored; the PR head is
accepted even when its branch is gone from origin.
The plan a record binds is the changed docs/plans/*.md that is not a
.reviews.md sidecar and, among several, not a pointer (front matter
canonical:). In a repository holding only a pointer file, the record's plan
line binds the pointer's body-sha.
Statuses
verified: the signature verifies, withssh-keygen -Y verify -nunder the namespace of the record's name set (greengate-provenanceoramont-provenance), for a principal of the committed.github/allowed_signers(or.forgejo/allowed_signers). The human row saysverified under <namespace>; the JSONstatusstaysverified.signed, signer not allowed: the signature is structurally valid (ssh-keygen -Y check-novalidate) but no listed principal verifies it.signed, no allowed_signers: valid signature, no allowed_signers file.unsigned: the block carries no signature.bad signature: the signature does not hold for the payload (tampered).signature not checked:ssh-keygencould not be run, or no scratch file could be written; nothing is said about the record.no provenance: nothing found.
Flags on a record: plan line does not match tree (its plan body sha
differs from the plan's body sha in the record's tree) and reviewed an earlier body (it differs from the body sha on origin/main).
The gates line of the first block in refs/notes/greensummit, when its
header is greensummit-v2, on the same object is shown as context,
unverified. A note under refs/notes/greengate-attest or
refs/notes/amont-attest is not read (ADR-0073).
Output
One line per merge commit:
amont #338 9f1c2ab v1.55.2 review reviewed · preview not-required · plan 031240153fa4 · gates cargo-test clippy · verified under amont-provenance
--json prints one array of {repo, pr, merge, head, release, provenance: {status, review, preview, plan_body_sha, flags} | null, gates} and nothing
else on stdout. Exit 0 on success, 2 on a usage error (a missing or unknown
argument, an unreadable plan), 1 when no repository could be read or the
answer could not be written (a reader that closed the pipe is not an error). Payload
files older than 30 days under <config dir>/greenbelay/provenance/<repo>/
are noted on stderr and never deleted.
Budget
One gh pr view per GitHub squash PR, and none for a merge commit or a
non-GitHub origin. GREENBELAY_GH names another program in place of gh.
The implementation review
Before the push of a branch that carries a plan, one independent reviewer
has read the diff against that plan and the repository's active rules, and
its verdict is recorded in the plan (ADR-0022, fleet rule
work.implementation-review). The worktree-task skill runs the review
(step F4b). The implementation-review rule checks, at git push, that it
happened for the tree being pushed.
The plan step has a panel; the quality loop has one reviewer. A diff with its surrounding code is larger than a plan and arrives on every push, and the reviewer's job is narrower: findings only, never an edit, never a waiver.
What the reviewer reads
Its prompt carries, in order: the review block, Round 1. or Delta., a
brief the session builds once, and its output contract. The brief is the
landed plan's path and Verification section, the diff against the default
branch without docs/plans/ (its stat when it is large), the repository's
active constraints (greentopo rules --level constraint), and the plan's
Non-goals. It checks plan conformance, that every recorded verification is
an observable check, violated constraints (rule id and file:line), tests
that cannot fail, and scope past the phases or the Non-goals.
Its result begins with the verdict, exactly, because the hook reads it:
Verdict: approve | approve-with-changes | rework
Findings:
1. [blocking|high|medium|low] <problem>. Evidence: <file:line>. Rule: <id or —>. Edit: <concrete change>.
Would still check by hand: <one to three things>
What a review binds to
The content id: the sha256 of git ls-tree -r -z of the commit with
every entry under docs/plans/ left out, 64 hex in any object format,
computed read-only (attest SPEC, "Content id"). Recording the review in the
plan, or adding a plan, therefore never makes it stale; a code change does.
It is not attest's canonical tree, canon(T), which counts whether a plan
file exists; greenbelay tree-sha prints the content id.
A pass also holds for another tree with the same branch patch, when the
repository's rule files are unchanged (ADR-0034,
work.implementation-review-binding). The patch is git diff --binary <merge-base> <pushed> -- . ':!docs/plans' hashed by git patch-id --verbatim: whitespace counts, index lines and hunk line numbers do not.
The rules are the entries of AGENTS.md, CLAUDE.md, .adr.yaml, .adr/
and .claude/ in the pushed tree. So a rebase onto a moved main that
does not touch the patch or the rules keeps the review. A rebase that
resolved a conflict, changed a line of the patch's context, or brought new
rules does not, with one exception: the root CHANGELOG.md (ADR-0059).
A release rewrites the lines around a branch's ## Unreleased entry, so a
pass is also filed, under by-notes-patch/, by a second key that ignores
where the changelog entry sits: the git patch-id --verbatim of every
other file, plus the changelog's changed non-blank lines inside its hunks,
in order. A rebase that only moved the changelog's context or blank lines
keeps the review, journalled reviewed-by-patch-notes-moved. An entry whose
text or order changed, any other file, a mode change or a rename does not.
A person's overrule carries over on the same terms, once
the overruled tree itself has been pushed (the push files it under its
patch); journalled overruled-by-patch. When the patch cannot be computed,
the held message says why.
greenbelay tree-sha [--block] [-C <dir>] [--] [<rev>]
--block prints the block the reviewer's prompt carries:
<<<TREE repo=<name> sha=<64 hex>>>>
<name> is the basename of the directory holding the repository's common
.git, so a worktree checked out as amont-agent-wt-x says amont-agent.
Exit 0; 1 outside a repository or for a rev that names no tree (the reason
on stderr); 2 on a usage error.
What the hook does at a push
- Resolves the push (
crate::push_target): the repository and the commit each refspec publishes. A dry run, a push tomain/master, and a push of tags only are not its business. - No plan on the branch:
docs/plans/unchanged betweenmerge-base(<pushed>, <base>)and the pushed commit, where<base>is the first of<remote>/HEAD,<remote>/main,<remote>/masterthat exists, never the branch's own tracking ref and neverHEAD. The rule declines, silently. - Computes the content id of the pushed commit.
- Looks for a binding: a completed
implementation-reviewagent in this session's transcript whose block names this repository and tree, or a pass remembered under~/.claude/greenbelay/implementation-review/by-tree/. Completion is read from structured fields only, as the review panel reads it; a notification echoed inside a tool result never counts. A reviewer resumed withSendMessageon a new block counts as a review of that block (below). - Reads the verdict. A review that said
reworkand got no later delta on the same tree is not a pass. - On the first transcript binding that passes, writes the pass file
(0700 directory, 0600 file), so a new session pushing the same tree
passes without a transcript. The pass is also filed under
by-patch/with the patch, the rules fingerprint and the tree. - No binding for this tree: looks the branch patch up under
by-patch/. A pass there whose rules fingerprint matches is copied toby-tree/for this tree ("how": "patch <old tree>"), and the push passes asreviewed-by-patch. The exact patch is tried first, then the changelog key underby-notes-patch/("how": "patch-notes-moved <old tree>",reviewed-by-patch-notes-moved). A patch or fingerprint that cannot be computed is a miss.
| situation | advise (ships) | deny |
|---|---|---|
reviewed this tree, verdict not rework | silent | passes |
| reviewed the same branch patch, rules unchanged | silent | passes |
| no plan on the branch | silent | silent |
| reviewed an older tree | note, names both trees | held, names both trees |
verdict rework, no delta | note | held |
| never reviewed | note | held |
| transcript unreadable, git failed, no default branch known | note | held |
a push shape this guard cannot read (--all, --mirror, …) | journalled, passes | held |
Every note ends with the next step:
greenbelay/implementation-review: no implementation review of greenbelay tree 5085edae1d66 is in this session. worktree-task F4b: `greenbelay tree-sha --block`, then launch the implementation-review agent …
A resumed review
The delta (F4b.6) may resume the same reviewer with SendMessage, giving
it the new block, instead of launching a fresh one. Each round is a review
of its own, read from the shape a real session recorded
(tests/fixtures/sendmessage-resume.jsonl, 2026-10-08):
- the launch's result carries
toolUseResult.agentId; - a
SendMessagewhoseinput.tois that agent id, and whose result carriestoolUseResult.resumedAgentId= the same id, starts a round: its prompt isinput.message(the block is read from it) and its id is the SendMessage's own. Claude Code 2.1.330 and later answer some subagents' resumes withrevivedAgentIdalone; whenresumedAgentIdis absent or null,revivedAgentId= the same id starts the round instead; aresumedAgentIdthat is present and not null alone decides, so one that is not a string starts nothing; - the round completes only on a structured task notification whose
<tool-use-id>is that SendMessage's id and whose<task-id>is the agent id. The launch's own result is never overwritten.
A message to an agent that was not launched as implementation-review, a
round whose notification names another task, or a notification typed or
echoed rather than queued by Claude Code does not count. Only this rule
reads resumes: the plan-review panel counts fresh launches alone.
A delta brief
A resumed reviewer brings its whole first round with it, 50-80k tokens each time. A delta after a rebase or a small fix can instead be a fresh launch that reads only what changed:
greenbelay review-brief --interdiff <head> [--profile <role>]
prints the same <<<TREE>>>, <<<RULES>>> and <<<CANDIDATES>>> headers
as the full brief, then what changed since <head>, docs/plans/ left
out: the plain diff when <head> is an ancestor of HEAD (a fix on top), or
the diff between the two branch patches after a rebase. git range-diff
is not used: it lists a commit added on top without its patch, which would
hide the fix. The plan, the full diff and the rules are not repeated.
<head> is 7 to 64 hex digits; anything else is a usage error (exit 2).
The brief is refused (exit 1, one stderr line naming the brief to build)
when <head> or its merge-base cannot be read, when the rule files
changed since it, when this role's last passed review of the branch read
another head (the line names that head and its --interdiff command), or
when what changed is 60 KB or more. It is never cut. Each brief built is
journalled interdiff-brief with the head, its size and its shape.
The head comes from the stale line. Each fresh pass records, per role, the
head, merge-base and tree it read under by-branch/<repo>/<role>/<sha256 of the remote ref>.json (last writer wins). A push whose review is stale
then says "A delta reads only what changed: greenbelay review-brief --interdiff <head> (a profile seat adds --profile <role>)" when that
record matches the stale review's tree. The brief looks the record up
under the branch of the same name, which is what git push and amont land update; a push to another name finds no record, and the brief says so.
A stale push also names each resumed round on the pushed tree that did not
count, right after (stale). and before the carry-over and delta sentences:
"A resumed round was not counted: SendMessage its answer did not name that agent as resumed (the answer's resumedAgentId, or with none its
revivedAgentId, is another agent or missing) or no notification of its own yet (still running, or ended without one). Only an answered
SendMessage to an agent launched as implementation-review, whose message
header carries this repository's block at the pushed tree, is named; at
most the last 3 (side transcripts first, then the main one, each in line
order), preceded by "N earlier resumed rounds are not shown" (singular for
one), each id cut to 64
characters and control characters escaped. The journal excerpt does not
change.
The person's overrule
A rework that survives the delta goes to the person on a marked
question: its text starts with [implementation-review <repo>@<sha64>]
and its options are exactly Overrule, Fix, Hold. As with the preview
approval, the hook records the question before it runs and trusts the
answer only when that record exists and the question did not arrive with
answers pre-filled. On Overrule, and only when this session's
transcript shows a completed review of that tree that said rework, the
hook writes the pass file with verdict: overruled. An overrule that
bound nothing says so in the model's context.
Only the hook writes a pass file
Under deny a pass file is a trust boundary. A Write, Edit or MultiEdit
under ~/.claude/greenbelay/implementation-review/ is refused, with .
and .. folded before the comparison; a Bash command that would write
there — a redirect into it, or rm, cp, tee, python, chezmoi and
the like with a word naming it — is refused too, whatever the rule's
stance. Reading the record (ls, cat, find, grep) is allowed. The
Bash half is best-effort by nature: a parser cannot see inside python -c
beyond its words.
~/.claude/greenbelay/provenance/ is guarded the same way (below).
The provenance record
When the hook passes a push that carries a plan, it writes the unsigned
amont-provenance-v1 payload to
~/.claude/greenbelay/provenance/<repo>/<pushed sha>. The format is attest
SPEC amont-provenance-v1; the decision is ADR-0036. One datum per line:
amont-provenance-v1, commit, tree (the full tree), patch (only when
the branch patch could be computed), plan <path> <body sha> (the plan
under docs/plans/ changed on the branch, read from the pushed tree),
review <reviewed|by-patch|overruled> <content id the review read>,
preview <approved|evidence|not-required> and producer amont-agent <version>. There is no canon line: attest's canonical tree is a tree fact
greenbelay does not own, and the signer, amont, computes it and inserts it
before signing. A payload that carries one is refused by the signer.
After the review line, one code-review <role> <how> <content id> line
records each code-review profile the plan declares for the repository, in
declaration order: how is reviewed, by-patch, carried or overruled,
and the content id is the tree that profile's review read. A push with no
declared profile writes no such line. greenbelay doctor (and doctor --json) reports one gap for each code-review agent file
(code-review-<role>.md, code-review-language.md, interface-review.md)
that no agents directory carries, and says nothing when all eight are there.
It is written on reviewed, reviewed-by-patch,
reviewed-by-patch-notes-moved, overruled, overruled-by-patch,
overruled-by-patch-notes-moved and on a transcript pass; never for a held
push or a push declined as no-plan, no-branch, dry-run or nothing-new. A write that fails is
journalled provenance-write-failed and never changes the judgment; a write
that lands is journalled provenance-written. The record is written once
per repository and commit: a re-push of the same commit finds the file and
keeps it (the first pass's origin stays), journalled provenance-kept.
The preview datum is the preview gate's own decision: evidence when the
plan's evidence stood, approved when the person's approval did,
not-required for no interface change. While the preview has not stood
(the gate holds the push), no record is written, journalled
provenance-deferred: the push that passes writes it. Like the pass files, the
directory is hook-only: Write, Edit and Bash writes are refused.
What the journal records
Every push writes its decision line, under the rule's id, in the buckets
greenbelay status counts: a declined push as unconfirmed with the reason
(reviewed, reviewed-by-patch, reviewed-by-patch-notes-moved,
overruled, overruled-by-patch, overruled-by-patch-notes-moved,
no-plan, dry-run, no-branch, unresolvable), a spoken one as
advised, denied or watched. The excerpt of a spoken line is
structured:
tree=<12 hex> review=<stale|rework|missing|unknown> verdict=<approve|approve-with-changes|rework|->
A push that passed writes a second line. Its review is compared with the
rules as they are now, advise-only and never holding the push, and a
rules-checked line is journalled. status counts it in no bucket, because
its outcome, rules-checked, is a note beside a decision, not one. Its
excerpt is tree=<12 hex> review=<rules-current|rules-missing|rules-stale|rules-unknown>:
rules-current when the review read the rules as they are now (the count the
rollout reads before the check may deny), rules-missing when its prompt had
no rules line, rules-stale when the rules changed since, rules-unknown
when the pass predates the stored sha or greentopo could not answer.
A third line, candidates-checked, records what the review did with the
candidates greenspotter listed. Its excerpt is tree=<12 hex> review=<...>:
candidates-ruled n=<n> when every listed id has a ruling,
candidates-undisposed n=<k>/<n> when k of n do not,
candidates-unlisted when the reviewer's prompt had no block,
candidates-unknown when the pass predates the stored candidates, and
candidates-unavailable when it had the unavailable marker. It never changes
the judgment, and status counts it in no bucket.
Candidates and rulings
greenbelay review-brief runs greenspotter candidates --base <merge-base> --json --max 40 in the repository (greenspotter from PATH, or the program
named by GREENBELAY_GREENSPOTTER; a bounded wait; stdin from /dev/null). A
candidate is a line greenspotter marked on a line the branch adds, for the
reviewer to rule on; greenspotter owns the document (greenspotter.candidates/1)
and the ruling record (greenspotter.ruling/1). The reader refuses any other
format token and ignores unknown fields.
Right after the RULES line the brief prints a block to paste verbatim into the reviewer prompt:
<<<CANDIDATES sha=<sha256 of greenspotter's stdout> n=<count>>>>
<id> <rule> <pattern_id> <path>:<line>
<<<END CANDIDATES>>>
and a ## Candidates section in the body with each candidate's id, place,
rule, pattern message and text, the per-rule overflow counts, and the
instruction for the result. When greenspotter is missing, fails or prints
another format, the block is <<<CANDIDATES unavailable>>>, the section
names the cause, stderr carries one line, and the brief still exits 0.
The reviewer's result carries a Candidates: block with one line per listed
id: <id> violation: <finding> or <id> fine: <one clause quoted from the rule body>. An id is the full 64 hex or a unique prefix of at least 12.
On a passing review (the transcript, the tree memory and the patch memory
alike; the pass file keeps what the prompt listed and the result ruled) the
push check journals the candidates-checked line above and appends, for each
ruling, one greenspotter.ruling/1 line to
~/.claude/greenbelay/rulings/<repo>.jsonl (created 0600 in a 0700
directory, appended to and never rewritten): format, review (the
reviewer's agent id), tool (amont-agent), repo, tree (the content
id), candidate, rule, pattern_id, pattern (the message from the
brief's section, the rule id when unknown), ruling, clause and at
(RFC 3339 UTC). A retried push of the same review appends no second record
for the same review and candidate. greenspotter ruling-record --check <file>
validates the file.
A repository with no .adr.yaml gets a brief with no RULES line and a
# Code rules section saying that no decided code rules apply (stderr says
so in one line); rules-sha there still exits 3.
A repository with .adr.yaml where greentopo is not installed (GREENBELAY_GREENTOPO
unset and no greentopo on PATH, not even a non-executable file or a dangling
symlink) also gets the brief, with no RULES line and a # Code rules section
saying the decided code rules were not read; stderr says so in one line. The
review-brief exit codes: 0 the brief was printed (greentopo not installed
included), 1 a repository error, 3 an installed greentopo failed or
GREENBELAY_GREENTOPO points nowhere. A row of greentopo relevant
without a string key is an greentopo error (exit 3) naming the row.
Away from a push: overruled, answered, unbound, unknown,
prefilled, unrecorded for the marked question, and denied for a
refused write. The soak reads them with:
grep -E ' implementation-review ' ~/.claude/greenbelay/journal.log
Stance
Ships advise. git config --global greenbelay.implementation-review.stance deny holds a push whose review is missing, stale, rework or unknown;
observe journals and says nothing. The 2026-10-06 soak review, alongside
push-preview, decides between deny, advise and retiring the gate from
the journal's review= counts and the first real cycles' finding quality.
Recording what a review found
echo '[{"severity":"high","disposition":"fixed","section":"Verification"}]' |
greenbelay implementation-review record <plan.md> --verdict approve-with-changes
Appends one greenbelay-impl-review-outcome-v1 row per invocation to
~/.claude/greenbelay/implementation-review-outcomes/outcomes.jsonl (outside
the hook-only store): recorded_at,
tree (the content id of HEAD, as tree-sha), round (one more than the rows
already kept for the plan: a per-plan count, unlike the plan-review ledger's
round), plan_path, model (the resolvedModel of the completed
implementation-review agent in the newest transcript of the working
directory's session, empty when none), verdict and
findings. Each finding on stdin is {severity: blocking|high|medium|low, disposition: fixed|deliberate|overruled, section?} and is rebuilt from those
keys alone; --verdict is
approve, approve-with-changes or rework. A bad severity, disposition or
verdict exits 2 and appends nothing; an unreadable stdin exits 1. When a pass
is remembered for the tree and its verdict differs from --verdict (a remembered
overruled counts as agreeing with rework), a warning
goes to stderr. The command writes only outcomes.jsonl
and its lock file, never a pass file. greenbelay plan-review stats reads
this ledger and reports it as role implementation-review, fixed counting as
accepted.
Per-profile briefs
greenbelay review-brief --profile <role> (backend, platform, unix,
tui, react, ui-design, architect or lang:<x>) adds a
Profile: <role> line after the TREE, RULES and CANDIDATES lines and, after
the code rules, a ## Judge rules for <role> section: the full text of each
active code rule whose **Checked by:** classes are all judge and whose
**Reviewed by:** line names the role (language matches any lang:<x>).
A Reviewed by: name outside that set makes the command exit 1 naming the
rule and the name; an unknown --profile exits 2. Without --profile the
brief is unchanged except for one line in the plan section, Declared code review for <repo>: <profiles|none — reason|not declared>, read from the
plan (the canonical file of a pointer plan, under the plan root).
The declared profiles at a push
When the plan declares code-review profiles for the repository, the push
needs a pass for each of them on the pushed tree, beside the implementation
review (ADR-0052). The hook reads the declaration from the plan(s) changed
under docs/plans/ between the merge base and the pushed commit, as that
commit holds them. A pointer plan (canonical: <repo>:<path>) that has
its own ## Code review section declares through it; that section must
declare this repository, and an empty one or one naming only other
repositories is a declaration error. When the canonical plan is also
readable and holds a different line for this repository, the pointer's line
wins and pointer-line-drift is journalled. A pointer with no section is
read through its canonical file under the plan root (3.14.0). A canonical file or a
## Code review section that cannot be read is held under deny and
journalled (profiles-unreadable) otherwise. A plan with no section, or a
repository line none — …, requires the implementation review alone; a
plan with no section journals undeclared-profiles.
A copy of a reviewed block
A branch whose whole change is an exact copy of a block that was fully reviewed once needs no declared profile (ADR-0067). The plan says so on the repository's line:
- <repo>: none — copy of fp:<12 hex>
greenbelay plan-panel --code-review <plan.md> -C <dir> --base <ref>
proposes that line. The hook does not trust the sentence: it recomputes the
fingerprint of the pushed branch (greenbelay block sha) and rechecks the
registry. A hit requires the implementation review alone and journals
profiles-copy-matched; a miss requires the full declared profiles, with no
question to the person, and journals profiles-copy-missed.
Only the hook registers a block, after every profile in the full set for the
block's file types has its own approve on that exact tree. The entry keeps
that profile set and the rules sha. A miss names its cause: no entry for fp:<id>, revoked: <because>, role <r> not covered, rules changed since registration, agent <a> changed since registration, no passed pin check; run greenbelay review-brief -C <dir> (no record), pin check failed: <detail> (the record's own detail), the pin record was made with GREENBELAY_GH set; run review-brief without it, binary diff, git failed.
greenbelay block manages the registry:
block sha [-C <dir>] [--base <ref>]prints the fingerprint of the branch.block list [--json]lists the registered blocks, with the repository each came from (-andsource_repo: nullwhen the entry predates the field).block revoke <fp> --because <text>ends a registration, for instance after a defect is found in a copy, until the person reinstates it; it prints the pilot (<source repo> TAB <branch> TAB -) and every recorded copy for a re-check. An ambiguous prefix exits 1:matches <N> blocks; give more hex.block reinstate <fp>lifts a revocation and says so on stderr. It is the person's to run, in their own shell; the guard refuses it to an agent (block-reinstate).
A review recorded with implementation-review record carries copy: true
when the hook journalled profiles-copy-matched for its tree, and copy: false otherwise; a row written before the key existed reads as not a copy.
greenbelay plan-review stats counts, per seat, the copy-tagged reviews
(copies) and the blocking or high findings fixed in them (copy-defects),
which is how the rule is revisited at the first defect found in a copy or at
30 copies.
A branch that changes nothing outside docs/plans/ needs no profile: there
is no code for one to read (3.14.0). The hook decides it with git diff --quiet --no-relative --ignore-submodules=none over the whole tree minus
docs/plans/, before it reads the declaration, and journals
profiles-plan-only; a diff git cannot answer is not plan-only. The
implementation review still reviews such a branch's plan record.
A completed launch counts for a profile only when its agent is the one the
profile maps to (lang:<x> to code-review-language, ui-design to
interface-review, any other role to code-review-<role>) and its prompt
carries exactly one Profile: <role> line naming that profile, in its
header. Two lines, or a line naming another profile, count for nothing. The
header is every line before the first that opens the body: a Markdown heading
(# to ###### then a space), a code fence (three or more backticks or
tildes), or an unfenced diff (diff --git, @@). So an inlined brief, which
starts with # Implementation review brief, and an inlined diff never add a
line. The launch's own Profile: line must come before them: a prompt that
opens with the inlined brief and carries its line only there counts for
nothing. The review block (<<<TREE …>>>) a profile review binds is read
from the same header, so a block inside an inlined brief or diff binds no
tree (3.11.1). A resumed round
(SendMessage) inherits its launch's profile and may omit the line; one that
names another profile counts for nothing. A profile review never satisfies
the implementation review, nor the reverse. A profile's verdict is read like
the implementation review's: rework is not a pass.
A pass is a completed review in this session's transcript whose TREE
block names this repository and the pushed content id, or a remembered pass:
by-profile/<slug>/by-tree/<repo>/<sha>.json, and
by-profile/<slug>/by-patch/<repo>/<patch>.json for a tree with the same
branch patch and rule files (lang:rust is lang-rust). The implementation
review's own by-tree/ files are unchanged. A missing profile is refused:
missing code review of <repo> tree <12 hex>: <agent> [--lang <x>], … (declared in <plan path>). Launch them on this tree, or narrow ## Code review with a reason.
The person's Overrule of a profile's rework uses
[implementation-review <repo>@<sha64> profile=<role>] and writes that
profile's pass only.
A profile's approve carries to a fix
After a fix the implementation review always reads the new tree, and a
profile whose verdict was rework or approve-with-changes reviews again.
A profile that said approve keeps its pass on a later pushed tree when the
hook can check it (work.code-review-delta, ADR-0052). A profile pass
records the commit the review read (the newest commit of
git rev-list <pushed> ^<merge-base> whose content id is the reviewed tree),
the plan that declared the profile, and a digest of this repository's parsed
## Code review declaration. When a declared profile has no pass on the
pushed tree, and the implementation review has passed it, the hook accepts the
pass of an earlier commit C only when all hold:
- its verdict is
approve(notapprove-with-changes,reworkoroverruled); - C is in
git rev-list <pushed> ^<merge-base>: an ancestor of the pushed commit and strictly after the current merge-base, so a rebased branch (the old commit is no longer an ancestor) and a review from a plan already merged carry nothing; a rebase keeps a pass only by patch, as before; - its plan path and declaration digest equal the current ones;
- the pass has all three fields; one written without them never carries.
The approval may also come from the session itself, with no push ever
judged at its tree (3.13.0). The hook reads the transcript before any filed
pass. It takes this profile's latest completed review, in launch order, of a
tree of a commit in git rev-list <pushed> ^<merge-base> other than the
pushed one:
- if that review is not
approve, nothing carries, not even a filed pass: a laterreworkof an earlier tree outranks an older pass; - if it is
approve, it carries when every branch commit whose content id is the reviewed tree holds the current plan path and declaration digest, read at that commit from the plans it changed since the merge-base. A content id leavesdocs/plans/out, so a plan-only commit shares its tree: each such commit is one the review may have read. A declaration that differs or cannot be read there carries nothing, and never holds the push as unknown; - a pointer plan with its own
## Code reviewsection is read at that commit like any plan, and carries; one without the section records no revision of its canonical plan, so what it declared then cannot be proven: it gets no session carry, and filed passes still may.
The carry writes a pass for the pushed tree (how is carried-from <12 hex of the reviewed content id>) and journals profile-carried with
carried-from <12 hex> and the git diff --shortstat C <pushed>. Otherwise
the profile is missing and must review the new tree.
The implementation review's own block is read from the prompt's header too
(3.13.0), as a profile's is: a <<<TREE …>>> block inside an inlined brief
or diff binds nothing, so the prompt's TREE line comes first.
The push browser check
Interface work is done when an agent has looked at the rendered result in a
real browser through the browser-check agent. Nothing bound that look to
what was pushed: a change could go out with no check, or with the check of an
older tree. The push-browser-check rule binds the two: a push that changes
interface files goes out silently only when a browser-check of that very
tree completed, and any later edit makes the check stale.
push-preview gates the person's approval of a commit and
implementation-review gates an independent read of the code. This rule gates
the agent's own look at the page. It asks nobody a question: the only way
through at push time is the check itself, or the plan's declaration below.
When it speaks
It fires on a push (not a dry run, not a push to main or master) when all
of these hold:
- the repository has a user interface (a
devscript, orgit config greenbelay.push-preview.ui true); - the pushed branch changes a rendered file, detected exactly as
push-previewdoes it (tests, test-tool configs and comment-only diffs never count); - no pass is remembered for the pushed tree;
- the landed, approved plan does not declare
## Browser check→none: <reason>; - no completed
browser-checkagent is bound to the tree (below).
What binds a check to a tree
The pushed tree is its content id (greenbelay tree-sha, 64 hex, with
docs/plans/ left out). A check counts only when it is a completed
browser-check agent in this session's transcript or in one of its side
transcripts (<session>/subagents/*.jsonl, where a fork runs its checks), and
- its prompt carries the line
<<<TREE repo=<repo> sha=<id>>>>of the pushed tree (greenbelay tree-sha --block -C <repo> <rev>prints it), and - its result has a line starting
browser:that nameschrome-devtools,playwrightorclaude-in-chrome, and a line startingurl:.
A report that stops on unreachable: <url>, or names a browser and no page, is
not a check. The report's other content is not judged. Another session's
transcript never counts, and neither does a check of an older tree: a rebase
onto a moved base can change what renders, so there is no carry-over by patch.
On a pass the hook remembers the tree in
~/.claude/greenbelay/push-browser-check/by-tree/<repo>/<id>.json. Only the
hook writes there; a Write, Edit or shell write into that directory is refused
whatever the stance, and the refusal names the browser-check agent and the
greenbelay tree-sha --block line, not the implementation review's remedy.
The escape
A UI that cannot be served headless is declared in the plan the branch landed:
a ## Browser check section whose first non-empty line is none: <reason>.
It is read as push-preview reads ## Preview → evidence:: the plan must be
approved (its body sha is in plan-approved/), not a pointer plan, and added
since the merge base with the default branch. A pass this way is journalled
declared, with the plan, the commit, the sha and the reason.
Stance and gaps
Ships at advise, ceiling deny (git config greenbelay.push-browser-check.stance deny).
Under deny a push shape the rule cannot read (--all, a detached directory)
is held, so it is not a way around the gate. Where no browser-check agent is
installed, the rule says so at every stance, as advice and never a hold
(ADR-0073: a missing reviewer is reported, not hidden), so a machine without
the agent hears that its UI pushes go unchecked; greenbelay doctor lists the
gap too.
The advice names the tree and prints its block alone on one line:
This push changes the interface and no browser check in this session carried
this tree's TREE line. Launch `browser-check` on the dev server serving this
commit, with this line, on a line of its own, in its brief:
<<<TREE repo=app sha=…>>>
then push again. …
A push run with git -C <worktree> names that worktree's tree.
Measuring
The backtester never runs confirm, so it cannot measure this rule. The journal
carries tree=<12> check=missing|stale|unreachable|gap|unknown per advice and
declared per escape; the 7-day count of Seen lines decides graduation
(greenbelay graduate push-browser-check --to deny, gated on the reviewed corpus)
or demotion (greenbelay demote push-browser-check).
The session notice
There is a mistake no command-level rule can catch, because no command is
wrong: a session opens in a checkout last pulled on Tuesday, the model reads
the tree it is given, and builds a feature that landed on origin/main on
Wednesday. The work is correct against the code it can see.
So at SessionStart the guard does the one thing the model cannot do for
itself.
The stale checkout
It refreshes origin/main — one branch, no tags, killed at five seconds,
skipped when FETCH_HEAD is under ten minutes old so a burst of sessions
shares one round-trip — and if HEAD is behind, says so:
greenbelay/stale-base: this checkout of amont-agent (branch main) is 8
commits behind origin/main; newest there: d3b2ed5 chore(release): 2.1.0
(3 days ago). Work that seems missing here may already exist on
origin/main — `git log HEAD..origin/main --oneline` lists it — and a
branch or worktree started from HEAD inherits the gap; one started from
origin/main does not.
It never pulls. git pull rewrites the working tree under whoever is
using it, and a per-task worktree exists precisely so that nobody does that.
Moving refs/remotes/origin/* is safe in every worktree at once; moving HEAD
is not.
If the fetch fails or times out, the notice is computed against the last successful fetch and says so. When the checkout is up to date, or it is not a repository, or there is no remote, it says nothing.
The stale-base rule is the same fact at the moment it is about to be
inherited: git worktree add, git checkout -b or git switch -c from HEAD
or a local branch, while that start point is behind. The remote form
(… -b feat/x origin/main) is the remedy and never fires.
git config --global greenbelay.stale-base.stance observe # measure, say nothing
git config --global greenbelay.fetch false # never touch the network
git config checkout.defaultRemote forgejo # measure against another remote
checkout.defaultRemote is git's own key for "which remote is the remote", and
a repository mid-migration — origin a mirror going stale, a second remote
carrying the truth — sets it once for both git and the guard. With two remotes
and no preference the guard says nothing rather than guess.
The stale guidance block
The same moment is when an agent reads AGENTS.md and believes it, and follows
it for the whole session. A block generated two releases ago can be wrong
before any command runs.
This one is entirely optional and entirely about
amont. If — and only if — this
repository carries an <!-- amont:start --> block and amont is on your
PATH, the guard asks amont the question amont already answers:
amont agents-md --check
and reports drift. Two file reads decide whether to spawn anything at all, so
a repository with no such block costs no process. No amont on PATH means
this says nothing — which is the right answer for anyone who does not use it.
It reads amont's stderr, not its exit code, and that is not fussiness:
agents-md --check exits 1 for a file it could not read as well as for a
drifted one, so the exit code alone would announce staleness for a permissions
error. A session-opening notice that cries wolf is worse than one that
occasionally says nothing.
git config --global greenbelay.agentsMdNotice false # silence this half
Open plans
If the session opens inside a repository with a docs/plans/ directory
(ADR-0022), one line per active plan: its title and its first unchecked
phase (- [ ] …). A pointer file — a plan whose canonical copy lives in
another repository — prints the canonical path and the phases this
repository carries. At most five lines; the rest are counted.
greenbelay/plans: 1 open plan in docs/plans/ (read one on demand; they are history, not instructions):
- Settings toggle (2026-09-28-settings.md) — next: Phase 2 — route
Closed plans (done, abandoned, imported) print nothing. A plan with no
status, or one outside that list, is reported: nothing else reads plan
front matter, greentopo check included. Nothing from a plan's body beyond those
two lines is loaded — an old plan is history, and loading it into every
session would compete with the instructions that are current.
The size summary
If the session opens at the root of a repository whose greenspotter.toml
has a [size] section (ADR-0089), the notice adds what
greenspotter size summary prints: counts and trends, never the file list,
which stays behind greenspotter size. Without that section no process
starts and nothing is printed.
The summary gets about a second (a 1 s deadline, plus up to half a second to
read a pipe a stray grandchild holds open). Control characters are dropped,
then at most four of its lines are kept, each cut at 200 characters with a
trailing …, whatever greenspotter prints, so a newer or broken greenspotter
cannot crowd out the other notices. The header may carry a trailing #
comment. A missing greenspotter, a non-zero exit, a timeout or empty output
prints nothing; the journal records greenspotter-unavailable or
greenspotter-slow once per session.
The board: session activity
Every session records which repository, worktree and branch it edits, so that
another session can tell whether somebody else is working in the same place.
work-overlap reads it, and greenbelay board lists it (see below).
The activity file
One file per session, <journal dir>/sessions/<full session id>.activity
(the journal dir is <config dir>/greenbelay, ~/.claude/greenbelay by
default). Each line is
<ts> <repo_identity> <worktree_root> <branch>
whitespace-separated, where
tsis epoch seconds;repo_identityis the git common dir, shared by every worktree of a repository (/r/amont-agent/.git);worktree_rootis the worktree's top directory;branchis read fromHEAD, ordetached.
A space, tab, newline or % inside a field is percent-encoded (%20, %09,
%0A, %25), so a path with a space still splits into four fields.
The place is resolved without running a process: the hook walks up to .git,
follows a gitdir: file and its commondir, and reads HEAD.
Which calls record
A call records when its PreToolUse payload is
- an Edit, MultiEdit, Write or NotebookEdit: the place is the one of the file's parent directory;
- a Bash command that runs
git commit,push,tag,worktree add,checkout -borswitch -c: the place is the one ofgit -C <dir>, else of a leadingcd <dir> &&or a subshell(cd <dir> && ...), else of the payload's cwd.
A Read, Grep or Glob, and any other Bash command, records nothing. A target outside any git repository records nothing. The payload's cwd is never the place of a file tool.
Last seen, and what is live
A line is appended only when the place differs from the file's last line.
Every other recorded call only moves the file's modification time. The
modification time is the session's last-seen time, not ts.
Only the latest line of a session is live: a session that worked in repository A and then moved to B is not in A any more, whatever its earlier lines say. A session is live in that place while its file's modification time is less than the window old.
work-overlap looks for peers in two passes, so a write that meets nobody
spawns nothing. The first pass reads only files modified within the last week
(the sweep's horizon; older files are skipped from their metadata), and only
their last line. Only when one of them is in the same repository is the
window read from git config, and the second pass keeps the live ones.
A changed-place append to a file longer than 256 KiB first trims it to the
newest complete lines that fit in 128 KiB, the new line included (a new line
that alone exceeds 128 KiB is kept alone); a call that finds the same place
never trims. The trim writes <file>.tmp.<pid> (mode 0600) and renames it
over the file, so a reader sees the old or the new file whole. A line another
process appends during a trim may be lost. The session sweep deletes it after
a week. The record is written after the decision and never changes it; a
failure to write, and a trim that fails (the line is then appended to the
untrimmed file), are each journalled once per session and then ignored.
work-overlap
Advise, ceiling advise. On a session's first Edit, MultiEdit, Write or
NotebookEdit in a repository, it advises once when another session's latest
line names the same repository and that session is live. The window is 2 h
and is set with git config --global greenbelay.work-overlap.window
(90m, 3h, 2d; a bare number is seconds). The message names the other
session, its worktree, its branch, the title of the active plan its branch
added (the first active file under docs/plans that the worktree's HEAD
adds relative to the repository's default branch, read with bounded git calls
only when the rule fires; none for a peer on the default branch) and how long
ago it was last seen. The plan lookups of all named peers (at most three)
share one 2 s budget, and a peer reached after it is named without a plan.
The message then points to greenbelay board --repo <repo name>, then to a message to that session (SendMessage) or to the person. It
is silent when the only matching activity is the session's own, and fires
when another live session works in the very same worktree.
The once-per-repository telling is used up only when a live peer is found:
a session whose first write meets nobody is told on a later write, once a
peer appears. Under observe the journalled firing counts as the telling,
so the journal holds one line per session and repository.
greenbelay board
greenbelay board [--repo <name>...] [--since <dur>] [--fetch] [--json]
Read-only. It lists, per repository, the work in flight and what landed
recently, derived from git and the activity files on every call. It reads the
activity files through the same reader as work-overlap and never writes
them.
Repositories: those named with --repo (resolved like plan-review repos=
names: git config greenbelay.plan-review.<name>.path, else
<plan root>/<name>), else the working directory's repository, else every git
repository directly under the plan root.
In flight: each worktree of git worktree list --porcelain (the main
checkout on the default branch with no session is not listed), and each local
or origin/ branch not merged into the default branch that is live. A branch
is live when its tip commit is newer than --since (default 48h), when it is
checked out in a worktree, or when a session's latest activity line names it.
Plans are read (git diff, git show) only for live branches: a stale
unmerged branch, with or without a plan, costs no git call beyond the single
for-each-ref listing and is not listed. Each entry shows:
- the path (if checked out) and the branch; a branch checked out in a worktree
whose change is already on the default branch is marked
(merged: git worktree remove <path>); - the title of the active plan: a plan file under
docs/plansthat the branch adds relative to the default branch and whosestatusisactive. A plan whoserepos:names several repositories is listed under each of them: in another repository's block it appears as a branch-only entry labelled<repository>:<branch>(in branch-name order), found by scanning the other repositories directly under the plan root (primary checkouts only: a linked worktree directory is never scanned, and a repository is scanned once), unless that repository carries the same file itself. This scan runs when one repository is selected (--repo, or the cwd); listing the whole root skips it, since every repository is listed anyway. For such a repository a branch is live when its tip is within--sinceor it is checked out; its sessions are not read here (ask--repofor that repository). It costs onegit for-each-refcall (default branch, branch tips and checked-out branches), so a sibling with no live branch costs exactly one git call; a live branch adds one merged-ness listing, then plans for it; programme <slug> ticket <id>for aprog/<slug>/<id>branch;- the sessions whose latest activity line names that worktree, with the full session id and the age of the activity file's modification time;
- for a worktree with an owner record,
owner: <name> [ref] / <uuid>, claimed <age> agoand, on its own line, the owner's state (live, message it,cleared since: …,gone,stale, …,unknown: …), every line wrapped at 78 columns without cutting a word (owners); pushed by <name> / <uuid8> <age> ago, the newest push of that branch in that repository recorded inpushes.log.
Merged: a live candidate branch (a worktree's branch, or a live branch
with no worktree) is merged when its whole change from the merge-base
(git diff <merge-base> <branch>) is not empty and its git patch-id --stable equals the patch-id of one non-merge commit on the default branch
after the merge-base. The default branch's patch-ids are built once per
repository per call, from the oldest merge-base among its candidates
(git log -p --no-merges <oldest-merge-base>..<default> into git patch-id --stable); each candidate then costs a merge-base and one diff. Every diff
and log runs with --no-ext-diff --no-textconv --no-color, and nothing is
written to the repository. A merged branch with no worktree is left out; one
in a worktree stays listed with the label above. This is how a squash merge
reads as merged although the branch's commits are not ancestors of the
default branch. Known limits:
- Without
--fetch, a branch merged after the last fetch reads as in flight. - A squash whose content changed while merging (a conflict resolution), or one
merged after the default branch changed lines within 3 lines of the branch's
change, is not recognised and stays listed until it leaves the
--sincewindow.
Just landed (landed in the JSON): git log --first-parent <default> --since <dur>, with short sha, subject and age. --fetch first runs
git fetch --prune origin -q on the selected repositories, up to 4 at once,
each within 60 s, and every fetch finishes before any report is built; a
failure is one stderr line starting <repo>:, in the order of the selected
repositories. When stderr is a terminal a fetching <n> repositories... line
comes first.
A repository with nothing in flight and nothing landed prints nothing unless
it was named with --repo. --json prints an array of {repo, path, worktrees: [{path, branch, merged, plans, programme_ticket, sessions: [{id, last_seen_secs}], owner, pushed}], landed: [{sha, subject, age_secs}]}; merged is a boolean; plans is an array of titles (empty when none); path is null for a
branch with no worktree, programme_ticket is <slug>/<id> or null; owner is null or {session, name, ref, pid, state, claimed_at, now_session?} (now_session for a cleared
owner), and pushed null or {session, name, sha, at}. Exit 0
unless the command itself fails; an unreadable repository is reported on
stderr and skipped.
Owners: who holds the work
Several sessions on one task need to agree on who owns it, by an address
they can message. greenbelay keeps one owner record per worktree and per
programme ticket, and one line per push that left the machine. Every output
is advice, journalled under the work-owner rule (stance advise); nothing
is refused.
Who a session is
Claude Code keeps one file per live session, ~/.claude/sessions/<pid>.json,
with sessionId, name (the name SendMessage takes), pid and startedAt.
greenbelay reads it best-effort, and only when peerProtocol is 1: it is
the host's undocumented store, read under the host-store limits of the
decisions corpus's harness.cross-tool-reads (ADR-0088). A *.key file beside it holds peer tokens and is
never opened. GREENBELAY_HOST_SESSIONS_DIR points the reader elsewhere.
The calling session is the nearest ancestor of the hook (at most four processes up) that has a registry file. Against an owner record, the registry answers one state:
| state | meaning |
|---|---|
live | the same process (pid and startedAt) still runs that session |
cleared | the same process now runs another session, after a /clear, which has none of the work |
gone | no file for that pid, or a file with another startedAt (a reused pid) |
stale | not refreshed for 8 hours, even when live |
unknown | the directory is unreadable, the file does not parse, or peerProtocol is not 1; never reported as gone |
The records
Under <data dir>/owners/: worktree/<hash>.json, keyed by the worktree's
real path, and ticket/<repo>/<programme>/<ticket>.json. Each holds v: 1,
the identity {session, pid, started_at, name, ref?}, claimed_at and
refreshed_at. A free record is created with link(), so no half record is
ever visible; a reclaim, a takeover and a steal hold an flock on
<record>.lock (never removed) and read the record again under it, so two
claims never both win.
A gone, stale or cleared record is free. A cleared record is taken
over by its own process's new session on that session's first write in the
worktree or its first resume of the ticket; a takeover drops the old ref.
Who claims:
- The first write in a worktree claims it (a file write, or a git command
the activity hook tracks), unless it is the primary checkout on its default
branch. Later writes refresh it.
git config --global greenbelay.work-owner.auto-claim falseturns this off. - An observed
relais programme claim <programme> <ticket> --dir <dir>that exits 0 writes the ticket record. This is interim: it goes when relais callsgreenbelay owner claim --ticketitself. greenbelay owner claim, below.
greenbelay owner
greenbelay owner claim [--ticket <repo>/<prog>/<id>] [--name <n>] [--ref <r>] [--steal]
greenbelay owner release [--ticket <repo>/<prog>/<id>]
greenbelay owner show [--worktree <p> | --ticket <repo>/<prog>/<id>] [--json]
claim exits 0 when claimed, 3 when another live session holds it (stderr
names it and the SendMessage to send), 2 on a usage error, 1 otherwise.
--ref records the session's short ref ([417dc6]), which only the session
knows. release exits 0 when released or already free, 3 when another session
holds it. show exits 0 when it shows an owner, whatever its state, and 1
when there is no record.
The resume check
A prompt starting resume <repo> <programme> <ticket> (not a driver's
… drive: …) is looked up before the session reads it. The ticket record
answers when it exists; without one, the worktree records on
prog/<programme>/<ticket> whose own repository is <repo> do, and several
sessions among them answer unknown.
- Another live session owns it: the context names it,
<name> [ref] / <uuid>, its worktree and when it was seen, and says to message it with SendMessage before any work; aWARNING:note tells the person. - This process owned it before its
/clear: the record is taken over, and the context saysyou continue <ticket>. - Its owner's process has cleared: the context names the old session and the
new one, and says not to credit it; a
WARNING:note tells the person. - Live records that disagree: all are named, and nothing is taken over.
- No owner, or a gone or stale one: silent. No registered caller:
unknown.
Pushes
Exit 0 is not publication. A git push is credited only for a ref-update line
in its output (<old>..<new> <src> -> <dst>, * [new branch]), never for
"Everything up-to-date"; a land only for a receipt whose status is landed.
A detached land's launch saves its launcher, and the --wait that sees it
landed credits that launcher once, never the waiting session. The line goes to
<data dir>/pushes.log (tab-separated: time, session, name, pid, start,
repository, branch, full sha), which rotates at 1 MB.
greenbelay who-pushed <branch|sha> [--repo <r>] [--json]
prints each recorded push, newest first: <ago> <name> <uuid8> <state> <branch> <sha7>; --json carries the full session UUID. With none, it says
no pushes recorded for <arg> on stderr and exits 1.
Limits
- Unix only: the calling session is found by walking parent pids, which only works on unix. Elsewhere no record is ever made, so there is nothing to show.
- The session file is the host's own, undocumented store; a format change
reads as
unknown, never asgone. - A ticket is found only through a ticket record or a worktree on its
prog/branch. An owner working on a feature branch with no ticket record is not found by the resume check. - Only
resume <repo> <programme> <ticket>prompts are checked. - A squash merge on the default branch is not mapped back to its branch:
who-pushedanswers by branch or by pushed sha. - The ref is whatever a session reported; the registry does not carry it.
Configuration
Every key is plain git config, readable and removable without this tool.
The keys live under greenbelay.. Keys written as amont.agent.* by an
earlier release are migrated by greenbelay migrate; see
migrate. Environment variables start with GREENBELAY_.
The kill switches
| key | default | effect |
|---|---|---|
$GREENBELAY_OFF | unset | any value switches the guard off for that shell |
greenbelay.enabled | true | switches it off everywhere |
The environment variable is checked first, before any rule runs, because
reading a git config key costs a process and the variable costs nothing.
greenbelay.enabled is consulted only once something has already fired.
Both take git's own boolean dialect — true/false, yes/no, on/off,
1/0, case-insensitively — because git parses them, not us. A value git
refuses warns once and falls back to the default rather than failing.
Stances
| key | takes |
|---|---|
greenbelay.stance | observe | advise | deny — every rule |
greenbelay.<rule>.stance | the same, for one rule |
greenbelay.<rule>.denyAgents | repeatable: an agent type (relais:relais-worker-haiku-default) or a prefix ending in * (relais:relais-worker-haiku-*) |
Most specific wins. See stances.
denyAgents raises advise to deny for a subagent of a named type, and only
for symbol-grep-not-lsp. It is read from --global and --system config only
(a repository cannot set it), and the two lists are merged: an entry in
--system config cannot be removed from --global config, because an empty
value clears nothing. An empty value, a
bare *, or a * anywhere but the end is ignored with one warning; a scope git
refuses adds no values and is reported once. The deny is refuse-once: the first
search for a pattern by that agent is refused, and the identical retry runs. If
the refusal cannot be recorded, the rule advises instead of refusing every retry.
# add the value once (idempotent), and take it back out (exit 5 means it was already absent)
git config --global --get-all greenbelay.symbol-grep-not-lsp.denyAgents | grep -qxF 'relais:relais-worker-haiku-*' \
|| git config --global --add greenbelay.symbol-grep-not-lsp.denyAgents 'relais:relais-worker-haiku-*'
git config --global --fixed-value --unset-all greenbelay.symbol-grep-not-lsp.denyAgents 'relais:relais-worker-haiku-*'
The session notice
| key | default | effect |
|---|---|---|
greenbelay.fetch | true | may a session opening touch the network at all |
greenbelay.agentsMdNotice | true | may it mention a stale amont guidance block |
greenbelay.opener | platform opener | the command greenbelay open and preview register --open use to show a page: a template, split like shell words, {} replaced by the page inside each word (appended when absent), run with no shell. Unset: open, xdg-open or rundll32 url.dll,FileProtocolHandler {} |
checkout.defaultRemote | — | git's own key; which remote is the remote |
Showing a page: greenbelay open
greenbelay open <url|path> opens a page in a window the person sees
(work.page-shown-before-asked). A path must exist and is opened as a
percent-encoded file:// URL. The opener is spawned in its own process group
with no stdin or stdout and its error output kept in a temporary file; it is
waited for up to 2 s. Exit 0, or still running at 2 s (a browser that became
the process), counts as launched and it is never killed. Success prints
nothing; a failure prints one line naming the page, the opener's error output
and greenbelay.opener, and exits 1. A usage error exits 2.
The platform default can hand a page to an automation instance of the browser, so name the command that reaches your own:
git config --global greenbelay.opener '"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" {}'
preview register --open uses the same opener and prints its JSON after the
attempt, with "opened": true or "opened": false; an opener failure leaves
the registration standing and the exit status 0. greenbelay doctor reports
the opener (and warns, with this command, when its program is not found).
Beacons
Beacons tell a central collector which rules a release loaded and which fired (ADR-0090, blue-factory). They are off. Greenbelay writes a beacon to a local spool only when all of these hold in the hook's environment:
GREENBELAY_BEACONS_ENDPOINTis the collector's OTLP endpoint. Claude Code strips everyOTEL_*variable from a hook's environment, so the standard names cannot carry it.GREENBELAY_BEACONSison.- Nothing switches it off:
OTEL_SDK_DISABLED=true;GREENBELAY_BEACONSset to0,off,falseorno(trimmed, any case); or git configgreenbelay.beaconsset to one of those. Any off value wins, and an unrecognised value counts as off. No git config key or greenbelay file turns beacons on.
# the operator, in Claude Code managed settings (env):
# GREENBELAY_BEACONS=on
# GREENBELAY_BEACONS_ENDPOINT=https://otel.example.internal:4318
# a person who wants them off whatever the environment says:
git config --global greenbelay.beacons false
A repository's own .claude/settings.json env reaches the hook the same way
the managed one does, and greenbelay cannot tell them apart: a repository can
turn beacons on toward its own endpoint. greenbelay doctor prints the
endpoint host, so the source is visible.
A beacon holds: the rule id, the verdict (pass, warn, block), the arm,
the session id, the release, and sha256: of the repository name (guessable
for a common name). It never holds a command, a path, an excerpt or the
endpoint. greenbelay doctor says which of off (no endpoint, not opted in, an
off switch) or on the current environment gives, and whether the spool is
unwritable or full. It reads the environment of the shell it runs in, which can
differ from the hook's.
The spool is ~/.claude/greenbelay/beacons.jsonl, one JSON object per line,
written whole under a lock. Past 1 MiB it is renamed to beacons.jsonl.1 (only
when no .1 exists); with .1 present, beacons are dropped once the two files
reach 2 MiB, until a sender drains .1: until a sender exists, beacons stop at the cap and greenbelay doctor says spool full. A sender reads .1 first, then the
live file, skips a malformed or unterminated line, and removes .1 only while
holding beacons.lock in the same directory, after the collector's
acknowledgement. Greenbelay never deletes .1.
What is deliberately not configurable
Which file any of these keys can be set in. --global, then --system,
and nothing else. Not a committed file, and not the --local/--worktree
config of the repository you happen to be standing in — see
stances. Write them with
git config --global; a bare git config inside a repository writes
--local, where this tool will not look.
Whether a failure is silent. It always is. See what it will not do.
Whether the journal can affect a decision. It cannot.
What it will not do
It never emits allow. That would short-circuit your own permission
prompt, so a guard approving everything it has no objection to would have
switched off the permission system it was installed beside. Silence is how it
says "no objection".
Every failure path is silence. An unreadable payload, an unknown event, a command it cannot parse, a rule that panics, a journal it cannot write — all of them exit 0 having written nothing.
A hook that fails toward refusing gets in the way of work you knew was
correct, and the fix people reach for at that moment is to delete it from
settings.json, which switches off every rule at once. One that fails toward
silence loses a single firing. That trade is the whole posture, and it is why
the hook payload is parsed with serde_json::Value and hand-written accessors
rather than a derived struct: a field that is missing or has changed type
becomes "no opinion", not a parse error somebody would be tempted to treat as
an opinion. What the hook writes back is emitted by a hand-rolled escaper
(src/json.rs), so the reading and the writing share no representation.
It does not judge what it cannot read. Heredocs without terminators,
unbalanced quotes, eval — all opaque, and opaque never fires.
The unit of that is the pipeline, not the line. | chains one command's
output into the next, so a stage we cannot read makes the whole run
unreadable. &&, || and ; do not: a command there is as independent of an
unreadable neighbour as of any other clause, and treating the whole line as
opaque cost every rule on it — measured over 33,774 real commands, 218 had a
readable pipeline thrown away. Those are judged now, and check names the run
it could not read beneath the verdict.
Two things keep that honest. eval, source and . run in THIS shell and
can move it, so one of them still hides the whole line — otherwise a later
confirm would resolve a path against a directory we can no longer vouch for.
And a finding from a partly-read command never refuses: it advises, whatever
stance the rule carries. Total opacity would have let the command run, so
blocking on half a reading is the worst outcome available.
It does not phone home by itself. No update checks, no fetches — with one
exception, which is git fetch against your own remote for the
session notice, and greenbelay.fetch false switches
that off. Nothing leaves the machine on greenbelay's own account. A separate,
redacted beacon stream exists for an operator who
runs a collector; it is off until that operator opts in (see below).
No repository can change a stance. Stances are read from --global and
--system git config only — never from a committed file, and never from the
.git/config of the repository the agent is standing in, which is a file that
agent could write. See stances.
The journal
Every firing is recorded at ~/.claude/greenbelay/journal.log, redacted. The
journal stays on the machine: it is never transmitted, and it is never the
source of a beacon. A beacon is a separate, smaller record (see
Beacons): a rule id, a verdict, the arm, the
session id, the release and a hashed repository name, and never a command, a
path or an excerpt.
It only counts. Nothing in it may participate in a decision — the rules read the command in front of them and nothing else. A guard whose verdict depended on its own history would be one you could not reason about from the command alone, and could not test from a corpus.
Shell analysis
src/analysis/ answers one question about a single Bash command, before it
runs: which network transfers it may make, and which it must, with the
evidence for each count. No rule consumes it now (request-fanout, its
first consumer, was retired); greenbelay analyze prints it. The analysis
decides nothing.
Layers
| layer | module | job |
|---|---|---|
| frontend | analysis::frontend | source → crate-owned IR, spans on every node |
| semantics | analysis::interp, state, domain | abstract interpretation: state, control flow, exit statuses, counts |
| command models | analysis::models | a client's arguments → its explicit transfers |
Everything in analysis is pure. The dialect is an input; nothing reads the
environment, the filesystem or the network. The legacy lexer
(src/shell.rs) is untouched and still serves every other rule.
Inputs
- The command text.
- The dialect —
bash,zshorunknown. The hook reads it fromSHELL;check --dialectsets it; the backtester always usesunknown, because transcripts do not record the shell. Where bash and zsh differ, anunknowndialect gets the join of both readings — never one of them silently.
Dialect differences that are modelled: whether the last element of a
pipeline runs in the current shell (zsh yes; bash only under
shopt -s lastpipe); word-splitting of unquoted parameters (bash splits,
zsh does not); an unmatched glob in a URL-shaped word (bash passes it
through; zsh refuses the command); break/continue with no loop in the
current shell, as inside ( … ) (bash warns and carries on; zsh leaves).
Where the command does not say which seq runs, seq 5 1 is either nothing
(GNU) or five numbers (BSD, macOS): both are allowed.
tools/shell-oracle/ checks all of this against bash and zsh actually
running generated scripts with stubbed clients — see its Cargo.toml.
Assumptions
Every "established" count holds under these, and the rule's message lists them:
- the shell is not killed from outside;
- redirections succeed;
errexitandpipefailare off unless the command sets them (then they are modelled);- no aliases are defined;
- inherited environment variables are unknown;
- the command has no positional arguments of its own.
What is counted
Explicit command-line transfers: the requests a client's arguments ask
for. Redirects, authentication hops, a client's own retries and pagination,
and defaults from ~/.curlrc are named as possible extras and never counted.
A count is an interval: at least lower, at most upper, where upper is a
number, saturated (too large to represent), uncapped (positive evidence
that nothing bounds it: a loop following next-page links, --paginate,
wget -r, while true with no way out), or unknown (no evidence either
way). Zero annihilates: code that provably never runs makes no transfers,
whatever it would have done.
A finite upper bound on a loop comes only from the counter pattern: a
literal initial value, a comparison as the condition's final command, exactly
one unconditional +1 of the counter in the body, and no other write to it —
including from a function the body calls, or from anything unmodelled — and
no continue that could skip the increment.
Pacing
Each path through the interpreter carries how long it definitely slept
(sleep 30, sleep 2m; a backgrounded sleep does not count). A loop is
paced when every path back to its head — the end of the body, or a
continue — slept: a continue that skips the sleep, or a sleep behind a
condition, leaves it unpaced. A paced call site records the interval and its
burst: the transfers it makes per iteration, an inner loop or --retry
included. The innermost paced loop is the one recorded.
Paced and unpaced transfers never join across if branches: a poll in one
branch and a one-off request in the other are two different kinds of load.
The supported subset
Sequences, &&/||, pipelines and !, if/elif/else, case with ;;,
;& and ;;&, for, for ((…)), while, until, { }, ( ), (( )),
[[ ]], [ ]/test, function definitions in both forms, local/typeset,
break/continue with levels, return, exit, set -e,
set -o pipefail, shopt -s lastpipe; $( ) and backticks, $v, ${v},
positional parameters, $@/$*, the ${v:-x} family (not evaluated: its
value is unknown), every quoting form, unquoted brace expansion.
Unknown and Incomplete
- Unsupported constructs —
eval,source,trap,xargs,parallel, a command name built at run time, a program that runs another program — may do anything: every variable becomes unknown, the command may exit or never end, and the region is reported as activity the analysis could not follow. It never erases a known count elsewhere in the command. - Incomplete means a resource limit ended the analysis (nesting depth, IR size, interpreter steps, call depth, recursion). What was found before it is kept; nothing after it is known.
- Cardinalities —
{1..999999999},seq, curl URL ranges — are computed arithmetically and never expanded.
A rule built on the analysis never fires on an unknown count alone.