Private
Public Access
0
0
Commit Graph

2562 Commits

Author SHA1 Message Date
ed f2f5ee1197 conductor(plan): flip track from lazy-loading to proactive warmup
Architectural shift driven by user clarification: lazy-loading on first
use causes user-perceptible lag when the user-triggered action (e.g.
provider switch) propagates to a controller method that triggers the
first import. The fix is to pre-import heavy modules on a bg thread
at startup and have functions access them via _require_warmed().

Old design (rejected):
  - from google import genai inside _send_gemini (lazy on first call)
  - First user action that triggers this pays the cost; UI feels laggy

New design (this commit):
  - Top-level heavy imports REMOVED from main-thread-reachable files
  - AppController.__init__ submits warmup jobs to _io_pool (4 threads,
    named 'controller-io-N')
  - Each warmup worker imports its module and updates a thread-safe
    warmup_status dict
  - Functions access modules via _require_warmed(name), which assumes
    the module is in sys.modules (warmed at startup)
  - When all jobs complete, _warmup_done_event is set and registered
    on_warmup_complete callbacks fire
  - GUI shows status indicator + toast when warmup completes
  - Hook API exposes /api/warmup_status and /api/warmup_wait
  - Tests can call controller.wait_for_warmup() before exercising
    warmup-dependent functionality

Phase 2 now bundles job pool + warmup (T2.3+T2.4 add warmup tests +
implementation). Phases 3-5 do 'remove top-level imports' instead of
'lazy-load'. Phase 7 is the notification surface (Hook API + GUI).
Definition of Done includes warmup-completion criteria, the
'no function-body imports' check, and an end-to-end 'provider switch
is INSTANT' smoke test.

No code changes; this is a planning update only.
2026-06-06 13:45:05 -04:00
ed ca254bac41 fix(imports): break models<->dag_engine circular dependency
Track.get_executable_tickets (in models.py) called TrackDAG at
runtime, forcing a top-level import of src.dag_engine into models.py
and creating a 2-cycle that broke whichever module loaded second
(Ticket was not yet defined when models.py loaded first; TrackDAG
was not yet defined when dag_engine.py loaded first).

Fix: hoist the method out of the Track dataclass and into a free
function get_executable_tickets(track) in dag_engine.py. models.py
no longer needs TrackDAG at all, so the cycle is one-directional
(models -> dag_engine) and resolves cleanly in any import order.

Tests updated:
- tests/test_mma_models.py: import get_executable_tickets and call
  it instead of track.get_executable_tickets() (4 call sites)
- tests/test_conductor_engine_v2.py: comment update

Verified both import orders resolve cleanly:
  forward:  import src.models; import src.dag_engine  -> OK
  reverse:  import src.dag_engine; import src.models  -> OK
34 tests pass (test_mma_models, test_dag_engine, test_execution_engine,
test_arch_boundary_phase3, test_track_state_schema).
2026-06-06 13:30:18 -04:00
r00tz 9e4fac496d made local rag needs optional (prevents having to have torch / sentence-transformers if you never use local embedding) 2026-06-06 13:21:43 -04:00
ed 32e633b3ec conductor(plan): mark startup_speedup_20260606 track creation committed (cd4fb045) 2026-06-06 13:01:32 -04:00
ed cd4fb04541 conductor(track): create startup_speedup_20260606 track for sloppy.py startup latency
Fulfills the existing backlog entry at conductor/tracks.md:152
(2026-06-05 root-cause analysis of live_gui wait_for_server timeouts).

Main Thread Purity Invariant: the main thread (entering immapp.run())
must never import a module heavier than imgui_bundle and the lean
gui_2 skeleton. Enforced by:
  - static gate: scripts/audit_main_thread_imports.py (CI)
  - runtime hook: tests/test_main_thread_purity.py (sys.addaudithook)

Threading constraint: no new threading.Thread(...) calls in src/.
All background work goes through AppController._io_pool
(ThreadPoolExecutor, max_workers=4, thread_name_prefix='controller-io').

9 phases, 57 tasks: audit+baseline, job pool, lazy-load SDKs, lazy-load
FastAPI, lazy-load feature-gated GUI, migrate ad-hoc threads, runtime
enforcement, hook API + diagnostics, verify+checkpoint.

