feat(delivery): add the verify stage: delivery-operator and delivery-verify
delivery-operator (opus; no Edit, Write, NotebookEdit or Agent) is the verify-stage lead. After a human approves and merges, it reads the delivery doc at the merge commit's first parent, proves its kubeconfig cannot write (four auth can-i probes), loads the routed tool skills and runs delivery-verify. It posts the operator report as its own comment, then the final Handoff (Next command none on pass). delivery-verify: - stops first if the change was already reverted; - waits for Flux through flux-diagnose's Applied check (15-minute cap) and reads post-merge CI per workflow through delivery-ci-checks (45-minute cap), accepting a later cumulative run as cover; - checks the PR's post-merge assertions with Read-tier commands only; - ties a failure to the change only when that is established, and otherwise stops. A tied failure opens a revert PR (Ready for Human, built in a temporary worktree); it never reverts on its own. For Flux the guarantee is bounded: the merge commit applied and the inventory HelmReleases are Ready. The assertions prove a values or chart change took effect. The delivery doc format gains a seventh parsed section, Post-merge checks (glob -> push-event status names, or none when Flux pulls the change), so delivery-repo-doc goes to 0.2.0. delivery-ci-checks takes a caller check list and wait cap; delivery-handoff carries the verify stops. delivery 0.6.0. Refs: #194 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
277d6f5826
commit
5081206c45
19 files changed
+788
-34
No files matched your search
@@ -0,0 +1,113 @@
|
||||
# Attributing a failure
|
||||
|
||||
A revert PR undoes this change, so it is opened only when a failure is tied to this change. When
|
||||
in doubt the failure is untied: a stop asks a human, a wrong revert PR asks them to undo the undo.
|
||||
A failure is tied only when every condition below is established from what the run read; anything
|
||||
not established, including a cause or an earlier state that cannot be read, is untied.
|
||||
|
||||
## Assertion
|
||||
|
||||
Tied only when its target was reached and the observed value contradicts the change: a service
|
||||
answering with the old version, an object present with the wrong spec. Untied when an untied
|
||||
failure below (a Kustomization already failing, another commit's failure) is what made it fail. A
|
||||
connection error or timeout reaching the target is never a `fail`: it is
|
||||
`unverifiable: <why>` (`SKILL.md` Step 5).
|
||||
|
||||
Untied when the state read may come from a commit after the merge commit: the Applied commit
|
||||
(`references/report.md`) is not the merge commit, a waited Kustomization carries a
|
||||
`superseded by` note, or a check passed only as "covered by" a later commit. A later commit may
|
||||
have changed the target.
|
||||
|
||||
## CI check
|
||||
|
||||
Always untied, whatever file or component it names: a failure from an unreachable host, a
|
||||
timeout, a cancelled run, a runner or registry error, or a refusal to run such as Provision's "not
|
||||
tip of main". These say the run could not judge the change, not that the change is wrong.
|
||||
|
||||
Otherwise tied when both hold:
|
||||
|
||||
- **It names this change.** The cause from `delivery-ci-checks`, or the job log
|
||||
(`mcp__gitea__actions_run_read` `get_job_log_preview`), names a file the PR changed, or names a
|
||||
component whose files the PR changed. A component is a unit the repo's tooling runs by name:
|
||||
an Ansible role or playbook, a Flux app, a Helm chart, a Terraform module. It maps to the
|
||||
directory or file that defines it (`roles/<name>/`, `<playbook>.yml`, the app's or chart's
|
||||
directory); the failure names the component and the PR changed a file under its directory.
|
||||
- **It was passing before.** Walk the merge commit's first-parent history back to the nearest
|
||||
ancestor carrying a status with the same name:
|
||||
|
||||
```bash
|
||||
git log --first-parent --format=%H -n 50 <merge commit>^1 # ADR-0023: parsed
|
||||
```
|
||||
|
||||
Bare `git`, per ADR-0023: rtk filters `git log` and this output is parsed. Read each SHA's
|
||||
statuses with `mcp__gitea__commit_read` `get_status`, newest first. A `skipped` status ran
|
||||
nothing, so pass over it, but only when every row of its workflow (the status name's prefix
|
||||
before ` / `) on that commit is `success` or `skipped`; otherwise a failure there may have
|
||||
skipped it, and the failure is untied. The first one found must be `success`. Anything else, or
|
||||
none in the 50 commits → untied.
|
||||
|
||||
## Kustomization
|
||||
|
||||
Tied when all hold:
|
||||
|
||||
- Its attempted revision is the merge commit itself. One that strictly descends from it is
|
||||
another commit's failure, not this change's: untied.
|
||||
- Its diagnosis names a path the PR changed, or an object rendered from one.
|
||||
- It was Ready at the revision before: its Ready message, `flux events` or `flux trace`, read
|
||||
through `flux-diagnose`, show that. A Kustomization already failing is untied.
|
||||
|
||||
A Kustomization that is `failed` only through its HelmReleases, including a failed health check
|
||||
on them, is judged under §HelmRelease alone.
|
||||
|
||||
## HelmRelease
|
||||
|
||||
The Applied check reports every failing HelmRelease in a waited Kustomization's inventory, so
|
||||
most are not this change's. A failing one is tied only when all three hold:
|
||||
|
||||
1. **It is linked to this PR**, by one of these:
|
||||
- Its manifest is in a changed file. Read each changed `.yaml` or `.yml` file the PR did not
|
||||
delete with `mcp__gitea__get_file_contents`, `ref` the merge commit; a `HelmRelease`
|
||||
document matches by name and namespace. One with no `metadata.namespace` matches by name
|
||||
only when its Kustomization's `spec.path` contains that file.
|
||||
- Its `spec.chartRef` or a `spec.valuesFrom` entry names, by kind, namespace and name, an
|
||||
object defined in a changed file, or generated from one. A generator matches when a
|
||||
`configMapGenerator` or `secretGenerator` in any `kustomization.yaml` under its
|
||||
Kustomization's `spec.path` lists the changed file: a `files`, `envs` or `env` entry (the
|
||||
path after any `key=`, `../` included) resolves, relative to that `kustomization.yaml`, to
|
||||
the changed path. It generates `<base>-<hash>`, or `<base>` when it disables the name
|
||||
suffix. A hashed generator matches a `valuesFrom` name that is `<base>-` plus a 10-character
|
||||
suffix, by prefix, or the unhashed `<base>`: kustomize rewrites the name only when a
|
||||
`configurations:` nameReference for `kind: HelmRelease`, `path: spec/valuesFrom/name`
|
||||
exists. List the candidates and read each at the merge commit, with `.` for an empty
|
||||
`spec.path` or `./`:
|
||||
|
||||
```bash
|
||||
rtk git ls-tree -r --name-only <merge commit> -- <spec.path>
|
||||
```
|
||||
|
||||
A `secretGenerator` matches by name only; never read the files it lists.
|
||||
- Its `spec.chart.spec.sourceRef` is a `GitRepository` `references/apply-wait.md` step 2
|
||||
kept, and its `spec.chart.spec.chart` path contains a changed path (that file's step 4
|
||||
rule).
|
||||
|
||||
Read the references, names only, never values (an empty namespace is the release's own):
|
||||
|
||||
```bash
|
||||
KUBECONFIG=<path> kubectl get helmrelease <hr> -n <hr-ns> -o jsonpath='{.spec.chartRef.kind}{"|"}{.spec.chartRef.namespace}{"|"}{.spec.chartRef.name}{"|"}{.spec.chart.spec.sourceRef.kind}{"|"}{.spec.chart.spec.sourceRef.namespace}{"|"}{.spec.chart.spec.sourceRef.name}{"|"}{.spec.chart.spec.chart}{"\n"}{range .spec.valuesFrom[*]}{.kind}{"|"}{.name}{"\n"}{end}'
|
||||
```
|
||||
|
||||
2. **It was Ready before the change**, shown by its `flux events` or `flux trace` through
|
||||
`flux-diagnose`: an upgrade from Ready to failing is this change's. A HelmRelease failing
|
||||
before, or new in this PR with no earlier state, is untied.
|
||||
3. **Its Kustomization reached the merge commit itself**: `applied` at it, or `failed` with its
|
||||
attempted revision equal to it. The second covers `wait: true` or `healthChecks`: when a health
|
||||
check on its HelmReleases fails, kustomize-controller is believed, not confirmed, to keep the
|
||||
applied revision at the previous commit. A `superseded by` or `later revision … failing` note
|
||||
on that Kustomization → untied: a later commit's chart or values may be what fails.
|
||||
|
||||
Anything else is untied: a stop, never a revert.
|
||||
|
||||
## Recording
|
||||
|
||||
Record each failure in the report's Verification line with `tied` or `untied` and the one-line
|
||||
reason.
|
||||
Reference in new issue
Block a user