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-pages.test.ts --json
JSON
/christopher/abso-core/blame/src/engine/test/graph-atom-list-pages.test.ts?format=json
71 linescapacity 100%Last change capacity in version 239,

71 lines from 1 change in 1 version.

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.Compare1// An atom's long lists (abso Capacity, readonlyPagedArray): a new atom keeps them 256 values to a row (list format 2),
2// and an atom stored before keeps a row per value (list format 1). Both read back whole, in order and by index.
3
4import assert from "node:assert/strict";
5import { test } from "node:test";
6import { buildBase, Graph } from "../index.ts";
7import { lineKey } from "../keys.ts";
8import { storedArray } from "../state-source.ts";
9import type { Atom } from "../types.ts";
10import { SqlState } from "./storage-helper.ts";
12function listAtom(keys: string[]): Atom {
13 return {
14 id: "a1",
15 seq: 1,
16 author: "fixture",
17 message: "lists",
18 time: 1,
19 inserts: [],
20 deletes: [],
21 writes: keys,
22 reads: [],
23 holds: [],
24 needs: [],
25 resolves: [],
26 reasons: [],
27 deps: ["a0"],
28 };
31const keys = Array.from({ length: 600 }, () => lineKey("a0.0"));
33test("a new atom's long list is kept 256 values to a row and reads back whole", () => {
34 const storage = new SqlState();
35 try {
36 const graph = new Graph({ storage });
37 graph.add(buildBase({ "a.txt": "base" }, { author: "fixture", message: "base", time: 0 }));
38 graph.add(listAtom(keys));
39 assert.equal((storage.read("atoms", "1") as { listFormat?: number }).listFormat, 2);
40 assert.equal((storage.read("atom-list:1:writes:pages", "2") as unknown[]).length, 600 - 512);
41 assert.equal(storage.read("atom-list:1:writes", "0"), undefined, "no row per value");
42 const writes = new Graph({ storage }).atom("a1").writes;
43 assert.deepEqual([...writes], keys);
44 assert.equal(writes.length, 600);
45 assert.equal(writes[300], keys[300]);
46 assert.equal(writes[600], undefined);
47 } finally {
48 storage.db.close();
49 }
50});
52test("an atom stored before pages, a row per value, still reads back whole", () => {
53 const storage = new SqlState();
54 try {
55 const graph = new Graph({ storage });
56 graph.add(buildBase({ "a.txt": "base" }, { author: "fixture", message: "base", time: 0 }));
57 graph.add(listAtom(keys));
58 // Rewrite it as list format 1 kept it: a row per value and no pages.
59 const record = storage.read("atoms", "1") as Record<string, unknown>;
60 for (let page = 0; page < 3; page++) storage.remove("atom-list:1:writes:pages", String(page));
61 storage.remove("atom-list:1:writes:meta", "length");
62 const rows = storedArray<string>(storage, "atom-list:1:writes");
63 for (const key of keys) rows.push(key);
64 storage.write("atoms", "1", { ...record, listFormat: 1 });
65 const writes = new Graph({ storage }).atom("a1").writes;
66 assert.deepEqual([...writes], keys);
67 assert.equal(writes[599], keys[599]);
68 } finally {
69 storage.db.close();
70 }
71});