Private
Public Access
refactor(ai_client): extract _delete_gemini_cache_result helper (Phase 10 sites 2+3)
Sites L1680 (cache.delete on context change) and L1692 (cache.delete on
TTL expiry) had identical patterns:
try: _gemini_client.caches.delete(name=_gemini_cache.name)
except Exception as e: _append_comms('OUT', 'request', {'message': f'[CACHE DELETE WARN] {e}'})
Per TIER1_REVIEW: logging is NOT a drain. MIGRATE to Result[T].
Single helper _delete_gemini_cache_result() -> Result[None]:
- Returns Result(data=None) on success
- Returns Result(data=None, errors=[ErrorInfo]) on SDK failure + logs warning to comms
- Caller (_send_gemini) ignores errors (best-effort cleanup)
Audit: ai_client BC 8 -> 6. Both sites migrated.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""Phase 10 invariant tests (RED) — sites 2+3: _delete_gemini_cache_result.
|
||||
|
||||
Sites 2 (L1680) and 3 (L1692): both are
|
||||
try: _gemini_client.caches.delete(name=_gemini_cache.name)
|
||||
except Exception as e: _append_comms("OUT", "request", {"message": f"[CACHE DELETE WARN] {e}"})
|
||||
|
||||
Migrate via single helper _delete_gemini_cache_result() -> Result[None].
|
||||
"""
|
||||
import sys
|
||||
sys.path.insert(0, ".")
|
||||
|
||||
|
||||
def test_phase10_site23_delete_gemini_cache_result_exists():
|
||||
import src.ai_client
|
||||
assert hasattr(src.ai_client, "_delete_gemini_cache_result"), \
|
||||
"_delete_gemini_cache_result helper missing"
|
||||
|
||||
|
||||
def test_phase10_site23_delete_gemini_cache_result_returns_result():
|
||||
"""The helper must return Result[None]."""
|
||||
import src.ai_client
|
||||
import inspect
|
||||
fn = src.ai_client._delete_gemini_cache_result
|
||||
sig = inspect.signature(fn)
|
||||
assert "Result" in str(sig.return_annotation), \
|
||||
f"_delete_gemini_cache_result return must be Result, got {sig.return_annotation}"
|
||||
Reference in New Issue
Block a user