test(baseline): add 3 Phase 7 invariant tests (Batch E complete)
TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 7. Phase 7 Batch E migrated 8 sites (1 of 8 was done in 57b67780; 7 added here). Total tests: 22 pass (4 Phase 1 + 3 Phase 2 + 3 Phase 3 + 3 Phase 4 + 3 Phase 5 + 3 Phase 6 + 3 Phase 7). Audit: mcp_client BC 9 -> 3. Total MIG 56 -> 48 (8 sites migrated).
This commit is contained in:
+103
-19
@@ -3,6 +3,10 @@
|
||||
Phase 1 (4): audit + inventory doc counts match expected baseline
|
||||
Phase 2 (3): baseline state is correct (88 MIG sites in 3 files)
|
||||
Phase 3 (3): mcp_client BC count decreased from 40 -> 32 after Batch A
|
||||
Phase 4 (3): mcp_client BC count decreased from 32 -> 24 after Batch B
|
||||
Phase 5 (3): mcp_client BC count decreased from 24 -> 16 after Batch C
|
||||
Phase 6 (3): mcp_client BC count decreased from 16 -> 9 after Batch D
|
||||
Phase 7 (3): mcp_client BC count decreased from 9 -> <=3 after Batch E
|
||||
"""
|
||||
import json
|
||||
import subprocess
|
||||
@@ -111,18 +115,14 @@ def test_phase2_per_file_baseline_counts_match_inventory():
|
||||
for target, expected in BASELINE.items():
|
||||
mig = [f for f in files[target]["findings"] if f["category"] in MIG]
|
||||
assert len(mig) == expected, (
|
||||
f"{target}: baseline expected {expected}, got {len(mig)} "
|
||||
f"(a previous phase may have introduced a violation)"
|
||||
f"{target}: baseline expected {expected}, got {len(mig)}"
|
||||
)
|
||||
|
||||
|
||||
# ============ Phase 3 tests (3) ============
|
||||
|
||||
def test_phase3_mcp_client_broad_catch_decreased_from_40_to_32():
|
||||
"""Phase 3 Batch A migrated 8 INTERNAL_BROAD_CATCH sites.
|
||||
This test asserts the snapshot AFTER Phase 3 (BC=32).
|
||||
Subsequent phases will loosen this test (it documents the Phase 3 boundary).
|
||||
"""
|
||||
"""Loosened: BC <= 32 to allow Phase 4+ overshoot."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
findings = files["src\\mcp_client.py"]["findings"]
|
||||
@@ -131,8 +131,7 @@ def test_phase3_mcp_client_broad_catch_decreased_from_40_to_32():
|
||||
|
||||
|
||||
def test_phase3_total_migration_target_decreased_to_80():
|
||||
"""Total MIG was 88; after Phase 3 it's <=80 (Batch A migrated 8).
|
||||
Subsequent phases will loosen this test."""
|
||||
"""Loosened: total MIG <= 80."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
total = 0
|
||||
@@ -155,9 +154,7 @@ def test_phase3_audit_baseline_matches_phase1_audit_json():
|
||||
# ============ Phase 4 tests (3) ============
|
||||
|
||||
def test_phase4_mcp_client_broad_catch_decreased_to_24():
|
||||
"""Phase 4 Batch B migrated 8 more BC sites (32 -> 24).
|
||||
Loosened to <=24 to allow Phase 5 Batch C to overshoot (the Batch C
|
||||
partial migration reduces BC further)."""
|
||||
"""Loosened: BC <= 24."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
findings = files["src\\mcp_client.py"]["findings"]
|
||||
@@ -166,7 +163,7 @@ def test_phase4_mcp_client_broad_catch_decreased_to_24():
|
||||
|
||||
|
||||
def test_phase4_total_migration_target_decreased_to_72():
|
||||
"""Total MIG was 88; after Phase 4 Batch B it's <= 88 - 16 = 72."""
|
||||
"""Loosened: total MIG <= 72."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
total = 0
|
||||
@@ -177,13 +174,100 @@ def test_phase4_total_migration_target_decreased_to_72():
|
||||
|
||||
|
||||
def test_phase4_modules_import_cleanly():
|
||||
"""Verify mcp_client module imports without errors after the 8 new _result variants."""
|
||||
"""Verify mcp_client module imports after Batch B."""
|
||||
import src.mcp_client
|
||||
assert hasattr(src.mcp_client, "get_git_diff_result")
|
||||
assert hasattr(src.mcp_client, "ts_c_get_skeleton_result")
|
||||
assert hasattr(src.mcp_client, "ts_c_get_code_outline_result")
|
||||
assert hasattr(src.mcp_client, "ts_c_get_definition_result")
|
||||
assert hasattr(src.mcp_client, "ts_c_get_signature_result")
|
||||
assert hasattr(src.mcp_client, "ts_c_update_definition_result")
|
||||
assert hasattr(src.mcp_client, "ts_cpp_get_skeleton_result")
|
||||
assert hasattr(src.mcp_client, "ts_cpp_get_code_outline_result")
|
||||
|
||||
|
||||
# ============ Phase 5 tests (3) ============
|
||||
|
||||
def test_phase5_mcp_client_broad_catch_decreased_to_16():
|
||||
"""Loosened: BC <= 16."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
findings = files["src\\mcp_client.py"]["findings"]
|
||||
bc = sum(1 for f in findings if f["category"] == "INTERNAL_BROAD_CATCH")
|
||||
assert bc <= 16, f"expected mcp_client BC<=16 after Phase 5, got {bc}"
|
||||
|
||||
|
||||
def test_phase5_total_migration_target_decreased_to_64():
|
||||
"""Loosened: total MIG <= 64."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
total = 0
|
||||
for key in TARGETS:
|
||||
findings = files[key]["findings"]
|
||||
total += sum(1 for f in findings if f["category"] in MIG)
|
||||
assert total <= 64, f"expected total MIG<=64 after Phase 5, got {total}"
|
||||
|
||||
|
||||
def test_phase5_modules_import_cleanly():
|
||||
"""Verify mcp_client module imports after Batch C."""
|
||||
import src.mcp_client
|
||||
assert hasattr(src.mcp_client, "ts_cpp_get_definition_result")
|
||||
assert hasattr(src.mcp_client, "py_get_skeleton_result")
|
||||
assert hasattr(src.mcp_client, "py_get_code_outline_result")
|
||||
|
||||
|
||||
# ============ Phase 6 tests (3) ============
|
||||
|
||||
def test_phase6_mcp_client_broad_catch_decreased_to_9():
|
||||
"""Loosened: BC <= 9."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
findings = files["src\\mcp_client.py"]["findings"]
|
||||
bc = sum(1 for f in findings if f["category"] == "INTERNAL_BROAD_CATCH")
|
||||
assert bc <= 9, f"expected mcp_client BC<=9 after Phase 6, got {bc}"
|
||||
|
||||
|
||||
def test_phase6_total_migration_target_decreased_to_56():
|
||||
"""Loosened: total MIG <= 56."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
total = 0
|
||||
for key in TARGETS:
|
||||
findings = files[key]["findings"]
|
||||
total += sum(1 for f in findings if f["category"] in MIG)
|
||||
assert total <= 56, f"expected total MIG<=56 after Phase 6, got {total}"
|
||||
|
||||
|
||||
def test_phase6_modules_import_cleanly():
|
||||
"""Verify mcp_client module imports after Batch D."""
|
||||
import src.mcp_client
|
||||
assert hasattr(src.mcp_client, "py_get_signature_result")
|
||||
assert hasattr(src.mcp_client, "py_set_signature_result")
|
||||
assert hasattr(src.mcp_client, "py_check_syntax_result")
|
||||
|
||||
|
||||
# ============ Phase 7 tests (3) ============
|
||||
|
||||
def test_phase7_mcp_client_broad_catch_decreased():
|
||||
"""After Phase 7 Batch E, mcp_client BC <= 3 (the 3 nested helper functions)."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
findings = files["src\\mcp_client.py"]["findings"]
|
||||
bc = sum(1 for f in findings if f["category"] == "INTERNAL_BROAD_CATCH")
|
||||
assert bc <= 3, f"expected mcp_client BC<=3 after Phase 7, got {bc}"
|
||||
|
||||
|
||||
def test_phase7_total_migration_target_decreased():
|
||||
"""Total MIG was 56 after Phase 6; should be <= 48 after Phase 7 (8 sites migrated)."""
|
||||
data = _audit_live()
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
total = 0
|
||||
for key in TARGETS:
|
||||
findings = files[key]["findings"]
|
||||
total += sum(1 for f in findings if f["category"] in MIG)
|
||||
assert total <= 48, f"expected total MIG<=48 after Phase 7, got {total}"
|
||||
|
||||
|
||||
def test_phase7_modules_import_cleanly():
|
||||
"""Verify mcp_client module imports after Phase 7 Batch E migrations."""
|
||||
import src.mcp_client
|
||||
assert hasattr(src.mcp_client, "py_get_docstring_result")
|
||||
assert hasattr(src.mcp_client, "derive_code_path_result")
|
||||
assert hasattr(src.mcp_client, "get_tree_result")
|
||||
assert hasattr(src.mcp_client, "web_search_result")
|
||||
assert hasattr(src.mcp_client, "fetch_url_result")
|
||||
assert hasattr(src.mcp_client, "get_ui_performance_result")
|
||||
Reference in New Issue
Block a user