Repository navigation
feat: Fleet Intelligence & Model Lifecycle Management (F19/F20) - #201
Merged
Merged
Conversation
Implement RFC-001 Phase 3: Fleet Intelligence and Model Lifecycle Management.
Model Lifecycle (F20):
- POST /v1/models/load — trigger model load with VRAM validation
- DELETE /v1/models/{id} — graceful unload with active request protection
- POST /v1/models/migrate — coordinated migration (zero request drops)
- LifecycleReconciler filters loading backends from routing pipeline
- OllamaAgent: load_model (POST /api/pull), unload_model (keep_alive=0),
resource_usage (GET /api/ps)
- Operation tracking, timeout detection, health checker integration
Fleet Intelligence (F19):
- FleetReconciler: background pattern analysis (not in hot path)
- Request history tracking per model (DashMap, 30-day retention)
- Time-of-day pattern detection with peak-to-average ratio analysis
- Model popularity trend analysis (7-day window comparison)
- Confidence scoring (0.0-1.0) based on pattern strength and sample size
- VRAM headroom checking, hot model protection
- GET /v1/fleet/recommendations — advisory-only recommendations
- Background analysis loop with configurable interval
- Suggestion-first: never auto-executes, operator approval required
Configuration:
- [lifecycle] section: timeout_ms, vram_headroom_percent, vram_buffer_percent
- [fleet] section: enabled, min_sample_days, min_request_count,
analysis_interval_seconds, max_recommendations
Tests: 15 new fleet intelligence unit tests, 22+ lifecycle tests
All 1287 tests pass, clippy clean.
Closes #194
Closes #195
Closes #196
Closes #197
Closes #198
Closes #199
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- T089a: Add X-Nexus-Lifecycle-Status and X-Nexus-Lifecycle-Operation response headers to all lifecycle API endpoints - T089b: Add Retry-After header to 503 responses when all backends are in Loading state (LifecycleReconciler rejections) - T082/T083: Add lifecycle API documentation (docs/api/lifecycle.md) - T091: Update README.md with Fleet Intelligence feature highlights - T084: Validated routing latency <1ms via benchmarks (6-160µs) - T087: All 1287 tests pass, clippy clean Closes #200 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…19/F20) - Fill out verification.md: 143 pass, 67 N/A, 0 unchecked - Create walkthrough.md with architecture, decisions, test summary - Fix 2 unwrap() calls in fleet.rs → let-else pattern (safer) - Update spec.md status to Implemented - Check off verified performance criteria in tasks.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix memory leak: record_request() skips when fleet disabled (Issue 1) - Fix TOCTOU race: set operation BEFORE load_model/migrate (Issue 2, 4) - Fix VRAM heuristic: make threshold configurable via vram_heuristic_max_gb (Issue 3) - Migration rollback: clear both operations on load_model failure (Issue 4) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…9/F20 - roadmap.md: Mark F19/F20/Phase 3 as Complete with spec links - docs/api/rest.md: Add lifecycle endpoints to quick reference - copilot-instructions.md: Add lifecycle routes, reconciler modules, update v0.5 status Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Ship Model Lifecycle Management (F20) and Pre-warming & Fleet Intelligence (F19) — RFC-001 Phase 3.
Enables Nexus to control model loading/unloading across the fleet and predict demand for proactive model placement.
What Changed
New API Endpoints
POST /v1/models/load— Load model on specific backendDELETE /v1/models/{id}— Unload model from specific backendPOST /v1/models/migrate— Coordinated migration (load on target, operator unloads source)GET /v1/fleet/recommendations— Pre-warming recommendations based on request patternsNew Modules
src/api/lifecycle.rs— HTTP handlers with X-Nexus-Lifecycle-Status headerssrc/routing/reconciler/fleet.rs— Background pattern analysis, 15 unit testssrc/routing/reconciler/lifecycle.rs— Routing filter for loading backends, 11 unit testssrc/config/lifecycle.rs/src/config/fleet.rs— Configuration typesOllama NII Implementation
load_model()→ POST /api/pullunload_model()→ POST /api/generate (keep_alive=0)resource_usage()→ GET /api/ps (VRAM tracking)Key Design Decisions
Verification
Red Team Review
Verdict: [PASS] (after fixes)
Initial review found 4 issues, all fixed in commit
6cda049:record_request()grew unbounded when fleet disabledif !self.config.enabled { return; }guardupdate_operation()set afterload_model()Nonefor total VRAMvram_heuristic_max_gbload_model(); rollback both on failureRe-review confirmed all fixes correct, no new issues introduced.
Configuration
Spec & Docs
specs/022-fleet-intelligence-model-lifecycle/docs/api/lifecycle.mdspecs/022-fleet-intelligence-model-lifecycle/walkthrough.mdCloses #194
Closes #195
Closes #196
Closes #197
Closes #198
Closes #199
Closes #200