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

A draft's view takes its base view's layout of every file the draft doesn't touch (disk-first 2; abso Capacity).

of shared·capacity··Not checked

An agent's tree, files and folder blame lay out every file in the agent's view, and tree also lays out the base to see which files the draft changed. Each layout read the file's packed history again, though every file the draft doesn't touch lays out exactly as in the draft's base.

  • View.shareFiles(from, except): a view lays out a file by taking from's layout of it, unless the file is in except. except is worked out once, when a file is first needed.
  • Project.#agentView sets it for a draft's view over its base's when the draft moves nothing (its moves are then the base's, as shareMoves already relies on). The touched files are touchedFiles over the draft's atoms, in both views: the files they write, delete in, set attributes on, and, where moves count, the files their deleted lines and their runs' parents sit in.

On abso adopted fresh, one kept writer: an agent's tree with authors 23.4 s to 12 to 14 s. It's still slow because a whole abso layout is bigger than the views' byte budget, so it isn't kept between calls.

New test agent-views-shared: after a published move of a function into another file, drafts that edit a moved line, delete one, change another file, set an attribute, or move lines themselves each read every file (text, attributes, writers) as the in-memory project does, read twice; it fails when the touched files are taken from where lines were written only. Named tests: every engine test (288 of 288), every worker/project test (338 of 338); typescript-rs, all 27 answers match replay; tsc and biome clean.

Version 234 · Files at version 235

3 files, 105 lines added, 3 removed.

