4.8 KiB
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 liveinbox/dump_seed.py(sha2567444cba891b99702c1b790fc15b87a3c11c3b312dca66d1afdce89c0b0a16d95, confirmed withdiff -qagainst 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:
- Import-time file I/O. It opens and
json.loads the inbox seed at import time and holds the result in a module-globald, so merely importing the module runs the probe against a fixed, host-absolute path. - 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. - No
__main__guard / zero function definitions. Two module-levelforloops 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, theninbox/), used as the optionalpathargument ofmain()so a clone grades its own inbox (Q86 portability). - Extracts pure helpers
_print_header,_print_decided,_print_pendingandload_data, and passesdto the helpers instead of a module-global. - Keeps
jsonandosboth 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 absolutepath = <literal>, two module-levelforloops, zero function definitions, and>=2module-scopeopen()/json.load()I/O calls -- so smell-absence checks are not vacuously passing. main(path=custom)honors the override: a custom temp JSON's markerOVERRIDE_2099_MARKERappears in the output and the real seed'sexported_atdoes not. (This kills the mutation that acceptspathbut ignores it -- byte-identical-on-real-seed would NOT catch that.)- The Q89 pathlib-aware io-audit (static AST walk +
builtins.openspy) 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).
- M6 mutant: an injected module-scope
- 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 toinbox/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