@mikeargento/bitgraph-mcp 0.1.2 → 0.2.0

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/dist/server.js CHANGED
@@ -2,18 +2,70 @@
2
2
  /**
3
3
  * @mikeargento/bitgraph-mcp: tool definitions.
4
4
  *
5
- * Three gestures, the same three the website has: record a file (take a
6
- * BitGraph), check whether bytes are on record, fetch a proof. Only SHA-256
7
- * digests ever leave the machine; file contents are never uploaded.
5
+ * Three gestures, the same three the website has: take a BitGraph of a file,
6
+ * check whether bytes are on record, fetch a proof. Taking a BitGraph builds a
7
+ * fused artifact from the file in memory, on this machine, and commits its
8
+ * digest under a slot allocated for it; only SHA-256 digests and slot records
9
+ * ever leave the machine. File contents are never uploaded.
8
10
  */
9
11
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
12
  import { z } from "zod";
11
- import { ApiError, PartialCommitError, batchCheck, commitDigests, configFromEnv, getProofDetail, search, } from "./api.js";
13
+ import { readFile } from "node:fs/promises";
14
+ import { fuse, builderFor, placementForBytes, fusedNamesFor } from "@mikeargento/bitgraph";
15
+ import { ApiError, batchCheck, configFromEnv, getProofDetail, search, } from "./api.js";
12
16
  import { fromUrlSafeB64, looksLikeDigest, mapConcurrent, sha256FileB64, toUrlSafeB64, } from "./encoding.js";
13
17
  import { capJson, positionOf, proofUrl, renderCheckMarkdown, renderProofMarkdown, renderRecordMarkdown, } from "./format.js";
14
- export const SERVER_VERSION = "0.1.2";
18
+ export const SERVER_VERSION = "0.2.0";
15
19
  const HASH_CONCURRENCY = 4;
16
20
  const MAX_FILES = 500;
21
+ /** Files above this are refused: the fused artifact is built in memory. */
22
+ const MAX_FUSE_BYTES = 256 * 1024 * 1024;
23
+ /**
24
+ * The default pipeline, the same one the site's drop and the bitgraph-fuse
25
+ * command run: choose the placement from the bytes, allocate a slot, derive
26
+ * the commitment, build the fused bytes, hash them, commit under that exact
27
+ * slot, verify the returned proof against the bytes.
28
+ */
29
+ async function fuseFileDefault(bytes, name, config) {
30
+ const placement = placementForBytes(bytes);
31
+ const { fusedName } = fusedNamesFor(name, placement);
32
+ const r = await fuse(builderFor(placement, bytes), {
33
+ placement,
34
+ original: bytes,
35
+ fusedFile: fusedName,
36
+ keepFused: false,
37
+ transport: { baseUrl: config.baseUrl, ...(config.apiKey ? { apiKey: config.apiKey } : {}) },
38
+ });
39
+ return {
40
+ proof: r.proof,
41
+ frame: r.frame,
42
+ placement,
43
+ artifactDigestB64: r.artifactDigestB64,
44
+ originDigestB64: r.originDigestB64 ?? "",
45
+ };
46
+ }
47
+ /** Read the given paths whole (bounded concurrency). Throws before any network call. */
48
+ async function readPaths(paths) {
49
+ const failures = [];
50
+ const out = await mapConcurrent(paths, HASH_CONCURRENCY, async (p) => {
51
+ try {
52
+ const buf = await readFile(p);
53
+ if (buf.length > MAX_FUSE_BYTES)
54
+ throw new Error(`larger than ${MAX_FUSE_BYTES / (1024 * 1024)} MB; the fused artifact is built in memory`);
55
+ const bytes = new Uint8Array(buf);
56
+ const digestB64 = await sha256FileB64(p);
57
+ return { bytes, digestB64 };
58
+ }
59
+ catch (err) {
60
+ failures.push(`${p}: ${err instanceof Error ? err.message : String(err)}`);
61
+ return { bytes: new Uint8Array(0), digestB64: "" };
62
+ }
63
+ });
64
+ if (failures.length > 0) {
65
+ throw new Error(`Could not read ${failures.length} file(s); nothing was BitGraphed.\n${failures.join("\n")}\nUse absolute paths to existing regular files under ${MAX_FUSE_BYTES / (1024 * 1024)} MB.`);
66
+ }
67
+ return out;
68
+ }
17
69
  const responseFormatSchema = z
