# Track state for startup_speedup_20260606 # Updated by Tier 2 Tech Lead as tasks complete [meta] track_id = "startup_speedup_20260606" name = "Sloppy.py Startup Speedup" status = "active" current_phase = 9 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 = "completed", checkpoint_sha = "51c054ec", name = "Remove top-level SDK imports (ai_client)" } phase_4 = { status = "completed", checkpoint_sha = "3849d304", name = "Remove top-level FastAPI imports (app_controller)" } phase_5 = { status = "completed", checkpoint_sha = "515a3029", name = "Remove top-level feature-gated GUI imports (5A, 5B, 5C, 5D)" } phase_6 = { status = "completed", checkpoint_sha = "85d18885", name = "Migrate ad-hoc threads to _io_pool (partial - log_pruner done)" } phase_7 = { status = "completed", checkpoint_sha = "b464d1fe", name = "Warmup Notification (Hook API + GUI) - minimal scope (diagnostics endpoint only)" } phase_8 = { status = "completed", checkpoint_sha = "61d21c70", name = "Enforcement: static main thread purity test" } phase_9 = { status = "in_progress", checkpoint_sha = "", name = "Verify + Checkpoint" } [tasks] # Phase 1: Audit + Benchmark + Foundation t1_1 = { status = "completed", commit_sha = "6f9a3af2", description = "Capture baseline benchmark to docs/reports/startup_baseline_20260606.txt" } t1_2 = { status = "completed", commit_sha = "6f9a3af2", description = "Write scripts/audit_gui2_imports.py + commit results to docs/reports/startup_audit_20260606.txt" } t1_3 = { status = "completed", commit_sha = "5a856536", description = "Add StartupProfiler (src/startup_profiler.py + 5 tests)" } t1_4 = { status = "completed", commit_sha = "6f9a3af2", description = "Write scripts/audit_main_thread_imports.py (static CI gate) + 9 tests" } t1_5 = { status = "in_progress", commit_sha = "", description = "Commit plan update (this commit)" } # Phase 2: Job Pool + Warmup Foundation t2_1 = { status = "completed", commit_sha = "1354679e", description = "Red: tests/test_io_pool.py (4 tests)" } t2_2 = { status = "completed", commit_sha = "1354679e", description = "Green: src/io_pool.py make_io_pool factory" } t2_3 = { status = "completed", commit_sha = "1354679e", description = "Red: tests/test_warmup.py (10 tests)" } t2_4 = { status = "completed", commit_sha = "1354679e", description = "Green: src/warmup.py WarmupManager class" } 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 = "completed", commit_sha = "16780ec6", description = "Red: tests/test_ai_client_no_top_level_sdk_imports.py (9 tests, all FAILING)" } 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 = "completed", commit_sha = "8905c26b", description = "Updated tracks.md T3 row with [phase-3-done: 51c054ec] tag" } # Phase 4: Remove top-level FastAPI imports t4_1 = { status = "completed", commit_sha = "3849d304", description = "Red: tests/test_app_controller_no_top_level_fastapi.py (4 tests, 3 of which were FAILING)" } t4_2 = { status = "completed", commit_sha = "3849d304", description = "Green: removed fastapi imports from src/app_controller.py; used _require_warmed in create_api() + 7 _api_* helpers; also lifted _require_warmed to src/module_loader.py" } t4_3 = { status = "completed", commit_sha = "3849d304", description = "No new breakage; pre-existing test_generate_endpoint failure in test_headless_service.py is google.genai circular import (not a regression)" } t4_4 = { status = "completed", commit_sha = "3849d304", description = "Confirmed T4.1 tests PASS (4/4 green); T3.1 tests still pass (9/9, re-export works)" } t4_5 = { status = "completed", commit_sha = "3849d304", description = "Committed: refactor(app_controller): remove top-level fastapi imports; lift _require_warmed to shared module" } # Phase 5: Remove top-level feature-gated GUI imports t5a_1 = { status = "completed", commit_sha = "78d3a1db", description = "Red: tests/test_commands_no_top_level_command_palette.py (4 tests, 3 were FAILING)" } t5a_2 = { status = "completed", commit_sha = "78d3a1db", description = "Green: refactored src/commands.py with _LazyCommandRegistry proxy that defers src.command_palette instantiation to first attribute access" } t5a_3 = { status = "completed", commit_sha = "78d3a1db", description = "No fixes needed; 13 unit + 7 live_gui tests pass transparently with lazy proxy" } t5a_4 = { status = "completed", commit_sha = "78d3a1db", description = "Committed T5A: refactor(commands): use lazy registry proxy" } t5b_1 = { status = "completed", commit_sha = "69d098ba", description = "Red: tests/test_theme_2_no_top_level_nerv.py (4 tests, all FAILING)" } t5b_2 = { status = "completed", commit_sha = "69d098ba", description = "Green: removed 3 top-level NERV imports + 3 module-level FX instantiations; added lookups in apply() NERV branch, ai_text_color(), render_post_fx()" } t5b_3 = { status = "completed", commit_sha = "69d098ba", description = "No fixes needed; 21 theme tests pass" } t5b_4 = { status = "completed", commit_sha = "69d098ba", description = "Committed T5B: refactor(theme_2): remove top-level NERV theme imports" } t5c_1 = { status = "completed", commit_sha = "48c96499", description = "Red: tests/test_markdown_helper_no_top_level_table.py (3 tests, all FAILING)" } t5c_2 = { status = "completed", commit_sha = "48c96499", description = "Green: removed top-level src.markdown_table import; added lookup in MarkdownRenderer.render()" } t5c_3 = { status = "completed", commit_sha = "48c96499", description = "No fixes needed; 24 markdown tests pass" } t5c_4 = { status = "completed", commit_sha = "48c96499", description = "Committed T5C: refactor(markdown_helper): remove top-level src.markdown_table import" } t5d_1 = { status = "completed", commit_sha = "de6b85d2", description = "Ran audit_gui2_imports.py; 51 module-level + 18 function-level imports; identified 2 dead imports + 2 feature-gated" } t5d_2 = { status = "completed", commit_sha = "de6b85d2", description = "Removed 2 dead imports (tomli_w, theme_nerv_fx); added _LazyModule proxy for numpy + tkinter" } t5d_3 = { status = "completed", commit_sha = "de6b85d2", description = "Ran 13 sampled gui tests; all PASS, no breakage" } t5d_4 = { status = "completed", commit_sha = "de6b85d2", description = "Committed T5D: refactor(gui_2): remove dead imports; lazy numpy/tkinter via _LazyModule proxy" } # Phase 6: Migrate ad-hoc threads (PARTIAL) t6_1 = { status = "completed", commit_sha = "85d18885", description = "Audited: 25 threading.Thread spawns in src/; identified 4 domain-specific (HookServer, WebSocket, WorkerPool, CPU monitor) and ~21 ad-hoc candidates" } t6_2 = { status = "completed", commit_sha = "85d18885", description = "PARTIAL: Migrated 2 log_pruner + 2 _handle_ask threads in app_controller.py. Added submit_io() helper. ~13 other ad-hoc threads remain (follow-up sub-track)" } t6_3 = { status = "completed", commit_sha = "85d18885", description = "Ran log + app_controller tests; 15/15 PASS" } t6_4 = { status = "completed", commit_sha = "85d18885", description = "Commit T6 partial" } # Phase 7: Warmup Notification (MINIMAL) t7a_1 = { status = "completed", commit_sha = "b464d1fe", description = "Skipped dedicated test - minimal scope used existing /api/gui/diagnostics endpoint" } t7a_2 = { status = "completed", commit_sha = "b464d1fe", description = "Added warmup_status field to existing /api/gui/diagnostics endpoint (no dedicated endpoints)" } t7a_3 = { status = "completed", commit_sha = "b464d1fe", description = "warmup_status auto-accessed via _get_app_attr fallback" } t7a_4 = { status = "completed", commit_sha = "b464d1fe", description = "Commit T7A" } t7b_1 = { status = "pending", commit_sha = "", description = "GUI status bar indicator - DEFERRED (out of scope for minimal Phase 7)" } t7b_2 = { status = "pending", commit_sha = "", description = "Toast notification on completion - DEFERRED" } t7b_3 = { status = "pending", commit_sha = "", description = "Docs - DEFERRED" } t7b_4 = { status = "pending", commit_sha = "", description = "Commit T7B - DEFERRED" } # Phase 8: Enforcement - Main Thread Purity t8_1 = { status = "completed", commit_sha = "61d21c70", description = "Static enforcement: tests/test_main_thread_purity.py with 7 AST-based tests for 6 refactored files" } t8_2 = { status = "completed", commit_sha = "61d21c70", description = "All 7 tests PASS; removed residual requests/tomli_w from app_controller.py" } t8_3 = { status = "pending", commit_sha = "", description = "CI wiring - DEFERRED (can be added by including test_main_thread_purity.py in default test run)" } t8_4 = { status = "completed", commit_sha = "61d21c70", description = "Commit T8" } # Phase 9: Verify + Checkpoint t9_1 = { status = "completed", commit_sha = "61d21c70", description = "Re-measured: import src.ai_client 161ms (was 1800ms; 91% reduction), import src.gui_2 341ms (was 1770ms; 81% reduction); total 3066ms saved on the 2 big files" } t9_2 = { status = "completed", commit_sha = "61d21c70", description = "Re-ran audit: 63 violations remaining (was 67 baseline; -4 net); all 6 refactored files contribute ZERO new violations" } t9_3 = { status = "completed", commit_sha = "61d21c70", description = "Ran test_warmup.py + test_io_pool.py: PASS" } t9_4 = { status = "completed", commit_sha = "61d21c70", description = "Ran test_main_thread_purity.py: 7/7 PASS" } t9_5 = { status = "completed", commit_sha = "b464d1fe", description = "Ran 7 live_gui tests (test_hooks, test_live_workflow, test_live_gui_integration_v2): all PASS" } t9_6 = { status = "pending", commit_sha = "", description = "Phase checkpoint commit (this commit)" } t9_7 = { status = "pending", commit_sha = "", description = "Update tracks.md; archive track" } [verification] baseline_ai_client_ms = 1800 after_ai_client_ms = 161 baseline_gui_2_ms = 1770 after_gui_2_ms = 341 baseline_app_controller_ms = 0 after_app_controller_ms = 317 warmup_completes_within_seconds = 10 warmup_modules_in_sys_modules = 9 provider_switch_latency_ms_after_warmup = 0 live_gui_passed = 7 live_gui_failed = 0 audit_main_thread_violations = 63 io_pool_max_workers = 4 io_pool_thread_name_prefix = "controller-io" new_threading_thread_calls = 0 function_body_heavy_imports = 0 refactored_files_clean = 6 tests_added = 35 tests_passing = 50 [ad_hoc_threads] # Filled in Phase 6 T6.1 audit # Format: {file = "src/foo.py", line = 42, current_target = "lambda", proposed_target = "controller.submit_io(...)"} [warmup_list] # Filled in Phase 2 T2.4 implementation google_genai = true anthropic = true openai = true requests = true src_command_palette = true src_theme_nerv = true src_theme_nerv_fx = true src_markdown_table = true numpy = true fastapi = "conditional" # only when enable_test_hooks or web_host fastapi_security_api_key = "conditional"