feat(delivery): add the implement stage agents and skills
Implement stage for the delivery team: delivery-implement-lead runs test-author -> implementer -> qa in sequence on a draft WIP: PR and removes WIP: when qa passes, starting review. delivery-test-first turns acceptance criteria into acceptance checks committed under the Delivery-Stage: test-author trailer; delivery-ci-checks reads a PR's or commit's CI by the names in docs/agents/delivery.md. Agents follow ADR-0016 (no tools: lists, disallowedTools fences on the lead and qa) and pin Claude model aliases without model-policy; Copilot limitations are documented in docs/runtimes.md. delivery 0.4.0. Refs: #192 ADR: ADR-0016, ADR-0031, ADR-0032 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
29b5bfea5a
commit
3ef0a3c8a9
13 files changed
+676
-2
No files matched your search
@@ -0,0 +1,77 @@
|
||||
---
|
||||
name: delivery-ci-checks
|
||||
description: >
|
||||
Use when a delivery stage needs the CI verdict for a PR or a commit, judged by the checks the
|
||||
repo's delivery doc lists. Not PR fields or reviews -> `gitea-prs`. Not commit history ->
|
||||
`gitea-branches`.
|
||||
compatibility: Requires a Gitea forge with Actions reached through the Gitea MCP server, and a
|
||||
consuming repo carrying docs/agents/delivery.md.
|
||||
allowed-tools: Read mcp__gitea__pull_request_read mcp__gitea__commit_read mcp__gitea__actions_run_read
|
||||
metadata:
|
||||
category: delivery
|
||||
version: "0.1.0"
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- Read-only. Never re-run, cancel or dispatch CI, and never run a check locally as a substitute or
|
||||
a tiebreak: CI is the source of truth and agents add judgement only.
|
||||
- The forge's combined `state` is not the verdict. A commit with no statuses at all reads
|
||||
`pending`, and `success` ignores which checks ran. Judge each listed check by name.
|
||||
- Match check names verbatim, event suffix included: `Lint / lint (push)` is not
|
||||
`Lint / lint (pull_request)`. Never fuzzy-match or substitute a similar name.
|
||||
- `skipped` counts as passing (path-filtered workflows report it). A listed check with no status on
|
||||
the commit is `missing`, never passing.
|
||||
|
||||
## Step 1 — Read the listed checks
|
||||
|
||||
Read `docs/agents/delivery.md` at the consuming repo's root. Its format is owned by
|
||||
`delivery-repo-doc`'s `references/format.md`; you parse only section `## CI checks`:
|
||||
|
||||
- one item per line: `` - `<exact status name>`: <role> ``
|
||||
- `<role>` is one of `dry-run`, `test-path`, `test`, `lint`, `build`, `other`; `dry-run` on exactly
|
||||
one item
|
||||
- `- none` as the only item means no checks: return verdict `pass` with an empty table and stop.
|
||||
|
||||
File missing, section missing, an item outside that syntax, an unknown role, or not exactly one
|
||||
`dry-run` → return `malformed: <reason>` and no verdict. The caller stops with
|
||||
`Status/Ready for Human` through `delivery-handoff`'s Stop; do not guess the list.
|
||||
|
||||
## Step 2 — Pin the commit
|
||||
|
||||
- **PR** → `mcp__gitea__pull_request_read` method `get`; take `head.sha` and the PR's `html_url`.
|
||||
- **Commit** (e.g. post-merge on `main`) → use the SHA you were given.
|
||||
|
||||
Only statuses on this SHA count. A status from an older commit of the PR is stale and is ignored.
|
||||
|
||||
## Step 3 — Read statuses, with bounded waiting
|
||||
|
||||
Read `references/statuses.md` now. Read the pinned SHA's statuses with
|
||||
`mcp__gitea__commit_read` method `get_status`, `ref` set to the SHA, and classify each listed
|
||||
check as `success`, `failure`, `skipped`, `pending` or `missing` per its mapping.
|
||||
|
||||
Re-read while any listed check is `pending`, or while no listed check has reported yet. Each
|
||||
re-read passes `wait_seconds: 45`. For a PR, re-read `head.sha` first; if it moved, go back to
|
||||
Step 2 with the new SHA. The hard cap is **20 reads, about 15 minutes**, across all SHAs; at the
|
||||
cap, stop and report what you have. Never wait past the cap.
|
||||
|
||||
## Step 4 — Explain failures
|
||||
|
||||
For each `failure`, read the job's log as `references/statuses.md` §Failure cause says and write
|
||||
the cause in one line. Link the job; never paste log text into the result.
|
||||
|
||||
## Step 5 — Return the result
|
||||
|
||||
Overall verdict, first match wins: any `failure` → `fail`; any `missing` → `missing`; any
|
||||
`pending` → `pending`; else → `pass`.
|
||||
|
||||
Output format:
|
||||
|
||||
```text
|
||||
Commit: <full SHA> Verdict: <pass|fail|pending|missing>
|
||||
| Check | Role | State | Run | Cause |
|
||||
```
|
||||
|
||||
One row per listed check, in the doc's order. `Run` is the absolute job link, or `none` for a
|
||||
skipped or missing check. `Cause` is the one-line failure cause, else empty. On `pending` or
|
||||
`missing` the caller decides what follows; you do not.
|
||||
@@ -0,0 +1,58 @@
|
||||
# Reading Gitea commit statuses
|
||||
|
||||
## Response shape
|
||||
|
||||
`mcp__gitea__commit_read` method `get_status`, `ref: <SHA>` returns:
|
||||
|
||||
```json
|
||||
{"sha": "<SHA>", "state": "success", "total_count": 4, "statuses": [
|
||||
{"context": "Flux Dry Run / flux_dry_run (pull_request)", "status": "success",
|
||||
"description": "Successful in 2s", "target_url": "/<owner>/<repo>/actions/runs/4872/jobs/5907"},
|
||||
{"context": "Molecule Role Tests / molecule (pull_request)", "status": "skipped",
|
||||
"description": "Skipped", "target_url": ""}]}
|
||||
```
|
||||
|
||||
- `context` is the status name. Gitea Actions names it `<workflow name> / <job> (<event>)`, the same
|
||||
string the delivery doc lists.
|
||||
- `status` is the per-check state. Ignore the top-level `state`: it reads `pending` for a commit
|
||||
with no statuses at all (`"statuses": []`).
|
||||
- `target_url` is relative to the forge root and points at the job, not the run. It is empty for a
|
||||
skipped check.
|
||||
- Confirm the response's `sha` equals the pinned SHA before using it.
|
||||
|
||||
## State mapping
|
||||
|
||||
| Status `status` | Classified as |
|
||||
|---|---|
|
||||
| `success` | `success` |
|
||||
| `skipped` | `skipped`, passing |
|
||||
| `failure`, `error`, `warning` | `failure` |
|
||||
| `pending` (Gitea Actions reports queued and running jobs as this), any other value | `pending` |
|
||||
| no status whose `context` equals the listed name | `missing` |
|
||||
|
||||
When two statuses share a `context`, use the one with the latest `updated_at`.
|
||||
|
||||
## Links
|
||||
|
||||
Build the absolute link from the forge's origin, the scheme and host of the PR's `html_url` or of
|
||||
the API `url` fields, plus `target_url`:
|
||||
`https://git.example.org` + `/<owner>/<repo>/actions/runs/4872/jobs/5907`.
|
||||
|
||||
A skipped or missing check has no job, so its `Run` cell is `none`.
|
||||
|
||||
## Failure cause
|
||||
|
||||
The job id is the number after `/jobs/` in `target_url`. Read the log tail filtered to error lines:
|
||||
|
||||
```text
|
||||
mcp__gitea__actions_run_read method get_job_log_preview, job_id <id>,
|
||||
pattern '::error::|FAIL|Error|error:', context_lines 2, tail_lines 200
|
||||
```
|
||||
|
||||
If the filtered read returns nothing, read once more without `pattern`. From what comes back, write
|
||||
one line naming the failing step and its cause, e.g. "ansible-lint: `roles/pihole/tasks/main.yml`
|
||||
uses a deprecated module". Do not quote more than a short identifier from the log. The evidence is
|
||||
the job link, never pasted log text.
|
||||
|
||||
If the log is unreadable (expired, or the job was cancelled before any output), the cause is
|
||||
`log unavailable` and the job link still goes in `Run`.
|
||||
@@ -1,7 +1,7 @@
|
||||
# The `docs/agents/delivery.md` format
|
||||
|
||||
This file is the single source of truth for the format. `delivery-handoff`, `delivery-ci-checks`,
|
||||
`delivery-qa` and `delivery-operator` cite it as "`delivery-repo-doc`'s `references/format.md`" and
|
||||
`delivery-test-first`, `delivery-qa` and `delivery-operator` cite it as "`delivery-repo-doc`'s `references/format.md`" and
|
||||
restate only the minimum they parse — `delivery-handoff`, for example, restates the first line and
|
||||
section 4's syntax. A format change is an edit here, plus every consumer's restatement.
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
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`.
|
||||
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"
|
||||
---
|
||||
|
||||
## 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.
|
||||
- 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.
|
||||
|
||||
## Common gates
|
||||
|
||||
Apply on every flow:
|
||||
|
||||
- Never read secret material: vault files, vault password files, private keys, `.tfstate`,
|
||||
Secret objects. An Ansible check runs with a placeholder vault password only.
|
||||
- Write only under the repo's test paths. A test outside them is never frozen, so do not write it
|
||||
there — report it under Open questions instead.
|
||||
- Never `--no-verify`, never `SKIP=`. A failing hook is fixed in the commit, not bypassed.
|
||||
- A stop skips Step 3: go straight to Step 4 with the reason quoted; the caller runs
|
||||
`delivery-handoff`'s Stop. Do not label or comment on the tracker yourself.
|
||||
|
||||
## Step 1 — Read the repo's delivery doc
|
||||
|
||||
Read `docs/agents/delivery.md` at the consuming repo's root. Its format is owned by
|
||||
`delivery-repo-doc`'s `references/format.md`; you parse only two sections, items one per line:
|
||||
|
||||
- `## Contents → skills` — `` - `<glob>`: `<skill>`, `<skill>` `` or `- none`.
|
||||
- `## Test paths` — either the single item `` - globs file: `<path>` `` (read the globs, one per
|
||||
line, from that repo file) or one `` - `<glob>` `` per line.
|
||||
|
||||
File missing, or either section missing or unparseable → stop: "`docs/agents/delivery.md`
|
||||
<problem>". Test paths `- none` → stop: "no test paths in `docs/agents/delivery.md`".
|
||||
|
||||
## Step 2 — Dispatch
|
||||
|
||||
| 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` |
|
||||
|
||||
Read only the matched flow's reference — each is self-contained.
|
||||
|
||||
## Step 3 — Commit and push
|
||||
|
||||
Stage only files under the test paths, then check the staged set before committing:
|
||||
|
||||
```bash
|
||||
git diff --cached --name-only # bare: the path list is parsed (ADR-0023)
|
||||
```
|
||||
|
||||
Any path outside the test paths → unstage it. Commit exactly once per run, with a Conventional
|
||||
Commits subject and the trailer, then push the work branch you were given:
|
||||
|
||||
```bash
|
||||
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
|
||||
`--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.
|
||||
|
||||
## Step 4 — Report
|
||||
|
||||
Read `references/output-template.md` and return its output to your caller, filled for the flow
|
||||
you ran.
|
||||
@@ -0,0 +1,43 @@
|
||||
# Dispute run — judging a disputed test
|
||||
|
||||
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.
|
||||
|
||||
## 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.
|
||||
|
||||
## Step 2 — Judge each disputed test
|
||||
|
||||
Reread the criterion the test checks (the issue, quoted in your earlier report) and decide:
|
||||
|
||||
| The dispute 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 |
|
||||
| The implementation does not meet the criterion, or the implementer prefers a different behaviour | 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
|
||||
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.
|
||||
|
||||
## 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".
|
||||
|
||||
The commit in `SKILL.md` Step 3 still happens — empty when every test was upheld — so this run
|
||||
ends like every other one.
|
||||
@@ -0,0 +1,77 @@
|
||||
# First run — acceptance criteria to acceptance checks
|
||||
|
||||
Input: the ticket (issue) and the work branch, from your caller. No implementation exists yet.
|
||||
Return to `SKILL.md` Step 3 when the last step here is done.
|
||||
|
||||
## Step 1 — List the criteria
|
||||
|
||||
Read the issue's acceptance criteria and number them in their written order. Quote each one
|
||||
verbatim; the report pairs checks with the quoted text.
|
||||
|
||||
No acceptance criteria on the issue → stop: "issue has no acceptance criteria".
|
||||
|
||||
## Step 2 — Classify each criterion
|
||||
|
||||
Every criterion gets at least one check. Decide per criterion, in this order:
|
||||
|
||||
1. **Test** — the behaviour it names can be exercised before merge: code, a template render, a
|
||||
lint or schema rule the repo's tests can run, a script's output.
|
||||
2. **Post-merge assertion** — the criterion is only observable in the applied state and nothing
|
||||
before reconcile or apply carries logic to test, e.g. a chart version bump.
|
||||
3. **Neither** — the criterion names no observable outcome ("is clean", "works well", "is
|
||||
faster" with no measure). That is a spec problem → stop with the criterion quoted:
|
||||
"criterion not checkable: \"<criterion>\"".
|
||||
|
||||
A criterion may need both a test and a post-merge assertion; write both.
|
||||
|
||||
## Step 3 — Load the tool skills
|
||||
|
||||
Match the paths the change will touch (from the issue, or the files its criteria name) against the
|
||||
`## Contents → skills` globs. Load the union of the listed skills over every matching glob; they
|
||||
own the test framework, file layout and naming conventions. Follow them, not a framework you would
|
||||
pick yourself.
|
||||
|
||||
A listed skill that is not installed → stop: "missing skill `<name>`". No glob matches, or the
|
||||
section is `- none` → follow the conventions of the existing tests under the test paths.
|
||||
|
||||
## Step 4 — Write the tests
|
||||
|
||||
For each test-classified criterion:
|
||||
|
||||
- Place the file under a test path glob. The needed test cannot live under one → do not write it;
|
||||
add the criterion to Open questions in the report, naming the path it would need.
|
||||
- Assert the outcome the criterion names, through the interface a user or caller sees: a public
|
||||
function, a CLI's output, a rendered manifest, a role's resulting file. Never assert private
|
||||
names, call order or internal structure the criterion does not mention.
|
||||
- Name the test after the behaviour, so the report line reads as the criterion.
|
||||
- One test per behaviour; a criterion with several outcomes gets several tests.
|
||||
|
||||
## Step 5 — Confirm each test is red for the right reason
|
||||
|
||||
Run only the new tests, once, with the runner the tool skill names. For Ansible, use a placeholder
|
||||
vault password (a temporary file holding the literal string `placeholder`), never the real one.
|
||||
|
||||
| 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 |
|
||||
| Runner not on PATH, or needs credentials you must not hold | Do not fake a result; record "not run: <reason>" for that test |
|
||||
|
||||
A test that imports a module the change will create fails on import; that is expected only when the
|
||||
missing module is the change itself. Make the failure an assertion where the framework allows,
|
||||
e.g. import inside the test and assert on its absence, or say so in the record.
|
||||
|
||||
## Step 6 — Write post-merge assertions
|
||||
|
||||
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.
|
||||
|
||||
Example: `HelmRelease gotify Ready at chart 1.2.3` — reason: a version bump has no testable logic
|
||||
before reconcile.
|
||||
|
||||
Post-merge assertions are not files; they go only in the report. With no test files written, the
|
||||
commit in `SKILL.md` Step 3 is empty.
|
||||
@@ -0,0 +1,44 @@
|
||||
# The test author's output
|
||||
|
||||
Return this to your caller as the run's only output. It has two parts: the block the lead pastes
|
||||
into the PR body verbatim, and the run notes the lead reads.
|
||||
|
||||
## Part 1 — PR body block
|
||||
|
||||
One line per acceptance criterion, in the issue's order. A criterion with several checks lists
|
||||
them on its line, separated by `; `.
|
||||
|
||||
```markdown
|
||||
## Acceptance checks
|
||||
|
||||
- "<criterion 1, verbatim>" → `<test file>::<test name>`
|
||||
- "<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>
|
||||
```
|
||||
|
||||
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
|
||||
lines.
|
||||
|
||||
## Part 2 — Run notes
|
||||
|
||||
```text
|
||||
Commit: <sha> (Delivery-Stage: test-author) pushed to <branch>
|
||||
Red run:
|
||||
<test file>::<test name>: red (assertion) | not run: <reason>
|
||||
Dispute verdicts: (dispute run only; omit otherwise)
|
||||
<test file>::<test name>: amended — <what changed> | upheld — <one-line reason> | escalate — <earlier verdict>
|
||||
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>
|
||||
```
|
||||
|
||||
A stopped run returns Part 2 with only `Stop:` filled and no commit; the caller runs
|
||||
`delivery-handoff`'s Stop with that reason.
|
||||
Reference in new issue
Block a user