{"file":"src/engine/test/graph-atom-list-rollback.test.ts","version":318,"total":46,"from":1,"to":46,"lines":[{"n":1,"text":"import assert from \"node:assert/strict\";","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":2,"text":"import { test } from \"node:test\";","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":3,"text":"import { buildBase, Graph } from \"../index.ts\";","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":4,"text":"import { lineKey } from \"../keys.ts\";","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":5,"text":"import type { Atom } from \"../types.ts\";","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":6,"text":"import { SqlState } from \"./storage-helper.ts\";","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":7,"text":"","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":8,"text":"test(\"partial atom-list persistence rolls back and retries on the same graph\", () => {","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":9,"text":"\tconst storage = new SqlState();","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":10,"text":"\ttry {","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":11,"text":"\t\tconst graph = new Graph({ storage });","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":12,"text":"\t\tgraph.add(buildBase({ \"a.txt\": \"base\" }, { author: \"fixture\", message: \"base\", time: 0 }));","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":13,"text":"\t\tconst keys = Array.from({ length: 257 }, () => lineKey(\"a0.0\"));","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":14,"text":"\t\tconst atom: Atom = {","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":15,"text":"\t\t\tid: \"a1\",","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":16,"text":"\t\t\tseq: 1,","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":17,"text":"\t\t\tauthor: \"fixture\",","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":18,"text":"\t\t\tmessage: \"lists\",","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":19,"text":"\t\t\ttime: 1,","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":20,"text":"\t\t\tinserts: [],","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":21,"text":"\t\t\tdeletes: [],","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":22,"text":"\t\t\twrites: keys,","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":23,"text":"\t\t\treads: [],","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":24,"text":"\t\t\tholds: [],","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":25,"text":"\t\t\tneeds: [],","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":26,"text":"\t\t\tresolves: [],","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":27,"text":"\t\t\treasons: [],","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":28,"text":"\t\t\tdeps: [\"a0\"],","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":29,"text":"\t\t};","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":30,"text":"\t\tconst before = storage.db.prepare(\"SELECT * FROM state ORDER BY collection,key\").all();","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":31,"text":"\t\tconst write = storage.write.bind(storage);","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":32,"text":"\t\tstorage.write = (collection, key, value) => {","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":33,"text":"\t\t\twrite(collection, key, value);","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":34,"text":"\t\t\t// Partway through: the second of the list's two pages (256 values to a page).","atom":"a2469","author":"capacity","version":239},{"n":35,"text":"\t\t\tif (collection === \"atom-list:1:writes:pages\" && key === \"1\") throw Error(\"injected list persistence failure\");","atom":"a2469","author":"capacity","version":239},{"n":36,"text":"\t\t};","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":37,"text":"\t\tassert.throws(() => graph.add(atom), /injected list persistence failure/);","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":38,"text":"\t\tassert.deepEqual(storage.db.prepare(\"SELECT * FROM state ORDER BY collection,key\").all(), before);","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":39,"text":"\t\tassert.equal(graph.size, 1);","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":40,"text":"\t\tstorage.write = write;","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":41,"text":"\t\tgraph.add(atom);","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":42,"text":"\t\tassert.deepEqual([...new Graph({ storage }).atom(\"a1\").writes], keys);","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":43,"text":"\t} finally {","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":44,"text":"\t\tstorage.db.close();","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":45,"text":"\t}","atom":"a1702","author":"codex-capacity-chair","version":162},{"n":46,"text":"});","atom":"a1702","author":"codex-capacity-chair","version":162}],"atoms":[{"atom":"a1702","author":"codex-capacity-chair","message":"","time":1791944420248,"timeIso":"2026-10-14T02:20:20.248Z","publish":{"draft":null,"version":162,"agent":"codex-capacity-chair","message":"Add reviewed disk-first history and indexed graph storage for core issue 16; retain runtime activation gate","time":1791945013341,"timeIso":"2026-10-14T02:30:13.341Z"}},{"atom":"a2469","author":"capacity","message":"","time":1792066098920,"timeIso":"2026-10-15T12:08:18.920Z","publish":{"draft":null,"version":239,"agent":"capacity","message":"An atom's long lists kept 256 values to a row (list format 2; disk-first 2; abso Capacity).\n\nCollisions 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).\n\n- 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.\n- 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.\n\nOn 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.\n\nTests: 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.","time":1792066099506,"timeIso":"2026-10-15T12:08:19.506Z"}}]}