К основному содержанию
скилл CX Codex

trader-explain — скилл для Claude Code: что делает и как установить

Ранжирует признаки в сигналах LSTM и Transformer через PageRank и создаёт подписанный отчёт для аудита торговых моделей.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add ruvnet/ruflo --skill trader-explain -a claude-code
Открыть на GitHub

Что делает trader-explain

Скилл объясняет торговые сигналы нейросетей через алгоритм single-entry PageRank. Для этого он строит граф влияния входных признаков на итоговое решение. Данные берутся из пространства trading-signals. Оценки извлекаются через команду npx neural-trader --predict --signal <signalId> --explain --json. При отсутствии флага объяснения расчёт переходит на z-score признаков.

Вычисления запускаются через инструмент mcp__ruflo-sublinear__page-rank-entry. При его отсутствии работает локальный скрипт signed-attribution.mjs с генератором mulberry32. Итоговый отчёт SignedAttributionArtifact заверяется подписью Ed25519 и сохраняется в раздел trading-analysis.

Без приватного ключа свидетеля артефакт остаётся неподписанным. Регуляторные проверки не примут такой файл.

Какие задачи решает

  • ранжировать входные признаки сигналов моделей LSTM и Transformer
  • сформировать криптографически подписанный артефакт с подписью Ed25519
  • сохранить проверяемую историю атрибуции в долгосрочное хранилище trading-analysis
  • построить граф влияния с учётом матрицы внимания Transformer-моделей

Примеры запросов агенту

  • Объясни торговый сигнал sig-9482 через trader-explain
  • trader-explain sig-401 --top-k 5 --seed 42
  • Покажи ключевые факторы для сигнала sig-1082 с помощью trader-explain

Как установить trader-explain

1Через Skills CLI (Vercel)

npx skills add ruvnet/ruflo --skill trader-explain -a claude-code

2Вручную: положить файлы

~/.claude/skills/trader-explain/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/trader-explain/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Из того же набора146

witness Подписывает манифест исправлений с Ed25519 и следит за регрессиями через текстовые маркеры в коде. Помогает вовремя заметить, если баг вернулся после случайного отката. CX Codex +1 655установок trader-cloud-backtest Уводит тяжёлый прогон neural-trader — walk-forward, Monte-Carlo, перебор параметров или обучение модели — в контейнер Managed Agent вместо локальной машины. CX Codex +1 599установок managed-agent Скилл для запуска Claude Managed Agents в облаке Anthropic. Подходит для долгих асинхронных задач в изолированном контейнере с постоянной файловой системой. CX Codex +1 596установок trader-portfolio-cg Решает задачу mean-variance через сопряжённые градиенты вместо ряда Неймана. Нужен, когда пересчитываете веса портфеля часто и упираетесь в задержку. CX Codex +1 513установок gaia-submission Скилл ведёт запуск бенчмарка GAIA от проверки ключей до сборки пакета для лидерборда HAL. Пригодится при замере качества агента и подготовке результатов к отправке. CX Codex +1 435установок gaia-debugging Скилл разбирает сбой задания GAIA: читает трассировку, определяет тип ошибки и предлагает точечное исправление перед повторным запуском. CX Codex +1 435установок gaia-architecture-comparison Сравнивает тестовый стенд ruflo для бенчмарка GAIA с референсной реализацией HAL от Принстона. Помогает найти архитектурные пробелы и спланировать доработки для роста точности. CX Codex +1 432установок nested-subagents Строит дерево субагентов, где каждый ребёнок может породить своих детей. Нужен, когда промежуточное состояние не влезает в контекст одного агента. CX Codex +1 316установок

Похожие

skill-creator официальный anthropics Помогает создать новый скилл, доработать существующий и проверить результат через тестовые промпты и оценки. 414 180установок writing-for-agents Matt Pocock Помогает писать скиллы и документы с инструкциями для агентов. Пригодится при правках AGENTS.md, CLAUDE.md и связанных справочных файлов. 466 719установок media-use heygen-com Находит и генерирует ассеты для видео в HyperFrames — музыку, дикторский голос, аватары и эффекты. Сохраняет всё локально в assets. CX Codex +1 1 100 000установок mcp-builder официальный anthropics Скилл проводит через создание MCP-сервера на TypeScript или Python: от изучения протокола до тестов и оценки качества. 130 949установок subagent-driven-development Jesse Vincent Скилл выполняет план через отдельных субагентов для каждой задачи и проверяет результат после каждого шага. Подходит для независимых задач в одной сессии. CX Codex 237 746установок orchestration stablyai Координирует воркеров Orca через DAG задач, циклы супервизора и цепочки сообщений. Пригодится для распределения сложной работы между агентами. CX Codex +1 349 800установок

Рядом в теме «ИИ и ML»

