Skip to content

test(mutation): mutate rate_limiter.py live via a duckdb-free fixtureless test#114

Merged
brownjuly2003-code merged 1 commit into
mainfrom
test/rate-limiter-mutation
Jun 29, 2026
Merged

test(mutation): mutate rate_limiter.py live via a duckdb-free fixtureless test#114
brownjuly2003-code merged 1 commit into
mainfrom
test/rate-limiter-mutation

Conversation

@brownjuly2003-code

Copy link
Copy Markdown
Owner

What

Closes the declared-vs-live gap for src/serving/api/rate_limiter.py in the
mutation gate (road-to-9.8 R2 / workstream B1). The rate limiter was a
declared mutation target (test_mutmut_policy.py) but the runner never
actually mutated it — scripts/mutation_report.py only ran retry, sql_guard and
masking live.

How

  • New narrow test tests/unit/test_rate_limiter_mutation.py — duckdb-free,
    fixtureless, inline construction + direct check() / _check_local() calls so
    mutate_only_covered_lines attributes every method line (the masking/sql_guard
    pattern).
  • src.constants shim — rate_limiter does from src.constants import …, but
    the serving workspace copies src/serving → top-level serving without src.
    The test registers a tiny src.constants stub (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 can't drift.
  • Gate wiringserving/api/rate_limiter.py added to MODULE_TARGETS @
    threshold 0.90; honest declared-vs-live comments updated in
    mutation_report.py, pyproject [tool.mutmut], and test_mutmut_policy.py.

Verification

  • Local: ruff check + format clean; 30 unit tests green; test_mutmut_policy.py
    • test_mutation_report.py green.
  • Mutation (WSL py3.10 reproduction of 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.
  • Golden gate mutation.yml dispatched on this branch (py3.11 real runner) for
    the authoritative number.

🤖 Generated with Claude Code

…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>
@github-actions

Copy link
Copy Markdown

DORA Metrics

  • Window: last 30 days
  • Branch: main
  • Deployment frequency: 155 total / 36.17 per week
  • Lead time for changes: avg 0.28h / median 0.0h
  • Change failure rate: 62.58% (97/155)
  • MTTR: 0.25h across 3 incident(s)

@brownjuly2003-code brownjuly2003-code merged commit bd85eb0 into main Jun 29, 2026
21 checks passed
@brownjuly2003-code brownjuly2003-code deleted the test/rate-limiter-mutation branch June 29, 2026 20:58
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