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 142 to 143

Compare

+83 −0 in 1 place
new file, 83 lines
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import { ExperimentalMarkerProjection as MarkerProjection } from "../experimental/projection-marker.ts";
4+import { Graph } from "../graph.ts";
5+import { CachedStateStorage } from "../state-source.ts";
6+import { Repo, Rng } from "./helpers.ts";
7+import { SqlState } from "./storage-helper.ts";
8+
9+test("typed marker projection matches competing cyclic moves and removals", () => {
10+ const db = new SqlState();
11+ try {
12+ const repo = Repo.init({ "f.txt": Array.from({ length: 12 }, (_, n) => `${n}\n`).join("") }),
13+ graph = new Graph({ storage: new CachedStateStorage(db) }),
14+ rng = new Rng(45131);
15+ graph.add(repo.graph.atom("a0"));
16+ const p = new MarkerProjection(db, graph, "f.txt", "typed-" + "cycle");
17+ let state = p.apply(p.empty(), repo.graph.atom("a0")),
18+ checks = 0;
19+ const atoms = [];
20+ const check = () => {
21+ const view = repo.view();
22+ assert.deepEqual(
23+ p.lines(state),
24+ view.lines("f.txt").map((x) => x.id),
25+ );
26+ for (let n = 0; n < 12; n++) {
27+ const parent = view.parentOf(`a0.${n}`);
28+ assert.equal(
29+ (p.markers.get(state.locator, n + 1) as { parentKey: number }).parentKey,
30+ parent.startsWith("^") ? 0 : graph.lineN(parent) + 1,
31+ );
32+ }
33+ checks++;
34+ };
35+ for (let j = 0; j < 24; j++) {
36+ const offset = rng.int(12),
37+ moves = Array.from({ length: 3 }, (_, i) => {
38+ const line = `a0.${(offset + i) % 12}`,
39+ candidate = `a0.${rng.int(12)}`;
40+ return { line, parent: candidate === line ? "^f.txt" : candidate };
41+ });
42+ const atom = {
43+ id: repo.graph.nextId(),
44+ seq: repo.graph.size,
45+ author: "fixture",
46+ message: "move",
47+ time: j,
48+ inserts: [],
49+ deletes: [],
50+ writes: moves.flatMap((m) => [`P:${m.line}`, `G:${m.parent}`]),
51+ reads: [],
52+ holds: [],
53+ needs: [],
54+ resolves: [],
55+ reasons: [],
56+ deps: ["a0"],
57+ moves,
58+ };
59+ repo.graph.add(atom);
60+ repo.shared.add(atom.id);
61+ graph.add(atom);
62+ atoms.push(atom);
63+ state = p.apply(state, atom);
64+ check();
65+ }
66+ for (const atom of atoms.filter((_, i) => i % 2 === 0)) {
67+ repo.shared.delete(atom.id);
68+ state = p.removeAtom(state, atom);
69+ check();
70+ }
71+ assert.equal(
72+ db.db
73+ .prepare(
74+ "SELECT count(*) AS n FROM state WHERE collection LIKE '%sequence-resolver:%' OR collection LIKE '%sequence-relocation-work:%'",
75+ )
76+ .get()!.n,
77+ 0,
78+ );
79+ assert.equal(checks, 36);
80+ } finally {
81+ db.db.close();
82+ }
83+});
MCP
compare on this site's /mcp
CLI
abso diff 142 143 src/engine/test/projection-marker-cycle.test.ts --json
JSON
/christopher/abso-core/compare/142..143?file=src%2Fengine%2Ftest%2Fprojection-marker-cycle.test.ts&format=json