From 50ee495199276a7832b39e37d1841e0c4d8e7dfc Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 20 Jun 2026 00:21:57 -0400 Subject: [PATCH] =?UTF-8?q?TIER-2=20READ=20conductor/code=5Fstyleguides/er?= =?UTF-8?q?ror=5Fhandling.md=20end-to-end=20before=20Phase=207:=20conducto?= =?UTF-8?q?r(gui=5F2):=20Phase=207=20checkpoint=20=E2=80=94=201=20worker?= =?UTF-8?q?=20site=20migrated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../state.toml | 2 +- tests/test_gui_2_result.py | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/conductor/tracks/result_migration_gui_2_20260619/state.toml b/conductor/tracks/result_migration_gui_2_20260619/state.toml index 929d4a0e..9c98fb94 100644 --- a/conductor/tracks/result_migration_gui_2_20260619/state.toml +++ b/conductor/tracks/result_migration_gui_2_20260619/state.toml @@ -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 = "", 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)" } diff --git a/tests/test_gui_2_result.py b/tests/test_gui_2_result.py index 6070acc0..c79e0116 100644 --- a/tests/test_gui_2_result.py +++ b/tests/test_gui_2_result.py @@ -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}'." + ) +