Repository navigation
fix(health): ignore evidence-confirmed PR lifecycle interruptions - #70915
Conversation
Correlate PR merge, closure, and head-deletion events with cancelled runs. Require explicit closed-PR checkout diagnostics for failure-conclusion interruptions, preserve genuine failures, and bound/cache lifecycle evidence requests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use promoted fields in JobInfoWithDuration literals to satisfy modernize/embedlit without changing the test fixtures. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: 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.
|
|
✅ Ponytail Reviewer completed successfully!
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Commit pushed:
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
There was a problem hiding this comment.
L967: delete: duplicate statement that filtered runs do not consume the minimum sample. Nothing replaces it; L965 already says this.
net: -1 lines possible.
Generated by ✂️ Ponytail Reviewer for #70915 · codex · gpt56 · 11.1 AIC · ⌖ 5.39 AIC · ⊞ 14.8K
Comment /ponytail to run again
|
|
||
| Ignored runs do not count as successes or consume the minimum sample. They are excluded from rates, durations, token averages, revision/recovery evidence, failure candidates, clusters, and investigation targets. JSON `collection.pr_lifecycle_evidence` and text `[health_pr_lifecycle]` entries report `ignored`, `retained`, or `unknown` classifications and reasons. Missing, ambiguous, incomplete, or unavailable evidence leaves a run unfiltered by this check. Lifecycle API responses (including errors and targeted checkout-job logs) are cached within the collection, use the configured repository and host, and share its API budget. `collection.lifecycle_requests` is capped at 40 additional requests; branch-event listings are limited to two pages. Health downloads no artifacts. | ||
|
|
||
| Filtered runs do not consume the minimum sample. Health searches backward for five completed first-attempt runs per current-revision scope, stopping at the requested time boundary or API budget rather than a fixed page count. It narrows the search window to continue beyond GitHub's 1,000-run search limit, overlapping boundary timestamps and deduplicating runs. If timestamp ties prevent further progress, the report explicitly marks collection as partial. |
There was a problem hiding this comment.
L967: delete: duplicate statement that filtered runs do not consume the minimum sample. Nothing replaces it; L965 already says this.
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Request changes
The lifecycle filter can ignore failed PR runs without proving the required downstream Handle agent failure conclusion job exists. That permits incomplete job evidence to suppress genuine failures from health metrics and investigation. Require a valid post-checkout aftermath before classifying the run as ignored.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · 2.33 AIC · ⌖ 0.679 AIC · ⊞ 1.6K
Comment /review to run again
| evidence.Status, evidence.Reason = "unknown", "missing_failed_checkout_job" | ||
| return evidence | ||
| } | ||
| if !healthValidClosureAftermath(aftermath, checkoutCompleted) { |
There was a problem hiding this comment.
This accepts a failed PR run as lifecycle-ignored even when no subsequent conclusion job with the Handle agent failure step exists, so a truncated or otherwise incomplete job inventory can erase a real failure from metrics and investigation.
💡 Require the documented aftermath
aftermath is allowed to remain empty, and healthValidClosureAftermath([]JobInfoWithDuration{}, ...) returns true. Require at least one valid conclusion aftermath job (and validate it occurs after checkout) before setting ignored; otherwise retain or mark the evidence unknown.
🏗️ Design Decision Gate — ADR RequiredThis PR changes core business logic in 📄 Draft ADR committed: The draft records this decision:
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and check that the implementation matches the decision. ❓ Why ADRs MatterADRs 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 each decision. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /codebase-design (triage unavailable — used fallback heuristic against pr-meta.json/pr-diff.patch; largest-diff files health_pr_lifecycle.go and health_pr_lifecycle_test.go prioritized) and /tdd. The new PR-lifecycle filter is impressively well-specified and the 374-line regression suite (health_pr_lifecycle_test.go) covers an unusually thorough matrix of evidence/edge cases — merged/closed/deleted/restored heads, genuine vs. aftermath failures, malformed/incomplete/unavailable evidence, request-budget caps, and shared caching. Two non-blocking design suggestions posted inline; nothing here blocks merge.
📋 Key Themes & Highlights
Key Themes
- Hardcoded job/step vocabulary:
"agent"/"conclusion"job-name literals inhealth_pr_lifecycle.goduplicate values already exposed asconstants.AgentJobName/constants.ConclusionJobName, whichpkg/cliimports elsewhere. - Duplicated PR-lookup logic:
fetchHealthLifecyclePRre-implements the same/commits/{sha}/pullslookup asfetchObsoletePREvidence(logs_pr_lifecycle.go), but without its--paginate/--slurphandling for commits linked to >99 PRs — a narrow case, but one the two copies will now diverge on if changed independently.
Positive Highlights
- ✅ Evidence requirements are conservative by design: unknown/ambiguous evidence always falls back to
retained, never a silent success. - ✅ Request budget (
healthMaximumLifecycleRequests, 2-page branch-event cap) and response caching are both enforced and directly tested (TestHealthLifecycleRequestBudgetAndSharedCache). - ✅ Docs (
cli.md) and the changeset clearly describe the newignored/retained/unknownsemantics and their exclusion from metrics/sampling.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 122.1 AIC · ⌖ 15.1 AIC · ⊞ 10.2K
Comment /matt to run again
| } | ||
| continue | ||
| } | ||
| if run.Conclusion == "failure" && job.Name == "conclusion" && healthOnlyFailedStep(job, "Handle agent failure") { |
There was a problem hiding this comment.
[/codebase-design] The job names "agent" and "conclusion" (and "Checkout PR branch" / "Handle agent failure" step names below) are hardcoded string literals, but pkg/constants.AgentJobName / ConclusionJobName already exist and pkg/cli imports pkg/constants elsewhere in the package.
💡 Suggestion
if run.Conclusion == "failure" && job.Name == string(constants.ConclusionJobName) && healthOnlyFailedStep(job, "Handle agent failure") {and similarly at line 264 with string(constants.AgentJobName). This keeps the lifecycle filter resilient to any future rename of the generated job names and matches the existing vocabulary used throughout pkg/workflow.
@copilot please address this.
| return classifyHealthHeadDeletion(run, start, evidence, collection) | ||
| } | ||
|
|
||
| func fetchHealthLifecyclePR(run WorkflowRun, collection *HealthCollection) (healthLifecyclePR, error) { |
There was a problem hiding this comment.
[/codebase-design] fetchHealthLifecyclePR duplicates most of fetchObsoletePREvidence in pkg/cli/logs_pr_lifecycle.go (same /commits/{sha}/pulls endpoint, same head-ref disambiguation idea), but with subtly different logic: this version does not paginate past the first 100 PRs (logs_pr_lifecycle.go uses --paginate --slurp), so a commit shared by >99 PRs silently becomes missing_or_ambiguous_pull_request here instead of being handled across pages.
💡 Suggestion
Consider extracting a shared helper (e.g. fetchCommitPullRequests(ctx, headSha, headBranch)) used by both the logs and health lifecycle paths so the pagination/disambiguation rule is defined once and the two call sites only differ in caching/budget behavior. This reduces the risk of the two copies drifting further apart as PR-lifecycle heuristics evolve.
@copilot please address this.
There was a problem hiding this comment.
🔵 Needs a closer look
Failure suppression still requires fixes and human validation of lifecycle timing and evidence assumptions.
4 open issues
What changed in this PR
Updates gh aw health to exclude evidence-confirmed PR lifecycle interruptions without counting them as successes.
Changes:
- Correlates PR events, job evidence, and checkout diagnostics.
- Applies exclusions consistently across sampling and failure reporting.
- Adds bounded caching, explicit classifications, tests, and documentation.
| File | Description |
|---|---|
pkg/cli/health_sampling.go |
Filters samples and reuses complete job inventories. |
pkg/cli/health_pr_lifecycle.go |
Adds lifecycle classification and bounded lookups. |
pkg/cli/health_pr_lifecycle_test.go |
Covers classification, budgets, and sampling consistency. |
pkg/cli/health_job_evidence.go |
Clarifies the shared job-evidence comment. |
pkg/cli/health_failures_first.go |
Filters interruptions before counting failure candidates. |
pkg/cli/health_command.go |
Updates help and capability metadata. |
pkg/cli/health_collection.go |
Exposes lifecycle classifications and request counts. |
docs/src/content/docs/setup/cli.md |
Documents exclusions, evidence requirements, and limits. |
.changeset/patch-health-pr-lifecycle.md |
Adds the patch release note. |
Review effort: Max
| } | ||
| } | ||
| if len(events) < 100 { | ||
| if evidence.Reason == "pr_head_deleted" && !restoredAt.After(evidence.EventAt) { |
| var aftermath []JobInfoWithDuration | ||
| var checkoutCompleted time.Time | ||
| for _, job := range jobs.details { | ||
| if job.Status != "completed" || job.Conclusion == "" { |
|
|
||
| func healthClosedCheckoutLog(jobID int64, prNumber int, collection *HealthCollection) (bool, error) { | ||
| data, err := healthLifecycleAPI(collection, fmt.Sprintf("%s/actions/jobs/%d/logs", | ||
| healthRepositoryEndpoint(collection.repoOverride), jobID), "--allow-escape-sequences") |
| } | ||
| evidence, checked := collection.PRLifecycleEvidence[run.DatabaseID] | ||
| if !checked || evidence.Attempt != run.Attempt || !evidence.UpdatedAt.Equal(run.UpdatedAt) { | ||
| evidence = classifyHealthPRLifecycle(run, collection) |
|
🎉 This pull request is included in a new release. Release: |

Summary
Handle agent failureconclusion aftermath. Other checkout failures remain failures.ignored/retained/unknownclassifications in JSON/text, and update CLI docs/release notes.Validation
make build,make fmt, andgo test ./pkg/cli -run '^TestHealth' -count=1 -timeout=180s.make check-workflow-drift(346 workflows in sync).make agent-report-progress: aggregate status is blocked by a pre-existingnolint_filterwarning about unknown custom linters. Direct golangci-lint reports only unchanged-file findings:add_workflow_resolution.go:1040,1090,1194(modernize) andspec_test.go:251(testifylint). No changed-file lint diagnostics; unrelated baseline issues were not modified.Live evidence
Read-only check:
Run 39618696466, whose checkout failed after PR #70898 merged at 14:39:05Z, is explicitly
ignored/pr_merged. Result:total_runs=0,success_count=0,failure_count=0, no clusters/investigation, andstatus=no_recent_runsrather than healthy. This used 10 total API requests, including two lifecycle requests.