18
70
  .enum(["markdown", "json"])
19
71
  .default("markdown")
@@ -51,38 +103,31 @@ async function hashPaths(paths) {
51
103
  }
52
104
  return digests;
53
105
  }
54
- export function buildServer() {
106
+ export function buildServer(deps = {}) {
107
+ const fuseFile = deps.fuseFile ?? fuseFileDefault;
55
108
  const server = new McpServer({
56
109
  name: "bitgraph-mcp-server",
57
110
  version: SERVER_VERSION,
58
111
  });
59
112
  server.registerTool("bitgraph_record", {
60
113
  title: "Take a BitGraph",
61
- description: "Take a BitGraph of one or more files: record each file's SHA-256 digest at a new causal position in the BitGraph ledger (bitgraph.ing). " +
62
- "Only the digest leaves the machine; file contents are never uploaded. " +
63
- "Files whose bytes are already on record are NOT re-recorded by default; they come back as 'on record' with their existing proof. " +
64
- "Pass again=true to deliberately record already-recorded bytes at a new causal position (BitGraph Again). " +
65
- "Recordings are permanent: the ledger has 10-year retention and no deletes, so only record files the user asked to record. " +
66
- "Returns one outcome per file: 'recorded' (newly minted) or 'on record' (was already there), with its position number and proof page URL. " +
114
+ description: "Take a BitGraph of one or more files. For each file, on this machine: hash it (the origin), allocate an unused slot in the BitGraph ledger (bitgraph.ing) before any artifact exists, build a new fused artifact from the file in memory with a registered placement (a 48-byte trailer for formats that ignore trailing bytes such as JPEG, PNG, TIFF, WebP; a small tar container otherwise), hash it, and commit that digest under the same slot. " +
115
+ "The file is never modified and never uploaded; only digests and slot records leave the machine. The fused bytes are not kept: the original plus the proof rebuilds them, and the Frame for each file is returned in the structured result. " +
116
+ "Files whose bytes are already on record, as a recording or as the origin of a fused artifact, are NOT BitGraphed again by default; they come back as 'on record' with their earliest position. " +
117
+ "Pass again=true to deliberately make a new fused artifact from a file already on record. " +
118
+ "BitGraphs are permanent: the ledger has 10-year retention and no deletes, so only BitGraph files the user asked to. " +
119
+ "Returns one outcome per file: 'fused' (a new fused artifact, with its placement, position and proof page URL), 'on record', or 'not fused' (with the error). " +
67
120
  "Use bitgraph_check instead when the user only wants to know whether a file is on record.",
68
121
  inputSchema: {
69
122
  paths: z
70
123
  .array(z.string().min(1))
71
124
  .min(1)
72
125
  .max(MAX_FILES)
73
- .describe(`File paths to record (absolute paths preferred), up to ${MAX_FILES}.`),
74
- attribution: z
75
- .object({
76
- name: z.string().max(200).optional().describe("Submitter's name (self-attributed)."),
77
- title: z.string().max(200).optional(),
78
- message: z.string().max(2000).optional(),
79
- })
80
- .optional()
81
- .describe("Optional self-attributed submitter's note, stored in the signed proof. Rendered as a note, never as verified identity."),
126
+ .describe(`File paths to BitGraph (absolute paths preferred), up to ${MAX_FILES}.`),
82
127
  again: z
83
128
  .boolean()
84
129
  .default(false)
85
- .describe("false (default): files already on record are returned as-is, nothing minted. true: record every file at a new causal position even if already on record. Positions are per unique file content: two paths with identical bytes yield one position."),
130
+ .describe("false (default): files already on record are returned as-is, nothing minted. true: make a new fused artifact from every file even if its bytes are already on record. Outcomes are per unique file content: two paths with identical bytes yield one artifact."),
86
131
  response_format: responseFormatSchema,
87
132
  },
88
133
  annotations: {
@@ -91,16 +136,16 @@ export function buildServer() {
91
136
  idempotentHint: false,
92
137
  openWorldHint: true,
93
138
  },
94
- }, async ({ paths, attribution, again, response_format }) => {
139
+ }, async ({ paths, again, response_format }) => {
95
140
  const config = configFromEnv();
96
141
  try {
97
- const digests = await hashPaths(paths);
98
- // Unique digests, first path wins for display; extra paths listed too.
142
+ const read = await readPaths(paths);
143
+ // Unique by content, first path wins for the artifact's name; extra paths listed too.
99
144
  const byDigest = new Map();
100
- digests.forEach((d, i) => {
101
- const list = byDigest.get(d) ?? [];
102
- list.push(paths[i]);
103
- byDigest.set(d, list);
145
+ read.forEach((r, i) => {
146
+ const entry = byDigest.get(r.digestB64) ?? { bytes: r.bytes, paths: [] };
147
+ entry.paths.push(paths[i]);
148
+ byDigest.set(r.digestB64, entry);
104
149
  });
105
150
  const unique = [...byDigest.keys()];
106
151
  const checked = await batchCheck(config, unique.map(toUrlSafeB64));
@@ -111,57 +156,48 @@ export function buildServer() {
111
156
  existing.set(d, entry.proofs);
112
157
  }
113
158
  const toMint = again ? unique : unique.filter((d) => !existing.has(d));
114
- let minted = [];
115
- let partial = null;
116
- if (toMint.length > 0) {
159
+ const fused = new Map();
160
+ const failed = new Map();
161
+ for (const d of toMint) {
162
+ const entry = byDigest.get(d);
163
+ const name = entry.paths[0].split(/[\\/]/).pop() ?? "file";
117
164
  try {
118
- minted = await commitDigests(config, toMint, attribution);
119
- // A 200 with fewer proofs than digests is still a partial failure;
120
- // never let it reach the success path looking complete.
121
- if (minted.length < toMint.length) {
122
- partial = new PartialCommitError(minted, toMint.length, new Error("commit returned fewer proofs than digests sent"));
123
- }
165
+ fused.set(d, await fuseFile(entry.bytes, name, config));
124
166
  }
125
167
  catch (err) {
126
- if (err instanceof PartialCommitError) {
127
- minted = err.minted;
128
- partial = err;
129
- }
130
- else {
131
- throw err;
132
- }
168
+ failed.set(d, err instanceof Error ? err.message : String(err));
133
169
  }
134
170
  }
135
- const mintedByDigest = new Map();
136
- for (const p of minted) {
137
- const d = p.artifact?.digestB64;
138
- if (d !== undefined)
139
- mintedByDigest.set(d, p);
140
- }
141
171
  const outcomes = [];
142
- for (const [digest, pathList] of byDigest) {
143
- const mintedProof = mintedByDigest.get(digest);
172
+ const frames = {};
173
+ for (const [digest, entry] of byDigest) {
174
+ const made = fused.get(digest);
144
175
  const prior = existing.get(digest);
145
- for (const path of pathList) {
146
- if (mintedProof) {
147
- const { counter, epoch } = positionOf(mintedProof);
176
+ for (const path of entry.paths) {
177
+ if (made) {
178
+ const { counter, epoch } = positionOf(made.proof);
179
+ frames[toUrlSafeB64(made.artifactDigestB64)] = made.frame;
148
180
  outcomes.push({
149
181
  path,
150
182
  digest: toUrlSafeB64(digest),
151
- outcome: "recorded",
183
+ outcome: "fused",
184
+ artifact_digest: toUrlSafeB64(made.artifactDigestB64),
185
+ placement: made.placement,
152
186
  counter,
153
187
  epoch,
154
188
  total_positions: (prior?.length ?? 0) + 1,
155
- proof_url: proofUrl(config.baseUrl, digest, counter ?? undefined, mintedProof.commit?.epochId),
189
+ proof_url: proofUrl(config.baseUrl, made.artifactDigestB64, counter ?? undefined, made.proof.commit?.epochId),
156
190
  });
157
191
  }
158
- else if (prior) {
192
+ else if (prior && !failed.has(digest)) {
159
193
  const first = prior[0]?.proof;
160
194
  const { counter, epoch } = first ? positionOf(first) : { counter: null, epoch: null };
161
195
  outcomes.push({
162
196
  path,
163
197
  digest: toUrlSafeB64(digest),
164
198
  outcome: "on record",
199
+ artifact_digest: null,
200
+ placement: null,
165
201
  counter,
166
202
  epoch,
167
203
  total_positions: prior.length,
@@ -169,50 +205,41 @@ export function buildServer() {
169
205
  });
170
206
  }
171
207
  else {
172
- // Neither minted nor previously on record: lost to a partial
173
- // failure. The honest outcome is "not recorded", never a claim.
174
208
  outcomes.push({
175
209
  path,
176
210
  digest: toUrlSafeB64(digest),
177
- outcome: "not recorded",
211
+ outcome: "not fused",
212
+ artifact_digest: null,
213
+ placement: null,
178
214
  counter: null,
179
215
  epoch: null,
180
- total_positions: 0,
216
+ total_positions: prior?.length ?? 0,
181
217
  proof_url: null,
218
+ error: failed.get(digest) ?? "not attempted",
182
219
  });
183
220
  }
184
221
  }
185
222
  }
186
223
  const structured = {
187
224
  results: outcomes,
225
+ frames,
188
226
  summary: {
189
- recorded: outcomes.filter((o) => o.outcome === "recorded").length,
227
+ fused: outcomes.filter((o) => o.outcome === "fused").length,
190
228
  on_record: outcomes.filter((o) => o.outcome === "on record").length,
191
- not_recorded: outcomes.filter((o) => o.outcome === "not recorded").length,
229
+ not_fused: outcomes.filter((o) => o.outcome === "not fused").length,
192
230
  },
193
231
  };
194
- if (partial) {
195
- const unrecorded = toMint.length - minted.length;
196
- const retryGuidance = again
197
- ? `Some 'not recorded' files MAY still have been recorded server-side if the failure was a timeout. Run bitgraph_check on the 'not recorded' paths first, then re-run bitgraph_record with again=true for only the paths still missing.`
198
- : `Re-run bitgraph_record with the same paths: already-recorded files will come back as 'on record' and only the missing ones will mint.`;
232
+ if (failed.size > 0) {
233
+ const guidance = again
234
+ ? "A file marked 'not fused' MAY still have been BitGraphed if the failure was a timeout: run bitgraph_check on it first, then re-run bitgraph_record with again=true for only the files still missing."
235
+ : "Re-run bitgraph_record with the same paths: files already on record come back as 'on record' and only the missing ones are BitGraphed.";
199
236
  return {
200
237
  isError: true,
201
- content: [
202
- {
203
- type: "text",
204
- text: `${errorText(partial.cause2)}\n` +
205
- `${minted.length} of ${toMint.length} digests were recorded before the failure (those recordings are permanent); ${unrecorded} were not. ` +
206
- `${retryGuidance}\n\n` +
207
- renderRecordMarkdown(outcomes),
208
- },
209
- ],
238
+ content: [{ type: "text", text: `${fused.size} of ${toMint.length} files were BitGraphed; ${failed.size} failed. ${guidance}\n\n${renderRecordMarkdown(outcomes)}` }],
210
239
  structuredContent: structured,
211
240
  };
212
241
  }
213
- const text = response_format === "json"
214
- ? capJson(structured).text
215
- : renderRecordMarkdown(outcomes);
242
+ const text = response_format === "json" ? capJson(structured).text : renderRecordMarkdown(outcomes);
216
243
  return ok(text, structured);
217
244
  }
218
245
  catch (err) {
@@ -223,8 +250,8 @@ export function buildServer() {
223
250
  title: "Check for BitGraphs",
224
251
  description: "Check whether files or digests are on record in the BitGraph ledger, without recording anything. " +
225
252
  "Accepts file paths (hashed locally; only digests are sent) and/or raw SHA-256 digests in standard or URL-safe base64. " +
226
- "Returns, per item: on record or not, every causal position (a file recorded more than once has several), and the proof page URL. " +
227
- "Read-only. Use bitgraph_record to record files that turn out not to be on record.",
253
+ "Returns, per item: on_record (a recording of the exact bytes exists), fused_descendants (fused artifacts that name the bytes as their origin), every position by counter, and the proof page URL. " +
254
+ "Read-only. Use bitgraph_record to BitGraph files that turn out not to be on record.",
228
255
  inputSchema: {
229
256
  paths: z
230
257
  .array(z.string().min(1))
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACd,MAAM,GACP,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,cAAc,EACd,eAAe,EACf,aAAa,EACb,aAAa,EACb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E,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;YACjF,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/B,OAAO,IAAI,CACT,6CAA6C,aAAa,2CAA2C,CACtG,CAAC;YACJ,CAAC;YAED,IAAI,eAAe,KAAK,MAAM,EAAE,CAAC;gBAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;gBAC/B,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAA4C,CAAC,CAAC;YACvE,CAAC;YACD,OAAO,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,MAA4C,CAAC,CAAC;QACvG,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikeargento/bitgraph-mcp",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server for BitGraph. Take a BitGraph of a file, check whether bytes are on record, and fetch proofs from any MCP client.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://bitgraph.ing",
@@ -38,7 +38,8 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@modelcontextprotocol/sdk": "^1.29.0",
41
- "zod": "^3.25.0"
41
+ "zod": "^3.25.0",
42
+ "@mikeargento/bitgraph": "^1.3.0"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@types/node": "^20.0.0",
@@ -30,14 +30,14 @@ test("record markdown mentions again=true only when something was already on rec
30
30
  total_positions: 1,
31
31
  proof_url: "https://bitgraph.ing/proof/x",
32
32
  };
33
- const fresh = renderRecordMarkdown([{ ...base, path: "/a", outcome: "recorded" }]);
33
+ const fresh = renderRecordMarkdown([{ ...base, path: "/a", outcome: "fused", artifact_digest: "ZnVzZWQ", placement: "container/1" }]);
34
34
  assert.ok(!fresh.includes("again=true"));
35
35
  const mixed = renderRecordMarkdown([
36
- { ...base, path: "/a", outcome: "recorded" },
37
- { ...base, path: "/b", outcome: "on record" },
36
+ { ...base, path: "/a", outcome: "fused", artifact_digest: "ZnVzZWQ", placement: "container/1" },
37
+ { ...base, path: "/b", outcome: "on record", artifact_digest: null, placement: null },
38
38
  ]);
39
39
  assert.ok(mixed.includes("again=true"));
40
- assert.ok(mixed.startsWith("1 recorded, 1 already on record."));
40
+ assert.ok(mixed.startsWith("1 fused, 1 already on record."));
41
41
  });
42
42
 
43
43
  test("proof markdown states the window as between lower and upper", () => {
@@ -15,7 +15,7 @@ import { tmpdir } from "node:os";
15
15
  import { join } from "node:path";
16
16
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
17
17
  import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
18
- import { buildServer } from "../server.js";
18
+ import { buildServer, type FusedSummary } from "../server.js";
19
19
  import { toUrlSafeB64 } from "../encoding.js";
20
20
 
21
21
  interface Recorded {
@@ -32,7 +32,6 @@ let fileB = "";
32
32
  let fileC = "";
33
33
  let digestA = ""; // standard b64 of fileA bytes
34
34
  let digestB = "";
35
- let commitMode: "ok" | "429" | "short" = "ok";
36
35
  const EPOCH = createHash("sha256").update("test-epoch").digest("base64");
37
36
  let mintCounter = 100;
38
37
 
@@ -90,17 +89,8 @@ before(async () => {
90
89
  }
91
90
  send(200, { results });
92
91
  } else if (url.pathname === "/api/commit") {
93
- if (commitMode === "429") {
94
- res.writeHead(429, { "Content-Type": "application/json", "Retry-After": "30" });
95
- res.end(JSON.stringify({ error: "Rate limit exceeded: per-client proof rate limit exceeded" }));
96
- return;
97
- }
98
- const digests = (body as { digests: Array<{ digestB64: string }> }).digests;
99
- if (commitMode === "short") {
100
- send(200, digests.slice(1).map((d) => proofFor(d.digestB64)));
101
- return;
102
- }
103
- send(200, digests.map((d) => proofFor(d.digestB64)));
92
+ // Ordinary recording is no longer what the record tool does; nothing here should call it.
93
+ send(500, { error: "unexpected /api/commit" });
104
94
  } else if (url.pathname.startsWith("/api/proofs/digest/")) {
105
95
  const digest = decodeURIComponent(url.pathname.split("/").pop() ?? "");
106
96
  if (digest === toUrlSafeB64(digestA)) {
@@ -143,8 +133,24 @@ after(() => {
143
133
  delete process.env["BITGRAPH_API_KEY"];
144
134
  });
145
135
 
136
+ /** A stand-in for the fuse pipeline: no slot, no enclave; records what it was asked to fuse. */
137
+ const fusedCalls: Array<{ name: string; digestB64: string }> = [];
138
+ let fuseMode: "ok" | "fail" = "ok";
139
+ async function fakeFuse(bytes: Uint8Array, name: string): Promise<FusedSummary> {
140
+ const digestB64 = createHash("sha256").update(bytes).digest("base64");
141
+ fusedCalls.push({ name, digestB64 });
142
+ if (fuseMode === "fail") throw new Error("the boundary is restarting");
143
+ const artifactDigestB64 = createHash("sha256").update("fused:" + digestB64).digest("base64");
144
+ return {
145
+ proof: proofFor(artifactDigestB64) as unknown as FusedSummary["proof"],
146
+ frame: { type: "bitgraph-fuse/1" },
147
+ placement: "container/1",
148
+ artifactDigestB64,
149
+ originDigestB64: digestB64,
150
+ };
151
+ }
146
152
  async function connectedClient(): Promise<Client> {
147
- const server = buildServer();
153
+ const server = buildServer({ fuseFile: fakeFuse });
148
154
  const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
149
155
  const client = new Client({ name: "test-client", version: "0.0.0" });
150
156
  await Promise.all([client.connect(clientTransport), server.connect(serverTransport)]);
@@ -158,56 +164,53 @@ test("lists the three tools", async () => {
158
164
  assert.deepEqual(names, ["bitgraph_check", "bitgraph_get_proof", "bitgraph_record"]);
159
165
  });
160
166
 
161
- test("record dedups on-record files and mints only fresh ones", async () => {
167
+ test("record dedups on-record files and fuses only fresh ones", async () => {
162
168
  const client = await connectedClient();
163
169
  requests.length = 0;
170
+ fusedCalls.length = 0;
164
171
  const result = await client.callTool({
165
172
  name: "bitgraph_record",
166
173
  arguments: { paths: [fileA, fileB] },
167
174
  });
168
175
  assert.ok(!result.isError, JSON.stringify(result.content));
169
-
170
- const commit = requests.find((r) => r.path === "/api/commit");
171
- if (!commit) throw new Error("no commit request was sent");
172
- const commitBody = commit.body as { digests: Array<{ digestB64: string; hashAlg: string }>; chainId: string };
173
- assert.equal(commitBody.chainId, "bitgraph:main");
174
- assert.deepEqual(commitBody.digests, [{ digestB64: digestB, hashAlg: "sha256" }], "only fileB minted, standard b64");
175
- assert.equal(commit.headers["authorization"], "Bearer test-key-123", "api key forwarded");
176
-
176
+ assert.equal(requests.filter((r) => r.path === "/api/commit").length, 0, "nothing is committed as bytes-only");
177
+ assert.deepEqual(fusedCalls.map((c) => c.digestB64), [digestB], "only fileB fused; fileA was on record");
178
+ assert.equal(fusedCalls[0]?.name, "b.txt", "the artifact is named after the file");
177
179
  const batch = requests.find((r) => r.path === "/api/proofs/batch");
178
- if (!batch) throw new Error("no batch check preceded the commit");
180
+ if (!batch) throw new Error("no batch check preceded the fuse");
179
181
  const batchBody = batch.body as { digests: string[] };
180
182
  assert.ok(batchBody.digests.every((d) => !d.includes("+") && !d.includes("=")), "check uses url-safe digests");
181
-
182
183
  const structured = result.structuredContent as {
183
- results: Array<{ path: string; outcome: string; counter: string | null }>;
184
- summary: { recorded: number; on_record: number };
184
+ results: Array<{ path: string; outcome: string; counter: string | null; placement: string | null; artifact_digest: string | null }>;
185
+ frames: Record<string, unknown>;
186
+ summary: { fused: number; on_record: number; not_fused: number };
185
187
  };
186
- assert.equal(structured.summary.recorded, 1);
188
+ assert.equal(structured.summary.fused, 1);
187
189
  assert.equal(structured.summary.on_record, 1);
190
+ assert.equal(structured.summary.not_fused, 0);
188
191
  const a = structured.results.find((r) => r.path === fileA);
189
192
  const b = structured.results.find((r) => r.path === fileB);
190
193
  assert.equal(a?.outcome, "on record");
191
194
  assert.equal(a?.counter, "10", "on-record outcome reports the EARLIEST position");
192
- assert.equal(b?.outcome, "recorded");
195
+ assert.equal(b?.outcome, "fused");
196
+ assert.equal(b?.placement, "container/1");
197
+ assert.ok(b?.artifact_digest && structured.frames[b.artifact_digest], "the Frame rides in the structured result under the fused digest");
193
198
  });
194
199
 
195
- test("record with again=true mints even on-record digests", async () => {
200
+ test("record with again=true fuses even on-record files", async () => {
196
201
  const client = await connectedClient();
197
- requests.length = 0;
202
+ fusedCalls.length = 0;
198
203
  const result = await client.callTool({
199
204
  name: "bitgraph_record",
200
205
  arguments: { paths: [fileA], again: true },
201
206
  });
202
207
  assert.ok(!result.isError, JSON.stringify(result.content));
203
- const commit = requests.find((r) => r.path === "/api/commit");
204
- const commitBody = commit?.body as { digests: Array<{ digestB64: string }> };
205
- assert.deepEqual(commitBody.digests.map((d) => d.digestB64), [digestA]);
208
+ assert.deepEqual(fusedCalls.map((c) => c.digestB64), [digestA]);
206
209
  const structured = result.structuredContent as {
207
210
  results: Array<{ outcome: string; total_positions: number }>;
208
211
  };
209
- assert.equal(structured.results[0]?.outcome, "recorded");
210
- assert.equal(structured.results[0]?.total_positions, 3, "two prior positions plus the new one");
212
+ assert.equal(structured.results[0]?.outcome, "fused");
213
+ assert.equal(structured.results[0]?.total_positions, 3, "two prior positions plus the new artifact");
211
214
  });
212
215
 
213
216
  test("check reports positions without ever committing", async () => {
@@ -274,49 +277,29 @@ test("get_proof requires exactly one selector", async () => {
274
277
  assert.ok(result.isError);
275
278
  });
276
279
 
277
- test("commit failure labels unminted files as 'not recorded', never 'on record'", async () => {
280
+ test("a fuse failure labels the file 'not fused', never 'on record'", async () => {
278
281
  const client = await connectedClient();
279
- commitMode = "429";
282
+ fuseMode = "fail";
280
283
  try {
281
284
  const result = await client.callTool({
282
285
  name: "bitgraph_record",
283
286
  arguments: { paths: [fileC] },
284
287
  });
285
- assert.ok(result.isError, "partial failure must be an error result");
288
+ assert.ok(result.isError, "a failure must be an error result");
286
289
  const text = (result.content as Array<{ text: string }>)[0]?.text ?? "";
287
- assert.ok(text.includes("Retry after 30 seconds"), text);
288
290
  assert.ok(text.includes("0 of 1"), text);
291
+ assert.ok(text.includes("the boundary is restarting"), text);
289
292
  const structured = result.structuredContent as {
290
- results: Array<{ outcome: string; proof_url: string | null; counter: string | null }>;
291
- summary: { recorded: number; on_record: number; not_recorded: number };
293
+ results: Array<{ outcome: string; proof_url: string | null; error?: string }>;
294
+ summary: { fused: number; on_record: number; not_fused: number };
292
295
  };
293
- assert.equal(structured.results[0]?.outcome, "not recorded");
296
+ assert.equal(structured.results[0]?.outcome, "not fused");
294
297
  assert.equal(structured.results[0]?.proof_url, null);
295
- assert.equal(structured.summary.not_recorded, 1);
296
- assert.equal(structured.summary.recorded, 0);
298
+ assert.equal(structured.summary.not_fused, 1);
299
+ assert.equal(structured.summary.fused, 0);
297
300
  assert.equal(structured.summary.on_record, 0);
298
301
  } finally {
299
- commitMode = "ok";
300
- }
301
- });
302
-
303
- test("a 200 with fewer proofs than digests is treated as a partial failure", async () => {
304
- const client = await connectedClient();
305
- commitMode = "short";
306
- try {
307
- const result = await client.callTool({
308
- name: "bitgraph_record",
309
- arguments: { paths: [fileC] },
310
- });
311
- assert.ok(result.isError, "shortfall must not reach the success path");
312
- const structured = result.structuredContent as {
313
- results: Array<{ outcome: string }>;
314
- };
315
- assert.equal(structured.results[0]?.outcome, "not recorded");
316
- const text = (result.content as Array<{ text: string }>)[0]?.text ?? "";
317
- assert.ok(text.includes("fewer proofs than digests"), text);
318
- } finally {
319
- commitMode = "ok";
302
+ fuseMode = "ok";
320
303
  }
321
304
  });
322
305
 
@@ -330,5 +313,5 @@ test("record surfaces unreadable paths before any network call", async () => {
330
313
  assert.ok(result.isError);
331
314
  assert.equal(requests.length, 0, "no API call happened; nothing was minted");
332
315
  const text = (result.content as Array<{ text: string }>)[0]?.text ?? "";
333
- assert.ok(text.includes("nothing was recorded"));
316
+ assert.ok(text.includes("nothing was BitGraphed"));
334
317
  });