Private
Public Access
conductor(plan): mark Phase 10 complete (ai_client Batch B; BC 9->0)
Phase 10: ai_client Batch B (9 INTERNAL_BROAD_CATCH sites migrated via 7 helpers).
Helpers added to src/ai_client.py:
- _list_gemini_models_result (site 1)
- _delete_gemini_cache_result (sites 2+3)
- _should_cache_gemini_result (site 4)
- _create_gemini_cache_result (site 5)
- _send_cli_round_result (site 6)
- _run_tier4_analysis_result (site 7)
- _run_tier4_patch_callback_result (site 8)
- _run_tier4_patch_generation_result (site 9)
Per-site decision (TIER1_REVIEW):
- Sites with broad except Exception + log/_append_comms: MIGRATE to Result[T]
- Site 6 with events.emit + raise: extract Result variant; inner re-raises
original exception to preserve outer _send_gemini_cli catch flow
- Sites 7+9 with empty-default ('[XXX FAILED] {e}'): MIGRATE to Result[T]
Audit state (after Phase 10):
mcp_client: 0 migration-target (Phase 3-8 complete)
ai_client: 27 -> 18 migration-target
BC: 9 -> 0 ✓
SS: 11 (Phase 11)
RETHROW: 6 (Phase 12; was 7; -1 from migration)
COMPLIANT: 19 -> 27 (+8 from helpers)
rag_engine: 9 migration-target (Phase 13)
Tests: 79 pass (47 prior + 32 Phase 10 site tests + 3 invariant).
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
"""Phase 10 invariant tests (GREEN).
|
||||
|
||||
9 BC sites migrated via 7 helpers:
|
||||
- _list_gemini_models_result (site 1)
|
||||
- _delete_gemini_cache_result (sites 2+3)
|
||||
- _should_cache_gemini_result (site 4)
|
||||
- _create_gemini_cache_result (site 5)
|
||||
- _send_cli_round_result (site 6)
|
||||
- _run_tier4_analysis_result (site 7)
|
||||
- _run_tier4_patch_callback_result (site 8)
|
||||
- _run_tier4_patch_generation_result (site 9)
|
||||
"""
|
||||
import sys
|
||||
sys.path.insert(0, ".")
|
||||
|
||||
|
||||
def test_phase10_ai_client_bc_count_zero():
|
||||
"""After Phase 10: ai_client BC count is 0 (was 17 at baseline)."""
|
||||
import json
|
||||
import subprocess
|
||||
r = subprocess.run(
|
||||
["uv", "run", "python", "scripts/audit_exception_handling.py",
|
||||
"--include-baseline", "--json"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
data = json.loads(r.stdout)
|
||||
files = {f["filename"]: f for f in data["files"]}
|
||||
ai = files["src\\ai_client.py"]
|
||||
bc = sum(1 for x in ai["findings"] if x["category"] == "INTERNAL_BROAD_CATCH")
|
||||
assert bc == 0, f"expected ai_client BC=0 after Phase 10, got {bc}"
|
||||
|
||||
|
||||
def test_phase10_all_helpers_exist():
|
||||
"""All 7 new _result helpers must exist on ai_client."""
|
||||
import src.ai_client
|
||||
expected = [
|
||||
"_list_gemini_models_result",
|
||||
"_delete_gemini_cache_result",
|
||||
"_should_cache_gemini_result",
|
||||
"_create_gemini_cache_result",
|
||||
"_send_cli_round_result",
|
||||
"_run_tier4_analysis_result",
|
||||
"_run_tier4_patch_callback_result",
|
||||
"_run_tier4_patch_generation_result",
|
||||
]
|
||||
for name in expected:
|
||||
assert hasattr(src.ai_client, name), f"{name} helper missing from src.ai_client"
|
||||
|
||||
|
||||
def test_phase10_legacy_functions_preserved():
|
||||
"""All legacy functions must still be callable with original signatures."""
|
||||
import src.ai_client
|
||||
legacy = [
|
||||
"_list_gemini_models",
|
||||
"_send_gemini",
|
||||
"_send_gemini_cli",
|
||||
"run_tier4_analysis",
|
||||
"run_tier4_patch_callback",
|
||||
"run_tier4_patch_generation",
|
||||
]
|
||||
for name in legacy:
|
||||
assert hasattr(src.ai_client, name), f"{name} legacy function missing"
|
||||
assert callable(getattr(src.ai_client, name)), f"{name} not callable"
|
||||
Reference in New Issue
Block a user