Private
Public Access
TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 4: refactor(mcp_client): migrate 8 Batch B sites to Result[T]
Phase 4 Batch B (8 INTERNAL_BROAD_CATCH sites in mcp_client.py): Added _result variants inside the Result Variants region: - get_git_diff_result (subprocess.run + CalledProcessError) - ts_c_get_skeleton_result (ASTParser.get_skeleton) - ts_c_get_code_outline_result (ASTParser.get_code_outline) - ts_c_get_definition_result (ASTParser.get_definition) - ts_c_get_signature_result (ASTParser.get_signature) - ts_c_update_definition_result (ASTParser.update_definition) - ts_cpp_get_skeleton_result (ASTParser.get_skeleton with lang=cpp) - ts_cpp_get_code_outline_result (ASTParser.get_code_outline with lang=cpp) Plus 5 internal _ast_* helpers (extract ASTParser boilerplate). Each legacy string-returning function now delegates to its _result variant; the try/except Exception is REMOVED from the legacy function. Updated test_baseline_result.py: - Phase 3 tests loosened (BC<=32, total MIG<=80) - Phase 4 tests added (BC=24, total MIG=72, modules import cleanly) Audit: mcp_client BC 32 -> 24. Total MIG 80 -> 72.
This commit is contained in:
@@ -119,21 +119,27 @@ def test_phase2_per_file_baseline_counts_match_inventory():
|
||||
# ============ 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).
|
||||
"""
|
||||
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 == 32, f"expected mcp_client BC=32 after Batch A, got {bc}"
|
||||
assert bc <= 32, f"expected mcp_client BC<=32 after Phase 3, got {bc}"
|
||||
|
||||
|
||||
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."""
|
||||
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 == 80, f"expected total MIG=80 after Phase 3, got {total}"
|
||||
assert total <= 80, f"expected total MIG<=80 after Phase 3, got {total}"
|
||||
|
||||
|
||||
def test_phase3_audit_baseline_matches_phase1_audit_json():
|
||||
@@ -143,4 +149,39 @@ def test_phase3_audit_baseline_matches_phase1_audit_json():
|
||||
for key in TARGETS:
|
||||
findings = files[key]["findings"]
|
||||
total += sum(1 for f in findings if f["category"] in MIG)
|
||||
assert total == 88, f"PHASE1_AUDIT_BASELINE.json expected 88 baseline MIG, got {total}"
|
||||
assert total == 88, f"PHASE1_AUDIT_BASELINE.json expected 88 baseline MIG, got {total}"
|
||||
|
||||
|
||||
# ============ 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)."""
|
||||
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 == 24, f"expected mcp_client BC=24 after Phase 4, got {bc}"
|
||||
|
||||
|
||||
def test_phase4_total_migration_target_decreased_to_72():
|
||||
"""Total MIG was 88; after Phase 4 Batch B it's 88 - 16 = 72."""
|
||||
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 == 72, f"expected total MIG=72 after Phase 4, got {total}"
|
||||
|
||||
|
||||
def test_phase4_modules_import_cleanly():
|
||||
"""Verify mcp_client module imports without errors after the 8 new _result variants."""
|
||||
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")
|
||||
Reference in New Issue
Block a user