fix: prioritize current failures in workflow health checks by pelikhan · Pull Request #70552 · github/gh-aw · GitHub
Skip to content

fix: prioritize current failures in workflow health checks - #70552

Merged
pelikhan merged 9 commits into
mainfrom
pelikhan-sturdy-parakeet
Oct 20, 2026
Merged

pelikhan merged 9 commits into
mainfrom
pelikhan-sturdy-parakeet

Conversation

@pelikhan

@pelikhan pelikhan commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Health checks were spending their API budget on successful workflows, repeatedly reading unchanged files, and investigating failures superseded by pushed workflow changes. This makes gh aw health a budgeted early-warning scan: discover potential issues cheaply, verify representative evidence, and reuse source objects.

  • Inventory registered AW failure conclusions from run-list payloads before job or revision lookups. Preserve approximate per-workflow signals in collection.potential_issues, explicitly separated from confirmed current-revision clusters. Verify one job-backed representative per branch/event, then fill chronological samples, prioritizing recently failing workflows and deduplicating runs. Named checks query only their selected workflow.
  • Prefer committed local Git objects when the checkout origin matches the target repository and host. Resolve the pushed branch head once; never infer pushed changes from dirty files, local-only tips, or stale tracking refs. Missing objects fall back to GitHub without fetching or deepening the checkout. Fleet API fallback shares workflow-directory snapshots per ref and lock metadata per blob SHA.
  • Compare workflow Markdown blob SHAs with the pushed source even when lock files are unchanged. Stop superseded history and exclude it from current investigation targets. Updated sources without matching runs await evidence rather than being declared fixed.
  • Expose candidate counts, representative verification status, listing/verification completion, source SHAs, and local-read counts. List-only signals can include jobless, historical, or superseded failures and are not fleet failure rates. Actions run discovery remains REST-based; the GraphQL repository schema does not expose a workflow-run connection.

Validation

  • make build
  • make fmt
  • go test ./pkg/cli -run '^TestHealth' -count=1
  • make agent-report-progress passed for the combined review batch, including formatting, scoped lint, impacted tests, and workflow drift checks, using session-isolated TMPDIR and GOLANGCI_LINT_CACHE and modern Bash on PATH.

Regression coverage includes pushed sources with unchanged locks, other branches, budget exhaustion before verification, list-only signal retention, scoped queries, pagination, deduplication, chronological metrics, local/remote repository identity, dirty-file exclusion, missing-object fallback, and snapshot/blob reuse.

Request-count fixtures verify that 150 failures across 50 workflows are inventoried with two listing requests and no enrichment, and that two workflows across two commits share three directory snapshots and one lock-blob request.

Observed behavior

Live checks use the same run-creation window, October 19-20, 2026, 13:42:01 UTC. Before the latest reuse optimization, failure-first collection surfaced 97 failed runs instead of 60 and 46 clusters instead of 36 at the same 1,000-request budget, but overall coverage remained partial.

With local-first reuse, a targeted Daily A/B Testing Advisor check completed in about 4.5 seconds with 9 counted API requests, 4 local revision reads, and zero remote file/revision lookups. A full-fleet comparison was interrupted by a GitHub Jobs API HTTP 502, so no new fleet-wide performance claim is made. Network timings are observational, not controlled benchmarks.

ADR: ADR-70552: Failure-First, Source-Aware Workflow Health Collection

Review follow-up

Merged the latest main and verified bounded failure inventory, named-workflow scoping, branch-sensitive cache checks, chronological coverage of failure-discovered scopes, and sample precedence. Corrected the remaining unknown-source edge case so unavailable immutable sources retain current unknown failure evidence instead of borrowing branch identity. Added direct status-precedence, stale-boundary, and distinct-source recovery regressions.

The ADR is reviewed and remains Proposed pending maintainer acceptance. The prior review setup failure was an external sum.golang.org HTTP/2 transport error, not a demonstrated setup configuration defect; no CI was triggered.

pelikhan and others added 2 commits October 20, 2026 08:28
Compare workflow source blob SHAs with the pushed branch even when lock metadata is unchanged. Stop superseded branch/event history, exclude stale failures, and retain current failures in other scopes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Collect explicit agentic workflow failures before successful-run evidence, preserve bounded failure samples at API limits, and prioritize recently failing workflows for chronological follow-up. Expose failure-pass completion and retain source-revision filtering.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review October 20, 2026 16:31
Copilot AI max review requested due to automatic review settings October 20, 2026 16:31
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · haiku45 · 5.13 AIC · ⌖ 10 AIC · ◇ 2.49 AIC · ⊞ 9.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Commit pushed: 05b3508

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR adds 767 new lines under pkg/, which is over the 100-line threshold for business logic. It does not link to an Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/70552-failure-first-source-aware-health-collection.md. Please review and complete it before merging.