Expected savings: ~2000-2400ms off main-thread import cost.
Target: import src.ai_client < 50ms (from ~1800ms), live_gui fixtures
no longer time out at wait_for_server(timeout=15).
2026-06-06 12:57:20 -04:00
ed 2adf3274af add benchmark scriptr 2026-06-06 12:47:41 -04:00
ed 311fde9a8b fixes 2026-06-06 12:44:07 -04:00
ed 9ccaf0594c some org on ai_client 2026-06-06 11:35:20 -04:00
ed 9d72d98b50 conductor(tracks): mark rag_phase4_stress_test_flake resolved (commit 16412ad5) 2026-06-06 11:29:03 -04:00
ed 16412ad5f9 fix(rag): detect ChromaDB dim mismatch and recreate collection on provider switch 2026-06-06 11:26:47 -04:00
ed 339b062913 more organization 2026-06-06 11:08:07 -04:00
ed 7d555361f9 more organization 2026-06-06 10:24:22 -04:00
ed 1c627bcc30 fix(docs): correct section order in guide_testing (patterns before See Also) + fix LF/CRLF 2026-06-06 09:34:38 -04:00
ed 0f742b1d5f conductor(workflow): add Indentation-Driven Class Method Visibility pitfall (2026-06-05) 2026-06-06 02:04:05 -04:00
ed e276bac093 docs(gui_2): add __getattr__/__setattr__ delegation pattern + indentation gotcha 2026-06-06 01:59:20 -04:00
ed 4ee22dedb9 docs(testing): add Narrow Test Paths + Indentation-Driven Method Visibility patterns 2026-06-06 01:53:25 -04:00
ed e7b8877f2a docs(readme): update for v2 completion (24 guides, 273 test files, 98.9% pass rate) 2026-06-06 01:42:45 -04:00
ed 5e0b6bbfd3 conductor(tracks): queue RAG test flake as new backlog item; mark prior_session complete 2026-06-06 01:35:21 -04:00
ed 008179360f conductor(index): v2 recently shipped, all 4 live_gui failures resolved 2026-06-06 01:30:03 -04:00
ed 9a3831897b conductor(tracks): mark live_gui_test_hardening_v2 complete (root cause was indent, not state sync) 2026-06-06 01:28:02 -04:00
ed 26e0ced4d9 test(prior_session): refactor to narrow render_prior_session_view (50+ mocks -> 20) 2026-06-06 01:12:29 -04:00
ed 11f8772401 docs(spec): live_gui_state_sync — REAL root cause is bad indent in _capture_workspace_profile 2026-06-06 01:08:07 -04:00
ed c4691a54b0 fking python 2026-06-06 01:05:00 -04:00
ed 6c541bc788 move track mds to tracks 2026-06-06 00:42:40 -04:00
ed e670fc1c3e more org 2026-06-06 00:40:07 -04:00
ed 053f5d867a some organization pass, still need to review a bunch 2026-06-06 00:21:36 -04:00
ed f8b0a1243d add note aobut hook helpers... 2026-06-05 23:03:45 -04:00
ed 7785f09fa9 Some organizing of the api_hook_client.py 2026-06-05 23:02:41 -04:00
ed 5c23ad190d conductor(tracks): link v2 to 4 sub-track specs and plans 2026-06-05 22:56:55 -04:00
ed 3e52f20d16 docs(spec+plan): undo_redo_lifecycle_fix (3-phase investigation: state-sync vs snapshot vs flake) 2026-06-05 22:49:16 -04:00
ed b692353e98 docs(spec+plan): wait_for_ready_test_pattern (replace time.sleep with polling) 2026-06-05 22:45:14 -04:00
ed 85cd34683a docs(spec+plan): prior_session_test_harden (refactor to narrow render_prior_session_view) 2026-06-05 22:41:46 -04:00
ed 9542c4c750 docs(spec+plan): live-gui state sync (App/Controller single source of truth) 2026-06-05 22:36:55 -04:00
ed aa56981c87 organizing (mostly aggregate.py) 2026-06-05 22:34:26 -04:00
ed 8b83c5d0b7 conductor(index): v2 active, v1 + regression_fixes now in recently-shipped 2026-06-05 22:12:34 -04:00
ed 70c18f92c3 conductor(tracks): mark v1 fragility_fixes complete, queue v2 (state sync + undo_redo + prior_session) 2026-06-05 22:09:30 -04:00
ed 873edf42cf began to go through the files and organize imports and gui_2.py's new context defs
still a bunch to sift through after the last ai passes
2026-06-05 21:44:41 -04:00
ed 1d89fcaf8a update readme 2026-06-05 21:33:06 -04:00
ed ed98481578 update readme with note 2026-06-05 21:32:46 -04:00
ed 1488e71568 docs: add Sentinel type contract note to 3 defer-not-catch sections 2026-06-05 20:31:38 -04:00
ed 0e299140ca conductor(tracks): register live_gui_fragility_fixes + queue prior_session_test_harden follow-up 2026-06-05 20:17:11 -04:00
ed 5692cbef56 test(workspace_profile): add str/bytes TOML serialization contract test 2026-06-05 20:14:39 -04:00
ed cb206b973f docs(spec): defer Change 2 (prior_session test) to separate track; reason + follow-up 2026-06-05 20:12:33 -04:00
ed eb0bd39327 fix(gui_2): use str sentinel not bytes in _capture_workspace_profile 2026-06-05 19:24:12 -04:00
ed 7a0ed74b5c docs(plan): implementation plan for live-gui fragility fixes 2026-06-05 19:20:21 -04:00
ed f6d9c70de8 docs(spec): defer Change 4 doc hardening per user review 2026-06-05 19:15:50 -04:00
ed 0d6dd8dbab docs(spec): design for live-gui fragility fixes (272-file suite: 269/272 -> 272/272) 2026-06-05 19:05:35 -04:00
ed 449a827a82 conductor(tracks): queue sloppy.py startup speedup as new backlog item 2026-06-05 18:53:01 -04:00
ed 9467769260 docs(themes): rewrite authoring guide to match actual API + 8-shipped themes 2026-06-05 18:50:10 -04:00
ed dc691e3de0 docs(workflow): reframe live_gui fragility as authoring-side, not fixture bug 2026-06-05 18:43:58 -04:00