Skip to content

Fail closed on contradictory empty daily AIC history - #76804

Merged
pelikhan merged 6 commits into
mainfrom
copilot/fix-daily-aic-guardrail-counts
Nov 11, 2026
Merged

pelikhan merged 6 commits into
mainfrom
copilot/fix-daily-aic-guardrail-counts

Conversation

Copilot AI commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Detect contradictory evidence: Check restored observations within the 24-hour window. In workflow-ID mode, also check up to 10 unfiltered runs through the existing API budget.
  • Fail closed: Contradictory evidence produces unknown usage and transient_error, blocking activation.
  • Preserve valid zero usage: Exclude the current run and out-of-window evidence; leave repository filtering and subsequent pagination unchanged.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix daily AIC guardrail counts for empty completed-run listing Fail closed on contradictory empty daily AIC history Nov 11, 2026
Copilot AI requested a review from pelikhan November 11, 2026 08:46
@pelikhan
pelikhan marked this pull request as ready for review November 11, 2026 09:07
Copilot AI adaptive review requested due to automatic review settings November 11, 2026 09:07
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

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 PR Specification Reviewer · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

Generated by PR Specification Reviewer for #76804

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

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 Ponytail Reviewer · routed: gpt61 medium · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 181 · ◷

Generated by Ponytail Reviewer for #76804

@github-actions

github-actions Bot commented Nov 11, 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.

Design Decision Gate 🏗️

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 Design Decision Gate 🏗️ · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 8.5K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

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.

Generated from PR Code Quality Reviewer · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 11, 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 Nov 11, 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 · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-11T09:11:18Z
review_event: REQUEST_CHANGES
top_themes: [API-budget accounting for added history probe]
files_reviewed: [actions/setup/js/daily_aic_scan.cjs, actions/setup/js/daily_aic_scan.test.cjs, actions/setup/js/check_daily_aic_workflow_guardrail.test.cjs]
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
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.

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

Comment thread actions/setup/js/daily_aic_scan.cjs Outdated
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);

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reserved API headroom for both bounded history listings and added a budget-boundary test. Addressed in bcca8337.

@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, /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_id mode, not in repo_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

Comment thread actions/setup/js/daily_aic_scan.cjs Outdated
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);

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.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread actions/setup/js/daily_aic_scan.cjs Outdated
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;

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.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread actions/setup/js/daily_aic_scan.cjs Resolved

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

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)

Comment thread actions/setup/js/daily_aic_scan.cjs Resolved
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/daily_aic_scan.cjs:70): address unresolved feedback - Review comment
  3. Review (actions/setup/js/daily_aic_scan.cjs:70): address unresolved feedback - Review comment
  4. Review (actions/setup/js/daily_aic_scan.cjs:73): address unresolved feedback - Review comment
  5. Review (actions/setup/js/daily_aic_scan.cjs:61): address unresolved feedback - Review comment
  6. Fix failing check push_evals_state (FAILURE): Check run.

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"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

Copilot AI and others added 2 commits November 11, 2026 09:51
…-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>
@github-actions

Copy link
Copy Markdown
Contributor

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.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~5 AIC · ⌖ ~2 AIC · ⊞ 15.9K · ◷

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Fix failing check Analyze (python) (FAILURE): Check run.

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"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

…-guardrail-counts

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

Copilot AI commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Merged latest main via make merge-main in d21f0be6; build, workflow recompilation, 237 tests, and final validation pass. Python CodeQL completed analysis but failed during SARIF post-processing with “API rate limit exceeded for installation.” No source fix is indicated, and I did not retry or trigger CI.

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Merged latest main via make merge-main in d21f0be6. All four linked review fixes remain intact in bcca833 and already have direct replies; 237 tests and the final validation gate pass. push_evals_state failed because concurrent writers repeatedly advanced its results branch, not because of this PR. No CI retry or dispatch was requested.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot estimate cost in gh api points of this change

Copilot AI commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@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: empty scans requiring a probe × average probe pages points, plus retry/recovery traffic; actual frequency isn't measured here. The extra 10-request budget reservation is headroom, not API consumption. Most REST GETs cost 1 secondary-limit point and generally one primary-limit request; GitHub notes some endpoint costs aren't public (rate-limit documentation).

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot add privacy preserving logging to diagnose

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add privacy preserving logging to diagnose

Added aggregate-only probe outcome, page, run and observed-response counts without logging response data or identifiers in 9187bb0b. Focused tests and the final validation gate pass.

@pelikhan
pelikhan merged commit c0a0ba9 into main Nov 11, 2026
31 checks passed
@pelikhan
pelikhan deleted the copilot/fix-daily-aic-guardrail-counts branch November 11, 2026 15:54
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Daily AIC guardrail counts an empty completed-run listing as zero usage

4 participants