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
MCP
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/server/test/projected-move-sync.test.ts?format=json
51 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 163, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { answer } from "../../worker/project/http.ts";
4import { DiskFirstRuntime } from "../src/disk-first-runtime.ts";
5import { memoryStorage } from "./helpers.ts";
6
7test("disk runtime syncs overlapping edits after a published move", (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 assert.equal(call("move", "alice", { from: "a.txt", to: "b.txt" }).status, 200);
22 assert.equal(call("publish", "alice", { message: "Move" }).status, 200);
23 for (const agent of ["alice", "bob"]) assert.equal(call("sync", agent, {}).status, 200);
24 assert.equal(call("record", "alice", { files: { "b.txt": "one\nalice\nthree\n" } }).status, 200);
25 assert.equal(call("record", "bob", { files: { "b.txt": "one\nbob\nthree\n" } }).status, 200);
26 assert.equal(call("publish", "alice", { message: "alice" }).status, 200);
27 const result = {
28 status: 200,
29 body: runtime().write(
30 (c) => c.sync("bob"),
31 () => {},
32 ),
33 };
34 assert.equal(result.status, 200, JSON.stringify(result));
35 const body = result.body as {
36 version: number;
37 files: Record<string, string>;
38 collisions: { kind: string; marked?: boolean }[];
39 };
40 assert.equal(body.version, 2);
41 assert.equal(body.collisions.length, 1);
42 assert.equal(body.collisions[0]!.kind, "lines");
43 assert.equal(body.collisions[0]!.marked, true);
44 assert.match(body.files["b.txt"]!, /<<<<<<< yours/);
45 assert.match(body.files["b.txt"]!, /bob/);
46 assert.match(body.files["b.txt"]!, /alice/);
47 const repeated = call("sync", "bob", {});
48 assert.equal(repeated.status, 200);
49 assert.equal((repeated.body as typeof body).collisions.length, 1);
50 assert.equal((repeated.body as typeof body).collisions[0]!.marked, true);
51});