v3/implementation/adrs/ADR-064-stub-remediation-v3522.md
Date: 2026-03-17 Status: Implemented (22 stubs fully implemented in v3.5.43, PR #1438) Context: Deep capability audit (ADR-063) identified stub implementations and broken features. This ADR documents the remediation plan and tracks which items were already functional vs genuinely needing fixes.
The ADR-063 audit flagged several items as "stub" or "missing" that are in fact fully implemented. The audit ran in Docker where some capabilities were degraded due to pruned dependencies, leading to false negatives.
| Item | Finding | Evidence |
|---|---|---|
| Session restore --latest | Fully implemented with MCP integration | session.ts:274-432 — interactive selector when no ID given |
| Workflow persistence | Saves to .claude-flow/workflows/store.json | workflow-tools.ts:52-78 — loadWorkflowStore()/saveWorkflowStore() |
| Daemon scheduler | Working process management with PID files | daemon.ts:234-458 — detached process, signal handling |
| Flash Attention JS | CPU-optimized block-wise implementation | flash-attention.ts:67-150 — top-K sparse, fused softmax-matmul |
| MCP path resolution | Properly sanitized with process.cwd() | session-tools.ts:34-39 — path sanitization regex |
| Hook handler stdin | Correct timeout + pause cleanup | hook-handler.cjs:40-58 — graceful degradation |
| Priority | Item | Current State | Target |
|---|---|---|---|
| P0 | @ruvector/learning-wasm integration | Not wired in CLI | Wire @ruvector/[email protected] into neural commands |
| P0 | Consensus vote counting | Proposals queued but no quorum validation | BFT 2/3 majority, Raft leader election, configurable quorum |
| P1 | Memory delete HNSW cleanup | SQL row deleted, vector remains | Delete embedding row + rebuild search index |
| P1 | SONA reinforcement learning | Signal recording only | Trajectory → reward → weight update loop |
| P1 | EWC++ consolidation execution | Algorithm defined, not executed | Fisher matrix computation + penalty application |
| P2 | Coverage hooks test integration | Returns 0% always | Read lcov.info / jest coverage-summary.json from disk |
| P2 | Intelligence stats → neural bridge | Stats counter disconnected | Read from ReasoningBank .claude-flow/neural/patterns.json |
Wire the published @ruvector/[email protected] package into the CLI:
neural train → ruvector.initTraining() with WASM backend
neural predict → ruvector.predict() with Flash Attention
neural optimize → ruvector.quantize() for Int8
Files: src/commands/neural.ts, src/ruvector/index.ts
Test: neural train --wasm should use WASM backend, report >2x speedup
Replace stub vote recording with real consensus algorithms:
BFT (Byzantine Fault Tolerance):
Raft (Leader Election):
Quorum:
File: src/mcp-tools/hive-mind-tools.ts
Test: Create proposal → submit votes → verify quorum reached/rejected
When deleting a memory entry:
File: src/memory/memory-initializer.ts
Test: Store entry → search finds it → delete → search no longer finds it
Implement the 4-step intelligence pipeline for real:
Implementation:
recordTrajectoryStep() → accumulate steps with outcomesendTrajectory(verdict) → compute reward signaldistillLearning() → update pattern confidence scores based on outcomesconsolidate() → apply EWC++ Fisher penaltyFiles: src/memory/intelligence.ts, src/memory/ewc-consolidation.ts
Test: Train patterns → use them → record outcome → confidence scores change
The Fisher Information Matrix and consolidation formula are defined but not executed.
Implementation:
L_total = L_new + (lambda/2) * sum(F_i * (theta_i - theta_old_i)^2).swarm/ewc-fisher.jsonFile: src/memory/ewc-consolidation.ts
Test: Train → consolidate → retrain different domain → verify original patterns preserved
Read real coverage data from common test tools:
Supported formats:
coverage/coverage-summary.json (Jest/Istanbul)coverage/lcov.info (lcov).nyc_output/ (NYC)Implementation:
coverage-gaps reads coverage files, computes per-file gapscoverage-route uses coverage data to prioritize test-related tasksFile: src/commands/hooks.ts (coverage-gaps, coverage-route, coverage-suggest)
Connect hooks intelligence stats to ReasoningBank data:
.claude-flow/neural/patterns.json.claude-flow/neural/stats.jsonFile: src/commands/hooks.ts (intelligence stats handler)
| Issue | Fix | File |
|---|---|---|
| #1335 Daemon scheduler | Verify interval comparison uses consistent timestamps | daemon.ts |
| #1122 Memory delete HNSW | See P1-1 above | memory-initializer.ts |
| #1117 Orphan processes | Kill child process on timeout rejection | src/utils/ |
| #1116 daemon.log 0 bytes | Use import('fs') instead of require('fs') in ESM | daemon.ts |
| #1113 Scheduling intervals | Fix interval multiplier calculation | daemon.ts |
| #1333 MCP from / | Already fixed — path sanitization is correct | N/A |
| #1342 Post-bash junk files | Quote/escape tool output in hook args | hook-handler.cjs |
| #1331 stdin hang | Already fixed — timeout + pause cleanup works | N/A |
| Package | Version | Purpose |
|---|---|---|
@ruvector/learning-wasm | 0.1.29 | MicroLoRA, Flash Attention WASM, Int8 quantization |
@claude-flow/memory | 3.0.0-alpha.12 | AgentDB + ControllerRegistry |
neural train --wasm uses WASM backend and reports >2x speeduphive-mind consensus validates votes with real quorum logicmemory delete removes both SQL row and embedding vectorneural train → neural predict → hooks post-task → confidence scores updatecoverage-gaps reads real coverage files (or reports "no data" instead of 0%)hooks intelligence stats shows real pattern/trajectory counts@ruvector/learning-wasm adds ~2MB to package size