Repository navigation
Fail closed on contradictory empty daily AIC history - #76804
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: 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! Ponytail ReviewerOutcome: 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.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: 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.
|
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ 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.
|
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.
Found one blocking API-budget regression in the new empty-history contradiction probe. The inline comment explains how the additional request can exceed the existing reservation at the inspection boundary. Static review only; tests were not run per review instructions.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| const observedRuns = [...entries.values()].filter(entry => entry.run_id !== context.runId && inWindow(entry.created_at)).length; | ||
| if (observedRuns > 0) throw new Error(`Empty daily AIC workflow history contradicts ${observedRuns} restored observations in the inspection window`); | ||
| if (lookupMode === "workflow_id") { | ||
| const unfiltered = await budget.request(() => github.rest.actions.listWorkflowRuns({ owner, repo, workflow_id: current.workflow_id, per_page: 10, page: 1 }), true, API_READ_OPERATIONS.WORKFLOW_HISTORY); |
There was a problem hiding this comment.
This extra history probe is not included in the guardrail's API-budget reservation: REQUEST_OVERHEAD_BUDGET still accounts for the prior listing overhead, while computeMaxInspectableRuns() can already consume the full remaining allowance (minus reserve) for artifact inspection. At that boundary this additional WORKFLOW_HISTORY request can be rejected as quota-exhausted, turning a previously viable empty-history scan into transient_error. Please increase the reserved overhead (or otherwise account for this probe) and add a budget-boundary test.
There was a problem hiding this comment.
Reserved API headroom for both bounded history listings and added a budget-boundary test. Addressed in bcca8337.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs, /tdd, and /grill-with-docs to the contradiction guard in daily_aic_scan.cjs. The fail-closed direction is right, but the evidence it checks is bounded in ways the PR does not cover.
📋 Key Themes & Highlights
Key Themes
- Bounded evidence: the unfiltered check reads only 10 runs, so older in-window completed runs can be missed (reproduced with a Node harness; the scan resolved to 0 AIC).
- Test gaps: no tests for the 24h window boundary, the status filter, or the current-run exclusion.
- Mode-dependent guarantee: the check runs only in
workflow_idmode, not inrepo_workflow_id_fallback, and the spec does not say so.
Positive Highlights
- ✅ Unknown timestamps and failed unfiltered requests fail closed.
- ✅ The filtered-page case avoids mistaking a repository page for an empty source.
Limits of this review
Vitest could not run here (sandbox TLS blocked npm ci), so test-suite results are unverified. The 10-run cap finding comes from a direct Node harness, not from the test suite.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| const observedRuns = [...entries.values()].filter(entry => entry.run_id !== context.runId && inWindow(entry.created_at)).length; | ||
| if (observedRuns > 0) throw new Error(`Empty daily AIC workflow history contradicts ${observedRuns} restored observations in the inspection window`); | ||
| if (lookupMode === "workflow_id") { | ||
| const unfiltered = await budget.request(() => github.rest.actions.listWorkflowRuns({ owner, repo, workflow_id: current.workflow_id, per_page: 10, page: 1 }), true, API_READ_OPERATIONS.WORKFLOW_HISTORY); |
There was a problem hiding this comment.
[/diagnosing-bugs] The contradiction check only inspects the first 10 unfiltered runs, so a completed in-window run behind 10 newer non-completed runs still yields a zero AIC total.
💡 Reproduction and fix
I reproduced this with a Node harness against the changed module: the scan resolved with countedRuns=0. Either page through the unfiltered history until the window start is covered, or pass a created lower bound so the query returns only in-window runs. Add a regression test with 10+ newer non-completed runs ahead of an in-window completed run.
@copilot please address this.
There was a problem hiding this comment.
The empty-history check now pages through up to 10 pages of in-window unfiltered runs and fails closed if the scan cannot complete; regression coverage includes 100 queued runs ahead of a completed run. Addressed in bcca8337.
| const unfiltered = await budget.request(() => github.rest.actions.listWorkflowRuns({ owner, repo, workflow_id: current.workflow_id, per_page: 10, page: 1 }), true, API_READ_OPERATIONS.WORKFLOW_HISTORY); | ||
| const runs = unfiltered.data?.workflow_runs; | ||
| if (!Array.isArray(runs)) throw new Error("Incomplete daily AIC workflow history"); | ||
| const completedRuns = runs.filter(run => run.id !== context.runId && run.status === "completed" && inWindow(run.created_at)).length; |
There was a problem hiding this comment.
[/tdd] The window boundary, status filter, and current-run exclusion in the new unfiltered check have no direct tests.
💡 Suggested tests
Add cases for: a completed run created exactly at now - WINDOW_MS (counted), one just older (ignored), one in in_progress or queued status (ignored), and the current run ID (ignored). These pin the behavior that inWindow and the status filter must preserve.
@copilot please address this.
There was a problem hiding this comment.
Added tests for the exact window boundary, just-outside history, in-progress/queued runs, and current-run exclusion in both lookup modes. Addressed in bcca8337.
There was a problem hiding this comment.
🟡 Changes recommended
The scan’s upper time bound can exclude completed runs when the runner clock lags GitHub, incorrectly reporting zero usage.
1 open issue
What changed in this PR
Hardens gh-aw’s daily AI Credits guardrail against empty history responses that contradict recent-run evidence, addressing #76560.
Changes:
- Cross-checks an empty first page against restored observations and, in workflow-ID mode, up to 10 unfiltered runs.
- Reports contradictory history as unknown usage with
transient_error, blocking activation. - Adds regression coverage and updates the expected API request count.
| File | Description |
|---|---|
actions/setup/js/daily_aic_scan.test.cjs |
Tests contradictory evidence, valid zero usage, malformed history, and activation failure. |
actions/setup/js/daily_aic_scan.cjs |
Adds contradiction checks before accepting an empty first history page. |
actions/setup/js/check_daily_aic_workflow_guardrail.test.cjs |
Updates request-count expectations for the additional history check. |
Review effort: Max (auto)
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "ebbfd6d7b2cc156fe448435d2c6030ee3acf78a6",
"kind": "requested",
"schema_version": "1",
"state": "3f3845b75206fb0c4f5f02d050e0019d1e39106ac64d95b8b4fbefa7c4db6022",
"work": [
"1a17b66526137462fd5721d5527cec08f266081aa2792df9afde97fba9458ae4",
"29b181863687a8a0ab172b18f93b5e7080b6d66e90d703ec66726f88d60331a0",
"962e250565171c737ef71087477332c30dfe4ffbbc04786f93da7328c30c49f3",
"c9a1f4f65b020004dc586f75dc768e3064b16c88be71dd27bc49edc821dc4136",
"da53055201c9cdebbb27eee66b2151e542d3388cafce62a79b37dc300e2313d5"
],
"workflow": "pr-sous-chef"
}
|
…-guardrail-counts Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
Category: bug | Risk: high | Score: 88/100 (impact 46 + urgency 27 + quality 15). Recommended action: fast_track. Batch: pr-batch:copilot-runtime. Reason: billing/credit correctness fix with strong user impact and direct safety semantics.
|
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "bcca8337fd02e5a8b5345a0b17a7a150cc0f23f5",
"kind": "requested",
"schema_version": "1",
"state": "83c997600e7ff69aafdf7fab36df8f2ef82ce805afbabea07ae065344e1f1556",
"work": [
"43282e7f5b3023b8c8cf9099eab79e7b99f650965f08b47d3df33cde5589879d"
],
"workflow": "pr-sous-chef"
}
|
…-guardrail-counts Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Merged latest
Merged latest |
|
@copilot estimate cost in gh api points of this change |
Estimated incremental cost per guardrail scan: 0 points normally; typically +1 point when the first completed-history page is empty and there is no contradictory cached observation. That path makes 1–10 extra REST GETs (100 runs/page), so up to +10 points without retries; both workflow and repository fallback modes are covered. Transient retries (up to 3 attempts per read) and one quota-reset recovery can increase actual requests. Fleet estimate: |
|
@copilot add privacy preserving logging to diagnose |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added aggregate-only probe outcome, page, run and observed-response counts without logging response data or identifiers in |
|
🎉 This pull request is included in a new release. Release: |

An empty first page of completed workflow runs could incorrectly report zero AI Credits and
under_budget, allowing activation despite recent usage.transient_error, blocking activation.