Skip to main content

Module implementation_review

Module implementation_review 

Source
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§

PatchKey
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 SendMessage on 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 --verbatim of the branch’s diff since merge_base, docs/plans/ left out. Err on 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 in cwd.
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: an Overrule of a rework this 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 AskUserQuestion runs: 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-changes or overruled), 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 worktree repo is.
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, find of 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 None when it states none the contract knows — which is not a pass.