{"draft":null,"from":3,"to":318,"files":[{"path":"server/test/projected-sync.test.ts","added":43,"removed":0,"diff":"--- /dev/null\n+++ b/server/test/projected-sync.test.ts\n@@ -0,0 +1,43 @@\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { answer } from \"../../worker/project/http.ts\";\n+import { DiskFirstRuntime } from \"../src/disk-first-runtime.ts\";\n+import { memoryStorage } from \"./helpers.ts\";\n+\n+test(\"disk runtime syncs overlapping edits without unkeyed membership\", (t) => {\n+\tconst storage = memoryStorage();\n+\tt.after(() => storage.db.close());\n+\tconst runtime = () => new DiskFirstRuntime(storage, \"sync\", \"sync\");\n+\truntime().initialize(\n+\t\t(c) => answer(c, \"init\", undefined, { files: { \"a.txt\": \"one\\ntwo\\nthree\\n\" } }),\n+\t\t() => {},\n+\t);\n+\twhile (!runtime().preparePage(() => {}).ready) {}\n+\tconst call = (op: string, agent: string, body: unknown) =>\n+\t\truntime().write(\n+\t\t\t(c) => answer(c, op, agent, body),\n+\t\t\t() => {},\n+\t\t);\n+\tfor (const agent of [\"alice\", \"bob\"]) assert.equal(call(\"sync\", agent, {}).status, 200);\n+\tassert.equal(call(\"record\", \"alice\", { files: { \"a.txt\": \"one\\nalice\\nthree\\n\" } }).status, 200);\n+\tassert.equal(call(\"record\", \"bob\", { files: { \"a.txt\": \"one\\nbob\\nthree\\n\" } }).status, 200);\n+\tassert.equal(call(\"publish\", \"alice\", { message: \"alice\" }).status, 200);\n+\tconst result = call(\"sync\", \"bob\", {});\n+\tassert.equal(result.status, 200, JSON.stringify(result));\n+\tconst body = result.body as {\n+\t\tversion: number;\n+\t\tfiles: Record<string, string>;\n+\t\tcollisions: { kind: string; marked?: boolean }[];\n+\t};\n+\tassert.equal(body.version, 1);\n+\tassert.equal(body.collisions.length, 1);\n+\tassert.equal(body.collisions[0]!.kind, \"lines\");\n+\tassert.equal(body.collisions[0]!.marked, true);\n+\tassert.match(body.files[\"a.txt\"]!, /<<<<<<< yours/);\n+\tassert.match(body.files[\"a.txt\"]!, /bob/);\n+\tassert.match(body.files[\"a.txt\"]!, /alice/);\n+\tconst repeated = call(\"sync\", \"bob\", {});\n+\tassert.equal(repeated.status, 200);\n+\tassert.equal((repeated.body as typeof body).collisions.length, 1);\n+\tassert.equal((repeated.body as typeof body).collisions[0]!.marked, true);\n+});"}],"unmatched":[]}