Skip to content

fix(#820): classify runner-never-started CI (billing lockout) as infra-blocked, not NOT_MET - #828

Merged
admarble merged 4 commits into
mainfrom
feature/820-fix-qa-classify-runner-never-started-ci-billin
Jul 27, 2026
Merged

admarble merged 4 commits into
mainfrom
feature/820-fix-qa-classify-runner-never-started-ci-billin

Conversation

@admarble

@admarble admarble commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A repository that hits its GitHub Actions spending limit fails every check within seconds — no runner is ever allocated, so no step executes. gh pr checks and gh run view both report these as ordinary failures, so /qa Phase 1's FAILURE → NOT_MET → blocks merge mapping marked CI-dependent ACs unmet for a condition no code change can fix, and fed those findings to /loop.

  • Phase 1 now queries the head commit's check-run annotations — only when every check is in the fail bucket — and on a message matching /job was not started/i classifies CI as infra-blocked: CI-dependent ACs are marked PENDING (which routes to a NEEDS_VERIFICATION verdict — see below), the report carries the annotation verbatim, and the finding is marked <!-- qa:ci-infra-blocked -->.
  • /loop gains an Excluded Finding Classes rule that rebinds qa_comment before the verdict/findings extraction, so marked findings never reach the fix pass.
  • Detection lives in src/lib/qa/infra-blocked-ci.ts as pure predicates, mirroring the existing markdown-only-ci.ts split (detection in TypeScript, gh api plumbing in the skill prompt).

AC Verification

AC Description Status Evidence
AC-1 Annotation query gated on all-checks-failing ✅ Implemented allChecksFailing (infra-blocked-ci.ts:40); step 1 of the Phase 1 procedure, with the fetch inside the if. 7 unit tests.
AC-2 Not-started signature ⇒ infra-blocked, verbatim message ✅ Implemented NOT_STARTED_SIGNATURE + detectInfraBlockedCi; AC status PENDING → verdict NEEDS_VERIFICATION, never NOT_MET. Message verified verbatim against the issue body's own bytes.
AC-3 Excluded from /loop, documented in both skill docs ✅ Implemented qa/SKILL.md § "Loop Exclusion"; loop/SKILL.md § "Excluded Finding Classes" + Step 3 exit condition.
AC-4 Byte-identical behavior off the trigger path ✅ Implemented 6 unit tests on the gate; /loop filter byte-identical on 40 real QA comments; confirmed live on this PR (8 passing checks → no annotation query).
AC-5 gh api commands verified against real output per §6a ✅ Verified Whole procedure executed, not just read — see below.
AC-6 Mirrored across all three skill dirs ✅ Implemented check-skill-sync.ts: 42 synced, 0 diverged.

Command verification — executed, not read

The procedure in qa/SKILL.md was run verbatim:

Path Result
Healthy CI (8 passing checks) all_failing=false → no annotation query fires (AC-4)
Forced branch against the real API 8 checks assembled with their annotations
Incident fixture through the real step-4/5 shell blocked=true, message verbatim incl. the 'Billing & plans' apostrophes
Annotations URL that 404s degrades to [], scan continues
{"message":"Bad credentials"} into step 4 {"blocked":false}, no throw

Field checks: gh pr checks --json name,state,bucket ✅, gh pr view --json headRefOid ✅, gh api .../check-runs with .output.annotations_url ✅ (live).

Three deliberate choices worth reviewing

  1. AC status is PENDING, not NEEDS_VERIFICATION. AC-2's text says "map to NEEDS_VERIFICATION" — but that is a verdict value, and §7 counts only MET/PARTIALLY_MET/PENDING/NOT_MET. An AC stamped NEEDS_VERIFICATION lands in no counter and lets a fully-red board fall through to READY_FOR_MERGE — worse than the bug being fixed. PENDING routes through the existing pending_count > 0 → NEEDS_VERIFICATION branch and produces the intended outcome. Requirement implemented, prescription adjusted; reasoning recorded inline in the skill.
  2. Matching is on the annotation message only. The fixture also carries annotation_level: "failure", but gating on it adds a condition the AC never states, and a warning-level variant would then be silently missed. A test pins that the variant still matches.
  3. No output.annotations_count pre-filter. The field exists in live API output but is absent from the captured fixture, so a zero there could skip detection entirely.

Bugs caught before merge

  1. sed '/marker/,/^### /d' silently ate the next section header. Dogfooded against a real QA comment: it deleted ### Required Fixes and orphaned a genuinely actionable finding (sed ranges are end-inclusive). Replaced with an exclusive-range awk, verified on 20 real /qa comments.
  2. NEEDS_VERIFICATION used as an AC status — see choice 1 above.
  3. The /loop filter was inert — assigned actionable, nothing read it, and it sat after the extraction it was meant to filter. Now rebinds qa_comment in the data path.
  4. The Phase 1 procedure's core step was a comment, not code — annotations were fetched and never consumed; $ci_buckets was read but never defined. Steps 3–5 are now real, executed shell.
  5. detectInfraBlockedCi threw on a non-array annotations — a 404/rate-limit returns an object, and iterating it crashed the QA phase for exactly the broken-CI case this detector exists to handle gracefully. Now guarded; 5 new tests, and removing the guard fails 2 of them.

Also adds Bash(gh api:*) to the qa skill's allowed-tools — the new procedure needs it and it was not previously granted.

Test plan

  • npm run build — passes
  • npm run lint — passes (--max-warnings 0)
  • npm test — 206 files, 4283 passed, 1 expected fail, 2 skipped
  • npm run validate:skills / lint:skill-calls / lint:skill-sync — all pass, 42 synced 0 diverged
  • Mutation-tested: every→some fails 3 tests; loosening the regex to /started/i fails 1; removing the Array.isArray guard fails 2

Risk

  • Likely failure mode: GitHub changes the lockout annotation wording and the signature stops matching — detection degrades silently to today's NOT_MET behavior. Safe direction to fail (nothing gets waved through), but invisible.
  • Not tested: a live positive case on a genuinely locked-out repo. The classification, the shell pipeline, and the fixture path are each verified; only the real-world combination is unexercised.

Closes #820

admarble added 2 commits July 27, 2026 04:56
…_MET

A repo that hits its Actions spending limit fails every check in seconds
because no runner is ever allocated. `gh pr checks` shows plain failures,
so /qa Phase 1's `FAILURE -> NOT_MET` mapping marked CI-dependent ACs unmet
for a condition no code change can fix -- and fed those findings to /loop.

Phase 1 now queries the head commit's check-run annotations, but only when
every check is in the `fail` bucket. On a message matching
/job was not started/i it classifies CI as infra-blocked: CI-dependent ACs
map to NEEDS_VERIFICATION, the report carries the annotation verbatim, and
the finding is marked `<!-- qa:ci-infra-blocked -->` so the loop skill's new
Excluded Finding Classes rule drops it before counting actionable issues.

Detection lives in src/lib/qa/infra-blocked-ci.ts as pure predicates,
mirroring the markdown-only-ci.ts split, unit-tested against the live
incident fixture captured in the issue (perishable -- now committed here).

Notes on two deliberate choices:
- Matching is on the annotation message only. The fixture carries
  annotation_level "failure", but gating on it adds an unstated condition
  that would silently miss a warning-level variant.
- No `output.annotations_count` pre-filter: the field exists in live API
  output but not in the captured fixture, so a zero could skip detection.

The /loop filter uses an exclusive-range awk rather than
`sed '/marker/,/^### /d'`, which was verified against a real QA comment to
also delete the following `### Required Fixes` header and orphan a
genuinely actionable finding.

Also adds `Bash(gh api:*)` to the qa skill's allowed-tools -- the new
procedure needs it and it was not previously granted.

Closes #820
…filter in the data path

Two defects found by the adversarial re-read, both of which would have
shipped inert or actively wrong.

1. `NEEDS_VERIFICATION` is a VERDICT value, not an AC status. Section 7
   counts only MET / PARTIALLY_MET / PENDING / NOT_MET, so an AC stamped
   NEEDS_VERIFICATION lands in no bucket, increments no counter, and lets
   the algorithm fall through to READY_FOR_MERGE on a fully-red board --
   strictly worse than the misclassification this change exists to fix.
   The AC status is now PENDING, which routes through the existing
   `pending_count > 0 -> NEEDS_VERIFICATION` branch and produces the
   outcome AC-2 asks for. All four sites updated consistently, with the
   reasoning recorded inline so it does not get "corrected" back.

   Note on AC-2's wording: it says CI-dependent ACs "map to
   NEEDS_VERIFICATION". That names the verdict; PENDING is how this
   skill's vocabulary produces that verdict. Requirement implemented,
   prescription adjusted.

2. The loop exclusion assigned `actionable` and nothing ever read it --
   and the extraction it was meant to filter (`verdict`, `not_met_acs`,
   `recommendations`) runs EARLIER in the document, so even a careful
   reader would have filtered after the fact. The filter now rebinds
   `qa_comment` itself, so every existing downstream consumer picks it up
   with no other change, `qa_comment_raw` preserves the original for
   verbatim cause reporting, and the Step 1 parsing block carries an
   explicit "run the filter first" precondition.

Filter logic itself is unchanged and re-verified: 20/20 correct exclusion
across real past /qa comments, 40/40 byte-identical pass-through when the
marker is absent.
admarble added 2 commits July 27, 2026 09:44
…on API errors

Adversarial gap analysis over the committed state found five real gaps.

A. The procedure's core step was a comment, not code. Steps 3 and 4 said
   "collect annotations" and "classify" in prose; `annotations_json` was
   fetched and then never consumed. An agent following it literally would
   fetch data and have nothing to do with it -- the same assigned-but-never-
   read defect already fixed on the loop side, sitting in the qa skill.
   Steps 3-5 are now real shell: fetch per-check annotations, assemble one
   array, classify, and destructure the result into the variables the
   classification table and report actually reference.

B. `$ci_buckets` was read but never defined. Now assigned from
   `gh pr checks --json bucket`.

C. `detectInfraBlockedCi` threw a TypeError on a non-array `annotations`.
   Callers feed it raw `gh api` output, and a 404 / rate limit / revoked
   token returns `{"message":"Not Found"}` where an array is expected.
   Crashing the QA phase is the worst possible response for a detector
   whose entire purpose is handling broken CI gracefully. Now guarded with
   Array.isArray at both levels; malformed input degrades to
   {blocked:false}. 5 new tests; removing the guard fails 2 of them.

D. CHANGELOG still described the pre-fix `NEEDS_VERIFICATION`-as-AC-status
   behavior. Updated, including why PENDING is the correct status.

E. Every failure path in the shell now degrades to {"blocked":false} rather
   than aborting: an API error must never be reported as infra-blocked, and
   must never crash the run.

Verified by executing the committed procedure, not by reading it:
- healthy CI (8 pass) -> all_failing=false, no annotation query (AC-4)
- forced branch on real API -> 8 checks assembled with annotations
- incident fixture through the real step-4/5 shell -> blocked=true,
  message verbatim including the 'Billing & plans' apostrophes
- 404 annotations URL -> degrades to []
- {"message":"Bad credentials"} into step 4 -> {"blocked":false}, no throw

Full suite: 206 files, 4283 passed.
…assify-runner-never-started-ci-billin

# Conflicts:
#	CHANGELOG.md
@admarble
admarble merged commit 4c258a6 into main Jul 27, 2026
8 checks passed
@admarble
admarble deleted the feature/820-fix-qa-classify-runner-never-started-ci-billin branch July 27, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(qa): classify runner-never-started CI (billing lockout) as infra-blocked, not NOT_MET — keep it out of /loop

1 participant