Skip to content

fix: fetch AIC logs per workflow so audit/optimizer survive high-CI-volume repos#124

Open
mrfelton wants to merge 2 commits into
githubnext:mainfrom
LN-Zap:fix/logs-per-workflow
Open

fix: fetch AIC logs per workflow so audit/optimizer survive high-CI-volume repos#124
mrfelton wants to merge 2 commits into
githubnext:mainfrom
LN-Zap:fix/logs-per-workflow

Conversation

@mrfelton

Copy link
Copy Markdown

Problem

In busy repos, both the audit and the optimizer download data with an unfiltered gh aw logs --json call, which stops paginating after roughly one repo-wide batch of CI history — full write-up in #123, root cause in the CLI filed as github/gh-aw#38782 (skipped/cancelled runs are dropped, then the empty filtered batch is mistaken for end-of-history).

Net effect we hit in production:

  • Audit: daily issues reporting "0 completed runs / 0.00 AIC" — the raw window contained only the audit's own in-progress run; rolling-summary.json never accumulates, so the trend chart can never render.
  • Optimizer: candidate pool silently truncated to the last couple of hours.

Fix

Enumerate agentic workflows from .github/workflows/*.lock.yml and call gh aw logs <id> per workflow — workflow-scoped listing uses the per-workflow runs API and is unaffected by repo-wide CI volume — then merge results (deduped by run_id) into the same {summary, runs} shape the agent prompts already expect. Tolerates per-workflow failures (partial results still merge).

Applied to both workflows, in both the workflows/ templates and the .github/workflows/ active copies (kept identical).

Validation

Notes

Fixes #123

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

mrfelton and others added 2 commits June 11, 2026 19:15
The Phase 1 self-targeting guard ("Exclude workflows with \"Token\" in the
name") can never fire: gh aw logs reports `workflow_name` as the display
name (the H1), which for these two workflows is "Agentic Workflow AIC
Usage Optimizer" / "Daily Agentic Workflow AIC Usage Audit" — neither
contains "Token". The string only appears in the workflow id / tracker-id.
So the monitoring family is never excluded, and the optimizer selects
itself (or its sibling audit) as the target.

This fixes it two ways:
- Deterministic pre-filter in the "Download" step: drop runs whose
  workflow_path matches `agentic-token-(optimizer|audit)` or whose
  display name matches `AIC Usage (Optimizer|Audit)`, so neither
  all-runs.json nor top-workflows.json can list the family.
- Correct the Phase 1 prompt guard to key off the actual ids/display
  names instead of the substring "Token".

Source `.md` only — the generated `.lock.yml` files are intentionally
left for in-repo regeneration via `gh aw compile` (lock cron jitter and
action-pin resolution are repo-scoped, so fork-built locks would not
match this repo's CI output).

Fixes githubnext#119

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The audit reported empty days ("0 completed runs") and the optimizer's
candidate pool silently truncated in busy repos: unfiltered
`gh aw logs` scans repo-wide run batches and stops paginating when a
batch filters down to zero processable agentic runs (skipped/cancelled
dropped first) — github/gh-aw#38782. 250 repo-wide runs span ~2h of CI
in a large monorepo, so the call rarely saw past the most recent runs.

Enumerate agentic workflows from .github/workflows/*.lock.yml and call
`gh aw logs <id>` per workflow (workflow-scoped listing is unaffected
by repo CI volume), then merge results deduped by run_id into the same
{summary, runs} shape the agent prompts already expect.

Validated in a production monorepo over a window that produced an
empty audit: unfiltered call returned 1 run (the audit itself);
per-workflow loop returned 15 runs including 5016/3674/2548-AIC runs.

Fixes githubnext#123

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Audit reports empty days / optimizer pool truncated in busy repos: unfiltered gh aw logs stops paginating after ~one batch of CI history

1 participant