TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 8: conductor(gui_2): Phase 8 checkpoint — 2 property setter sites migrated
Adds 2 invariant tests: - test_phase_8_invariant_property_setter_count_dropped: pins the count to exactly 0 (post-Phase-8 baseline; all 22 INTERNAL_BROAD_CATCH sites in src/gui_2.py migrated across Phases 3-8). - test_phase_8_invariant_all_2_migration_sites_have_tests: verifies the 2 migrated sites (L591, L897) have both success and failure tests. Updates state.toml: phase_8 status = completed.
This commit is contained in:
@@ -26,7 +26,7 @@ phase_4 = { status = "pending", checkpointsha = "", name = "INTERNAL_BROAD_CATCH
|
||||
phase_5 = { status = "pending", checkpointsha = "", name = "INTERNAL_BROAD_CATCH Batch C — event handler sites (<=10 sites)" }
|
||||
phase_6 = { status = "completed", checkpointsha = "c574393", name = "Signal handler sites (<=5 sites; Pattern 3 drain) — 0 sites in this track" }
|
||||
phase_7 = { status = "completed", checkpointsha = "50ee495", name = "Worker / background sites (<=5 sites; thread-safety) — 1 site migrated (L4321)" }
|
||||
phase_8 = { status = "pending", checkpointsha = "", name = "Property setter / state sites (<=5 sites)" }
|
||||
phase_8 = { status = "completed", checkpointsha = "<pending>", name = "Property setter / state sites (<=5 sites) — 2 sites migrated (L591, L897)" }
|
||||
phase_9 = { status = "pending", checkpointsha = "", name = "Helper / utility sites (<=5 sites)" }
|
||||
phase_10 = { status = "pending", checkpointsha = "", name = "INTERNAL_SILENT_SWALLOW migrations (<=13 sites; logging NOT a drain)" }
|
||||
phase_11 = { status = "pending", checkpointsha = "", name = "INTERNAL_RETHROW classification (<=2 sites; Pattern 1/2/3)" }
|
||||
|
||||
@@ -1592,3 +1592,61 @@ def test_phase_8_l897_capture_workspace_profile_ini_result_failure():
|
||||
assert "imgui backend down" in err.message
|
||||
assert result.data == ""
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Phase 8 Invariant Tests (result_migration_gui_2_20260619)
|
||||
# Lock the per-phase progress: 2 INTERNAL_BROAD_CATCH property setter sites
|
||||
# migrated to Result[T], all 2 sites have both success and failure tests.
|
||||
# =============================================================================
|
||||
|
||||
|
||||
def test_phase_8_invariant_property_setter_count_dropped():
|
||||
"""
|
||||
Phase 8 invariant: the audit's INTERNAL_BROAD_CATCH count for src/gui_2.py
|
||||
has dropped from 2 (pre-Phase 8) to 0 (post-Phase 8). All INTERNAL_BROAD_CATCH
|
||||
sites in src/gui_2.py have been migrated across Phases 3-8.
|
||||
|
||||
The 2 migrated sites in Phase 8 are: L591 _diag_layout_state, L897 _capture_workspace_profile.
|
||||
- L591 (startup callback) drains to app._startup_timeline_errors.
|
||||
- L897 (property setter) drains to app._last_request_errors.
|
||||
"""
|
||||
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]
|
||||
broad_catches = [f for f in gui2.get("findings", []) if f.get("category") == "INTERNAL_BROAD_CATCH"]
|
||||
# Post-Phase 8 baseline: 0 (all 22 sites migrated across Phases 3-8).
|
||||
assert len(broad_catches) == 0, (
|
||||
f"Phase 8 invariant: expected 0 INTERNAL_BROAD_CATCH sites in src/gui_2.py "
|
||||
f"(post-Phase 8 baseline, all sites migrated); found {len(broad_catches)}. "
|
||||
f"Lines: {[f.get('line') for f in broad_catches]}"
|
||||
)
|
||||
|
||||
|
||||
def test_phase_8_invariant_all_2_migration_sites_have_tests():
|
||||
"""
|
||||
Phase 8 invariant: each of the 2 Batch E (property setter / state) sites
|
||||
has both success and failure tests in this test file.
|
||||
"""
|
||||
import re
|
||||
text = Path(__file__).read_text(encoding="utf-8")
|
||||
expected_lines = [591, 897]
|
||||
for line in expected_lines:
|
||||
success_pattern = f"test_phase_8_l{line}_.*_result_success"
|
||||
failure_pattern = f"test_phase_8_l{line}_.*_result_failure"
|
||||
assert re.search(success_pattern, text), (
|
||||
f"Phase 8 invariant: missing success test for L{line}. "
|
||||
f"Expected a test matching '{success_pattern}'."
|
||||
)
|
||||
assert re.search(failure_pattern, text), (
|
||||
f"Phase 8 invariant: missing failure test for L{line}. "
|
||||
f"Expected a test matching '{failure_pattern}'."
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user