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

Compare

+43 −0 in 1 place
new file, 43 lines
1+import assert from "node:assert/strict";
2+import { test } from "node:test";
3+import { answer } from "../../worker/project/http.ts";
4+import { DiskFirstRuntime } from "../src/disk-first-runtime.ts";
5+import { memoryStorage } from "./helpers.ts";
6+
7+test("disk runtime syncs overlapping edits without unkeyed membership", (t) => {
8+ const storage = memoryStorage();
9+ t.after(() => storage.db.close());
10+ const runtime = () => new DiskFirstRuntime(storage, "sync", "sync");
11+ runtime().initialize(
12+ (c) => answer(c, "init", undefined, { files: { "a.txt": "one\ntwo\nthree\n" } }),
13+ () => {},
14+ );
15+ while (!runtime().preparePage(() => {}).ready) {}
16+ const call = (op: string, agent: string, body: unknown) =>
17+ runtime().write(
18+ (c) => answer(c, op, agent, body),
19+ () => {},
20+ );
21+ for (const agent of ["alice", "bob"]) assert.equal(call("sync", agent, {}).status, 200);
22+ assert.equal(call("record", "alice", { files: { "a.txt": "one\nalice\nthree\n" } }).status, 200);
23+ assert.equal(call("record", "bob", { files: { "a.txt": "one\nbob\nthree\n" } }).status, 200);
24+ assert.equal(call("publish", "alice", { message: "alice" }).status, 200);
25+ const result = call("sync", "bob", {});
26+ assert.equal(result.status, 200, JSON.stringify(result));
27+ const body = result.body as {
28+ version: number;
29+ files: Record<string, string>;
30+ collisions: { kind: string; marked?: boolean }[];
31+ };
32+ assert.equal(body.version, 1);
33+ assert.equal(body.collisions.length, 1);
34+ assert.equal(body.collisions[0]!.kind, "lines");
35+ assert.equal(body.collisions[0]!.marked, true);
36+ assert.match(body.files["a.txt"]!, /<<<<<<< yours/);
37+ assert.match(body.files["a.txt"]!, /bob/);
38+ assert.match(body.files["a.txt"]!, /alice/);
39+ const repeated = call("sync", "bob", {});
40+ assert.equal(repeated.status, 200);
41+ assert.equal((repeated.body as typeof body).collisions.length, 1);
42+ assert.equal((repeated.body as typeof body).collisions[0]!.marked, true);
43+});
MCP
compare on this site's /mcp
CLI
abso diff 98 318 server/test/projected-sync.test.ts --json
JSON
/christopher/abso-core/compare/98..318?file=server%2Ftest%2Fprojected-sync.test.ts&format=json