feat(ci): freeze the conftest save/restore inventory so it can only shrink - #37621
Conversation
Greptile SummaryThe PR adds TQ007 to freeze the known conftest snapshot inventory and updates the quality gate so reduced counts must be accompanied by lower ceilings.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| scripts/check_test_quality.py | Adds TQ007 detection, including the named mappings and helper-local snapshot dictionaries raised in the previous threads. |
| scripts/test_quality_gate.py | Enforces ceiling updates after violations are removed and measures base counts using the current checker. |
| test-quality-budget.json | Seeds TQ007 at the documented current inventory count of 117. |
| tests/test_litellm/test_check_test_quality.py | Adds focused coverage for direct, named, deduplicated, suppressible, and helper-built snapshot inventories. |
| tests/test_litellm/test_test_quality_gate.py | Covers the one-way budget update and stale-ceiling detection behavior. |
Reviews (8): Last reviewed commit: "feat(ci): fail a branch that clears TQ v..." | Re-trigger Greptile
|
Good catch: two conftests name their inventory via _SCALAR_DEFAULTS. Resolving it takes the count from 54 to 82. |
|
TQ007 ratchets exactly like TQ001-006 and the other three budgets: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Right again: batches_tests stores into a local dict in a helper. Matching the shape, not dict names, finds 117 across six conftests. |
|
The seeded exemption is branch-scoped: it reads the merge-base budget, so TQ007 ratchets normally on every branch after this merges. |
|
buildkite e2e has canceled every build org-wide since 12:17Z: 22 builds, 7 branches, none started. Not this PR. |
|
scripts/test_quality_gate.py is not in this diff. The ratchet path shipped in #37588 at 5/5; TQ007 only registers a rule against it. |
b4b5611 to
04d62ad
Compare
6e19208 to
c98eaa5
Compare
ffea6b9 to
f3575d7
Compare
tin-berri
left a comment
There was a problem hiding this comment.
New TQ007 rule freezes the conftest global save/restore inventory (117 globals across 6 conftests) so it can only shrink, closing the 'just add another line' shortcut that let it grow to 491 lines. Seeded budget + red-the-moment-it-grows repro is solid. Caveats honestly scope what the rule does and doesn't detect (loop-based saves vs directly spelled names, skips undefined-module loops rather than guessing). CI green.
…e ceiling A limit that only ever falls is not the same as one that falls when it can. Clearing violations and leaving the ceiling above the new count let the same violations return later under a limit nobody moved, so the gate now fails on that and names `make lint-budget-update` as the fix. It needs both head below base and head below limit, so headroom already in the base is never blamed on the branch that happens to run next. Drops the seeded-rule exemption from the ratchet along with it. Its stated reason was that the base tree predates a rule introduced on this branch, but base counts are measured with the current checker, so such a rule is counted at the base too and its grandfathered total was never at risk of reading as fixed. Removing the exemption is what lets a newly seeded rule ratchet like the six that came before it. The base scan is skipped when the branch touches neither the test tree nor the checker, since neither count can have moved.
f3575d7 to
990339a
Compare
|
Implemented it: the gate now fails a branch that clears violations and leaves the ceiling above the new count, for all seven rules. |
TLDR
Problem this solves:
litellmglobals around every testHow it solves it:
User Flow
Before: a leaking global is papered over instead of fixed
litellm.some_flagsetAfter: the shortcut is closed and the real fix is the cheap one
test-quality-gatefails:TQ007: total 55 over limit 54 (this change added 1)Relevant issues
Linear ticket
Pre-Submission checklist
uv run pytest tests/test_litellm/<your_test_file>.py -vScreenshots / Proof of Fix
Before (b4b5611)
After (6e19208)
The inventory, measured
Green at the seeded ceiling
Red the moment the list grows
_SCALAR_ATTRStupletests/batches_tests/conftest.pysnapshots through a helper:Unit tests
Type
🆕 New Feature
✅ Test
Caveats
conftest.pythat stores a value read offlitellminto a dict under that attribute's name, whatever the dict is calleddir(litellm)) is skipped rather than guessed atFinal Attestation