Всё по теме «ИИ и ML» →

Вопросы о trader-explain

Как установить trader-explain в Claude Code?

Выполните команду npx skills add ruvnet/ruflo --skill trader-explain -a claude-code. Конфигурация запишется в файл ~/.claude/skills/trader-explain/SKILL.md.

Что делает скилл trader-explain?

Он строит граф вклада признаков в торговый сигнал и находит главные факторы алгоритмом PageRank. Итоговая таблица сохраняется в память как артефакт для регуляторной отчётности.

Что произойдёт при отсутствии ключа Ed25519?

Если переменная RUFLO_WITNESS_KEY_PATH не задана и файл verification/witness-key.json не найден, скилл сохранит отчёт в неподписанном виде с предупреждением в консоли.

Исходный текст

SKILL.md · MIT
---
name: trader-explain
description: Regulator-grade feature attribution for any LSTM/Transformer signal — single-entry PageRank ranks the top-K features that drove the prediction (ADR-126 Phase 6, ADR-123 single-entry PR)
allowed-tools: Bash Read mcp__plugin_ruflo-core_ruflo__memory_retrieve mcp__plugin_ruflo-core_ruflo__memory_store mcp__ruflo-sublinear__page-rank-entry
argument-hint: "<signalId> [--top-k 10] [--seed 42]"
---
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:**
- EU AI Act + SEC Reg-AI guidance require interpretable model output for any algorithmic trading system that touches retail capital. This is the regulator-grade attribution path the rest of the substrate has been waiting for.
- The same call site picks up the full native-WASM PageRank from `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:

1. **Retrieve the signal** from the canonical `trading-signals` namespace (ADR-126 Phase 1 + Phase 2 lifecycle):
   ```text
   mcp__plugin_ruflo-core_ruflo__memory_retrieve({
     key: "SIGNAL_ID",
     namespace: "trading-signals"
   })
   ```
   The signal entry includes `modelId`, `prediction`, and the feature vector at the time of inference.

2. **Extract per-feature contribution scores** from the model:
   ```bash
   npx neural-trader --predict --signal "$SIGNAL_ID" --explain --json
   ```
   The expected output shape:
   ```ts
   {
     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.

3. **Build the feature-contribution graph**:
   - **Nodes**: one node per feature + one source node `__signal_output__` for the prediction.
   - **Edges**: outgoing edges from `__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.
   - **Source**: `__signal_output__` (index 0 by convention so the smoke can assert reproducibility).

4. **Run single-entry PageRank** — preferred path when `mcp__ruflo-sublinear__page-rank-entry` is registered:
   ```text
   mcp__ruflo-sublinear__page-rank-entry({
     nodes: GRAPH_NODES,
     edges: GRAPH_EDGES,
     sourceIndex: 0,
     damping: 0.85,
     maxIterations: 100,
     tolerance: 1e-8,
     seed: 42
   })
   ```
   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).

5. **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.

6. **Sign the artifact** (reuses the Phase 4 signing primitives — same Ed25519 + canonicalization):
   - Build the `SignedAttributionArtifact` body:
     ```ts
     {
       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
     }
     ```
   - Resolve the witness signing key — same lookup order as Phase 4:
     1. `RUFLO_WITNESS_KEY_PATH` env var — JSON file with `{ "privateKey": "<hex>" }`.
     2. `verification/witness-key.json` (the ADR-103 default path).
   - If a key resolves: `signAttributionArtifact(body, privateKeyHex)` from `plugins/ruflo-neural-trader/src/signed-attribution.mjs`.
   - If NEITHER path resolves: log `"[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.

7. **Store the (possibly signed) artifact** to the canonical `trading-analysis` namespace (ADR-126 Phase 1):
   ```text
   mcp__plugin_ruflo-core_ruflo__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.

8. **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)
   ```

### Verification

Downstream consumers verify the artifact before any regulator-facing report or paper→live promotion:

```ts
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).
- Reproducibility: two runs with the same `signalId` + same `--seed` produce byte-identical rank ordering (asserted by `scripts/smoke-neural-trader-feature-attribution.mjs`).
- Signed artifact verifies under the trusted pubkey; tampering any feature score or `graphMetadata.seed` invalidates the signature.
- Fallback paths engage cleanly: when MCP unavailable, local kernel runs; when `--explain` flag missing, z-score heuristic runs and the artifact is tagged.

**Refs:**
- ADR-126 Phase 6 (this skill's authoring ADR)
- ADR-126 Phase 4 (the signing scheme this reuses)
- ADR-123 (single-entry PageRank substrate; the same family that Phase 3 leverages for portfolio CG)
- `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)

© ruvnet · MIT · ruvnet/ruflo

Смотрите также

Спонсоры проекта

Компании, которые помогают держать аналитику открытой