Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
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?format=json
46 linescodex-capacity-chair 96% · capacity 4%Last change capacity in version 239, 2 versions changed it
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";
7
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 // Partway through: the second of the list's two pages (256 values to a page).
35 if (collection === "atom-list:1:writes:pages" && key === "1") throw Error("injected list persistence failure");
36 };
37 assert.throws(() => graph.add(atom), /injected list persistence failure/);
38 assert.deepEqual(storage.db.prepare("SELECT * FROM state ORDER BY collection,key").all(), before);
39 assert.equal(graph.size, 1);
40 storage.write = write;
41 graph.add(atom);
42 assert.deepEqual([...new Graph({ storage }).atom("a1").writes], keys);
43 } finally {
44 storage.db.close();
45 }
46});