c5a119d63f
Phase 4 (5 of 9 cruft sites obliterated): OBLITERATED wrappers: 1. _reread_file_items (4 callers in _send_gemini + _send_gemini_cli + 2 others) 2. _list_anthropic_models (1 caller in list_models) 3. _list_gemini_models (1 caller in list_models) 4. _extract_gemini_thoughts (1 caller in _send_gemini) 5. _list_minimax_models (2 callers in _set_minimax_provider_result + set_provider) Migration: each caller now uses the _result sibling directly with .ok check + .data extraction. The Result[T] error context (structured ErrorInfo) is now propagated instead of dropped. _send_gemini gets .data with explicit .ok check. Updated tests to assert OBLITERATED state (5 sub-track 5 tests inverted from '_legacy_preserved' to '_legacy_obliterated'): - tests/test_baseline_result.py: test_phase9_redo_modules_import_cleanly - tests/tier2/phase10_invariant_test.py: _list_gemini_models removed from list - tests/tier2/phase10_site1_test.py: _legacy_unchanged -> _legacy_obliterated - tests/tier2/phase11_invariant_test.py: _extract/_list_minimax moved to obliterated - tests/tier2/phase11_sites78_test.py: _legacy_preserved -> _legacy_obliterated - tests/tier2/phase12_invariant_test.py: _list_anthropic moved to obliterated - tests/tier2/phase12_site4_test.py: _legacy_preserved -> _legacy_obliterated - tests/test_gemini_thinking_format.py: helper uses _result directly - tests/test_cruft_removal.py: 5 new obliterated-wrappers invariant tests Test result: 122/122 pass (31 baseline + 16 heuristic + 9 cruft + 5 thinking + 61 tier2). Audit gate: src/ai_client.py --strict exits 0 (no new violations introduced). Wrapper count: 9 -> 3 (Phase 5-6 remaining: rag_engine 1, gui_2 2).
57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
"""Phase 11 sites 7+8: _extract_gemini_thoughts + _list_minimax_models Result helpers.
|
|
|
|
Site 7 (_extract_gemini_thoughts):
|
|
try: candidates = getattr(resp, "candidates", None) or []
|
|
for ... parts = getattr(content, "parts", None) or []
|
|
... if thought: chunks.append(p.text)
|
|
except Exception: pass
|
|
return "".join(chunks).strip()
|
|
|
|
Body: pass + empty default '' = SS violation (silent + data loss).
|
|
|
|
Site 8 (_list_minimax_models):
|
|
try: client = OpenAI(api_key=api_key, base_url=base_url)
|
|
models_list = client.models.list()
|
|
found = [m.id for m in models_list]
|
|
if found: return sorted(found)
|
|
except Exception: pass
|
|
return ["MiniMax-M2.7", "MiniMax-M2.5", "MiniMax-M2.1", "MiniMax-M2"]
|
|
|
|
Body: pass + hardcoded default = SS violation.
|
|
"""
|
|
import sys
|
|
sys.path.insert(0, ".")
|
|
|
|
|
|
def test_phase11_sites78_extract_gemini_thoughts_result_exists():
|
|
import src.ai_client
|
|
assert hasattr(src.ai_client, "_extract_gemini_thoughts_result"), \
|
|
"_extract_gemini_thoughts_result helper missing"
|
|
|
|
|
|
def test_phase11_sites78_list_minimax_models_result_exists():
|
|
import src.ai_client
|
|
assert hasattr(src.ai_client, "_list_minimax_models_result"), \
|
|
"_list_minimax_models_result helper missing"
|
|
|
|
|
|
def test_phase11_sites78_helpers_return_result():
|
|
import src.ai_client
|
|
import inspect
|
|
for name in ("_extract_gemini_thoughts_result",
|
|
"_list_minimax_models_result"):
|
|
fn = getattr(src.ai_client, name)
|
|
sig = inspect.signature(fn)
|
|
assert "Result" in str(sig.return_annotation), \
|
|
f"{name} return must be Result, got {sig.return_annotation}"
|
|
|
|
|
|
def test_phase11_sites78_legacy_obliterated():
|
|
"""Legacy wrappers OBLITERATED (cruft-removal Phase 4)."""
|
|
import src.ai_client
|
|
assert not hasattr(src.ai_client, "_extract_gemini_thoughts"), (
|
|
"_extract_gemini_thoughts legacy wrapper must be DELETED."
|
|
)
|
|
assert not hasattr(src.ai_client, "_list_minimax_models"), (
|
|
"_list_minimax_models legacy wrapper must be DELETED."
|
|
) |