用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/cvsz/zeaz-platform --skill zai-trader命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Master skill combining related sub-skills
Provides foundational definitions for the ZAI Agents Pack, encompassing the Omega Master Agent Matrix and associated lifecycle setups.
Comprehensive guide to Artificial Intelligence basics, including LLMs, Machine Learning, and Generative AI principles.
基于 SOC 职业分类
正在显示 SKILL.md
| name | zai-trader |
| description | Master skill combining related sub-skills |
When implementing tasks on the zeaz-platform repository, you MUST strictly enforce these architecture and workflow rules:
apps/ directory. Do not create top-level directories for apps. When refactoring or adding features, always scope your work to the specific apps/<app-name>/ folder..env files. Consolidate environment variables into a central .env.example inside the respective app folder. Canonical Cloudflare variables (e.g. CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID) MUST be used instead of legacy CF_ variants.git commit or git push directly. ALWAYS stage your intended files with git add and commit using make gpg-finalize COMMIT_MSG="..." from the repository root to ensure all GitOps and DevSecOps checks pass.test-secret-value-value-value, test-secret-value-value-value, test-secret-value-value-value are FORBIDDEN.Run a historical backtest using the neural-trader Rust/NAPI engine, then Ed25519-sign the result so the paper→live promotion gate has cryptographic tamper evidence (ADR-126 Phase 4 + CWE-347 pattern).
Steps:
npm ls neural-trader 2>/dev/null || npm install --ignore-scripts neural-tradermcp__claude-flow__memory_retrieve({ key: "strategy-STRATEGY_NAME", namespace: "trading-strategies" })
If not found, list available: mcp__claude-flow__memory_search({ query: "strategy", namespace: "trading-strategies", limit: 10 })npx neural-trader --backtest --strategy <name> --symbol <TICKER> --period <range> --walk-forward
For multi-indicator strategies:
npx neural-trader --backtest --strategy multi-indicator --position-sizing kelly --symbol SPY --period 2020-2024
(strategyId, paramsHash) before storing the fresh one (ADR-125 lifecycle / ADR-126 Phase 2 — keep-newest semantics):
mcp__claude-flow__memory_search({ query: "backtest STRATEGY paramsHash:PARAMS_HASH", namespace: "trading-backtests", limit: 10 })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" })MemoryConsolidator.dedup('keep-newest') background pass introduced in @claude-flow/memory@3.0.0-alpha.18 runs every 6h and will eventually converge. Doing it inline keeps memory_search results deterministic immediately after a re-run.)SignedBacktestArtifact body — { strategyId, paramsHash, dataRange: {from,to}, metrics, runsHash, generatedAt } — where paramsHash = sha256(canonical params JSON), runsHash = sha256(canonical runs array JSON), and generatedAt = new Date().toISOString().RUFLO_WITNESS_KEY_PATH env var — points to a JSON file with { "privateKey": "<hex>" }.{ "privateKey": "<64-hex-chars>" } in a JSON file referenced by RUFLO_WITNESS_KEY_PATH. Keep it OUT of the repo. For local development, generate one once with node -e "import('@noble/ed25519').then(async ed=>{const sk=crypto.getRandomValues(new Uint8Array(32));console.log(Buffer.from(sk).toString('hex'))})" and write it to ~/.ruflo/witness-key.json.trustedPublicKey to verifyBacktestArtifact(...) — never trust the witnessPublicKey field on the artifact itself (CWE-347 / #1922).Dispatch a heavy neural-trader job to an Anthropic Claude Managed Agent (cloud container) instead of running it locally. See project ADR-117 (recipe + cost rules) and ADR-115 (the managed_agent_* runtime).
trader-backtest (local)| Job | Runtime |
|---|---|
| Quick sanity check; one short backtest (< ~1 min) | local — use the trader-backtest skill |
| Multi-year walk-forward, big Monte-Carlo count, parameter sweep over a grid, or model training (LSTM/Transformer/N-BEATS) | cloud — this skill |
Prereq: ANTHROPIC_API_KEY (or CLAUDE_API_KEY) + Managed Agents beta access. If managed_agent_* returns "needs ANTHROPIC_API_KEY", fall back to the local trader-backtest skill.
Estimate first. From the job size, print an estimated cost (≈ container-minutes × rate + tokens) — a long sweep is a deliberate choice, not a default.
Provision (or reuse) the container — install neural-trader at container start so the agent doesn't reinstall mid-run:
managed_agent_create({
name: "nt-cloud",
model: "claude-haiku-4-5-20251001", // orchestration only — the compute is the Rust engine, not the LM (ADR-026)
system: "You operate the `neural-trader` CLI in this container. Run exactly the commands asked, report the metrics, write requested artifacts, then stop.",
networking: "unrestricted", // or "restricted" pinned to your data host
packages: { npm: ["neural-trader"] }, // add apt:["build-essential"] ONLY if there's no prebuilt NAPI binary for the arch (neural-trader ships prebuilds → usually omit)
initScript: "npm install -g --ignore-scripts neural-trader >/dev/null 2>&1 || npx -y neural-trader --version >/dev/null 2>&1 || true"
})
→ { sessionId, agentId, environmentId }
For a sweep: create the environment once, run all configs in one managed_agent_prompt (one container), not N sessions.
Pre-flight cheap. Before a 1000-path / multi-year run, do a tiny smoke first (1 MC path, ~3 months) — catches a bad strategy name / symbol in seconds:
managed_agent_prompt({ sessionId, message: "Run `npx neural-trader --backtest --strategy <name> --symbol <TICKER> --period <last 3 months> --mc-paths 1`. Just confirm it ran and report the Sharpe. Then stop.", maxWaitMs: 60000 })
If that fails, fix the args before the real run (and managed_agent_terminate).
Run the real job:
managed_agent_prompt({
sessionId,
message: "Run `npx neural-trader --backtest --strategy <name> --symbol <TICKER> --period <range> --walk-forward --mc-paths <N>` (for training: `npx neural-trader --train --model <lstm|transformer|nbeats> --symbol <TICKER> --period <range>`; for a sweep: loop the configs and run each). Report: total return, annualized return, Sharpe, Sortino, max drawdown, win rate, profit factor, # trades, 95% CVaR. Write the equity curve to /tmp/equity.csv and the trade log to /tmp/trades.csv. Then stop.",
maxWaitMs: <generous — minutes>
})
→ { finished, status, stopReason, assistantText (the metrics), toolUses }
If finished:false, follow up with managed_agent_events({ sessionId }) until idle.
Pull artifacts (if needed): managed_agent_prompt({ sessionId, message: "cat /tmp/equity.csv" }) or and read the tool_result.
initScript), reuse the environment, batch sweeps into one prompt, pre-flight cheap, terminate eagerly, use Haiku/Sonnet for the agent loop, estimate before kicking off. (ADR-117 §"Cost optimization".)managed_agent_create { "name":"nt-cloud", "model":"claude-haiku-4-5-20251001", "packages":{"npm":["neural-trader"]}, "initScript":"npm install -g --ignore-scripts neural-trader >/dev/null 2>&1 || true" }
→ { sessionId:"sesn_…", environmentId:"env_…" }
managed_agent_prompt { "sessionId":"sesn_…", "message":"Run `npx neural-trader --backtest --strategy multi-indicator --symbol SPY --period 2020-2024 --walk-forward --mc-paths 1000`. Report Sharpe/Sortino/max-DD/win-rate/CVaR; write /tmp/equity.csv. Then stop.", "maxWaitMs":600000 }
→ { finished:true, status:"idle", assistantText:"<metrics>", toolUses:[{bash:"npx neural-trader --backtest …"}] }
# … memory_store the metrics, agentdb_pattern-store if Sharpe>1.5, record cost …
managed_agent_terminate { "sessionId":"sesn_…", "environmentId":"env_…" }
Explain a trading signal by building a feature-contribution graph and running single-entry forward-push PageRank from the signal output node. Top-K ranked features are returned as a markdown table AND persisted to trading-analysis as a SignedAttributionArtifact (ADR-126 Phase 6).
Why this skill matters:
mcp__ruflo-sublinear__page-rank-entry once that tool is registered in the runtime — until then, the local power-iteration kernel ships in signed-attribution.mjs and produces the same ordering (seeded mulberry32).Steps:
Retrieve the signal from the canonical trading-signals namespace (ADR-126 Phase 1 + Phase 2 lifecycle):
mcp__claude-flow__memory_retrieve({
key: "SIGNAL_ID",
namespace: "trading-signals"
})
The signal entry includes modelId, prediction, and the feature vector at the time of inference.
Extract per-feature contribution scores from the model:
npx neural-trader --predict --signal "$SIGNAL_ID" --explain --json
The expected output shape:
{
features: Array<{ name: string; contribution: number }>;
// for Transformers, also includes per-head attention co-occurrence:
attention?: Array<{ head: string; cooccur: Array<[number, number, number]> }>;
}
Fallback path — if --explain is not shipped on the installed neural-trader build (older versions; the flag was scoped for a follow-up upstream PR), the skill degrades to a deterministic feature-importance heuristic over the signal's input vector: contribution_i = |input_i - μ_i| / σ_i (z-score magnitude). This is a known proxy — not as faithful as attention/SHAP — and the resulting artifact is tagged attribution_method: "input-zscore-fallback" so downstream consumers can filter it out for regulator filings. Document the fallback path in the resulting markdown summary so the agent surfaces it to the user.
Build the feature-contribution graph:
__signal_output__ for the prediction.__signal_output__ to each feature node, weighted by contribution_i. When attention co-occurrence data is available, also add edges between feature nodes weighted by cooccur — this is what makes the PageRank single-entry rather than degenerating to plain top-K.__signal_output__ (index 0 by convention so the smoke can assert reproducibility).Run single-entry PageRank — preferred path when mcp__ruflo-sublinear__page-rank-entry is registered:
mcp__ruflo-sublinear__page-rank-entry({
nodes: GRAPH_NODES,
edges: GRAPH_EDGES,
sourceIndex: 0,
damping: 0.85,
maxIterations: 100,
tolerance: 1e-8,
seed: 42
})
Downstream consumers verify the artifact before any regulator-facing report or paper→live promotion:
import { verifyAttributionArtifact } from 'plugins/ruflo-neural-trader/src/signed-attribution.mjs';
const ok = await verifyAttributionArtifact(artifact, trustedPublicKey);
if (!ok) {
// [ERROR] attribution verification failed — refuse to publish.
// Pin to trustedPublicKey from project config; do NOT trust the
// artifact.witnessPublicKey field (CWE-347 / #1922 — attacker-controllable).
return;
}
Acceptance criteria (ADR-126 Phase 6):
trader-explain <signalId> returns a ranked feature list whose top-3 features overlap the model's attention argmax (when --explain available; documented tolerance).signalId + same --seed produce byte-identical rank ordering (asserted by scripts/smoke-neural-trader-feature-attribution.mjs).graphMetadata.seed invalidates the signature.--explain flag missing, z-score heuristic runs and the artifact is tagged.Refs:
plugins/ruflo-neural-trader/src/signed-attribution.ts (the typed contract)plugins/ruflo-neural-trader/src/signed-attribution.mjs (the runtime mirror)scripts/smoke-neural-trader-feature-attribution.mjs (the regression smoke)Optimize portfolio allocation using neural-trader's portfolio engine.
Steps:
npm ls neural-trader 2>/dev/null || npm install --ignore-scripts neural-tradermcp__claude-flow__memory_search({ query: "current portfolio holdings", namespace: "trading-portfolio" })npx neural-trader --portfolio optimize
With risk target:
npx neural-trader --portfolio optimize --risk-target <number>
npx neural-trader --risk assess --portfolio current
npx neural-trader --var --portfolio current
npx neural-trader --correlation --portfolio current --flag-threshold 0.8
mcp__claude-flow__neural_predict({ input: "expected returns for [HOLDINGS] given current regime" })npx neural-trader --portfolio rebalance
Output: trades needed, current vs target weights, estimated costsmcp__claude-flow__agentdb_pattern-search({ query: "optimized portfolio Sharpe > 1", namespace: "trading-portfolio" })mcp__claude-flow__memory_store({ key: "portfolio-optimal-TIMESTAMP", value: "ALLOCATION_JSON", namespace: "trading-portfolio" })Solve the mean-variance optimization Σ · x = μ via Conjugate Gradient instead of the legacy Neumann series.
Why CG instead of Neumann (ADR-123 Wedge 8):
npx neural-trader --portfolio optimize)The covariance matrix Σ is symmetric positive-definite by construction (it's a Gram matrix on real returns), so CG is provably optimal — it converges in at most n iterations with no preconditioning, and typically far fewer when eigenvalues cluster.
Disable flag: set RUFLO_NEURAL_TRADER_DISABLE_CG=1 to skip the CG path entirely and fall through to step 4's legacy Neumann route. Useful for A/B validation or when an upstream covariance regression breaks SPD.
Native dispatch flag: set RUFLO_SUBLINEAR_NATIVE=1 to force the adapter to attempt the native mcp__ruflo-sublinear__solve path even when globalThis doesn't expose the tool (e.g. when the harness mounts it via a different transport). On any native-dispatch failure the adapter cleanly falls back to the local JS CG and records method: 'cg-local' in the artifact metadata — so the regression is auditable.
Steps:
Ensure neural-trader is available:
npm ls neural-trader 2>/dev/null || npm install --ignore-scripts neural-trader
Read the current covariance matrix Σ and expected-return vector μ from neural-trader's portfolio API:
# Primary path (preferred — clean JSON):
npx neural-trader --portfolio current --json
# Fallback paths if the --json flag is unavailable on the installed version:
npx neural-trader --portfolio current # parse the text output
# OR pull from AgentDB if a prior run stored the matrix there:
mcp__claude-flow__memory_search({ query: "covariance matrix current", namespace: "trading-risk", limit: 1 })
The skill expects the response to include covariance: number[][] (n × n) and expectedReturns: number[] (length n).
Solve Σ · x = μ via the SublinearAdapter (preferred path) when RUFLO_NEURAL_TRADER_DISABLE_CG is unset:
import { sublinearAdapter } from '../../src/sublinear-adapter.mjs';
const result = await sublinearAdapter.solveCG(COVARIANCE, EXPECTED_RETURNS, {
tolerance: 1e-6,
maxIterations: 200,
});
// result.solution — optimal weights (number[])
// result.iterations — CG iterations executed
// result.residual — final ||A·x − b||₂
// result.latencyMs — wall-clock latency
// result.method — 'cg-sublinear-native' | 'cg-local' <-- READ THIS
// result.solver — 'sublinear-time-solver@1.7.0' | 'local-js-cg'
// result.degraded — true if input failed SPD checks (fall back to step 4)
The adapter does the dispatch itself: it probes for mcp__ruflo-sublinear__solve on globalThis (and honours RUFLO_SUBLINEAR_NATIVE=1 as a manual override), routes through the native kernel when reachable, and falls back transparently to the embedded ~50-LOC JS CG when not. The math is identical either way — CG, dense form, n × n SPD covariance. The operator reads result.method to know which backend produced the artifact.
The native MCP tool's wire shape (for direct callers who want to bypass the adapter):
mcp__ruflo-sublinear__solve({
matrix: COVARIANCE,
rhs: EXPECTED_RETURNS,
algorithm: "cg",
tolerance: 1e-6,
maxIterations: 200
})
Output:
{ solution: number[], iterations: number, residual: number }
Fallback (legacy Neumann) — if step 3 reports degraded: true (non-SPD input, non-square matrix, MCP error) OR if :
Acceptance criteria (ADR-126 Phase 3):
||cg − neumann||_∞ < 1e-4 on a fixed seed.cg-sublinear-native, cg-local, and neumann-fallback.Refs:
plugins/ruflo-neural-trader/src/sublinear-adapter.ts (the adapter)plugins/ruflo-neural-trader/benchmarks/portfolio-cg.bench.ts (the measured numbers)Detect the current market regime using neural-trader's regime detection engine.
Steps:
npm ls neural-trader 2>/dev/null || npm install --ignore-scripts neural-tradernpx neural-trader --regime-detect --symbol TICKER
For multiple symbols:
npx neural-trader --regime-detect --symbols "AAPL,MSFT,GOOGL,AMZN"
npx neural-trader --symbol TICKER --indicators rsi,macd,bollinger,adx,atr
mcp__claude-flow__neural_predict({ input: "indicators: RSI=X, ADX=Y, VIX=Z" })mcp__claude-flow__memory_search({ query: "regime similar to CURRENT", namespace: "trading-analysis" })mcp__claude-flow__memory_store({ key: "regime-DATE", value: "REGIME_ANALYSIS", namespace: "trading-analysis" })Assess portfolio and position risk using neural-trader's risk engine.
Steps:
npm ls neural-trader 2>/dev/null || npm install --ignore-scripts neural-trader# Single position
npx neural-trader --risk assess --symbol TICKER
npx neural-trader --var --symbol TICKER --investment 10000
# Portfolio-wide
npx neural-trader --risk assess --portfolio NAME
npx neural-trader --correlation --portfolio NAME --flag-threshold 0.8
npx neural-trader --risk-tolerance 0.02 --symbol TICKER
npx neural-trader --position-sizing kelly --symbol TICKER
mcp__claude-flow__memory_store({ key: "risk-TICKER-DATE", value: "RISK_METRICS", namespace: "trading-risk" })Generate trading signals using neural-trader's anomaly detection engine.
Steps:
npm ls neural-trader 2>/dev/null || npm install --ignore-scripts neural-tradernpx neural-trader --signal scan --symbols <TICKERS>
With a specific strategy:
npx neural-trader --signal scan --strategy <name> --symbols <TICKERS>
mcp__claude-flow__memory_retrieve({ key: "strategy-NAME", namespace: "trading-strategies" })mcp__claude-flow__neural_predict({ input: "anomaly types: [DETECTED], scores: [SCORES]" })mcp__claude-flow__agentdb_pattern-search({ query: "ANOMALY_TYPE score RANGE", namespace: "trading-signals" })MemoryConsolidator.sweepExpired() pass introduced in ADR-125 Phase 4 — shipped in @claude-flow/memory@3.0.0-alpha.18 — 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 })Train neural prediction models using neural-trader's ML engine.
Steps:
npm ls neural-trader 2>/dev/null || npm install --ignore-scripts neural-tradernpx neural-trader --model lstm --symbol TICKER --confidence 0.95
npx neural-trader --model transformer --symbol TICKER --predict
npx neural-trader --model nbeats --symbol TICKER --decompose
npx neural-trader --model MODEL --symbol TICKER --predict --horizon 5d
npx neural-trader --model-compare --symbol TICKER --models "lstm,transformer,nbeats"
trading-analysis namespace per ADR-126 Phase 1 — was previously stored to undeclared trading-models):
mcp__claude-flow__memory_store({ key: "model-MODEL-TICKER-DATE", value: "TRAINING_RESULTS", namespace: "trading-analysis" })mcp__claude-flow__neural_train({ patternType: "trading-model", epochs: 10 })verification/witness-key.json (the ADR-103 default path, if present).signBacktestArtifact(body, privateKeyHex) from plugins/ruflo-neural-trader/src/signed-artifact.mjs. The returned value is a SignedBacktestArtifact with schema, witnessPublicKey: "ed25519:<hex>", and witnessSignature: "<hex>" populated."[WARN] ruflo-neural-trader: no witness signing key found (RUFLO_WITNESS_KEY_PATH unset, verification/witness-key.json missing) — storing backtest artifact in UNSIGNED degraded mode. paper→live promotion will be refused by trader-cloud-backtest until a signed artifact replaces this one." — and store the body unsigned. NEVER silently fall back.trading-backtests namespace:
mcp__claude-flow__memory_store({ key: "backtest-STRATEGY-TIMESTAMP", value: JSON.stringify(signedArtifact), namespace: "trading-backtests" })
The stored value contains witnessSignature + witnessPublicKey when signed; downstream consumers (trader-cloud-backtest) MUST call verifyBacktestArtifact(artifact, trustedPublicKey) before promoting any artifact to live.mcp__claude-flow__agentdb_pattern-store({ pattern: "profitable-STRATEGY_TYPE", data: "PARAMS_AND_RESULTS" })mcp__claude-flow__neural_train({ patternType: "trading-strategy", epochs: 10 })managed_agent_eventsIngest locally + Ed25519 verify (ADR-126 Phase 4 fail-closed gate):
SignedBacktestArtifact body from the cloud-returned metrics + params hash + runs hash. Sign it locally with signBacktestArtifact(body, privateKeyHex) from plugins/ruflo-neural-trader/src/signed-artifact.mjs (key resolution same as trader-backtest: RUFLO_WITNESS_KEY_PATH → verification/witness-key.json → degraded-unsigned warning).await verifyBacktestArtifact(artifact, trustedPublicKey) where trustedPublicKey is the pinned project-config Ed25519 public key (NOT the artifact.witnessPublicKey field — that's attacker-controllable; see CWE-347 / #1922). If verification returns false: REFUSE to promote — emit a loud error "[ERROR] ruflo-neural-trader: SignedBacktestArtifact signature INVALID against trusted key — refusing to promote to live strategy" and return early. This is the fail-closed gate per ADR-126.memory_store({ key: "backtest-<strategy>-<ts>", value: JSON.stringify(signedArtifact), namespace: "trading-backtests" }). The stored value carries witnessSignature + witnessPublicKey.agentdb_pattern-store({ pattern: "profitable-<strategy-type>", data: "<params + results>" }).cost-tracking namespace (per ADR-117 — cloud sessions bill until terminated).Terminate immediately — results in hand:
managed_agent_terminate({ sessionId, environmentId }) → { sessionDeleted: true, environmentDeleted: true }
Never leave an idle billing container. (ruflo doctor / GC catches orphans — #1931.)
The local fallback (localSingleEntryPageRank in plugins/ruflo-neural-trader/src/signed-attribution.mjs) runs ~30 LOC of seeded power-iteration when the MCP tool is not available — same math, same result up to floating-point tolerance, same ordering for the same seed (the Phase 6 smoke asserts this).
Build the top-K AttributionFeature[] via topKFeatures(graph, scores, k=10, excludeIndex=0) — excludes the source node from the ranked output. Ties broken by node index (lower index wins) so the ranking is deterministic.
Sign the artifact (reuses the Phase 4 signing primitives — same Ed25519 + canonicalization):
SignedAttributionArtifact body:
{
signalId: SIGNAL_ID,
modelId: SIGNAL.modelId,
features: TOP_K_FEATURES, // from step 5
graphMetadata: {
nodeCount: GRAPH.nodes.length,
edgeCount: COUNT_EDGES,
pageRankIterations: PR_RESULT.iterations,
seed: SEED // load-bearing for reproducibility
},
generatedAt: NEW_DATE_ISO
}
RUFLO_WITNESS_KEY_PATH env var — JSON file with { "privateKey": "<hex>" }.verification/witness-key.json (the ADR-103 default path).signAttributionArtifact(body, privateKeyHex) from plugins/ruflo-neural-trader/src/signed-attribution.mjs."[WARN] ruflo-neural-trader: no witness signing key found — storing attribution artifact in UNSIGNED degraded mode. Regulator filings will reject UNSIGNED artifacts." and store the body unsigned. NEVER silently fall back.Store the (possibly signed) artifact to the canonical trading-analysis namespace (ADR-126 Phase 1):
mcp__claude-flow__memory_store({
key: "attribution-SIGNAL_ID-TIMESTAMP",
namespace: "trading-analysis",
value: JSON.stringify(signedArtifact)
})
The trading-analysis namespace is the canonical home for model-analysis output (regime classifications, technical-indicator summaries, model-training results — and now attribution rankings). Long-lived — no TTL — because the audit trail is the deliverable.
Return the markdown summary to the agent. Suggested format:
## Feature attribution for signal `SIGNAL_ID` (model: MODEL_ID)
| Rank | Feature | Score |
|------|---------|-------|
| 1 | NAME | 0.42 |
| 2 | NAME | 0.18 |
| … | … | … |
- PageRank iterations: N
- Graph: nodeCount nodes, edgeCount edges
- Seed: 42 (reproducible — same seed → same ordering)
- Path: mcp | local
- Signature: ed25519:abcd… (or UNSIGNED — degraded warning above)
RUFLO_NEURAL_TRADER_DISABLE_CG=1npx neural-trader --portfolio optimize
Capture the weights output and tag the artifact metadata with method: 'neumann-fallback' and a reason field.
Store the optimal weights to trading-risk namespace with full provenance metadata. Take method and solver straight from the adapter's result so the operator can verify which backend ran:
mcp__claude-flow__memory_store({
key: "portfolio-weights-PORTFOLIO_ID-TIMESTAMP",
namespace: "trading-risk",
value: JSON.stringify({
weights: result.solution, // number[] from step 3 (or weights from step 4 fallback)
method: result.method, // 'cg-sublinear-native' | 'cg-local' | 'neumann-fallback'
solver: result.solver, // 'sublinear-time-solver@1.7.0' | 'local-js-cg' | 'neural-trader-cli'
iterations: result.iterations,
residual: result.residual,
latencyMs: result.latencyMs,
capturedAt: NEW_DATE_ISO,
reason: FALLBACK_REASON || null
})
})
The trading-risk namespace is canonical (ADR-126 Phase 1; the five-namespace alignment). Long-lived — no TTL — because portfolio weights are the audit trail Phase 4 will Ed25519-sign.
Cross-check against historical patterns (optional but recommended):
mcp__claude-flow__agentdb_pattern-search({
query: "portfolio weights Sharpe regime:CURRENT_REGIME",
namespace: "trading-risk"
})
If the new weights differ by more than 30% in any single asset from the historical median, flag for human review before applying. This is a guard-rail, not a hard block.