Repository navigation
Fix daily AIC accounting for reusable workflows - #74932
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@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.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ 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.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are blocking the reusable-workflow AI-credit accounting fix.
No open issues 🎉
What changed in this PR
Fixes daily AI-credit accounting for reusable workflows so caller-prefixed job names no longer bypass max-daily-ai-credits guardrails, addressing #74864.
Changes:
- Matches billable components using the final
/segment while preserving case normalization and theEvaluationsalias. - Extends regression coverage to unprefixed, caller-prefixed, and nested
agent,detection, andevalsjobs.
| File | Description |
|---|---|
actions/setup/js/daily_aic_component_coverage.test.cjs |
Adds parameterized coverage for prefixes, nesting, capitalization, and aliases. |
actions/setup/js/daily_aic_component_coverage.cjs |
Extracts the final job-name segment before matching billable components. |
Review effort: Balanced (auto)
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.
Review complete: one correctness concern identified about broad component matching.
💡 Findings
- Final-segment matching can classify unrelated jobs as compiler-owned components and inflate daily AIC.
- Added regression coverage should include a negative unrelated-suffix case.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| for (const candidate of [job.job_id, job.name]) { | ||
| if (typeof candidate !== "string") continue; | ||
| const lower = candidate.toLowerCase(); | ||
| const lower = (candidate.split(" / ").pop() ?? "").toLowerCase(); |
There was a problem hiding this comment.
Matching any job whose final segment is agent, detection, or evals can classify unrelated caller jobs as gh-aw components and add their token usage to the daily total, potentially inflating AIC and triggering the guardrail incorrectly.
💡 Restrict component identification or add a negative case
The new logic intentionally supports nested caller prefixes, but it no longer verifies that the prefix/job shape belongs to the compiler-owned reusable workflow. A repository job such as other / detection will now be treated as the detection component. Please constrain the match to the supported generated naming convention (while retaining nested prefixes), or otherwise establish ownership, and add a regression test for an unrelated suffix match.
There was a problem hiding this comment.
Fixed in ab4117f. Prefixed components now require both compiler-generated activation and conclusion siblings under the exact same caller prefix. Unrelated agent/detection/evals suffixes are ignored; regression tests cover miscounts and ambiguity.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /tdd. The fix is correct and the regression tests are meaningful. No blocking issues.
📋 Key Themes & Highlights
Verification
- Vitest could not run in this sandbox because
npm cifailed with a TLS error, so the test suite was not executed through its normal runner. I verified with Node replays of the real modules using mock GitHub clients instead. - Replays show
caller / Agent,outer / caller / AgentandBuild / Agentnow resolve to the agent component.caller / agent-helpercorrectly does not match. Two agent jobs in the same attempt throwAmbiguous daily AIC component jobs, which fails closed. - Against the pre-fix code, the prefixed cases return 0. Against the fixed code they return 49.11352, so the new regression cases do catch the bug.
Key Themes
- Suffix rule scope: matching on the last
/segment can make an unrelated job whose name ends inagent,detectionorevalsa billable component. It fails closed, but it is a new hard-fail mode. See the inline comment on the source line. - Test fixture gap: the
evaluatehelper still matches artifacts by exact job name, so prefixed jobs never exercise real artifact-to-job matching. - Test readability: the
it.eachtitles are awkward, and thejob()helper gives all prefixed jobs the same id. - Missing negative cases: look-alike names and the ambiguity path are not pinned by tests.
Positive Highlights
- ✅ The source change is a one-line, minimal fix.
- ✅
Object.hasOwnavoids prototype-key false matches. - ✅ The regression cases fail on the old code and pass on the new code.
@copilot please address the review comments above, starting with the test fixture and the negative look-alike case.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again
| for (const candidate of [job.job_id, job.name]) { | ||
| if (typeof candidate !== "string") continue; | ||
| const lower = candidate.toLowerCase(); | ||
| const lower = (candidate.split(" / ").pop() ?? "").toLowerCase(); |
There was a problem hiding this comment.
[/codebase-design] Suffix matching now treats any job whose final / segment is agent, detection or evals as a billable component. A non-compiler job such as security / agent running in the same attempt as the compiler Agent job now throws Ambiguous daily AIC component jobs, so that run accounting fails. Before this change the job was ignored. The failure is fail-closed rather than a miscount, but it is a new hard-fail mode for unrelated job names. Decide whether suffix matching should be limited to the compiler caller-prefix shapes, or document this trade-off and pin it with a test.
@copilot please address this.
There was a problem hiding this comment.
Fixed in ab4117f by checking the compiler caller-group naming convention rather than accepting arbitrary suffixes. security / agent alongside the compiler Agent job is ignored, not ambiguous. Tests also cover nested prefixes, partial/mismatched sibling groups, and siblings on another API page.
| "evals/token_usage.jsonl": '{"aic":1}', | ||
| }, | ||
| [job("Agent"), job("Detection"), job("Evaluations")] | ||
| names.map(name => job(`${prefix}${name}`)) |
There was a problem hiding this comment.
[/tdd] The new cases do catch the regression: pre-fix they total 0, post-fix 49.11352. But the evaluate helper (line 42, outside this diff) still matches artifacts by exact lowercased job name, and job() assigns ids by exact name. Every prefixed job therefore gets job id 3 and an undefined artifact id, so attempt greater than 1 producer matching is never exercised with prefixed names. Make the fixture apply the same final / segment rule so artifacts and ids match the real jobs.
@copilot please address this.
There was a problem hiding this comment.
Fixed in ab4117f. Fixture job IDs and producer-artifact matching now normalize the final job-name segment, including the Evaluations alias. The naming matrix runs for attempts 1 and 2, asserts distinct component IDs, and rejects stale prefixed producer artifacts.
| ["", ["Agent", "Detection", "Evaluations"]], | ||
| ["caller / ", ["Agent", "Detection", "Evaluations"]], | ||
| ["outer / caller / ", ["Agent", "Detection", "Evaluations"]], | ||
| ])("counts %j-prefixed %j jobs using their lowercase accounting paths", async (prefix, names) => { |
There was a problem hiding this comment.
[/tdd] Add a negative case. Nothing pins that look-alikes are ignored, for example caller / agent-helper or caller / my-agent, which should resolve to no component. I confirmed caller / agent-helper is ignored with this change, but a test should lock it in so the suffix rule does not drift to substring or prefix matching. Add it to this it.each, expecting no AIC from that job.
@copilot please address this.
There was a problem hiding this comment.
Added in ab4117f: parameterized negatives for caller / agent-helper, caller / my-agent, and nested look-alikes. Even with compiler sibling jobs present, these contribute zero AIC and require no artifact download.
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 42b583d
|
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 42b583d
|
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 42b583d
|
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 42b583d
|
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 42b583d
|
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 42b583d
|
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 42b583d
|
|
@copilot run pr-finisher skill |
…rail-counts Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot compiler threat specification or safe output spec - where daily aic is specified |
Ran pr-finisher. Merged main via |
Neither—the normative home is AI Credits Specification §9, Daily AI Credits Guardrail. Specifically, §9.11, Per-Run Accounting and Source Fallbacks specifies component-name normalization, ambiguous-job rejection, rerun selection, and producer-artifact coverage. That is the appropriate section for this PR’s reusable caller-prefix/ownership contract; it currently does not spell out that naming rule. Local location: |
|
🎉 This pull request is included in a new release. Release: |
Daily AIC guardrails counted reusable-workflow runs as zero because caller-prefixed job names did not match billable components, preventing
max-daily-ai-creditsfrom triggering./segment, socaller / agentandouter / caller / agentresolve toagent. Preserve unprefixed names, case normalization, and theEvaluationsalias.agent,detection, andevalsjobs.