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 146 to 147

Compare

+56 −0 in 1 place
Lines 47–105 at 147 (were 47–49 at 146)
4747 storage.db.close();
4848 }
4949});
51+test("bounded locator batches preserve old roots, discard intermediate pages, and roll back writes", () => {
52+ const db = new SqlState();
53+ try {
54+ const index = new ProjectionLocator(db, "batch", decode);
55+ const old = index.set(null, 0, 1);
56+ const values = Array.from({ length: 64 }, (_, i) => [i, i + 10] as const);
57+ const before = db.writes;
58+ const root = index.setMany(old, values);
59+ const batchWrites = db.writes - before;
60+ assert.equal(index.get(old, 0), 1);
61+ for (const [id, value] of values) assert.equal(index.get(root, id), value);
62+ const plain = new ProjectionLocator(db, "plain", decode);
63+ let sequential: number | null = plain.set(null, 0, 1);
64+ const baseline = db.writes;
65+ for (const [id, value] of values) sequential = plain.set(sequential, id, value);
66+ assert.ok(batchWrites < (db.writes - baseline) / 2);
67+ const rows = db.db.prepare("SELECT * FROM state ORDER BY collection,key").all();
68+ // Fail every persisted page and the final allocation-counter write.
69+ for (let offset = 1; offset <= batchWrites; offset++) {
70+ db.failWrite = db.writes + offset;
71+ assert.throws(() => index.setMany(old, values), /injected/);
72+ assert.deepEqual(db.db.prepare("SELECT * FROM state ORDER BY collection,key").all(), rows);
73+ }
74+ db.failWrite = Infinity;
75+ assert.throws(
76+ () =>
77+ index.setMany(
78+ root,
79+ Array.from({ length: 257 }, () => [0, 1] as const),
80+ ),
81+ /batch limit/,
82+ );
83+ assert.equal(index.setMany(root, []), root);
84+ const duplicate = index.setMany(root, [
85+ [0, 100],
86+ [0, 200],
87+ [0xffffffff, 300],
88+ ]);
89+ assert.equal(index.get(duplicate, 0), 200);
90+ assert.equal(index.get(duplicate, 0xffffffff), 300);
91+ assert.equal(index.get(root, 0), 10);
92+ const stable = db.db.prepare("SELECT * FROM state ORDER BY collection,key").all();
93+ assert.throws(
94+ () =>
95+ index.setMany(duplicate, [
96+ [1, 3],
97+ [2 ** 32, 4],
98+ ]),
99+ /identity limit/,
100+ );
101+ assert.deepEqual(db.db.prepare("SELECT * FROM state ORDER BY collection,key").all(), stable);
102+ } finally {
103+ db.db.close();
104+ }
105+});
MCP
compare on this site's /mcp
CLI
abso diff 146 147 src/engine/test/projection-locator.test.ts --json
JSON
/christopher/abso-core/compare/146..147?file=src%2Fengine%2Ftest%2Fprojection-locator.test.ts&format=json