PR lifecycle & review
Draft PRs, layered reviewers, comment-resolution loop, HITL mergeTwo things go wrong without a codified review process. First, the process is tribal: who reviews what, when a pull request (PR) is “ready,” what happens to a bot’s finding, and who may merge all live in people’s heads, so they happen inconsistently or not at all. Second, adding AI reviewers to that vacuum makes it worse — an automated reviewer with no measured precision and the power to block turns review into noise, and one wired carelessly into CI becomes a security hole (a reviewer that runs untrusted code from a fork with repository secrets, or lets the PR being reviewed alter the reviewer’s own prompts and policy). This module codifies the draft→review→resolve→merge loop with layered reviewers, measured automation, and the human checkpoints kept explicit.
PRs open as drafts, unless the repository declares that they open Ready because none of its reviewers reviews drafts; Ready is marked by a human, or by an unattended review driver the repository adopts, at the review round (or the convergence) the repository declares; a human merges (HITL). How a PR is shaped is declared policy, not an agent’s improvisation: its base, whether it may stack on another PR, its branch name and its size; and every PR’s final integration target is resolvable by tooling, from its base or from stack metadata. The mandatory review steps are selected by what changed (via the M3 change-area catalog), not by reviewer memory. Every review comment ends resolved with an audit trail — in one of a closed set of terminal states, declared by the author rather than inferred from prose — before merge. Review is a loop over rounds, and its stop condition is a round that finds nothing left, not a single pass. The lifecycle does not stop at the merge: after it, each class of residual obligation (the tracker state, deferred findings, out-of-tree actions, temporary scaffolding, live verification, the next step) is settled as owed, and filed or done, or as not owed, with the evidence that settled it; “nothing found” is not evidence. Automated reviewers run comment-only until measured precision clears a pre-committed bar that justifies more. And any reviewer that executes PR code runs it under a fork-safe wiring that never grants untrusted code access to secrets. The reviewer runtime, prompts, and active policy come from a pinned external source, a separately hosted service, or the target base branch — never from the PR head being reviewed.
Everything below is one tool-independent statement made mechanical; concrete per-forge, per-bot wiring lives in mappings.md.
M7 Lite — minimum useful
PRs open as drafts (or Ready, where the repository declares that none of its reviewers reviews drafts), a human marks any draft Ready, and a human merges; the lifecycle is written down once (PR-LIFECYCLE.md) and self-review before requesting review is expected. Review may be humans-only; enforcement may be convention.
- The PR lifecycle is written down once — open as a draft (or Ready, where the repository declares that no reviewer reviews drafts), self-review, review, resolve threads, Ready (by a human or an adopted review driver), human merges — and referenced by the instructions.
lifecycle-documentedWhat the audit looks for (2)- a pr-lifecycle doc states the draft -> review -> resolve loop (Ready inside it) -> merge, or, where the repository declares that no reviewer reviews drafts, the Ready-at-open review -> resolve -> merge loop
- it names merging as a human-only step and says who marks Ready
- Authors are expected to read their own full diff and run the local gate set before requesting review.
self-review-before-requestWhat the audit looks for (1)- the lifecycle doc requires author self-review + local gates before requesting review
M7 Standard — production teams
the pull-request shape policy (stacking, branch names, issue link, size) is declared where the PR-opening agent reads it; mandatory reviews are selected by change-area (M3); at least one automated reviewer runs comment-only with a written precision bar for ever blocking, and it can be any automated reviewer; the comment-resolution loop is a contract (addressed/rejected/deferred/moot, every thread terminal, the state declared in an anchored encoding that an export adapter decodes rather than inferred from prose) and no PR merges with unresolved threads; any reviewer executing PR code uses the fork-safe wiring; no authoritative reviewer obtains its runtime, prompts, or active policy from the PR head it is reviewing; and a post-merge stage settles each class of residual obligation as owed (filed or done) or not owed (with evidence), including that every deferred reply produced a tracked item.
- Which mandatory reviews a PR needs is derived from the change-area catalog (a generated projection), not a hand-kept list or reviewer memory.
reviews-selected-by-change-areaWhat the audit looks for (2)- a review-gate projection is generated from the M3 catalog
- review requests / required checks are driven by that projection
- Any automated reviewer runs comment-only, and a pre-committed precision bar for ever flipping it (or a lens) to blocking is written down.
automated-reviewer-comment-only-with-barWhat the audit looks for (2)- the review config sets a comment-only posture for new reviewers/lenses
- a precision bar (and who measures it) is recorded, not implied
- A secret-bearing or merge-relevant automated reviewer gets its runtime, prompts, and active policy from a pinned external source, separately hosted service, or target base branch — never the PR head it reviews.
automated-review-source-independentWhat the audit looks for (2)- review wiring identifies a trusted runtime and policy source outside the PR head
- proposed reviewer changes can only affect a separate unprivileged shadow run, not their own authoritative review
- Every review thread reaches a terminal state (addressed / rejected / deferred / moot) with an audit trail, and no PR merges with an open thread.
comment-resolution-loop-gatedWhat the audit looks for (4)- the addressed/rejected/deferred/moot loop contract is documented
- an unresolved-threads check runs as a required merge gate in CI
- the state set is closed — an unrecognised state fails rather than passing
- a state claiming a change (addressed / deferred / moot) fails without a reference to one, not merely with blank text
- A finding whose anchored code no longer exists has its own terminal state, distinct from rejection, so a learning loop is not told the reviewer was wrong when it was right about deleted code.
moot-distinct-from-rejectedWhat the audit looks for (2)- a moot (or equivalently named) state exists and is documented as distinct from rejection
- it requires a trail naming what superseded the finding
- The author declares the terminal state in a machine-readable, anchored form at reply time, rather than leaving it to be reconstructed from prose.
verdict-declared-not-inferredWhat the audit looks for (3)- a verdict encoding is specified (leading token, trailer, or forge field) and anchored to a fixed position, not a free-text search
- an export adapter decodes that encoding onto the gate's closed state set, rather than passing reply prose to the gate
- 'cannot tell' is its own exported value, distinguishable from a real state
- After a merge, each class of residual obligation (tracker state, deferred findings, out-of-tree actions, temporary scaffolding, live verification, the next step) is settled as owed and filed or done, or as not owed with the evidence that settled it, and a deferred reply is checked against the tracker rather than trusted.
post-merge-obligations-settledWhat the audit looks for (9)- the lifecycle doc has a post-merge stage naming those classes, each ending owed or not owed with evidence ('nothing found' is not evidence)
- the stage re-lists resolved threads and summary findings and confirms each deferred reply's referenced item exists, instead of relying on the reply's text
- the stage picks the next item with a bias toward closure (a nearly-done epic, then operations that can be cleared, then a batch of small items) and leaves the pick to a person
- the stage reverts temporary scaffolding in the repository and outside it (timeouts, gates, drivers, environments, flags) and asks for live verification only when the change has a runtime surface, has reached an environment and is not covered by CI
- routine local branches, retired workspaces and scratch notes are left to periodic cleanup, even without collector coverage, and do not make the follow-up incomplete or require a human retention decision; evidence of unlanded work or an active operational problem remains in scope
- on recent merges, a closing comment or pass report records each class as owed or not owed (a scheduled or hook-run pass that only reports is advisory; mechanical needs a check that fails while a merge has a class nobody recorded)
- a repository whose post-merge command is the plugin's /jig:followup (dispatch.followup_command, or the stage run by hand) has the stage's procedure: its arms are these classes and its settle step refuses to end a run with an arm unrecorded; the evidence of a settled merge is still the recorded report on recent merges, and an arm turned off in followup.off is a class the repository does not settle
- an obligation only this repository has after a merge (a site, a ledger, a status page) is settled in the same report as the classes above, by whatever procedure the repository runs; a check that cannot answer is recorded unread, never not owed, and an obligation kept only in a procedure the stage never runs is not settled
- a repository that adopts the plugin's /jig:followup declares such an obligation as a repository arm in followup.arms (an instructions file read from the integration branch, a read-only check command, or a skill), settled in the same report
- No secret-bearing reviewer workflow checks out and runs untrusted fork code, and a lint enforces it.
pr-target-wiring-fork-safeWhat the audit looks for (2)- a pull_request_target safety lint runs in CI over the workflows
- no workflow trips it (fork code is treated as data under privileged triggers)
- How pull requests are shaped is declared once where the PR-opening agent reads it: whether they may stack and how, the maximum stack depth, branch naming, the issue link, and a size budget.
pr-shape-policy-declaredWhat the audit looks for (2)- a configuration file or instructions section declares the stacking mode (none, forge-native, or plain branch chains)
- the same place declares branch naming, the issue link and the size budget, or states the defaults apply
M7 Strict — regulated / compliance posture
the unresolved-threads gate and the PR-target safety lint run in CI (the authority); the declared verdict is validated by whatever posts the reply, at write time, with an opt-out for replies that are not verdicts; the review loop’s stop condition is a mechanical convergence check rather than a judgement call; the HITL decision registry is published and the hitl label revokes autonomous merge; the pull-request shape policy is applied by the tool that opens PRs, so a stack whose final target cannot be resolved is refused rather than opened; reviewer promotion comment-only→blocking is gated on measured precision from the M8 corpus; the gates ship with self-tests run in CI.
- The tool that posts thread replies validates the declared verdict as the reply is written, so a missing verdict fails immediately instead of becoming an unclassifiable row at export.
verdict-validated-at-write-timeWhat the audit looks for (2)- the reply-posting tool rejects a reply carrying no verdict, at write time
- an explicit opt-out flag exists for replies that are deliberately not a verdict
- The loop's stop condition distinguishes 'no open threads' from 'the reviewer has not reported yet', and re-checks that the PR is still open each round.
review-loop-convergence-rulesWhat the audit looks for (4)- a convergence check runs per round and its result is the loop's control flow, not a person's judgement
- convergence waits for the reviewer to settle before declaring zero threads a stop
- the loop aborts when the PR stops being open, rather than pushing to a branch that will not merge
- the check counts every thread the merge gate would reject, not only those literally marked open
- Merging is mechanically reserved to humans — branch protection requires a human actor and green required checks. (Who may mark Ready is a convention, scored under hitl-registry-published: GitHub and GitLab let any writer take the draft-to-Ready transition.)
human-ready-and-merge-enforcedWhat the audit looks for (2)- branch protection requires required checks + review before merge
- automation cannot self-merge (no bot bypass of the human merge step)
- Every open PR's final integration target is resolvable by tooling, and the tool that opens PRs refuses one whose target is not: a stack the policy forbids, a base no open PR chain leads from, a stack deeper than allowed, or a change over the size budget without a stated reason.
pr-final-target-resolvableWhat the audit looks for (2)- the PR-opening tool applies the declared policy and exits non-zero on a violation
- on recent PRs, every base is the integration branch, a forge-native stack, or a chain of open same-repository PRs ending at it
- The human-only decision classes (merge, promote a reviewer to blocking, expand scope, overrule a human, and mark Ready unless delegated to a review driver; where the repository runs a post-merge stage or closes epics on a verdict, also picking the next item and reopening on a rejecting verdict or waiving a missing acceptance review) are listed in one registry, which reserves parking an autonomous run to its classes, and a hitl label revokes autonomous merge.
hitl-registry-publishedWhat the audit looks for (7)- a HITL decision registry enumerates the human-only decisions with a trigger each
- the registry has a row reserving parking (an autonomous run stopping for a person) to the registry's classes, each park carrying its class and a framed decision
- the registry requires a framed Authorize decision to offer refusal as an option
- a hitl label is defined and revokes autonomous merge for the linked PR
- the registry names who may mark Ready: humans, plus the review driver when the repository delegates to it
- where the repository runs a post-merge stage or closes epics on a verdict, the registry also lists picking the next item and reopening on a rejecting verdict or waiving a missing acceptance review, the latter naming an approver other than whoever runs the post-merge pass or the epic-closing step
- on recent PRs, every draft-to-Ready transition was made by a human or by the declared review driver
- Promoting a reviewer or lens from comment-only to blocking is gated on measured precision (from the M8 corpus / parity report), not a hunch.
reviewer-promotion-gated-on-measurementWhat the audit looks for (2)- a lens flipped to blocking carries a recorded precision measurement clearing the bar
- the measurement source (M8 parity report) is wired, not aspirational
- The PR-target safety lint and the unresolved-threads gate each ship a self-test that runs in CI, so a broken review gate fails loudly.
review-gates-self-testedWhat the audit looks for (2)- each gate has a paired self-test exercising a known pass and a known fail
- CI runs the self-tests
Adoption steps
- Copy
PR-LIFECYCLE.mdinto your docs tree and adjust the checkpoints to your forge; turn on required-draft / required-human settings where the forge supports them. - Point the mandatory-review selection at your M3 review-gate projection instead of a hand-kept list.
- If you run an automated reviewer, express it as
review-config.yaml(tool registry, comment-only posture, numbered lenses, precision bar, reviewer source). Load the authoritative runtime and policy from a pinned external version, hosted service, or target base branch; test proposed reviewer changes in a separate unprivileged shadow run. Wire the reviewer fork-safe and add the PR-target safety lint so the wiring can’t regress. - Adopt the unresolved-threads gate as a
merge gate. Pick a verdict encoding, and wire the
export adapter
between your forge and the gate — mapping your own vocabulary in its
canon()rather than loosening the gate (recipes in mappings.md). - Drive the resolve→push→re-review loop with the convergence gate instead of a person deciding when it looks done, so a still-running reviewer or a mid-loop merge cannot end the loop quietly.
- Fill in
HITL-REGISTRY.mdand wire thehitllabel / draft rules to it. - Declare the pull-request shape: whether PRs may stack and how (forge-native
stacks or plain branch chains), the maximum stack depth, branch naming,
the issue link, and the size budget. With Jig’s plugin
that is the
pull_requestssection of.config/jig.yaml(reference); per-tool options are in mappings.md. - Run the post-merge stage after every merge, as step 6 of
PR-LIFECYCLE.mdstates it: by the session that drove the pull request, by a person, or by a scheduled job. Record each class as owed or not owed with its evidence in the tracker item’s closing comment, or, for a pull request no tracked item names, in a pass report or a comment on the pull request, and add the rows for its human decisions to your HITL registry.
Core pieces"Nothing found" is not evidence because a pass that looks in the wrong place finds nothing just as a clean one does; a reason names a fact ("no file under the deploy directory changed")…Open
-
Draft-first lifecycle — a PR opens as a draft PR so CI and bots run while the author still owns it; marking it Ready is a deliberate human act unless the repository delegates it to an adopted review driver, and the merge is always a human act. A repository whose reviewers all skip drafts may declare that PRs open Ready instead, since there a draft only delays the first review. The narrative contract — open draft → self-review → automated + human review → resolve loops (Ready once the draft reviewers settle, then the rest review) → gates green → merge → tracker update — is the copyable
PR-LIFECYCLE.md. -
Change-area-selected reviews — which mandatory reviews a PR needs is a generated projection of the M3 catalog (a migration touches the migration review; an API change touches the API review), not a reviewer’s recall. The review-gate table is one of M3’s projections; M7 consumes it.
-
Layered reviewers, one harness shape — humans, commercial review bots, and an in-house shadow reviewer run concurrently with distinct roles. The shadow reviewer is a harness, not a static analyzer: a repo-agnostic core (a tool registry, the verify-tool invariant, containment guards) plus a repo-specific config of numbered, additive review lenses. The core/config split is what lets one harness serve many repositories without forking its engine. The config shape is
review-config.yaml. -
Comment-only until proven — a new automated reviewer posts comments and blocks nothing. Flipping any lens to blocking requires clearing a pre-committed precision bar (an advisory gate promoted only on measured evidence — the measurement is M8’s job). The posture and the bar live in the config, so “why is this still advisory?” is answerable, not forgotten.
-
The comment-resolution loop — every review thread reaches one of four terminal states before merge: addressed (accepted and fixed here, with the commit linked), rejected (the finding is wrong or intended, with a reason), deferred (accepted but not fixed here, filed as a tracked follow-up), or moot (no longer applies — the code it anchored to is gone, with what superseded it). Scope-expanding findings and unresolved human threads are HITL — an agent may not silently widen scope or overrule a person. The unresolved-threads gate makes “no open threads at merge” mechanical.
mootearns its own state because the alternatives all corrupt something: folded intorejectedit tells a learning loop the reviewer was wrong when it may have been right about deleted code; left open it blocks convergence forever. See the gate’s README for the full argument.A loop may record more than the gate needs. The plugin’s
resolve-review-commentssplits a valid finding it deliberately declines,wont-fix, from one that was wrong,rejected. The gate reads both asrejected, since either closes the thread; a reviewer’s score must not, because one is a hit and the other a false positive. The skill’s page says what each outcome leaves behind and what it measures. -
The verdict is declared, not inferred — the author states which terminal state applies, in a form a machine can read, at the moment of reply. Reconstructing it later from prose is a measurably lossy step, and the loss is not random: it lands hardest on the acceptances, because “fixed in
<sha>” is easy to spot while a considered rejection reads like discussion. A review loop that infers verdicts will therefore systematically under-count agreement — and if M8 consumes that, the reviewer’s best findings come back as evidence it should stop surfacing them.Declaring costs one decode step that is easy to forget: no forge has a verdict field, so something has to turn the declared reply into the state the gate reads. That step is the export adapter — the one shipped here — and it is where “cannot tell” stays visible instead of being rounded to a real state. Concrete per-forge encodings are in mappings.md.
-
Rounds, and knowing when to stop — a push that resolves one round re-triggers the reviewers and produces the next, so the loop’s stop condition needs two rules that a naive “are there open threads?” check gets wrong:
- Zero open threads while a reviewer is still running is not convergence — that round’s comments have not posted yet, and stopping there abandons live findings.
- A merge that lands mid-loop orphans every later fix onto a branch nothing will merge, silently and with no error raised. Liveness has to be re-checked each round, not assumed from the round before.
Both are properties of any asynchronous review loop, not of a particular forge or bot, which is why the convergence gate is a portable check over an exported status file: its exit code is the loop’s control flow, so neither rule depends on the person driving the loop remembering it at the point they are most keen to stop.
A repository whose CI is expensive may hold it between rounds: the CI hold (M13, piece 7) skips the heavy jobs on intermediate heads while a required check fails, so no held head is mergeable, and the release at convergence runs everything again on the final head.
-
The reviewed change cannot define its reviewer — the authoritative reviewer runtime, prompts, and active policy are loaded from an immutable external version, a separately hosted service, or the target base branch. The PR head is review input, not reviewer configuration. A proposed change to the reviewer can run in a separate unprivileged, comment-only shadow job, but it cannot alter the review that decides whether that same change is safe.
-
Fork-safe reviewer wiring — an automated reviewer needs repository secrets (model keys, a bot token) yet must inspect code from untrusted forks. The safe pattern extracts and analyzes the base-branch tooling while treating fork code as data, never executing it in the privileged context. The PR-target safety lint fails a workflow that checks out and runs untrusted PR head code in a secret-bearing job.
-
Explicit HITL boundaries — the human-only decision classes (merge, promote a reviewer to blocking, expand scope, override a human thread, pick the next item from the computed ranking, reopen on a rejecting verdict or waive a missing acceptance review, with an approver other than whoever runs the post-merge pass or the epic-closing step that found the gap, and mark Ready unless the repository delegates it to a review driver) are listed once in
HITL-REGISTRY.mdrather than scattered across skills and habits, so autonomous runs know exactly where to stop. The registry reserves parking to its classes: an autonomous run stops for a person only on a decision one of its rows names, with the decision framed (the question, the options with what each changes and costs, the recommendation, what the person must do), and decides everything else, recording each decision where a person can reverse it (ADR-0010). Jig’s review drive enforces it: its park refuses any other class (drive-pr). -
Declared pull-request shape — whether a PR may be based on another open PR’s branch (stacked), how deep a stack may grow, how branches are named, how a PR links its issue, and how large it may be are one written policy, read by the agent that opens the PR. Without it an agent improvises, and the improvisation fails quietly: a hand-built stack whose layers target feature branches gives every base-scoped tool (a reviewer that loads its policy from the trunk, branch protection, deploy previews) nothing to resolve the final target from, so those tools skip the PR and nobody notices. The policy states the invariant every PR’s final target is resolvable: either the PR targets the integration branch, or it is part of a forge-native stack whose metadata names the target, or the repository accepts plain branch chains and its tooling walks them. Jig’s
do-itemapplies the policy withpr-plan.tsand refuses a PR that breaks it; the fields are in the configuration reference. -
A post-merge stage: what does the merge still owe? — merging closes the pull request, not the work, and nothing else looks at what a merge leaves behind. After every merge one pass settles each class of residual obligation, and each ends in one of two states: owed, and filed or done, or not owed, with the evidence that settled it. The classes:
- Tracker state: the item’s own state, and the epic rolled up from its children. The epic closes as M9 says, never because a pull request merged.
- Deferred findings: each
deferredreply really produced a tracked item. The pass re-lists the resolved threads and the summary findings, because a deferred thread resolves the moment its reply posts and a summary finding has no thread. The unresolved-threads gate can check that a deferred reply names a reference, not that the item behind it exists: only a step that can reach the tracker can. - Out-of-tree obligations: every action the merge leaves outside the repository is listed when the pull request opens and recorded where a person will find it, in the tracker item and in the repository’s own ledger of such work where it keeps one.
- Temporary scaffolding: reverted, in the repository and outside it. A widened timeout, a disabled gate, a live review driver, an environment or a flipped flag can still affect behavior, cost or access after the merge. Routine local branches, retired workspaces and scratch notes wait for periodic cleanup, even where no collector covers them yet. Their presence alone never makes a follow-up incomplete or calls for a human retention decision; evidence of unlanded work or an active operational problem remains owed.
- Live verification: owed only when the change has a runtime surface, has reached an environment and is not already covered by CI. Anything else is not owed, and says which condition it fails.
- Next step: picked with a bias toward closure. Finish a nearly-done
epic first; otherwise clear the operations that can be cleared;
otherwise take a batch of small items
(
/jig:work-batch). A computed ranking proposes the shortlist; picking from it is a human decision. It is not owed only when the tracker shows no open work.
“Nothing found” is not evidence because a pass that looks in the wrong
place finds nothing just as a clean one does; a reason names a fact
(“no file under the deploy directory changed”) that someone else can
check. The decisions the stage hands to a person (see core piece 10)
are rows of the HITL registry. Step 6 of
PR-LIFECYCLE.md is the copyable form, and
mappings.md says how each class is
checked per forge and tracker.
In your toolsThe same rule, wired into a specific CI provider, hook manager or tracker. Shows only your stack.Open
The module invariant — draft PRs, change-area-selected reviews,
layered comment-only-until-proven reviewers, a resolve-every-thread loop, a
Ready by a human or an adopted review driver, a human merge, reviewer code and policy independent of the reviewed
change, and fork-safe wiring — is tool-independent. This file maps its
mechanisms onto concrete forges, review bots, agent
runtimes, CI providers, and
issue trackers. Replace <placeholders> with your values.
The gates, per rung
| Gate | Local (hook) | CI (authority) |
|---|---|---|
| PR-target safety lint | pre-commit over .github/workflows/** (optional) | blocking; the authority — the workflows are the thing checked |
| Unresolved-threads | n/a (needs the forge’s thread state) | blocking merge gate, after the thread-state export step |
| Round convergence | n/a (needs the forge’s PR + reviewer state) | not a merge gate — a loop step whose exit code is control flow (see § Round convergence below) |
The change-area review selection is not a gate here — it rides on M3’s review-gate projection, which decides which mandatory reviewers a PR needs.
Three things these examples get right and you must not drop:
- Run the gate logic from the BASE, not the PR checkout. A merge-blocking gate that runs scripts out of the PR’s own checkout is not a gate — the PR can edit the script (or the workflow) to report success. Check the PR’s tree out as data to be scanned, and run the gate scripts from a separately checked-out base tree the PR cannot alter (or a pinned reusable workflow).
- The PR cannot define its own reviewer. Load a secret-bearing or merge-relevant reviewer’s runtime, prompts, and active policy from a pinned external version, separately hosted service, or the target base branch. If a PR changes reviewer code or policy, exercise that proposal only in a separate unprivileged, comment-only shadow job; the authoritative review keeps using the previously trusted version.
- Use paths that exist after checkout. The scripts live under the module
directory (
modules/M7-pr-lifecycle-review/reference/...as shipped). Set oneM7variable to wherever you vendored the module and build every path from it; a barereference/...resolves from the repo root and will not be found.
GitHub Actions
# .github/workflows/pr-hygiene.yml — runs on pull_request (no secrets for forks)
on:
pull_request: {}
jobs:
hygiene:
runs-on: ubuntu-latest
env:
M7: base/modules/M7-pr-lifecycle-review # gate scripts, from the base tree
steps:
# The PR's tree — inspected as DATA only; its scripts never run the gate.
- uses: actions/checkout@<full-commit-sha> # v4
with: { path: pr }
# The gate scripts, from the BASE commit the PR targets — the PR cannot
# edit these, so it cannot make an unsafe workflow report success.
- uses: actions/checkout@<full-commit-sha> # v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
- name: Reviewer wiring is fork-safe (blocking)
# scan the PR's workflow files as data; run the trusted, base-owned gate
run: WORKFLOWS_DIR=pr/.github/workflows bun "$M7"/reference/pr-target-safety/check-pr-target-safety.ts
- name: Gate self-tests (blocking)
run: |
bun test "$M7"/reference/pr-target-safety/check-pr-target-safety.test.ts
bun test "$M7"/reference/comment-resolution/check-threads-resolved.test.ts
bun test "$M7"/reference/comment-resolution/normalize-thread-states.test.ts
bun test "$M7"/reference/review-convergence/check-round-converged.test.ts
- name: Export review-thread rows
# The API emits ROWS — id, resolved, reply body — and nothing more.
# Decoding the declared verdict is the next step's job, not this one's.
#
# Several rows per thread, NEWEST REPLY FIRST. Do not send only the last
# comment: a reviewer answering "confirmed" after the author's
# `**accepted** — fixed in abc1234` would bury the verdict, and the thread
# would export as `unclassified` and block a correct resolution. The
# exporter takes the freshest reply that actually declares one.
env: { GH_TOKEN: ${{ github.token }} }
run: |
gh api graphql --paginate \
-F owner='${{ github.repository_owner }}' \
-F repo='${{ github.event.repository.name }}' \
-F pr='${{ github.event.pull_request.number }}' \
-f query='
query($owner:String!,$repo:String!,$pr:Int!,$endCursor:String){
repository(owner:$owner,name:$repo){
pullRequest(number:$pr){
reviewThreads(first:100,after:$endCursor){
pageInfo{ hasNextPage endCursor }
nodes{ id isResolved comments(last:20){ nodes{ body } } }
}}}}' \
--jq '.data.repository.pullRequest.reviewThreads.nodes[]
| .id as $id
| (.isResolved | tostring) as $res
| [ .comments.nodes[].body // "" ] | reverse
| .[] | [ $id, $res, (gsub("\\s+";" ")) ] | @tsv' \
> pr-thread-rows.tsv
- name: Decode declared verdicts into gate states
# The one place the reply encoding is decoded — checked in, self-tested
# against the gate. Piping reply bodies straight into the gate instead
# makes every declared verdict an unknown state (see § below).
run: |
VERDICT_ENCODING=token \
bun "$M7"/reference/comment-resolution/normalize-thread-states.ts \
pr-thread-rows.tsv > pr-threads.txt
- name: Every thread resolved with a trail (blocking merge)
run: THREADS=pr-threads.txt bun "$M7"/reference/comment-resolution/check-threads-resolved.tsGitLab CI
pr_hygiene:
variables:
M7: modules/M7-pr-lifecycle-review # point at where you vendored the module
script:
# On GitLab, run from a protected branch's copy of the scripts (or a
# component) so a fork MR cannot alter the gate it must pass.
- WORKFLOWS_DIR=.gitlab/ci bun "$M7"/reference/pr-target-safety/check-pr-target-safety.ts
- bun test "$M7"/reference/pr-target-safety/check-pr-target-safety.test.ts
- bun test "$M7"/reference/comment-resolution/check-threads-resolved.test.ts
- bun test "$M7"/reference/comment-resolution/normalize-thread-states.test.ts
- bun test "$M7"/reference/review-convergence/check-round-converged.test.ts
# Same two steps as GitHub: rows out of the API, verdicts decoded by the
# checked-in exporter. Only the API call differs — and, as there, every note
# is emitted newest-first rather than just `.notes[-1]`.
- |
glab api "projects/:id/merge_requests/$CI_MERGE_REQUEST_IID/discussions" \
--paginate \
| jq -r '.[] | select(.resolvable)
| (.id|tostring) as $id | (.resolved|tostring) as $res
| [ .notes[].body // "" ] | reverse
| .[] | [ $id, $res, (gsub("\\s+";" ")) ] | @tsv' > mr-thread-rows.tsv
- |
VERDICT_ENCODING=token \
bun "$M7"/reference/comment-resolution/normalize-thread-states.ts \
mr-thread-rows.tsv > mr-threads.txt
- THREADS=mr-threads.txt bun "$M7"/reference/comment-resolution/check-threads-resolved.tsForges — lifecycle primitives + thread-state export
| Forge | Draft PR | Human-only merge | Thread state → gate input |
|---|---|---|---|
| GitHub | native draft PRs | branch protection: required reviews + required checks, no self-merge of bot PRs | GraphQL pullRequest.reviewThreads → rows of (id, isResolved, reply body), one per reply, newest first |
| GitLab | Draft: title prefix | protected branch + “all threads resolved” + approval rules | merge_requests/:iid/discussions (id, resolved, resolvable, every note) → same rows |
| Gitea / Forgejo | native draft PRs | branch protection + required approvals | conversations API → same rows |
Every forge gives the same three things and nothing more: an id, a resolved
boolean, and free-text replies. Turning those into the gate’s
addressed | rejected | deferred | moot | unclassified | open states is a
separate, checked-in step —
normalize-thread-states.ts,
shown in the export recipes above. An unresolved thread emits open whatever its
last reply says.
Keep the API call and the decode step apart. It is tempting to collapse them into
one clever jq filter that emits the reply body straight after the id, but the
gate reads the first whitespace-delimited token as the state, so a body like
**accepted** — fixed in a1b2c3d arrives as the state **accepted** and fails as
an unknown state. Every documented encoding fails that way, which is worse than
useless: the gate reports typo’d resolutions on threads that were resolved
correctly.
isOutdated is deliberately not fetched. GitHub can tell you a thread’s
anchored lines have changed, and it is tempting to map that to moot
automatically. Don’t: that is precisely the inference core piece 6 forbids. Code
moving is not the same claim as “this finding no longer applies”, and the author
is the one who knows which. Treat an outdated thread as a prompt to consider
moot — worth surfacing in a review UI or a resolve-comments skill — never as
the verdict itself.
Encoding the declared verdict
Core piece 6 says the author declares the terminal state rather than leaving it to be inferred. Every forge here exposes thread replies as free text and none has a native verdict field, so the encoding is a convention on the reply body — but a checkable one, and each of these has an exporter setting that actually decodes it:
| Encoding | Looks like | Exporter |
|---|---|---|
| Leading token | **accepted** — added the guard in a1b2c3d | VERDICT_ENCODING=token (the default). Emphasis markers and trailing punctuation are stripped; the anchor is the position, not the bold |
| Trailing trailer | … Verdict: deferred as the last thing in the reply | VERDICT_ENCODING=trailer. Flattening a multi-line reply turns “on its own line” into “at the end of the body”, so the trailer has to be last |
| Forge label / emoji | a reaction or thread label | not shipped — no forge above models a verdict field. If yours does, fetch it and extend the exporter’s canon(); a real field beats any body convention |
Jig takes no position on which of the two. token is the exporter’s
default, not a recommendation — it is the form the
resolve-review-comments
skill writes, and it has not run through enough review cycles to be called
settled (see the README). Both are one variable apart,
deliberately, so an adopter picking the other is not fighting the module. What
Jig does assert is the pair of properties below; those are what the
evidence supports, and they hold for any encoding including a forge field that
makes this whole section unnecessary.
Whichever you pick, two properties do the work:
- Anchored — matched at a fixed position (start of body, or end of body), not “somewhere in the text”. An unanchored match reads narration as a verdict: a reply explaining why something was intentional will contain the word “intentional” long after its actual verdict. The exporter’s self-test pins this down in both directions.
- Enforced at write time — validate in whatever posts the reply, so a missing verdict fails immediately rather than becoming an unclassifiable row at export. Enforcement after the fact cannot recover a verdict nobody wrote. This is why the write-time criterion in the module’s maturity criteria sits a rung above the convention.
Adopters whose tooling emits different words (accepted for addressed,
obsolete for moot) map them in the exporter’s canon(), whose synonym
table is verdicts in lib/module-gates.ts — the exporter is
already forge- and repo-specific, and the gate’s vocabulary stays closed so a
typo’d resolution still fails.
Provide an explicit opt-out (a flag on the posting tool) for replies that are genuinely not a verdict — a clarifying question mid-thread. Without one, authors invent a token to satisfy the check, which is worse than an honest abstention.
Expect a legacy tail: replies written before the convention, and opt-out
replies, will never carry a token. Those export as unclassified, which is its
own state and fails with its own message rather than being folded into a real
one — an abstention counted as a rejection is the same corruption as a moot
counted as a rejection, one layer down. Keep whatever prose heuristic you have as
a fallback for the tail, but keep it outside the exporter, and never let it
produce a state it is not sure of.
Round convergence — producing the status file
The convergence gate reads three scalar keys plus
one reviewer: line per reviewer.
| Key | GitHub | GitLab |
|---|---|---|
pr_state | gh pr view <n> --json state -q '.state | ascii_downcase' | glab mr view <n> → state (opened → open) |
open_threads | the number of rows the unresolved-threads gate rejects in pr-threads.txt | same, from mr-threads.txt |
round | the loop’s own counter, incremented per push | same |
reviewer: <id> <reported|pending> | one line per expected reviewer — see below | same |
Count open_threads as the rows the unresolved-threads gate rejects, not the
rows whose state is literally open. A trail-less moot and an unclassified
reply are both still work; counting only open reads them as convergence and
lets the loop stop on a PR that cannot merge.
Enumerate reviewers by identity, and settle each one exactly once. This is the step where a producer silently breaks the gate, so it is worth spelling out.
The expected set is the reviewers actually scheduled for this PR, named
individually. It is not the row list of
review-config.yaml, and reading it that way
wedges the loop at WAIT forever:
- That registry contains category rows, not identities — the shipped config has
- id: humans(kind: human), which stands for “whichever humans M3 selects”. No artifact can ever settle an identity literally namedhumans, so expand it to the concrete reviewers the PR requested and drop the row itself. - It contains reviewers that are not running on this PR:
enabled: falseentries, and tools scoped to change-areas this PR does not touch. A reviewer that was never invoked has nothing to report and will never report it.
So: expected = (automated reviewers with enabled: true that this PR actually
invoked) + (the concrete human identities currently on the hook). If a
reviewer is not going to run, it does not belong in the census at all — leaving it
in is indistinguishable from waiting for it forever.
Two ways to get that union wrong, both of which park the loop at WAIT for good:
The rule that makes this correct by construction: a human is on the hook for this
round if they are currently requested, or if they have already submitted for
the current head. Nothing else belongs in the census — and note that the second
half is exactly settled_for_head, so deriving it from that same predicate means
the census and the settle check cannot disagree about anybody.
# Still-pending requests.
requested=$(gh pr view "$PR" --json reviewRequests -q '.reviewRequests[].login')
# Reviewers who have already reported ON THIS HEAD. Filtering through
# `settled_for_head` rather than trusting a review's mere existence is what keeps a
# stale reviewer out: with stale-review dismissal disabled, someone who reviewed an
# earlier head is still in `latestReviews` and not `DISMISSED`, and adding them to
# the census while `settled_for_head` refuses to settle them parks the loop at WAIT
# for good.
already=$(gh pr view "$PR" --json latestReviews \
-q '.latestReviews[] | select(.state != "DISMISSED") | .author.login' \
| while read -r id; do settled_for_head "$id" "$head_sha" && echo "$id"; done)
# Dedupe the COMBINED set, bots first. A bot that both registers a check and posts a
# review appears in more than one source, and per-source `unique` cannot see that —
# two identical `reviewer:` lines make the gate exit 2 on a duplicate identity
# instead of deciding.
EXPECTED_REVIEWER_IDS=$(printf '%s\n' $(invoked_bot_ids) $requested $already \
| awk 'NF && !seen[$0]++')Deciding whether each of those has reported means looking at what that reviewer leaves behind, and reviewers do not leave the same things:
| Reviewer kind | Settled when | Where to look |
|---|---|---|
| bot registering a check | its check run concludes | gh pr checks <n> / pipeline job status |
| bot posting comments only | it has posted for the current head sha | its review/comment timestamps vs. the head sha — a comment-only bot is invisible to gh pr checks |
| human reviewer | a review is submitted for the current head sha | gh pr view <n> --json reviews / MR approvals + notes |
The trap: a bot that does both — registers a check and posts a review — is
two settled signals for one reviewer. Sum signals and you get “2 of 2 reported”
with one bot finished and a human who has not looked, which is the early stop the
gate exists to prevent. So key the derivation on the identity: build a
reviewer: line per expected reviewer, never one per artifact found. The gate
rejects a repeated identity rather than counting it twice, which is what turns a
producer bug into a visible error instead of a false CONVERGED.
Resolve ties toward pending. Every mistake in the optimistic direction ends
the loop early and silently; a mistake in the pessimistic direction costs one
extra round.
Do not let the thread count swallow the gate’s own failure. The tempting
one-liner — check-threads-resolved.ts … | grep -c '^FAIL' || true — pipes the
gate’s stdout into grep and then masks every nonzero status. If the states file
is missing, unreadable, or malformed, the gate exits 2 with empty stdout, the
count comes out 0, and the convergence gate cheerfully reports CONVERGED on
an export that never happened. Capture the gate’s status first and treat 2 as
fatal; only exit 0 and 1 are answers.
Capture it with && rc=0 || rc=$?, not cmd; rc=$?. Under the set -e the loop
recipe below recommends, a bare assignment from a command substitution aborts the
shell on the gate’s ordinary exit 1 — every normal WORK round would kill the
driver before the status could be classified.
gate_out=$(bun "$M7"/reference/comment-resolution/check-threads-resolved.ts pr-threads.txt) \
&& gate_rc=0 || gate_rc=$?
case "$gate_rc" in
0) threads=0 ;; # every thread terminal
1) threads=$(printf '%s\n' "$gate_out" | grep -c '^FAIL') ;;
*) echo "$gate_out" >&2
echo "ERROR: thread-state export or gate failed (exit $gate_rc) — not a converged round" >&2
exit "$gate_rc" ;;
esac
head_sha=$(gh pr view "$PR" --json headRefOid -q .headRefOid)
{
echo "pr_state: $(gh pr view "$PR" --json state -q '.state | ascii_downcase')"
echo "open_threads: $threads"
echo "round: $ROUND"
# One line per EXPECTED reviewer identity — see § Enumerate reviewers, above.
# `settled_for_head <id>` is your repo's per-reviewer rule from the table there;
# it must answer for THIS head sha, or a reviewer that reported one push ago
# counts as having reviewed the current code.
for id in $EXPECTED_REVIEWER_IDS; do
if settled_for_head "$id" "$head_sha"; then echo "reviewer: $id reported"
else echo "reviewer: $id pending"; fi
done
} > round-status.txtNote the head-sha condition in that loop. “Has this reviewer reported?” without it means “ever”, so every reviewer stays settled from round 2 onward and the gate converges on the first round with no open threads — the early stop, reintroduced one layer down.
Making the decision the loop’s control flow
Running the gate and keeping its output is not the same as obeying it. WORK,
WAIT and ABORT exit 1, 3 and 4 on purpose: under set -e the loop
dies at this line, and without set -e it slides past as though the four
decisions were interchangeable. Dispatch on the status explicitly — that dispatch
is the mechanism the maturity criterion asks for.
set -euo pipefail
bun "$M7"/reference/review-convergence/check-round-converged.ts round-status.txt > decision.txt \
&& decision_rc=0 || decision_rc=$?
cat decision.txt # keep it: M8's reflection trigger reads this file
case "$decision_rc" in
0) # CONVERGED — the only state in which the loop may stop.
run_reflection_trigger ;; # see M8's mappings.md
1) # WORK — resolve every thread, declare each verdict, push, run round N+1.
resolve_threads && git push && exec "$0" "$((ROUND + 1))" ;;
3) # WAIT — a reviewer is still running. Do NOT stop and do NOT push;
# sleep and re-poll, so the round's comments can arrive.
sleep "$POLL_SECONDS"; exec "$0" "$ROUND" ;;
4) # ABORT — the PR is merged or closed. Stop without pushing: anything
# committed from here lands on a branch nothing will merge.
echo "PR is no longer open — abandoning the loop" >&2; exit 0 ;;
*) echo "convergence gate failed (exit $decision_rc)" >&2; exit "$decision_rc" ;;
esacThe WAIT branch is the one worth getting right, and the easy mistake is to make
it identical to WORK. Pushing on WAIT restarts the reviewers you were waiting
for, so the round you were about to receive never arrives; the loop can spin like
that indefinitely while looking busy. WAIT waits.
The decision line is also
M8’s
reflection trigger input, so
keep decision.txt around for that step.
The post-merge stage
The classes of core piece 12 are tool-independent; what reaches each fact differs by forge and tracker.
| Class | What to read | GitHub / GitLab | Linear / Jira / forge issues |
|---|---|---|---|
| Tracker state | the item’s state and its parent’s children | the closing reference (Closes #123) names the issue and the forge closes it on merge; check it did not close an item that still owes a step | the item’s state and its parent’s child list; Jig’s do-item applies the post-merge status rule, and its Step 5a rolls the parent up (reconcile_parent_status.ts proposes the state; Step 5a applies it only after the acceptance and closing checks) |
| Deferred findings | every deferred reply, resolved threads included, and summary findings | GitHub: pullRequest.reviewThreads with isResolved unfiltered, plus the PR’s issue comments; GitLab: merge_requests/:iid/discussions with resolved unfiltered, plus the MR notes | look each referenced id up in the tracker; a reply that names an id nobody can open is unfiled |
| Out-of-tree obligations | the list made when the PR opened | the PR description and the tracker item’s closing comment | an unchecked-checkbox list on the item, or a ledger the promotion step reads |
| Temporary scaffolding | what the work put in place | the forge’s environment lists; scheduled or running workflows; the diff for a disabled check, a widened timeout or a flipped flag; routine local leftovers belong to periodic cleanup | the tracker holds none of it; read the PR description and the driver’s log |
| Live verification | whether the change reached an environment | the deployment record of the forge’s environments, the CI jobs that exercise the change | not tracker state; the tracker item may name where it was checked |
| Next step | the ranking, open epics and waiting operations | not forge state | the tracker’s computed ranking (M9) |
Ways to run the pass: by hand after a merge; as a skill the session that drove the pull request runs (Jig’s own repository does this with a skill of its own); or as a scheduled job that lists recent merges and reports the classes no one has recorded. A scheduled job reports; it does not reopen, waive or pick (the HITL registry keeps those with a person).
Stacked pull requests
A stack is only safe when every tool that reads settings from a PR’s base can work out where the stack finally lands. The options differ in where that answer lives:
| Option | How a layer is opened | Where the final target is recorded | What base-scoped tools must do |
|---|---|---|---|
| No stacking | Every PR targets the integration branch | The base itself | Nothing |
| GitHub native stacks | gh pr create --base <predecessor branch>, then link it with the gh-stack extension: gh stack link <stack number> <new> to append to an existing stack (only on its top), or gh stack link --base <trunk> <bottom> … <predecessor> <new> to start one, each pull request by URL (a bare number that is also a local branch’s name is read as that branch and pushed); gh stack submit for a whole local stack | GitHub’s stack record (its Stacks API), merged members included; each layer’s base is still its predecessor’s branch, and only the bottom layer targets the trunk | Read the stack record; a walk of open PRs misses merged members and upper layers |
| Graphite | gt create, gt submit | Graphite’s own stack record; on the forge, a plain branch chain | Walk the chain, or read Graphite’s record |
| ghstack | ghstack (submit) | Nowhere on the forge: each PR targets its own synthetic gh/<user>/<n>/base branch, which no open PR owns, and ghstack land lands the commits on the trunk | Recognise the gh/<user>/<n>/base pattern as “lands on the trunk”; a walk of open PRs stops at the first synthetic base |
| git-town, Sapling, Jujutsu | Each tool’s submit command | A plain branch chain on the forge | Walk the chain |
| Plain branch chaining | gh pr create --base <predecessor branch> | Nowhere: only the chain of open PRs, head to base | Walk the chain: each hop is the one open, same-repository PR whose head is the current branch, until the trunk |
| GitLab | glab stack (stacked diffs), or merge requests targeting a predecessor’s branch | Per merge request, the target branch | Walk the chain |
| Gerrit | A relation chain of dependent changes | The chain’s target branch, on every change | Nothing |
A plain chain breaks when a lower layer merges and its branch is kept: the layer above then targets a branch no open PR owns. GitHub retargets the dependent PR automatically only when the merged head branch is deleted, so a repository that allows plain chains should turn on “Automatically delete head branches”.
Review bots / harness (the tool registry)
Each reviewer is one entry in review-config.yaml
with a posture. New reviewers enter comment-only; promotion to blocking is
HITL and gated on measured precision (M8).
The config’s review_source records where the authoritative runtime and policy
come from. A checked-in config can change in a PR, but the review of that PR
reads the target base branch’s copy.
| Reviewer | Role | Typical posture |
|---|---|---|
| In-house shadow reviewer (this harness) | additive numbered lenses, grown by the learning loop | comment-only until its bar clears |
| CodeRabbit / Greptile / other commercial bot | static-analysis + AST depth | comment-only until it clears the same measured-precision bar |
Agent-runtime reviewer (Claude Code / Codex / Cursor /review) | on-demand local tiered review before pushing | advisory / author-side |
| Humans | judgment + sign-off; selected per change-area | authoritative (a “request changes” blocks) |
What each automated reviewer meets of the reviewer-evidence contract
The drive reads a reviewer through its evidence:
a check run, and either a summary comment that names the commit it reviewed
or a review object that names it. That is completion evidence only: the
drive reads findings from unresolved review threads, and from summary or
review bodies only for a reviewer it has a body format for (today CodeRabbit).
A reviewer that posts its findings as inline review comments and produces that
evidence works, and ADR-0027
records why Jig depends on the contract and not on one reviewer. A GitHub
Actions job is itself a check run named by the workflow job, so
review.reviewer_check_pattern can match it. The gap in most rows is the
commit stamp: the table says what each reviewer does by default, read from its
documentation, and a team checks it against the version it installs.
drive-pr has a built-in profile for CodeRabbit and for no other reviewer in the table. For the others, a repository sets the check pattern, the comment marker and the commit stamp in its own configuration (AI reviewers). Those settings only name evidence that exists; they post nothing. A reviewer that emits no commit stamp, or no summary comment, also needs a workflow step or a reviewer customization that posts and updates the marked, stamped comment, or the drive waits for evidence that never arrives. A profile waits until a consumer has validated one.
| Reviewer | Takes | Check run | Summary comment naming the reviewed commit | Review objects | drive-pr profile |
|---|---|---|---|---|---|
| PR-Agent as a GitHub Action | A model key as a secret | The workflow job | Posts one review comment as github-actions[bot] and updates it in place; it does not stamp the reviewed commit | No | None |
| openai/codex-action | An OpenAI-compatible key as a secret | The workflow job | None of its own: the workflow posts the action’s final message, and adds the stamp if it wants one | No | None |
| anthropics/claude-code-action with an API key | An Anthropic key as a secret | The workflow job | One sticky comment with use_sticky_comment, plus inline comments; no commit stamp by default | No | None |
| opencode GitHub Action | A model key as a secret, any provider | The workflow job | Replies and comments only as its prompt directs; no commit stamp by default | No | None |
| CodeRabbit for public repositories | None: a hosted service, free for open-source repositories on its own terms | Its own check run, CodeRabbit | None | Yes: each review names its commit | Built in: review.reviewer_app: coderabbitai; default bot login coderabbitai[bot] |
Reference reviewer, jig-harness/ai-review (planned, not yet published) | A model key as a secret, an OpenAI-compatible or Anthropic endpoint the team chooses | Yes | One summary comment updated in place, naming the reviewed commit and any skip, plus inline comments | No | None until published and validated |
A row names a reviewer a team can add; it does not rank them. An adopter chooses on what each posts, what it costs per pull request and who holds the key, and measures the choice the way M8 measures any reviewer before it is allowed to block.
CI providers
Any provider works — the gates use Bun and TypeScript. The only provider-specific piece is the thread-state export step (a forge API call), shown above for GitHub Actions and GitLab CI.
Issue trackers
| Tracker | Wiring |
|---|---|
| GitHub / GitLab issues | a hitl label revokes autonomous merge for the linked PR; a PR-template checkbox “threads resolved / follow-ups filed” |
| Linear / Jira | a hitl label (see M0 / M9) marks a deliverable whose merge stays human; deferred threads become linked follow-up issues, whose ids are the deferred gate’s trail |
The human checkpoints (merge, promote a reviewer to blocking) are
enforced by forge settings + the HITL registry,
not by a script — a bot must not hold those. Mark Ready is the one
checkpoint a repository may delegate: an unattended review driver such as
Jig’s drive-pr marks a draft Ready at the point
pull_requests.mark_ready declares (after its first review round by default,
after a later round, or only at convergence), so reviewers that skip drafts
spend their pass on a head the draft-reviewing reviewer has already cleaned. The driver’s opt-out
(--keep-draft) keeps the step human.
Runnable form
The practice runs as skills in Jig’s
jig plugin, installed once per machine for
Claude Code and Codex. Each reads the repository’s own reviewers, tracker
values and gate commands from its configuration at run time
(setup).
| Skill or agent | The part of this practice it runs |
|---|---|
resolve-review-comments | The comment-resolution loop (core pieces 5 and 6): walks every unresolved thread to a declared outcome, and its reply-to-thread.ts validates the verdict as the reply is written (--no-outcome is the opt-out for a reply that is not a verdict) |
drive-pr | The PR drive loop (core piece 7) run unattended: waits for reviewers to settle, stops on a named end state, marks a draft Ready at the point pull_requests.mark_ready declares, and never merges |
do-item | Opens the pull request under the declared shape policy (core piece 11) through its pr-plan.ts, and refuses one that breaks it; its post-merge status rule and mandatory ## Out-of-tree follow-ups section run the tracker-state and out-of-tree classes of the post-merge stage (core piece 12) |
followup | The post-merge stage (core piece 12) in any repository: one verdict with its evidence per class of residual obligation, a settle step that refuses to end a run while a class has no verdict, a preview before the merge, and a fixed authority table a repository can only tighten |
review | The author-side tiered review before pushing (the agent-runtime reviewer in core piece 3) |
| Review Arbiter | Rules on contested findings the triage rubric cannot settle |
resolve-conflicts | Brings a conflicting pull request up to date with its base: records each conflict decision in the merge commit for reviewers and refuses a resolution that silently drops either side’s change |
What the module provides
| Piece | What it is |
|---|---|
templates/PR-LIFECYCLE.md | The copyable lifecycle contract, draft to the post-merge stage, with its human-in-the-loop boundaries |
templates/HITL-REGISTRY.md | The human-only decision classes, each with its trigger (shared with M0) |
templates/review-config.yaml | The config half of the review-harness core/config split: tool registry, postures, reviewer source, verify tool, containment guards, precision bar, numbered lenses |
reference/comment-resolution/ | The unresolved-threads merge gate, and the verdict export adapter that decodes a declared reply into the gate’s states |
reference/review-convergence/ | The round stop condition: waits for reviewers to settle, aborts on a PR that stopped being open |
reference/pr-target-safety/ | The fork-safe wiring lint |
mappings.md | Forges, stacked-PR tools, review bots, agent-runtime reviewers, CI providers, trackers |
| maturity criteria | The criteria the audit skill scores |
Each reference gate ships with a self-test and fixtures, and delegates to the
shared implementation in lib/module-gates.ts;
keep the module and lib/ together when you vendor them.
The verdict encoding
The invariant that a verdict is declared rather than inferred (core piece 6)
rests on evidence that does not depend on any one encoding: on a real corpus,
treating resolved-with-a-reply as rejection classified all of a reviewer’s
threads as rejections when roughly half were acceptances, and a later prose
classifier over the same corpus still lost or misfiled a majority of
declared outcomes. The moot state rests on the same kind of evidence: such
threads were observed being scored as push-back.
Which encoding should carry the verdict is less settled. The bold leading token has not yet run through enough review cycles to be called the answer, so two layers treat it differently:
| Layer | Treatment of the bold-token encoding |
|---|---|
The resolve-review-comments skill and its reply-to-thread.ts | Uses the bold leading token and enforces it at reply time. The skill is one operated mechanism, kept whole rather than rewritten into an encoding-neutral variant that would become a fork |
| This module’s practice references: mappings.md, the export adapter, the lifecycle contract | Encoding-agnostic. What they assert is the invariant: a verdict is declared, in an anchored form, at reply time. mappings.md presents a leading token and a trailing trailer as alternatives and states no preference; adopter vocabulary lives in the adapter’s canon(), and the token is its default only because a default is required |
An adopter that does not run the skill is free to choose the trailer form; one that does inherits the token. The obligation sits on two rungs of the enforcement ladder (M1): declaring in an anchored encoding is a Standard convention, while validating the verdict at write time, which needs a reply-posting tool to hang it on, is Strict. When the encoding question settles, only the skill’s token vocabulary would change; the practice references above would not.
The reviewer: a contract and a reference
A review harness is an agent job in whatever language the repository uses, so this module specifies the reviewer-evidence contract and ships only the pieces that are portable gates: the fork-safe wiring lint, the resolution gate and its exporter, and the convergence check. The contract is what the drive reads to learn that a reviewer reviewed the head commit: a check run, and either a summary comment that names the reviewed commit or a review object that names it (or a successful check run on the head, for a reviewer that posts nothing when a push has no new findings). The glossary and drive-pr’s README give the complete definition. The evidence says the reviewer finished on the head commit; it does not make the reviewer’s findings readable. The drive reads findings from unresolved review threads, and from summary-only bodies only in a format it has a profile for. Teams that drive with drive-pr need a reviewer that produces that evidence, and mappings.md says what each reviewer Jig knows of meets.
Jig’s reference reviewer implements the contract
(ADR-0027). It
is planned, not yet published, as jig-harness/ai-review in its own
repository, because it runs in an adopter’s CI or as a service and releases
on its own cadence. The plugin holds no reviewer runtime.
Left out by design
- A lens catalogue beyond the seed lenses. Jig ships a few
seed lenses with the
reviewskill, each the review form of one rule a Jig module states (jig.swallowed-failurefor M15’s rules on failures), and the lens file as the contract: one Markdown file per lens, holding its id and version, the rules it enforces, the trigger that selects it, the evidence every finding must give, and what is and is not a finding.reviewruns those files, and a repository’s shadow reviewer can load the same ones. A repository’s own lenses and its model-routing tiers are its tuned content, not a portable mechanism: they are grown locally through M8, in the same file format. - Precision-bar values and their measurement wiring. They belong with M8 (the measurement) and M11 (the emission).
- What CI spends on a pull request. Cancelling the runs of a superseded head, selecting jobs by what changed, and the CI hold between review rounds are M13 pipeline economy.
Future
- Delegated merge. Letting a converged drive arm the forge’s auto-merge for the exact head it certified relaxes “a human merges”, so it waits on its own decision; it is open work in the roadmap.