{ "track_id": "startup_speedup_20260606", "name": "Sloppy.py Startup Speedup", "initialized": "2026-06-06", "owner": "tier2-tech-lead", "priority": "high", "status": "active", "type": "refactor + performance", "scope": { "new_files": [ "src/startup_profiler.py", "scripts/audit_main_thread_imports.py", "scripts/audit_gui2_imports.py", "tests/test_ai_client_lazy_imports.py", "tests/test_hook_server_lazy_fastapi.py", "tests/test_app_controller_io_pool.py", "tests/test_command_palette_lazy.py", "tests/test_theme_nerv_lazy.py", "tests/test_markdown_helper_lazy.py", "tests/test_main_thread_purity.py", "tests/test_startup_profiler.py", "tests/test_io_pool_endpoint.py" ], "modified_files": [ "src/ai_client.py", "src/api_hooks.py", "src/app_controller.py", "src/commands.py", "src/command_palette.py", "src/theme_2.py", "src/theme_nerv.py", "src/theme_nerv_fx.py", "src/markdown_helper.py", "src/markdown_table.py", "src/gui_2.py", "src/log_pruner.py", "src/project_manager.py" ] }, "blocked_by": [], "blocks": [], "estimated_phases": 9, "spec": "spec.md", "plan": "plan.md", "architectural_invariant": "The main thread (the one that enters immapp.run()) must NEVER import a module heavier than imgui_bundle and the lean gui_2 skeleton. Enforced by scripts/audit_main_thread_imports.py (static CI gate) and tests/test_main_thread_purity.py (runtime audit-hook test).", "threading_constraint": "NO new threading.Thread(...) calls in src/. All background work must go through AppController._io_pool (ThreadPoolExecutor, max_workers=4, thread_name_prefix='controller-io').", "verification_criteria": [ "import src.ai_client < 50ms cold start (from ~1800ms)", "import src.gui_2 < 500ms cold start (from ~3000ms)", "import src.app_controller < 300ms cold start (from ~700ms)", "uv run sloppy.py --enable-test-hooks reaches immapp.run() in < 1.5s", "live_gui.wait_for_server(timeout=15) passes for all tests", "scripts/audit_main_thread_imports.py exits 0 (no main-thread heavy imports)", "tests/test_main_thread_purity.py passes (runtime audit hook confirms invariant)", "No regressions in 273+ existing tests", "ZERO new threading.Thread(...) calls in src/ (after Phase 6 migration)", "Startup profile + io_pool status visible via /api/startup_profile and /api/io_pool_status" ], "links": { "backlog_entry": "conductor/tracks.md:152", "benchmark_script": "scripts/benchmark_imports.py", "audit_script": "scripts/audit_main_thread_imports.py", "related_docs": [ "docs/guide_architecture.md", "docs/guide_app_controller.md", "docs/guide_hot_reload.md", "docs/guide_testing.md" ] } }