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

Bound file-location ancestry scratch and memo

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

Version 124 · Files at version 125

2 files, 28 lines added, 2 removed.

--- a/src/engine/test/view.test.ts
+++ b/src/engine/test/view.test.ts
@@ -8,6 +8,23 @@
88import { lines, Repo } from "./helpers.ts";
99
1010describe("View", () => {
11+ it("bounds file-location memo growth across long ancestry walks with moves", () => {
12+ const retained = (count: number) => {
13+ const repo = Repo.init({ "long.txt": "line\n".repeat(count), "a.txt": "move\n", "b.txt": "base\n" });
14+ repo.edit({ move: { file: "a.txt", start: 0, end: 1, to: "b.txt", at: 1 } });
15+ const view = new View(repo.graph, new StableOverlaySet<AtomId>(["a0", "a1"]));
16+ const oracle = repo.view();
17+ // Resolve the deepest ancestry first, then force repeated cache eviction.
18+ const sequence = oracle.sequence("long.txt");
19+ assert.equal(sequence.length, count);
20+ assert.equal(view.fileOf(sequence[count - 1]!.id), "long.txt");
21+ for (const line of sequence) assert.equal(view.fileOf(line.id), "long.txt");
22+ for (const line of oracle.lines("b.txt")) assert.equal(view.fileOf(line.id), "b.txt");
23+ assert.equal(view.fileOf(sequence[count - 1]!.id), "long.txt");
24+ return view.weight();
25+ };
26+ assert.equal(retained(2048), retained(512), "file-location retained state must not grow with ancestry depth");
27+ });
1128 it("current indexed paths do not retain deleted historical file layouts", () => {
1229 const retained = (count: number) => {
1330 const files: Record<string, string> = { "live.txt": "live\n" };
--- a/src/engine/view.ts
+++ b/src/engine/view.ts
@@ -83,6 +83,7 @@
8383const MAP_ENTRY_BYTES = 40;
8484const SET_ENTRY_BYTES = 32;
8585const REFERENCE_BYTES = 8;
86+const FILE_LOCATION_MEMO_ENTRIES = 256;
8687
8788/**
8889 * The projection of a closed set. Construct once, then ask for files, lines
@@ -110,6 +111,7 @@
110111 #relocs: Map<LineId, RelocationInfo> | undefined;
111112 /** The same, by n, with the new parent's code. */
112113 #relocsN: Map<number, { readonly r: RelocationInfo; readonly parent: number }> | undefined;
114+ /** Bounded memo: ancestry can span the entire history even for one visible line. */
113115 #fileOf = new Map<number, string>();
114116 /** The latest records asked for: one file's lines, one file's sequence, one file's text. */
115117 #linesCache: { path: string; lines: readonly VisibleLine[] } | undefined;
@@ -286,7 +288,10 @@
286288 const graph = this.graph;
287289 if (!this.#hasMoves) return graph.writtenIn(n);
288290 const relocs = this.#relocationsN();
291+ // Keep only a fixed tail of the walk for path compression. The selected
292+ // relocation graph is acyclic, so traversal needs no history-sized stack.
289293 const path: number[] = [];
294+ let visited = 0;
290295 let cur = n;
291296 let file: string | undefined;
292297 while (file === undefined) {
@@ -294,12 +299,16 @@
294299 else {
295300 file = this.#fileOf.get(cur);
296301 if (file === undefined) {
297− path.push(cur);
302+ path[visited++ % FILE_LOCATION_MEMO_ENTRIES] = cur;
298303 cur = relocs.get(cur)?.parent ?? graph.parentCodeOf(cur);
299304 }
300305 }
301306 }
302− for (const l of path) this.#fileOf.set(l, file);
307+ for (const l of path) {
308+ if (!this.#fileOf.has(l) && this.#fileOf.size >= FILE_LOCATION_MEMO_ENTRIES)
309+ this.#fileOf.delete(this.#fileOf.keys().next().value!);
310+ this.#fileOf.set(l, file);
311+ }
303312 return file;
304313 }
305314