Private
Public Access
0
0

conductor(plan): mark T3.1 RED done; T3.2 holding for MCP fix (16780ec6)

This commit is contained in:
2026-06-06 15:16:02 -04:00
parent 16780ec6d4
commit 9eed60238a
2 changed files with 22 additions and 19 deletions
@@ -48,24 +48,27 @@ The current `src/ai_client.py` has `from google import genai` etc. at the top,
which puts the main thread in the import chain. Phase 3 removes these and
swaps to `_require_warmed(name)`.
- [ ] **T3.1 (Red)** Write `tests/test_ai_client_no_top_level_sdk_imports.py`:
- `test_ai_client_does_not_import_genai_at_module_level`: spawn fresh subprocess, `import src.ai_client`, assert `'google.genai' not in sys.modules` (warmup hasn't run in this subprocess)
- `test_ai_client_does_not_import_anthropic_at_module_level`
- `test_ai_client_does_not_import_openai_at_module_level`
- `test_ai_client_does_not_import_requests_at_module_level`
- Confirm tests FAIL (proves the imports are currently eager)
- [ ] **T3.2 (Green)** In `src/ai_client.py`:
- Add `import sys, importlib, threading` at top
- Remove `from google import genai`, `import anthropic`, `import openai`, `import requests` from top
- Add `_require_warmed(name)` helper: returns `sys.modules[name]` or raises `RuntimeError`
- Each `_send_*` function calls `_require_warmed("google.genai")` etc. instead of using the module directly
- Provider client globals stay as `None` until first `_send_*` initializes them via `_ensure_<provider>_client()` (extracted from current top-level logic, uses the warmed module)
- [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
**Phase 3 checkpoint:** `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 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 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.
---
@@ -34,12 +34,12 @@ t2_4 = { status = "completed", commit_sha = "1354679e", description = "Green: sr
t2_5 = { status = "completed", commit_sha = "922c5ad9", description = "Wire _io_pool + warmup into AppController.__init__ + 5 public delegation methods + io_pool shutdown" }
t2_6 = { status = "in_progress", commit_sha = "", description = "Plan update (this commit)" }
# Phase 3: Remove top-level SDK imports
t3_1 = { status = "pending", commit_sha = "", description = "Red: tests/test_ai_client_no_top_level_sdk_imports.py" }
t3_2 = { status = "pending", commit_sha = "", description = "Green: remove top-level SDK imports from src/ai_client.py; add _require_warmed helper; update _send_* to use it" }
t3_3 = { status = "pending", commit_sha = "", description = "Fix existing test_ai_client.py breakage" }
t3_4 = { status = "pending", commit_sha = "", description = "Confirm T3.1 tests PASS" }
t3_5 = { status = "pending", commit_sha = "", description = "Commit T3" }
t3_6 = { status = "pending", commit_sha = "", description = "Update tracks.md T3 row" }
t3_1 = { status = "completed", commit_sha = "16780ec6", description = "Red: tests/test_ai_client_no_top_level_sdk_imports.py (9 tests, all FAILING)" }
t3_2 = { status = "pending", commit_sha = "", description = "Green: HOLDING for MCP fix. Remove 5 top-level SDK imports from src/ai_client.py; add _require_warmed; add local lookups in 18 functions" }
t3_3 = { status = "pending", commit_sha = "", description = "Fix existing test_ai_client.py breakage (after T3.2 lands)" }
t3_4 = { status = "pending", commit_sha = "", description = "Confirm T3.1 tests turn PASS (after T3.2)" }
t3_5 = { status = "pending", commit_sha = "", description = "Commit T3 refactor (after T3.2-T3.4)" }
t3_6 = { status = "pending", commit_sha = "", description = "Update tracks.md T3 row (after T3.5)" }
# Phase 4: Remove top-level FastAPI imports
t4_1 = { status = "pending", commit_sha = "", description = "Red: tests/test_hook_server_no_top_level_fastapi.py" }
t4_2 = { status = "pending", commit_sha = "", description = "Green: remove fastapi imports from src/api_hooks.py; use _require_warmed" }