{"version":235,"agent":"capacity","message":"A draft's view takes its base view's layout of every file the draft doesn't touch (disk-first 2; abso Capacity).\n\nAn agent's tree, files and folder blame lay out every file in the agent's view, and tree also lays out the base to see which files the draft changed. Each layout read the file's packed history again, though every file the draft doesn't touch lays out exactly as in the draft's base.\n\n- View.shareFiles(from, except): a view lays out a file by taking from's layout of it, unless the file is in except. except is worked out once, when a file is first needed.\n- Project.#agentView sets it for a draft's view over its base's when the draft moves nothing (its moves are then the base's, as shareMoves already relies on). The touched files are touchedFiles over the draft's atoms, in both views: the files they write, delete in, set attributes on, and, where moves count, the files their deleted lines and their runs' parents sit in.\n\nOn abso adopted fresh, one kept writer: an agent's tree with authors 23.4 s to 12 to 14 s. It's still slow because a whole abso layout is bigger than the views' byte budget, so it isn't kept between calls.\n\nNew test agent-views-shared: after a published move of a function into another file, drafts that edit a moved line, delete one, change another file, set an attribute, or move lines themselves each read every file (text, attributes, writers) as the in-memory project does, read twice; it fails when the touched files are taken from where lines were written only. Named tests: every engine test (288 of 288), every worker/project test (338 of 338); typescript-rs, all 27 answers match replay; tsc and biome clean.","time":1792064261947,"timeIso":"2026-10-15T11:37:41.947Z","changes":3,"change":3685,"files":["src/engine/view.ts","worker/project/project.ts","worker/project/test/agent-views-shared.test.ts"],"draft":null,"diff":[{"path":"src/engine/view.ts","added":25,"removed":2,"diff":"--- a/src/engine/view.ts\n+++ b/src/engine/view.ts\n@@ -49,7 +49,7 @@\n /** Structural read boundary shared by historical and transaction-bound projections. */\n export type ReadView = Omit<\n \tPick<View, keyof View>,\n-\t\"sameText\" | \"visibleCount\" | \"shareMoves\" | \"fileOfNumber\" | \"lineNumberOf\" | \"visibleWriters\"\n+\t\"sameText\" | \"visibleCount\" | \"shareMoves\" | \"shareFiles\" | \"fileOfNumber\" | \"lineNumberOf\" | \"visibleWriters\"\n > & {\n \tsameText(path: string, other: ReadView): boolean;\n };\n@@ -389,6 +389,27 @@\n \t\tthis.#movesFrom = from;\n \t}\n \n+\t/**\n+\t * Files laid out as another view lays them out (abso Capacity): a draft's view over its base's, for every file the\n+\t * draft doesn't touch. The caller knows what the draft is; `except` is asked once, when a file is first needed, for\n+\t * the files the draft touches, or undefined when nothing can be shared (a draft that moves lines). Without it, an\n+\t * agent's tree, files and blame laid out every file of the project again for each agent.\n+\t */\n+\tshareFiles(from: View, except: () => ReadonlySet<string> | undefined): void {\n+\t\tif (from.graph !== this.graph || from === this || this.#filesFrom !== undefined) return;\n+\t\tthis.#filesFrom = { from, except };\n+\t}\n+\t#filesFrom: { from: View; except: () => ReadonlySet<string> | undefined } | null | undefined;\n+\t#filesShared: { from: View; except: ReadonlySet<string> } | null | undefined;\n+\t#sharedFiles(): { from: View; except: ReadonlySet<string> } | null {\n+\t\tif (this.#filesShared === undefined) {\n+\t\t\tconst share = this.#filesFrom;\n+\t\t\tconst except = share ? share.except() : undefined;\n+\t\t\tthis.#filesShared = share && except ? { from: share.from, except } : null;\n+\t\t}\n+\t\treturn this.#filesShared;\n+\t}\n+\n \t#takeShared(): void {\n \t\tconst from = this.#movesFrom;\n \t\tif (!from) return;\n@@ -1104,7 +1125,9 @@\n \t#file(path: string, complete = false): FileState {\n \t\tlet state = this.#files.get(path);\n \t\tif (!state || (complete && !state.complete)) {\n-\t\t\tstate = this.graph.hasAtomsIn(path) ? this.#layout(path, complete) : NO_FILE;\n+\t\t\tconst shared = this.#filesFrom === undefined ? null : this.#sharedFiles();\n+\t\t\tif (shared && !shared.except.has(path)) state = shared.from.#file(path, complete);\n+\t\t\telse state = this.graph.hasAtomsIn(path) ? this.#layout(path, complete) : NO_FILE;\n \t\t\tthis.#files.set(path, state);\n \t\t}\n \t\treturn state;"},{"path":"worker/project/project.ts","added":10,"removed":1,"diff":"--- a/worker/project/project.ts\n+++ b/worker/project/project.ts\n@@ -2742,7 +2742,16 @@\n \t\t// A draft that moves nothing resolves its moves as its base does (abso Capacity): take them from the base's view.\n \t\tif (this.#writerStorage && agent.mine.length > 0 && view instanceof View) {\n \t\t\tconst base = this.#viewAt(this.#spaceOf(agent), agent.base);\n-\t\t\tif (base instanceof View) view.shareMoves(base);\n+\t\t\tif (base instanceof View) {\n+\t\t\t\tview.shareMoves(base);\n+\t\t\t\t// And its layout of every file the draft doesn't touch, when the draft moves nothing (abso Capacity).\n+\t\t\t\tconst mine = agent.mine;\n+\t\t\t\tview.shareFiles(base, () =>\n+\t\t\t\t\tmine.some((id) => (this.#graph.atom(id).moves?.length ?? 0) > 0)\n+\t\t\t\t\t\t? undefined\n+\t\t\t\t\t\t: this.#touchedFiles(mine, [base, view]),\n+\t\t\t\t);\n+\t\t\t}\n \t\t}\n \t\treturn view;\n \t}"},{"path":"worker/project/test/agent-views-shared.test.ts","added":70,"removed":0,"diff":"--- /dev/null\n+++ b/worker/project/test/agent-views-shared.test.ts\n@@ -0,0 +1,70 @@\n+// A draft's view takes its base view's layout of every file the draft doesn't touch (abso Capacity, View.shareFiles).\n+// On a writer-backed project every agent's view must still read every file as the in-memory project does: a draft\n+// that edits lines moved into another file by a published move, one that deletes such a line, one that only sets an\n+// attribute, and one that moves lines itself (which shares nothing).\n+\n+import assert from \"node:assert/strict\";\n+import { test } from \"node:test\";\n+import { storedArray } from \"../../../src/engine/state-source.ts\";\n+import { SqlState } from \"../../../src/engine/test/storage-helper.ts\";\n+import { MemoryStore, Project } from \"../project.ts\";\n+import type { Entry, ProjectStore } from \"../project-types.ts\";\n+\n+function writer() {\n+\tconst storage = new SqlState();\n+\tconst entries = storedArray<Entry>(storage, \"canonical-log\");\n+\tconst store: ProjectStore = {\n+\t\tappend(batch) {\n+\t\t\tfor (const entry of batch) entries.push(entry);\n+\t\t},\n+\t};\n+\treturn new Project(store, { writerStorage: storage });\n+}\n+\n+const AREA = \"export function area(r: number) {\\n  const pi = 3.14;\\n  return pi * r * r;\\n}\\n\";\n+const FILES = {\n+\t\"src/shapes.ts\": `// shapes\\n${AREA}\\nexport function other() {\\n  return 1;\\n}\\n`,\n+\t\"src/geometry.ts\": \"// geometry\\n\",\n+\t\"src/plain.ts\": \"one\\ntwo\\nthree\\n\",\n+\t\"run.sh\": \"echo hi\\n\",\n+\t\"README.md\": \"readme\\n\",\n+};\n+\n+function history(project: Project) {\n+\tlet t = 0;\n+\tproject.init(FILES, t);\n+\t// ann moves area() into geometry.ts and publishes: its lines were written in shapes.ts.\n+\tproject.edit(\"ann\", { file: \"src/shapes.ts\", old: AREA, new: \"\" }, ++t);\n+\tproject.edit(\"ann\", { file: \"src/geometry.ts\", content: `// geometry\\n${AREA}` }, ++t);\n+\tassert.equal(project.publish(\"ann\", \"Move area to geometry\", ++t).ok, true);\n+\tfor (const agent of [\"bob\", \"cy\", \"dee\", \"eve\", \"fay\"]) project.sync(agent);\n+\t// bob edits a moved line, cy deletes one, dee touches only plain.ts, eve sets an attribute, fay moves lines.\n+\tproject.edit(\"bob\", { file: \"src/geometry.ts\", old: \"3.14\", new: \"Math.PI\" }, ++t);\n+\tproject.edit(\"cy\", { file: \"src/geometry.ts\", old: \"  const pi = 3.14;\\n\", new: \"\" }, ++t);\n+\tproject.record(\"dee\", { \"src/plain.ts\": \"one\\nTWO\\nthree\\n\" }, ++t);\n+\tproject.record(\"eve\", {}, ++t, { \"run.sh\": { exec: true } });\n+\tproject.edit(\"fay\", { file: \"src/plain.ts\", old: \"one\\ntwo\\nthree\\n\", new: \"\" }, ++t);\n+\tproject.edit(\"fay\", { file: \"src/moved.ts\", content: \"one\\ntwo\\nthree\\n\" }, ++t);\n+}\n+\n+const read = (project: Project, agent: string) => {\n+\tconst view = project.draftOf(agent)!.view;\n+\tconst out: Record<string, unknown> = {};\n+\tfor (const path of view.paths()) out[path] = [view.text(path), view.attrs(path), view.lines(path).map((l) => l.atom)];\n+\treturn out;\n+};\n+\n+test(\"every agent's view reads every file as the in-memory project's, with files shared from the base\", () => {\n+\tconst oracle = new Project(new MemoryStore());\n+\tconst project = writer();\n+\thistory(oracle);\n+\thistory(project);\n+\tfor (const agent of [\"ann\", \"bob\", \"cy\", \"dee\", \"eve\", \"fay\"]) {\n+\t\t// Twice: the second read takes the shared layouts the first one made.\n+\t\tassert.deepEqual(read(project, agent), read(oracle, agent), agent);\n+\t\tassert.deepEqual(read(project, agent), read(oracle, agent), `${agent} again`);\n+\t}\n+\tassert.match(String(read(oracle, \"bob\")[\"src/geometry.ts\"]), /Math\\.PI/);\n+\tassert.doesNotMatch(String(read(oracle, \"cy\")[\"src/geometry.ts\"]), /const pi/);\n+\tassert.deepEqual(project.tree(\"\", { agent: \"cy\", authors: true }), oracle.tree(\"\", { agent: \"cy\", authors: true }));\n+});"}],"ci":null}