본문으로 건너뛰기
cccskills
무료GitHub에 공개

trader-explain

Explain a trading model's prediction by ranking the input features that contributed to its signal. Returns a Markdown table and saves an attribution record with calculation settings, adding a digital signature when a signing key is available.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

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)

설치 방법 보기

이럴 때 유용합니다

  • Reviewing which inputs drove a trading signal
  • Saving signed records of model explanations
  • Reproducing rankings with the same signal and seed
  • Checking whether an explanation used a fallback method

포함된 파일(1)

  • SKILL.md7.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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):

    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:

    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.

  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:

    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:
      {
        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):

    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:

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)

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Compare models available through the HuggingFace router with chat-ui configuration, research missing models, and write short English descriptions of their architecture and capabilities. Add entries to both production and development configuration files and commit the changes.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Adding newly available router models to chat-ui
  • Writing concise descriptions of model capabilities
  • Updating production and development model entries together
ruvnet/ruflo7.7만2026년 10월 19일 업데이트

Create an Architecture Decision Record, a document for recording important design choices, with the next sequential number. It generates a Markdown template, registers the record in AgentDB, and links related decisions found through search.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Record the reasoning behind adopting a technology
  • Start an ADR for an API or data model change
  • Document an infrastructure decision
ruvnet/ruflo7.7만2026년 10월 19일 업데이트

adr-index

무료

Build a searchable index and relationship graph from ADRs, records of architectural decisions. Import two supported document formats, refresh existing metadata without duplicate relationships, and review summaries of statuses, missing references, and inconsistencies.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Index ADRs imported from another project
  • Refresh a graph that differs from files on disk
  • Set up ADR tracking in an existing codebase
ruvnet/ruflo7.7만2026년 10월 19일 업데이트

Rebuild the index of ADRs, records of architectural decisions, after files or relationship lines are deleted. It clears stored records and relationships, indexes the files still present, and checks that the final record count matches.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Rebuild the index after deleting an ADR file
  • Remove stale relationships after editing an ADR
  • Reconcile the ADR index on a schedule
ruvnet/ruflo7.7만2026년 10월 19일 업데이트

Review code changes against accepted Architecture Decision Records, documents that capture agreed design choices. Report violations, outdated references, compliant changes, and areas without ADR coverage, then suggest code fixes or a new decision record where appropriate.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Check a pull request before merging
  • Review major code changes against agreed design decisions
  • Find references to superseded ADRs
ruvnet/ruflo7.7만2026년 10월 19일 업데이트

Check saved architecture decision records (ADRs) for broken references, circular replacement relationships, and inconsistent statuses. Use the results to verify imported records or stop a CI check when selected integrity rules fail.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Checking ADR integrity after import
  • Blocking CI when ADR issues are found
  • Reviewing ADR data before a release
ruvnet/ruflo7.7만2026년 10월 19일 업데이트

ruvnet의 스킬 모두 보기

이 스킬의 문제 신고