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 205 to 206

Compare

+56 −0 in 1 place
new file, 56 lines
1+// Each file's line history packed (abso Capacity, Graph.packedLines): a stored graph lays files out from a few pages,
2+// and must give exactly what the in-memory graph gives, through edits, deletes, moves between files and back.
3+
4+import assert from "node:assert/strict";
5+import { test } from "node:test";
6+import { Graph, View } from "../index.ts";
7+import { StableOverlaySet } from "../state-source.ts";
8+import { lines, Repo } from "./helpers.ts";
9+import { SqlState } from "./storage-helper.ts";
11+test("a packed file lays out as the in-memory graph does, at every step, moves included", () => {
12+ const oracle = Repo.init({ "a.txt": lines("one", "two", "three", "four"), "b.txt": lines("bee"), "c.txt": "" });
13+ const sets: Set<string>[] = [new Set(oracle.shared)];
14+ const step = (change: Parameters<Repo["edit"]>[0]) => {
15+ oracle.edit(change);
16+ sets.push(new Set(oracle.shared));
17+ };
18+ step({ edits: [{ file: "a.txt", old: "two", new: "TWO" }] });
19+ step({ move: { file: "a.txt", start: 1, end: 3, to: "b.txt", at: 1 } });
20+ step({ edits: [{ file: "b.txt", old: "TWO", new: "two again" }] });
21+ step({ edits: [{ file: "a.txt", old: "four", new: "" }] });
22+ step({ move: { file: "b.txt", start: 0, end: 2, to: "c.txt", at: 0 } });
23+ step({ edits: [{ file: "c.txt", old: "bee", new: "bee\nafter bee" }] });
24+ const storage = new SqlState();
25+ try {
26+ const graph = new Graph({ storage });
27+ for (const atom of oracle.graph.atoms()) graph.add(atom);
28+ const reopened = new Graph({ storage });
29+ assert.equal(reopened.packedFiles, true);
30+ for (const [i, set] of sets.entries()) {
31+ const packed = new View(reopened, new StableOverlaySet(set));
32+ const memory = new View(oracle.graph, set);
33+ assert.deepEqual(packed.paths(), memory.paths(), `step ${i}: paths`);
34+ for (const path of ["a.txt", "b.txt", "c.txt"]) {
35+ assert.equal(packed.text(path), memory.text(path), `step ${i}: ${path}`);
36+ assert.deepEqual(packed.sequence(path), memory.sequence(path), `step ${i}: ${path}'s sequence`);
37+ assert.deepEqual(packed.attrs(path), memory.attrs(path), `step ${i}: ${path}'s attributes`);
38+ }
39+ }
40+ } finally {
41+ storage.db.close();
42+ }
43+});
45+test("a graph made with packFiles off keeps no packed history", () => {
46+ const oracle = Repo.init({ "a.txt": lines("one") });
47+ const storage = new SqlState();
48+ try {
49+ const graph = new Graph({ storage, packFiles: false });
50+ for (const atom of oracle.graph.atoms()) graph.add(atom);
51+ assert.equal(new Graph({ storage }).packedFiles, false);
52+ assert.equal(new View(new Graph({ storage }), new StableOverlaySet(oracle.shared)).text("a.txt"), "one\n");
53+ } finally {
54+ storage.db.close();
55+ }
56+});
MCP
compare on this site's /mcp
CLI
abso diff 205 206 src/engine/test/packed-files.test.ts --json
JSON
/christopher/abso-core/compare/205..206?file=src%2Fengine%2Ftest%2Fpacked-files.test.ts&format=json