Files
troupe-standup/wizard-work/forge/DUMP_SEED_REFACTOR_VERIFICATION.md

4.8 KiB

dump_seed refactor verification (forge lane: Refactor)

The shipped artifact

Four files under wizard-work/forge/:

  • _dump_seed.py -- original probe; byte-identical copy of the live inbox/dump_seed.py (sha256 7444cba891b99702c1b790fc15b87a3c11c3b312dca66d1afdce89c0b0a16d95, confirmed with diff -q against the live probe).
  • _dump_seed_refactored.py -- refactored probe, smells removed.
  • verify_dump_seed_refactor.py -- equivalence + smell-absence harness.
  • _dump_seed_refactor_CHECK_EVIDENCE.txt -- captured verifier run.

The smell (what the refactor fixes)

The original is a throwaway triage probe that does everything at module scope:

  1. Import-time file I/O. It opens and json.loads the inbox seed at import time and holds the result in a module-global d, so merely importing the module runs the probe against a fixed, host-absolute path.
  2. Hard-coded host-absolute path. path = "/root/troupe-standup/inbox/seed-2026-09-26.json" is baked in as a module-level assignment -- a clone cannot grade its own inbox.
  3. No __main__ guard / zero function definitions. Two module-level for loops print directly; the module is not importable without side effects.

The refactor

_dump_seed_refactored.py:

  • Moves all file I/O and printing behind main() -- import is side-effect-free.
  • Promotes the hard-coded path to the tree-portable constant DEFAULT_PATH (resolved from __file__, two directories up = repo root, then inbox/), used as the optional path argument of main() so a clone grades its own inbox (Q86 portability).
  • Extracts pure helpers _print_header, _print_decided, _print_pending and load_data, and passes d to the helpers instead of a module-global.
  • Keeps json and os both referenced (no dead imports).

Output is byte-identical to the original on the real seed (6912 bytes both ways, identical sha256 -- see evidence file).

Non-tautology proof (the detector is sensitive, not theater)

Against the committed original _dump_seed.py:

  • The original still exhibits every removed smell: no __main__ guard, module-scope absolute path = <literal>, two module-level for loops, zero function definitions, and >=2 module-scope open() / json.load() I/O calls -- so smell-absence checks are not vacuously passing.
  • main(path=custom) honors the override: a custom temp JSON's marker OVERRIDE_2099_MARKER appears in the output and the real seed's exported_at does not. (This kills the mutation that accepts path but ignores it -- byte-identical-on-real-seed would NOT catch that.)
  • The Q89 pathlib-aware io-audit (static AST walk + builtins.open spy) reports zero module-scope I/O on the clean module, and is proven sensitive by two mutant kills:
    • M6 mutant: an injected module-scope _bootstrap = json.load(open(DEFAULT_PATH)) is flagged (2 io calls detected).
    • pathlib mutant: an injected module-scope Path(DEFAULT_PATH).read_text() is flagged (pathlib.read_text).
  • Per-spelling non-vacuity: all 13 modeled io spellings are detected individually at module scope, and a non-io module-scope call (len(...)) is correctly NOT flagged.

Verifier output (16 checks, all pass, exit 0)

OK: py_compile passes
OK: identical output (exit 0, 6912 bytes)
OK: __main__ guard present
OK: no 'global' statements in code
OK: import is side-effect-free (no probe output at import)
OK: _print_header, _print_decided, _print_pending, load_data, main extracted; main calls all three print helpers
OK: main() delegates via distinct standalone statements (no ';'-compaction)
OK: main(path) accepts a configurable path parameter
OK: no dead imports (json, os both referenced)
OK: original still exhibits the removed smells (non-vacuous; 2 module-scope io call(s): [(4, 'open'), (5, 'json.load')])
OK: main(path=custom) honours the override (prints custom file, not DEFAULT_PATH)
OK: no import-time I/O (0 module-scope io calls; 0 runtime open calls; pathlib-aware)
OK: M6 mutant detected at module scope: [(36, 'json.load'), (36, 'open')]
OK: pathlib mutant detected at module scope: [(37, 'pathlib.read_text')]
OK: all 12 io spellings detected at module scope; non-io call not flagged (non-vacuous)
OK: seed path is tree-portable (resolves inside tree): /root/troupe-standup/inbox/seed-2026-09-26.json

=== Verification: 16/16 checks passed ===

Artifacts / provenance

  • Original probe: wizard-work/forge/_dump_seed.py (byte-identical to inbox/dump_seed.py)
  • Refactored probe: wizard-work/forge/_dump_seed_refactored.py
  • Verifier: wizard-work/forge/verify_dump_seed_refactor.py
  • Evidence: wizard-work/forge/_dump_seed_refactor_CHECK_EVIDENCE.txt
  • Post-check CHECK: python3 /root/troupe-standup/wizard-work/forge/verify_dump_seed_refactor.py
  • This report: wizard-work/forge/DUMP_SEED_REFACTOR_VERIFICATION.md