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

Versions 3 to 318

Compare

+54 −0 in 1 place
new file, 54 lines
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import { buildBase, Graph } from "../index.ts";
4+import { lineKey } from "../keys.ts";
5+import type { Atom, LineId } from "../types.ts";
6+import { SqlState } from "./storage-helper.ts";
7+
8+test("deletion page failure rolls back acceptance and missing pages fail after reopen", () => {
9+ const storage = new SqlState();
10+ try {
11+ const graph = new Graph({ storage });
12+ graph.add(
13+ buildBase(
14+ { "a.txt": Array.from({ length: 300 }, (_, i) => `line ${i}`).join("\n") },
15+ { author: "fixture", message: "base", time: 0 },
16+ ),
17+ );
18+ const deletes = Array.from({ length: 300 }, (_, i) => `a0.${i}` as LineId);
19+ const atom: Atom = {
20+ id: "a1",
21+ seq: 1,
22+ author: "fixture",
23+ message: "delete",
24+ time: 1,
25+ inserts: [],
26+ deletes,
27+ writes: deletes.map(lineKey),
28+ reads: [],
29+ holds: [],
30+ needs: [],
31+ resolves: [],
32+ reasons: [],
33+ deps: ["a0"],
34+ };
35+ const before = storage.db.prepare("SELECT * FROM state ORDER BY collection,key").all();
36+ const write = storage.write.bind(storage);
37+ storage.write = (collection, key, value) => {
38+ write(collection, key, value);
39+ if (collection === "atom-deletes:pages" && key === JSON.stringify(["1", 1]))
40+ throw Error("injected deletion page failure");
41+ };
42+ assert.throws(() => graph.add(atom), /injected deletion page failure/);
43+ assert.deepEqual(storage.db.prepare("SELECT * FROM state ORDER BY collection,key").all(), before);
44+ assert.equal(graph.size, 1);
45+ storage.write = write;
46+ graph.add(atom);
47+ assert.equal(new Graph({ storage }).deleteCount("a1"), 300);
48+ assert.deepEqual(new Graph({ storage }).deletedLines("a1"), deletes);
49+ storage.remove("atom-deletes:pages", JSON.stringify(["1", 1]));
50+ assert.throws(() => new Graph({ storage }).deletedLines("a1"), /missing or invalid writer list page/);
51+ } finally {
52+ storage.db.close();
53+ }
54+});
MCP
compare on this site's /mcp
CLI
abso diff 3 318 src/engine/test/graph-deletion-rollback.test.ts --json
JSON
/christopher/abso-core/compare/3..318?file=src%2Fengine%2Ftest%2Fgraph-deletion-rollback.test.ts&format=json