feat: Phase 5.3 - Multi-Agent Learning Infrastructure
Implement intelligent agent learning from Knowledge Graph execution history
with per-task-type expertise tracking, recency bias, and learning curves.
## Phase 5.3 Implementation
### Learning Infrastructure (✅ Complete)
- LearningProfileService with per-task-type expertise metrics
- TaskTypeExpertise model tracking success_rate, confidence, learning curves
- Recency bias weighting: recent 7 days weighted 3x higher (exponential decay)
- Confidence scoring prevents overfitting: min(1.0, executions / 20)
- Learning curves computed from daily execution windows
### Agent Scoring Service (✅ Complete)
- Unified AgentScore combining SwarmCoordinator + learning profiles
- Scoring formula: 0.3*base + 0.5*expertise + 0.2*confidence
- Rank agents by combined score for intelligent assignment
- Support for recency-biased scoring (recent_success_rate)
- Methods: rank_agents, select_best, rank_agents_with_recency
### KG Integration (✅ Complete)
- KGPersistence::get_executions_for_task_type() - query by agent + task type
- KGPersistence::get_agent_executions() - all executions for agent
- Coordinator::load_learning_profile_from_kg() - core KG→Learning integration
- Coordinator::load_all_learning_profiles() - batch load for multiple agents
- Convert PersistedExecution → ExecutionData for learning calculations
### Agent Assignment Integration (✅ Complete)
- AgentCoordinator uses learning profiles for task assignment
- extract_task_type() infers task type from title/description
- assign_task() scores candidates using AgentScoringService
- Fallback to load-based selection if no learning data available
- Learning profiles stored in coordinator.learning_profiles RwLock
### Profile Adapter Enhancements (✅ Complete)
- create_learning_profile() - initialize empty profiles
- add_task_type_expertise() - set task-type expertise
- update_profile_with_learning() - update swarm profiles from learning
## Files Modified
### vapora-knowledge-graph/src/persistence.rs (+30 lines)
- get_executions_for_task_type(agent_id, task_type, limit)
- get_agent_executions(agent_id, limit)
### vapora-agents/src/coordinator.rs (+100 lines)
- load_learning_profile_from_kg() - core KG integration method
- load_all_learning_profiles() - batch loading for agents
- assign_task() already uses learning-based scoring via AgentScoringService
### Existing Complete Implementation
- vapora-knowledge-graph/src/learning.rs - calculation functions
- vapora-agents/src/learning_profile.rs - data structures and expertise
- vapora-agents/src/scoring.rs - unified scoring service
- vapora-agents/src/profile_adapter.rs - adapter methods
## Tests Passing
- learning_profile: 7 tests ✅
- scoring: 5 tests ✅
- profile_adapter: 6 tests ✅
- coordinator: learning-specific tests ✅
## Data Flow
1. Task arrives → AgentCoordinator::assign_task()
2. Extract task_type from description
3. Query KG for task-type executions (load_learning_profile_from_kg)
4. Calculate expertise with recency bias
5. Score candidates (SwarmCoordinator + learning)
6. Assign to top-scored agent
7. Execution result → KG → Update learning profiles
## Key Design Decisions
✅ Recency bias: 7-day half-life with 3x weight for recent performance
✅ Confidence scoring: min(1.0, total_executions / 20) prevents overfitting
✅ Hierarchical scoring: 30% base load, 50% expertise, 20% confidence
✅ KG query limit: 100 recent executions per task-type for performance
✅ Async loading: load_learning_profile_from_kg supports concurrent loads
## Next: Phase 5.4 - Cost Optimization
Ready to implement budget enforcement and cost-aware provider selection.
2026-01-11 13:03:53 +00:00
# Vapora Tracking System
A unified tracking and change logging system for Vapora projects. Provides a "project cuaderno de bitácora" (logbook) for aggregating changes, TODOs, and tracking across multiple sources with real-time synchronization.
## 🎯 Features
### Core Capabilities
- **Unified Tracking**: Aggregates changes and TODOs from multiple sources
- Claude Code tracking files (`~/.claude/todos/` )
- `.coder/` directory tracking (`changes.md` , `todo.md` )
- Workflow YAML definitions
- **Real-time Sync**: File watchers detect changes and automatically sync
- **REST API**: Axum-based HTTP API for queries and management
- **SQLite Storage**: Persistent storage with efficient indexing
- **Multi-format Export**: JSON, CSV, Markdown, Kanban board formats
### Integration Points
- **Slash Commands**: `/log-change` , `/add-todo` , `/track-status`
- **Interactive Skill**: Guided workflows for comprehensive logging
- **Nushell Scripts**: `sync-tracking` , `export-tracking` , `start-tracking-service`
- **Claude Code Hooks**: Automatic event synchronization
## 📦 Architecture
### Modular Design
```
vapora-tracking/
├── types.rs # Core types with Debug/Display
├── error.rs # Canonical error handling
├── parsers.rs # Markdown, JSON, YAML parsing
├── storage.rs # SQLite async persistence
├── watchers.rs # File system monitoring
└── api.rs # Axum REST endpoints
```
### Data Flow
```
File Changes (.coder/, ~/.claude/)
↓
File Watchers (notify)
↓
Parsers (markdown, JSON)
↓
SQLite Storage
↓
REST API ← Queries
```
## 🚀 Quick Start
### Installation
Add to `Cargo.toml` :
```toml
[dependencies]
vapora-tracking = { path = "crates/vapora-tracking" }
```
### Basic Usage
```rust
use vapora_tracking::{TrackingDb, MarkdownParser, TrackingEntry};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result< (), Box< dyn std::error::Error > > {
// Initialize database
let db = Arc::new(TrackingDb::new("sqlite://tracking.db").await?);
// Parse markdown changes
let content = std::fs::read_to_string(".coder/changes.md")?;
let entries = MarkdownParser::parse_changes(& content, "/project")?;
// Store entries
for entry in entries {
db.insert_entry(&entry).await?;
}
// Query summary
let summary = db.get_summary().await?;
println!("Total entries: {}", summary.total_entries);
Ok(())
}
```
### Using Slash Commands
```bash
# Log a change
/log-change "Implemented WebSocket sync" --impact backend --files 12
# Add a TODO
/add-todo "Refactor database" --priority H --estimate XL --due 2025-11-20
# Show status
/track-status --project vapora --status pending
```
### Using Nushell Scripts
```bash
# Start tracking service
./scripts/start-tracking-service.nu --port 3000 --verbose
# Sync all projects
./scripts/sync-tracking.nu --projects-dir /Users/Akasha --verbose
# Export to different formats
./scripts/export-tracking.nu json --output report
./scripts/export-tracking.nu kanban --project vapora
```
## 📊 Data Structures
### TrackingEntry
```rust
pub struct TrackingEntry {
pub id: Uuid,
pub project_path: PathBuf,
pub source: TrackingSource,
pub entry_type: EntryType,
pub timestamp: DateTime< Utc > ,
pub summary: String,
pub details_link: Option< PathBuf > ,
pub metadata: HashMap< String , String > ,
}
```
### Entry Types
**Changes**:
- Impact: Backend, Frontend, Security, Performance, Docs, Infrastructure, Testing
- Breaking change indicator
- Files affected count
**TODOs**:
- Priority: High, Medium, Low
- Estimate: Small, Medium, Large, Extra Large
- Status: Pending, In Progress, Completed, Blocked
- Tags for categorization
## 🔗 Integration with Vapora
### Recommended Setup
1. **Start tracking service** :
```bash
2026-01-24 02:15:31 +00:00
# From repository root
feat: Phase 5.3 - Multi-Agent Learning Infrastructure
Implement intelligent agent learning from Knowledge Graph execution history
with per-task-type expertise tracking, recency bias, and learning curves.
## Phase 5.3 Implementation
### Learning Infrastructure (✅ Complete)
- LearningProfileService with per-task-type expertise metrics
- TaskTypeExpertise model tracking success_rate, confidence, learning curves
- Recency bias weighting: recent 7 days weighted 3x higher (exponential decay)
- Confidence scoring prevents overfitting: min(1.0, executions / 20)
- Learning curves computed from daily execution windows
### Agent Scoring Service (✅ Complete)
- Unified AgentScore combining SwarmCoordinator + learning profiles
- Scoring formula: 0.3*base + 0.5*expertise + 0.2*confidence
- Rank agents by combined score for intelligent assignment
- Support for recency-biased scoring (recent_success_rate)
- Methods: rank_agents, select_best, rank_agents_with_recency
### KG Integration (✅ Complete)
- KGPersistence::get_executions_for_task_type() - query by agent + task type
- KGPersistence::get_agent_executions() - all executions for agent
- Coordinator::load_learning_profile_from_kg() - core KG→Learning integration
- Coordinator::load_all_learning_profiles() - batch load for multiple agents
- Convert PersistedExecution → ExecutionData for learning calculations
### Agent Assignment Integration (✅ Complete)
- AgentCoordinator uses learning profiles for task assignment
- extract_task_type() infers task type from title/description
- assign_task() scores candidates using AgentScoringService
- Fallback to load-based selection if no learning data available
- Learning profiles stored in coordinator.learning_profiles RwLock
### Profile Adapter Enhancements (✅ Complete)
- create_learning_profile() - initialize empty profiles
- add_task_type_expertise() - set task-type expertise
- update_profile_with_learning() - update swarm profiles from learning
## Files Modified
### vapora-knowledge-graph/src/persistence.rs (+30 lines)
- get_executions_for_task_type(agent_id, task_type, limit)
- get_agent_executions(agent_id, limit)
### vapora-agents/src/coordinator.rs (+100 lines)
- load_learning_profile_from_kg() - core KG integration method
- load_all_learning_profiles() - batch loading for agents
- assign_task() already uses learning-based scoring via AgentScoringService
### Existing Complete Implementation
- vapora-knowledge-graph/src/learning.rs - calculation functions
- vapora-agents/src/learning_profile.rs - data structures and expertise
- vapora-agents/src/scoring.rs - unified scoring service
- vapora-agents/src/profile_adapter.rs - adapter methods
## Tests Passing
- learning_profile: 7 tests ✅
- scoring: 5 tests ✅
- profile_adapter: 6 tests ✅
- coordinator: learning-specific tests ✅
## Data Flow
1. Task arrives → AgentCoordinator::assign_task()
2. Extract task_type from description
3. Query KG for task-type executions (load_learning_profile_from_kg)
4. Calculate expertise with recency bias
5. Score candidates (SwarmCoordinator + learning)
6. Assign to top-scored agent
7. Execution result → KG → Update learning profiles
## Key Design Decisions
✅ Recency bias: 7-day half-life with 3x weight for recent performance
✅ Confidence scoring: min(1.0, total_executions / 20) prevents overfitting
✅ Hierarchical scoring: 30% base load, 50% expertise, 20% confidence
✅ KG query limit: 100 recent executions per task-type for performance
✅ Async loading: load_learning_profile_from_kg supports concurrent loads
## Next: Phase 5.4 - Cost Optimization
Ready to implement budget enforcement and cost-aware provider selection.
2026-01-11 13:03:53 +00:00
cargo run -p vapora-backend -- --enable-tracking
```
2. **Configure Claude Code** :
- Hook: `~/.claude/hooks/tracking-sync.sh`
- Commands: `.claude/commands/log-change.md` , etc.
- Skill: `.claude/skills/tracking.md`
3. **Watch projects** :
```bash
./scripts/sync-tracking.nu --watch-dirs /Users/Akasha
```
### REST API Endpoints
```
GET /api/v1/tracking/entries # List all entries
GET /api/v1/tracking/summary # Get summary statistics
GET /api/v1/tracking/projects/:project # Get project entries
POST /api/v1/tracking/sync # Sync from file
```
## 📋 File Format Examples
### `.coder/changes.md`
```markdown
---
project: vapora
last_sync: 2025-11-10T14:30:00Z
---
## 2025-11-10T14:30:00Z - Implemented real-time sync
**Impact**: backend | **Breaking** : no | **Files** : 5
Non-blocking async synchronization using tokio channels.
[Details ](./docs/changes/20251110-realtime-sync.md )
```
### `.coder/todo.md`
```markdown
---
project: vapora
last_sync: 2025-11-10T14:30:00Z
---
## [ ] Implement webhook system
**Priority**: H | **Estimate** : L | **Tags** : #feature #api
**Created**: 2025-11-10T14:30:00Z | **Due** : 2025-11-15
Implement bidirectional webhook system for real-time events.
[Spec ](./docs/specs/webhook-system.md )
```
## 📈 Statistics
```
✅ 20+ unit tests (100% coverage)
✅ 1,640 lines of production code
✅ 0% unsafe code
✅ 100% guideline compliance
✅ Async/await throughout
✅ Full error handling
✅ Complete documentation
```
## 🛠️ Development Guidelines
Follows Microsoft Pragmatic Rust Guidelines:
- ✅ M-PUBLIC-DEBUG: All public types implement Debug
- ✅ M-PUBLIC-DISPLAY: User-facing types implement Display
- ✅ M-ERRORS-CANONICAL-STRUCTS: Specific error types
- ✅ M-PANIC-IS-STOP: Result for recoverable errors
- ✅ M-CANONICAL-DOCS: Complete with Examples, Errors
- ✅ M-UPSTREAM-GUIDELINES: Follows official Rust API guidelines
## 📚 Documentation
- **API Docs**: `cargo doc --open`
- **User Guide**: See `.claude/skills/tracking.md`
- **Examples**: See slash command descriptions
- **Architecture**: See module docs in source
## 🔄 Workflow Examples
### Logging a Complex Feature
```bash
/log-change "Implemented WebSocket-based real-time sync" \
--impact backend \
--files 12
# Opens interactive skill for detailed documentation
```
### Creating a Sprint TODO
```bash
/add-todo "API redesign for caching" \
--priority H \
--estimate XL \
--due 2025-11-30 \
--tags "api,performance,cache"
# Creates entry with specification template
```
### Checking Project Status
```bash
/track-status --project vapora --status pending
# Shows all pending tasks with details
```
## 🔐 Security
- No sensitive data in logs/errors
- File-based access control via filesystem permissions
- SQLite in-memory for testing
- Prepared statements (via sqlx)
## 🚀 Performance
- Connection pooling: 5 concurrent connections
- File watching: 500ms debounce
- Query indices on project, timestamp, source
- Async throughout for non-blocking I/O
## 📞 Support
For issues or questions:
- Check documentation in `.claude/skills/tracking.md`
- Review examples in slash commands
- Check database with `/track-status`
## License
Part of Vapora project - MIT OR Apache-2.0