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
show on this site's /mcp
CLI
abso show 230 --json
JSON
/christopher/abso-core/versions/230?format=json

Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity).

of shared·capacity··Not checked

On website, with one opened writer, tree with authors took 9.6 s, tree for an agent with authors 9.1 s, and a folder's blame 4.9 s. Replay takes about 0.25 s. Few row reads: the time went on reading the same few large atoms again and again.

  • tree with authors, a folder's blame and a file's blame look up each atom's author once per call. graph.atom read and parsed the whole atom for every line, and most lines share a few big atoms.
  • The packed layout keeps each visible line's writer (visWriter), and lines() and buildLines use it instead of looking each line's writer up again.
  • The packed layout reads each atom's lamport number once per layout instead of once per line.

On website adopted fresh, cold: tree with authors 3.2 s, tree for an agent with authors 4.5 s, a folder's blame 2.4 s; all seven tree and blame answers match replay.

New test authors-stored: tree with authors (head, an older version, an agent's draft, a folder), folder blame and file blame on a writer-backed project answer as the in-memory one; it fails when the layout records the wrong writer. Named tests: every engine test (288 of 288), authors-stored, history, trail, draft-reads-stored, packed-crossings, version-files, files-reads, view-cache, membership-pages, project (54 of 54); tsc and biome clean.

Version 229 · Files at version 230

4 files, 125 lines added, 13 removed.

--- a/src/engine/view.ts
+++ b/src/engine/view.ts
@@ -69,6 +69,8 @@
6969 readonly deletedBy: ReadonlyMap<number, readonly number[]>;
7070 /** Its visible lines' text, when laid out from the file's packed history: null for a line too long to pack. */
7171 readonly visText?: readonly (string | null)[];
72+ /** Its visible lines' writers' seqs, when laid out from the file's packed history. */
73+ readonly visWriter?: Int32Array;
7274 /** Positions by n, built the first time they're asked for. */
7375 seqIndex?: Map<number, number>;
7476 visIndex?: Map<number, number>;
@@ -645,7 +647,18 @@
645647 const files = new Set<number>([-1 - start, ...(this.#movedInFrom().get(path) ?? [])]);
646648 const children = new Map<number, Child[]>();
647649 const texts = new Map<number, string | null>();
650+ const writers = new Map<number, number>();
648651 const deleters = new Map<number, number[]>();
652+ // Each atom's lamport once per layout: most lines share a few atoms, and a stored graph reads it from a page.
653+ const lamports = new Map<number, number>();
654+ const lamportOf = (seq: number): number => {
655+ let lamport = lamports.get(seq);
656+ if (lamport === undefined) {
657+ lamport = graph.lamportOfSeq(seq);
658+ lamports.set(seq, lamport);
659+ }
660+ return lamport;
661+ };
649662 for (const file of files) {
650663 const lineTexts = graph.packedTexts(file);
651664 for (const [n, parent, seq, k, replaces] of graph.packedLines(file)) {
@@ -653,16 +666,17 @@
653666 if (!this.#has(seq)) continue;
654667 const moved = relocs?.get(n);
655668 let at = parent;
656− let child: Child = { n, replaces, lamport: graph.lamportOfSeq(seq), seq, k };
669+ let child: Child = { n, replaces, lamport: lamportOf(seq), seq, k };
657670 if (moved) {
658671 const mover = graph.atom(moved.r.atom).seq;
659− child = { n, replaces: 0, lamport: graph.lamportOfSeq(mover), seq: mover, k: moved.r.k };
672+ child = { n, replaces: 0, lamport: lamportOf(mover), seq: mover, k: moved.r.k };
660673 at = moved.parent;
661674 }
662675 const list = children.get(at);
663676 if (list) list.push(child);
664677 else children.set(at, [child]);
665678 texts.set(n, text);
679+ writers.set(n, seq);
666680 }
667681 for (const [n, deleter] of graph.packedDeletes(file)) {
668682 if (!this.#has(deleter)) continue;
@@ -675,10 +689,11 @@
675689 }
676690 const order = (a: Child, b: Child) =>
677691 b.replaces - a.replaces || b.lamport - a.lamport || b.seq - a.seq || a.k - b.k;
678− const priority = (a: number, b: number) => graph.lamportOfSeq(a) - graph.lamportOfSeq(b) || a - b;
692+ const priority = (a: number, b: number) => lamportOf(a) - lamportOf(b) || a - b;
679693 const seq: number[] = [];
680694 const vis: number[] = [];
681695 const visText: (string | null)[] = [];
696+ const visWriter: number[] = [];
682697 const deletedBy = new Map<number, readonly number[]>();
683698 const stack: number[] = [];
684699 const push = (code: number) => {
@@ -696,11 +711,20 @@
696711 } else {
697712 vis.push(n);
698713 visText.push(texts.get(n) ?? null);
714+ visWriter.push(writers.get(n)!);
699715 }
700716 if (complete) seq.push(n);
701717 push(n);
702718 }
703− return { attrs, complete, seq: Int32Array.from(seq), vis: Int32Array.from(vis), deletedBy, visText };
719+ return {
720+ attrs,
721+ complete,
722+ seq: Int32Array.from(seq),
723+ vis: Int32Array.from(vis),
724+ deletedBy,
725+ visText,
726+ visWriter: Int32Array.from(visWriter),
727+ };
704728 }
705729
706730 #attributes(path: string): FileAttrs {
@@ -859,8 +883,8 @@
859883 /** Atom-building line handles; text is loaded only when requested. */
860884 buildLines(path: string): readonly VisibleLine[] {
861885 const graph = this.graph;
862− // Texts the packed layout already holds are not read again (abso Capacity).
863− const { vis, visText } = this.#file(path);
886+ // Texts and writers the packed layout already holds are not read again (abso Capacity).
887+ const { vis, visText, visWriter } = this.#file(path);
864888 const lines: VisibleLine[] = new Array(vis.length);
865889 for (let i = 0; i < vis.length; i++) {
866890 const n = vis[i]!;
@@ -871,7 +895,7 @@
871895 get text() {
872896 return packed ?? graph.textOf(n);
873897 },
874− atom: graph.idOfSeq(graph.writerSeqOf(n)),
898+ atom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
875899 };
876900 }
877901 return lines;
@@ -881,14 +905,14 @@
881905 lines(path: string): readonly VisibleLine[] {
882906 if (this.#linesCache?.path === path) return this.#linesCache.lines;
883907 const graph = this.graph;
884− const { vis, visText } = this.#file(path);
908+ const { vis, visText, visWriter } = this.#file(path);
885909 const lines: VisibleLine[] = new Array(vis.length);
886910 for (let i = 0; i < vis.length; i++) {
887911 const n = vis[i]!;
888912 lines[i] = {
889913 id: graph.lineIdOf(n),
890914 text: visText?.[i] ?? graph.textOf(n),
891− atom: graph.idOfSeq(graph.writerSeqOf(n)),
915+ atom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
892916 };
893917 }
894918 this.#linesCache = { path, lines };
@@ -1025,6 +1049,7 @@
10251049 n += OBJECT_BYTES + OBJECT_BYTES + 2 * ARRAY_HEADER_BYTES;
10261050 n += f.seq.byteLength + f.vis.byteLength;
10271051 if (f.visText) for (const text of f.visText) n += REFERENCE_BYTES + 2 * (text?.length ?? 0);
1052+ if (f.visWriter) n += 4 * f.visWriter.length;
10281053 n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + ARRAY_HEADER_BYTES) * f.deletedBy.size;
10291054 for (const deleters of f.deletedBy.values()) n += REFERENCE_BYTES * deleters.length;
10301055 if (f.seqIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.seqIndex.size;
--- a/worker/project/blame.ts
+++ b/worker/project/blame.ts
@@ -91,11 +91,21 @@
9191 const first = Math.max(1, from ?? 1);
9292 const last = Math.min(all.length, to ?? all.length);
9393 const graph = project.graph;
94+ // Each atom's author once (abso Capacity): on a stored writer, graph.atom reads and parses the whole atom, and
95+ // most lines share a few big atoms.
96+ const authors = new Map<AtomId, string>();
97+ const authorOf = (id: AtomId): string => {
98+ const known = authors.get(id);
99+ if (known !== undefined) return known;
100+ const author = graph.atom(id).author;
101+ authors.set(id, author);
102+ return author;
103+ };
94104 const rows: BlameLine[] = all.slice(first - 1, last).map((l, i) => ({
95105 n: first + i,
96106 text: l.text,
97107 atom: l.atom,
98− author: graph.atom(l.atom).author,
108+ author: authorOf(l.atom),
99109 version: project.versionOf(l.atom) ?? null,
100110 ...(project.publishOf(l.atom) === undefined ? { unpublished: true as const } : {}),
101111 }));
@@ -380,6 +390,16 @@
380390 const key = pathKey(want.join("/"));
381391 const graph = project.graph;
382392 const counts = new Map<string, number>();
393+ // Each atom's author once (abso Capacity): on a stored writer, graph.atom reads and parses the whole atom, and
394+ // most lines share a few big atoms.
395+ const authors = new Map<AtomId, string>();
396+ const authorOf = (id: AtomId): string => {
397+ const known = authors.get(id);
398+ if (known !== undefined) return known;
399+ const author = graph.atom(id).author;
400+ authors.set(id, author);
401+ return author;
402+ };
383403 let files = 0;
384404 let total = 0;
385405 let stored: string | undefined;
@@ -390,7 +410,7 @@
390410 stored ??= parts.slice(0, want.length).join("/");
391411 files++;
392412 for (const l of view.lines(path)) {
393− const author = graph.atom(l.atom).author;
413+ const author = authorOf(l.atom);
394414 counts.set(author, (counts.get(author) ?? 0) + 1);
395415 total++;
396416 }
--- a/worker/project/history.ts
+++ b/worker/project/history.ts
@@ -2,7 +2,7 @@
22// (pathLife), and where lines went (follow). They read through HistoryHost, the one seam the derived tables
33// (abso issues 48 and 79) plug into: today the host is the project in memory.
44
5−import type { Graph, LineId, ReadView } from "../../src/engine/index.ts";
5+import type { AtomId, Graph, LineId, ReadView } from "../../src/engine/index.ts";
66import { pathKey } from "./pathkey.ts";
77import { checkReadPath, differs, type LastChange, ProjectError, utf8Bytes } from "./project.ts";
88import { last, SHARED, type Space } from "./spaces.ts";
@@ -121,6 +121,16 @@
121121 return e;
122122 };
123123 const paths = (agent ? undefined : h.keptPaths?.(space, version)) ?? view.paths();
124+ // Each atom's author once (abso Capacity): on a stored writer, graph.atom reads and parses the whole atom, and
125+ // most lines share a few big atoms.
126+ const authors = new Map<AtomId, string>();
127+ const authorOf = (id: AtomId): string => {
128+ const known = authors.get(id);
129+ if (known !== undefined) return known;
130+ const author = graph.atom(id).author;
131+ authors.set(id, author);
132+ return author;
133+ };
124134 for (const path of paths) {
125135 const e = entryOf(path);
126136 if (!e) continue;
@@ -131,7 +141,7 @@
131141 if (options.authors) {
132142 const counts = (e.authors ??= new Map());
133143 for (const l of view.lines(path)) {
134− const author = graph.atom(l.atom).author;
144+ const author = authorOf(l.atom);
135145 counts.set(author, (counts.get(author) ?? 0) + 1);
136146 }
137147 const blob = view.attrs(path).blob;
--- /dev/null
+++ b/worker/project/test/authors-stored.test.ts
@@ -0,0 +1,57 @@
1+// Who wrote what, on a writer-backed project (abso Capacity): tree with authors, a folder's blame and a file's blame
2+// take each line's writer from the packed layout and each atom's author once. They must answer as the in-memory
3+// project does, at the head, at an older version and in an agent's draft.
4+
5+import assert from "node:assert/strict";
6+import { test } from "node:test";
7+import { storedArray } from "../../../src/engine/state-source.ts";
8+import { SqlState } from "../../../src/engine/test/storage-helper.ts";
9+import { blame, folderBlame } from "../blame.ts";
10+import { MemoryStore, Project } from "../project.ts";
11+import type { Entry, ProjectStore } from "../project-types.ts";
13+function writer() {
14+ const storage = new SqlState();
15+ const entries = storedArray<Entry>(storage, "canonical-log");
16+ const store: ProjectStore = {
17+ append(batch) {
18+ for (const entry of batch) entries.push(entry);
19+ },
20+ };
21+ return new Project(store, { writerStorage: storage });
22+}
24+function history(project: Project) {
25+ let t = 0;
26+ project.init({ "src/a.ts": "one\ntwo\nthree\n", "src/b.ts": "b\n", "README.md": "readme\n" }, t);
27+ project.record("ann", { "src/a.ts": "one\nTWO\nthree\nfour\n" }, ++t);
28+ assert.equal(project.publish("ann", "Ann's lines", ++t).ok, true);
29+ project.sync("bob");
30+ project.record("bob", { "src/b.ts": "b\nbob's\n", "src/c.ts": "new\n" }, ++t);
31+ assert.equal(project.publish("bob", "Bob's lines", ++t).ok, true);
32+ project.sync("cy");
33+ project.record("cy", { "src/a.ts": "one\nTWO\nthree\nfour\nfive\n" }, ++t);
34+}
36+test("tree with authors and blame read the same from disk as from memory", () => {
37+ const oracle = new Project(new MemoryStore());
38+ const project = writer();
39+ history(oracle);
40+ history(project);
41+ for (const options of [{ authors: true }, { authors: true, version: 1 }, { authors: true, agent: "cy" }])
42+ assert.deepEqual(project.tree("", options), oracle.tree("", options), JSON.stringify(options));
43+ assert.deepEqual(project.tree("src", { authors: true }), oracle.tree("src", { authors: true }));
44+ for (const [folder, version, where] of [
45+ ["", undefined, {}],
46+ ["src", 1, {}],
47+ ["src", undefined, { agent: "cy" }],
48+ ] as const)
49+ assert.deepEqual(folderBlame(project, folder, version, where), folderBlame(oracle, folder, version, where));
50+ assert.deepEqual(blame(project, "src/a.ts"), blame(oracle, "src/a.ts"));
51+ assert.deepEqual(
52+ blame(project, "src/a.ts", undefined, undefined, undefined, { agent: "cy" }),
53+ blame(oracle, "src/a.ts", undefined, undefined, undefined, { agent: "cy" }),
54+ );
55+ const authors = oracle.tree("", { authors: true }).entries.find((e) => e.name === "src")?.authors ?? [];
56+ assert.ok(authors.length >= 2, "more than one author wrote src");
57+});