Inferred decision: gh aw health collects explicit failures in a repository-wide pass before it samples successful runs. It also compares the Markdown source blob SHA at each run with the pushed branch source. When they differ, it stops collecting older history and excludes the superseded failures.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch. It was generated from the PR diff and description.
  2. Complete the missing sections: confirm the deciders, refine the rationale, and check that the alternatives are ones you actually considered (budget increase, lock-hash-only revision detection, stopping on any repository commit).
  3. Commit the finalized ADR to docs/adr/ on your branch.
  4. Reference the ADR in this PR body, for example:

    ADR: ADR-70552: Failure-First, Source-Aware Workflow Health Collection

Once the ADR is linked in the PR body, this gate will re-run and check that the implementation matches the decision.

❓ Why ADRs Matter

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors, including your future self, can see the reasoning behind it.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context: What is the problem, and what forces are at play?
  • Decision: What did you decide, and why?
  • Alternatives Considered: What else could have been done?
  • Consequences: What are the trade-offs, positive and negative?

ADRs are stored in docs/adr/ as Markdown files numbered by PR number.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · opus55 · 30.2 AIC · ⌖ 40.4 AIC · ⊞ 1.9K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Found one medium-severity API-budget risk: the repository-wide failure-first scan can exhaust collection time on unrelated failures before registered AW workflows are sampled. An inline comment explains the impact and a bounded/early-terminating scan is needed. Static review only; tests were not run.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · 3.65 AIC · ⌖ 0.544 AIC · ⊞ 1.6K
Comment /review to run again

Comment thread pkg/cli/health_failures_first.go Outdated

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

One or more custom setup steps configured for this repository failed during this Copilot code review run:

Install development dependencies

Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review.

Note

You can configure setup steps for Copilot code review separately from Copilot cloud agent with a copilot-code-review.yml file. Read the docs for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Revision handling and cross-scope sampling can misclassify health evidence and investigation targets.

5 open issues
What changed in this PR

Updates gh aw health to prioritize actionable failures within its API budget and compare runs against pushed workflow sources.

Changes:

  • Collect failures before chronological evidence, with prioritization and deduplication.
  • Track source revisions and exclude superseded failures.
  • Document collection limits and expand regression coverage.
File Description
pkg/​cli/​health_time_window_test.go Adapts time-window tests to failure-first collection.
pkg/​cli/​health_source_revisions_test.go Tests source changes and lookup failures.
pkg/​cli/​health_sampling.go Integrates failure-first sampling and source boundaries.
pkg/​cli/​health_sampling_test.go Updates sampling fixtures and request expectations.
pkg/​cli/​health_revisions.go Adds source-aware revision cohorts and reporting.
pkg/​cli/​health_revision_metadata.go Resolves and compares source blob SHAs.
pkg/​cli/​health_pagination_test.go Updates pagination fixtures and request counts.
pkg/​cli/​health_no_jobs_test.go Adapts job-presence tests.
pkg/​cli/​health_failures_first.go Implements failure collection, prioritization, and deduplication.
pkg/​cli/​health_failures_first_test.go Tests ordering, limits, pagination, and merging.
pkg/​cli/​health_command.go Updates help and awaiting-evidence messaging.
pkg/​cli/​health_collection.go Tracks source revisions and failure-pass completion.
docs/​src/​content/​docs/​setup/​cli.md Documents collection and revision semantics.
.github/​aw/​analyzing-runs.md Updates health-report interpretation guidance.

Review effort: Max

Comment thread pkg/cli/health_failures_first.go Outdated
Comment thread pkg/cli/health_revision_metadata.go
Comment thread pkg/cli/health_revisions.go
Comment thread pkg/cli/health_revisions.go
Comment thread pkg/cli/health_sampling.go Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /codebase-design (pr-triage recommended /diagnosing-bugs + /tdd). Overall this is a well-tested bug fix — commenting with a few targeted suggestions rather than blocking.

📋 Key Themes & Highlights

Key Themes

  • Precedence fix undertested in isolation: calculateCurrentWorkflowHealth's failures_observed priority rule (health_revisions.go:199) is the actual bug fix in this PR, but is only exercised indirectly through a broader source-boundary scenario test. A dedicated table test over cohort-order permutations would lock in the fix.
  • Scope-capping ordering subtlety: in collectHealthFailures, the run that proves a source change happened is appended to runs before the scope is capped — worth double-checking that stale evidence isn't counted toward failures_observed.
  • Parameter/iteration-order mismatch: mergeHealthRunSamples(failures, runs) iterates runs before failures internally, inverting the apparent precedence from the signature — a readability/maintainability risk.
  • Doubled API cost per revision lookup is well documented in the PR description and covered by an updated test, but not called out in code comments at the call site.

