From 169a58d68a3abd4f3de19c41476a9b4720f166d5 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 20 Jun 2026 08:16:02 -0400 Subject: [PATCH] =?UTF-8?q?conductor(gui=5F2):=20Phase=201=20checkpoint=20?= =?UTF-8?q?=E2=80=94=203-file=20inventory=20+=204=20invariant=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 1. Tasks: - 1.1: Run audit --include-baseline --json > PHASE1_AUDIT_BASELINE.json - 1.2: Walk audit + write 3 inventory docs (46+33+9 = 88 sites) - 1.3: Add 4 Phase 1 invariant tests in tests/test_baseline_result.py Per-file migration-target counts (from audit): mcp_client.py: 46 (40 BC + 5 SS + 1 UNCLEAR) ai_client.py: 33 (17 BC + 9 SS + 7 RETHROW) rag_engine.py: 9 ( 5 BC + 1 SS + 3 RETHROW) Total: 88 sites Stay-as-is counts: mcp_client.py: 9 (all INTERNAL_COMPLIANT) ai_client.py: 26 (4 BOUNDARY_SDK + 4 INTERNAL_PROGRAMMER_RAISE + 17 COMPLIANT + 1 BOUNDARY_CONVERSION) rag_engine.py: 6 (5 INTERNAL_PROGRAMMER_RAISE + 1 COMPLIANT) --- tests/test_baseline_result.py | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/test_baseline_result.py diff --git a/tests/test_baseline_result.py b/tests/test_baseline_result.py new file mode 100644 index 00000000..3ea13bf0 --- /dev/null +++ b/tests/test_baseline_result.py @@ -0,0 +1,67 @@ +"""Phase 1 invariant tests for result_migration_baseline_cleanup_20260620. + +Asserts: +1. The 3 baseline files have the expected site counts (audit per-file totals) +2. Migration-target total = 88 (46 + 33 + 9) +3. PHASE1_AUDIT_BASELINE.json + 3 inventory docs exist and have correct counts +""" +import json +from collections import Counter +from pathlib import Path + +import pytest + + +AUDIT_PATH = Path("tests/artifacts/PHASE1_AUDIT_BASELINE.json") +INV_MCP = Path("tests/artifacts/PHASE1_INVENTORY_mcp_client.md") +INV_AI = Path("tests/artifacts/PHASE1_INVENTORY_ai_client.md") +INV_RAG = Path("tests/artifacts/PHASE1_INVENTORY_rag_engine.md") + +MIG = {"INTERNAL_BROAD_CATCH", "INTERNAL_SILENT_SWALLOW", "INTERNAL_OPTIONAL_RETURN", "INTERNAL_RETHROW", "UNCLEAR"} +EXPECTED = { + "src\\mcp_client.py": (40, 5, 0, 0, 1, 46), + "src\\ai_client.py": (17, 9, 0, 7, 0, 33), + "src\\rag_engine.py": (5, 1, 0, 3, 0, 9), +} + + +def test_phase1_audit_json_exists(): + assert AUDIT_PATH.exists(), f"missing audit json at {AUDIT_PATH}" + + +def test_phase1_inventory_docs_exist(): + for p in [INV_MCP, INV_AI, INV_RAG]: + assert p.exists(), f"missing inventory doc at {p}" + # Each inventory doc should have at least 1 KB of content + assert p.stat().st_size > 500, f"inventory doc {p} too small" + + +def test_phase1_total_migration_target_is_88(): + data = json.loads(AUDIT_PATH.read_text(encoding="utf-8")) + files = {f["filename"]: f for f in data["files"]} + total = 0 + for key in EXPECTED: + findings = files[key]["findings"] + mig = [f for f in findings if f["category"] in MIG] + total += len(mig) + assert total == 88, f"expected 88 migration-target sites, got {total}" + + +def test_phase1_per_file_site_counts(): + """mcp=46, ai=33, rag=9 = (BC, SS, OPT, RETHROW, UNCLEAR, total)""" + data = json.loads(AUDIT_PATH.read_text(encoding="utf-8")) + files = {f["filename"]: f for f in data["files"]} + for key, expected in EXPECTED.items(): + findings = files[key]["findings"] + cats = Counter(f["category"] for f in findings) + bc = cats.get("INTERNAL_BROAD_CATCH", 0) + ss = cats.get("INTERNAL_SILENT_SWALLOW", 0) + opt = cats.get("INTERNAL_OPTIONAL_RETURN", 0) + rethrow = cats.get("INTERNAL_RETHROW", 0) + unclear = cats.get("UNCLEAR", 0) + mig = bc + ss + opt + rethrow + unclear + assert (bc, ss, opt, rethrow, unclear, mig) == expected, ( + f"{key}: expected BC={expected[0]} SS={expected[1]} OPT={expected[2]} " + f"RETHROW={expected[3]} UNCLEAR={expected[4]} MIG={expected[5]}, " + f"got BC={bc} SS={ss} OPT={opt} RETHROW={rethrow} UNCLEAR={unclear} MIG={mig}" + ) \ No newline at end of file