--- a/src/engine/view.ts
+++ b/src/engine/view.ts
@@ -49,7 +49,7 @@
4949/** Structural read boundary shared by historical and transaction-bound projections. */
5050export type ReadView = Omit<
5151 Pick<View, keyof View>,
52− "sameText" | "visibleCount" | "shareMoves" | "fileOfNumber" | "lineNumberOf" | "visibleWriters"
52+ "sameText" | "visibleCount" | "shareMoves" | "shareFiles" | "fileOfNumber" | "lineNumberOf" | "visibleWriters"
5353> & {
5454 sameText(path: string, other: ReadView): boolean;
5555};
@@ -389,6 +389,27 @@
389389 this.#movesFrom = from;
390390 }
391391
392+ /**
393+ * Files laid out as another view lays them out (abso Capacity): a draft's view over its base's, for every file the
394+ * draft doesn't touch. The caller knows what the draft is; `except` is asked once, when a file is first needed, for
395+ * the files the draft touches, or undefined when nothing can be shared (a draft that moves lines). Without it, an
396+ * agent's tree, files and blame laid out every file of the project again for each agent.
397+ */
398+ shareFiles(from: View, except: () => ReadonlySet<string> | undefined): void {
399+ if (from.graph !== this.graph || from === this || this.#filesFrom !== undefined) return;
400+ this.#filesFrom = { from, except };
401+ }
402+ #filesFrom: { from: View; except: () => ReadonlySet<string> | undefined } | null | undefined;
403+ #filesShared: { from: View; except: ReadonlySet<string> } | null | undefined;
404+ #sharedFiles(): { from: View; except: ReadonlySet<string> } | null {
405+ if (this.#filesShared === undefined) {
406+ const share = this.#filesFrom;
407+ const except = share ? share.except() : undefined;
408+ this.#filesShared = share && except ? { from: share.from, except } : null;
409+ }
410+ return this.#filesShared;
411+ }
392413 #takeShared(): void {
393414 const from = this.#movesFrom;
394415 if (!from) return;
@@ -1104,7 +1125,9 @@
11041125 #file(path: string, complete = false): FileState {
11051126 let state = this.#files.get(path);
11061127 if (!state || (complete && !state.complete)) {
1107− state = this.graph.hasAtomsIn(path) ? this.#layout(path, complete) : NO_FILE;
1128+ const shared = this.#filesFrom === undefined ? null : this.#sharedFiles();
1129+ if (shared && !shared.except.has(path)) state = shared.from.#file(path, complete);
1130+ else state = this.graph.hasAtomsIn(path) ? this.#layout(path, complete) : NO_FILE;
11081131 this.#files.set(path, state);
11091132 }
11101133 return state;
--- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -2742,7 +2742,16 @@
27422742 // A draft that moves nothing resolves its moves as its base does (abso Capacity): take them from the base's view.
27432743 if (this.#writerStorage && agent.mine.length > 0 && view instanceof View) {
27442744 const base = this.#viewAt(this.#spaceOf(agent), agent.base);
2745− if (base instanceof View) view.shareMoves(base);
2745+ if (base instanceof View) {
2746+ view.shareMoves(base);
2747+ // And its layout of every file the draft doesn't touch, when the draft moves nothing (abso Capacity).
2748+ const mine = agent.mine;
2749+ view.shareFiles(base, () =>
2750+ mine.some((id) => (this.#graph.atom(id).moves?.length ?? 0) > 0)
2751+ ? undefined
2752+ : this.#touchedFiles(mine, [base, view]),
2753+ );
2754+ }
27462755 }
27472756 return view;
27482757 }
--- /dev/null
+++ b/worker/project/test/agent-views-shared.test.ts
@@ -0,0 +1,70 @@
1+// A draft's view takes its base view's layout of every file the draft doesn't touch (abso Capacity, View.shareFiles).
2+// On a writer-backed project every agent's view must still read every file as the in-memory project does: a draft
3+// that edits lines moved into another file by a published move, one that deletes such a line, one that only sets an
4+// attribute, and one that moves lines itself (which shares nothing).
5+
6+import assert from "node:assert/strict";
7+import { test } from "node:test";
8+import { storedArray } from "../../../src/engine/state-source.ts";
9+import { SqlState } from "../../../src/engine/test/storage-helper.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+const AREA = "export function area(r: number) {\n const pi = 3.14;\n return pi * r * r;\n}\n";
25+const FILES = {
26+ "src/shapes.ts": `// shapes\n${AREA}\nexport function other() {\n return 1;\n}\n`,
27+ "src/geometry.ts": "// geometry\n",
28+ "src/plain.ts": "one\ntwo\nthree\n",
29+ "run.sh": "echo hi\n",
30+ "README.md": "readme\n",
31+};
33+function history(project: Project) {
34+ let t = 0;
35+ project.init(FILES, t);
36+ // ann moves area() into geometry.ts and publishes: its lines were written in shapes.ts.
37+ project.edit("ann", { file: "src/shapes.ts", old: AREA, new: "" }, ++t);
38+ project.edit("ann", { file: "src/geometry.ts", content: `// geometry\n${AREA}` }, ++t);
39+ assert.equal(project.publish("ann", "Move area to geometry", ++t).ok, true);
40+ for (const agent of ["bob", "cy", "dee", "eve", "fay"]) project.sync(agent);
41+ // bob edits a moved line, cy deletes one, dee touches only plain.ts, eve sets an attribute, fay moves lines.
42+ project.edit("bob", { file: "src/geometry.ts", old: "3.14", new: "Math.PI" }, ++t);
43+ project.edit("cy", { file: "src/geometry.ts", old: " const pi = 3.14;\n", new: "" }, ++t);
44+ project.record("dee", { "src/plain.ts": "one\nTWO\nthree\n" }, ++t);
45+ project.record("eve", {}, ++t, { "run.sh": { exec: true } });
46+ project.edit("fay", { file: "src/plain.ts", old: "one\ntwo\nthree\n", new: "" }, ++t);
47+ project.edit("fay", { file: "src/moved.ts", content: "one\ntwo\nthree\n" }, ++t);
48+}
50+const read = (project: Project, agent: string) => {
51+ const view = project.draftOf(agent)!.view;
52+ const out: Record<string, unknown> = {};
53+ for (const path of view.paths()) out[path] = [view.text(path), view.attrs(path), view.lines(path).map((l) => l.atom)];
54+ return out;
55+};
57+test("every agent's view reads every file as the in-memory project's, with files shared from the base", () => {
58+ const oracle = new Project(new MemoryStore());
59+ const project = writer();
60+ history(oracle);
61+ history(project);
62+ for (const agent of ["ann", "bob", "cy", "dee", "eve", "fay"]) {
63+ // Twice: the second read takes the shared layouts the first one made.
64+ assert.deepEqual(read(project, agent), read(oracle, agent), agent);
65+ assert.deepEqual(read(project, agent), read(oracle, agent), `${agent} again`);
66+ }
67+ assert.match(String(read(oracle, "bob")["src/geometry.ts"]), /Math\.PI/);
68+ assert.doesNotMatch(String(read(oracle, "cy")["src/geometry.ts"]), /const pi/);
69+ assert.deepEqual(project.tree("", { agent: "cy", authors: true }), oracle.tree("", { agent: "cy", authors: true }));
70+});