Private
Public Access
0
0

TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 7: conductor(gui_2): Phase 7 checkpoint — 1 worker site migrated

Adds 2 invariant tests:
- test_phase_7_invariant_batch_d_count_dropped: pins the count to <=2
  (post-Phase-7 baseline, down from 3 pre-Phase-7).
- test_phase_7_invariant_all_1_migration_sites_have_tests: verifies the
  1 migrated site (L4321 worker) has both success and failure tests.

Updates state.toml: phase_7 status = completed.
This commit is contained in:
2026-06-20 00:21:57 -04:00
parent bcfb4887b1
commit 50ee495199
2 changed files with 59 additions and 1 deletions
@@ -25,7 +25,7 @@ phase_3 = { status = "completed", checkpointsha = "e622f1e", name = "INTERNAL_BR
phase_4 = { status = "pending", checkpointsha = "", name = "INTERNAL_BROAD_CATCH Batch B — modal/dialog sites (<=10 sites)" }
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 = "pending", checkpointsha = "", name = "Worker / background sites (<=5 sites; thread-safety)" }
phase_7 = { status = "completed", checkpointsha = "<pending>", 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_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)" }
+58
View File
@@ -1448,3 +1448,61 @@ def test_phase_7_l4321_worker_context_preview_result_failure():
assert "do_generate blew up" in err.message
assert app.context_preview_text == "Error generating context preview."
# =============================================================================
# Phase 7 Invariant Tests (result_migration_gui_2_20260619)
# Lock the per-phase progress: 1 INTERNAL_BROAD_CATCH worker site migrated
# to Result[T], all 1 sites have both success and failure tests.
# =============================================================================
def test_phase_7_invariant_batch_d_count_dropped():
"""
Phase 7 invariant: the audit's INTERNAL_BROAD_CATCH count for src/gui_2.py
has dropped from 3 (pre-Phase 7) to 2 (post-Phase 7). The 2 remaining sites
are in other phases: L591 (Phase 8), L897 (Phase 8).
The 1 migrated site is: L4321 (worker in _check_auto_refresh_context_preview).
The legacy wrapper drains errors to app.controller._worker_errors (with lock).
"""
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"]
# Pre-Phase 7 baseline: 3. Post-Phase 7: 2 (1 site migrated).
assert len(broad_catches) <= 2, (
f"Phase 7 invariant: expected <= 2 INTERNAL_BROAD_CATCH sites in src/gui_2.py "
f"(post-Phase 7 baseline, 1 site migrated); found {len(broad_catches)}. "
f"The 1 Phase 7 site (L4321 worker) must be migrated to Result[T] helper. "
f"Lines: {[f.get('line') for f in broad_catches]}"
)
def test_phase_7_invariant_all_1_migration_sites_have_tests():
"""
Phase 7 invariant: each of the 1 Batch D (worker/background) sites has
both success and failure tests in this test file.
"""
import re
text = Path(__file__).read_text(encoding="utf-8")
expected_lines = [4321]
for line in expected_lines:
success_pattern = f"test_phase_7_l{line}_.*_result_success"
failure_pattern = f"test_phase_7_l{line}_.*_result_failure"
assert re.search(success_pattern, text), (
f"Phase 7 invariant: missing success test for L{line}. "
f"Expected a test matching '{success_pattern}'."
)
assert re.search(failure_pattern, text), (
f"Phase 7 invariant: missing failure test for L{line}. "
f"Expected a test matching '{failure_pattern}'."
)