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

Compare

+64 −0 in 1 place
new file, 64 lines
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import { buildBase, Graph } from "../index.ts";
4+import { lineKey } from "../keys.ts";
5+import { storedLists } from "../state-source.ts";
6+import type { Atom } from "../types.ts";
7+import { SqlState } from "./storage-helper.ts";
8+
9+test("persistent key indexes deduplicate repeated keys without per-atom key sets", () => {
10+ const storage = new SqlState();
11+ try {
12+ const graph = new Graph({ storage });
13+ graph.add(buildBase({ "a.txt": "base" }, { author: "fixture", message: "base", time: 0 }));
14+ const keys = Array.from({ length: 513 }, () => lineKey("a0.0"));
15+ const atom: Atom = {
16+ id: "a1",
17+ seq: 1,
18+ author: "fixture",
19+ message: "keys",
20+ time: 1,
21+ inserts: [],
22+ deletes: [],
23+ writes: keys,
24+ reads: keys,
25+ holds: keys,
26+ needs: [],
27+ resolves: ["a0", "a0"],
28+ reasons: [],
29+ deps: ["a0"],
30+ };
31+ graph.add(atom);
32+ for (const collection of ["writers", "readers", "holders", "resolvers"]) {
33+ const index = storedLists<string>(storage, collection, (key) => key);
34+ let matches = 0;
35+ for (const key of index.keys()) {
36+ const values = [...index.values(key)];
37+ const count = values.filter((value) => value === "a1").length;
38+ assert.ok(count <= 1);
39+ matches += count;
40+ }
41+ assert.equal(matches, 1, collection);
42+ }
43+ } finally {
44+ storage.db.close();
45+ }
46+});
48+test("last list entry reads only its final page and rejects truncated pages", () => {
49+ const storage = new SqlState();
50+ try {
51+ const list = storedLists<number>(storage, "items");
52+ for (let i = 0; i < 513; i++) list.append("key", i);
53+ const read = storage.read.bind(storage);
54+ storage.read = (collection, key) => {
55+ if (collection === "items:pages") assert.equal(key, JSON.stringify(["key", 2]));
56+ return read(collection, key);
57+ };
58+ assert.equal(list.last("key"), 512);
59+ storage.write("items:pages", JSON.stringify(["key", 2]), [512, 513]);
60+ assert.throws(() => list.last("key"), /incomplete writer list page/);
61+ } finally {
62+ storage.db.close();
63+ }
64+});
MCP
compare on this site's /mcp
CLI
abso diff 154 318 src/engine/test/graph-index-dedup.test.ts --json
JSON
/christopher/abso-core/compare/154..318?file=src%2Fengine%2Ftest%2Fgraph-index-dedup.test.ts&format=json