test(mutation): mutate masking.py live via a duckdb-free fixtureless test#111
Merged
Merged
Conversation
…test The PII masker redacts cleartext PII, but the mutation gate only declared it (pyproject paths_to_mutate) without mutating it -- the live runner (scripts/mutation_report.py MODULE_TARGETS) ran only retry.py and sql_guard.py. A prior attempt mutated masking.py through a fixture-built masker, which under `mutate_only_covered_lines` left every method line uncovered, so only __init__ got mutated (score 0%). Add tests/unit/test_masking_mutation.py: a narrow, duckdb-free test (the ordinary test_masking.py pulls the API router -> DataCatalog -> duckdb chain, which crashes mutmut's workspace) that builds the masker inline and calls each method directly -- the shape that made test_sql_guard_mutation.py work -- so coverage attributes every method line and the whole module is mutated. Wire serving/masking.py into MODULE_TARGETS at threshold 0.90, matching sql_guard. Verified end-to-end with the runner's own workspace layout (mutmut 3.6): 184 mutants across all methods, 176 killed = 95.7%. The 8 survivors are equivalent or unreachable mutants (the yaml-None guard under `# pragma: no cover`, encoding="utf-8" vs the platform default on an ASCII config, and dialect-equivalent sqlglot.parse_one calls). Comments in pyproject [tool.mutmut] and test_mutmut_policy.py updated so the declared-vs-live note stays honest: masking is now live, not declared-only. 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
Bring
src/serving/masking.py(the PII masker) under the live mutation gate.Until now it was only declared in
pyproject [tool.mutmut].paths_to_mutate; thegate that actually runs (
scripts/mutation_report.pyMODULE_TARGETS) mutatedonly
retry.pyandsql_guard.py, so a weakened masking rule could pass CI.Why this needed a new test
tests/unit/test_masking.pyimports the API router →DataCatalog→ the duckdb engine chain, which drags duckdb's compiled subpackage into
mutmut's
mutants/workspace and crashes the run.mutate_only_covered_lines = truethat left every method line uncovered, soonly
__init__was mutated (score 0%).What this adds
tests/unit/test_masking_mutation.py— a narrow, duckdb-free, fixturelesstest that builds the masker inline and calls each method directly (the shape
that made
test_sql_guard_mutation.pywork), so coverage attributes everymethod line. Dual-context import (
serving.*under the harness,src.serving.*under ordinary pytest). It also runs in the normal unit suite.
serving/masking.pyadded toMODULE_TARGETSat threshold 0.90 (same baras
sql_guard).pyproject [tool.mutmut]andtest_mutmut_policy.pyupdated so thedeclared-vs-live note stays honest (masking is now live, not declared-only).
Verification
Replayed the runner's own workspace layout locally with mutmut 3.6:
184 mutants across all methods, 176 killed = 95.7% (≥ 0.90). The 8 survivors
are equivalent/unreachable mutants: the
yaml is Noneguard under# pragma: no cover,encoding="utf-8"vs the platform default on an ASCIIconfig, and dialect-equivalent
sqlglot.parse_onecalls.The
mutation.ymlworkflow has been dispatched on this branch to confirm thescore through the real runner on Python 3.11. Local gates: ruff check + format
clean,
test_mutmut_policy.py+test_mutation_report.py+test_masking*.pyall green.
🤖 Generated with Claude Code