Skip to content

refact(gate): name the two cost-floor rules - #208

Merged
veksen merged 1 commit into
mainfrom
refact-one-cost-floor-rule
Jul 31, 2026
Merged

veksen merged 1 commit into
mainfrom
refact-one-cost-floor-rule

Conversation

@veksen

@veksen veksen commented Jul 31, 2026

Copy link
Copy Markdown
Member

Goal

Make it possible to see what minimumCost does. Follow-up to #205, which put the floor in the comment copy and exposed that the number means two different things.

What

No behaviour changes. Both rules are preserved exactly and now have names, one home, and tests.

Measured against the real compareRuns with threshold=10, minimumCost=100:

1500 -> 99     IMPROVED
99   -> 1500   REGRESSED
50   -> 99     NOT REPORTED
99   -> 50     NOT REPORTED
200  -> 400    REGRESSED

The two rules, as they stand:

path rule effect at minimumCost: 100
comparison hide only when both costs are under the floor 99 -> 1500 reported, 99 -> 50 silent
recommendation show only when base cost is strictly over the floor a query costing exactly 100 is dropped

How

src/gate/cost-floor.ts holds comparisonClearsFloor and recommendationClearsFloor. site-api.ts and runner.ts call them instead of repeating the conditions inline.

Tests

cost-floor.test.ts pins both rules, including the boundaries: a cost exactly at the floor, and a move that stays under it on both sides. Full suite: 393 passing, 40 files, typecheck clean.

The decision this does not make

The comparison rule asks "is this query worth mentioning at all". The recommendation rule asks "is it expensive enough to bother indexing". Those are reasonable as separate questions, and they are configured by one field, so a repo setting minimumCost: 100 sets two policies without being told.

There is also a cliff: a query wholly under the floor can move by any factor in silence. At 100 that is trivia. At 10,000 it would hide real movement.

Changing either rule changes which pull requests get blocked, so it belongs in a decision rather than a refactor.

minimumCost is one repo setting applied two ways. A comparison hides a move
only when both costs are under the floor. A recommendation shows only when the
base cost is strictly over it. So a query at 99 becoming 1500 is a reported
regression, and a query costing exactly 100 with an index recommendation is not
reported at all.

Both rules keep their current behaviour. They now live in one module with names
and tests, so the difference is visible instead of being two inline conditions
in two files that look like they should agree.

Co-Authored-By: Claude <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

6 successful checks

 Cost regression — No query got more expensive than the threshold allows
 Untested data access — No changed data-access file without a test
 New query — No new queries
 New query with index recommendation — No new query ships an index recommendation
 Schema drift — No schema changes
 High-value nudge — No index or rewrite past the threshold


More details via MCP → get_ci_run({ runId: "019fb957-584e-796e-b373-fe4930cb17d4" }) · view run · docs
3 queries read against main on assumed statistics of 10,000,000 rows per table. Sync production stats for costs measured against your real data.

@veksen
veksen merged commit 2174727 into main Jul 31, 2026
6 checks passed
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.

1 participant