Positive Highlights

  • ✅ Strong new test coverage: health_failures_first_test.go and health_source_revisions_test.go cover pagination, budget exhaustion, dedup, and scope isolation scenarios thoroughly.
  • ✅ Documentation (analyzing-runs.md, cli.md) was updated consistently with the behavior change.
  • ✅ The source-SHA comparison mechanism (healthSourceChanged/healthContentRevisionKey) is a clean, well-isolated addition that composes naturally with the existing revision-cohort model.

Note: investigation was bounded per the review budget; the four inline comments above represent the highest-impact findings from tracing the new control flow in health_failures_first.go, health_revisions.go, and health_revision_metadata.go against their test suites.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 241.4 AIC · ⌖ 15.3 AIC · ⊞ 10.1K
Comment /matt to run again

Comment thread pkg/cli/health_revisions.go Outdated
Comment thread pkg/cli/health_failures_first.go Outdated
Comment thread pkg/cli/health_failures_first.go Outdated
Comment thread pkg/cli/health_revision_metadata.go
Inventory list-only failure signals before verifying one representative per scope. Preserve approximate candidates separately from confirmed current-revision evidence, scope named queries, and reuse committed local workflow trees and blobs with batched API fallback.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/cli/health_failures_first.go:77): This repository-wide failure scan can consume the entire health API budget before it reaches any registered AW run, because it paginates indefinitely through ordinary failures without a bound or an early exit once each registered workflow scope has five candidates. - fix: prioritize current failures in workflow health checks #70552 (comment)
  3. Review (pkg/cli/health_failures_first.go:79): For gh aw health <workflow>, discovery narrows collection.workflows to one workflow, but this endpoint still pages through every repository failure, including unrelated CI runs. Those pages consume the shared request budget before chronological sampling begins. A busy repository and a long time window can therefore leave the requested workflow's evidence uncollected despite having few runs itself. When the registry contains one target, use its workflow-specific runs endpoint with the same failure and creation-time filters. Update the endpoint stubs to cover this path. - fix: prioritize current failures in workflow health checks #70552 (comment)
  4. Review (pkg/cli/health_revision_metadata.go:34): healthRevisionLookupKey omits HeadBranch, but these source checks depend on the branch and run after the cache-hit return. If main and feature have runs at the same SHA/event, resolving unchanged main first skips checking an updated source on feature, leaving its superseded failure in current clusters and investigation targets. Resolving feature first instead caches nil metadata that is reused for unchanged main. Include the branch in this cache key, or separate branch-specific checks from immutable metadata caching. Cover both processing orders in a regression test. - fix: prioritize current failures in workflow health checks #70552 (comment)
  5. Review (pkg/cli/health_revisions.go:44): If only the run-SHA Markdown lookup fails while the branch source and lock metadata reads succeed, this returns an unknown run key against a known current key. The failure goes into Previous, producing no_current_revision_runs; sampling can stop, and the failure disappears from current clusters and investigation targets without a proven revision change. Preserve unresolved failures as unknown current evidence, and do not treat an unavailable lookup as a revision boundary. Add a regression where only the immutable-source lookup fails; the existing test fails both source lookups and misses this case. - fix: prioritize current failures in workflow health checks #70552 (comment)
  6. Review (pkg/cli/health_revisions.go:48): A normal Markdown fix loses recovery_observed: resolveHealthRevision skips lock metadata for superseded sources, so the predecessor falls through to an unknown: key. classifyHealthRevision then rejects recovery even after five successful first-attempt runs that started after the predecessor finished, reporting healthy instead. The existing recovery test masks this by returning the same source SHA for both prompt revisions. Give a confirmed superseded source a known source-based key, and test recovery with different old and current source SHAs. - fix: prioritize current failures in workflow health checks #70552 (comment)
  7. Review (pkg/cli/health_sampling.go:193): The chronological sampler does not know which branch/event scopes the failure pass found. If its first page contains enough recent scheduled runs, it stops even when an older workflow_dispatch scope has five successes after a failure. Merging then adds only that dispatch failure, incorrectly lowering the success rate and making it an investigation target, even with collection.partial == false. Use the failure pass to identify scopes that still need chronological coverage, or fetch those scopes directly. Do not count failure-only samples as chronological coverage. Add a two-scope regression with successful dispatch runs between the newest page and the older failure. - fix: prioritize current failures in workflow health checks #70552 (comment)
  8. Review (pkg/cli/health_revisions.go:199): [/diagnosing-bugs] This is the core fix (prioritize failures_observed across multiple revision cohorts), but the precedence logic is encoded as an inline boolean condition mixed with three unrelated statuses, and there is no unit test that isolates just this precedence rule. - fix: prioritize current failures in workflow health checks #70552 (comment)
  9. Review (pkg/cli/health_failures_first.go:48): [/diagnosing-bugs] scopes[scope] = healthMinimumRuns after a source change silently caps future failures in this scope at the current count, but this happens after runs = append(runs, run) for the run that triggered the change — so the run that proved the source changed is itself retained as evidence even though its lock-file content may already be superseded. - fix: prioritize current failures in workflow health checks #70552 (comment)
  10. Review (pkg/cli/health_failures_first.go:182): [/codebase-design] mergeHealthRunSamples(failures, runs) iterates [][]WorkflowRun{runs, failures} — i.e. the parameter named first (failures) is actually merged second, so on a DatabaseID collision the chronological runs sample wins over the failure-pass sample. The parameter order and iteration order being inverted relative to each other is confusing and easy to get wrong in a future edit. - fix: prioritize current failures in workflow health checks #70552 (comment)
  11. Review (pkg/cli/health_revision_metadata.go:27): [/diagnosing-bugs] resolveHealthRevision now issues an extra resolveHealthSourceRevision/resolveHealthHeadRevision API call per run, confirmed by the test change (TestHealthAPIQuotaAndRevisionLookupReuse 1→2 calls), which roughly doubles the API budget consumed per revision lookup. The PR body already documents the fleet-coverage trade-off (182 vs 147 uncollected workflows), but that trade-off isn't mentioned anywhere near this code — a future maintainer tuning healthMaximumAPIRequests or RevisionLookups would have no signal that this function's cost just doubled. - fix: prioritize current failures in workflow health checks #70552 (comment)

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 5585873
Sous-chef work: 13627f907fe1c4a0f178523f7919743b7f8651e29beecb01a2e1aa6111113430 195f75b2a5fc712568fdeefb87cb52161a19da87ebfc442c6347a14dab0e39d7 4a370f2a771d151b01f973febb1e20111c24dbdd1c0fd61cb488f1951784901c 4a9d969c500a1b350d6f9a4c0f93c54a72b41e8c6b49739dd8da0f6e7db3aced 7dea98f1d43c96991e99e57bf60196544997521b8bf72a05965392bd3730fb1e 90107df8333b9a7b06814b1d199b5bbcc91b549639b2e61c1dac66d233be6ae5 ab758b4e7d1fb173cf365fe2f70e4cd6951d5061e1e19a510fbef8adf20aee53 abeb908d48f960f8d76a7656536fd12ca20a9e86696463e7f8e279dcbd63d958 ce50e419da3a1c9d0d12aa8722b654e30b93ca184c111e8a73ec2b3e9666f748 ef3739430c780f970b41ac4542cd6aaadeb98d0054e0c4f5534c1a7f05ffd209
Sous-chef state: 22e0de03fc8d09daa39ae06479a8f42a82b13b95ec6ff0068771c2af2864d37d

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · 8.33 AIC · ⌖ 11.7 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

