[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ERVY09CMM7D3ZVTZXARKM9":3,"skill-same:01M7ERVY09CMM7D3ZVTZXARKM9":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7ERVY09CMM7D3ZVTZXARKM9","trader-portfolio-cg",null,"Mean-variance portfolio optimization via Conjugate Gradient — 40-60× faster than the legacy Neumann path (ADR-126 Phase 3, ADR-123 Wedge 8)","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fruflo\u002Fplugins\u002Fruflo-neural-trader\u002Fskills\u002Ftrader-portfolio-cg\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: trader-portfolio-cg\ndescription: Mean-variance portfolio optimization via Conjugate Gradient — 40-60× faster than the legacy Neumann path (ADR-126 Phase 3, ADR-123 Wedge 8)\nallowed-tools: Bash Read mcp__ruflo-sublinear__solve mcp__plugin_ruflo-core_ruflo__memory_store mcp__plugin_ruflo-core_ruflo__memory_retrieve mcp__plugin_ruflo-core_ruflo__memory_search mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search\nargument-hint: \"[--portfolio-id ID] [--tolerance 1e-6]\"\n---\nSolve the mean-variance optimization `Σ · x = μ` via Conjugate Gradient instead of the legacy Neumann series.\n\n**Why CG instead of Neumann (ADR-123 Wedge 8):**\n- Neumann series: ~50 µs at n=256 (legacy `npx neural-trader --portfolio optimize`)\n- Conjugate Gradient: ~816 ns at n=256 (this skill)\n- Measured speedup: 40-60×; parity within 1e-4 on a fixed seed.\n\nThe 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.\n\n**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\u002FB validation or when an upstream covariance regression breaks SPD.\n\n**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.\n\nSteps:\n\n1. **Ensure neural-trader is available**:\n   ```bash\n   npm ls neural-trader 2>\u002Fdev\u002Fnull || npm install --ignore-scripts neural-trader\n   ```\n\n2. **Read the current covariance matrix Σ and expected-return vector μ** from neural-trader's portfolio API:\n   ```bash\n   # Primary path (preferred — clean JSON):\n   npx neural-trader --portfolio current --json\n   # Fallback paths if the --json flag is unavailable on the installed version:\n   npx neural-trader --portfolio current  # parse the text output\n   # OR pull from AgentDB if a prior run stored the matrix there:\n   ```\n   ```text\n   mcp__plugin_ruflo-core_ruflo__memory_search({ query: \"covariance matrix current\", namespace: \"trading-risk\", limit: 1 })\n   ```\n   The skill expects the response to include `covariance: number[][]` (n × n) and `expectedReturns: number[]` (length n).\n\n3. **Solve Σ · x = μ via the SublinearAdapter** (preferred path) when `RUFLO_NEURAL_TRADER_DISABLE_CG` is unset:\n   ```js\n   import { sublinearAdapter } from '..\u002F..\u002Fsrc\u002Fsublinear-adapter.mjs';\n   const result = await sublinearAdapter.solveCG(COVARIANCE, EXPECTED_RETURNS, {\n     tolerance: 1e-6,\n     maxIterations: 200,\n   });\n   \u002F\u002F result.solution    — optimal weights (number[])\n   \u002F\u002F result.iterations  — CG iterations executed\n   \u002F\u002F result.residual    — final ||A·x − b||₂\n   \u002F\u002F result.latencyMs   — wall-clock latency\n   \u002F\u002F result.method      — 'cg-sublinear-native' | 'cg-local'   \u003C-- READ THIS\n   \u002F\u002F result.solver      — 'sublinear-time-solver@1.7.0' | 'local-js-cg'\n   \u002F\u002F result.degraded    — true if input failed SPD checks (fall back to step 4)\n   ```\n   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.\n\n   The native MCP tool's wire shape (for direct callers who want to bypass the adapter):\n   ```text\n   mcp__ruflo-sublinear__solve({\n     matrix: COVARIANCE,\n     rhs: EXPECTED_RETURNS,\n     algorithm: \"cg\",\n     tolerance: 1e-6,\n     maxIterations: 200\n   })\n   ```\n   Output:\n   ```ts\n   { solution: number[], iterations: number, residual: number }\n   ```\n\n4. **Fallback (legacy Neumann)** — if step 3 reports `degraded: true` (non-SPD input, non-square matrix, MCP error) OR if `RUFLO_NEURAL_TRADER_DISABLE_CG=1`:\n   ```bash\n   npx neural-trader --portfolio optimize\n   ```\n   Capture the weights output and tag the artifact metadata with `method: 'neumann-fallback'` and a `reason` field.\n\n5. **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**:\n   ```text\n   mcp__plugin_ruflo-core_ruflo__memory_store({\n     key: \"portfolio-weights-PORTFOLIO_ID-TIMESTAMP\",\n     namespace: \"trading-risk\",\n     value: JSON.stringify({\n       weights: result.solution,           \u002F\u002F number[] from step 3 (or weights from step 4 fallback)\n       method: result.method,              \u002F\u002F 'cg-sublinear-native' | 'cg-local' | 'neumann-fallback'\n       solver: result.solver,              \u002F\u002F 'sublinear-time-solver@1.7.0' | 'local-js-cg' | 'neural-trader-cli'\n       iterations: result.iterations,\n       residual: result.residual,\n       latencyMs: result.latencyMs,\n       capturedAt: NEW_DATE_ISO,\n       reason: FALLBACK_REASON || null\n     })\n   })\n   ```\n   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.\n\n6. **Cross-check against historical patterns** (optional but recommended):\n   ```text\n   mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search({\n     query: \"portfolio weights Sharpe regime:CURRENT_REGIME\",\n     namespace: \"trading-risk\"\n   })\n   ```\n   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.\n\n**Acceptance criteria (ADR-126 Phase 3):**\n- Latency \u003C 1 ms on n = 256 covariance (local JS CG); native path target 40-60× faster (816 ns native vs 50 µs Neumann per sublinear-time-solver@1.7.0).\n- Parity with legacy Neumann within `||cg − neumann||_∞ \u003C 1e-4` on a fixed seed.\n- Fallback path engages cleanly when native MCP unavailable \u002F covariance non-SPD.\n- Artifact metadata distinguishes `cg-sublinear-native`, `cg-local`, and `neumann-fallback`.\n\n**Refs**:\n- ADR-126 Phase 3 (this skill's authoring ADR)\n- ADR-123 §162 Row 8 (Wedge 8 speedup claim)\n- ADR-123 §262-289 (the SublinearAdapter contract)\n- `plugins\u002Fruflo-neural-trader\u002Fsrc\u002Fsublinear-adapter.ts` (the adapter)\n- `plugins\u002Fruflo-neural-trader\u002Fbenchmarks\u002Fportfolio-cg.bench.ts` (the measured numbers)\n","Solve the mean-variance optimization `Σ · x = μ` via Conjugate Gradient instead of the legacy Neumann series.\n\n**Why CG instead of Neumann (ADR-123 Wedge 8):**\n- Neumann series: ~50 µs at n=256 (legacy `npx neural-trader --portfolio optimize`)\n- Conjugate Gradient: ~816 ns at n=256 (this skill)\n- Measured speedup: 40-60×; parity within 1e-4 on a fixed seed.\n\nThe 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.\n\n**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\u002FB validation or when an upstream covariance regression breaks SPD.\n\n**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.\n\nSteps:\n\n1. **Ensure neural-trader is available**:\n   ```bash\n   npm ls neural-trader 2>\u002Fdev\u002Fnull || npm install --ignore-scripts neural-trader\n   ```\n\n2. **Read the current covariance matrix Σ and expected-return vector μ** from neural-trader's portfolio API:\n   ```bash\n   # Primary path (preferred — clean JSON):\n   npx neural-trader --portfolio current --json\n   # Fallback paths if the --json flag is unavailable on the installed version:\n   npx neural-trader --portfolio current  # parse the text output\n   # OR pull from AgentDB if a prior run stored the matrix there:\n   ```\n   ```text\n   mcp__plugin_ruflo-core_ruflo__memory_search({ query: \"covariance matrix current\", namespace: \"trading-risk\", limit: 1 })\n   ```\n   The skill expects the response to include `covariance: number[][]` (n × n) and `expectedReturns: number[]` (length n).\n\n3. **Solve Σ · x = μ via the SublinearAdapter** (preferred path) when `RUFLO_NEURAL_TRADER_DISABLE_CG` is unset:\n   ```js\n   import { sublinearAdapter } from '..\u002F..\u002Fsrc\u002Fsublinear-adapter.mjs';\n   const result = await sublinearAdapter.solveCG(COVARIANCE, EXPECTED_RETURNS, {\n     tolerance: 1e-6,\n     maxIterations: 200,\n   });\n   \u002F\u002F result.solution    — optimal weights (number[])\n   \u002F\u002F result.iterations  — CG iterations executed\n   \u002F\u002F result.residual    — final ||A·x − b||₂\n   \u002F\u002F result.latencyMs   — wall-clock latency\n   \u002F\u002F result.method      — 'cg-sublinear-native' | 'cg-local'   \u003C-- READ THIS\n   \u002F\u002F result.solver      — 'sublinear-time-solver@1.7.0' | 'local-js-cg'\n   \u002F\u002F result.degraded    — true if input failed SPD checks (fall back to step 4)\n   ```\n   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.\n\n   The native MCP tool's wire shape (for direct callers who want to bypass the adapter):\n   ```text\n   mcp__ruflo-sublinear__solve({\n     matrix: COVARIANCE,\n     rhs: EXPECTED_RETURNS,\n     algorithm: \"cg\",\n     tolerance: 1e-6,\n     maxIterations: 200\n   })\n   ```\n   Output:\n   ```ts\n   { solution: number[], iterations: number, residual: number }\n   ```\n\n4. **Fallback (legacy Neumann)** — if step 3 reports `degraded: true` (non-SPD input, non-square matrix, MCP error) OR if `RUFLO_NEURAL_TRADER_DISABLE_CG=1`:\n   ```bash\n   npx neural-trader --portfolio optimize\n   ```\n   Capture the weights output and tag the artifact metadata with `method: 'neumann-fallback'` and a `reason` field.\n\n5. **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**:\n   ```text\n   mcp__plugin_ruflo-core_ruflo__memory_store({\n     key: \"portfolio-weights-PORTFOLIO_ID-TIMESTAMP\",\n     namespace: \"trading-risk\",\n     value: JSON.stringify({\n       weights: result.solution,           \u002F\u002F number[] from step 3 (or weights from step 4 fallback)\n       method: result.method,              \u002F\u002F 'cg-sublinear-native' | 'cg-local' | 'neumann-fallback'\n       solver: result.solver,              \u002F\u002F 'sublinear-time-solver@1.7.0' | 'local-js-cg' | 'neural-trader-cli'\n       iterations: result.iterations,\n       residual: result.residual,\n       latencyMs: result.latencyMs,\n       capturedAt: NEW_DATE_ISO,\n       reason: FALLBACK_REASON || null\n     })\n   })\n   ```\n   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.\n\n6. **Cross-check against historical patterns** (optional but recommended):\n   ```text\n   mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search({\n     query: \"portfolio weights Sharpe regime:CURRENT_REGIME\",\n     namespace: \"trading-risk\"\n   })\n   ```\n   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.\n\n**Acceptance criteria (ADR-126 Phase 3):**\n- Latency \u003C 1 ms on n = 256 covariance (local JS CG); native path target 40-60× faster (816 ns native vs 50 µs Neumann per sublinear-time-solver@1.7.0).\n- Parity with legacy Neumann within `||cg − neumann||_∞ \u003C 1e-4` on a fixed seed.\n- Fallback path engages cleanly when native MCP unavailable \u002F covariance non-SPD.\n- Artifact metadata distinguishes `cg-sublinear-native`, `cg-local`, and `neumann-fallback`.\n\n**Refs**:\n- ADR-126 Phase 3 (this skill's authoring ADR)\n- ADR-123 §162 Row 8 (Wedge 8 speedup claim)\n- ADR-123 §262-289 (the SublinearAdapter contract)\n- `plugins\u002Fruflo-neural-trader\u002Fsrc\u002Fsublinear-adapter.ts` (the adapter)\n- `plugins\u002Fruflo-neural-trader\u002Fbenchmarks\u002Fportfolio-cg.bench.ts` (the measured numbers)\n",{"name":5,"description":7,"allowed-tools":24,"argument-hint":25},"Bash Read mcp__ruflo-sublinear__solve mcp__plugin_ruflo-core_ruflo__memory_store mcp__plugin_ruflo-core_ruflo__memory_retrieve mcp__plugin_ruflo-core_ruflo__memory_search mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search","[--portfolio-id ID] [--tolerance 1e-6]","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Fruflo\u002Fplugins\u002Fruflo-neural-trader\u002Fskills\u002Ftrader-portfolio-cg",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill trader-portfolio-cg",{"tool":40,"command":41},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill trader-portfolio-cg",{"tool":43,"command":44},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill trader-portfolio-cg","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fruflo\u002Fplugins\u002Fruflo-neural-trader\u002Fskills\u002Ftrader-portfolio-cg\u002FSKILL.md",true,[],[49,57,62,69,76,83],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":56},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":58,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":56},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":56},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":56},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":56},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":56},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]