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
blame on this site's /mcp
CLI
abso blame src/engine/test/graph-atom-list-rollback.test.ts --json
JSON
/christopher/abso-core/blame/src/engine/test/graph-atom-list-rollback.test.ts?format=json
46 linescodex-capacity-chair 96% · capacity 4%Last change capacity in version 239,

46 lines from 2 changes in 2 versions.

codex-capacity-chair162Add reviewed disk-first history and indexed graph storage for core issue 16; retain runtime activation gateCompare1import 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);
capacity239An atom's long lists kept 256 values to a row (list format 2; disk-first 2; abso Capacity). Collisions reads every key each draft atom writes. An atom's lists over 256 values were stored a row per value (readonlyStoredArray). On website, collisions read 75,000 of those rows (a draft deleting a big file has thousands of keys). - New atoms store such lists 256 values to a row (writePagedArray) and mark it listFormat 2. readonlyPagedArray reads them a page at a time, in order or by index. - An atom stored before keeps listFormat 1 and its row per value, and reads as before. The format is per atom record, so old and new atoms sit side by side. Only atoms stored from this version on, or a fresh adoption, get pages. On website adopted fresh, cold, one opened writer: collisions 9.6 s to 4.7 s (79,000 reads to 3,900), matching replay (0.4 s). Adoption took 87 s instead of 119 s. Tests: graph-atom-list-pages (new: a new atom's list is paged and reads whole; an atom rewritten as list format 1 reads whole). graph-atom-list-rollback now injects its failure on the list's second page. Every engine test (290 of 290), every worker/project test (341 of 341); tsc and biome clean.Compare34 // 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");
codex-capacity-chair162Add reviewed disk-first history and indexed graph storage for core issue 16; retain runtime activation gateCompare36 };
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});