Skip to content

ci(claude): move Claude workflows to Opus 5.5; stop audits losing their findings - #4191

Merged
kovtcharov-amd merged 6 commits into
amd:mainfrom
kovtcharov:claude/opus-5-5-workflows
Sep 26, 2026
Merged

kovtcharov-amd merged 6 commits into
amd:mainfrom
kovtcharov:claude/opus-5-5-workflows

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

The nightly code and security audits have filed nothing for weeks, and this is why. Most nights one lens fails, and synthesis — correctly — refuses to file off a partial sweep. Either a lens ran out of turns before writing anything (the features lens spent $3.85 one night and handed over nothing), or the shared Claude subscription hit its weekly limit and every lens failed in its first turn, logged only as is_error:true and then blamed on an install flake. This PR makes nightly lenses keep what they found, makes every early stop name its real cause, raises turn ceilings to 100+, and moves every Claude Code job to Opus 5.5.

  • Nightly lenses write findings as they go, with a complete flag. A lens cut off by its ceiling still gets its confirmed findings filed, and synthesis warns by name about the sweep it didn't finish. The security audit stays all-or-nothing on purpose: a partial file there would upload a SARIF that clears alerts the lens never re-checked.
  • Opus 5.5 needed a CLI bump. It needs Claude Code 2.1.280+, and both pinned claude-code-action SHAs bundled older CLIs (2.1.277 and 2.1.261), so a model-id swap alone would have broken these jobs. The action moves to 9171db3 (2.1.282) — the only non-version-bump commit in between is that repo's own CI — and claude-run.yml's CLI pin moves to 2.1.282.
  • Runs at Opus 5.5's default effort (medium), one level below Opus 5's high. We'll raise it in a follow-up if the test runs show the reviews missing things.
  • One deliberate exception: the eval scenario driver stays on claude-sonnet-4-6. The committed baselines were recorded with it, so switching it would compare a different agent against them on every PR. Moving it means regenerating the baselines too.

Test plan

  • All 526 tests that read workflow files pass; YAML parses for every workflow.
  • New contract tests (test_claude_audit_workflow_contract.py) fail against main and pass here: nightly lenses write early and mark completion, a partial sweep is reported, the security audit does not write incrementally, and both audits explain an early stop.
  • The stop-reason step, run against sample logs, names a turn ceiling, a weekly-limit rejection, and a missing log correctly.
  • gh workflow run claude-auth-canary.yml -f model=claude-opus-5-5 passes on this branch.
  • Manual claude-nightly-audit.yml and claude-security-audit.yml runs on this branch complete, and every lens reports in.

🤖 Generated with Claude Code

…sing their work

The nightly audits have filed no issues because most nights one lens fails and
synthesis, correctly, refuses to file off a partial sweep. Two causes:

- A lens hits its 45-turn ceiling before writing its findings file. The prompt
  asked it to stop "at ~5 turns remaining", which it cannot count; the
  `features` lens spent $3.85 one night and handed over nothing. Nightly lenses
  now write the file first and update it after each confirmed finding, with a
  `complete` flag; synthesis files what they found and warns by name about any
  sweep that did not finish. The security audit keeps all-or-nothing: a partial
  file there would upload a SARIF that clears alerts the lens never re-checked.
- The shared Claude subscription runs out of its weekly quota (Sep 15-16,
  22-23), failing every lens in 1 turn with only `is_error:true` in the log, which
  synthesis then blamed on an install flake. Both audits now name the cause —
  quota, credential or turn ceiling — via util/classify_claude_probe.py.

Turn ceilings rise to at least 100 (audit lenses and the walkthrough executor
to 150); the auth canary stays at its deliberate 1.

Every Claude Code job moves to claude-opus-5-5 at its default effort. Opus 5.5
needs Claude Code 2.1.280+, and both pinned claude-code-action SHAs bundled
older CLIs (2.1.277, 2.1.261), so the action moves to 9171db3 (2.1.282) and
claude-run.yml's CLI pin to 2.1.282 in the same change. The eval scenario
driver stays on claude-sonnet-4-6: the committed baselines were recorded with
it, and changing it would compare a different agent against them on every PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added devops DevOps/infrastructure changes tests Test changes labels Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Request changes

Good diagnosis and the right fix shape: lenses that write findings as they go, an explicit "did this sweep finish?" flag, and a step that names why a run stopped. The incremental-write design is the correct answer to "the features lens spent $3.85 and filed nothing."

