touchedBeyond, with named tests for 235's wrong draft diff (disk-first 2; abso Capacity). Version 237 of shared· capacity· Oct 15 (2026-10-15 11:55 UTC) · Not checked
236 fixed the wrong diff Disk-first Testing found on typescript-rs with 235 (cloud-ts-01's diff showed lib.rs and passes.rs from its older base). This moves that fix into a named function with its own tests, as Agent VCS asked.
collisions.ts touchedBeyond(graph, below, mine, views): the files a view over below plus mine can lay out differently from below, or undefined when any of it moves lines. It counts mine and whatever mine depends on that below lacks, since a view's set is closed. Project.#agentView's shareFiles uses it. touched-beyond.test.ts: a publish's tie writes no files, but it depends on the published change. Counted from version 0 its files include the changed file, which 235's count (the atoms alone) missed. A move beyond the base turns sharing off. agent-views-shared.test.ts adds a merge-queue landing with a move, then more drafting in the moved-to file. Checks: typescript-rs adopted fresh, diff for cloud-ts-01 matches replay (it differs on 235). Every worker/project test (341 of 341) and every engine test; tsc and biome clean.
Version 236 · Files at version 237
4 files, 106 lines added, 14 removed.
--- a/worker/project/collisions.ts
+++ b/worker/project/collisions.ts
@@ -293,6 +293,30 @@
297 + * The files a view over `below` plus `mine` can lay out differently from `below` (abso Capacity, View.shareFiles), or 298 + * undefined when any of it moves lines. A view's set is closed under dependencies, so it holds `mine` and whatever 299 + * `mine` depends on that `below` lacks; each of those can change a file, so all of them count. Counting `mine` alone 300 + * missed the files of work the draft depends on (Testing's typescript-rs diff for cloud-ts-01, core 235). 302 + export function touchedBeyond( 304 + below: ReadonlySet<AtomId>, 305 + mine: Iterable<AtomId>, 306 + views: readonly ReadView[], 307 + ): Set<string> | undefined { 308 + const beyond = new Set<AtomId>(); 309 + const stack = [...mine]; 310 + while (stack.length) { 311 + const id = stack.pop()!; 312 + if (beyond.has(id) || below.has(id)) continue; 314 + for (const dep of g.atom(id).deps) if (!beyond.has(dep) && !below.has(dep)) stack.push(dep); 316 + for (const id of beyond) if ((g.atom(id).moves?.length ?? 0) > 0) return undefined; 317 + return touchedFiles(g, beyond, views); 296 320 /** The atom's visible lines in a file of a view, or where it acted when none are left. */ 297 321 export function describeSide(view: ReadView, atom: AtomId, file: string, keys: readonly string[]): CollisionSide { 298 322 const visible = view.lines(file); --- a/worker/project/project.ts
+++ b/worker/project/project.ts
@@ -58,6 +58,7 @@
62 63 } from "./collisions.ts"; 63 64 import { type DefinitionCollision, DefinitionRule } from "./definition-rule.ts"; @@ -2748,20 +2749,7 @@
2748 2749 // view holds beyond its base is the draft and whatever the draft depends on that the base lacks (the view's 2749 2750 // set is closed): each of those can change a file, so all of them count. 2750 2751 const mine = agent.mine; 2751 − view.shareFiles(base, () => {
2752 − const graph = this.#graph;
2753 − const below = base.set;
2754 − const beyond = new Set<AtomId>();
2755 − const stack = [...mine];
2756 − while (stack.length) {
2757 − const id = stack.pop()!;
2758 − if (beyond.has(id) || below.has(id)) continue;
2759 − beyond.add(id);
2760 − for (const dep of graph.atom(id).deps) if (!beyond.has(dep) && !below.has(dep)) stack.push(dep);
2761 − }
2762 − for (const id of beyond) if ((graph.atom(id).moves?.length ?? 0) > 0) return undefined;
2763 − return this.#touchedFiles(beyond, [base, view]);
2764 − });
2752 + view.shareFiles(base, () => touchedBeyond(this.#graph, base.set, mine, [base, view])); --- a/worker/project/test/agent-views-shared.test.ts
+++ b/worker/project/test/agent-views-shared.test.ts
@@ -68,3 +68,46 @@
68 68 assert.doesNotMatch(String(read(oracle, "cy")["src/geometry.ts"]), /const pi/); 69 69 assert.deepEqual(project.tree("", { agent: "cy", authors: true }), oracle.tree("", { agent: "cy", authors: true })); 72 + // A push landed through the merge queue whose delete and write of the same text became a move, by an agent whose base 73 + // stays older than the landing, then more drafting in the moved-to file: the diff and every file read as in memory. 74 + // (Here the move is among the agent's own atoms, so nothing is shared; touched-beyond.test.ts covers work held only 76 + function landedWithMoves(project: Project) { 78 + project.checkerReady = true; 81 + "avcs.json": `${JSON.stringify({ queue: true })}\n`, 82 + "src/shapes.ts": `// shapes\n${AREA}`, 83 + "src/geometry.ts": "// geometry\n", 84 + "notes.md": "notes\n", 90 + const land = (agent: string, message: string) => { 91 + const queued = project.publish(agent, message, ++t); 92 + assert.ok(queued.ok && "queued" in queued, JSON.stringify(queued)); 93 + project.queueChecking(queued.queued); 94 + project.queueLand(queued.queued, ++t); 96 + project.record("bob", { "notes.md": "notes\nbob\n" }, ++t); 97 + land("bob", "Notes"); 98 + project.edit("ann", { file: "src/shapes.ts", old: AREA, new: "" }, ++t); 99 + project.edit("ann", { file: "src/geometry.ts", content: `// geometry\n${AREA}` }, ++t); 100 + project.record("ann", { "README.md": "readme\n" }, ++t); 101 + land("ann", "Move area, add a readme"); 102 + project.edit("ann", { file: "src/geometry.ts", old: "3.14", new: "Math.PI" }, ++t); 103 + project.edit("ann", { file: "README.md", content: "readme\nmore\n" }, ++t); 106 + test("a draft's diff takes nothing from its base that its landed work holds by dependency", () => { 107 + const oracle = new Project(new MemoryStore()); 108 + const project = writer(); 109 + landedWithMoves(oracle); 110 + landedWithMoves(project); 111 + assert.deepEqual(project.diffOf("ann"), oracle.diffOf("ann")); 112 + assert.deepEqual(read(project, "ann"), read(oracle, "ann")); --- /dev/null
+++ b/worker/project/test/touched-beyond.test.ts
@@ -0,0 +1,37 @@
1 + // The files a draft's view can't take from its base (abso Capacity, touchedBeyond): everything the view holds beyond 2 + // the base counts, not only the draft's own atoms. A view's set is closed under dependencies, so an atom the agent 3 + // holds can bring in work the base lacks, as a publish's tie does. Core 235 counted the agent's atoms alone and showed 4 + // such files at the older base (Testing's typescript-rs diff for cloud-ts-01). 6 + import assert from "node:assert/strict"; 7 + import { test } from "node:test"; 8 + import { touchedBeyond, touchedFiles } from "../collisions.ts"; 9 + import { MemoryStore, Project } from "../project.ts"; 11 + test("files changed by work the agent's atoms depend on count, not only the atoms' own", () => { 12 + const project = new Project(new MemoryStore()); 13 + project.init({ "a.txt": "a\n", "b.txt": "b\n" }, 0); 14 + project.record("ann", { "b.txt": "b\nmore\n" }, 1); 15 + assert.equal(project.publish("ann", "More b", 2).ok, true); 16 + const graph = project.graph; 17 + const tie = graph.idOfSeq(graph.size - 1); 18 + assert.deepEqual([...graph.filesOf(tie)], [], "a tie writes no files itself"); 19 + const base = project.viewAt(0); 20 + const view = project.viewAt(1); 21 + // Counted alone, the tie touches nothing, and b.txt would be taken from version 0. 22 + assert.deepEqual([...touchedFiles(graph, [tie], [base, view])], []); 23 + assert.deepEqual([...(touchedBeyond(graph, base.set, [tie], [base, view]) ?? [])], ["b.txt"]); 24 + // Counted from version 1, which holds the change, nothing is beyond it. 25 + assert.deepEqual([...(touchedBeyond(graph, view.set, [tie], [view]) ?? [])], []); 28 + test("nothing is shared when anything beyond the base moves lines", () => { 29 + const project = new Project(new MemoryStore()); 30 + project.init({ "a.txt": "one\ntwo\nthree\n", "b.txt": "b\n" }, 0); 31 + project.move("ann", "a.txt", "c.txt", 1); 32 + assert.equal(project.publish("ann", "Move a to c", 2).ok, true); 33 + const graph = project.graph; 34 + const tie = graph.idOfSeq(graph.size - 1); 35 + const base = project.viewAt(0); 36 + assert.equal(touchedBeyond(graph, base.set, [tie], [base, project.viewAt(1)]), undefined);