test(gui_2): add 2 Phase 10 invariant tests + Phase 10 checkpoint

TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 10.
ANTI-SLIMING VERIFIED: 13 INTERNAL_SILENT_SWALLOW sites migrated to Result[T].
logging NOT a drain per the user's principle 2026-06-17.

Invariant tests:
1. test_phase_10_invariant_silent_swallow_count_zero: verifies audit
   shows 0 INTERNAL_SILENT_SWALLOW sites in src/gui_2.py (was 13).
2. test_phase_10_invariant_all_13_sites_have_tests: verifies all 13
   sites have success and failure tests (>= 2 tests per site).

State updates:
- phase_10 = completed (was pending)
- silent_swallow_count_zero = true (was false)
- All 13 site tasks (t10_1 through t10_13) marked completed with SHAs
- t10_14 (this checkpoint commit) marked in_progress

29 Phase 10 tests pass: 27 site tests + 2 invariant tests.
This commit is contained in:
ed
2026-06-20 01:06:56 -04:00
parent 3c752eb2ae
commit 02dcca448f
2 changed files with 111 additions and 18 deletions
+93
View File
@@ -2300,4 +2300,97 @@ def test_phase_10_l7315_ticket_id_max_int_result_failure():
assert "invalid literal" in err.message or "T-abc" in err.message
# =============================================================================
# Phase 10 Invariant Tests (result_migration_gui_2_20260619)
# Lock the per-phase progress: 13 INTERNAL_SILENT_SWALLOW sites migrated to
# Result[T] with full propagation (NO narrowing+logging, NO pass-after-log).
# logging NOT a drain per the user's principle 2026-06-17.
# =============================================================================
def test_phase_10_invariant_silent_swallow_count_zero():
"""
Phase 10 invariant: the audit's INTERNAL_SILENT_SWALLOW count for src/gui_2.py
is now 0. All 13 sites in the inventory have been migrated to Result[T]
propagation. The new helpers are classified as INTERNAL_COMPLIANT (or
BOUNDARY_CONVERSION for the dispatcher wrappers), not as SILENT_SWALLOW.
Per the user's principle 2026-06-17 (logging NOT a drain), the
migration replaced each site with a full Result[T] pattern:
- Helper: returns Result(data=X, errors=[ErrorInfo]) on exception
- Wrapper: calls helper, drains errors to the appropriate data plane
(NOT silent swallow)
- Tests: 2 tests per site verify success + failure paths
Pre-Phase 10 baseline: 13. Post-Phase 10 baseline: 0. This test pins
the count to 0.
"""
result = subprocess.run(
["uv", "run", "python", "scripts/audit_exception_handling.py", "--src", "src", "--json"],
capture_output=True,
text=True,
)
assert result.returncode == 0, (
f"audit_exception_handling.py exited {result.returncode}; stderr:\n"
f"{result.stderr[:2000]}"
)
data = json.loads(result.stdout)
gui2 = [f for f in data.get("files", []) if "gui_2" in f.get("filename", "")][0]
silent_swallows = [f for f in gui2.get("findings", []) if f.get("category") == "INTERNAL_SILENT_SWALLOW"]
assert len(silent_swallows) == 0, (
f"Phase 10 invariant: expected 0 INTERNAL_SILENT_SWALLOW sites in src/gui_2.py "
f"(post-Phase 10 baseline; all 13 sites migrated to Result[T]); "
f"found {len(silent_swallows)}. Lines: {[f.get('line') for f in silent_swallows]}"
)
def test_phase_10_invariant_all_13_sites_have_tests():
"""
Phase 10 invariant: all 13 INTERNAL_SILENT_SWALLOW migration sites have
success and failure tests in this test file. Verifies the test coverage
for Phase 10 is complete.
The 13 sites (from PHASE1_SITE_INVENTORY.md):
- L216 _detect_refresh_rate_win32
- L241 _resolve_font_path
- L567 _post_init
- L683 run
- L974 shutdown
- L1074 _gui_func
- L1348 _close_vscode_diff
- L1504 render_main_interface (focus_response)
- L1530 render_main_interface (autosave)
- L4742 _on_warmup_complete_callback
- L6694 render_tier_stream_panel
- L7029 render_task_dag_panel (cycle_check)
- L7045 render_task_dag_panel (ticket_id_parse)
"""
import re
text = Path(__file__).read_text(encoding="utf-8")
sites = [
("L216", "detect_refresh_rate_win32"),
("L264", "resolve_font_path"),
("L612", "post_init_callback"),
("L728", "run_immapp"),
("L1052", "shutdown_save_ini"),
("L1152", "gui_func_entry_log"),
("L1466", "close_vscode_diff_terminate"),
("L1647", "focus_response_window"),
("L1693", "autosave_flush"),
("L4911", "on_warmup_complete_callback"),
("L6908", "tier_stream_scroll_sync"),
("L7271", "dag_cycle_check"),
("L7315", "ticket_id_max_int"),
]
for line, site in sites:
# Allow either _result_success/_result_failure OR descriptive suffixes
pattern = rf"def test_phase_10_{line.lower()}_{site}_result_(\w+)\("
matches = re.findall(pattern, text)
assert len(matches) >= 2, (
f"Phase 10 invariant: missing tests for {line} {site}. "
f"Found {len(matches)} tests matching {pattern}. "
f"Need at least 2 (one success-like, one failure-like)."
)