The new "say why Claude stopped" step is the problem. It reuses the auth-canary's classifier, which was built to read a one-line probe reply, and hands it the lens's entire transcript instead. The classifier looks for words like unauthorized, rate limit, billing and for bare 401 / 403 / 429 anywhere in that text — so a security lens whose actual job is to write about authentication and HTTP status codes will get diagnosed as a dead credential and tell whoever is on call to rotate the secrets. I ran it against a realistic lens transcript and it did exactly that. That is the same wrong-owner failure this tooling exists to end, only now stated with more confidence.

Two more worth fixing before merge:

  • A truncated findings file takes the whole audit down. The new completeness check reads each lens's JSON with no guard, inside a step that aborts on any error — so one unparseable file (a lens killed mid-write by a job timeout) fails the gate with a raw traceback and nothing gets filed. That is precisely the all-or-nothing outcome this PR is removing.
  • The pinned action's version comments are now wrong. Every updated pin still claims v1.0.230, and one file labels the same commit v1.0.216. The real version is v1.0.234. The comment is the only human-readable record of what is pinned, so it should not disagree with itself.

One judgment call worth stating out loud, not a blocker: the stated root cause includes exhausting the shared weekly subscription limit, and this PR responds by raising turn ceilings more than threefold across five nightly lenses and moving the per-push re-review from Sonnet to Opus. That is the highest-frequency Claude job in the repo. If the quota is the binding constraint, this may make the symptom more common before the incremental writes make it survivable.

Real-world evidence

N/A — CI/workflow-only change, no runnable GAIA surface; no evidence bundle was produced for this PR, so the verdict rests on static review plus local reproduction of the classifier and shell behaviour (both shown in the technical details below).

The evidence that actually matters here is the PR's own last two test-plan items — the canary dispatch at claude-opus-5-5 and a manual run of both audits on this branch — and both are still unchecked. The model-id swap and the action bump can only be proven by those runs; please land them before merge.

🔍 Technical details

🟡 Important

1. classify_claude_probe.py is fed a whole audit transcript, and misclassifies it (.github/workflows/claude-nightly-audit.yml:498, .github/workflows/claude-security-audit.yml:352)

extract_reply(..., "stream-json") concatenates every assistant text block plus the result text (util/classify_claude_probe.py:247-267), and _hits() does a plain case-insensitive substring match over that whole blob (:101-105), including bare 401/402/403/429 with only digit boundaries. The module's own docstring scopes it to "a Claude CLI probe response" — a one-turn canary reply — not a 150-turn lens transcript.

Reproduced locally against a synthetic-but-realistic security-lens transcript:

$ python3 util/classify_claude_probe.py --exit-code 1 --format stream-json --text-file /tmp/x.jsonl
::error::CREDENTIAL INVALID (401-class): the Claude credential is absent, expired, or
malformed... | WHAT TO DO: Run `claude setup-token` locally and update the repository
secret... Do NOT ask for a spend-limit increase - the budget is not the problem.
| MATCHED: 401, 403, unauthorized
exit=3

The transcript contained nothing but ordinary audit prose (returns 403 when the token is missing, and 401 for an expired one). The error_max_turns early-exit above shields the ceiling case, and a first-turn quota rejection still classifies correctly because the transcript is tiny — but every other mid-run failure on the security lens is a near-certain false CREDENTIAL verdict.

Suggested fix: classify only the terminal result entry's error payload, not the assistant transcript. Either add a --result-only mode to the classifier, or extract the result line in the step and pass it via --format text:

          python3 -c 'import json,sys
          last=""
          for l in open(sys.argv[1],encoding="utf-8",errors="replace"):
              l=l.strip()
              if not l.startswith("{"): continue
              try: e=json.loads(l)
              except ValueError: continue
              if e.get("type")=="result": last=str(e.get("result") or e.get("subtype") or "")
          open(sys.argv[2],"w",encoding="utf-8").write(last)' "$EXECUTION_FILE" "$RUNNER_TEMP/claude-result.txt"
          python3 util/classify_claude_probe.py --exit-code 1 --format text --text-file "$RUNNER_TEMP/claude-result.txt"

Apply the same change in both workflows.

2. The completeness check aborts the gate on an unparseable findings file (.github/workflows/claude-nightly-audit.yml:548)

The step runs under set -euo pipefail, and incomplete=$(python3 - <<'EOF' ...) inherits the substitution's exit status, so an uncaught JSONDecodeError kills the step before any warning is emitted. Verified:

