feat(delivery): add the review stage and the review hand-back loop

delivery-reviewer (opus; no Bash, Edit, Write or NotebookEdit) is the
review-stage lead. It judges the PR through the new delivery-review
skill and posts one COMMENT review per round. Gitea refuses
REQUEST_CHANGES from a PR's own poster, and the reviewer runs as the bot
that opened the PR. The review opens with `Delivery review: round <n> —
blocking|clear`, and each blocking finding is tagged with the role that
must fix it: [test-author] (with its dispute key), [implementer] or
[human].

Routing: a [human] finding, or a 3rd blocking round, stops with Ready
for Human. Other blocking rounds post the Handoff and put `WIP:` back,
handing the PR to delivery-implement-lead. A clear round hands on to
delivery-operator. A relaunch finishes a crashed routing, using whether
a later Handoff links the review.

delivery-review checks the change against the acceptance criteria and
re-judges every test-path change itself, because a dispute round moves
the CI freeze boundary. It also judges post-merge assertion reasons,
security and the dry run. It reads the delivery doc at the PR's base
ref, and a PR that changes the test-path rules is a [human] finding.

Hand-back: delivery-handoff lets the implement stage take a PR, with
the inbound Handoff required and the gate checked on the issue it
closes. The implement lead first sends [test-author] findings through
delivery-test-first's dispute flow, which now takes review findings,
then gives the implementer the rest. Dispute verdicts are one keyed
`- Dispute verdict:` line copied into every Handoff comment, so later
sessions never re-judge an item or re-dispute a settled test.

delivery-repo-doc, delivery-test-author, delivery-implementer and
delivery-qa are aligned with these contracts. Package bumped to 0.5.0,
with the marketplace allow key and manifest.

Refs: #193

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-11-23 22:44:18 +00:00
1 parent 5221b9ecd5
commit 0258cff316
22 files changed
+666 -129

No files matched your search

