Private
Public Access
0
0
Files
manual_slop/tests
ed 8c4791d03f fix(ai_client,module_loader): pre-existing bugs surfaced by Phase 3 refactor
Three test failures identified by the batched test suite, all rooted
in the Phase 3 lazy-import refactor of src/ai_client.py.

FIX 1: UnboundLocalError in _ensure_gemini_client
- _ensure_gemini_client had a latent bug: creds was assigned inside
  `if _gemini_client is None:` but used on the next line. When the
  client was already cached, the assignment was skipped and the next
  line raised UnboundLocalError. Moved the Client() construction
  inside the if block to match creds' scope.
- This affected test_ai_cache_tracking.py and (downstream)
  test_gui_updates.py::test_telemetry_data_updates_correctly.

FIX 2: Phase 3 removed top-level `import requests` from ai_client.py.
- test_discussion_compression.py::test_discussion_compression_deepseek
  did `patch("src.ai_client.requests.post", ...)` which no longer works.
- Updated the test to mock _require_warmed to return a fake requests
  module with `.post()`, matching the new lazy-import pattern.

FIX 3: _require_warmed could not import dotted names like `google.genai.types`
- The google-genai library has a self-referential __init__.py that
  does `from .client import Client` which transitively does
  `from .types import HttpOptions`. Importing `google.genai.types`
  FIRST (before the parent package is fully loaded) hit a "partially
  initialized module" circular import.
- Enhanced _require_warmed to pre-import parent packages for dotted
  names: walks `name.split(".")` and imports each parent (if not in
  sys.modules) before the leaf import. O(n) extra imports per call
  on first use; subsequent calls are O(1) sys.modules hit.

TESTS:
- test_ai_cache_tracking.py: 2/2 PASS
- test_discussion_compression.py: 4/4 PASS
- 29/29 PASS across the sampled test files that were failing
  (test_subagent_summarization, test_tool_access_exclusion,
  test_tier4_interceptor, test_gui2_mcp, test_gui_updates,
  test_headless_service)

ARCHITECTURAL NOTE: The _require_warmed enhancement is a small
but important robustness fix. The google-genai library's
__init__.py chain is a known source of fragility; the parent-
pre-import pattern is the recommended workaround.
2026-06-06 18:30:44 -04:00
..
2026-03-05 17:13:59 -05:00
2026-05-10 15:14:54 -04:00
2026-05-20 07:51:58 -04:00
2026-03-05 16:37:30 -05:00
2026-03-05 17:13:59 -05:00
2026-03-05 16:37:30 -05:00
2026-03-07 20:32:59 -05:00
2026-03-06 22:03:59 -05:00
2026-03-05 17:13:59 -05:00
2026-03-12 19:08:51 -04:00
2026-03-05 15:10:53 -05:00
2026-03-12 19:08:51 -04:00
2026-03-12 19:08:51 -04:00
2026-05-20 07:51:58 -04:00
2026-05-20 07:51:58 -04:00
ok
2026-03-07 21:40:40 -05:00