diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index e156eb9..aaca211 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -59,7 +59,7 @@ { "name": "delivery", "description": "Agents and skills for taking a change from spec to a verified merge through tracker-gated stages.", - "version": "0.2.0", + "version": "0.3.0", "category": "Developer Tools", "source": "./plugins/delivery" }, diff --git a/GLOSSARY.md b/GLOSSARY.md index 8af6bfa..10b5e6f 100644 --- a/GLOSSARY.md +++ b/GLOSSARY.md @@ -136,9 +136,22 @@ _Avoid_: specialist agent (implies a tool specialist), worker, persona **Handoff comment**: The fixed-shape tracker comment that ends every **Stage** — decisions, rejected options, evidence, -the pointer the next stage starts from, and open questions. The next stage reads it first. +the pointer the next stage starts from, open questions, and the command that launches the next +session (the next stage, a relaunch of a stopped one, or none after the last). The next stage reads +it first. _Avoid_: summary, status update +**Step mode**: +How v1 runs the delivery flow: a human launches each **Stage** session by hand, from the previous +**Handoff comment**'s Next command. The launch itself is the human's approval. +_Avoid_: manual mode, interactive mode + +**Run mode**: +The later way the delivery flow runs: Gitea Actions workflows launch the next **Stage** on **Gate** +events, and the launcher checks the event's sender against the repo's human allowlist before +starting an agent. +_Avoid_: auto mode, autopilot + **Acceptance check**: What the test author writes before any implementation, from a ticket's acceptance criteria: a failing test where a test can express the criterion, otherwise a post-merge assertion about the diff --git a/apm.yml b/apm.yml index 9bf54fb..0da8f0f 100644 --- a/apm.yml +++ b/apm.yml @@ -73,7 +73,7 @@ executables: bin: true # delivery ships the guard hook (ADR-0032 enforcement layer 2). Same # version-in-key convention as above, kept by the same sync check. - delivery#0.2.0: + delivery#0.3.0: hooks: true marketplace: diff --git a/docs/adr/0032-credentials-not-hooks-are-the-agent-safety-boundary.md b/docs/adr/0032-credentials-not-hooks-are-the-agent-safety-boundary.md index 23f3296..b0db7a3 100644 --- a/docs/adr/0032-credentials-not-hooks-are-the-agent-safety-boundary.md +++ b/docs/adr/0032-credentials-not-hooks-are-the-agent-safety-boundary.md @@ -54,8 +54,12 @@ running it in CI on a bot PR hands the bot those credentials. Decided in `flux diff` needs write RBAC, because Kubernetes authorises dry-run requests like real ones, so it is not used. Ansible's pre-merge `--check --diff` is reopened (see Secrets); later `tofu plan`; - - stage leads start only when a user on the human allowlist in `docs/agents/delivery.md` set the - gate label, checked against the issue timeline; + - in step mode (v1) the human launching a stage is the approval, and stage leads check gate + state only: the stage's gate label, if it has one, is present, and for verify the PR is + merged with a non-stale, non-dismissed approval by a user on the human allowlist in + `docs/agents/delivery.md`. The who-set-the-label check moves to the run-mode launcher, which + checks the triggering event's sender against the allowlist before starting an agent; it is + deterministic, so it belongs in the workflow, not an agent; - a CI test-path check, run from `main`'s copy, fails if a commit after the test author's (trailer `Delivery-Stage: test-author`) touches the globs in `.gitea/test-paths`; this check, not file protection, guards tests. The implementer hands disputed tests back instead of editing @@ -101,6 +105,10 @@ running it in CI on a bot PR hands the bot those credentials. Decided in cluster or state and print no secret: anything not on the list is denied, so an unlisted mutating subcommand fails safe. Codex cannot ask, so odd jobs are denied there; an unrecognised runtime is treated the same way. +- *Amended 2026-11-23 ([delivery-handoff skill](https://git.rkdr.net/Mortis/Holocron/issues/191)): stage + leads check gate state only and the who-set-the-label check moved to the run-mode launcher, + because gitea-mcp v1.13.0 has no timeline method, the timeline needs a token on private repos, + and in step mode the human already launches each stage.* - *Amended 2026-11-23 ([delivery guard hook](https://git.rkdr.net/Mortis/Holocron/issues/190)): Copilot ask kept as an accepted risk; the guard covers file tools and uses read-verb allowlists.* - *Amended 2026-11-22 ([Credential boundary setup in ansible-homelab-mono](https://git.rkdr.net/Mortis/Holocron/issues/184)): test paths left diff --git a/plugins/delivery/.apm/skills/delivery-handoff/SKILL.md b/plugins/delivery/.apm/skills/delivery-handoff/SKILL.md new file mode 100644 index 0000000..51b0128 --- /dev/null +++ b/plugins/delivery/.apm/skills/delivery-handoff/SKILL.md @@ -0,0 +1,66 @@ +--- +name: delivery-handoff +description: > + Use when a delivery Stage lead starts or finishes its stage. Owns the stage's entry gate and exit + Handoff comment. Not a plain issue comment -> `gitea-issues`. Not writing the repo's delivery doc + -> `delivery-repo-doc`. +compatibility: Requires a Gitea forge reached through the Gitea MCP server (via the gitea-issues and + gitea-prs skills), and a consuming repo carrying docs/agents/delivery.md. +allowed-tools: Read mcp__gitea__issue_read mcp__gitea__issue_write mcp__gitea__pull_request_read +metadata: + category: delivery + version: "0.1.0" +--- + +## Gotchas + +- `Status/Ready for Human` is a stop signal, not a Gate, so you may set it. Every real gate — + `Status/Ready for Agent`, a PR approval — is human-only: never set, add or remove a gate label, + and never approve a PR. +- Check gate *state*, not who set it: in step mode the human launching your stage is the approval. + Do not read the issue timeline. +- `Status/Ready for Agent` and `Status/Ready for Human` must not share an exclusive label scope: + Gitea would then drop the gate label when you add Ready for Human. Never re-add it yourself. + +## Step 1 — Read the repo's delivery doc + +Before any other work, read `docs/agents/delivery.md` at the consuming repo's root. Its format is +owned by `delivery-repo-doc`'s `references/format.md`; you need only the Human allowlist: section +`## Human allowlist`, one `` - `` `` item per line, never empty. + +File missing, first line not `# Delivery`, or the allowlist section missing, empty or `- none` → +go to **Stop** with the reason, e.g. "`docs/agents/delivery.md` missing". + +## Step 2 — Read the inbound Handoff comment + +Read the issue or PR you were pointed at via `gitea-issues` (or `gitea-prs` for the PR's own +fields). Find the latest Handoff comment and apply `references/gates.md` §Inbound Handoff comment; +if it says stop → **Stop**. + +## Step 3 — Check the gate + +Run every check in your stage's row of `references/gates.md`. Any check fails → **Stop**, quoting +the failed check as the reason. + +## Step 4 — Do the stage's work + +Run your stage's own flow. A blocker mid-stage — a skill named in `docs/agents/delivery.md` that is +not installed, a question only the human can answer — → **Stop**. + +## Step 5 — Exit + +Read `references/handoff-comment.md` now and write exactly one Handoff comment from its template, +with the Next command filled for your stage, and post it where its Rules say. Then end the session. + +## Stop + +Used by every step. Do both, then end the session without further work: + +1. Add the `Status/Ready for Human` label to the issue or PR you were pointed at, via `gitea-issues`. +2. Post one comment where `references/handoff-comment.md` §Rules says a stop posts: + - **Before the inbound check passed** (Step 1 or Step 2) → a plain comment stating the reason, + not a Handoff comment, so the inbound rule is never bypassed. A relaunch comes from the latest + real Handoff comment, or from scratch where your row's inbound is Optional. + - **After it passed** (Steps 3–4) → a Handoff comment from `references/handoff-comment.md`, + filled per its stop row. Open questions states the reason; for a missing skill use the + format's wording, "missing skill ``". diff --git a/plugins/delivery/.apm/skills/delivery-handoff/references/gates.md b/plugins/delivery/.apm/skills/delivery-handoff/references/gates.md new file mode 100644 index 0000000..9f89157 --- /dev/null +++ b/plugins/delivery/.apm/skills/delivery-handoff/references/gates.md @@ -0,0 +1,56 @@ +# Stage gates + +Each stage lead runs the checks in its own row, in order. Read issue fields through `gitea-issues` +and PR fields and reviews through `gitea-prs`. Every check reads tracker state only; none sets it. + +| Stage | Stage lead | Pointed at | Inbound Handoff comment | Gate checks | +|---|---|---|---|---| +| implement | `delivery-implement-lead` | issue | Optional: a human-written ticket has none | The issue carries the label `Status/Ready for Agent` | +| review | `delivery-reviewer` | PR | Required | No human gate. The PR title does not start with `WIP:` | +| verify | `delivery-operator` | PR | Required | The PR is merged (`merged` is true) **and** has at least one review meeting every review condition below | +| spec, tickets | `delivery-planner` | — | — | None in v1: the planner stops at the inbound check (below); gates come in slice 4 | + +## Inbound Handoff comment + +A Handoff comment is a comment whose `##` headings are exactly the six listed in +`references/handoff-comment.md` §Rules, in that order. Ignore every other comment: a quote of one, +a plain stop comment, a partial one. Run these in order, stopping at the first that applies: + +- Your agent has no row in the table above → stop with "no stage defined for agent ``". +- You are `delivery-planner` → stop with "no gate defined for the spec or tickets stage in v1": + there is no stage to relaunch into in v1. +- The item you were pointed at is not the kind your row's "Pointed at" column names → stop + with "pointed at an ``, expected an ``". + +Then find the latest Handoff comment, newest by creation time, on that item: + +- Its `## Next command` launches your stage's agent → it is your inbound comment. A stop after this + check passed posts a Handoff comment relaunching the stopped stage, so its relaunch lands here and + runs every gate check in your row again. +- There is none → proceed only if your row says Optional; otherwise stop with "no inbound Handoff + comment". +- It launches a different agent, or its Next command is `none` (the final stage) → stop with + "latest Handoff comment does not launch ``". + +Every stop in this section posts a plain comment, not a Handoff comment (`SKILL.md` §Stop). The +human removes `Status/Ready for Human` before relaunching; the agent does not check it. + +## Verify: review conditions + +Read the PR's reviews (`pull_request_read`, method `get_reviews`). A review counts only when all of +these hold: + +- `state` is `APPROVED`; +- its author's login is on the Human allowlist, compared against the forge's casing; +- `stale` is `false` — no push landed after it was submitted; +- `dismissed` is `false`. + +## Stop reasons + +Quote the failed check as the Open questions reason. Inbound-check wordings are in §Inbound Handoff +comment above. Typical gate-check wordings: + +- implement: "gate not set: `Status/Ready for Agent` missing" +- review: "PR title still starts `WIP:`" +- verify: "PR not merged"; "no approval from an allowlisted human that is neither stale nor + dismissed" diff --git a/plugins/delivery/.apm/skills/delivery-handoff/references/handoff-comment.md b/plugins/delivery/.apm/skills/delivery-handoff/references/handoff-comment.md new file mode 100644 index 0000000..74f208a --- /dev/null +++ b/plugins/delivery/.apm/skills/delivery-handoff/references/handoff-comment.md @@ -0,0 +1,123 @@ +# The Handoff comment + +One comment ends every stage, on success or on a stop after the inbound check passed; a stop before +it posts a plain comment instead (`SKILL.md` §Stop). The next stage reads it first, and run mode +will later parse it, so the shape is fixed even though nothing validates it yet. + +## Rules + +- Six `##` headings, verbatim and in this order: `## Decisions`, `## Rejected`, `## Evidence`, + `## Next pointer`, `## Open questions`, `## Next command`. No other `##` headings. +- Every section is present. An empty one holds the single word `none`. +- **Evidence** is links — CI runs, commits, the PR — never pasted logs. +- **Next pointer** is the URL the next stage starts from: the PR once one exists, otherwise the + issue. On a stop, it is the item you were pointed at. +- **Open questions** carries the stop reason on a stop. +- Post the comment on the Next pointer's item via `gitea-issues` — a Gitea PR's conversation + comments are issue comments. On a stop, post it — or the plain stop comment — on the item you + were pointed at. + +## Template + +````markdown +## Decisions + +- + +## Rejected + +-