- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/src/engine/test/graph-atom-list-rollback.test.ts?version=182&format=json
45 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 162, 1 version changed it
You're reading version 182. The newest is 318, and 1 version since then changed this file.
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { buildBase, Graph } from "../index.ts";
4import { lineKey } from "../keys.ts";
5import type { Atom } from "../types.ts";
6import { SqlState } from "./storage-helper.ts";
8test("partial atom-list persistence rolls back and retries on the same graph", () => {
9 const storage = new SqlState();
10 try {
11 const graph = new Graph({ storage });
12 graph.add(buildBase({ "a.txt": "base" }, { author: "fixture", message: "base", time: 0 }));
13 const keys = Array.from({ length: 257 }, () => lineKey("a0.0"));
14 const atom: Atom = {
15 id: "a1",
16 seq: 1,
17 author: "fixture",
18 message: "lists",
19 time: 1,
20 inserts: [],
21 deletes: [],
22 writes: keys,
23 reads: [],
24 holds: [],
25 needs: [],
26 resolves: [],
27 reasons: [],
28 deps: ["a0"],
29 };
30 const before = storage.db.prepare("SELECT * FROM state ORDER BY collection,key").all();
31 const write = storage.write.bind(storage);
32 storage.write = (collection, key, value) => {
33 write(collection, key, value);
34 if (collection === "atom-list:1:writes" && key === "128") throw Error("injected list persistence failure");
35 };
36 assert.throws(() => graph.add(atom), /injected list persistence failure/);
37 assert.deepEqual(storage.db.prepare("SELECT * FROM state ORDER BY collection,key").all(), before);
38 assert.equal(graph.size, 1);
39 storage.write = write;
40 graph.add(atom);
41 assert.deepEqual([...new Graph({ storage }).atom("a1").writes], keys);
42 } finally {
43 storage.db.close();
44 }
45});