Skip to content

sqlite_sql_translate.py: 20 surviving mutants in _translate_sql / _returning_was_stripped #265

Description

@cdeust

What

A scoped mutation run (mutmut 3.x, rules/coding-standards.md §12) against
mcp_server/infrastructure/sqlite_sql_translate.py — the SQL-dialect
translation module extracted from sqlite_compat.py in #260 to bring that
file under the project's 300-line cap — surfaces 20 surviving mutants:

mcp_server.infrastructure.sqlite_sql_translate.x__returning_was_stripped__mutmut_8: survived
mcp_server.infrastructure.sqlite_sql_translate.x__returning_was_stripped__mutmut_10: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_38: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_51: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_62: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_64: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_78: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_92: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_105: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_117: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_119: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_134: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_136: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_137: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_149: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_161: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_163: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_175: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_186: survived
mcp_server.infrastructure.sqlite_sql_translate.x__translate_sql__mutmut_188: survived

Reproduce (from a clean checkout, UV_NO_SYNC=1 to avoid a lockfile sync):

$ cp pyproject.toml /tmp/p.bak
$ python3 -c "
import re
s = open('pyproject.toml').read()
s = s.replace('only_mutate = [\"mcp_server/shared/json_native.py\"]',
              'only_mutate = [\"mcp_server/infrastructure/sqlite_sql_translate.py\"]')
s = s.replace('pytest_add_cli_args_test_selection = [\"tests_py/shared/test_json_native.py\"]',
              'pytest_add_cli_args_test_selection = [\"tests_py/handlers/test_wiki_pipeline_sqlite.py\", \"tests_py/infrastructure/test_sqlite_parity_197.py\"]')
open('pyproject.toml', 'w').write(s)
"
$ rm -rf mutants .mutmut-cache
$ UV_NO_SYNC=1 uv run mutmut run
$ UV_NO_SYNC=1 uv run mutmut results | grep survived
$ cp /tmp/p.bak pyproject.toml && rm -rf mutants .mutmut-cache

Why this is not new debt from #260

_translate_sql/_returning_was_stripped/_SUPPORTS_RETURNING were moved
byte-for-byte from sqlite_compat.py into the new
sqlite_sql_translate.py module — no logic changed, same tests run
against them before and after. The project's own test suite already
documents partial awareness of this class of gap:
tests_py/handlers/test_wiki_pipeline_sqlite.py::test_translate_sql_handles_postgres_constructs
says "a scoped mutation run over _translate_sql left 47 mutants alive
against fragment matching"
and switched those parametrized cases to
exact-string comparison as a mitigation — which reduced, but by this
run's count did not eliminate, the survivor set. This run's 20 survivors
predate #260; they were simply never previously counted in isolation
because _translate_sql lived inside the larger, already-partially-tested
sqlite_compat.py.

Acceptance criteria

  1. For each of the 20 mutant ids above, mutmut show <id> names the exact
    line/branch a test does not pin.
  2. Each is either killed by a new or strengthened test (prefer exact-string
    assertions, per the existing file's own documented lesson), or
    documented as a provable equivalent mutant with a written rationale
    (coding-standards §12.1(b)) — e.g. a mutation inside a regex character
    class that cannot change matched input for any reachable SQL shape.
  3. Re-running the reproduction above reports 0 unaccounted-for survivors.

Provenance

Surfaced 2026-07-29 while fixing #260 (the sqlite_compat.py datetime
adapter). Outside that fix's blast radius — the datetime-adapter change
touches only the module docstring, the import block, and the new
_adapt_datetime_iso function/registration in sqlite_compat.py; it does
not modify _translate_sql/_returning_was_stripped at all — so deferred
here per coding-standards.md §14.3 rather than folded into that PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions