Commit Graph
25 Commits
Author SHA1 Message Date
ruvnet e332689b8c fix(release): harden hooks, statusline, security, and plugin MCP integration 2026-07-16 23:06:29 -04:00
ruv ecd3a4ca80 darwin-plugins iter 2 — ruflo-neural-trader: fix stale skill count (7→9) and document missing trader-explain / trader-portfolio-cg 2026-06-26 20:15:24 -04:00
ruv 798b12abfd darwin-plugins iter 1 — ruflo-neural-trader: add ADR-112 'Use when' guidance to trader-regime description 2026-06-26 20:03:12 -04:00
ruvandruflo-bot 8a9c6ee538 security(neural-trader): #50 — supply-chain audit + AIDefence wiring sketch
Three-part security review of the ruflo-neural-trader plugin, documented
under plugins/ruflo-neural-trader/docs/.

1. Supply-chain audit (security-audit-2026-05-20.md):
   - `node scripts/audit-supply-chain.mjs` filtered for the plugin:
     no plugin-specific findings
   - Repo-wide layers all clean: 0 CVE direct-dep, 0 lockfile integrity,
     0 allowlist, 0 typosquat hits, 5 known publisher-trust entries

2. Static checks on plugin files (security-audit-2026-05-20.md):
   - `grep process.env|API_KEY|SECRET`: only documented prereqs
     (ANTHROPIC_API_KEY in trader-cloud-backtest) and feature flags
     (RUFLO_SUBLINEAR_NATIVE in sublinear-adapter). No hardcoded
     secrets anywhere.
   - `grep eval|new Function`: zero in code.
   - `grep spawn|execSync|spawnSync`: zero actual invocations —
     only documentation comments. Reviewed against the #2073/#2074
     Windows ENOENT regression: plugin never calls spawn* directly.

3. AIDefence wiring sketch (aidefence-wiring.md):
   - Per ADR-118, market data ingestion should pass through
     `aidefence_has_pii` / `aidefence_scan` / `aidefence_is_safe` —
     the same four-gate pattern ruflo-browser and ruflo-federation
     already use.
   - Wire points: `--symbol $TICKER` input + `fetchLiveBars` JSON
     response in market-analyst, plus the LLM prompt body and the
     AgentDB store value.
   - NOT implemented in this PR. Deferred to a separate ADR-127
     follow-up — wiring before the ADR-126 Phase 5 comms boundary
     is stable risks landing the gates in the wrong place.

Verdict: no blocking findings. The plugin is safe to ship as-is; the
AIDefence wiring is a defense-in-depth enhancement, not a remediation.

Co-Authored-By: ruflo-bot <ruflo-bot@users.noreply.github.com>
2026-05-20 16:48:53 -04:00
ruvandruflo-bot bb05c5a96f perf(neural-trader): #49 — bench-driven perf notes + targeted optimization
Add docs/perf-notes.md ranking the three hotspots identified by the #48
bench suite, with one concrete in-scope optimization shipped here.

Optimization (sublinear-adapter.mjs / neumannSeries):
  Replace per-iter `new Float64Array(n)` allocation with a two-buffer
  ping-pong (cur / next, swapped by reference). At n=256 a typical
  5-iter solve previously allocated 5×2 KB of garbage per call — fully
  eliminated. Algorithm unchanged: Jacobi-style update from cur into
  next, convergence check on inf-norm(next-cur), swap.

Measured (portfolio-cg.bench.mjs at n=256, 5-run mean):
  - Before:  Neumann avg ~0.635 ms
  - After:   Neumann avg ~0.522 ms  (~18% faster)
  - Parity: ||cg − neumann||_∞ = 2.12e-8 (identical to baseline)
  - smoke-neural-trader-portfolio-cg.mjs: PASS

Tracked-not-fixed (documented in perf-notes.md):
  - Memory recall scales ~96% of linear in the bench — production
    path uses HNSW (ADR-006), the bench is the recall regression gate.
  - Signal scan p99 ~9× p50 — GC pressure suspected; upstream
    `npx neural-trader` change, not plugin-layer.

Explicitly NOT optimized (would break a contract):
  - canonicalBytes — ADR-126 Phase 4 / CWE-347 parity with the
    plugin-registry signer requires `JSON.stringify` with NO sort.
  - isSymmetric — already short-circuits; full scan IS the SPD guard
    the smoke depends on.

