conductor(plan): mark Phase 13 complete (rag_engine 9->0 migration-target)
Phase 13: rag_engine migration (9 sites: 1 SS + 5 BC + 3 RETHROW). Helpers added: - _get_file_mtime_result (BC site 3) — class method, Result[float] - _check_existing_index_result (SS site 6) — class method, Result[bool] - _read_file_content_result (BC site 4) — class method, Result[str] - _chunk_code_result (BC site 2) — class method, Result[List[str]] - _parse_search_response_result (BC site 5) — module-level function, placed BEFORE class RAGEngine (a def at column 0 inside a class ends the class prematurely; module-level keeps it out of class scope) Site 1 (BC L33): narrowed 'except Exception' to (ImportError, AttributeError) 3 RETHROW sites (L29/L32/L33/L36 in _get_sentence_transformers): - L31 'raise ImportError(...) from e' — Pattern 1 compliant - L32 bare 'raise' (re-raise) — Pattern 3 compliant - L36 'raise' (after log) — Pattern 2 compliant All follow documented Re-Raise Patterns; remain INTERNAL_RETHROW per audit (no Pattern 1/3 heuristic exists). Strict mode accepts. Audit state (after Phase 13): mcp_client: V=0 (Phases 3-8 complete) ai_client: V=0 (Phases 9-12 complete; 5 RETHROW sites Pattern 1/3) rag_engine: V=0 (Phase 13 complete; 4 RETHROW sites Pattern 1/3) TOTAL BASELINE VIOLATIONS: 0 STRICT BASELINE GATE: PASS Non-baseline files (out of scope): 4 INTERNAL_OPTIONAL_RETURN violations in external_editor/session_logger/project_manager (pre-existing). Tests: 122 pass (was 109; +13 Phase 13 site/invariant tests).
This commit is contained in:
@@ -31,7 +31,7 @@ phase_9 = { status = "completed", checkpointsha = "84b7a693", name = "ai_client
|
||||
phase_10 = { status = "completed", checkpointsha = "40a60e63", name = "ai_client Batch B (broad-catch; 9 sites migrated via 7 helpers; BC 9->0)" }
|
||||
phase_11 = { status = "completed", checkpointsha = "26ebbf78", name = "ai_client silent-swallow (11 sites; CRITICAL anti-sliming; SS 11->0, UNCLEAR 0->0)" }
|
||||
phase_12 = { status = "completed", checkpointsha = "b95601e9", name = "ai_client rethrow classification (6 sites; 4 Pattern 1 fixes + 1 Result migration + 1 known limitation)" }
|
||||
phase_13 = { status = "pending", checkpointsha = "", name = "rag_engine migration (1 SS + 5 BC + 3 RETHROW = 9 sites)" }
|
||||
phase_13 = { status = "completed", checkpointsha = "1e323cae", name = "rag_engine migration (9 sites: 1 SS + 5 BC + 3 RETHROW; migration-target 9->0)" }
|
||||
phase_14 = { status = "pending", checkpointsha = "", name = "Audit gate + end-of-track report (5 tasks; --include-baseline --strict exits 0; 11/11 tiers PASS; campaign 100% complete)" }
|
||||
|
||||
[tasks]
|
||||
@@ -168,17 +168,17 @@ t12_7 = { status = "completed", commit_sha = "", description = "SKIPPED: was 7 s
|
||||
t12_8 = { status = "in_progress", commit_sha = "", description = "Add Phase 12 invariant test; Phase 12 checkpoint" }
|
||||
|
||||
# Phase 13: rag_engine migration (9 sites)
|
||||
t13_0 = { status = "pending", commit_sha = "", description = "Phase 13 styleguide re-read + ack commit" }
|
||||
t13_1 = { status = "pending", commit_sha = "", description = "Migrate broad-catch site 1" }
|
||||
t13_2 = { status = "pending", commit_sha = "", description = "Migrate broad-catch site 2" }
|
||||
t13_3 = { status = "pending", commit_sha = "", description = "Migrate broad-catch site 3" }
|
||||
t13_4 = { status = "pending", commit_sha = "", description = "Migrate broad-catch site 4" }
|
||||
t13_5 = { status = "pending", commit_sha = "", description = "Migrate broad-catch site 5" }
|
||||
t13_6 = { status = "pending", commit_sha = "", description = "Migrate silent-swallow site 6" }
|
||||
t13_7 = { status = "pending", commit_sha = "", description = "Classify or migrate rethrow site 7" }
|
||||
t13_8 = { status = "pending", commit_sha = "", description = "Classify or migrate rethrow site 8" }
|
||||
t13_9 = { status = "pending", commit_sha = "", description = "Classify or migrate rethrow site 9" }
|
||||
t13_10 = { status = "pending", commit_sha = "", description = "Add Phase 13 invariant test; Phase 13 checkpoint" }
|
||||
t13_0 = { status = "completed", commit_sha = "8321608", description = "Phase 13 styleguide re-read + ack commit" }
|
||||
t13_1 = { status = "completed", commit_sha = "f322052c", description = "Migrate BC site 1 (narrow 'except Exception' to (ImportError, AttributeError))" }
|
||||
t13_2 = { status = "completed", commit_sha = "7b3d7237", description = "Migrate BC site 2 (_chunk_code to Result)" }
|
||||
t13_3 = { status = "completed", commit_sha = "ee50c265", description = "Migrate BC sites 3+4 + SS 6 (3 index_file helpers)" }
|
||||
t13_4 = { status = "completed", commit_sha = "ee50c265", description = "Migrate BC site 4 (combined with site 3 in index_file batch)" }
|
||||
t13_5 = { status = "completed", commit_sha = "1e323cae", description = "Migrate BC site 5 (_async_search_mcp JSON parse to Result)" }
|
||||
t13_6 = { status = "completed", commit_sha = "ee50c265", description = "Migrate SS site 6 (combined with sites 3+4)" }
|
||||
t13_7 = { status = "completed", commit_sha = "", description = "RETHROW sites (Pattern 1/3 documented as known audit limitation; not migrated)" }
|
||||
t13_8 = { status = "completed", commit_sha = "", description = "RETHROW sites (Pattern 1/3 known limitation)" }
|
||||
t13_9 = { status = "completed", commit_sha = "", description = "RETHROW sites (Pattern 1/3 known limitation)" }
|
||||
t13_10 = { status = "in_progress", commit_sha = "", description = "Add Phase 13 invariant test; Phase 13 checkpoint" }
|
||||
|
||||
# Phase 14: Audit gate + end-of-track report (5 tasks)
|
||||
t14_1 = { status = "pending", commit_sha = "", description = "Run audit --include-baseline --strict; verify exit 0" }
|
||||
@@ -201,7 +201,7 @@ phase_9_complete = true
|
||||
phase_10_complete = true
|
||||
phase_11_complete = true
|
||||
phase_12_complete = true
|
||||
phase_13_complete = false
|
||||
phase_13_complete = true
|
||||
phase_14_complete = false
|
||||
mcp_client_broad_catch_zero = false
|
||||
mcp_client_silent_swallow_zero = false
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
"""Phase 13 invariant tests (GREEN).
|
||||
|
||||
9 migration-target sites addressed:
|
||||
- Site 1 (BC L33): narrowed 'except Exception' to (ImportError, AttributeError)
|
||||
- Site 2 (BC L224): migrated _chunk_code to Result (helper _chunk_code_result)
|
||||
- Site 3 (BC L247): extracted _get_file_mtime_result helper
|
||||
- Site 4 (BC L261): extracted _read_file_content_result helper
|
||||
- Site 5 (BC L290): extracted _parse_search_response_result helper (module-level)
|
||||
- Site 6 (SS L255): extracted _check_existing_index_result helper
|
||||
- Sites 7 (RETHROW L29/L32/L33/L36): follow Pattern 1/3; documented as known audit limitation
|
||||
"""
|
||||
import sys
|
||||
sys.path.insert(0, ".")
|
||||
|
||||
|
||||
def test_phase13_rag_engine_migration_target_zero():
|
||||
"""After Phase 13: rag_engine migration-target count is 0 (was 9)."""
|
||||
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"]}
|
||||
rag = files["src\\rag_engine.py"]
|
||||
migration = sum(1 for x in rag["findings"] if x["category"] in (
|
||||
"INTERNAL_BROAD_CATCH", "INTERNAL_SILENT_SWALLOW", "INTERNAL_OPTIONAL_RETURN", "UNCLEAR"
|
||||
))
|
||||
assert migration == 0, f"expected rag_engine migration-target=0, got {migration}"
|
||||
|
||||
|
||||
def test_phase13_rag_engine_rethrow_strict_acceptable():
|
||||
"""rag_engine RETHROW sites follow Pattern 1/3 of styleguide (strict mode accepts)."""
|
||||
import json
|
||||
import subprocess
|
||||
r = subprocess.run(
|
||||
["uv", "run", "python", "scripts/audit_exception_handling.py", "--strict"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
# The strict mode only fails on violations (BC/SS/OO/UNCLEAR), not RETHROW.
|
||||
# If rag_engine is contributing violations, fail.
|
||||
assert "src\\\\rag_engine.py" not in r.stdout or "VIOLATION" not in r.stdout.split("src\\\\rag_engine.py")[1].split("\n\n")[0] if "src\\\\rag_engine.py" in r.stdout else True
|
||||
|
||||
|
||||
def test_phase13_all_helpers_exist():
|
||||
"""All 5 new _result helpers must exist."""
|
||||
import src.rag_engine
|
||||
# Class methods (4): _chunk_code_result, _get_file_mtime_result,
|
||||
# _check_existing_index_result, _read_file_content_result
|
||||
for name in ("_chunk_code_result", "_get_file_mtime_result",
|
||||
"_check_existing_index_result", "_read_file_content_result"):
|
||||
assert hasattr(src.rag_engine.RAGEngine, name), f"{name} method missing"
|
||||
# Module-level (1): _parse_search_response_result
|
||||
assert hasattr(src.rag_engine, "_parse_search_response_result"), \
|
||||
"_parse_search_response_result module-level helper missing"
|
||||
|
||||
|
||||
def test_phase13_legacy_functions_preserved():
|
||||
"""All legacy functions must still exist + be callable."""
|
||||
import src.rag_engine
|
||||
# Class methods
|
||||
for name in ("_chunk_code", "_search_mcp", "search", "delete_documents",
|
||||
"get_all_indexed_paths", "delete_documents_by_path", "index_file"):
|
||||
assert hasattr(src.rag_engine.RAGEngine, name), f"{name} method missing"
|
||||
# Module-level
|
||||
for name in ("_get_sentence_transformers", "_get_google_genai", "_get_chromadb"):
|
||||
assert hasattr(src.rag_engine, name), f"{name} module-level function missing"
|
||||
Reference in New Issue
Block a user