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

Read long insertion text lazily and stream files through Git commit construction

of shared·codex-capacity-chair··Not checked

Version 165 · Files at version 166

6 files, 99 lines added, 6 removed.

--- a/server/src/push.ts
+++ b/server/src/push.ts
@@ -170,10 +170,10 @@
170170 // Each file goes into the tree as a blob with its mode (#27): 100755 for exec, 120000 for a link, whose blob is
171171 // its target.
172172 const enc = new TextEncoder();
173− for (const [path, text] of Object.entries(shared.files)) {
173+ for (const path of Object.keys(shared.files)) {
174174 const mode = shared.modes?.[path];
175175 const link = typeof mode?.link === "string" ? mode.link : null;
176− const bytes = enc.encode(link ?? text);
176+ const bytes = enc.encode(link ?? shared.files[path]!);
177177 await put(path, bytes, link !== null ? "120000" : mode?.exec ? "100755" : "100644", await blobOid(bytes));
178178 }
179179 const agent = shared.last?.agent ?? "abso";
--- a/server/test/push.test.ts
+++ b/server/test/push.test.ts
@@ -22,6 +22,33 @@
2222});
2323
2424describe("commitShared", () => {
25+ it("reads one lazy file at a time and does not read symlink placeholder text", async (t) => {
26+ const fs = new MemoryFS();
27+ const dir = "/repo";
28+ await git.init({ fs, dir, defaultBranch: "main" });
29+ let writes = 0;
30+ const writeBlob = git.writeBlob;
31+ t.mock.method(git, "writeBlob", async (options: Parameters<typeof writeBlob>[0]) => {
32+ const result = await writeBlob(options);
33+ writes++;
34+ return result;
35+ });
36+ const files = {
37+ get a() {
38+ assert.equal(writes, 0);
39+ return "first";
40+ },
41+ get b() {
42+ assert.equal(writes, 1);
43+ return "second";
44+ },
45+ get link(): string {
46+ throw Error("symlink placeholder text must not be read");
47+ },
48+ };
49+ await commitShared(fs, dir, null, { version: 0, files, modes: { link: { link: "a" } } }, () => null);
50+ assert.equal(writes, 3);
51+ });
2552 it("writes shared as a commit with its modes, then only what changed", async () => {
2653 const fs = new MemoryFS();
2754 const dir = "/repo";
--- a/src/engine/experimental/projection-reader.ts
+++ b/src/engine/experimental/projection-reader.ts
@@ -1,6 +1,5 @@
11import { startNode } from "../keys.ts";
22import { StableSet } from "../state-source.ts";
3−import { joinLines } from "../text.ts";
43import type { FileAttrs, ReadView, SeqLine, VisibleLine } from "../view.ts";
54import type { ExperimentalMarkerProjection, MarkerState } from "./projection-marker.ts";
65
@@ -74,7 +73,14 @@
7473 }
7574 lineNumber(path: string, line: string): number {
7675 this.#assertLive();
77− return this.lines(path).findIndex((item) => item.id === line);
76+ let index = 0;
77+ for (const id of this.#adapter.lineIds(this.#state, path)) {
78+ this.#assertLive();
79+ if (id === line) return index;
80+ index++;
81+ }
82+ this.#assertLive();
83+ return -1;
7884 }
7985 sameText(path: string, other: ReadView): boolean {
8086 this.#assertLive();
@@ -193,7 +199,16 @@
193199 }
194200 text(path: string): string {
195201 this.#assertLive();
196− return joinLines([...this.visibleLines(path)].map((line) => line.text));
202+ let text = "",
203+ part = "";
204+ for (const line of this.visibleLines(path)) {
205+ part += `${line.text}\n`;
206+ if (part.length >= 16384) {
207+ text += part;
208+ part = "";
209+ }
210+ }
211+ return text + part;
197212 }
198213 hasFile(path: string): boolean {
199214 this.#assertLive();
--- a/src/engine/graph.ts
+++ b/src/engine/graph.ts
@@ -429,7 +429,12 @@
429429 }
430430 const listCount = Object.keys(lists).length;
431431 const hasLists = listCount > 0;
432− if (atom.inserts.length > 256 || atom.inserts.some((run) => run.lines.length > 256)) {
432+ let insertionCharacters = 0;
433+ if (
434+ atom.inserts.length > 256 ||
435+ atom.inserts.some((run) => run.lines.length > 256) ||
436+ atom.inserts.some((run) => run.lines.some((line) => (insertionCharacters += line.length) > 65536))
437+ ) {
433438 const collection = `atom-inserts:${input.seq}`;
434439 const runs = storedArray<unknown>(storage, collection);
435440 let runIndex = 0;
--- a/src/engine/test/graph-long-text.test.ts
+++ b/src/engine/test/graph-long-text.test.ts
@@ -4,6 +4,28 @@
44import { Graph } from "../graph.ts";
55import { SqlState } from "./storage-helper.ts";
66
7+test("large insertion text stays lazy even when the run has few lines", (t) => {
8+ const storage = new SqlState();
9+ t.after(() => storage.db.close());
10+ const memory = new MemoryStore();
11+ const line = "x".repeat(100000);
12+ new Project(memory).init({ "a.txt": `${line}\n${line}\n${line}\n` }, 0);
13+ const entry = memory.entries[0]!;
14+ if (entry.type !== "init") throw Error("expected init");
15+ new Graph({ storage }).add(entry.atom);
16+ const read = storage.read.bind(storage);
17+ let textReads = 0;
18+ t.mock.method(storage, "read", (collection: string, key: string) => {
19+ if (collection === "atom-text:long:chunks") textReads++;
20+ return read(collection, key);
21+ });
22+ const atom = new Graph({ storage }).atom("a0");
23+ assert.equal(atom.inserts[0]!.lines.length, 3);
24+ assert.equal(textReads, 0, "reading line count must not decode the complete run");
25+ assert.equal(atom.inserts[0]!.lines[1], line);
26+ assert.equal(textReads, Math.ceil(line.length / 16384), "an indexed read decodes only the selected line");
27+});
729test("persistent graph stores long lines in chunks and reopens exact text", () => {
830 const storage = new SqlState();
931 try {
--- a/src/engine/test/projection-reader.test.ts
+++ b/src/engine/test/projection-reader.test.ts
@@ -10,6 +10,30 @@
1010import { Repo } from "./helpers.ts";
1111import { SqlState } from "./storage-helper.ts";
1212
13+test("projected text streams lines and line lookup does not read file text", (t) => {
14+ const storage = new SqlState();
15+ t.after(() => storage.db.close());
16+ const text = `${"x".repeat(40000)}\nsecond\nthird\n`;
17+ const repo = Repo.init({ "f.txt": text, "empty.txt": "" });
18+ const graph = new Graph({ storage: new CachedStateStorage(storage) });
19+ graph.add(repo.graph.atom("a0"));
20+ const adapter = new ExperimentalMarkerProjection(storage, graph, "f.txt", "streamed-text");
21+ const state = adapter.apply(adapter.empty(), graph.atom("a0"));
22+ const reader = new ProjectionReader(adapter, state, () => {});
23+ t.mock.method(reader, "lines", () => {
24+ throw Error("full line array forbidden");
25+ });
26+ assert.equal(reader.text("f.txt"), text);
27+ assert.equal(reader.text("empty.txt"), "");
28+ assert.equal(reader.text("missing.txt"), "");
29+ const ids = [...adapter.lineIds(state, "f.txt")];
30+ t.mock.method(graph, "textOf", () => {
31+ throw Error("line lookup must not read text");
32+ });
33+ for (let i = 0; i < ids.length; i++) assert.equal(reader.lineNumber("f.txt", ids[i]!), i);
34+ assert.equal(reader.lineNumber("f.txt", "missing"), -1);
35+});
1337test("unchanged atom builder consumes the private reader for replacement and insertion edits", () => {
1438 const storage = new SqlState();
1539 try {