Co-Authored-By: ruflo-bot <ruflo-bot@users.noreply.github.com>
2026-05-20 16:48:38 -04:00
ruvandruflo-bot 70861ced4d feat(neural-trader): #48 — benchmark suite (signal, backtest, memory-recall)
Add three self-contained benchmark files under
`plugins/ruflo-neural-trader/benchmarks/` to baseline JS-side compute
throughput for the plugin's hot paths. None of these touch
`portfolio-cg.bench.mjs` (ADR-126 Phase 3 / #2080 territory).

1. signal-generation.bench.mjs — anomaly-detection arithmetic core
   shared with `trader-signal --signal scan`. 5 symbols × 252 daily bars
   × 200 iters. Worst-symbol avg ~22 µs, full-scan sum-of-avgs <0.1 ms.

2. backtest-throughput.bench.mjs — SMA(10)/SMA(50) crossover on 1 sym
   × 252 daily bars. Avg ~0.04 ms / >6M bars/sec. Also reports Sharpe,
   max drawdown, trade count on the resulting equity curve so the
   bench doubles as a strategy regression gate.

3. memory-recall.bench.mjs — cosine-similarity top-K linear scan
   over N ∈ {100, 1000, 5000} 384-dim Gaussian embeddings (matches
   all-MiniLM-L6-v2 output dim). p95 at N=5000 is ~4 ms. Recall@10
   is computed against a 90% subset — the approximate-vs-exact gap
   an HNSW backend would have. The bench is the regression budget
   for any future linear→HNSW migration in the plugin.

Each bench writes markdown to stdout; baselines for all three are
captured under benchmarks/results/<name>-baseline-<timestamp>.md.
Synthetic data is mulberry32-seeded so the numbers are stable across
runs and CI workers — no live Yahoo, no network dependency.

Co-Authored-By: ruflo-bot <ruflo-bot@users.noreply.github.com>
2026-05-20 16:48:22 -04:00
ruvandruflo-bot e073b38fed feat(neural-trader): #55 — wire native sublinear CG dispatch (40-60× when available)
The Phase 3 SublinearAdapter (PR #2070) shipped with a JS-only kernel.
This wires the dispatch path to mcp__ruflo-sublinear__solve when the
ruflo-sublinear plugin is registered + available at runtime, falling
back to the local JS CG when not. The dispatch is detected via
`SublinearAdapter.detectSublinearTool()` (probes globalThis for the
mounted tool first, then honours `RUFLO_SUBLINEAR_NATIVE=1` as an
operator-controlled manual override for canary / A-B rollouts).

When the native path is hit, expected speedup is 40-60× per the
sublinear-time-solver@1.7.0 measured baseline (816 ns vs 50 µs Neumann
at n=256). Local JS fallback remains at 1.5-1.9× — same as PR #2070's
measured baseline, re-confirmed in this branch's bench.

Adapter result now carries `method: 'cg-sublinear-native' | 'cg-local'`
and `solver: 'sublinear-time-solver@1.7.0' | 'local-js-cg'` so the
operator can verify which backend ran. The trader-portfolio-cg skill
pulls both fields straight from the adapter result and records them
in the trading-risk artifact metadata.

Bench gained `CG native (ms)` and `Native speedup` columns — graceful
"n/a" when the tool surface isn't reachable. The smoke gained contract
checks for `detectSublinearTool`, `RUFLO_SUBLINEAR_NATIVE`, and the
new method+solver result fields. Smoke only validates the dispatch
contract; the actual 40-60× measurement requires the daemon to mount
the MCP tool — CI exercises that path.

Files:
  - plugins/ruflo-neural-trader/src/sublinear-adapter.{ts,mjs}
  - plugins/ruflo-neural-trader/skills/trader-portfolio-cg/SKILL.md
  - plugins/ruflo-neural-trader/benchmarks/portfolio-cg.bench.mjs
  - plugins/ruflo-neural-trader/benchmarks/results/cg-native-baseline-20260520T202735Z.md
  - scripts/smoke-neural-trader-portfolio-cg.mjs

Refs #55 (downstream task tracker), ruvnet/ruflo#2068 (ADR-126 Phase 3)

Co-Authored-By: ruflo-bot <ruflo-bot@users.noreply.github.com>
2026-05-20 16:28:51 -04:00
ruv 11c1ad974f feat(neural-trader): #2068 ADR-126 Phase 6 — feature attribution via single-entry PR
Phase 6 of ADR-126 closes the regulator-grade interpretability gap that
LSTM / Transformer trading signals leave by default. Given a `signalId`,
the new `trader-explain` skill builds a feature-contribution graph, runs
single-entry forward-push PageRank from the signal output node, and
persists the top-K ranked features to `trading-analysis` as a
`SignedAttributionArtifact`.

What's new:
- `plugins/ruflo-neural-trader/src/signed-attribution.{ts,mjs}` —
  typed contract + runtime mirror for the Ed25519-signed attribution
  envelope. Re-uses the Phase 4 signing scheme exactly (canonical body
  excludes signature fields; verifier pins to a caller-supplied
  `trustedPublicKey`, NOT the served `witnessPublicKey` — CWE-347 /
  #1922). Adds `localSingleEntryPageRank` (seeded mulberry32 power-
  iteration fallback, ~30 LOC), `singleEntryPageRank` (MCP dispatch with
  local fallback, mirrors the SublinearAdapter pattern from Phase 3), and
  `topKFeatures` (deterministic tie-breaking by node index).
- `plugins/ruflo-neural-trader/skills/trader-explain/SKILL.md` —
  the call site. Retrieves the signal from `trading-signals`, extracts
  per-feature contributions via `npx neural-trader --predict --explain
  --json` (degrades to a z-score heuristic if the flag isn't shipped
  upstream yet — artifact tagged `attribution_method:
  "input-zscore-fallback"`), runs the PageRank, signs the result with
  `signAttributionArtifact`, persists to `trading-analysis`, and surfaces
  a markdown ranking table to the agent.
- `scripts/smoke-neural-trader-feature-attribution.mjs` — three-layer
  regression smoke: (1) static contract on TS/MJS + skill, (2) Ed25519
  crypto round-trip with tamper detection on feature scores AND on the
  graphMetadata.seed (seed is signed-in), (3) reproducibility — same seed
  → byte-identical scores + ordering; different seed → scores differ.
- `.github/workflows/v3-ci.yml` — `neural-trader-feature-attribution-smoke`
  job with path triggers on the three load-bearing artifacts.
- `plugins/ruflo-neural-trader/README.md` — new "Feature attribution"
  section with schema, example output, regulator-compliance angle
  (EU AI Act Article 13 / SEC Reg-AI), and reproducibility guarantee.
- `plugins/ruflo-neural-trader/scripts/smoke.sh` — step 2 now requires
  9 skills (was 8), adding `trader-explain` to the contract check.

Acceptance (ADR-126 Phase 6):
- All 36 checks in `scripts/smoke-neural-trader-feature-attribution.mjs`
  pass: static contract, crypto round-trip, reproducibility, mass
  conservation, signed-seed coverage.
- No regression: portfolio-cg smoke, backtest-signing smoke, pipeline
  smoke all still green.
- Plugin smoke: 11 passed, 0 failed.
- `npx neural-trader --help` still clean (no upstream regression).

With Phase 6 landed, all six phases of ADR-126 are now complete:
  Phase 1 — Namespace alignment
  Phase 2 — TTL + dedup lifecycle (#2069)
  Phase 3 — Portfolio CG via sublinear (#2070)
  Phase 4 — Ed25519-signed backtest artifacts (#2071)
  Phase 5 — SendMessage risk-gate pipeline (#2071)
  Phase 6 — Feature attribution via single-entry PageRank (this PR)

Closes #2068

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 23:04:14 -04:00
ruv f8485c7b77 feat(neural-trader): #2068 ADR-126 Phase 5 — SendMessage risk-gate pipeline
Refactor the four neural-trader agents as a typed SendMessage pipeline
with risk-analyst as a structural BLOCKING GATE. The live broker call
(`npx neural-trader --broker <name>`) cannot fire without an explicit
RiskDecision approval event from risk-analyst for the proposal's
signalId.

Pipeline:
  market-analyst       → (RegimeVerdict)     → trading-strategist
  trading-strategist   → (SignalProposal[])  → risk-analyst  ◄── BLOCKING
  risk-analyst         → (RiskDecision)      → trading-strategist
                                              └→ execute-or-halt
  backtest-engineer    — orthogonal (signed promotion candidates only)

Reinforces Phase 4: signed artifacts give cryptographic provenance of
what was tested; the SendMessage risk-gate gives auditable provenance
of who approved the trade.

- src/pipeline-messages.ts: RegimeVerdict, SignalProposal, RiskDecision
  TypeScript schemas + PipelineMessage discriminated union. Future
  programmatic dispatchers can switch on `type` to validate routing.
- agents/market-analyst.md: pipeline entry point, sends RegimeVerdict
  to trading-strategist. Comms protocol section appended.
- agents/trading-strategist.md: middle stage. Live broker step
  (--broker <name>) now carries an explicit REFUSAL clause:
  refuses to fire without a RiskDecision approval for the signalId.
  Includes [ERROR] log shape + "NON-NEGOTIABLE" language so future
  refactors see the gate is mandatory.
- agents/risk-analyst.md: blocking gate. Receives SignalProposal,
  runs circuit-breaker checks, sends RiskDecision (approved or
  rejected with reasons + adjustedSizePct).
- agents/backtest-engineer.md: documented as orthogonal research
  lane — produces signed-artifact promotion candidates (Phase 4),
  does NOT participate in the live pipeline hot path.
- scripts/smoke-neural-trader-pipeline.mjs: four-layer smoke.
  Frontmatter + comms-section + structural-gate static checks, plus
  a behavioral mock that drives the pipeline. Happy path executes;
  missing approval, rejected decision, AND mismatched signalId are
  ALL refused (proves the gate correlates by signalId).
- .github/workflows/v3-ci.yml: neural-trader-pipeline-smoke job +
  path triggers for pipeline-messages.ts + all 4 agent files +
  the smoke script.

Smoke output: 28/28 checks pass. Phase 3 portfolio-CG smoke unchanged.
Phase 4 backtest-signing smoke unchanged (21/21). Plugin smoke.sh:
11/11 still pass.

Refs #2068

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 22:44:34 -04:00
ruv 48cb0a7ee8 feat(neural-trader): #2068 ADR-126 Phase 4 — Ed25519-signed backtest artifacts
Add cryptographic tamper-evidence to the paper→live promotion gate.
Mirrors the CWE-347 plugin-registry pattern (#1922): canonical body =
JSON.stringify without signature fields; verifier pins to a caller-
supplied trustedPublicKey, NOT to the served self-asserted
witnessPublicKey (which an attacker can swap freely).

- src/signed-artifact.{ts,mjs}: SignedBacktestArtifact schema + signer
  + verifier. Both files kept in sync; .mjs is the runtime the smoke
  imports directly (plugin has no build step).
- skills/trader-backtest: signs the artifact before store. Resolves
  the key via RUFLO_WITNESS_KEY_PATH → verification/witness-key.json
  → loud degraded-unsigned warning. Never silent.
- skills/trader-cloud-backtest: verifies the artifact against the
  pinned trusted pubkey BEFORE promoting to a live strategy. Refuses
  to promote on verify failure (fail-closed).
- scripts/smoke-neural-trader-backtest-signing.mjs: three-layer smoke
  modeled on smoke-plugin-registry-signature.mjs. Static contract,
  crypto round-trip (tampered/empty/swapped-served-key/wrong-trusted-key),
  and call-site byte check on the SKILL.md files.
- .github/workflows/v3-ci.yml: neural-trader-backtest-signing-smoke job
  + path triggers for the artifact files + both skill SKILL.md files.

Smoke output: 21/21 checks pass. Phase 3 portfolio-CG smoke unchanged.
Plugin smoke (scripts/smoke.sh): 11/11 still pass.

Refs #2068

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 22:39:21 -04:00
ruv 9c075a3c36 feat(neural-trader): #2068 ADR-126 Phase 3 — portfolio CG via sublinear/solve (40-60x)
Wires the Conjugate-Gradient mean-variance solve `Σ · x = μ` that ADR-123
Wedge 8 promises a 40-60× speedup over the legacy Neumann series. Ships:

- `src/sublinear-adapter.ts` — `SublinearAdapter` class per the ADR-123
  §262-289 contract: `solveCG(matrix, vector, opts)`, `isMcpAvailable()`,
  `SolveResult` shape, SPD/symmetric sanity checks, graceful degrade with
  `degraded: true` for malformed inputs.
- `src/sublinear-adapter.mjs` — runtime mirror so the smoke + bench
  import the adapter directly (the plugin has no build step). Both files
  ship a self-contained ~50-LOC CG kernel + Jacobi/Neumann baseline; the
  same call site picks up the full native-WASM speedup automatically
  once `mcp__ruflo-sublinear__solve` is registered.
- `skills/trader-portfolio-cg/SKILL.md` — declares `mcp__ruflo-sublinear__solve`
  in allowed-tools, writes weights with provenance metadata
  (`method: 'cg-sublinear' | 'cg-local' | 'neumann-fallback'`) to the
  canonical `trading-risk` namespace (ADR-126 Phase 1 alignment),
  documents the `RUFLO_NEURAL_TRADER_DISABLE_CG` disable flag, defines
  the legacy `npx neural-trader --portfolio optimize` fallback.
- `benchmarks/portfolio-cg.bench.mjs` — CG vs Neumann on synthetic SPD
  covariance at n ∈ {16, 64, 256}. Fixed-seed parity check
  (`||cg − neumann||_∞ < 1e-4`) and per-size latency table.
- `benchmarks/results/cg-baseline-20260520T022220Z.md` — captured
  baseline numbers. CG at n=256 is sub-ms (0.31 ms). The JS-vs-JS gap is
  ~1.5-1.9× because both kernels JIT to similar efficiency; the upstream
  40-60× figure is for native-CG vs native-Neumann in
  `sublinear-time-solver@1.7.0`, which the skill picks up automatically
  through the MCP dispatch.
- `scripts/smoke-neural-trader-portfolio-cg.mjs` — three-layer regression
  smoke: static adapter contract (class shape, method signatures, MCP
  tool name), static skill contract (allowed-tools, namespace, disable
  flag, fallback path), runtime correctness (textbook 2×2 SPD case
  A=[[4,1],[1,3]], b=[1,2] → x=[1/11, 7/11] within 1e-6, plus degraded
  paths for non-square / non-symmetric input).
- `.github/workflows/v3-ci.yml` — `neural-trader-portfolio-cg-smoke` job
  on the same shape as the kg-extract guard; triggers on adapter, skill,
  or smoke changes.
- `README.md` + plugin-smoke skill-count bumped from 7 → 8.

Acceptance:
- `bash plugins/ruflo-neural-trader/scripts/smoke.sh` → 11/11 pass.
- `node scripts/smoke-neural-trader-portfolio-cg.mjs` → all 17 checks pass.
- Bench parity: `||cg − neumann||_∞ < 1e-4` at every n ∈ {16, 64, 256}.

Refs: #2068, ADR-126 Phase 3, ADR-123 §162 Row 8 (Wedge 8).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 22:22:56 -04:00
ruv d9bd4e6adb feat(neural-trader): #2068 ADR-126 Phase 2 — ADR-125 memory lifecycle (TTL + dedup + warm HNSW doc)
Wires the plugin into the ADR-125 lifecycle guarantees shipped in
@claude-flow/memory@3.0.0-alpha.18 (already published). No new code,
just three lifecycle hooks:

1. trader-signal/SKILL.md
   - Adds `expiresAt: Date.now() + 24h` to the signal memory_store call.
     Rationale: intraday signals shouldn't pollute long-running memory;
     the MemoryConsolidator.sweepExpired() pass (ADR-125 Phase 4) clears
     them from all indexes — including HNSW — after they expire.
   - Adds `mcp__claude-flow__memory_delete` to allowed-tools (for
     symmetry with the dedup path; trader-signal itself doesn't delete
     today, but the allowed-tools surface is shared across the lifecycle
     story so consumers don't have to mentally re-derive permissions).

2. trader-backtest/SKILL.md
   - New step 5: search for prior entries with the same (strategyId,
     paramsHash) and memory_delete them before writing the fresh result.
     Inline dedup keeps memory_search deterministic right after a re-run.
   - Documents that the MemoryConsolidator.dedup('keep-newest') pass
     achieves the same convergence asynchronously every 6h, so the
     inline step is an optimization not a correctness requirement.
   - Adds `mcp__claude-flow__memory_delete` to allowed-tools.
   - Renumbers subsequent steps.

3. README.md — new "Memory lifecycle (ADR-125 integration)" subsection
   under "Namespace coordination". Covers:
   - Warm HNSW restart (Phase 3 — automatic via MemoryService)
   - Hybrid retrieval RRF+MMR (Phase 5 — automatic, graceful FTS5
     degrade)
   - Signal TTL (24h)
   - Backtest dedup (inline + 6h consolidator)
   - Consolidator schedule

Smoke: 11 passed, 0 failed.

Refs #2068

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 21:59:44 -04:00
ruv 8d9e20f0c6 fix(neural-trader): #2068 ADR-126 Phase 1 — canonical 5-namespace alignment (was bug)
Resolves the three-way namespace mismatch surfaced by the ADR-126 dossier:
- README.md L198-205 previously claimed 4 (-strategies/-backtests/-risk/-analysis)
- docs/adrs/0001 L63 previously claimed 4 (-backtests/-risk/-signals/-models)
- skills/trader-signal/SKILL.md L35 actually writes to `trading-signals`
- skills/trader-train/SKILL.md L28 actually writes to `trading-models`

The smoke test previously validated only the README's four, so signal data
silently landed in `trading-signals` (undeclared) and model results landed
in `trading-models` (undeclared), invisible to any downstream consumer
scoped to the documented namespace surface.

Aligns README, ADR-0001, smoke.sh, and trader-train on the canonical 5
defined by ADR-126 Phase 1:

  trading-strategies   — strategy definitions, parameters, regime mappings
  trading-backtests    — backtest results (long-lived; signed in Phase 4)
  trading-risk         — risk model state, VaR/CVaR, circuit-breaker triggers
  trading-analysis     — regime classifications + model-training results
  trading-signals      — short-lived signal events (TTL in Phase 2)

trader-train now stores model results to `trading-analysis` (was the
undeclared `trading-models`). smoke.sh check 8 now asserts the fifth
namespace claim. All 11 smoke checks still pass.

Refs #2068

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 21:57:26 -04:00
rUvandReuven 639b45a66b docs(plugin): correct runtime smoke gate count 17 → 20 (#1990)
The README still referenced "17 documented entry points end-to-end"
but #1988 extended the smoke to 20 (pairs/adaptive/multi-indicator
gates added). Update the text to match the actual gate count and
list what's covered.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 15:32:24 -04:00
rUvandReuven 17986904a5 chore(plugin): bump pin to ^2.8.11 + add pairs/adaptive/multi-indicator smoke (#1988)
Updates the README prerequisites block to reflect the 2.8.x line
(flag-style CLI dispatcher with --backtest, --signal, --risk,
--portfolio, --regime, --train, --predict, --strategy-create) and
the analytical layers (walk-forward, Monte Carlo, multi-symbol,
benchmark, optimize, Kelly).

Extends runtime-smoke.sh with three new gates for the strategies
shipped in 2.8.10 and 2.8.11:

  17. pairs strategy returns metrics
  18. adaptive strategy picks regime
  19. multi-indicator strategy runs

All 20 gates pass against neural-trader 2.8.11.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 14:42:03 -04:00
rUvandReuven b92716b322 test(plugin): extend runtime smoke to assert advanced backtest features (#1985)
Adds 6 new gates (11-16) that exercise the features wired in
neural-trader 2.8.x:

  11. .metrics.kellyFraction       (real Kelly from win/loss stats)
  12. .walkForward.windowsRun       (rolling 6m/1m validation)
  13. .monteCarlo.distribution      (Gaussian-resampled p5/p50/p95)
  14. .optimization.best.sharpeRatio (parameter sweep result)
  15. .signalsCount                  (live indicator scan)
  16. .aggregate.bestSymbol          (multi-symbol aggregate)

Also bumps NT_PIN default to 2.8.9. Current result: 17 / 17.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 14:05:38 -04:00
rUvandReuven cad471be2f test(plugin): add runtime smoke that exercises every documented command (#1984)
The existing `plugins/ruflo-neural-trader/scripts/smoke.sh` is
structural-only (file presence, README pins, frontmatter checks). It
passed for months while `npx neural-trader --backtest` and every
other documented invocation crashed at runtime — those gaps got
caught and fixed across neural-trader 2.7.5 → 2.8.1.

This adds a sibling `runtime-smoke.sh` that actually:
  1. Installs `neural-trader@2.8.1` in a clean tmpdir
  2. Runs each of the 8 commands the plugin's skills document
  3. Parses the JSON output and asserts `.command == <expected>`
  4. Confirms `require('neural-trader')` exposes >= 100 exports
  5. Confirms `--version` returns the pinned major.minor

Run:
  bash plugins/ruflo-neural-trader/scripts/runtime-smoke.sh

Current result: 11 passed, 0 failed.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 12:42:47 -04:00
rUvandReuven c37b7764b9 chore(plugin): bump neural-trader pin 2.7.2 → ^2.7.6 (#1982)
`neural-trader@2.7.6` is on npm with three working platform binaries
(linux-x64-gnu, darwin-arm64, darwin-x64) and three additional bugs
fixed beyond the install-hook fork-bomb that was resolved in 2.7.2:

  • Missing `napi-loader-shared.js` / `napi-loader.js` /
    `validation-utils.js` restored — `require('neural-trader')` no
    longer throws at import time on any platform (broken since
    2.5.0).
  • `fasthash-sys` x86-only SIMD flags replaced with stdlib
    `DefaultHasher` — `cargo build` now succeeds on aarch64-darwin.
  • Cross-platform binaries actually ship — `darwin-arm64` and
    `darwin-x64` are in the tarball for the first time ever.

Updates the README prerequisite block to reflect the new resolution,
adds a platform-coverage table, and pins to `^2.7.6` (compatible
with whatever future patches add linux-arm64 + win32 binaries).

Refs:
  • ruflo#1974 (original bug report)
  • ruflo#1981 (announcement)
  • https://gist.github.com/ruvnet/a1aca90a5c299d89fa92e905dab11041

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 11:02:41 -04:00
rUvandReuven 4051aeecad docs(neural-trader): record 2.7.2 fix, keep --ignore-scripts as defense (#1974) (#1979)
`neural-trader@2.7.2` published 2026-05-14 — install hook no longer spawns
a recursive `npm install`. Cite the upstream PR (ruvnet/neural-trader#109)
in the README's Prerequisites section, recommend pinning to >=2.7.2, and
keep the `--ignore-scripts` flag on every documented install as defense
in depth (cheap belt-and-braces against any future install-script
regression — and what `scripts/audit-neural-trader-safety.mjs` still
enforces).

The "danger zone" advisory still appears for anyone pinned to <=2.7.1,
since lockfiles can hold older versions long after the fix lands.

Verified end-to-end:
  $ rm -rf /tmp/nt-verify && mkdir /tmp/nt-verify && cd /tmp/nt-verify
  $ perl -e 'alarm 30; exec("npm","install","neural-trader@latest")'
  added 698 packages in 18s   ← was 80 min / 120 GB RAM
  exit=0
  $ ps aux | grep -c "[n]eural-trader"
  1   ← was 3,049

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 09:17:06 -04:00
rUvandReuven 4bd194554d fix(neural-trader): mitigate upstream fork-bomb on install + CI guard (#1974) (#1976)
The upstream `neural-trader@2.7.1` (and every earlier published version
audited) ships a malicious-by-accident `install` lifecycle script that
recursively invokes `npm install` from inside the install hook. On any
non-`linux-x64` host the recursion is unbounded — one reporter saw 3,049
stuck processes consuming ~120 GB of RAM in ~80 minutes before manual
intervention.

The `plugins/ruflo-neural-trader/README.md` Prerequisites section said
plainly `npm install neural-trader` — running THAT instruction is what
fork-bombs the machine.

We can't patch upstream from this repo, but we can stop telling users
to run the dangerous command. Mitigations:

  - README Prerequisites: add a prominent warning advisory + switch
    the recommended install to `npm install --ignore-scripts neural-trader`.
    The linux-x64 binary is hardcoded inline in the upstream tarball,
    so the package still works after `--ignore-scripts` on that platform.
  - agents/trading-strategist.md: same `--ignore-scripts` fix on the
    "Ensure installed" line that previously fork-bombed if the package
    wasn't already cached.
  - 6 skill files (trader-backtest/portfolio/regime/risk/signal/train):
    same one-liner fix.
  - trader-cloud-backtest/SKILL.md: also patch the `npm install -g
    neural-trader` line in the Managed-Agent `initScript` — cloud
    containers ARE isolated, but the same in-container fork-bomb
    amplification is still a problem.

CI guard: `scripts/audit-neural-trader-safety.mjs` scans
`plugins/ruflo-neural-trader/` for any `npm install neural-trader` /
`npm i neural-trader` invocation that doesn't also carry
`--ignore-scripts`. Allowlist: lines preceded by a "DO NOT run" marker
(the README's anti-example block). Wired into the existing
`hook-command-audit` job in `v3-ci.yml`.

Verified:
- audit clean on the fixed tree
- audit catches a deliberately-reverted regression (exit 1, diagnostic
  names the offending file:line)
- all other audits + plugin smoke still green

Mitigates #1974 in THIS repo. Upstream fix to the `neural-trader` npm
package (drop the recursive `npm install` in the install hook + publish
the platform-binary optionalDependencies) is still required for the
underlying bug.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 08:03:31 -04:00
rUvandReuven 545426f605 docs(adr-117): neural-trader heavy jobs on the Managed Agent cloud runtime (#1935)
ADR-117 (Accepted): dispatch heavy neural-trader jobs — multi-year
walk-forward backtests, big Monte-Carlo, parameter sweeps, LSTM/
Transformer/N-BEATS training — to an Anthropic Managed Agent cloud
container via the managed_agent_* tools (ADR-115, shipped in
3.7.0-alpha.27). No new MCP tools, no new deps — pure orchestration.

- skills/trader-cloud-backtest/SKILL.md — the recipe (provision-once,
  pre-flight-cheap, run, ingest-locally, terminate-eagerly); allowed-tools
  scoped to managed_agent_* + memory_* + agentdb_pattern-store + Bash/Read
  (no wildcard grant).
- commands/trader.md — /trader cloud <backtest|train|sweep> subcommand.
- scripts/smoke.sh — step 2 now asserts the 7th skill exists, references
  managed_agent_create, and names the local trader-backtest fallback;
  step 10 ADR-status check corrected to Accepted.
- README.md — overview + skills table + Architecture-Decisions +
  Related-Plugins cross-refs to ADR-117 / ADR-115 / ruflo-agent.
- ADR-115 Links — cross-refs ADR-117 as the first consumer.

Cost-optimization rules baked into the recipe (the "optimize" requirement):
install-once in initScript, reuse the environment, pre-flight cheap
(1-path/3-month smoke before a 1000-path/multi-year run), batch sweeps into
one prompt, terminate eagerly + GC orphans (#1931), cheap agent model
(Haiku/Sonnet — the compute is the Rust engine, not the LM; ADR-026),
estimate before kicking off.

Validation: ruflo-neural-trader smoke 11/0, ruflo-agent smoke 12/0,
audit-cli-mcp-tools / audit-tool-descriptions / audit-plugin-packages /
audit-hook-commands all green. No new MCP tools → cli build unaffected.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-12 12:31:42 -04:00
ReuvenandRuFlo 02eee0bcdc docs(adr): bulk-update plugin contract ADR statuses (sweep)
- 27 plugins moved Proposed → Accepted (shipped versions, in marketplace)
  - 0 plugins kept as Proposed (all have real versions ≥ 0.2.0)

Per-plugin breakdown:
  ruflo-aidefence    v0.2.0  Accepted — 3-gate pattern, 6 aidefence_* tools
  ruflo-autopilot    v0.2.0  Accepted — 10 autopilot_* tools, /loop integration
  ruflo-core         v0.2.1  Accepted — MCP server contract, plugin-catalog discovery
  ruflo-cost-tracker v0.16.1 Accepted — namespace-routing fix, ADR-097 budget integration
  ruflo-daa          v0.2.0  Accepted — 8 daa_* tools, intelligence-pipeline alignment
  ruflo-ddd          v0.2.0  Accepted — AgentDB domain graph, SPARC Architecture-phase
  ruflo-docs         v0.2.0  Accepted — document worker dispatch, drift detection
  ruflo-federation   v0.2.0  Accepted — ADR-097 Phase 1+2, 3-gate alignment
  ruflo-goals        v0.2.0  Accepted — 6 namespaces, GOAP + dossier ADR-099
  ruflo-iot-cognitum v0.2.0  Accepted — 5-tier trust, 6 background workers
  ruflo-jujutsu      v0.2.0  Accepted — 6 analyze_* tools, ADR-compliance cross-link
  ruflo-knowledge-graph v0.2.0 Accepted — embeddings_generate fix, pathfinder
  ruflo-loop-workers v0.2.0  Accepted — 12 worker triggers, 5 hooks_worker-* tools
  ruflo-market-data  v0.2.0  Accepted — embeddings + namespace-routing bugs fixed
  ruflo-migrations   v0.2.0  Accepted — namespace-routing bug fixed both skills
  ruflo-neural-trader v0.2.0 Accepted — 4 namespaces already compliant
  ruflo-observability v0.2.0 Accepted — namespace-routing bug fixed both skills
  ruflo-plugin-creator v0.2.0 Accepted — scaffolding templates updated with contract
  ruflo-rag-memory   v0.2.0  Accepted — claude-memories reserved namespace consumer
  ruflo-ruvllm       v0.2.0  Accepted — LLM-config + chat-format slice ownership
  ruflo-rvf          v0.2.0  Accepted — portable-memory + session-persistence slice
  ruflo-security-audit v0.2.0 Accepted — 3-gate + audit_1776853149979 regression class
  ruflo-sparc        v0.2.0  Accepted — all 5 SPARC phases cross-linked
  ruflo-swarm        v0.2.0  Accepted — 12 MCP tools (4 swarm_* + 8 agent_*)
  ruflo-testgen      v0.2.0  Accepted — testgaps worker + coverage CLI commands
  ruflo-wasm         v0.2.0  Accepted — 10 wasm_* tools, ADR-070 cross-ref
  ruflo-workflows    v0.2.0  Accepted — 10 workflow_* tools, SPARC phase transitions

Each ADR received: updated: 2026-05-09 in frontmatter + Implementation status
section noting version, marketplace presence, and contract element alignment.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-09 15:10:42 -04:00
ReuvenandRuFlo e148c56119 feat(ruflo-neural-trader): adopt plugin contract — already-compliant namespaces + 4-namespace claim (ADR-0001)
Plugin already at v0.2.0 with 4 agents + 6 skills + 1 command. Namespace
audit: all 4 namespaces (trading-strategies, trading-backtests,
trading-risk, trading-analysis) already kebab-case compliant and routed
through memory_* correctly. No bugs found.

Notable design choice: namespace prefix is `trading-` not
`neural-trader-`. ADR-0001 documents this as deliberate — `trading` is
the load-bearing concern downstream consumers reason about. The
<plugin-stem>-<intent> convention is interpreted broadly: when the
plugin's primary concern is the cleaner stem, that stem wins.

- ADR-0001 (Proposed) at docs/adrs/0001-neural-trader-contract.md
- README adds Compatibility (pin v3.6 + npx neural-trader runtime),
  Namespace coordination block claiming the 4 trading-* namespaces with
  the prefix-choice rationale, Verification + Architecture Decisions
- plugin.json keywords add neural-trader-runtime, walk-forward,
  monte-carlo (already at 0.2.0)
- scripts/smoke.sh — 11 structural checks: version + keywords, all 6
  skills + 4 agents + command present, v3.6 pin, neural-trader runtime
  pin, namespace coordination, 4 namespace claims, backtesting features
  (walk-forward / Monte Carlo / parameter optimization), ADR Proposed,
  no wildcard tools

Verification: bash plugins/ruflo-neural-trader/scripts/smoke.sh → 11/11

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-04 20:23:15 -04:00
Reuvenandclaude-flow 7ed18b8335 feat: upgrade neural-trader, ruvector, rag-memory plugins to wrap npm packages
- ruflo-neural-trader: wrap npx neural-trader (v2.7+), add market-analyst
  and backtest-engineer agents, add trader-regime/train/risk skills (4 agents, 6 skills)
- ruflo-ruvector: wrap npx ruvector — FlashAttention-3, Graph RAG, hybrid
  search, DiskANN, 103 MCP tools, Brain AGI
- ruflo-rag-memory: SOTA upgrade — hybrid search (sparse+dense RRF),
  Graph RAG multi-hop, MMR diversity, adaptive chunking, consolidation
- plugins/README.md: add npm package integration section

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-30 00:02:40 -04:00
Reuvenandclaude-flow f25bcf2073 feat: add 10 new ruflo plugins, optimize all 32, add READMEs and user guide
New plugins: ruflo-adr (ADR lifecycle), ruflo-ddd (domain-driven design),
ruflo-sparc (SPARC methodology), ruflo-neural-trader (trading strategies),
ruflo-ruvector (vector embeddings), ruflo-knowledge-graph (entity graphs),
ruflo-market-data (OHLCV ingestion), ruflo-migrations (schema management),
ruflo-observability (logging/tracing), ruflo-cost-tracker (token budgets).

Optimizations across all 32 plugins:
- All pass `claude plugin validate` (removed invalid manifest arrays)
- 51/51 skills have argument-hint frontmatter
- Model routing: 4 haiku, 24 sonnet, 2 opus (cost-optimized)
- Neural learning hooks on 25/30 agents
- Cross-references between 6 related plugin pairs
- Pathfinder graph traversal algo for researcher agent
- READMEs for all 32 plugins + plugins/README.md catalog
- discover-plugins skill updated with full 32-plugin catalog

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-29 23:46:54 -04:00