chain-insights 0.8.22 → 0.18.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +344 -190
  2. package/dist/action-log-Dfe88TwV.cjs +109 -0
  3. package/dist/action-log-diTHyMbV.mjs +93 -0
  4. package/dist/action-log-diTHyMbV.mjs.map +1 -0
  5. package/dist/{app-CCXmYEV1.mjs → app-CJwx_2Rr.mjs} +2 -2
  6. package/dist/{app-CCXmYEV1.mjs.map → app-CJwx_2Rr.mjs.map} +1 -1
  7. package/dist/{app-BNrqZ_LR.cjs → app-D4Cm69ob.cjs} +1 -1
  8. package/dist/{artifact-server-DR13HEei.mjs → artifact-server-D1D-_t5l.mjs} +2 -2
  9. package/dist/{artifact-server-DR13HEei.mjs.map → artifact-server-D1D-_t5l.mjs.map} +1 -1
  10. package/dist/{artifact-server-B4YVpWK2.cjs → artifact-server-sJBFGcum.cjs} +1 -1
  11. package/dist/{call-args-DyU9d6tT.cjs → call-args-DAiQSDmD.cjs} +4 -2
  12. package/dist/{call-args-D3UajHDq.mjs → call-args-ysbB_xdA.mjs} +5 -3
  13. package/dist/call-args-ysbB_xdA.mjs.map +1 -0
  14. package/dist/{capabilities-CjIcF3da.cjs → capabilities-BR985-bW.cjs} +26 -37
  15. package/dist/{capabilities-GuF58uDa.mjs → capabilities-rLNPG-O2.mjs} +16 -37
  16. package/dist/capabilities-rLNPG-O2.mjs.map +1 -0
  17. package/dist/cases-C1XewLdx.mjs +155 -0
  18. package/dist/cases-C1XewLdx.mjs.map +1 -0
  19. package/dist/cases-CVtc7Rf8.cjs +160 -0
  20. package/dist/cli.cjs +217 -167
  21. package/dist/cli.d.cts +1 -1
  22. package/dist/cli.d.mts +1 -1
  23. package/dist/cli.mjs +217 -167
  24. package/dist/cli.mjs.map +1 -1
  25. package/dist/{client-C_HEuq0f.mjs → client-BD9FLUt2.mjs} +131 -12
  26. package/dist/client-BD9FLUt2.mjs.map +1 -0
  27. package/dist/{client-rVqMG2j9.cjs → client-DLqndaSv.cjs} +130 -11
  28. package/dist/config-CwIb-tav.mjs +33 -0
  29. package/dist/config-CwIb-tav.mjs.map +1 -0
  30. package/dist/config-Cy-qzx4W.cjs +33 -0
  31. package/dist/{config-BFi5yBMm.mjs → config-DA6KRx60.mjs} +2 -2
  32. package/dist/{config-BFi5yBMm.mjs.map → config-DA6KRx60.mjs.map} +1 -1
  33. package/dist/{config-B8Hk-G1y.cjs → config-DE0dUT3P.cjs} +1 -1
  34. package/dist/{html-generator-DjWagEB5.mjs → html-generator-ClysZjfY.mjs} +3 -2
  35. package/dist/html-generator-ClysZjfY.mjs.map +1 -0
  36. package/dist/{html-generator-DF0F6nUI.cjs → html-generator-Ui29DLSD.cjs} +2 -1
  37. package/dist/index.cjs +9 -7
  38. package/dist/index.d.cts +66 -13
  39. package/dist/index.d.cts.map +1 -1
  40. package/dist/index.d.mts +66 -13
  41. package/dist/index.d.mts.map +1 -1
  42. package/dist/index.mjs +9 -8
  43. package/dist/init-9jY5rCcH.cjs +24 -0
  44. package/dist/init-BiRfMQcA.mjs +26 -0
  45. package/dist/init-BiRfMQcA.mjs.map +1 -0
  46. package/dist/{init-s0SU97fS.cjs → init-HVwOeOyo.cjs} +65 -80
  47. package/dist/{init-BWFFHDtL.mjs → init-Jp_AIMZ7.mjs} +66 -81
  48. package/dist/init-Jp_AIMZ7.mjs.map +1 -0
  49. package/dist/limits-D3Mn-gig.mjs +94 -0
  50. package/dist/limits-D3Mn-gig.mjs.map +1 -0
  51. package/dist/limits-km3pmmL3.cjs +115 -0
  52. package/dist/lock-Cs-a3Ng1.cjs +38 -0
  53. package/dist/lock-D_sWGS7W.mjs +40 -0
  54. package/dist/lock-D_sWGS7W.mjs.map +1 -0
  55. package/dist/mcp-proxy.cjs +79 -371
  56. package/dist/mcp-proxy.d.cts +4 -1
  57. package/dist/mcp-proxy.d.cts.map +1 -1
  58. package/dist/mcp-proxy.d.mts +4 -1
  59. package/dist/mcp-proxy.d.mts.map +1 -1
  60. package/dist/mcp-proxy.mjs +79 -372
  61. package/dist/mcp-proxy.mjs.map +1 -1
  62. package/dist/merge-B_5kxbGv.cjs +202 -0
  63. package/dist/merge-CJRZpuZ4.mjs +199 -0
  64. package/dist/merge-CJRZpuZ4.mjs.map +1 -0
  65. package/dist/paths-CffVTUCv.cjs +31 -0
  66. package/dist/paths-_3isihzD.mjs +21 -0
  67. package/dist/paths-_3isihzD.mjs.map +1 -0
  68. package/dist/public-tools-B9_wXs2o.mjs +1154 -0
  69. package/dist/public-tools-B9_wXs2o.mjs.map +1 -0
  70. package/dist/public-tools-CgiKgYgf.cjs +1154 -0
  71. package/dist/render-TmSq0f4f.cjs +207 -0
  72. package/dist/render-mxE0Tdsf.mjs +206 -0
  73. package/dist/render-mxE0Tdsf.mjs.map +1 -0
  74. package/dist/report-BFXFrJmj.mjs +36 -0
  75. package/dist/report-BFXFrJmj.mjs.map +1 -0
  76. package/dist/report-BwKQqOCR.cjs +36 -0
  77. package/dist/runner-CSss8Hvy.mjs +33 -0
  78. package/dist/runner-CSss8Hvy.mjs.map +1 -0
  79. package/dist/runner-aErdz2zn.cjs +31 -0
  80. package/dist/{schema-zWbVYCQW.mjs → schema-0BVyF-aL.mjs} +38 -2
  81. package/dist/schema-0BVyF-aL.mjs.map +1 -0
  82. package/dist/{schema-Dj2mqv1g.cjs → schema-DF0aOXII.cjs} +37 -1
  83. package/dist/{server-CGGSh1TZ.mjs → server-BXj6BRI1.mjs} +2 -2
  84. package/dist/{server-CGGSh1TZ.mjs.map → server-BXj6BRI1.mjs.map} +1 -1
  85. package/dist/{server-BkljWFmU.cjs → server-ta1oyJ2a.cjs} +1 -1
  86. package/dist/templates/graph.html +46 -3
  87. package/dist/{tool-visibility-9-rvB91K.mjs → tool-visibility-C0ALejXI.mjs} +12 -36
  88. package/dist/tool-visibility-C0ALejXI.mjs.map +1 -0
  89. package/dist/{tool-visibility-Cl2p7Ghx.cjs → tool-visibility-DMIEexib.cjs} +11 -35
  90. package/dist/{tools-e87fylVa.cjs → tools-BPfUpCUR.cjs} +12 -0
  91. package/dist/{tools-B4rwKdvU.mjs → tools-CWwX4yth.mjs} +2 -2
  92. package/dist/{tools-B4rwKdvU.mjs.map → tools-CWwX4yth.mjs.map} +1 -1
  93. package/dist/{topup-server-R3dNp-p8.mjs → topup-server-D2X7My7i.mjs} +3 -2
  94. package/dist/{topup-server-R3dNp-p8.mjs.map → topup-server-D2X7My7i.mjs.map} +1 -1
  95. package/dist/{topup-server-B8anfXcq.cjs → topup-server-VGl8-Fz5.cjs} +2 -1
  96. package/dist/{viz-Cvb81rMm.mjs → viz-Cq1jSWSH.mjs} +11 -7
  97. package/dist/viz-Cq1jSWSH.mjs.map +1 -0
  98. package/dist/{viz-C9m5OuQT.cjs → viz-HSwLcKr6.cjs} +10 -6
  99. package/docs/architecture.md +7 -8
  100. package/docs/contributing.md +1 -4
  101. package/docs/debugging.md +47 -2
  102. package/docs/development.md +38 -0
  103. package/docs/graph-query-compatibility.md +222 -0
  104. package/docs/graph-tools.md +34 -154
  105. package/docs/images/quickstart-demo.svg +1 -0
  106. package/docs/investigation-workspaces.md +35 -0
  107. package/docs/mcp-proxy.md +23 -40
  108. package/docs/monitoring.md +279 -0
  109. package/docs/search-limits.md +73 -0
  110. package/docs/stability.md +71 -0
  111. package/package.json +36 -15
  112. package/skills/chain-insights-address-risk/SKILL.md +12 -11
  113. package/skills/chain-insights-bittensor-cypher/SKILL.md +152 -61
  114. package/skills/chain-insights-cypher/SKILL.md +122 -44
  115. package/skills/chain-insights-cypher/references/gql-translation-matrix.md +22 -0
  116. package/skills/chain-insights-cypher/references/memgraph-examples.md +46 -57
  117. package/skills/chain-insights-developer-experience/SKILL.md +44 -11
  118. package/skills/chain-insights-investigation/SKILL.md +39 -26
  119. package/skills/chain-insights-investigation/scripts/run-target-uat.sh +11 -11
  120. package/skills/chain-insights-monitoring/SKILL.md +160 -0
  121. package/skills/chain-insights-monitoring/references/pm2-scheduling.md +100 -0
  122. package/skills/test-chain-insights-graph/SKILL.md +40 -11
  123. package/skills/test-chain-insights-graph/scripts/run-uat.sh +102 -155
  124. package/dist/call-args-D3UajHDq.mjs.map +0 -1
  125. package/dist/capabilities-GuF58uDa.mjs.map +0 -1
  126. package/dist/client-C_HEuq0f.mjs.map +0 -1
  127. package/dist/html-generator-DjWagEB5.mjs.map +0 -1
  128. package/dist/init-BWFFHDtL.mjs.map +0 -1
  129. package/dist/public-tools-CXD65Dfk.cjs +0 -2672
  130. package/dist/public-tools-DScJ1mRk.mjs +0 -2669
  131. package/dist/public-tools-DScJ1mRk.mjs.map +0 -1
  132. package/dist/schema-zWbVYCQW.mjs.map +0 -1
  133. package/dist/tool-visibility-9-rvB91K.mjs.map +0 -1
  134. package/dist/viz-Cvb81rMm.mjs.map +0 -1
  135. package/skills/chain-insights-trace-funds/SKILL.md +0 -135