$ printf '{"findings": [], "compl' > audit-findings/a/findings-features.json
$ bash -c 'set -euo pipefail; incomplete=$(python3 - <<EOF ... EOF); echo reached'
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 18
exit=1        # "reached" never printed

--max-turns stops between turns, so a Write completes — but a timeout-minutes kill or a cancelled runner can truncate mid-write, and incremental rewriting widens that window considerably. Worth noting that scripts/audit/prepare_synthesis.py:120-121 also hard-SystemExits on an unreadable file, so catching it here improves the error but does not by itself rescue the run; the durable fix is for both layers to quarantine a bad file rather than sink the batch.

          incomplete=$(python3 - <<'EOF'
          import json, pathlib
          for f in sorted(pathlib.Path("audit-findings").rglob("findings-*.json")):
              try:
                  done = json.loads(f.read_text(encoding="utf-8")).get("complete") is True
              except ValueError:
                  done = False
              if not done:
                  print(f.stem.removeprefix("findings-"))
          EOF
          )

3. Every updated action pin carries a stale version comment (11 sites)

9171db3e57d6a3140a37ddc2ba92788584e0ead6 is tagged v1.0.234 (gh api repos/anthropics/claude-code-action/tags), commit message chore: bump Claude Code to 2.1.282. The pins still read # v1.0.230, and .github/workflows/nightly-patch-release.yml:333 labels that same SHA # v1.0.216 — two different claims about one commit.

One example; apply the same to claude-auth-canary.yml:53, claude-nightly-audit.yml:266,612, claude-run.yml:333,356, claude-security-audit.yml:196, claude-weekly-doc-walkthrough.yml:399,538,834, claude.yml:1068,1543, lemonade-version-bump.yml:140, skill_audit.yml:480:

        uses: anthropics/claude-code-action@9171db3e57d6a3140a37ddc2ba92788584e0ead6  # v1.0.234

🟢 Minor

4. claude.yml still documents the re-review as a Sonnet pass — lines 6, 104-105, and 441-442. The last one reads "a Sonnet pass ... instead of re-running the full Opus review", a distinction the diff just erased. Both jobs now run claude-opus-5-5 at --max-turns 100, so the only remaining difference is the prompt.

5. Two more places still name Opus 5 as the audit model — claude-nightly-audit.yml:147 ("Opus 5 by default — half the token burn of Fable") and .claude/skills/weekly-audit-patterns/SKILL.md:207 (documents AUDIT_MODEL as claude-opus-5). CLAUDE.md asks that a behaviour change update every doc describing it; the skill file is the one a future contributor reads first.

6. The security audit's stop message asserts an outcome it cannot know (claude-security-audit.yml:349). It says the lens hit the ceiling "before writing its findings, so this run uploads no SARIF" — but that prompt still instructs the lens to stop and write at ~5 turns remaining (:313-315), so the file often will exist and SARIF will be built. Wording it as "may not have written its findings" keeps it honest.

Strengths

  • The complete flag is the right primitive. Separating "the lens found nothing" from "the lens never finished" is what lets synthesis file partial work without silently calling an unfinished sweep a clean bill of health, and the named warning per incomplete lens makes the gap visible in the run summary rather than buried.
  • The security audit is deliberately exempted from incremental writes, with the reason stated — a partial SARIF clearing alerts the lens never re-checked is a genuinely different risk from a partial issue list, and the contract test (test_the_security_audit_does_not_write_findings_incrementally) pins that asymmetry so a future cleanup pass cannot "fix" the inconsistency.
  • The tests fail against main. test_claude_audit_workflow_contract.py:591-630 asserts the behaviour rather than the YAML shape, and the docstrings carry the incident that motivated each one.
  • The CLI-version dependency was caught and handled. Noticing that Opus 5.5 needs Claude Code 2.1.280+ and that both pinned action SHAs bundled older builds — before a model-id swap silently broke every job — is exactly the check that is usually skipped.

