π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(neural-trader): #2068 ADR-126 Phase 2 β ADR-125 memory lifecycle (TTL + dedup + warm HNSW doc)
ruvd9bd4e6adbae
diff --git a/plugins/ruflo-neural-trader/README.md b/plugins/ruflo-neural-trader/README.mdindex e3ea1eb538..d26f656faa 100644--- a/plugins/ruflo-neural-trader/README.md+++ b/plugins/ruflo-neural-trader/README.md@@ -206,6 +206,16 @@ Note: the namespace prefix is `trading-` (the actual intent) rather than `neuralAll access via `memory_*` (namespace-routed). No `agentdb_hierarchical-*` or `agentdb_pattern-store` with namespace arguments β the plugin uses the correct routing throughout.+### Memory lifecycle (ADR-125 integration)++This plugin relies on `@claude-flow/[email protected]` for the lifecycle guarantees defined in [ADR-125](../../v3/docs/adr/ADR-125-memory-consolidation.md) and wired by [ADR-126 Phase 2](../../v3/docs/adr/ADR-126-neural-trader-substrate-integration.md):++- **Warm HNSW restart** β `@claude-flow/[email protected]` (ADR-125 Phase 3) snapshots the HNSW index to a `.hnsw` sidecar file, so neural-trader process restarts no longer rebuild the strategy / regime similarity index from scratch. No plugin-side change is required to benefit; routing is automatic through `MemoryService.search()`.+- **Hybrid retrieval (RRF + MMR)** β `market-analyst` regime-similarity queries automatically become hybrid (dense ANN + sparse FTS5 keyword, reciprocal-rank-fused and MMR-diversified) via the same `MemoryService.search()` path (ADR-125 Phase 5). When the embedding generator is unavailable, retrieval gracefully degrades to keyword-only rather than throwing.+- **Signal TTL (24h)** β `trader-signal` writes to `trading-signals` with `expiresAt: now + 24h`. The `MemoryConsolidator.sweepExpired()` pass (ADR-125 Phase 4) removes them from all indexes β including HNSW β when they expire. Long-running ruflo sessions no longer accumulate stale intraday signals.+- **Backtest dedup** β `trader-backtest` proactively deletes prior entries for the same `(strategyId, paramsHash)` before storing a fresh one. The same outcome is also produced asynchronously by the `MemoryConsolidator.dedup('keep-newest')` background pass that runs every 6 hours.+- **Consolidator schedule** β the consolidator runs every 6 hours by default (`sweepExpired` + `dedup` + `compactHnsw`), and also on `MemoryService.close()`. No plugin-side wiring is required.+## Verification```bashdiff --git a/plugins/ruflo-neural-trader/skills/trader-backtest/SKILL.md b/plugins/ruflo-neural-trader/skills/trader-backtest/SKILL.mdindex 38e3ddb4f2..02b6aae6af 100644--- a/plugins/ruflo-neural-trader/skills/trader-backtest/SKILL.md+++ b/plugins/ruflo-neural-trader/skills/trader-backtest/SKILL.md@@ -1,7 +1,7 @@---name: trader-backtestdescription: Run a historical backtest using npx neural-trader with Rust/NAPI engine (8-19x faster) and walk-forward validation-allowed-tools: Bash Read mcp__claude-flow__memory_store mcp__claude-flow__memory_retrieve mcp__claude-flow__memory_search mcp__claude-flow__neural_train mcp__claude-flow__agentdb_pattern-store+allowed-tools: Bash Read mcp__claude-flow__memory_store mcp__claude-flow__memory_retrieve mcp__claude-flow__memory_search mcp__claude-flow__memory_delete mcp__claude-flow__neural_train mcp__claude-flow__agentdb_pattern-storeargument-hint: "<strategy-name> --symbol <TICKER> [--period 2020-2024]"---Run a historical backtest using the `neural-trader` Rust/NAPI engine.@@ -21,9 +21,13 @@ Steps:npx neural-trader --backtest --strategy multi-indicator --position-sizing kelly --symbol SPY --period 2020-2024```4. Capture performance metrics from output: total return, annualized return, Sharpe ratio, Sortino ratio, max drawdown, win rate, profit factor, number of trades-5. Store backtest results:+5. Dedup prior backtests for the same `(strategyId, paramsHash)` before storing the fresh one (ADR-125 lifecycle / ADR-126 Phase 2 β `keep-newest` semantics):+ - Search: `mcp__claude-flow__memory_search({ query: "backtest STRATEGY paramsHash:PARAMS_HASH", namespace: "trading-backtests", limit: 10 })`+ - For each hit whose key matches `backtest-STRATEGY-*` AND whose stored `paramsHash` equals the current run's hash, delete it: `mcp__claude-flow__memory_delete({ key: "OLD_KEY", namespace: "trading-backtests" })`+ - (Note: even without this proactive step, the `MemoryConsolidator.dedup('keep-newest')` background pass introduced in `@claude-flow/[email protected]` runs every 6h and will eventually converge. Doing it inline keeps `memory_search` results deterministic immediately after a re-run.)+6. Store backtest results (long-lived; no TTL β backtest history is the audit trail that ADR-126 Phase 4 will Ed25519-sign):`mcp__claude-flow__memory_store({ key: "backtest-STRATEGY-TIMESTAMP", value: "RESULTS_JSON", namespace: "trading-backtests" })`-6. If Sharpe > 1.5, store as successful pattern:+7. If Sharpe > 1.5, store as successful pattern:`mcp__claude-flow__agentdb_pattern-store({ pattern: "profitable-STRATEGY_TYPE", data: "PARAMS_AND_RESULTS" })`-7. Train SONA on the outcome:+8. Train SONA on the outcome:`mcp__claude-flow__neural_train({ patternType: "trading-strategy", epochs: 10 })`diff --git a/plugins/ruflo-neural-trader/skills/trader-signal/SKILL.md b/plugins/ruflo-neural-trader/skills/trader-signal/SKILL.mdindex a59612e996..f5f4b0ac88 100644--- a/plugins/ruflo-neural-trader/skills/trader-signal/SKILL.md+++ b/plugins/ruflo-neural-trader/skills/trader-signal/SKILL.md@@ -1,7 +1,7 @@---name: trader-signaldescription: Generate trading signals using npx neural-trader anomaly detection engine with Z-score scoring and neural prediction-allowed-tools: Bash Read mcp__claude-flow__memory_store mcp__claude-flow__memory_retrieve mcp__claude-flow__memory_search mcp__claude-flow__neural_predict mcp__claude-flow__agentdb_pattern-search+allowed-tools: Bash Read mcp__claude-flow__memory_store mcp__claude-flow__memory_retrieve mcp__claude-flow__memory_search mcp__claude-flow__memory_delete mcp__claude-flow__neural_predict mcp__claude-flow__agentdb_pattern-searchargument-hint: "[--strategy NAME] [--symbols AAPL,MSFT]"---Generate trading signals using neural-trader's anomaly detection engine.@@ -31,5 +31,5 @@ Steps:6. Search historical pattern matches:`mcp__claude-flow__agentdb_pattern-search({ query: "ANOMALY_TYPE score RANGE", namespace: "trading-signals" })`7. Present ranked signals: instrument, direction, confidence, anomaly type, entry/stop/target-8. Store signals:- `mcp__claude-flow__memory_store({ key: "signal-TIMESTAMP", value: "SIGNALS_JSON", namespace: "trading-signals" })`+8. Store signals with a 24-hour TTL (intraday signals shouldn't pollute long-running memory; the `MemoryConsolidator.sweepExpired()` pass introduced in ADR-125 Phase 4 β shipped in `@claude-flow/[email protected]` β sweeps them out after they expire):+ `mcp__claude-flow__memory_store({ key: "signal-TIMESTAMP", value: "SIGNALS_JSON", namespace: "trading-signals", expiresAt: Date.now() + 24 * 60 * 60 * 1000 })`