refactor(gui_2): obliterate 2 legacy wrappers _detect_refresh_rate_win32 + _resolve_font_path (Phase 6)

Phase 6 (2 of 9 cruft sites obliterated):

OBLITERATED wrappers:
1. _detect_refresh_rate_win32() -> float (1 caller in App.__init__)
   Migrated: caller now uses _detect_refresh_rate_win32_result(...).data
   with explicit .ok check; on failure uses 0.0 default (no fps cap).
2. _resolve_font_path(font_path, assets_dir) -> str (1 caller in App._load_fonts)
   Migrated: caller now uses _resolve_font_path_result(...).data with .ok
   check; on failure falls back to 'fonts/Inter-Regular.ttf' (the bundled Inter).

Test result: 127/127 pass.
Audit gate: src/gui_2.py --strict exits 0 (no new violations).
Wrapper count: 2 -> 0.

PITFALL encountered: edit_file ate a def line in _apply_runtime_caps_override.
The function body got attached below the OBLITERATED stub. Fixed by
restoring the def line.

This completes Phases 3-6 (all file-level wrapper removals).
Phase 7 (remaining files) is N/A — audit found 0 wrappers in any src/ file.

Next: Phase 8 (audit gate + end-of-track report + campaign close-out).
This commit is contained in:
ed
2026-06-20 20:17:52 -04:00
parent abc23d5cbb
commit bf3a0b9f73
2 changed files with 33 additions and 38 deletions
+29
View File
@@ -146,4 +146,33 @@ def test_phase5_chunk_code_caller_uses_result():
assert len(bare_calls) == 0, (
f"caller should not call _chunk_code (legacy wrapper); "
f"found {len(bare_calls)} bare calls"
)
# ============ Phase 6 (gui_2 wrappers) ============
def test_phase6_detect_refresh_rate_wrapper_obliterated():
"""Phase 6 invariant: the legacy _detect_refresh_rate_win32 wrapper is DELETED."""
from src import gui_2
assert not hasattr(gui_2, "_detect_refresh_rate_win32"), (
"_detect_refresh_rate_win32 wrapper must be OBLITERATED."
)
def test_phase6_resolve_font_path_wrapper_obliterated():
"""Phase 6 invariant: the legacy _resolve_font_path wrapper is DELETED."""
from src import gui_2
assert not hasattr(gui_2, "_resolve_font_path"), (
"_resolve_font_path wrapper must be OBLITERATED."
)
def test_phase6_audit_finds_zero_wrappers_in_src():
"""Phase 6 invariant: 0 legacy wrappers remain anywhere in src/."""
r = subprocess.run(
["uv", "run", "python", "scripts/audit_legacy_wrappers.py"],
capture_output=True, text=True,
)
assert "Found 0 legacy wrappers" in r.stdout, (
f"expected 0 legacy wrappers in src/, but audit found:\n{r.stdout[:500]}"
)