Private
Public Access
0
0
Files
manual_slop/tests/tier2/phase10_site5_test.py
T
ed 1b03c280a9 refactor(ai_client): extract _create_gemini_cache_result helper (Phase 10 site 5)
Site L1773: cache.create block in _send_gemini had multiple global side
effects (sets _gemini_cache, _gemini_cache_created_at, _gemini_cached_file_paths,
returns chat_config with cached_content). Except body reset globals on failure.

Per TIER1_REVIEW: logging is NOT a drain. MIGRATE to Result[Any].

New helper _create_gemini_cache_result(sys_instr, tools_decl, file_items) -> Result[Any]:
- Returns Result(data=chat_config) on SDK success (sets globals, logs [CACHE CREATED])
- Returns Result(data=None, errors=[ErrorInfo]) on SDK failure (resets globals,
  logs [CACHE FAILED])
- Preserves original semantics: globals set on success, reset on failure

Caller:
  cached_config_result = _create_gemini_cache_result(sys_instr, tools_decl, file_items)
  if cached_config_result.ok:
      chat_config = cached_config_result.data

Audit: ai_client BC 5 -> 4. _send_gemini cache-related BC sites all migrated.
2026-06-20 13:05:48 -04:00

18 lines
641 B
Python

"""Phase 10 site 5: _create_gemini_cache_result helper."""
import sys
sys.path.insert(0, ".")
def test_phase10_site5_create_gemini_cache_result_exists():
import src.ai_client
assert hasattr(src.ai_client, "_create_gemini_cache_result"), \
"_create_gemini_cache_result helper missing"
def test_phase10_site5_create_gemini_cache_result_returns_result():
import src.ai_client
import inspect
fn = src.ai_client._create_gemini_cache_result
sig = inspect.signature(fn)
assert "Result" in str(sig.return_annotation), \
f"_create_gemini_cache_result return must be Result, got {sig.return_annotation}"