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

Compare

+58 −0 in 1 place
new file, 58 lines
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import { Graph } from "../graph.ts";
4+import { Repo } from "./helpers.ts";
5+import { SqlState } from "./storage-helper.ts";
6+
7+test("indexed identities and metadata do not decode atom payloads", () => {
8+ const db = new SqlState();
9+ try {
10+ const repo = Repo.init({ "a.txt": "one\ntwo\n" });
11+ const graph = new Graph({ storage: db });
12+ graph.add(repo.graph.atom("a0"));
13+ const read = db.read.bind(db);
14+ db.read = (collection, key) => {
15+ if (collection === "atoms") throw Error("atom payload read forbidden");
16+ return read(collection, key);
17+ };
18+ assert.equal(graph.idOfSeq(0), "a0");
19+ assert.equal(graph.lamport("a0"), 0);
20+ assert.deepEqual(graph.filesOf("a0"), ["a.txt"]);
21+ assert.equal(graph.line("a0.0")?.atom, "a0");
22+ assert.equal(graph.lineIdOf(0), "a0.0");
23+ for (const seq of [-1, 1, 0.5, NaN, Infinity]) assert.throws(() => graph.idOfSeq(seq), /no atom/);
24+ for (const id of ["a1", "a00", "a-1", "invalid"]) {
25+ assert.throws(() => graph.lamport(id), /no atom/);
26+ assert.throws(() => graph.filesOf(id), /no atom/);
27+ }
28+ assert.equal(graph.line("a1.0"), undefined);
29+ assert.throws(() => graph.atom("a0"), /payload read forbidden/);
30+ } finally {
31+ db.db.close();
32+ }
33+});
35+test("accepting an edit does not decode historical atoms to canonicalize identities", () => {
36+ const db = new SqlState();
37+ try {
38+ const repo = Repo.init({ "a.txt": `first\n${"old\n".repeat(8191)}` });
39+ const graph = new Graph({ storage: db });
40+ graph.add(repo.graph.atom("a0"));
41+ const edit = repo.edit({ edits: [{ file: "a.txt", old: "first\n", new: "changed\n" }] });
42+ assert.ok(edit.deps.includes("a0"));
43+ const read = db.read.bind(db);
44+ db.read = (collection, key) => {
45+ if (collection === "atoms") throw Error("historical atom payload read forbidden");
46+ return read(collection, key);
47+ };
48+ graph.add(edit);
49+ assert.equal(graph.size, 2);
50+ assert.equal(graph.idOfSeq(1), edit.id);
51+ assert.equal(graph.lamport(edit.id), repo.graph.lamport(edit.id));
52+ assert.deepEqual(graph.filesOf(edit.id), repo.graph.filesOf(edit.id));
53+ db.read = read;
54+ assert.deepEqual(graph.atom(edit.id), repo.graph.atom(edit.id));
55+ } finally {
56+ db.db.close();
57+ }
58+});
MCP
compare on this site's /mcp
CLI
abso diff 84 318 src/engine/test/graph-metadata-indexed.test.ts --json
JSON
/christopher/abso-core/compare/84..318?file=src%2Fengine%2Ftest%2Fgraph-metadata-indexed.test.ts&format=json