conductor(plan): Mark Phase 3 complete - ai_client SDK import removal done

This commit is contained in:
ed
2026-06-06 16:11:14 -04:00
parent 51c054ece8
commit 8905c26bff
3 changed files with 15 additions and 26 deletions
@@ -49,26 +49,15 @@ which puts the main thread in the import chain. Phase 3 removes these and
swaps to `_require_warmed(name)`.
- [x] **T3.1 (Red)** Write `tests/test_ai_client_no_top_level_sdk_imports.py` (9 tests, all currently FAILING). `[T3.1: 16780ec6]`
- [ ] **T3.2 (Green)** In `src/ai_client.py`**HOLDING pending MCP client fix (per user instruction)**. Steps:
- Add `import importlib` at top
- Remove `import anthropic`, `from google import genai`, `from openai import OpenAI`, `from google.genai import types`, `import requests` from top
- Add `_require_warmed(name)` helper: returns `sys.modules[name]` (with importlib fallback for tests)
- Each of the 18 functions that uses heavy modules gets a local lookup at its first executable statement:
`_classify_anthropic_error`, `_classify_deepseek_error`, `_classify_minimax_error`,
`_gemini_tool_declaration`, `_list_anthropic_models`, `_ensure_anthropic_client`,
`_send_anthropic`, `_list_gemini_models`, `_ensure_gemini_client`, `_send_gemini`,
`_send_deepseek`, `_list_minimax_models`, `_ensure_minimax_client`, `_send_minimax`,
`run_tier4_analysis`, `run_tier4_patch_generation`, `run_subagent_summarization`,
`run_discussion_compression`
- Use MCP `py_update_definition` for each (preferred) OR native `edit` with surgical `old_string`/`new_string` (fallback)
- [ ] **T3.3** Run existing `tests/test_ai_client.py`; fix any breakage. Tests that relied on top-level import side effects need a fixture that warms the modules (or a fallback for test mode).
- [ ] **T3.4** Re-run T3.1 tests, confirm PASS
- [ ] **T3.5** Commit: `refactor(ai_client): remove top-level SDK imports; use _require_warmed` + git note
- [ ] **T3.6** Update `conductor/tracks.md` T3 row with SHA
- [x] **T3.2 (Green)** In `src/ai_client.py`completed 51c054ec. 5 top-level heavy SDK imports removed (`anthropic`, `google.genai`, `openai`, `google.genai.types`, `requests`). `_require_warmed(name)` helper added at top (returns `sys.modules[name]` with importlib fallback for tests). All 18 functions updated with local lookups at their first executable line. MCP `edit_file` used for `run_discussion_compression` (last one); previous 17 functions edited in prior session. `[T3.2: 51c054ec]`
- [x] **T3.3** Run existing `tests/test_ai_client.py` + `tests/test_tier4_*.py`; fix breakage. 2 tests in `test_tier4_patch_generation.py` adapted: `patch('src.ai_client.types')` -> `patch('src.ai_client._require_warmed', return_value=mock_types)` (the new public mechanism). All 25 tests pass. `[T3.3: 51c054ec]`
- [x] **T3.4** Re-run T3.1 tests, confirm PASS (9/9 green). `[T3.4: 51c054ec]`
- [x] **T3.5** Commit: `refactor(ai_client): remove top-level SDK imports; use _require_warmed` + git note. `[T3.5: 51c054ec]`
- [x] **T3.6** Update `conductor/tracks.md` T3 row with SHA. `[T3.6: <next-commit>]`
**Phase 3 status:** T3.1 done (RED committed, 9 failing tests). T3.2-T3.6 HOLDING for MCP client fix. When T3.2 lands, the RED tests turn GREEN.
**Phase 3 status:** All tasks complete. `import src.ai_client` no longer triggers any heavy SDK import. When run inside an `AppController` whose warmup has completed, `_send_*` functions find the SDKs in `sys.modules` and execute instantly. Cold-start baseline (T9.1) will measure the time saved.
**Phase 3 checkpoint (target):** `import src.ai_client` < 50ms cold. When run inside an `AppController` whose warmup has completed, `_send_*` functions find the SDKs in `sys.modules` and execute instantly.
**Phase 3 checkpoint (target):** `import src.ai_client` < 50ms cold.
---