# forge: commit verified DRY refactors — gate_blame + check_lint
forge lane: Refactor. Two behavior-preserving DRY extractions in the working
tree, verified green against `HEAD` (the committed pre-refactor original), then
committed to origin/main.
## The work
### 1. gate_blame.py — `_install_checkin_check`
`--selftest` (21 cells) installs `checkin_check.py` into five fixture repos (A-E)
so `verify.py` grades each fixture by its own tree. The installer was a two-line
`shutil.copy` block, hand-duped five times:
```python
shutil.copy(os.path.join(here, "checkin_check.py"),
os.path.join(, "tools", "checkin_check.py"))
```
Collapsed into one module-level helper:
```python
def _install_checkin_check(base):
here = os.path.dirname(os.path.abspath(__file__))
shutil.copy(os.path.join(here, "checkin_check.py"),
os.path.join(base, "tools", "checkin_check.py"))
```
Five call sites (A-E) become five `_install_checkin_check()` calls. Same
source, same destination, same bytes.
### 2. check_lint.py — `_write_json_file`
Two `--json` output paths (`report()` and `main()`'s `--check --json` branch)
each inlined an identical try/except json-dump block. Collapsed into one helper
returning `0`/`2` (the repo's "could not grade" code), preserving `indent=2`,
`sort_keys=False`, the `\n` terminator, the exact error message, and the rc-2
contract.
## ORIGINAL vs REFACTORED
- ORIGINAL = `git show HEAD:tools/.py` (the committed pre-refactor source).
- REFACTORED = working tree / committed tree (post-commit).
Both anchors are stable: `HEAD` here is the last tree without this commit.
## Evidence (measured, fresh run captured in DRY_REFACTOR_COMMIT_EVIDENCE.log)
```
--- git diff --stat ---
tools/check_lint.py | 39 ++++++++++++++++++++++++---------------
tools/gate_blame.py | 30 +++++++++++++++++++----------
2 files changed, 44 insertions(+), 25 deletions(-)
--- verify_gate_blame_dry_refactor.py ---
[ok ] [1] selftest: original (HEAD) 21/21 rc 0
[ok ] [2] selftest: refactored (working tree) 21/21 rc 0
[ok ] [3] selftest: stdout BYTE-IDENTICAL (original == refactored)
[ok ] [4] code-level: refactored HAS the helper; original has none
[ok ] [5] code-level: refactored has 0 inlined sites; original has 5
[ok ] [6] non-vacuity: live run produced a real 21-cell census
verify: 6 checks, 6 passed, 0 failed (rc 0)
--- verify_check_lint_dry_refactor.py ---
[ok ] [1] selftest: original (HEAD) 37/37 rc 0
[ok ] [2] selftest: refactored (working tree) 37/37 rc 0
[ok ] [3] selftest: stdout BYTE-IDENTICAL (original == refactored)
[ok ] [4] code-level: refactored HAS _write_json_file; original NONE
[ok ] [5] code-level: json.dump( count 2 in original, 1 in refactored
[ok ] [6] non-vacuity: live run produced a real 37-cell census
[ok ] [7] --check --json: stdout + JSON file BYTE-IDENTICAL (rc match)
[ok ] [8] --check --json unwritable path: both return rc 2
verify: 8 checks, 8 passed, 0 failed (rc 0)
--- selftest gate_blame.py --selftest ---
selftest: 21 cells, 21 passed, 0 failed (rc 0)
--- selftest check_lint.py --selftest ---
selftest: 37 cells, 37 passed, 0 failed (rc 0)
```
## Non-tautology proof
Against the pinned original (`git show HEAD:`), the smells genuinely existed
(gate_blame: 5 inlined sites in HEAD, 0 in refactored; check_lint: 2
`json.dump(` call sites in HEAD, 1 in refactored) and the helper definitions
exist only in the refactored source. The selftest census is a real 37-cell and
21-cell run, not a stub, and stdout is byte-identical pre/post-refactor.
## Artifacts
- Refactored tools: `tools/gate_blame.py`, `tools/check_lint.py`
- Verifiers (committed): `wizard-work/forge/verify_gate_blame_dry_refactor.py`,
`wizard-work/forge/verify_check_lint_dry_refactor.py`
- Fresh evidence log: `DRY_REFACTOR_COMMIT_EVIDENCE.log`
- Report: this file
- Post-check CHECK (see verdict below): selftests on the committed tree
VERDICT: PASS — both DRY refactors verified green (gate_blame 6/6, check_lint
8/8; selftests 21/21 + 37/37, byte-identical stdout) and committed to origin/main.
EXIT=0