diff --git a/conductor/tracks.md b/conductor/tracks.md index 6629b1c9..a979a665 100644 --- a/conductor/tracks.md +++ b/conductor/tracks.md @@ -149,7 +149,7 @@ User review surfaced five outstanding UI issues, each previously attempted witho ## Remaining Backlog (Phases 3 & 4) -0. [~] **Track: Sloppy.py Startup Speedup** `[track-created: cd4fb045]` +0. [~] **Track: Sloppy.py Startup Speedup** `[track-created: cd4fb045] [phase-3-done: 51c054ec]` *Link: [./tracks/startup_speedup_20260606/](./tracks/startup_speedup_20260606/), Spec: [./tracks/startup_speedup_20260606/spec.md](./tracks/startup_speedup_20260606/spec.md), Plan: [./tracks/startup_speedup_20260606/plan.md](./tracks/startup_speedup_20260606/plan.md)* 0c. [~] **Track: Test Batching Refactor** `[track-created: b7a97374]` diff --git a/conductor/tracks/startup_speedup_20260606/plan.md b/conductor/tracks/startup_speedup_20260606/plan.md index 711014f3..9f8e554d 100644 --- a/conductor/tracks/startup_speedup_20260606/plan.md +++ b/conductor/tracks/startup_speedup_20260606/plan.md @@ -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: ]` -**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. --- diff --git a/conductor/tracks/startup_speedup_20260606/state.toml b/conductor/tracks/startup_speedup_20260606/state.toml index b93a7603..ea7acf7d 100644 --- a/conductor/tracks/startup_speedup_20260606/state.toml +++ b/conductor/tracks/startup_speedup_20260606/state.toml @@ -5,13 +5,13 @@ track_id = "startup_speedup_20260606" name = "Sloppy.py Startup Speedup" status = "active" -current_phase = 2 +current_phase = 3 last_updated = "2026-06-07" [phases] phase_1 = { status = "completed", checkpoint_sha = "f9a01258", name = "Audit + Benchmark + Foundation" } phase_2 = { status = "completed", checkpoint_sha = "f9a01258", name = "Job Pool + Warmup Foundation" } -phase_3 = { status = "pending", checkpoint_sha = "", name = "Remove top-level SDK imports (ai_client)" } +phase_3 = { status = "completed", checkpoint_sha = "51c054ec", name = "Remove top-level SDK imports (ai_client)" } phase_4 = { status = "pending", checkpoint_sha = "", name = "Remove top-level FastAPI imports" } phase_5 = { status = "pending", checkpoint_sha = "", name = "Remove top-level feature-gated GUI imports" } phase_6 = { status = "pending", checkpoint_sha = "", name = "Migrate ad-hoc threads to _io_pool" } @@ -35,11 +35,11 @@ t2_5 = { status = "completed", commit_sha = "922c5ad9", description = "Wire _io_ t2_6 = { status = "in_progress", commit_sha = "", description = "Plan update (this commit)" } # Phase 3: Remove top-level SDK imports 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)" } +t3_2 = { status = "completed", commit_sha = "51c054ec", description = "Green: removed 5 top-level SDK imports from src/ai_client.py; added _require_warmed; 18 functions updated with local lookups" } +t3_3 = { status = "completed", commit_sha = "51c054ec", description = "Fixed existing test_tier4_patch_generation.py breakage (2 tests adapted to mock _require_warmed instead of types)" } +t3_4 = { status = "completed", commit_sha = "51c054ec", description = "Confirmed T3.1 tests turn PASS (9/9 green)" } +t3_5 = { status = "completed", commit_sha = "51c054ec", description = "Committed T3 refactor: refactor(ai_client): remove top-level SDK imports; use _require_warmed" } +t3_6 = { status = "in_progress", commit_sha = "", description = "Update tracks.md T3 row (in this commit)" } # 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" }