# 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: ` (`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//`, `.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 ^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 `-`, or `` when it disables the name suffix. A hashed generator matches a `valuesFrom` name that is `-` plus a 10-character suffix, by prefix, or the unhashed ``: 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 -- ``` 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= kubectl get helmrelease
-n -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.