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

Compare

+121 −0 in 1 place
new file, 121 lines
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import { ProjectionAtomAdoption } from "../experimental/projection-atom-adoption.ts";
4+import { indexAcceptedProjectionAtom, ProjectionAtomIndex } from "../experimental/projection-atom-index.ts";
5+import { ExperimentalMarkerProjection as MarkerProjection } from "../experimental/projection-marker.ts";
6+import { Graph } from "../graph.ts";
7+import { CachedStateStorage } from "../state-source.ts";
8+import type { Atom } from "../types.ts";
9+import { Repo, Rng } from "./helpers.ts";
10+import { SqlState } from "./storage-helper.ts";
12+for (const paged of [false, true, "indexed"] as const)
13+ test(`typed marker projection matches competing cyclic moves and removals (paged=${paged})`, () => {
14+ const db = new SqlState();
15+ try {
16+ const repo = Repo.init({ "f.txt": Array.from({ length: 12 }, (_, n) => `${n}\n`).join("") }),
17+ graph = new Graph({
18+ storage: new CachedStateStorage(db),
19+ indexAcceptedAtom: paged === "indexed" ? indexAcceptedProjectionAtom : undefined,
20+ }),
21+ rng = new Rng(45131);
22+ graph.add(repo.graph.atom("a0"));
23+ const p = new MarkerProjection(db, graph, "f.txt", "typed-" + "cycle");
24+ let state = p.apply(p.empty(), repo.graph.atom("a0")),
25+ checks = 0;
26+ const atoms = [];
27+ let task = 0;
28+ const apply = (atom: Atom, remove: boolean) => {
29+ if (!paged) return remove ? p.removeAtom(state, atom) : p.apply(state, atom);
30+ const job = new ProjectionAtomAdoption(p, String(task++));
31+ const previous = state;
32+ for (let pages = 0; pages < 10000; pages++) {
33+ const read = db.read.bind(db);
34+ if (paged === "indexed")
35+ db.read = (collection, key) => {
36+ if (collection === "atoms") throw Error("full atom read forbidden");
37+ return read(collection, key);
38+ };
39+ let result;
40+ try {
41+ result = job.page({
42+ previous,
43+ atom: paged === "indexed" ? new ProjectionAtomIndex(db).openAccepted(atom.id) : atom,
44+ remove,
45+ source: "c".repeat(64),
46+ maxSteps: 3,
47+ validateSource: () => {},
48+ });
49+ } finally {
50+ db.read = read;
51+ }
52+ assert.ok(result.steps <= 3);
53+ assert.equal(result.atomicMoveWork, false);
54+ if (result.done) return result.state;
55+ }
56+ throw Error("move adoption did not finish");
57+ };
58+ const check = () => {
59+ const view = repo.view();
60+ assert.deepEqual(
61+ p.lines(state),
62+ view.lines("f.txt").map((x) => x.id),
63+ );
64+ for (let n = 0; n < 12; n++) {
65+ const parent = view.parentOf(`a0.${n}`);
66+ assert.equal(
67+ (p.markers.get(state.locator, n + 1) as { parentKey: number }).parentKey,
68+ parent.startsWith("^") ? 0 : graph.lineN(parent) + 1,
69+ );
70+ }
71+ checks++;
72+ };
73+ for (let j = 0; j < 24; j++) {
74+ const offset = rng.int(12),
75+ moves = Array.from({ length: 3 }, (_, i) => {
76+ const line = `a0.${(offset + i) % 12}`,
77+ candidate = `a0.${rng.int(12)}`;
78+ return { line, parent: candidate === line ? "^f.txt" : candidate };
79+ });
80+ const atom = {
81+ id: repo.graph.nextId(),
82+ seq: repo.graph.size,
83+ author: "fixture",
84+ message: "move",
85+ time: j,
86+ inserts: [],
87+ deletes: [],
88+ writes: moves.flatMap((m) => [`P:${m.line}`, `G:${m.parent}`]),
89+ reads: [],
90+ holds: [],
91+ needs: [],
92+ resolves: [],
93+ reasons: [],
94+ deps: ["a0"],
95+ moves,
96+ };
97+ repo.graph.add(atom);
98+ repo.shared.add(atom.id);
99+ graph.add(atom);
100+ atoms.push(atom);
101+ state = apply(atom, false);
102+ check();
103+ }
104+ for (const atom of atoms.filter((_, i) => i % 2 === 0)) {
105+ repo.shared.delete(atom.id);
106+ state = apply(atom, true);
107+ check();
108+ }
109+ assert.equal(
110+ db.db
111+ .prepare(
112+ "SELECT count(*) AS n FROM state WHERE collection LIKE '%sequence-resolver:%' OR collection LIKE '%sequence-relocation-work:%' OR collection LIKE '%move-adoption:%'",
113+ )
114+ .get()!.n,
115+ 0,
116+ );
117+ assert.equal(checks, 36);
118+ } finally {
119+ db.db.close();
120+ }
121+ });
MCP
compare on this site's /mcp
CLI
abso diff 7 318 src/engine/test/projection-marker-cycle.test.ts --json
JSON
/christopher/abso-core/compare/7..318?file=src%2Fengine%2Ftest%2Fprojection-marker-cycle.test.ts&format=json