Repository navigation
[Unified Routing] Outstanding Tasks and Future Enhancements #554
Copy link
Copy link
Closed
Description
Overview
This issue tracks outstanding tasks and future enhancements for the unified routing system (terraphim_router + terraphim_spawner).
Completed
- terraphim_router crate with capability-based routing
- 4 routing strategies (CostOptimized, LatencyOptimized, CapabilityFirst, RoundRobin)
- ProviderRegistry with Markdown/YAML frontmatter support
- terraphim_spawner crate for agent process management
- Health checking with 30s heartbeat
- Output capture with @mention detection
- @mention routing for decentralized coordination
- FallbackRouter with 4 fallback strategies
- RouterMetrics for observability
- KnowledgeGraphRouter for smart routing
- Comprehensive integration tests
- Examples (basic + advanced)
- Documentation
High Priority -- DONE (PR #556)
1. terraphim_persistence Integration
- PersistedProviderRegistry with Persistable trait
- Feature-gated behind
persistencefeature - Write-through persistence to DeviceStorage
- 7 persistence tests with real DeviceStorage (memory backend)
2. OpenTelemetry Integration
- Replace
logwithtracingfor structured spans - Privacy helpers (prompt_preview, prompt_hash)
- Spans on routing engine, fallback router, all strategies
- OTel export feature-gated for future use
3. terraphim_llm_proxy Integration
- RouterBridgeLlmClient connecting router to LlmClient execution
- Capability-based provider selection (Ollama, OpenRouter)
- Single-provider optimization (skip routing overhead)
- 11 bridge tests covering strategy mapping, routing, fallback
- Removed dead RoutedLlmClient pass-through wrapper
Medium Priority -- DONE (PR #556)
4. Dynamic Strategy Selection
- Context-aware strategy selection via RoutingContext.strategy_override
- PreferenceFilter for cost/latency constraints
- WeightedStrategy for deterministic A/B testing
- StrategyRegistry with factory pattern for named lookup
- 11 new strategy tests
5. Advanced Health Checking
- CircuitBreaker with Closed/Open/HalfOpen state machine
- CircuitBreakerConfig (failure_threshold, cooldown, success_threshold)
- HealthHistory with sliding window and success rate calculation
- Degraded health status for gradual degradation detection
- 15 new circuit breaker and health history tests
6. Agent Lifecycle Management
- Graceful shutdown (SIGTERM -> grace period -> SIGKILL)
- Non-blocking try_wait() for exit status polling
- AgentPool with checkout/release/drain semantics
- Configurable max restart attempts
- 5 new lifecycle tests
Low Priority -- DONE (branch feat/router-tracing)
7. WebSocket Support for Agents
- Broadcast channel (capacity 256) for live agent output streaming
-
subscribe_output()on AgentHandle for callers - WebSocket server endpoint (future terraphim_server task)
- Browser-based agent UI
8. Provider Discovery
- Dynamic provider registration with RegistryEvent notifications
- File-watching hot-reload via
notify(feature-gated:file-watch) - 500ms debounced reload, optional change notifications
- mDNS/Bonjour discovery (deferred -- too heavyweight)
- Service mesh / load balancer integration
9. Security Hardening
- ResourceLimits (memory, CPU, file size, open files) via rlimit
- Structured audit events via tracing target
- Full sandboxing via terraphim_firecracker (sub-2s boot, VM pooling)
- Secret management integration
Technical Debt -- DONE (branch feat/router-tracing)
Code Quality
- Property-based tests (proptest) for strategies, keywords, circuit breaker
- Criterion benchmarks for routing performance
- Spawner migrated from log to tracing
- Dead code warnings resolved (accessors added)
- Extract common traits between Router and Spawner
- Unify error types across crates
Related PRs
- feat: Add terraphim_router crate for unified LLM and Agent routing #553 - Initial unified routing implementation
- fix(terraphim_router): fix compilation errors in router and examples #555 - Compilation fixes for router and spawner
- feat: complete unified routing system (tasks 1-9 + technical debt) #556 - High-priority + medium-priority tasks (tracing, persistence, LLM bridge, dynamic strategy, health checking, lifecycle)
Milestone
v2.0 Unified Routing Release
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat(terraphim_router): replace log with tracing for structured obser…
feat(terraphim_router): add feature-gated persistence for ProviderReg…
AlexMikhalev commentedon Feb 22, 2026
Low-Priority Tasks + Technical Debt -- DONE (branch
feat/router-tracing)6 additional commits pushed covering all remaining items:
Commit A: Cleanup and Tracing Migration (
d9d410b6)terraphim_spawnerfromlogtotracingwith structured fieldsoutput_capture()accessor andinfo_span!("spawner.spawn")source_path()accessor andremove_provider()toProviderRegistryCommit B: Security Hardening (
261afa39)ResourceLimitsstruct (max_memory_bytes, max_cpu_seconds, max_file_size_bytes, max_open_files)pre_exechook usingnix::sys::resource::setrlimit(unix-only)AuditEventenum with structured audit logging viatracing::info!(target: "terraphim_spawner::audit", ...)terraphim_firecracker(sub-2s boot, VM pooling)Commit C: WebSocket Support (
cdaedb4d)broadcast::Sender<OutputEvent>(capacity 256) for live agent output streamingsubscribe_output()onAgentHandlefor callers to receive eventsterraphim_servertaskCommit D: Provider Discovery (
2c33faaa)RegistryEventenum (ProviderAdded, ProviderRemoved, ProvidersReloaded) via broadcast channelProviderDirectoryWatcherusingnotifyfor hot-reload (feature-gated:file-watch)Commit E: Property-Based Tests (
3f3f9dd7)proptestfor strategy invariants (cost/latency selection correctness, round-robin cycling)Commit F: Benchmarks (
e7959f25)keyword_extraction,strategy_selection,full_routingcargo bench --bench routing_bench -p terraphim_routerTest Summary
Remaining Future Work
feat: complete unified routing system (tasks 1-9 + technical debt) (#556
feat: complete unified routing system (tasks 1-9 + technical debt) (#556