feat(core-ai): add safe local runtime preloader#421
Merged
Conversation
- add residency policy and manager primitives for safe local runtime loading - add a global preloader with abort, generation gating, and no-eviction background warmup - wire chat startup through the shared preloader instead of ad hoc Gemini/LiteRT warmups - add focused policy, preloader, service, and widget coverage This centralizes local runtime warmup so first-use latency can improve without surprise evictions or duplicated startup logic.
Plugin Module Size GatePolicy: modules over 3 MB must be delivered as plugins; plugin modules over 5 MB must document cache management.
|
|
🚀 PR Quick Check Summary
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
This PR introduces changes to the local runtime orchestration layer.
Goal: centralize safe local model warmup so chat startup can reduce first-use latency without background evictions or duplicated runtime-specific startup logic.
Core outcome:
Changes
Code
packages/core_ai/lib/src/residency/model_residency_manager.dartpackages/core_ai/lib/src/preload/model_preloader.dartapp/lib/core/services/local_runtime_preloader_service.dartpackages/core_ai/lib/core_ai.dartexports for the new shared runtime orchestration primitivesapp/lib/features/agent_chat/presentation/screens/chat_screen.dartto trigger shared preload asynchronously and abort when the screen is disposed or generation startsLogic
canLoadWithoutEvictionbefore warming a runtimemakeRoomFor,ensureResident, andrunExclusivethrough the shared managerAPI Changes (if any)
Database Changes (if any)
Observability / Logging
Performance Impact
Risks
Testing
cd packages/core_ai && flutter analyze lib/core_ai.dart lib/src/residency/model_residency_manager.dart lib/src/preload/model_preloader.dart test/residency/model_residency_manager_test.dart test/preload/model_preloader_test.dartcd packages/core_ai && flutter test test/residency/model_residency_manager_test.dart test/preload/model_preloader_test.dartcd app && flutter analyze lib/core/services/local_runtime_preloader_service.dart lib/features/agent_chat/presentation/screens/chat_screen.dart test/core/services/local_runtime_preloader_service_test.dart test/features/agent_chat/presentation/screens/chat_screen_preloader_test.dartcd app && flutter test --no-pub test/core/services/local_runtime_preloader_service_test.dart test/features/agent_chat/presentation/screens/chat_screen_preloader_test.dartDeployment Notes
Related Commits
feat(core-ai): add safe local runtime preloaderNotes