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

Versions 111 to 318

Compare

+59 −1 in 3 places
Lines 8–59 at 318 (were 8–13 at 111)
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+ });
28+ it("current indexed paths do not retain deleted historical file layouts", () => {
29+ const retained = (count: number) => {
30+ const files: Record<string, string> = { "live.txt": "live\n" };
31+ for (let i = 0; i < count; i++) files[`old-${i}.txt`] = "gone\n";
32+ const repo = Repo.init(files);
33+ repo.edit({ edits: Array.from({ length: count }, (_, i) => ({ file: `old-${i}.txt`, old: "gone\n", new: "" })) });
34+ const view = new View(repo.graph, new StableOverlaySet<AtomId>(["a0", "a1"]));
35+ assert.deepEqual(view.files(), { "live.txt": "live\n" });
36+ const weight = view.weight();
37+ assert.equal(view.knownPaths().length, count + 1, "explicit historical enumeration is preserved");
38+ return weight;
39+ };
40+ assert.equal(retained(200), retained(20), "deleted path count must not grow current-view retained state");
41+ });
42+ it("reuses indexed membership across a long run of lines without a history-sized memo", () => {
43+ const repo = Repo.init({ "long.txt": "line\n".repeat(1000) });
44+ class CountingSet extends StableOverlaySet<AtomId> {
45+ calls = 0;
46+ override has(id: AtomId): boolean {
47+ this.calls++;
48+ return super.has(id);
49+ }
50+ }
51+ const set = new CountingSet(["a0"]);
52+ const view = new View(repo.graph, set);
53+ set.calls = 0;
54+ assert.equal(view.text("long.txt"), "line\n".repeat(1000));
55+ assert.ok(set.calls <= 2, `membership was queried ${set.calls} times for one atom`);
56+ });
1157 it("immutable indexed membership avoids a history-sized bitmap and remains a snapshot", () => {
1258 class RangeMembership extends StableSet<AtomId> {
1359 readonly retainedBytes = 64;
Lines 87–103 at 318 (were 41–46 at 111)
4187 assert.equal(first.set.has("a80"), false);
4288 assert.throws(() => new View(repo.graph, new StableOverlaySet<AtomId>(["a1"])), /not closed/);
4389 });
90+ it("membership memo collisions preserve both included and excluded historical atoms", () => {
91+ const repo = Repo.init({ "f.txt": "0\n" });
92+ for (let i = 1; i <= 257; i++) repo.edit({ edits: [{ file: "f.txt", old: `${i - 1}\n`, new: `${i}\n` }] });
93+ const old = new View(repo.graph, new StableOverlaySet<AtomId>(["a0"]));
94+ assert.equal(old.text("f.txt"), "0\n");
95+ assert.deepEqual(
96+ old.sequence("f.txt").map((line) => line.text),
97+ ["0"],
98+ );
99+ assert.equal(repo.view().text("f.txt"), "257\n");
100+ });
44101 it("keeps deleted lines as tombstones in the full sequence", () => {
45102 const repo = Repo.init({ "f.txt": lines("one", "two", "three") });
46103 const del = repo.edit({ edits: [{ file: "f.txt", old: "two\n", new: "" }] });
Lines 134–142 at 318 (were 77–84 at 111)
77134 assert.equal(repo.text("f.txt"), lines("top", "r", "q", "p", "bottom"));
78135 assert.deepEqual(
79136 r.deps,
80− ["a0", p.id, q.id].sort((a, b) => Number(a.slice(1)) - Number(b.slice(1))),
137+ [p.id, q.id].sort((a, b) => Number(a.slice(1)) - Number(b.slice(1))),
81138 );
139+ assert.deepEqual(repo.graph.closureOf(r.deps), repo.graph.closureOf(["a0", p.id, q.id]));
82140 });
83141
84142 it("puts a line's replacements ahead of the lines inserted after it, whatever their priority", () => {
MCP
compare on this site's /mcp
CLI
abso diff 111 318 src/engine/test/view.test.ts --json
JSON
/christopher/abso-core/compare/111..318?file=src%2Fengine%2Ftest%2Fview.test.ts&format=json