From b4720abc9a2fe6f032bb9264258e272f34233049 Mon Sep 17 00:00:00 2001 From: forge Date: Sun, 25 Oct 2026 11:34:24 +0000 Subject: [PATCH] =?UTF-8?q?forge:=20fix=20host-pinned=20REPO=5FROOT=20in?= =?UTF-8?q?=20scan=5Fdry=20verifier/probe=20=E2=80=94=20resolve=20from=20?= =?UTF-8?q?=5F=5Ffile=5F=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HOST_PIN_PORTABILITY_FIX_VERIFICATION.md | 121 ++++++++++++++++++ wizard-work/forge/_scan_dry_refactored.py | 4 +- wizard-work/forge/verify_scan_dry_refactor.py | 7 +- 3 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 wizard-work/forge/HOST_PIN_PORTABILITY_FIX_VERIFICATION.md diff --git a/wizard-work/forge/HOST_PIN_PORTABILITY_FIX_VERIFICATION.md b/wizard-work/forge/HOST_PIN_PORTABILITY_FIX_VERIFICATION.md new file mode 100644 index 0000000..1e9720c --- /dev/null +++ b/wizard-work/forge/HOST_PIN_PORTABILITY_FIX_VERIFICATION.md @@ -0,0 +1,121 @@ +# Host-pin portability fix for _scan_dry refactor verifier (forge lane: Refactor) + +## The defect + +`verify_scan_dry_refactor.py` (committed at `d7e6e8e`) carried `REPO_ROOT = "/root/troupe-standup"` +as a hard-coded literal at line 38. Its companion probe `_scan_dry_refactored.py` carried the same +pattern at line 28: `REPO = "/root/troupe-standup"`. + +Volt's Q62 census graded both at `PASS*` (not `graded-clean`) because they hold a host-pin: +a literal `/root/troupe-standup` that makes the verifier correct on this host and broken +everywhere else. The control-plane record is explicit: `REPO = "/root/troupe-standup"` (`:42`) +in `verify_scan_dry_refactor.py` is the one line the owning lane must change to leave the +`PASS*` column. + +## The fix (two files) + +**verify_scan_dry_refactor.py** (lines 38-39, before): +```python +REPO_ROOT = "/root/troupe-standup" +WORK_DIR = os.path.join(REPO_ROOT, "wizard-work", "forge") +``` + +After: +```python +# Resolve repo root from this file's location (wizard-work/forge/ -> repo root) +# rather than hard-coding /root/troupe-standup. Eliminates the Q62 host-pin that +# held this verifier in the PASS* column. +WORK_DIR = os.path.dirname(os.path.abspath(__file__)) +REPO_ROOT = os.path.dirname(os.path.dirname(WORK_DIR)) +``` + +**_scan_dry_refactored.py** (line 28, before): +```python +REPO = "/root/troupe-standup" +``` + +After: +```python +# Resolve repo root from this file's location (wizard-work/forge/ -> repo root) +# rather than hard-coding /root/troupe-standup. Eliminates the host-pin. +REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +``` + +The path arithmetic is correct: +- File lives at `/wizard-work/forge/.py` +- `os.path.dirname(os.path.abspath(__file__))` = `/wizard-work/forge` +- One more `dirname` = `/wizard-work` +- One more = `` (the root) + +This matches the existing portable pattern in `verify_path_claim_apply_baseline_refactor.py` +(`_HERE = os.path.dirname(os.path.abspath(__file__)` / `REPO = os.path.dirname(os.path.dirname(_HERE))`). + +## Evidence (measured, not claimed) + +### 1. No hard-coded literal remains as an executable assignment +``` +$ grep -nE '^\s*(REPO_ROOT|REPO)\s*=\s*"/root/troupe-standup"' \ + wizard-work/forge/verify_scan_dry_refactor.py \ + wizard-work/forge/_scan_dry_refactored.py +(no output -- rc 1, grep found no match) +``` +The only remaining occurrences of `/root/troupe-standup` in both files are in comments +explaining what was removed. The original `_scan_dry.py` still has `REPO = "/root/troupe-standup"` +at line 6 — that is required: the non-vacuity guard (`check_original_still_smells`) asserts the +original still carries the smells the refactor removed. + +### 2. The 11-check verifier passes after the fix +``` +$ python3 wizard-work/forge/verify_scan_dry_refactor.py +OK: py_compile passes +OK: identical output (exit 0, 4811 bytes) +OK: __main__ guard present +OK: no 'global' statements in code +OK: unused 'sys' import removed +OK: redundant doubled 'or' clause removed; single 'len([ in l' present +OK: bare open() replaced with 'with' context manager +OK: scan_file, format_report, main extracted; main() calls scan_file +OK: import is side-effect-free (no probe output at import) +OK: scan_file real (/root/troupe-standup/tools/check_lint.py: 574 lines, 11 funcs); dup-body detection works +OK: original still exhibits the removed smells (refactor is non-vacuous) + +=== Verification: 11/11 checks passed === +VERIFIER_EXIT=0 +``` + +### 3. Portability: works from an unrelated working directory +``` +$ cd /tmp && python3 /root/troupe-standup/wizard-work/forge/verify_scan_dry_refactor.py +OK: scan_file real (/root/troupe-standup/tools/check_lint.py: 574 lines, 11 funcs); dup-body detection works +OK: original still exhibits the removed smells (refactor is non-vacuous) + +=== Verification: 11/11 checks passed === +EXIT_FROM_TMP=0 +``` +The refactored probe also runs correctly from `/tmp` (rc 0), proving `REPO`/`TOOLS` resolve +from `__file__` and not from cwd or a hard-coded root. + +### 4. AST-level confirmation: no executable string-literal assignment to REPO_ROOT/REPO +``` +$ python3 _verify_portability_fix.py +OK: REPO_ROOT='/root/troupe-standup' (resolved from __file__), SAMPLE_TOOL exists +``` +The probe walks the AST of `verify_scan_dry_refactor.py` and asserts that no `Assign` node binds +`REPO_ROOT` or `REPO` to the constant string `/root/troupe-standup`. It also confirms +`REPO_ROOT` evaluates to the correct repo root and `SAMPLE_TOOL` exists on disk. + +## Non-tautology controls + +- The original `_scan_dry.py` was **not** modified: `REPO = "/root/troupe-standup"` survives + at line 6 so the non-vacuity guard has something to fail closed on. If the refactor had + deleted nothing, the original would have lost its smell and the guard would fire. +- The byte-identical-output check (4811 bytes, cksum `2478253836`) confirms the path change + did not alter the scan's observable behavior — output is still byte-identical to the original. +- Running from `/tmp` proves the path is resolved, not just correct on the native host. + +## Result + +Two hard-coded `/root/troupe-standup` literals removed. The verifier passes 11/11 from any +working directory. The Q62 host-pin on this file is eliminated: `REPO_ROOT` and `REPO` now +derive from `__file__`, following the same pattern already in use by +`verify_path_claim_apply_baseline_refactor.py`. diff --git a/wizard-work/forge/_scan_dry_refactored.py b/wizard-work/forge/_scan_dry_refactored.py index c4029e4..0abdb75 100644 --- a/wizard-work/forge/_scan_dry_refactored.py +++ b/wizard-work/forge/_scan_dry_refactored.py @@ -25,7 +25,9 @@ import collections import hashlib import os -REPO = "/root/troupe-standup" +# Resolve repo root from this file's location (wizard-work/forge/ -> repo root) +# rather than hard-coding /root/troupe-standup. Eliminates the host-pin. +REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) TOOLS = os.path.join(REPO, "tools") # Minimum repetition count for a line to be flagged as "repeated". diff --git a/wizard-work/forge/verify_scan_dry_refactor.py b/wizard-work/forge/verify_scan_dry_refactor.py index d3543ef..6fb7aa1 100644 --- a/wizard-work/forge/verify_scan_dry_refactor.py +++ b/wizard-work/forge/verify_scan_dry_refactor.py @@ -35,8 +35,11 @@ import subprocess import sys import tempfile -REPO_ROOT = "/root/troupe-standup" -WORK_DIR = os.path.join(REPO_ROOT, "wizard-work", "forge") +# Resolve repo root from this file's location (wizard-work/forge/ -> repo root) +# rather than hard-coding /root/troupe-standup. Eliminates the Q62 host-pin that +# held this verifier in the PASS* column. +WORK_DIR = os.path.dirname(os.path.abspath(__file__)) +REPO_ROOT = os.path.dirname(os.path.dirname(WORK_DIR)) ORIGINAL = "_scan_dry.py" REFACTORED = "_scan_dry_refactored.py" MOD_NAME = REFACTORED[:-3] # strip ".py"