Keep unresolved source lookups in current unknown evidence instead of borrowing branch source identity. Pin recovery, stale-boundary exclusion, and status precedence with direct regressions, and review the health collection ADR.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator Author

Acknowledged the Ponytail no-action notification. This comment contains no actionable change request; the concrete review findings are being handled separately.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Acknowledged the Test Quality Sentinel no-action notification. No change is required by this notification; focused health regression coverage was validated independently.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Acknowledged the skills-review completion notification. It contains no actionable feedback requiring another code change.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Accepted the ADR follow-up: the generated draft has been reviewed and updated to match budgeted failure discovery, representative verification, and local Git reuse. The ADR remains Proposed pending maintainer acceptance.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Acknowledged the code-quality review completion notification. It contains no actionable findings; specific inline comments have been evaluated separately.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Accepted the ADR gate feedback: reviewed and completed the rationale, alternatives, consequences, and decision status without inventing approvals. The updated ADR is linked in the PR body and remains Proposed for maintainer acceptance.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Investigated the review setup failure: run 39458171343 failed while installing gopls because sum.golang.org returned an HTTP/2 INTERNAL_ERROR during dependency verification. This is an external transport failure rather than a demonstrated setup defect in this PR, so I declined a speculative configuration change and did not rerun CI.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

@pelikhan
pelikhan merged commit f9cab05 into main Oct 20, 2026
118 checks passed
@pelikhan
pelikhan deleted the pelikhan-sturdy-parakeet branch October 20, 2026 18:32
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.

4 participants