Skip to content

Mutation testing: 8 of 34 mutations survive a green suite, two on memory handling #175

Closed

Description

@fdaviddpt

A mutation-testing pass over pipeline/*.py and scripts/log.sh: 34 mutations, ~8 survived (24%) against a green 695-test suite. The survivors cluster on memory/path handling.

1. LRU eviction is never exercised (HIGH)

Deleting sessions.pop(session_id, None) from cmd_save_position survives — including test_a_session_that_keeps_saving_is_not_evicted, the regression test for that exact line. The fixture makes exactly _POSITION_SLOTS saves, so the eviction loop never runs.

Without the pop, plain key reassignment does not move the entry to the end of insertion order: an actively-worked session gets evicted, resumes from 0, and re-summarizes everything — the #140 symptom, reintroduced silently.

Fix: fixture must exceed the cap.

2. Truncation direction untested (HIGH)

raw[-max_extract_bytes:] → raw[:max_extract_bytes] survives. The only test touching max_extract_bytes checks the CLI forwards the argument; nothing feeds an oversized extract and checks which end survives. Flipped, the summarizer receives the oldest context instead of the recent tail — inverting #96.

3. TZ="" regression test depends on the wall clock (MEDIUM)

test_log_sh_no_config_falls_back_to_system_local_not_utc compares UTC against America/Los_Angeles, which share a calendar date for most of the day. Removing the [ -n "$REMEMBER_TZ" ] guard — the literal historical bug — passes outside roughly 17:00–24:00 PT. Needs a frozen clock, not a real one.

4. _session_dir HOME-vs-expanduser order unverifiable (MEDIUM)

Swapping the fallback order survives: on POSIX expanduser("~") reads $HOME anyway, so the Windows-specific reason for the ordering has no assertion that can fail on any platform CI runs.

5. Lower severity

  • is_skip check in consolidate() removable when text both starts with SKIP and contains a valid header
  • split("===ARCHIVE===") without maxsplit=1
  • >= vs > at the prompt-byte boundary
  • sorted(staging_contents.items()) removable (single-file fixtures only)
  • _POSITION_SLOTS assertion imports the constant it checks — tautological

consolidate.py's fence parser, by contrast, killed nearly every mutation — it has been through adversarial hardening and it shows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions