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 229 --json
JSON
/christopher/abso-core/versions/229?format=json

Draft collisions without copying shared's atoms per pair (disk-first 2; abso Capacity).

of shared·capacity··Not checked

On typescript-rs, with one opened writer, collisions ran past 5 minutes with 2.5 million row reads; replay takes 5 s.

  • Each pair of agents built a new set of all of shared's atoms plus both drafts, and each agent's view of shared-now did the same. On a stored writer that read every one of shared's atoms, per pair, and the view then proved the copy closed by walking it. The pair's set is now a lookup over shared's own atoms and the two drafts (same membership as before). The views are built over shared's view's own closed set plus the drafts, which closes to the same atoms and walks only the drafts.
  • View.lines and buildLines use the texts the packed layout already holds, instead of reading each line's text again.
  • The definition rule takes a line's atom and place from its id, and collisions use graph.lineAtom; graph.line read each line's text as well.

On typescript-rs adopted fresh, cold: collisions finishes in 71 s with 299,000 reads, matching replay. Still slow: most of what's left is laying the same files out again for each agent's view.

Named tests: every engine test (288 of 288), changed-definition, collision-streaming, definition-code, definitions, draft-reads-stored, same-line, spelling-clash, review-fixes, membership-pages, stored-closure, packed-crossings, project-writer-storage, writer-adoption, moves, version-files, where-many-agents (67 of 67); tsc and biome clean.

Version 228 · Files at version 229

3 files, 50 lines added, 15 removed.

--- a/src/engine/view.ts
+++ b/src/engine/view.ts
@@ -859,15 +859,17 @@
859859 /** Atom-building line handles; text is loaded only when requested. */
860860 buildLines(path: string): readonly VisibleLine[] {
861861 const graph = this.graph;
862− const vis = this.#file(path).vis;
862+ // Texts the packed layout already holds are not read again (abso Capacity).
863+ const { vis, visText } = this.#file(path);
863864 const lines: VisibleLine[] = new Array(vis.length);
864865 for (let i = 0; i < vis.length; i++) {
865866 const n = vis[i]!;
867+ const packed = visText?.[i];
866868 lines[i] = {
867869 id: graph.lineIdOf(n),
868870 textChunks: () => graph.textChunks(n),
869871 get text() {
870− return graph.textOf(n);
872+ return packed ?? graph.textOf(n);
871873 },
872874 atom: graph.idOfSeq(graph.writerSeqOf(n)),
873875 };
@@ -879,11 +881,15 @@
879881 lines(path: string): readonly VisibleLine[] {
880882 if (this.#linesCache?.path === path) return this.#linesCache.lines;
881883 const graph = this.graph;
882− const vis = this.#file(path).vis;
884+ const { vis, visText } = this.#file(path);
883885 const lines: VisibleLine[] = new Array(vis.length);
884886 for (let i = 0; i < vis.length; i++) {
885887 const n = vis[i]!;
886− lines[i] = { id: graph.lineIdOf(n), text: graph.textOf(n), atom: graph.idOfSeq(graph.writerSeqOf(n)) };
888+ lines[i] = {
889+ id: graph.lineIdOf(n),
890+ text: visText?.[i] ?? graph.textOf(n),
891+ atom: graph.idOfSeq(graph.writerSeqOf(n)),
892+ };
887893 }
888894 this.#linesCache = { path, lines };
889895 return lines;
--- a/worker/project/definition-rule.ts
+++ b/worker/project/definition-rule.ts
@@ -67,9 +67,11 @@
6767 */
6868 #replacedNames(line: LineId, base: ReadView, runsOf: Map<AtomId, readonly RunEnd[]>): ReadonlySet<string> {
6969 const g = this.#graph;
70− const info = g.line(line);
71− if (!info) return EMPTY_NAMES;
72− const atom = g.atom(info.atom);
70+ // The line's atom and place in it from its id (abso Capacity): line() reads its text as well.
71+ if (g.lineN(line) < 0) return EMPTY_NAMES;
72+ const dot = line.indexOf(".");
73+ const atom = g.atom(line.slice(0, dot));
74+ const k = Number(line.slice(dot + 1));
7375 // Where each of the atom's runs ends, worked out once per check (abso issue 158): reading a run's
7476 // lines can mean reading its text back from the log, so not once per line of a big change.
7577 let runs = runsOf.get(atom.id);
@@ -78,7 +80,7 @@
7880 runs = atom.inserts.map((run) => ({ end: (k += run.lines.length), parent: run.parent }));
7981 runsOf.set(atom.id, runs);
8082 }
81− const parent = runs.find((r) => info.k < r.end)?.parent;
83+ const parent = runs.find((r) => k < r.end)?.parent;
8284 if (parent === undefined || parent.startsWith("^") || !g.deletersOf(parent).includes(atom.id)) return EMPTY_NAMES;
8385 const key = `${atom.id} ${parent}`;
8486 let names = this.#replacedCache.get(key);
@@ -156,7 +158,7 @@
156158 // Who changed it: newer writers of the new definition's lines, or newer deleters of the old one's.
157159 const by = new Set<AtomId>();
158160 for (const d of after)
159− for (const line of d.lines) if (newer.has(this.#graph.line(line)!.atom)) by.add(this.#graph.line(line)!.atom);
161+ for (const line of d.lines) if (newer.has(this.#graph.lineAtom(line)!)) by.add(this.#graph.lineAtom(line)!);
160162 for (const d of before)
161163 for (const line of d.lines) for (const x of this.#graph.deletersOf(line)) if (newer.has(x)) by.add(x);
162164 const first = [...by].sort((p, q) => this.#graph.atom(p).seq - this.#graph.atom(q).seq)[0];
--- a/worker/project/draft-collisions.ts
+++ b/worker/project/draft-collisions.ts
@@ -2,6 +2,7 @@
22// is the project in memory.
33
44import { type AtomId, type Graph, parseKey, type ReadView } from "../../src/engine/index.ts";
5+import { StableSet, unionOverlay } from "../../src/engine/state-source.ts";
56import { claimantsAmong, describeSide, fileOfKey, pairsFrom } from "./collisions.ts";
67import type { DefinitionRule } from "./definition-rule.ts";
78import { type Definition, definedTwice } from "./definitions.ts";
@@ -37,6 +38,29 @@
3738 * top of a file (refused once the second syncs onto the first's work). Exact for shared at `version`; as shared moves on, so can
3839 * the answer, as a real publish's would. `file` or `folder` narrows it.
3940 */
41+/**
42+ * A set and some drafts' atoms, by lookup (abso Capacity): copying shared's atoms into a new set read every one of them
43+ * from disk on a stored writer, once per pair of agents.
44+ */
45+class WithDrafts extends StableSet<AtomId> {
46+ readonly retainedBytes: number;
47+ readonly #base: ReadonlySet<AtomId>;
48+ readonly #drafts: ReadonlySet<AtomId>;
49+ constructor(base: ReadonlySet<AtomId>, drafts: Iterable<AtomId>) {
50+ super();
51+ this.#base = base;
52+ this.#drafts = new Set(drafts);
53+ this.retainedBytes = 64 + this.#drafts.size * 32;
54+ }
55+ has(atom: AtomId): boolean {
56+ return this.#drafts.has(atom) || this.#base.has(atom);
57+ }
58+ *values(): SetIterator<AtomId> {
59+ yield* this.#base;
60+ for (const atom of this.#drafts) if (!this.#base.has(atom)) yield atom;
61+ }
62+}
4064export function draftCollisions(
4165 host: DraftCollisionHost,
4266 options: { file?: string; folder?: string } = {},
@@ -71,11 +95,14 @@
7195 if (!set) draftSets.set(agent, (set = new Set(host.draft(agent))));
7296 return set;
7397 };
74− // Shared now with each agent's draft on top, once per agent: the key of a view of a set lists every atom in it.
98+ // Shared now with each agent's draft on top, once per agent. Over shared's view's own set (abso Capacity): a view's set
99+ // is closed under dependencies anyway, so shared's closed set and the drafts lay out what shared's atoms and the drafts
100+ // do, and only the drafts' atoms are walked to close it.
101+ const withDraftsView = (...drafts: readonly AtomId[][]) => host.view(unionOverlay(sharedView.set, drafts.flat()));
75102 const nowViews = new Map<Agent, ReadView>();
76103 const nowViewOf = (agent: Agent) => {
77104 let view = nowViews.get(agent);
78− if (!view) nowViews.set(agent, (view = host.view(new Set([...shared, ...host.draft(agent)]))));
105+ if (!view) nowViews.set(agent, (view = withDraftsView(host.draft(agent))));
79106 return view;
80107 };
81108 // Each agent's touched files once, not once per pair (abso Capacity).
@@ -93,7 +120,7 @@
93120 const draftA = host.draft(a);
94121 const draftB = host.draft(b);
95122 const newer = draftSet(a);
96− const union = new Set([...shared, ...draftA, ...draftB]);
123+ const union = new WithDrafts(shared, [...draftA, ...draftB]);
97124 const viewA = host.agentView(a);
98125 const viewB = host.agentView(b);
99126 if (i < j) {
@@ -134,15 +161,15 @@
134161 const mineB = new Set(draftB);
135162 const filesA = touchedBy(a);
136163 for (const file of [...touchedBy(b)].filter((f) => filesA.has(f)).toSorted()) {
137− both ??= host.view(union);
164+ both ??= withDraftsView(draftA, draftB);
138165 if (!both.hasFile(file)) continue;
139166 for (const [name, defs] of definedTwice(both, file)) {
140− const by = (mine: Set<AtomId>) => defs.find((d) => d.lines.some((l) => mine.has(host.graph.line(l)!.atom)));
167+ const by = (mine: Set<AtomId>) => defs.find((d) => d.lines.some((l) => mine.has(host.graph.lineAtom(l)!)));
141168 const dA = by(mineA);
142169 const dB = by(mineB);
143170 if (!dA || !dB || dA === dB) continue;
144171 const atomsOf = (d: Definition, mine: Set<AtomId>) =>
145− d.lines.map((l) => host.graph.line(l)!.atom).filter((x) => mine.has(x));
172+ d.lines.map((l) => host.graph.lineAtom(l)!).filter((x) => mine.has(x));
146173 if (atomsOf(dA, mineA).some((x) => atomsOf(dB, mineB).some((y) => paired.has(`${x} ${y}`)))) continue;
147174 out.push({
148175 kind: "duplicate",