fix(guardrails): report increase only from threshold-exceeding projects - #73
Merged
Conversation
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
marked this pull request as ready for review
June 29, 2026 14:43
owenrumney
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 is0rather 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.