test(mutation): mutate rate_limiter.py live via a duckdb-free fixtureless test#114
Merged
Merged
Conversation
…less test
The rate limiter is declared a mutation target but was never actually mutated
(declared-vs-live gap, road-to-9.8 R2). Make it live: add a narrow,
duckdb-free, fixtureless test that constructs RateLimiter inline and calls
check()/_check_local() directly, and add serving/api/rate_limiter.py to
scripts/mutation_report.py MODULE_TARGETS at threshold 0.90.
rate_limiter imports `from src.constants import ...`, but the serving mutation
workspace copies src/serving -> top-level `serving` without `src`. The test
registers a tiny src.constants stub (the real default, 60) before importing the
module; the dual-context import pulls the REAL constant under ordinary pytest,
where test_real_default_window_is_sixty_seconds pins it so the stub cannot drift.
Verified via the WSL py3.10 reproduction of prepare_workspace: 120/121 killed
= 99.2% (the lone survivor is the equivalent float("-inf")/float("-INF") mutant,
documented in the test). Honest declared-vs-live comments updated in
mutation_report.py, pyproject [tool.mutmut], and test_mutmut_policy.py.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
DORA Metrics
|
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.
What
Closes the declared-vs-live gap for
src/serving/api/rate_limiter.pyin themutation gate (road-to-9.8 R2 / workstream B1). The rate limiter was a
declared mutation target (
test_mutmut_policy.py) but the runner neveractually mutated it —
scripts/mutation_report.pyonly ran retry, sql_guard andmasking live.
How
tests/unit/test_rate_limiter_mutation.py— duckdb-free,fixtureless, inline construction + direct
check()/_check_local()calls somutate_only_covered_linesattributes every method line (the masking/sql_guardpattern).
from src.constants import …, butthe serving workspace copies
src/serving→ top-levelservingwithoutsrc.The test registers a tiny
src.constantsstub (real default, 60) beforeimporting the module. The dual-context import pulls the real constant under
ordinary pytest, where
test_real_default_window_is_sixty_secondspins it sothe stub can't drift.
serving/api/rate_limiter.pyadded toMODULE_TARGETS@threshold 0.90; honest declared-vs-live comments updated in
mutation_report.py,pyproject [tool.mutmut], andtest_mutmut_policy.py.Verification
test_mutmut_policy.pytest_mutation_report.pygreen.prepare_workspace): 120/121 killed =99.2% (threshold 90%). The single survivor is the equivalent
float("-inf")/float("-INF")mutant —float()is case-insensitive —documented in the test.
mutation.ymldispatched on this branch (py3.11 real runner) forthe authoritative number.
🤖 Generated with Claude Code