Files
proffesor-for-testing__agen…/docs/planning/ruvector-implementation-plan.md
Dragan Spiridonov 6dbc1c377b fix: critical memory/learning system fixes for v1.9.4 (#89)
* SwarmMemoryManager Refactoring Plan

* fix: add missing directories to npm package (v1.9.3)

Added templates/, .claude/helpers/, and docs/reference/ to package.json
files array. These were missing from the npm distribution, causing
`aqe init` to fail with "Template file not found" errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* checkpoint improvements

* fix: critical memory/learning system fixes for v1.9.4

## Critical Fixes
- Vector embeddings now stored correctly (was storing NULL)
- SQL parameter style fixed for agentdb's SqlJsDatabase wrapper
- HNSW index schema mismatch resolved with pattern_id column
- Hooks now save to correct database (.agentic-qe/agentdb.db)

## New Features
- Added 5 SwarmMemoryManager methods for learning data retrieval:
  - getBestAction() - Q-learning best action selection
  - getRecentLearningExperiences() - Recent experience retrieval
  - getLearningExperiencesByTaskType() - Task-filtered experiences
  - getHighRewardExperiences() - Successful experience extraction
  - getLearningStats() - Aggregate learning statistics
- Added comprehensive integration test for memory/learning loop
- Added RuVector pattern store integration (experimental)

## Technical Details
- Vector embeddings: 384 dimensions × 4 bytes = 1,536 bytes per pattern
- All 12 integration tests pass
- HNSW index: 150x faster vector search enabled

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: move ARM64-only ruvector packages to optionalDependencies

Fixes CI failures caused by platform-specific dependencies:
- @ruvector/node-linux-arm64-gnu (ARM64 only)
- ruvector-core-linux-arm64-gnu (ARM64 only)

These packages caused npm ci to fail on x64 CI runners with:
"EBADPLATFORM - wanted linux/arm64, current linux/x64"

Solution: Move ARM64 packages to optionalDependencies and add
x64 variants for cross-platform compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: regenerate package-lock.json with x64 ruvector packages

Updates lockfile to include optional x64 platform packages for
CI compatibility:
- @ruvector/node-linux-x64-gnu@0.1.17
- ruvector-core-linux-x64-gnu@0.1.15

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-30 20:52:44 +01:00

238 lines
6.0 KiB
Markdown

# RuVector Integration Implementation Plan
## Executive Summary
Based on successful proof-of-concept benchmarks on ARM64 and ruv's latest AgentDB v2 improvements, this document outlines a phased approach to integrating RuVector as a high-performance vector database for the Agentic QE Fleet.
## Current State (Baseline - Nov 29-30, 2025)
### Yesterday's RuVector Benchmark Results (ARM64 Linux)
| Metric | 1K Vectors | 10K Vectors |
|--------|------------|-------------|
| Insert throughput | 20,945 ops/sec | 42,875 ops/sec |
| Search p50 latency | 256.3 µs | 1,618.7 µs |
| Search p99 latency | 290.3 µs | 2,167.5 µs |
| Throughput (QPS) | 3,638 qps | 559 qps |
### ruv's AgentDB v2 Benchmarks (x64, 100K vectors)
From [ruv's gist](https://gist.github.com/ruvnet/6755d4bbb0e61e28709c00b42d9bba1b):
| Metric | Value | vs Baseline |
|--------|-------|-------------|
| Search latency | 61 µs | 8.2x faster than hnswlib (498 µs) |
| Memory footprint | 151 MB | 18% less than baseline (180 MB) |
| Recall | >95% | Maintained |
| Neural enhancement | +24.4% | Combined GNN + RL + optimization |
| Performance degradation prevention | 98% | Self-organizing mechanisms |
---
## Phase 1: Foundation (Week 1-2)
### Goals
- Validate ruv's AgentDB v2 integration
- Establish benchmark baseline comparison
- Create unified pattern store interface
### Tasks
#### 1.1 Benchmark Validation
- [ ] Clone ruv's `agentic-flow` branch
- [ ] Run benchmarks with updated AgentDB
- [ ] Compare against our ARM64 RuVector results
- [ ] Document findings
#### 1.2 Interface Unification
- [ ] Define `IPatternStore` interface
- [ ] Implement adapter pattern for AgentDB and RuVector
- [ ] Add feature detection for platform-specific optimizations
#### 1.3 Configuration System
- [ ] Create unified config for vector databases
- [ ] Add environment-based selection (RUVECTOR_ENABLED, AGENTDB_ENABLED)
- [ ] Implement graceful fallback chain
### Deliverables
- Benchmark comparison report
- `IPatternStore` interface definition
- Configuration schema
---
## Phase 2: Integration (Week 3-4)
### Goals
- Replace AgentDB vector operations with RuVector
- Maintain backward compatibility
- Add neural enhancement support
### Tasks
#### 2.1 Core Integration
- [ ] Update `RuVectorPatternStore` with ruv's optimizations
- [ ] Integrate neural enhancement layer (multi-head attention)
- [ ] Add RL-based navigation for query optimization
#### 2.2 Migration Path
- [ ] Create data migration script (AgentDB → RuVector)
- [ ] Implement dual-write mode for safe rollout
- [ ] Add rollback capability
#### 2.3 QE Agent Integration
- [ ] Update `QEReasoningBank` to use new pattern store
- [ ] Integrate with `AgentDBLearningIntegration`
- [ ] Update pattern matching in test generation agents
### Deliverables
- Integrated `RuVectorPatternStore` v2
- Migration tooling
- Updated agent configurations
---
## Phase 3: Optimization (Week 5-6)
### Goals
- Apply ruv's neural enhancements
- Implement self-organizing mechanisms
- Achieve target performance metrics
### Tasks
#### 3.1 Neural Stack Integration
- [ ] Implement 8-head attention mechanism
- [ ] Add GNN-based pattern relationships
- [ ] Integrate RL navigation for traversal
#### 3.2 Self-Healing System
- [ ] Implement performance degradation detection
- [ ] Add automatic index rebalancing
- [ ] Create health monitoring dashboard
#### 3.3 Hypergraph Support
- [ ] Add multi-entity relationship modeling
- [ ] Implement 3-10 node relationship queries
- [ ] Optimize edge storage (73% reduction target)
### Deliverables
- Neural-enhanced pattern store
- Self-healing monitoring
- Hypergraph query support
---
## Phase 4: Production Hardening (Week 7-8)
### Goals
- Production-ready deployment
- Comprehensive testing
- Documentation and training
### Tasks
#### 4.1 Production Configuration
- [ ] Apply recommended settings (M=32, efConstruction=200)
- [ ] Configure dynamic-k adaptation (min:5, max:20)
- [ ] Enable MPC adaptation
#### 4.2 Testing
- [ ] Load testing at 100K+ patterns
- [ ] Chaos engineering scenarios
- [ ] Performance regression suite
#### 4.3 Documentation
- [ ] Architecture documentation
- [ ] Operational runbook
- [ ] Performance tuning guide
### Deliverables
- Production deployment guide
- Test suite
- Documentation package
---
## Success Metrics
| Metric | Target | Current |
|--------|--------|---------|
| Search p50 latency | <100 µs | 256 µs (ARM64) |
| QPS (10K vectors) | >5,000 | 559 |
| Memory efficiency | 18% reduction | TBD |
| Recall | >95% | TBD |
| Performance degradation | <5% over 30 days | TBD |
---
## Risk Mitigation
### Platform Support
- **Risk**: ARM64 native bindings unavailable
- **Mitigation**: Fallback to WASM or AgentDB
### Data Migration
- **Risk**: Data loss during migration
- **Mitigation**: Dual-write mode, backup procedures
### Performance Regression
- **Risk**: Slower than AgentDB in edge cases
- **Mitigation**: A/B testing, gradual rollout
---
## Dependencies
### External
- `@ruvector/core` v0.1.15+
- `ruvector-core-linux-arm64-gnu` (ARM64)
- ruv's `agentic-flow` AgentDB v2
### Internal
- `AgentDBManager` refactoring
- `QEReasoningBank` updates
- Configuration system updates
---
## Timeline
```
Week 1-2: Phase 1 - Foundation
Week 3-4: Phase 2 - Integration
Week 5-6: Phase 3 - Optimization
Week 7-8: Phase 4 - Production Hardening
```
**Total Duration**: 8 weeks
---
## Appendix: File Structure
```
src/core/memory/
├── IPatternStore.ts # Unified interface
├── RuVectorPatternStore.ts # RuVector implementation
├── AgentDBPatternStore.ts # AgentDB adapter
├── PatternStoreFactory.ts # Factory with feature detection
├── NeuralEnhancement.ts # Neural stack integration
└── SelfHealingMonitor.ts # Performance monitoring
tests/benchmarks/
├── agentdb-vs-ruvector.benchmark.ts
├── neural-enhancement.benchmark.ts
└── scale-test.benchmark.ts
docs/
├── planning/ruvector-implementation-plan.md
└── benchmarks/ruvector-benchmark-results.md
```
---
*Created: 2025-11-30*
*Author: Agentic QE Fleet*
*Status: Draft*