Skip to content

fix(guardrails): report increase only from threshold-exceeding projects - #73

Merged
liamg merged 1 commit into
mainfrom
fix/guardrail-project-max-increase
Jun 29, 2026
Merged

fix(guardrails): report increase only from threshold-exceeding projects#73
liamg merged 1 commit into
mainfrom
fix/guardrail-project-max-increase

Conversation

@liamg

@liamg liamg commented Jun 29, 2026

Copy link
Copy Markdown
Member

For project-scoped guardrails, the reported "Cost increased by $X (Y%)" was taken as the max increase across all filter-matched projects, including ones that didn't breach the threshold. That could surface a figure from a project that never triggered the guardrail — e.g. a large absolute increase that's under a percent threshold, while a smaller project actually breaches it.

Now the representative max-increase is computed only over the projects that exceeded the threshold, matching the dashboard's getTriggeredGuardrails (api/src/services/guardrails.ts). When nothing triggers, the reported increase is 0 rather than the max of non-triggering projects.

Found while reconciling the runner/vcs-rendered PR comment guardrail numbers with the dashboard. Latent today (the runs we checked had the max-increase project also breaching the threshold), but worth fixing for correctness.

Adds a regression test (TestGuardrails_ProjectScope_ReportsTriggeringProjectIncrease) and updates the none-triggered expectation.

For project-scoped guardrails, the reported "Cost increased by $X (Y%)" was
taken as the max increase across all filter-matched projects, including ones
that did not breach the threshold. This could surface a figure belonging to a
project that never triggered the guardrail (e.g. a large absolute increase that
is under a percent threshold, while a smaller project breaches it).

Compute the representative max-increase only over the projects that actually
exceeded the threshold, matching the dashboard's getTriggeredGuardrails
(api/src/services/guardrails.ts). When nothing triggers, the reported increase
is now zero rather than the max of non-triggering projects.

Adds a regression test plus updates the none-triggered expectation.
@liamg liamg self-assigned this Jun 29, 2026
@liamg
liamg marked this pull request as ready for review June 29, 2026 14:43
@liamg
liamg merged commit 7ad38f2 into main Jun 29, 2026
3 checks passed
@liamg
liamg deleted the fix/guardrail-project-max-increase branch June 29, 2026 14:47
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.

2 participants