Expand description
The implementation review (ADR-0022, work.implementation-review):
before the push of a branch that carries a plan, one independent
reviewer has read the diff against the plan and the active rules, and
its verdict is bound to the tree it read.
A review is bound to the content id of the commit it read (attest
SPEC, “Content id”; not attest’s canonical tree, which counts whether a
plan exists): the sha256 of git ls-tree -r -z --full-tree <rev>’s entries — mode,
type, object id and path, in git’s own order — with every entry under
docs/plans/ left out. So recording the review in the plan never makes
it stale, a later code change does, and the id is 64 hex whatever the
repository’s object format. It is computed read-only: no index, no
object written, nothing to clean up if the hook is killed.
The repository in a block is named by the basename of the parent of
git rev-parse --git-common-dir, so a worktree checked out as
amont-agent-wt-x still says amont-agent, and tree-sha and the
rule cannot disagree on the name.
§What the hook reads
A push is judged by confirm (the rule is rules::implementation_review):
the pushed commit, the base it grew from (the remote’s default branch,
never the branch’s own tracking ref — once a branch is published its
plan commit is on the remote too, and a later push compared to the
tracking ref would show no docs/plans/ change and skip the rule for
good), whether docs/plans/ changed since that base, the content id,
and then a binding: a completed implementation-review agent in this
session’s transcript whose block names this repository and tree, or a
pass remembered under <state>/implementation-review/by-tree/.
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): a conflict-free rebase onto a
moved main changes the tree, not the diff the reviewer read. The patch
is git diff --binary <merge-base> <pushed> -- . ':!docs/plans' hashed by
git patch-id --verbatim; the rules are AGENTS.md, CLAUDE.md,
.adr.yaml, .adr/ and .claude/ in the pushed tree. A pass is filed
under by-patch/ too, and a hit there is journalled reviewed-by-patch.
The verdict is read, not assumed: a review that said rework and got
no later delta on the same tree is not a pass. Only the hook writes a
pass file — from a transcript binding, or from the person’s Overrule
on a marked question — and a Bash, Write or Edit under that directory
is refused by the hook itself, outside any stance, because under deny
a pass file is a trust boundary.
Structs§
- Patch
Key - What a pass carries over to another tree: the branch patch and the fingerprint of the rule files. Both must match.
- Review
- The reviews this session completed, in launch order: what each bound
and what it said. A reviewer resumed with
SendMessageon a new block is a review of its own (completed_agents_resumable).
Enums§
- Judged
- What the hook found out about a push.
- Verdict
- What a reviewer’s result said, read from its first
Verdict:line.
Constants§
- BLOCK_
OPEN - Opens a review block in the reviewer’s prompt.
- GUARD_
REASON - GUARD_
REMEDY - RULE_ID
Functions§
- block
- The review block a reviewer’s prompt carries.
- branch_
patch - The
git patch-id --verbatimof the branch’s diff sincemerge_base,docs/plans/left out.Erron an empty diff or any failure: a key that cannot be computed carries nothing over. - confirm_
push - The rule’s
confirm, for a push: what to say, or why not. - guards_
path - Whether a path is inside the pass-file store, compared lexically (
.and..folded, no symlink followed) and, where the store exists, by its canonical form too. Only the hook writes there. - is_
sha256 - judge_
push - Judge the push in
cmd, whose clause runs incwd. - lexical
- A path with
.and..folded lexically. - marker
- The
(repo, sha)a marked question names:[implementation-review <repo>@<sha64>], split at the last@. - names_
store - Whether a shell word names the store, spelled with either separator: Windows writes the same directory with backslashes.
- on_
post_ ask - After an
AskUserQuestion: anOverruleof areworkthis session’s transcript shows is remembered as a pass; anything else changes nothing. Returns what the session must hear when an overrule bound nothing. - on_
pre_ ask - Before an
AskUserQuestionruns: remember a marked question, and whether it arrived pre-answered, so the answer can be trusted or not. - parse_
blocks - The
(repo, sha)of every review block in a prompt. A sha that is not 64 hex is not a binding. - patch_
key - Both halves of the key for
pushed, or why either cannot be computed: a miss, never a pass, and the caller says the reason when it holds. - remembered
- The verdict a remembered pass carries (
approve,approve-with-changesoroverruled), if this repository and tree have one. - repo_
name - The repository’s name for a block: the basename of the directory that
holds its common
.git, whichever worktreerepois. - reviews
- rules_
fingerprint - The sha256 of the rule files’ entries in
rev’s tree. - store_
clause - The first clause of a command that would WRITE into the store: a redirect
into it (
> …/by-tree/…), or a program on [WRITERS] with a word naming it. A read —ls,cat,findof the pass files — passes: the record is there to be looked at. Returns the clause’s span. - verdict_
of - The verdict a result text states, or
Nonewhen it states none the contract knows — which is not a pass.