@@ -2,20 +2,21 @@
name: delivery-test-first
description: >
Use when a delivery ticket's acceptance criteria must become Acceptance checks before any
implementation exists, or a disputed one must be judged. Not interactive red-green-refactor
-> `tdd`.
implementation exists, or a disputed check or review finding must be judged. Not interactive
red-green-refactor -> `tdd`.
compatibility: Requires git with push access to the work branch, and a consuming repo carrying
docs/agents/delivery.md. Running the new tests needs the repo's test runner on PATH.
allowed-tools: Read Write Edit Bash
metadata:
category: delivery
version: "0.1.0"
version: "0.2.0"
---
## Gotchas
- A new test that passes before the change is vacuous; one that fails on a syntax or import error
proves nothing. Only an assertion failure counts as red.
proves nothing unless the missing import is the change itself. Otherwise only an assertion
failure counts as red.
- Test what the criterion names, observable from outside. A test pinned to a private name or call
sequence becomes a dispute the moment the implementer picks another design.
@@ -48,7 +49,7 @@ File missing, or either section missing or unparseable → stop: "`docs/agents/d
| Condition | Flow | Reference |
|---|---|---|
| Caller passed a ticket and no dispute | First run | `references/first-run.md` |
| Caller passed an implementer's dispute of named tests | Dispute run | `references/dispute.md` |
| Caller passed an implementer's dispute of named tests, or a review round's `[test-author]` findings | Dispute run | `references/dispute.md` |
Read only the matched flow's reference — each is self-contained.
@@ -68,7 +69,7 @@ rtk git commit -m "test: <subject>" --trailer "Delivery-Stage: test-author"
rtk git push
```
Nothing staged — only post-merge assertions, or every disputed test upheld — → still commit, with
Nothing staged — only post-merge assertions, or every disputed item upheld — → still commit, with
`--allow-empty`. CI's test-path check takes the newest trailer commit as the freeze boundary and
passes at once when there is none, so a skipped commit leaves the tests unfrozen. A pre-commit
hook you cannot satisfy by fixing the test → stop with its output quoted.
@@ -1,25 +1,60 @@
# Dispute run — judging a disputed test
# Dispute run — judging disputed tests or review findings
Input from your caller: the work branch, the issue, and the implementer's dispute — the disputed
tests by `file::test name`, each with the implementer's reason. The implementation may already be
on the branch. Return to `SKILL.md` Step 3 when the last step here is done.
Input from your caller: the work branch, the issue, the current `## Acceptance checks` block (on a
review source, the PR body's), and one source of disputes:
- **Implementer** — the disputed tests by `file::test name`, each with the implementer's reason.
- **Review** — the `[test-author]` findings from a review round, each as the review states it,
with the key the review line carries right after the tag: a criterion with no check or an
`open question` line, a test that would pass without the change, a weakened, skipped or deleted
test, an unjustified `post-merge:` reason, a security issue in a test path, a failing CI check
whose error is in a test-path file (syntax, import or fixture), or a PR body with no
`## Acceptance checks` block. The missing block carries no key and gets no verdict line: return
the full Part 1 of `references/output-template.md`, and the lead inserts it into the PR body.
The caller also passes every earlier verdict, from this session or recorded in the Handoff comments
of the PR and of the issue it closes, each one line:
```text
- Dispute verdict: <key> — source: implementer | review — amended | upheld | escalate — <reason>
```
`<key>` is `` `<file>::<test>` `` for a test, `"<criterion>"` verbatim from the issue for a
criterion with no test or its Acceptance checks line, or `` `<file>` `` for a file under the test
paths that is not a test (a fixture with a credential) — never the finding's wording. On a review
source, use the key the review line carries; never derive it.
The implementation may already be on the branch. Return to `SKILL.md` Step 3 when the last step
here is done.
## Step 1 — Check the round
Each test gets one dispute round. A disputed test the caller marks as already judged once → do not
judge it again; return it as `escalate` with the earlier verdict, and the lead escalates to the
human.
Each test, criterion or file gets one judgement across the whole PR, whichever session or source
raised it, so each disputed item gets one verdict line — except the missing-block finding, which
gets none. An item is already judged when a verdict with the same `<key>` exists:
## Step 2 — Judge each disputed test
- review source — any recorded verdict with the same key; the lead has already removed findings
answered after the review;
- implementer source — earlier in this session, or in any earlier Handoff comment.
Reread the criterion the test checks (the issue, quoted in your earlier report) and decide:
Already judged → do not judge it again; return it as `escalate` with the earlier verdict as the
reason, and the lead escalates to the human.
| The dispute shows | Verdict |
## Step 2 — Judge each item
Reread the criterion the item concerns (the issue, quoted in the Acceptance checks block) and
decide:
| The dispute or finding shows | Verdict |
|---|---|
| The test asserts an implementation detail the criterion does not name | Amend |
| The test misreads the criterion, or asserts something the criterion does not require | Amend |
| The test is wrong in itself: bad fixture, wrong expected value, flaky setup | Amend |
| A criterion has no check, or a check that would pass without the change | Amend |
| A `post-merge:` reason fails because a pre-merge test could exercise the criterion | Amend |
| A security issue in a test path (a committed secret, a plaintext credential in a fixture) | Amend |
| The implementation does not meet the criterion, or the implementer prefers a different behaviour | Uphold |
| A review finding misreads the criterion or the check, and the check stands | Uphold |
| The criterion itself is ambiguous and both readings are defensible | Uphold, and add it to Open questions |
Do not weaken a test to make the current implementation pass. An amendment must still check the
@@ -27,17 +62,31 @@ behaviour the criterion names.
## Step 3 — Amend
Edit the test under the test paths only. An amended test must still fail without the
implementation: when a runner is available, run it against the branch's merge-base with the default
branch in a temporary worktree, and apply the same red-for-the-right-reason table as a first run —
assertion failure counts, a pass is vacuous, a syntax or import error is fixed. Runner not on PATH
→ record "not run: <reason>". Also run it once on the branch head and record pass or fail; that
result goes to the implementer and does not change the verdict.
An amendment may change a test, add a test, or rewrite the item's `## Acceptance checks` line (a
new test name, a test in place of `post-merge:`, a sharper post-merge reason). Write tests under
the test paths only. A new or amended test must still fail without the implementation: run it
against the branch's merge-base with the default branch, in a temporary worktree outside the repo
checkout, with the runner the tool skill names (for Ansible, a placeholder vault password as in
`references/first-run.md` Step 5), and judge the result:
| Result | Action |
|---|---|
| Fails on an assertion about the named behaviour | Correct — record it as red |
| Passes | Vacuous: the behaviour already exists or the assertion is too weak. Strengthen it until it fails; if the behaviour truly already exists, add the criterion to Open questions |
| Fails on syntax, import, collection or fixture errors | Fix the test and rerun — except an import of a module the change itself creates, which is expected: make the failure an assertion where the framework allows, or say so in the record |
| Runner not on PATH, or needs credentials you must not hold | Do not fake a result; record "not run: <reason>" for that test |
Then remove the worktree (`git worktree remove`). Also run each new or amended test once on the
branch head and record pass or fail; that result goes to the implementer and does not change the
verdict.
All amendments of the run land in the single commit of `SKILL.md` Step 3.
## Step 4 — Uphold
Leave the test unchanged and write a one-line reason that names the criterion it enforces, e.g.
"upheld: criterion 2 requires the 404 on an unknown id; the implementation returns 500".
Leave the test and its line unchanged and write a one-line reason that names the criterion it
enforces, e.g. "upheld: criterion 2 requires the 404 on an unknown id; the implementation returns
500". On a review finding, the reviewer re-judges the upheld item in the next round.
The commit in `SKILL.md` Step 3 still happens — empty when every test was upheld — so this run
The commit in `SKILL.md` Step 3 still happens — empty when every item was upheld — so this run
ends like every other one.
@@ -68,7 +68,7 @@ For each assertion-classified criterion, write one line holding:
- one **observable statement** about the applied state, concrete enough for `delivery-operator`
to check with read-only commands — resource kind, name, field and expected value;
- a **reason** no pre-merge test applies, which `delivery-reviewer` judges.
- a **reason** no pre-merge test applies, which `delivery-review` judges (its checklist check 3).
Example: `HelmRelease gotify Ready at chart 1.2.3` — reason: a version bump has no testable logic
before reconcile.
@@ -15,15 +15,17 @@ them on its line, separated by `; `.
- "<criterion 2, verbatim>" → `<test file>::<test name>`; `<test file>::<test name>`
- "<criterion 3, verbatim>" → post-merge: <observable statement> — reason: <why no pre-merge test applies>
- "<criterion 4, verbatim>" → `<test file>::<test name>`; post-merge: <statement> — reason: <reason>
- "<criterion 5, verbatim>" → open question
```
Rules:
- `<test file>` is repo-relative. `<test name>` is the name the runner reports, with any class or
describe prefix the runner needs to select it (`tests/test_api.py::TestUsers::test_unknown_id_404`).
- Every criterion appears exactly once. A criterion left unchecked because its test cannot live
under a test path still appears, as `→ open question`, and is listed in Part 2.
- On a dispute run, return the whole block with amended test names updated, not only the changed
- Every criterion appears exactly once. Any criterion added to Open questions appears as
`→ open question` — e.g. a test that cannot live under a test path — except an item a
dispute upheld: it keeps its line, and the ambiguity goes only in Part 2's `Open questions:`.
- On a dispute run, return the whole block with every amended line updated, not only the changed
lines.
## Part 2 — Run notes
@@ -32,13 +34,23 @@ Rules:
Commit: <sha> (Delivery-Stage: test-author) pushed to <branch>
Red run:
<test file>::<test name>: red (assertion) | not run: <reason>
Head run: (dispute run only; omit otherwise)
<test file>::<test name>: pass | fail | not run: <reason>
Dispute verdicts: (dispute run only; omit otherwise)
<test file>::<test name>: amended — <what changed> | upheld — <one-line reason> | escalate — <earlier verdict>
- Dispute verdict: <key> — source: implementer | review — amended | upheld | escalate — <reason>
Open questions:
- <criterion or test, quoted>: <the question> | none
Stop: (only when the run stopped; omit otherwise)
<reason, with the criterion or skill name quoted>
```
Each dispute verdict is exactly that one line, one per disputed item except a missing-block
finding (its answer is Part 1), so the lead copies it verbatim into its Handoff comment. `<key>` is
`` `<test file>::<test name>` `` for a test, `"<criterion, verbatim>"` for a criterion with no test
or its Acceptance checks line, or `` `<file>` `` for a file under the test paths that is not a test
— on a review source, the key the review line carries — never the finding's wording, so a later
round can match it. `<reason>` is what changed (amended), the one-line reason (upheld), or the
earlier verdict (escalate).
A stopped run returns Part 2 with only `Stop:` filled and no commit; the caller runs
`delivery-handoff`'s Stop with that reason.