package/README.md CHANGED
@@ -1,49 +1,238 @@
1
1
  # Chain Insights
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/chain-insights)](https://www.npmjs.com/package/chain-insights)
4
+ [![CI](https://img.shields.io/github/actions/workflow/status/chainswarm/chain-insights/verify.yml?branch=main)](https://github.com/chainswarm/chain-insights/actions/workflows/verify.yml)
5
+ [![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/chainswarm/chain-insights)](https://securityscorecards.dev/viewer/?uri=github.com/chainswarm/chain-insights)
6
+ [![License](https://img.shields.io/npm/l/chain-insights)](https://github.com/chainswarm/chain-insights/blob/main/LICENSE)
7
+
3
8
  [Website](https://chain-insights.ai) | [npm](https://www.npmjs.com/package/chain-insights)
4
9
 
5
10
  Chain Insights is an open-source AML investigation toolkit for AI agents and
6
- analysts. Install it from npm to screen blockchain addresses, trace role-specific
7
- fund flows, manage workspace evidence, and generate graph reports.
11
+ analysts. It screens blockchain addresses, explores fund flows through graph
12
+ queries, manages local evidence workspaces, and generates graph reports.
13
+
14
+ ## Quickstart
15
+
16
+ All shell snippets in this documentation are for **Linux** (bash). They work
17
+ as-is on macOS; on Windows use WSL.
18
+
19
+ ```bash
20
+ npx chain-insights@latest --help # run without installing
21
+ npm install -g chain-insights # or install the cia CLI globally
22
+ cia init ~/cases # scaffold an investigation workspace
23
+ cia networks # supported networks + public tool surface
24
+ ```
25
+
26
+ ![Terminal demo: help, workspace init, and the network tool surface in under a minute](docs/images/quickstart-demo.svg)
27
+
28
+ Sixty seconds gets you the CLI, a workspace, and the live tool catalog.
29
+ To call the same tools from an agent, register the MCP proxy:
30
+ `cia setup claude-code` (or `codex` / `hermes`).
31
+
32
+ ## Purpose And Ownership
8
33
 
9
- Graph access is configuration-driven. The package defaults to a local Chain
10
- Insights Graph endpoint for development; hosted endpoints are set explicitly with
11
- `graphMcpEndpoint` or `CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT`.
34
+ One public npm package (`chain-insights`) providing the `cia` CLI and a
35
+ stdio MCP proxy over a Chain Insights Graph endpoint.
12
36
 
13
- ## What You Can Do Today
37
+ Owning group: chainswarm org, infra group.
38
+
39
+ ## What It Does
40
+
41
+ Owns:
42
+
43
+ - The `cia` / `chain-insights` CLI and the `chain-insights-mcp-proxy` MCP
44
+ server (source under `src/`).
45
+ - The canonical public tool surface: prefixed `aml_*` / `graph_*` / `meta_*`
46
+ / `wallet_*` tools.
47
+ - Local wallet and payment on Base mainnet (payment chain only).
48
+ - Investigation workspaces, graph reports, and visualization.
49
+ - `cia monitor`: per-case tracking with rendered dossiers on an external
50
+ schedule.
51
+ - Shipped product skills under `skills/` (`chain-insights-*`), packaged
52
+ into the npm tarball.
53
+ - The local Bittensor graph devkit under `devkit/`.
54
+
55
+ Never touches:
56
+
57
+ - Blockchain indexing, graph database storage, or graph serving — those
58
+ belong to the Chain Insights Graph backend.
59
+ - Automatic risk labeling. Address labels are served by the Chain Insights
60
+ Graph backend and read through `aml_address_risk`; the CLI never writes
61
+ labels.
62
+ - Custodial wallets or hosted case databases. Investigation data stays in
63
+ the local workspace unless the operator exports it.
64
+
65
+ ### What You Can Do Today
14
66
 
15
67
  | Tool | Use it for |
16
68
  | --- | --- |
17
69
  | `aml_address_risk` | Screen one address for risk, behavior, neighborhood context, and exchange exposure |
18
- | `aml_trace_victim_funds` | Trace victim/source funds forward to exchange deposit candidates |
19
- | `aml_trace_deposit_sources` | Trace backward from suspected deposit/cashout addresses to upstream sources and convergence |
20
- | `aml_trace_suspect_funds` | Trace suspected scammer, mule, operator, or laundering-ring funds forward to cashout topology |
21
70
  | `graph_query` | Run one read-only GQL/Cypher query against a Chain Insights Graph layer |
22
71
  | `graph_query_batch` | Run related read-only graph queries as one MCP call |
23
72
  | `meta_network_capabilities` | Check supported Chain Insights networks and graph tools |
24
73
  | `meta_usage_status` | Check the caller's daily free-tier graph query allowance |
74
+ | `meta_help` | Show Chain Insights tool and workflow guidance |
25
75
  | `wallet_balance` | Show the local payment wallet amount |
26
76
 
27
- ## Quick Start
77
+ ### Continuous Monitoring
28
78
 
29
- Install from npm:
79
+ `cia monitor` re-renders each open case's dossier on a schedule. It turns one
80
+ investigation into a standing view: seeds, scope changes, and render state
81
+ stay as plain files in the workspace.
30
82
 
31
- ```bash
32
- npm install -g chain-insights
83
+ | Command | What it does |
84
+ | --- | --- |
85
+ | `cia monitor run` | One pass: render the dossier of every open case |
86
+ | `cia monitor status` | Open cases and the last run |
87
+ | `cia monitor render` | Re-render all open cases (or one case) from the case document |
88
+ | `cia monitor init victim` | Bootstrap a stolen-funds case-tracking config in one command |
89
+ | `cia monitor case add` | Register a monitor case with one or more seed addresses |
90
+ | `cia monitor case list` | List monitor cases (open by default, `--all` for closed) |
91
+ | `cia monitor case add-seed` | Widen an open case's seed set, timestamped |
92
+ | `cia monitor case remove-seed` | Narrow an open case's seed set |
93
+ | `cia monitor case close` | Close a case; passes skip it |
94
+
95
+ Three things to know before scheduling it:
96
+
97
+ - **`cia monitor run` is a one-shot.** One pass, then exit. Schedule it with
98
+ cron, pm2 (`cron_restart` plus `autorestart: false`), or your agent
99
+ harness's scheduled tasks.
100
+ - **Exit `2` means an isolated case failed** while every other case
101
+ completed. Partial success, not a crash. Only exit `1` means nothing ran.
102
+ - **An unchanged case is skipped, not re-rendered.** The run document
103
+ records `skipped_reason: 'unchanged'`, so a quiet watch reads as healthy
104
+ by design.
105
+
106
+ See [Continuous monitoring](docs/monitoring.md) for the full surface.
107
+
108
+ ## Dependencies
109
+
110
+ Upstream:
111
+
112
+ - **Chain Insights Graph MCP endpoint** — all graph queries and AML
113
+ primitives. Configured via `graphMcpEndpoint`; defaults to a local
114
+ endpoint.
115
+ - **Base mainnet RPC** — wallet balance and payment only
116
+ (`BASE_RPC_URL` override). Not a graph-support claim.
117
+ - **Devkit fixture data** — pre-generated from the upstream export path
118
+ and committed under `devkit/data/`.
119
+
120
+ Downstream:
121
+
122
+ - Analysts and AI agents install the npm package and call the CLI or the
123
+ MCP tools.
124
+ - Monitor case dossiers render as Markdown under the workspace
125
+ (`published/cases/<case_id>/`), ready for review and handoff.
126
+
127
+ ## Architecture
128
+
129
+ Chain Insights is the investigation layer above the Chain Insights Graph.
130
+ The CLI and MCP proxy call graph tools over one MCP endpoint, keep all
131
+ evidence in local workspace folders, and never write to the graph.
132
+
133
+ ```text
134
+ Agent or CLI user
135
+ -> Chain Insights CLI / MCP proxy
136
+ -> local config, wallet, workspace, artifacts, reports
137
+ -> Chain Insights Graph
138
+ -> graph intelligence for AML workflows
33
139
  ```
34
140
 
35
- Check the CLI:
141
+ Source modules (hand-maintained):
36
142
 
37
- ```bash
38
- cia --version
39
- cia update --check
40
- ```
143
+ | Module | Entrypoint | Component doc |
144
+ |---|---|---|
145
+ | `config` | `src/config` | [components/config.md](docs/architecture/components/config.md) |
146
+ | `federation` | `src/federation` | [components/federation.md](docs/architecture/components/federation.md) |
147
+ | `investigation` | `src/investigation` | [components/investigation.md](docs/architecture/components/investigation.md) |
148
+ | `mcp` | `src/mcp` | [components/mcp.md](docs/architecture/components/mcp.md) |
149
+ | `monitor` | `src/monitor` | [components/monitor.md](docs/architecture/components/monitor.md) |
150
+ | `server` | `src/server` | [components/server.md](docs/architecture/components/server.md) |
151
+ | `viz` | `src/viz` | [components/viz.md](docs/architecture/components/viz.md) |
152
+ | `wallet` | `src/wallet` | [components/wallet.md](docs/architecture/components/wallet.md) |
153
+
154
+ Entry points:
155
+
156
+ - `bin/cli.js` → `src/cli.ts` (CLI bins: `cia`, `chain-insights`).
157
+ - `bin/mcp-proxy.cjs` → `src/mcp/proxy.ts` (bin:
158
+ `chain-insights-mcp-proxy`).
159
+ - `src/index.ts` — library exports.
160
+
161
+ Full architecture docs: [docs/architecture/](docs/architecture/ARCHITECTURE.md),
162
+ including C4 diagrams, [data contracts](docs/architecture/data-contracts.md),
163
+ and [operating rules](docs/architecture/operating-rules.md).
164
+
165
+ ### Graph Access
166
+
167
+ Graph queries choose the read graph explicitly:
168
+
169
+ | Graph | Use it for |
170
+ | --- | --- |
171
+ | `topology` | The unified address / FLOWS_TO / LINKED graph — recent and full historical fund-flow traversal, plus the node `risk_score`/`risk_level` verdict |
172
+ | `facts` | Labels, features, assets, and enrichment |
173
+
174
+ One rule is worth reading before writing a query by hand: the `network`
175
+ argument selects the graph, not the addresses inside it. The address-space
176
+ split lives on the `:Address.network` node property. A `USE topology` match
177
+ on `:Address` without an exact address must scope itself with
178
+ `WHERE a.network = "..."`. On `USE facts` each network has its own backing
179
+ database and `Address` carries no `network` property at all. See
180
+ [Graph query compatibility](docs/graph-query-compatibility.md).
181
+
182
+ Agent installs include `chain-insights-cypher` for generic layer-aware
183
+ GQL/Cypher work and `chain-insights-bittensor-cypher` for Bittensor-specific
184
+ schema notes and examples (the bundled devkit serves a Bittensor fixture).
185
+
186
+ ## Billing: Billable Units
187
+
188
+ Chain Insights Graph bills by **billable units**.
189
+
190
+ - A **billable unit** is one row, node, or edge in your returned payload.
191
+ - Bigger responses cost more. Narrow queries cost less.
192
+ - The server reports `billable_units` on every graph response.
193
+
194
+ **Check your own count.** `src/lib/recount-units.ts` mirrors the server's
195
+ counting logic. Use it client-side to recount units in a response and
196
+ confirm the billed amount matches what you received.
41
197
 
42
- Run `cia update` to update a global npm install from the public npmjs registry.
43
- `cia init` also checks for a newer npm release in interactive terminals and
44
- prompts before updating.
198
+ **Watch for `truncated: true`.** A response can hit the row limit and get
199
+ cut off. When you see `truncated: true`:
45
200
 
46
- From a local checkout:
201
+ - Narrow the query with `LIMIT` to ask for fewer rows.
202
+ - Page through results with `SKIP` to fetch the next batch.
203
+ - Add a tighter `WHERE` filter before raising the limit.
204
+
205
+ **Workflow tools carry a `usage` block.** `aml_address_risk` runs many graph
206
+ queries behind the scenes to answer one question. Every response includes a
207
+ `usage` block with the total cost of all of them:
208
+
209
+ - **`billable_units`** — total units billed across every internal graph
210
+ query this workflow ran.
211
+ - **`query_count`** — how many internal graph queries it took.
212
+ - **`truncated_queries`** — how many of those internal queries hit their
213
+ row limit and got cut off.
214
+
215
+ Use `usage` to see the real cost of a workflow call, not just of one
216
+ `graph_query`.
217
+
218
+ ## Prerequisites And Environment Setup
219
+
220
+ - **Linux** is the reference platform; shell snippets use bash (macOS works
221
+ the same; on Windows use WSL).
222
+ - **Node.js 22 or newer** (`package.json` engines) and npm.
223
+ - Optional: Docker with the Compose plugin, for the local devkit backend.
224
+ - Optional: pm2 or cron, for standing-watch monitoring.
225
+
226
+ `.env.example` documents the two supported overrides:
227
+
228
+ | Variable | Purpose |
229
+ | --- | --- |
230
+ | `BASE_RPC_URL` | Base RPC override for wallet balance and the local top-up page |
231
+ | `CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT` | Chain Insights Graph endpoint override; local HTTP loopback allowed, remote hosts must use `https://` |
232
+
233
+ ## Run
234
+
235
+ ### Local (from a checkout)
47
236
 
48
237
  ```bash
49
238
  npm install
@@ -52,250 +241,215 @@ npm install -g .
52
241
  cia --version
53
242
  ```
54
243
 
55
- Create an investigation workspace:
244
+ Or install the released package:
245
+
246
+ ```bash
247
+ npm install -g chain-insights
248
+ cia --version
249
+ cia update --check
250
+ ```
251
+
252
+ Create an investigation workspace and run a first screen:
56
253
 
57
254
  ```bash
58
255
  mkdir -p ./chain-insights-investigations
59
256
  cd ./chain-insights-investigations
60
257
  cia init .
61
- ```
62
258
 
63
- Chain Insights workspaces are plain local folders. Use any editor or agent
64
- tooling you want to inspect workspace files, graph reports, artifacts, and
65
- published outputs.
259
+ cia mcp call aml_address_risk \
260
+ network=robinhood address=0xYourAddressHere
66
261
 
67
- ## Configure Chain Insights Graph Endpoint
262
+ find reports -maxdepth 3 -type f | sort
263
+ ```
68
264
 
69
- `cia` uses `graphMcpEndpoint` for all Chain Insights Graph calls. The npm
70
- package does not hardcode a hosted endpoint. Configure the endpoint explicitly for the
71
- environment you intend to use.
265
+ Workspaces are plain local folders. Reports, graph JSON, graph HTML, and
266
+ published bundles live under the initialized workspace. Export only when
267
+ you need to share, hand off, or archive a review checkpoint — the handoff
268
+ package lands under `published/<workspace-slug>/`.
72
269
 
73
- Local development endpoint (default):
270
+ Example queries. Direct topology:
74
271
 
75
272
  ```bash
76
- cia config set graphMcpEndpoint http://127.0.0.1:8012/mcp
273
+ cia mcp call graph_query \
274
+ network=robinhood \
275
+ "query=USE topology MATCH (a:Address) RETURN a.address AS address, a.network AS network, a.labels AS labels, a.risk_level AS risk_level LIMIT 10"
77
276
  ```
78
277
 
79
- For a deterministic local Bittensor backend, use the RBMK-managed devkit
80
- runbook and point Chain Insights at it persistently:
278
+ Batch across graph views:
81
279
 
82
280
  ```bash
83
- cia debug on --token <any-string> --endpoint http://127.0.0.1:18012/mcp
281
+ cia mcp call graph_query_batch \
282
+ network=robinhood \
283
+ 'queries=[{"id":"count","query":"USE topology MATCH (a:Address) RETURN count(a) AS count LIMIT 1"},{"id":"flows","query":"USE topology MATCH (src:Address)-[f:FLOWS_TO]->(dst:Address) RETURN src.address AS source, dst.address AS target, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count LIMIT 3"},{"id":"linked","query":"USE topology MATCH (a:Address)-[l:LINKED]-(b:Address) RETURN a.address AS address, b.address AS linked_address, l.basis AS basis, l.confidence AS confidence LIMIT 3"},{"id":"node_metrics","query":"USE topology MATCH (a:Address {address:\"FULL_ADDRESS\"}) RETURN a.address AS address, a.tx_out_count AS tx_out_count, a.tx_in_count AS tx_in_count LIMIT 1"}]'
84
284
  ```
85
285
 
86
- The devkit backend is unmetered and never issues a paid challenge, so
87
- `cia config set graphMcpEndpoint http://127.0.0.1:18012/mcp` alone also works;
88
- `debug on` just skips payment negotiation outright.
286
+ More query examples (manual fund-flow reads, pagination):
287
+ [Graph tools](docs/graph-tools.md).
89
288
 
90
- Hosted staging endpoint for approved testers:
289
+ ### Dev Compose (local devkit backend)
91
290
 
92
- ```bash
93
- cia config set graphMcpEndpoint https://staging-mcp.chain-insights.ai/mcp
94
- ```
291
+ The devkit runs a deterministic local Bittensor Chain Insights Graph
292
+ backend. Compose file: `devkit/docker-compose.yml` (default compose
293
+ project network). Services: `starrocks`, `memgraph`,
294
+ `starrocks-import`, `memgraph-import` (one-shot), and
295
+ `chain-insights-graph-devkit`. Images build locally with
296
+ `docker compose build` — never pulled from a registry.
95
297
 
96
- For now, use the staging endpoint only for tester activation. Production is not
97
- live yet.
298
+ Start from a clean state:
98
299
 
99
- Hosted access also needs an access mode, such as an approved access key or a
100
- prepared wallet. Keep those credentials out of README examples; setup commands
101
- live in [MCP proxy](docs/mcp-proxy.md). For paid access, run
102
- `cia wallet ready`; it checks funding and finishes one-time payment setup.
300
+ ```bash
301
+ docker compose -f devkit/docker-compose.yml down -v --remove-orphans
302
+ docker compose -f devkit/docker-compose.yml up -d --build
303
+ ```
103
304
 
104
- Optional one-shot override from the environment:
305
+ One-shot import services must exit 0. `starrocks`, `memgraph`, and
306
+ `chain-insights-graph-devkit` must stay running. The MCP endpoint is
307
+ `http://127.0.0.1:18012/mcp`, unmetered:
105
308
 
106
309
  ```bash
107
- export CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT=https://staging-mcp.chain-insights.ai/mcp
310
+ export CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT=http://127.0.0.1:18012/mcp
108
311
  ```
109
312
 
110
- Validation rules:
111
-
112
- - `http://` is accepted only for `localhost` / loopback addresses.
113
- - Remote hosts must use `https://`.
114
- - Endpoint URLs with credentials, query strings, or fragments are rejected.
313
+ Full contract and procedures live in the devkit directory's own README.
115
314
 
116
- Configuration precedence for `graphMcpEndpoint`:
315
+ ## Configure
117
316
 
118
- 1. `CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT` env var (`GRAPH_MCP_ENDPOINT` legacy alias also supported)
119
- 2. `cia config set graphMcpEndpoint ...` saved value
120
- 3. Local default `http://127.0.0.1:8012/mcp`
317
+ `cia` uses `graphMcpEndpoint` for all Chain Insights Graph calls. The npm
318
+ package does not hardcode a hosted endpoint.
121
319
 
122
- Check the configured endpoint and current Chain Insights Graph capabilities:
320
+ Local development endpoint (default):
123
321
 
124
322
  ```bash
125
- cia config get graphMcpEndpoint
126
- cia mcp networks
127
- cia mcp call meta_usage_status
128
- cia mcp tools --refresh
323
+ cia config set graphMcpEndpoint http://127.0.0.1:8012/mcp
129
324
  ```
130
325
 
131
- If network or tool discovery fails, check the endpoint and access mode first.
132
- The CLI can still initialize workspaces and continue investigation workflow
133
- without a reachable Chain Insights Graph endpoint.
134
-
135
- Hosted Chain Insights Graph includes a small public free tier for `graph_query`
136
- before paid access is required. The default public free tier is 10 execution seconds
137
- per IP per UTC day. Use `meta_usage_status` to see the current caller allowance.
138
- Prepared wallet users receive the daily free tier first, then paid access
139
- continues automatically after the allowance is exhausted.
140
- If you do not have a prepared wallet yet, use bounded single `graph_query`
141
- calls within the free tier, then prepare a wallet or use an invited tester
142
- access key when the allowance is exhausted.
143
-
144
- Run a focused investigation in the initialized workspace:
326
+ Hosted endpoint (when you have one; it is operator configuration, never a
327
+ package default):
145
328
 
146
329
  ```bash
147
- cia init .
148
-
149
- cia mcp trace-victim-funds \
150
- --network bittensor \
151
- --victim-addresses 5GTjfJaLpBNrgybhY24NqhDnKW9r94z72RSYLxeodxJfSkj5
330
+ cia config set graphMcpEndpoint https://graph.example.com/mcp
152
331
  ```
153
332
 
154
- Then inspect:
333
+ Optional one-shot override from the environment:
155
334
 
156
335
  ```bash
157
- find reports -maxdepth 3 -type f | sort
336
+ export CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT=https://graph.example.com/mcp
158
337
  ```
159
338
 
160
- ## Export Only When Sharing
339
+ Configuration precedence:
161
340
 
162
- Normal local work happens in the workspace. Export only when you need
163
- to share, hand it off to a partner, ingest into LLM Wiki, or archive a
164
- review checkpoint.
341
+ 1. `CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT` env var (`GRAPH_MCP_ENDPOINT`
342
+ legacy alias also supported).
343
+ 2. `cia config set graphMcpEndpoint ...` saved value.
344
+ 3. Local default `http://127.0.0.1:8012/mcp`.
165
345
 
166
- ```bash
167
- # Use your configured workspace export flow to produce the handoff package.
168
- published/<workspace-slug>/
169
- ```
346
+ Validation rules:
347
+
348
+ - `http://` is accepted only for localhost / loopback addresses.
349
+ - Remote hosts must use `https://`.
350
+ - Endpoint URLs with credentials, query strings, or fragments are rejected.
170
351
 
171
- Workspace-generated reports, graph JSON, graph HTML, and published bundles live
172
- under the initialized workspace. Treat those files as the durable handoff
173
- surface.
352
+ Hosted access also needs an access mode, such as an approved access key or
353
+ a prepared wallet. For paid access, run `cia wallet ready` — it checks
354
+ funding and finishes one-time payment setup. Setup commands live in
355
+ [MCP proxy](docs/mcp-proxy.md).
174
356
 
175
- ## Examples
357
+ The hosted graph includes a small public free tier for `graph_query`
358
+ (default: 10 execution seconds per IP per UTC day). Use
359
+ `meta_usage_status` to see the current caller allowance. Prepared wallet
360
+ users receive the free tier first, then paid access continues
361
+ automatically.
176
362
 
177
- Run a direct live topology query:
363
+ Search bounds (hops, row limits, frontiers) are tunable per call, per
364
+ network, or globally — see [Search limits](docs/search-limits.md).
178
365
 
179
- ```bash
180
- cia mcp call graph_query \
181
- network=bittensor \
182
- "query=USE live_topology MATCH (i:Identity) RETURN i.identity_id AS identity_id, i.labels AS labels, i.risk_level AS risk_level LIMIT 10"
183
- ```
366
+ ## Test
184
367
 
185
- Run a batch across graph views:
368
+ Local gate, in order:
186
369
 
187
370
  ```bash
188
- cia mcp call graph_query_batch \
189
- network=bittensor \
190
- 'queries=[{"id":"count","query":"USE live_topology MATCH (i:Identity) RETURN count(i) AS count LIMIT 1"},{"id":"archive_flows","query":"USE archive_topology MATCH (src:Identity)-[f:FLOWS_TO]->(dst:Identity) RETURN f.period_granularity AS granularity, src.identity_id AS source, dst.identity_id AS target, f.amount_usd_sum AS amount_usd_sum LIMIT 3"},{"id":"archive_member_address","query":"USE archive_topology MATCH (i:Identity)-[:HAS_ADDRESS]->(m:Address) RETURN i.identity_id AS identity_id, m.address AS member_address, m.network AS member_network LIMIT 3"},{"id":"facts_sample","query":"USE facts MATCH (i:Identity)-[:HAS_FEATURE]->(f:AddressFeature) RETURN i.identity_id AS identity_id, f.tx_out_count AS tx_out_count LIMIT 3"}]'
371
+ npm run typecheck
372
+ npm run build
373
+ npm test
374
+ npm run release:check # PR-only step in verify.yml
191
375
  ```
192
376
 
193
- For no-wallet public free-tier usage, prefer the single-query example first.
194
- Batch calls reserve worst-case execution time and can ask for paid access even
195
- when a small free allowance remains.
196
-
197
- Run suspect topology without requiring an incident timestamp:
377
+ Devkit-backed tiers (need the dev compose lane running):
198
378
 
199
379
  ```bash
200
- cia mcp trace-suspect-funds \
201
- --network bittensor \
202
- --suspect-addresses 5... \
203
- --max-hops 16
380
+ npm run devkit:smoke
381
+ npm run devkit:smoke:parity
382
+ npm run test:devkit
204
383
  ```
205
384
 
206
- ## How It Fits Together
385
+ CI install step, when reproducing CI:
207
386
 
208
- ```text
209
- Agent or CLI user
210
- -> Chain Insights CLI / MCP proxy
211
- -> local config, wallet, workspace, artifacts, reports
212
- -> Chain Insights Graph
213
- -> graph intelligence for AML workflows
387
+ ```bash
388
+ npm ci --ignore-scripts --audit=false --fund=false
214
389
  ```
215
390
 
216
- Chain Insights stores investigation outputs in initialized local workspaces.
217
- Chain Insights Graph performs graph-language reads against network-specific
218
- layers.
391
+ CI workflows: `.github/workflows/verify.yml` (typecheck, build,
392
+ release:check, tests, npm pack contents), `security.yml`, `scorecard.yml`,
393
+ `docs.yml`.
219
394
 
220
- ## Graph Access
395
+ ## Debug
221
396
 
222
- Graph queries must choose the right read layer explicitly:
223
-
224
- | Layer | Use it for |
225
- | --- | --- |
226
- | `live_topology` | Recent topology and fast traversal |
227
- | `archive_topology` | Historical fund-flow context |
228
- | `facts` | Labels, features, risk scores, assets, and enrichment |
397
+ - Diagnostics and debug workflows: [docs/debugging.md](docs/debugging.md).
398
+ - Skip payment negotiation against the unmetered devkit:
399
+ `cia debug on --token <any-string> --endpoint http://127.0.0.1:18012/mcp`.
400
+ - MCP proxy structured logs: `~/.chain-insights/runtime/logs/mcp-proxy.jsonl`.
229
401
 
230
- Use `graph_query_batch` when related reads should share one call and one
231
- result envelope. Use explicit `LIMIT` and pagination in your query when you
232
- want bounded result sets. Endpoint access and authentication are configured
233
- separately; see [MCP proxy](docs/mcp-proxy.md).
402
+ Health checks (each is runnable):
234
403
 
235
- Agent installs include `chain-insights-cypher` for generic layer-aware
236
- GQL/Cypher work and `chain-insights-bittensor-cypher` for Bittensor-specific
237
- schema notes and examples.
404
+ ```bash
405
+ # Configured endpoint
406
+ cia config get graphMcpEndpoint
238
407
 
239
- ## AML Tools
408
+ # Endpoint reachable, networks listed
409
+ cia mcp networks
240
410
 
241
- The high-level AML tools are Chain Insights workflows built around graph access
242
- and local workspace state:
411
+ # Caller allowance / metering status
412
+ cia mcp call meta_usage_status
243
413
 
244
- - `aml_address_risk` starts a single-address screen with risk, behavior,
245
- neighborhood context, and exchange exposure.
246
- - `aml_trace_victim_funds` traces victim/source funds forward through
247
- intermediaries to exchange deposit candidates.
248
- - `aml_trace_deposit_sources` traces backward from suspected deposit/cashout
249
- addresses to upstream sources and shared-source convergence.
250
- - `aml_trace_suspect_funds` traces suspected scammer, mule, operator, or
251
- laundering-ring funds forward to cashout topology.
414
+ # Fresh tool discovery
415
+ cia mcp tools --refresh
252
416
 
253
- AML tools accept full blockchain addresses and return blockchain addresses as
254
- the public result surface. Chain Insights resolves those addresses to
255
- identity-grain topology internally and includes identity resolution metadata for
256
- audit/debug use.
417
+ # Installed CLI sanity
418
+ cia --version && cia update --check
257
419
 
258
- The three trace tools share `chain-insights.trace.v1` and return compact,
259
- chainable results. Full graph/table/report artifacts remain on disk under the
260
- workspace, with pointers in the tool result and workspace evidence.
420
+ # Devkit service state (all imports exited 0, backends running)
421
+ docker compose -f devkit/docker-compose.yml ps -a
422
+ ```
261
423
 
262
- Trace traversal treats exchange hot wallets as terminal endpoints only. Tools do
263
- not expand through exchange nodes or classify them as deposit, suspect, or
264
- intermediate candidates.
424
+ If network or tool discovery fails, check the endpoint and access mode
425
+ first. The CLI can still initialize workspaces and continue local
426
+ investigation workflow without a reachable endpoint.
265
427
 
266
- When investigation output is large, tools can save compact evidence pointers and
267
- graph reports under the workspace instead of embedding large payloads in human
268
- notes.
428
+ ## Documentation Links
269
429
 
270
- ## Docs Map
430
+ Product docs:
271
431
 
272
432
  | Doc | Use it for |
273
433
  | --- | --- |
274
- | [Graph tools](docs/graph-tools.md) | Chain Insights Graph layers, `graph_query`, `graph_query_batch`, AML tool contracts, graph reports, evidence pointers |
275
- | Bittensor devkit parity workflow (RBMK) | Local Chain Insights Graph backend with deterministic Bittensor fixture data for Chain Insights development |
276
- | [Investigation workspaces](docs/investigation-workspaces.md) | `cia init`, workspace layout, artifacts, imports, templates, sessions, reports, and visualization outputs |
277
- | [MCP proxy](docs/mcp-proxy.md) | Stdio proxy behavior, endpoint configuration, agent installers, local tools, auth modes, Inspector validation |
278
- | [Architecture](docs/architecture.md) | Product layers, data flow, local storage, security model, config keys |
434
+ | [Graph tools](docs/graph-tools.md) | Graph layers, `graph_query`, `graph_query_batch`, AML tool contracts, graph reports |
435
+ | [Graph query compatibility](docs/graph-query-compatibility.md) | GQL/Cypher support per layer, rewrite recipes, traversal guidance |
436
+ | [Search limits](docs/search-limits.md) | Tunable search/row/frontier/hop bounds, precedence, ceilings |
437
+ | [Investigation workspaces](docs/investigation-workspaces.md) | `cia init`, workspace layout, artifacts, templates, reports, visualization |
438
+ | [Continuous monitoring](docs/monitoring.md) | `cia monitor` commands, case tracking, dossier rendering, scheduling, exit codes |
439
+ | [MCP proxy](docs/mcp-proxy.md) | Stdio proxy behavior, endpoint configuration, agent installers, auth modes |
440
+ | [Architecture overview](docs/architecture.md) | Product layers, data flow, local storage, security model, config keys |
279
441
  | [Development](docs/development.md) | Build, test, and local install commands |
280
442
  | [Contributing](docs/contributing.md) | Development workflow, pull requests, release expectations |
443
+ | [Stability policy](docs/stability.md) | Guaranteed surfaces (exit codes, MCP tool names, workspace layout), deprecation rules |
281
444
  | [Debugging](docs/debugging.md) | Local troubleshooting, diagnostics, debug workflows |
445
+ | Bittensor devkit (in this repo under `devkit/`) | Local Bittensor graph backend contract, fixture, smoke procedures |
282
446
 
283
- ## What It Is Not
284
-
285
- Chain Insights is not a custodial wallet, hosted case database, or replacement
286
- for analyst review. It does not write risk labels automatically. Investigation
287
- data stays in the local workspace unless the operator exports or shares it.
447
+ Architecture depth:
288
448
 
289
- ## Workers
290
-
291
- <!-- gsd: workers -->
292
- | Worker | Entrypoint | Component doc |
293
- |---|---|---|
294
- | `claude-desktop` | `src/claude-desktop` | [components/claude-desktop.md](docs/architecture/components/claude-desktop.md) |
295
- | `config` | `src/config` | [components/config.md](docs/architecture/components/config.md) |
296
- | `investigation` | `src/investigation` | [components/investigation.md](docs/architecture/components/investigation.md) |
297
- | `mcp` | `src/mcp` | [components/mcp.md](docs/architecture/components/mcp.md) |
298
- | `server` | `src/server` | [components/server.md](docs/architecture/components/server.md) |
299
- | `viz` | `src/viz` | [components/viz.md](docs/architecture/components/viz.md) |
300
- | `wallet` | `src/wallet` | [components/wallet.md](docs/architecture/components/wallet.md) |
301
- <!-- /gsd: workers -->
449
+ - [docs/architecture/](docs/architecture/ARCHITECTURE.md) — index, C4
450
+ diagrams, context, containers, components.
451
+ - [Data contracts](docs/architecture/data-contracts.md) — tool surface,
452
+ search limits, endpoint rules, shared-graph model, devkit contract.
453
+ - [Operating rules](docs/architecture/operating-rules.md) — repo
454
+ invariants, findings rules, CI gotchas.
455
+ - [docs/acceptance/](docs/acceptance/) — per-component acceptance evidence.