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 153 to 318

Compare

+69 −0 in 2 places
Lines 6–33 at 318 (were 6–11 at 153)
66import { Repo } from "./helpers.ts";
77import { SqlState } from "./storage-helper.ts";
88
9+test("projection apply and removal compare atom contents without whole-atom JSON", (t) => {
10+ const storage = new SqlState();
11+ t.after(() => storage.db.close());
12+ const repo = Repo.init({ "f.txt": `${"x".repeat(40000)}\n` });
13+ const atom = repo.graph.atom("a0");
14+ const projection = new MarkerProjection(storage, repo.graph, "f.txt", "streamed-comparison");
15+ const stringify = JSON.stringify;
16+ t.mock.method(JSON, "stringify", (...args: Parameters<typeof JSON.stringify>) => {
17+ assert.notEqual(args[0], atom, "projection validation must not serialize the full atom");
18+ return stringify(...args);
19+ });
20+ const state = projection.apply(projection.empty(), atom);
21+ const before = storage.writes;
22+ const altered = { ...atom, message: "forged" };
23+ assert.throws(() => projection.apply(state, altered), /canonical atom mismatch/);
24+ assert.throws(() => projection.removeAtom(state, altered), /canonical atom mismatch/);
25+ assert.equal(storage.writes, before);
26+ const removed = projection.removeAtom(state, atom);
27+ assert.deepEqual(projection.lines(removed, "f.txt"), []);
28+ assert.equal(projection.lines(state, "f.txt").length, 1);
29+});
931test("typed marker projection matches mixed multi-file edits and reverse removals", () => {
1032 const db = new SqlState();
1133 try {
Lines 140–189 at 318 (were 118–120 at 153)
118140 storage.db.close();
119141 }
120142});
144+test("visibility batches roll back earlier batches and retry with exact line parity", (t) => {
145+ const db = new SqlState();
146+ t.after(() => db.db.close());
147+ const text = Array.from({ length: 35 }, (_, n) => `line ${n}\n`).join("");
148+ const repo = Repo.init({ "f.txt": text });
149+ const graph = new Graph({ storage: new CachedStateStorage(db) });
150+ graph.add(repo.graph.atom("a0"));
151+ const p = new MarkerProjection(db, graph, "f.txt", "batch-failure");
152+ const initial = p.apply(p.empty(), repo.graph.atom("a0"));
153+ const originalLines = p.lines(initial, "f.txt");
154+ const atom = repo.edit({ edits: [{ file: "f.txt", old: text, new: "" }] });
155+ graph.add(atom);
156+ const rows = () => db.db.prepare("SELECT * FROM state ORDER BY collection,key").all();
157+ const before = rows();
158+ const original = p.sequence.updateMany.bind(p.sequence);
159+ const sizes: number[] = [];
160+ let fail = true;
161+ t.mock.method(
162+ p.sequence,
163+ "updateMany",
164+ (state: Parameters<typeof original>[0], operations: Parameters<typeof original>[1]) => {
165+ const next = original(state, operations);
166+ if (operations.every((op) => op.kind === "visibility")) {
167+ sizes.push(operations.length);
168+ if (fail && sizes.length === 2) throw Error("second visibility batch failure");
169+ }
170+ return next;
171+ },
172+ );
173+ assert.throws(() => p.apply(initial, atom), /second visibility batch/);
174+ assert.deepEqual(sizes, [16, 16]);
175+ assert.deepEqual(rows(), before);
176+ assert.deepEqual(p.lines(initial, "f.txt"), originalLines);
177+ fail = false;
178+ sizes.length = 0;
179+ const next = p.apply(initial, atom);
180+ assert.deepEqual(sizes, [16, 16, 3]);
181+ assert.deepEqual(
182+ p.lines(next, "f.txt"),
183+ repo
184+ .view()
185+ .lines("f.txt")
186+ .map((line) => line.id),
187+ );
188+ assert.deepEqual(p.lines(initial, "f.txt"), originalLines);
189+});
MCP
compare on this site's /mcp
CLI
abso diff 153 318 src/engine/test/projection-marker.test.ts --json
JSON
/christopher/abso-core/compare/153..318?file=src%2Fengine%2Ftest%2Fprojection-marker.test.ts&format=json