chain-insights 0.58.3 → 0.58.4

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.
package/README.md CHANGED
@@ -159,8 +159,8 @@ Entry points:
159
159
  - `src/index.ts` — library exports.
160
160
 
161
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).
162
+ the contracts the code keeps in [Development](docs/development.md#contracts-the-code-keeps),
163
+ and the repository rules in [Contributing](docs/contributing.md#repository-rules).
164
164
 
165
165
  ### Graph Access
166
166
 
@@ -442,10 +442,10 @@ Product docs:
442
442
 
443
443
  Architecture depth:
444
444
 
445
- - [docs/architecture/](docs/architecture/ARCHITECTURE.md) — index, C4
446
- diagrams, context, containers, components.
447
- - [Data contracts](docs/architecture/data-contracts.md) — tool surface,
448
- search limits, endpoint rules, shared-graph model.
449
- - [Operating rules](docs/architecture/operating-rules.md) — repo
450
- invariants, findings rules, CI gotchas.
445
+ - [docs/architecture/](docs/architecture/ARCHITECTURE.md) — the component
446
+ diagram, containers, one doc per source module.
447
+ - [Contracts the code keeps](docs/development.md#contracts-the-code-keeps) —
448
+ tool surface, argument allowlists, endpoint rules, shared-graph model.
449
+ - [Repository rules](docs/contributing.md#repository-rules) — invariants,
450
+ CI gotchas, documentation rules.
451
451
  - [docs/acceptance/](docs/acceptance/) — per-component acceptance evidence.
@@ -53,6 +53,76 @@ npm run release:check
53
53
  git diff --check
54
54
  ```
55
55
 
56
+ ## Repository rules
57
+ ### Repository Invariants
58
+
59
+ - `AGENTS.md` and `CLAUDE.md` are twin files kept byte-identical. Edit both
60
+ together, or neither.
61
+ - Every PR that changes tracked files must bump `package.json`,
62
+ `package-lock.json`, and `CHANGELOG.md`. Enforced by
63
+ `npm run release:check` (`scripts/check-release-gate.mjs`) in
64
+ `verify.yml` on pull requests.
65
+ - This is a **public** repo. No private repository names, local workspace
66
+ paths, internal planning catalogs, private deployment details, or
67
+ org-only workflow names in tracked files. Use the name
68
+ "Chain Insights Graph" for the graph layer.
69
+ - Public workflow network support is one network: robinhood. The wallet
70
+ pays on Base mainnet as the payment chain only — not a graph-support
71
+ claim.
72
+ - Node 22 or newer is required (`package.json` engines). CI installs with
73
+ `npm ci --ignore-scripts`.
74
+
75
+ ### Data And Findings Invariants
76
+
77
+ - Address labels are served by the Chain Insights Graph backend, never
78
+ written by this CLI.
79
+
80
+ ### Development Workflow Rules
81
+
82
+ - `npm run build` is not plain compilation. It also copies wallet MCP-proxy
83
+ assets to `dist/assets`. Skipping it stales the packaged assets. See the
84
+ `dist/` trap in [development.md](development.md).
85
+ - `package.json` `files[]` ships `bin`, `dist`, `skills` and `docs/*.md`.
86
+ Adding a skill or doc changes the published tarball.
87
+ `verify.yml` runs `npm pack` and lists contents.
88
+ - npm overrides pin `ws` to 8.21.0 (`package.json`).
89
+
90
+ ### CI Gotchas
91
+
92
+ - `verify.yml` runs on every pull request and every push to `main`, on the
93
+ self-hosted `chainswarm-runner` runners. Its three tiers are the files
94
+ under `ci/` (`t1.sh`, `lint.sh`, `build.sh`), so `bash ci/t1.sh` runs the
95
+ same gate locally.
96
+ - Repo CI has a release gate blocking non-release PRs and a secret scan
97
+ flagging `0x{64}` hex. Avoid committing 64-hex strings.
98
+ - UATs expecting unprefixed tool names (`address_risk`, `trace_funds`, …)
99
+ are stale. Those names are deliberately hidden, and
100
+ `assertPublicMcpToolName()` throws with a suggested `aml_*` / `meta_*`
101
+ replacement.
102
+ - Backend big-query memory limits can surface as generic timeout-like
103
+ errors on archive queries. Do not diagnose these as proxy bugs.
104
+
105
+ ### Method Ownership (Reference, Do Not Restate)
106
+
107
+ - Inspector / ACP surface audits (tools/list, prompts/list, prefixed-name
108
+ sync): internal maintainer tooling, not part of this package.
109
+ - ACP release method: internal maintainer tooling.
110
+ - Real local UAT against the GraphRAG MCP: internal maintainer tooling.
111
+ - npm release testing: internal maintainer tooling.
112
+ - Graph serving tiers and sync detail: internal system knowledge, not this
113
+ repo.
114
+
115
+ ### Documentation Rules
116
+
117
+ - Keep docs product-first and user-workflow-first: install → configure graph
118
+ access → run AML tools.
119
+ - Localhost endpoints are fine in debugging docs. Private paths are not.
120
+ - The shipped product skill under `skills/` is `chain-insights-cypher`.
121
+ It is a separate product surface
122
+ packaged into the npm tarball and enforced by
123
+ `tests/skills-contract.test.ts`. A capability no skill mentions is
124
+ invisible to agents — keep the skill in step with any change.
125
+
56
126
  ## Release Discipline
57
127
 
58
128
  Every PR to `main` must:
@@ -73,8 +73,94 @@ npm install -g .
73
73
  cia --version
74
74
  ```
75
75
 
76
+ ## Contracts the code keeps
77
+ The contracts Chain Insights exposes and consumes. Every statement here
78
+ names the source file it was verified against.
79
+
80
+ ### Public MCP Tool Surface
81
+
82
+ - The canonical public tool surface is the prefixed set `graph_*` /
83
+ `meta_*` / `wallet_*`.
84
+ - `visibleRemoteTools()` in `src/mcp/tool-visibility.ts` hides unprefixed
85
+ backend names (`address_risk`, `trace_victim_funds`, `trace_suspect_funds`,
86
+ `trace_deposit_sources`, `trace_funds`, `track_funds`,
87
+ `network_capabilities`, `usage_status`, `balance`, `topup`, `help`,
88
+ `address_connection_risk` and the retired exchange-flows tool) via
89
+ `HIDDEN_REMOTE_TOOL_NAMES`. They never surface publicly. So does
90
+ `aml_address_risk`, hidden until its verdict is fixed.
91
+ - Local tools live in `src/mcp/proxy.ts` (`LOCAL_TOOL_NAMES`):
92
+ `meta_network_capabilities`, `meta_schema`, `meta_rules`, `meta_help`,
93
+ `meta_usage_status`, `meta_subscription_status`, `wallet_balance`,
94
+ `wallet_topup`, and `graph_expand`, which only the view calls
95
+ (`APP_ONLY_LOCAL_TOOL_NAMES`).
96
+ - `meta_schema` (`src/mcp/graph-schema.ts`) builds the live graph schema of one
97
+ network from the catalog statements of the graph endpoint (`CALL db.labels()`,
98
+ `CALL db.relationshipTypes()`, `CALL db.propertyKeys()`, `SHOW INDEXES`), a
99
+ sample of the main kinds and the published capabilities. It returns
100
+ `chain-insights.graph-schema.v1`, and keeps it on disk for 24 hours
101
+ (`src/mcp/graph-schema-cache.ts`).
102
+ - `meta_network_capabilities` repeats GraphRAG's advertised networks
103
+ (`mirrorGraphNetworkCapabilities` in `src/mcp/capabilities.ts`). CIA
104
+ preserves the tool status advertised for each network. It does not add
105
+ tools that the network did not advertise. It also repeats the blocks a
106
+ network publishes about its layers exactly as sent: `layers`,
107
+ `chain_admission`, `topology_admission` and `facts_admission`. A block the
108
+ server did not send stays absent, never empty. The limits of a layer are read
109
+ from these blocks, never written into a skill.
110
+
111
+ #### Tool Argument Contracts
112
+
113
+ - `PUBLIC_MCP_TOOL_REQUIRED_ARGS` / `PUBLIC_MCP_TOOL_ALLOWED_ARGS` in
114
+ `src/mcp/tool-visibility.ts` define the public arg contract. Examples:
115
+ `graph_query` requires query + network; `graph_query_batch` alone allows
116
+ `per_query_timeout_seconds`; both allow `time_scope`.
117
+ - An argument absent from the allowlist is silently stripped by
118
+ `normalizeRemoteToolArguments`. Every new tunable arg must be added here
119
+ and to the numeric-argument set in `src/mcp/call-args.ts` the moment it
120
+ appears on a tool schema.
121
+
122
+ ### Endpoint Configuration
123
+
124
+ Precedence for the Chain Insights Graph endpoint:
125
+
126
+ 1. `CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT` environment variable.
127
+ 2. Legacy `GRAPH_MCP_ENDPOINT` environment variable.
128
+ 3. Saved `graphMcpEndpoint` config value.
129
+ 4. Default `https://mcp.chain-insights.ai/`.
130
+
131
+ Validation (`validateMcpEndpoint` in `src/config/mcp-endpoint.ts`):
132
+
133
+ - `http://` only for loopback or Kubernetes `*.svc.cluster.local` service DNS.
134
+ - Other remote hosts must use `https://`.
135
+ - No credentials, query string, or fragment in the URL.
136
+
137
+ The MCP proxy uses stateless operation by default. It returns tool results to
138
+ the caller and does not create local investigation files.
139
+
140
+ ### Shared-Graph Model
141
+
142
+ The public surface exposes **one network** (`robinhood`, see Public MCP
143
+ Tool Surface). Address space details are a chain property, not a separate
144
+ query network.
145
+
146
+ Consequences:
147
+
148
+ - The `network` argument to `graph_query` selects the graph, not the address
149
+ subset. `network` is also a property of every node and relationship on
150
+ `USE topology`, `USE facts` and `USE chain`. Its value is the query's
151
+ `network`, it is computed and never stored, and only a `:Chain` node (the far
152
+ side of a bridge) stores its own, which names the remote chain. A filter on
153
+ `network` narrows nothing. Anchor a query on an address instead.
154
+ - `USE facts` carries `network` on its rows and endpoints too, with no view
155
+ column behind it. Facts serves `Address` only as a `TRANSFER` endpoint, so a
156
+ single-node `MATCH (a:Address)` is refused. Facts serves no kind label.
157
+
158
+ Verify against the live stack before restating it. Query-side detail:
159
+ [graph-query-compatibility.md](graph-query-compatibility.md).
160
+
76
161
  ## More Developer Docs
77
162
 
78
163
  - Contributor workflow: `docs/contributing.md`
79
164
  - Debugging and UAT: `docs/debugging.md`
80
165
  - Graph tool contracts: `docs/graph-tools.md`
166
+ - Architecture index: `docs/architecture/ARCHITECTURE.md`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chain-insights",
3
- "version": "0.58.3",
3
+ "version": "0.58.4",
4
4
  "description": "AML investigation CLI and MCP proxy for blockchain risk screening and Chain Insights Graph access",
5
5
  "homepage": "https://chain-insights.ai",
6
6
  "repository": {
@@ -50,8 +50,7 @@
50
50
  "dist",
51
51
  "skills",
52
52
  "!skills/rbmk-*",
53
- "docs/*.md",
54
- "docs/images"
53
+ "docs/*.md"
55
54
  ],
56
55
  "scripts": {
57
56
  "build": "tsdown && mkdir -p dist/assets dist/apps && cp -r src/wallet/mcp-proxy/assets/* dist/assets/ && cp src/mcp/apps/claude-view.html dist/apps/",
Binary file