Kalin Ovtcharov and others added 2 commits September 24, 2026 20:53
main renamed test_eval_agent_gemma_consolidation.yml to eval_flagship.yml
(amd#4096); this branch's task-judge bump follows it under the new name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dings file

Review follow-ups on amd#4191.

- The stop-reason step fed a lens's whole transcript to classify_claude_probe,
  which matches words like "unauthorized" and bare 401/403. A security lens
  writes about exactly those, so a mid-run failure would have been reported as
  a dead credential and sent someone to rotate secrets. Only the terminal
  result entry is classified now.
- A findings file truncated mid-write (job timeout, cancelled runner) crashed
  the completeness check and aborted synthesis, losing every other lens's work.
  Both layers now treat it as one unfinished lens: the check reports it by name,
  and prepare_synthesis quarantines it as a reject. A run where every file is
  unreadable still aborts rather than reading as a clean audit. This reverses
  the earlier "an unreadable file aborts the run" test deliberately — dropping
  it is no longer silent, and incremental writes widen the window.
- Pin comments now name the real tag, v1.0.234, instead of v1.0.230 / v1.0.216.
- Removed stale wording: the re-review is no longer a Sonnet pass, the audit
  model is Opus 5.5 in the workflow, the weekly-audit skill and both plan docs,
  and the security stop message no longer claims an outcome it cannot know.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the documentation Documentation changes label Sep 25, 2026
Both review fixes shipped as inline Python inside a `run:` block, which no
test could reach, so nothing stopped either regression from coming back.

Extract the snippet each step actually runs and execute it:

- A transcript full of ordinary auth prose ("returns 403 ... 401 for an
  expired one ... unauthorized") plus a generic crash must not be diagnosed
  as a dead credential, while a real 401 in the terminal result still must be.
  The second test is what stops the first being satisfied by classifying
  nothing at all.
- A findings file truncated mid-write must be named as an unfinished lens and
  leave the gate at exit 0, not abort it and unfile every other lens's work.

All five fail against the pre-fix workflows.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Both blockers were already fixed in 4b84f864a; what was missing was anything stopping them coming back. I reproduced each against the pre-fix branch, confirmed the fix, and added the tests.

The classifier fix is real: fed a transcript containing ordinary audit prose about 403s and expired tokens, the old path reported CREDENTIAL INVALID and told the reader to rotate secrets. The new path reports "matches neither", while a genuine 401 and a genuine weekly-limit rejection still classify correctly — so it did not fix the false positive by simply classifying nothing.

Both fixes shipped as inline Python inside a run: block, which no test could reach. The five new tests extract the snippet each step actually runs and execute it, and all five fail against the pre-fix workflows.

🔍 Technical details

Reproduction (pre-fix, whole transcript via --format stream-json)

Transcript: one assistant block reading returns 403 when the token is missing, and 401 for an expired one. An unauthorized caller should never reach the billing path, plus a terminal result of Error: process exited unexpectedly.

::error::... matches BOTH the quota and the credential signature ...
| MATCHED: 401, 403, 429, billing, rate limit, unauthorized
exit=4

Post-fix, same transcript, result-only extraction + --format text:

::error::The Claude probe was rejected (exit code 1) and the response matches
neither the quota nor the credential signature. Response: Error: process exited
unexpectedly
exit=4

Regression check through the new path: a usage limit reached result still exits 2 (QUOTA), an API Error: 401 ... authentication_error result still exits 3 (CREDENTIAL).

Tests added (tests/unit/test_claude_audit_workflow_contract.py)

  • test_a_lens_writing_about_auth_is_not_diagnosed_as_a_dead_credential — parametrized over both workflows
  • test_a_real_credential_rejection_is_still_named — the guard that stops the above passing vacuously
  • test_a_findings_file_truncated_mid_write_does_not_sink_the_audit — runs the completeness gate's heredoc against a truncated findings-features.json beside a complete findings-security.json; asserts exit 0 and ["features"] on stdout

Both snippets are pulled out of the parsed YAML rather than duplicated, so a rewrite of either step fails the extraction assertion instead of silently testing a stale copy.

Results

tests/unit/test_claude_audit_workflow_contract.py  39 passed
+ test_audit_synthesis_prep / test_classify_claude_probe
+ test_skill_audit_workflow_contract              163 passed

Pre-fix (workflows reverted to 951eebb41): 5 failed, 34 deselected.

Merged current main (61 commits) — clean, no conflicts; AST-parsed all 170 merged .py files and swept the repo for stray conflict markers, both clean. Untouched: the two unchecked test-plan items (the canary dispatch and the manual audit runs) still need a real run before merge, and the quota-pressure judgement call in the review is unaddressed by design.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 26, 2026
Merged via the queue into amd:main with commit bab7d32 Sep 26, 2026
33 of 34 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the claude/opus-5-5-workflows branch September 26, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants