F3 SLICE-3: pending-edit registry + sidecar section-merge update (INV-9 groundwork) (#6)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -54,4 +54,38 @@ describe("CoauthorStore", () => {
|
||||
expect(second).toBe(first);
|
||||
expect(first).toBe(serializeArtifact(a));
|
||||
});
|
||||
|
||||
it("update(): two writers merge sections instead of clobbering (F3 §6.2)", () => {
|
||||
const store = new CoauthorStore(root);
|
||||
store.update("d.md", (a) => {
|
||||
a.anchors["a_t"] = { fingerprint: { text: "t", before: "", after: "", lineHint: 0 } };
|
||||
a.threads.push({ id: "t1", anchorId: "a_t", status: "open", messages: [] });
|
||||
});
|
||||
store.update("d.md", (a) => {
|
||||
a.anchors["a_at"] = { fingerprint: { text: "x", before: "", after: "", lineHint: 0 } };
|
||||
a.attributions.push({
|
||||
id: "at1", anchorId: "a_at", author: { kind: "human", id: "ben" },
|
||||
createdAt: "2026-06-10T00:00:00.000Z", updatedAt: "2026-06-10T00:00:00.000Z",
|
||||
});
|
||||
});
|
||||
const loaded = store.load("d.md")!;
|
||||
expect(loaded.threads).toHaveLength(1);
|
||||
expect(loaded.attributions).toHaveLength(1);
|
||||
expect(Object.keys(loaded.anchors).sort()).toEqual(["a_at", "a_t"]);
|
||||
});
|
||||
|
||||
it("update() prunes anchors no longer referenced by threads or attributions", () => {
|
||||
const store = new CoauthorStore(root);
|
||||
store.update("d.md", (a) => {
|
||||
a.anchors["a_old"] = { fingerprint: { text: "o", before: "", after: "", lineHint: 0 } };
|
||||
a.attributions.push({
|
||||
id: "at1", anchorId: "a_old", author: { kind: "human", id: "ben" },
|
||||
createdAt: "2026-06-10T00:00:00.000Z", updatedAt: "2026-06-10T00:00:00.000Z",
|
||||
});
|
||||
});
|
||||
store.update("d.md", (a) => {
|
||||
a.attributions = [];
|
||||
});
|
||||
expect(Object.keys(store.load("d.md")!.anchors)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user