TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 9: conductor(gui_2): Phase 9 checkpoint — 0 helper/utility sites in this track
Adds 2 invariant tests: - test_phase_9_invariant_helper_utility_count_dropped: pins the count to exactly 0 (post-Phase-9 baseline; no Phase 9 sites, count should remain 0 after Phases 7-8 dropped it). - test_phase_9_invariant_zero_sites_in_phase_9: documents that no Phase 9 site tests exist (machine-checkable: future agent adding a Phase 9 site will see this test fail at the count assertion). Per PHASE1_SITE_INVENTORY.md, the one Phase 9 site (L1398 _close_vscode_diff) is INTERNAL_SILENT_SWALLOW (the bare-except classification) and will be handled in Phase 10 (logging NOT a drain per the convention). Updates state.toml: phase_9 status = completed.
This commit is contained in:
@@ -27,7 +27,7 @@ phase_5 = { status = "pending", checkpointsha = "", name = "INTERNAL_BROAD_CATCH
|
||||
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 = "completed", checkpointsha = "7ec512c", name = "Property setter / state sites (<=5 sites) — 2 sites migrated (L591, L897)" }
|
||||
phase_9 = { status = "pending", checkpointsha = "", name = "Helper / utility sites (<=5 sites)" }
|
||||
phase_9 = { status = "completed", checkpointsha = "<pending>", name = "Helper / utility sites (<=5 sites) — 0 sites in this track (L1398 is SILENT_SWALLOW, Phase 10)" }
|
||||
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)" }
|
||||
phase_12 = { status = "pending", checkpointsha = "", name = "UNCLEAR classification (<=2 sites)" }
|
||||
|
||||
@@ -1650,3 +1650,73 @@ def test_phase_8_invariant_all_2_migration_sites_have_tests():
|
||||
f"Expected a test matching '{failure_pattern}'."
|
||||
)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Phase 9 Tests - Helper/utility sites
|
||||
# Per PHASE1_SITE_INVENTORY.md, Phase 9 covers helper/utility module-level
|
||||
# sites. The audit shows 0 INTERNAL_BROAD_CATCH sites in this category
|
||||
# in src/gui_2.py (the one Phase 9 site from the inventory, L1398
|
||||
# _close_vscode_diff, is classified INTERNAL_SILENT_SWALLOW and is
|
||||
# handled in Phase 10 — logging is NOT a drain per the convention).
|
||||
# The two invariant tests below document this and pin the count.
|
||||
# =============================================================================
|
||||
|
||||
|
||||
def test_phase_9_invariant_helper_utility_count_dropped():
|
||||
"""
|
||||
Phase 9 invariant: the audit's INTERNAL_BROAD_CATCH count for src/gui_2.py
|
||||
remains at 0 (no sites migrated in Phase 9, since the helper/utility
|
||||
category has 0 INTERNAL_BROAD_CATCH sites in this track).
|
||||
|
||||
Per PHASE1_SITE_INVENTORY.md, the one Phase 9 site (L1398 _close_vscode_diff)
|
||||
is INTERNAL_SILENT_SWALLOW (the bare-except classification) and is handled
|
||||
in Phase 10 (logging NOT a drain). Phase 9 has no sites to migrate.
|
||||
|
||||
Pre-Phase 9 baseline: 0. Post-Phase 9 baseline: 0 (unchanged; Phase 9
|
||||
has 0 sites). This test pins the count to 0 after Phases 7-8 migrated
|
||||
all 3 remaining sites.
|
||||
"""
|
||||
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"]
|
||||
# Phase 9 baseline is 0 (Phase 8 already dropped the count to 0).
|
||||
# This test pins the count to 0 to verify no regression.
|
||||
assert len(broad_catches) == 0, (
|
||||
f"Phase 9 invariant: expected 0 INTERNAL_BROAD_CATCH sites in src/gui_2.py "
|
||||
f"(post-Phase 9 baseline; no Phase 9 sites, count should remain 0); "
|
||||
f"found {len(broad_catches)}. Lines: {[f.get('line') for f in broad_catches]}"
|
||||
)
|
||||
|
||||
|
||||
def test_phase_9_invariant_zero_sites_in_phase_9():
|
||||
"""
|
||||
Phase 9 invariant: documents that Phase 9 (helper/utility sites) has
|
||||
0 sites to migrate. The one Phase 9 site from the inventory
|
||||
(L1398 _close_vscode_diff) is INTERNAL_SILENT_SWALLOW and will be
|
||||
handled in Phase 10.
|
||||
|
||||
This test exists to make the "Phase 9 is empty" decision explicit and
|
||||
machine-checkable: a future agent who tries to add a Phase 9 site
|
||||
will see this test fail at the count assertion.
|
||||
"""
|
||||
import re
|
||||
text = Path(__file__).read_text(encoding="utf-8")
|
||||
# Expected: zero tests matching the Phase 9 site pattern
|
||||
phase_9_site_tests = re.findall(r"test_phase_9_l\d+_.*_result_(success|failure)", text)
|
||||
assert len(phase_9_site_tests) == 0, (
|
||||
f"Phase 9 invariant: expected 0 Phase 9 site tests (helper/utility "
|
||||
f"category has 0 INTERNAL_BROAD_CATCH sites in src/gui_2.py per the "
|
||||
f"PHASE1_SITE_INVENTORY); found {len(phase_9_site_tests)}. Tests: "
|
||||
f"{phase_9_site_tests}. If a Phase 9 site was added, update the "
|
||||
f"inventory and migrate it."
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user