{"version":229,"agent":"capacity","message":"Draft collisions without copying shared's atoms per pair (disk-first 2; abso Capacity).\n\nOn typescript-rs, with one opened writer, collisions ran past 5 minutes with 2.5 million row reads; replay takes 5 s.\n\n- Each pair of agents built a new set of all of shared's atoms plus both drafts, and each agent's view of shared-now did the same. On a stored writer that read every one of shared's atoms, per pair, and the view then proved the copy closed by walking it. The pair's set is now a lookup over shared's own atoms and the two drafts (same membership as before). The views are built over shared's view's own closed set plus the drafts, which closes to the same atoms and walks only the drafts.\n- View.lines and buildLines use the texts the packed layout already holds, instead of reading each line's text again.\n- The definition rule takes a line's atom and place from its id, and collisions use graph.lineAtom; graph.line read each line's text as well.\n\nOn typescript-rs adopted fresh, cold: collisions finishes in 71 s with 299,000 reads, matching replay. Still slow: most of what's left is laying the same files out again for each agent's view.\n\nNamed tests: every engine test (288 of 288), changed-definition, collision-streaming, definition-code, definitions, draft-reads-stored, same-line, spelling-clash, review-fixes, membership-pages, stored-closure, packed-crossings, project-writer-storage, writer-adoption, moves, version-files, where-many-agents (67 of 67); tsc and biome clean.","time":1792054426575,"timeIso":"2026-10-15T08:53:46.575Z","changes":3,"change":3649,"files":["src/engine/view.ts","worker/project/definition-rule.ts","worker/project/draft-collisions.ts"],"draft":null,"diff":[{"path":"src/engine/view.ts","added":10,"removed":4,"diff":"--- a/src/engine/view.ts\n+++ b/src/engine/view.ts\n@@ -859,15 +859,17 @@\n \t/** Atom-building line handles; text is loaded only when requested. */\n \tbuildLines(path: string): readonly VisibleLine[] {\n \t\tconst graph = this.graph;\n-\t\tconst vis = this.#file(path).vis;\n+\t\t// Texts the packed layout already holds are not read again (abso Capacity).\n+\t\tconst { vis, visText } = this.#file(path);\n \t\tconst lines: VisibleLine[] = new Array(vis.length);\n \t\tfor (let i = 0; i < vis.length; i++) {\n \t\t\tconst n = vis[i]!;\n+\t\t\tconst packed = visText?.[i];\n \t\t\tlines[i] = {\n \t\t\t\tid: graph.lineIdOf(n),\n \t\t\t\ttextChunks: () => graph.textChunks(n),\n \t\t\t\tget text() {\n-\t\t\t\t\treturn graph.textOf(n);\n+\t\t\t\t\treturn packed ?? graph.textOf(n);\n \t\t\t\t},\n \t\t\t\tatom: graph.idOfSeq(graph.writerSeqOf(n)),\n \t\t\t};\n@@ -879,11 +881,15 @@\n \tlines(path: string): readonly VisibleLine[] {\n \t\tif (this.#linesCache?.path === path) return this.#linesCache.lines;\n \t\tconst graph = this.graph;\n-\t\tconst vis = this.#file(path).vis;\n+\t\tconst { vis, visText } = this.#file(path);\n \t\tconst lines: VisibleLine[] = new Array(vis.length);\n \t\tfor (let i = 0; i < vis.length; i++) {\n \t\t\tconst n = vis[i]!;\n-\t\t\tlines[i] = { id: graph.lineIdOf(n), text: graph.textOf(n), atom: graph.idOfSeq(graph.writerSeqOf(n)) };\n+\t\t\tlines[i] = {\n+\t\t\t\tid: graph.lineIdOf(n),\n+\t\t\t\ttext: visText?.[i] ?? graph.textOf(n),\n+\t\t\t\tatom: graph.idOfSeq(graph.writerSeqOf(n)),\n+\t\t\t};\n \t\t}\n \t\tthis.#linesCache = { path, lines };\n \t\treturn lines;"},{"path":"worker/project/definition-rule.ts","added":7,"removed":5,"diff":"--- a/worker/project/definition-rule.ts\n+++ b/worker/project/definition-rule.ts\n@@ -67,9 +67,11 @@\n \t */\n \t#replacedNames(line: LineId, base: ReadView, runsOf: Map<AtomId, readonly RunEnd[]>): ReadonlySet<string> {\n \t\tconst g = this.#graph;\n-\t\tconst info = g.line(line);\n-\t\tif (!info) return EMPTY_NAMES;\n-\t\tconst atom = g.atom(info.atom);\n+\t\t// The line's atom and place in it from its id (abso Capacity): line() reads its text as well.\n+\t\tif (g.lineN(line) < 0) return EMPTY_NAMES;\n+\t\tconst dot = line.indexOf(\".\");\n+\t\tconst atom = g.atom(line.slice(0, dot));\n+\t\tconst k = Number(line.slice(dot + 1));\n \t\t// Where each of the atom's runs ends, worked out once per check (abso issue 158): reading a run's\n \t\t// lines can mean reading its text back from the log, so not once per line of a big change.\n \t\tlet runs = runsOf.get(atom.id);\n@@ -78,7 +80,7 @@\n \t\t\truns = atom.inserts.map((run) => ({ end: (k += run.lines.length), parent: run.parent }));\n \t\t\trunsOf.set(atom.id, runs);\n \t\t}\n-\t\tconst parent = runs.find((r) => info.k < r.end)?.parent;\n+\t\tconst parent = runs.find((r) => k < r.end)?.parent;\n \t\tif (parent === undefined || parent.startsWith(\"^\") || !g.deletersOf(parent).includes(atom.id)) return EMPTY_NAMES;\n \t\tconst key = `${atom.id} ${parent}`;\n \t\tlet names = this.#replacedCache.get(key);\n@@ -156,7 +158,7 @@\n \t\t\t// Who changed it: newer writers of the new definition's lines, or newer deleters of the old one's.\n \t\t\tconst by = new Set<AtomId>();\n \t\t\tfor (const d of after)\n-\t\t\t\tfor (const line of d.lines) if (newer.has(this.#graph.line(line)!.atom)) by.add(this.#graph.line(line)!.atom);\n+\t\t\t\tfor (const line of d.lines) if (newer.has(this.#graph.lineAtom(line)!)) by.add(this.#graph.lineAtom(line)!);\n \t\t\tfor (const d of before)\n \t\t\t\tfor (const line of d.lines) for (const x of this.#graph.deletersOf(line)) if (newer.has(x)) by.add(x);\n \t\t\tconst first = [...by].sort((p, q) => this.#graph.atom(p).seq - this.#graph.atom(q).seq)[0];"},{"path":"worker/project/draft-collisions.ts","added":33,"removed":6,"diff":"--- a/worker/project/draft-collisions.ts\n+++ b/worker/project/draft-collisions.ts\n@@ -2,6 +2,7 @@\n // is the project in memory.\n \n import { type AtomId, type Graph, parseKey, type ReadView } from \"../../src/engine/index.ts\";\n+import { StableSet, unionOverlay } from \"../../src/engine/state-source.ts\";\n import { claimantsAmong, describeSide, fileOfKey, pairsFrom } from \"./collisions.ts\";\n import type { DefinitionRule } from \"./definition-rule.ts\";\n import { type Definition, definedTwice } from \"./definitions.ts\";\n@@ -37,6 +38,29 @@\n  * top of a file (refused once the second syncs onto the first's work). Exact for shared at `version`; as shared moves on, so can\n  * the answer, as a real publish's would. `file` or `folder` narrows it.\n  */\n+/**\n+ * A set and some drafts' atoms, by lookup (abso Capacity): copying shared's atoms into a new set read every one of them\n+ * from disk on a stored writer, once per pair of agents.\n+ */\n+class WithDrafts extends StableSet<AtomId> {\n+\treadonly retainedBytes: number;\n+\treadonly #base: ReadonlySet<AtomId>;\n+\treadonly #drafts: ReadonlySet<AtomId>;\n+\tconstructor(base: ReadonlySet<AtomId>, drafts: Iterable<AtomId>) {\n+\t\tsuper();\n+\t\tthis.#base = base;\n+\t\tthis.#drafts = new Set(drafts);\n+\t\tthis.retainedBytes = 64 + this.#drafts.size * 32;\n+\t}\n+\thas(atom: AtomId): boolean {\n+\t\treturn this.#drafts.has(atom) || this.#base.has(atom);\n+\t}\n+\t*values(): SetIterator<AtomId> {\n+\t\tyield* this.#base;\n+\t\tfor (const atom of this.#drafts) if (!this.#base.has(atom)) yield atom;\n+\t}\n+}\n+\n export function draftCollisions(\n \thost: DraftCollisionHost,\n \toptions: { file?: string; folder?: string } = {},\n@@ -71,11 +95,14 @@\n \t\tif (!set) draftSets.set(agent, (set = new Set(host.draft(agent))));\n \t\treturn set;\n \t};\n-\t// Shared now with each agent's draft on top, once per agent: the key of a view of a set lists every atom in it.\n+\t// Shared now with each agent's draft on top, once per agent. Over shared's view's own set (abso Capacity): a view's set\n+\t// is closed under dependencies anyway, so shared's closed set and the drafts lay out what shared's atoms and the drafts\n+\t// do, and only the drafts' atoms are walked to close it.\n+\tconst withDraftsView = (...drafts: readonly AtomId[][]) => host.view(unionOverlay(sharedView.set, drafts.flat()));\n \tconst nowViews = new Map<Agent, ReadView>();\n \tconst nowViewOf = (agent: Agent) => {\n \t\tlet view = nowViews.get(agent);\n-\t\tif (!view) nowViews.set(agent, (view = host.view(new Set([...shared, ...host.draft(agent)]))));\n+\t\tif (!view) nowViews.set(agent, (view = withDraftsView(host.draft(agent))));\n \t\treturn view;\n \t};\n \t// Each agent's touched files once, not once per pair (abso Capacity).\n@@ -93,7 +120,7 @@\n \t\t\tconst draftA = host.draft(a);\n \t\t\tconst draftB = host.draft(b);\n \t\t\tconst newer = draftSet(a);\n-\t\t\tconst union = new Set([...shared, ...draftA, ...draftB]);\n+\t\t\tconst union = new WithDrafts(shared, [...draftA, ...draftB]);\n \t\t\tconst viewA = host.agentView(a);\n \t\t\tconst viewB = host.agentView(b);\n \t\t\tif (i < j) {\n@@ -134,15 +161,15 @@\n \t\t\t\tconst mineB = new Set(draftB);\n \t\t\t\tconst filesA = touchedBy(a);\n \t\t\t\tfor (const file of [...touchedBy(b)].filter((f) => filesA.has(f)).toSorted()) {\n-\t\t\t\t\tboth ??= host.view(union);\n+\t\t\t\t\tboth ??= withDraftsView(draftA, draftB);\n \t\t\t\t\tif (!both.hasFile(file)) continue;\n \t\t\t\t\tfor (const [name, defs] of definedTwice(both, file)) {\n-\t\t\t\t\t\tconst by = (mine: Set<AtomId>) => defs.find((d) => d.lines.some((l) => mine.has(host.graph.line(l)!.atom)));\n+\t\t\t\t\t\tconst by = (mine: Set<AtomId>) => defs.find((d) => d.lines.some((l) => mine.has(host.graph.lineAtom(l)!)));\n \t\t\t\t\t\tconst dA = by(mineA);\n \t\t\t\t\t\tconst dB = by(mineB);\n \t\t\t\t\t\tif (!dA || !dB || dA === dB) continue;\n \t\t\t\t\t\tconst atomsOf = (d: Definition, mine: Set<AtomId>) =>\n-\t\t\t\t\t\t\td.lines.map((l) => host.graph.line(l)!.atom).filter((x) => mine.has(x));\n+\t\t\t\t\t\t\td.lines.map((l) => host.graph.lineAtom(l)!).filter((x) => mine.has(x));\n \t\t\t\t\t\tif (atomsOf(dA, mineA).some((x) => atomsOf(dB, mineB).some((y) => paired.has(`${x} ${y}`)))) continue;\n \t\t\t\t\t\tout.push({\n \t\t\t\t\t\t\tkind: \"duplicate\","}],"ci":null}