{"version":230,"agent":"capacity","message":"Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity).\n\nOn website, with one opened writer, tree with authors took 9.6 s, tree for an agent with authors 9.1 s, and a folder's blame 4.9 s. Replay takes about 0.25 s. Few row reads: the time went on reading the same few large atoms again and again.\n\n- tree with authors, a folder's blame and a file's blame look up each atom's author once per call. graph.atom read and parsed the whole atom for every line, and most lines share a few big atoms.\n- The packed layout keeps each visible line's writer (visWriter), and lines() and buildLines use it instead of looking each line's writer up again.\n- The packed layout reads each atom's lamport number once per layout instead of once per line.\n\nOn website adopted fresh, cold: tree with authors 3.2 s, tree for an agent with authors 4.5 s, a folder's blame 2.4 s; all seven tree and blame answers match replay.\n\nNew test authors-stored: tree with authors (head, an older version, an agent's draft, a folder), folder blame and file blame on a writer-backed project answer as the in-memory one; it fails when the layout records the wrong writer. Named tests: every engine test (288 of 288), authors-stored, history, trail, draft-reads-stored, packed-crossings, version-files, files-reads, view-cache, membership-pages, project (54 of 54); tsc and biome clean.","time":1792055493972,"timeIso":"2026-10-15T09:11:33.972Z","changes":5,"change":3657,"files":["src/engine/view.ts","worker/project/blame.ts","worker/project/history.ts","worker/project/test/authors-stored.test.ts"],"draft":null,"diff":[{"path":"src/engine/view.ts","added":34,"removed":9,"diff":"--- a/src/engine/view.ts\n+++ b/src/engine/view.ts\n@@ -69,6 +69,8 @@\n \treadonly deletedBy: ReadonlyMap<number, readonly number[]>;\n \t/** Its visible lines' text, when laid out from the file's packed history: null for a line too long to pack. */\n \treadonly visText?: readonly (string | null)[];\n+\t/** Its visible lines' writers' seqs, when laid out from the file's packed history. */\n+\treadonly visWriter?: Int32Array;\n \t/** Positions by n, built the first time they're asked for. */\n \tseqIndex?: Map<number, number>;\n \tvisIndex?: Map<number, number>;\n@@ -645,7 +647,18 @@\n \t\tconst files = new Set<number>([-1 - start, ...(this.#movedInFrom().get(path) ?? [])]);\n \t\tconst children = new Map<number, Child[]>();\n \t\tconst texts = new Map<number, string | null>();\n+\t\tconst writers = new Map<number, number>();\n \t\tconst deleters = new Map<number, number[]>();\n+\t\t// Each atom's lamport once per layout: most lines share a few atoms, and a stored graph reads it from a page.\n+\t\tconst lamports = new Map<number, number>();\n+\t\tconst lamportOf = (seq: number): number => {\n+\t\t\tlet lamport = lamports.get(seq);\n+\t\t\tif (lamport === undefined) {\n+\t\t\t\tlamport = graph.lamportOfSeq(seq);\n+\t\t\t\tlamports.set(seq, lamport);\n+\t\t\t}\n+\t\t\treturn lamport;\n+\t\t};\n \t\tfor (const file of files) {\n \t\t\tconst lineTexts = graph.packedTexts(file);\n \t\t\tfor (const [n, parent, seq, k, replaces] of graph.packedLines(file)) {\n@@ -653,16 +666,17 @@\n \t\t\t\tif (!this.#has(seq)) continue;\n \t\t\t\tconst moved = relocs?.get(n);\n \t\t\t\tlet at = parent;\n-\t\t\t\tlet child: Child = { n, replaces, lamport: graph.lamportOfSeq(seq), seq, k };\n+\t\t\t\tlet child: Child = { n, replaces, lamport: lamportOf(seq), seq, k };\n \t\t\t\tif (moved) {\n \t\t\t\t\tconst mover = graph.atom(moved.r.atom).seq;\n-\t\t\t\t\tchild = { n, replaces: 0, lamport: graph.lamportOfSeq(mover), seq: mover, k: moved.r.k };\n+\t\t\t\t\tchild = { n, replaces: 0, lamport: lamportOf(mover), seq: mover, k: moved.r.k };\n \t\t\t\t\tat = moved.parent;\n \t\t\t\t}\n \t\t\t\tconst list = children.get(at);\n \t\t\t\tif (list) list.push(child);\n \t\t\t\telse children.set(at, [child]);\n \t\t\t\ttexts.set(n, text);\n+\t\t\t\twriters.set(n, seq);\n \t\t\t}\n \t\t\tfor (const [n, deleter] of graph.packedDeletes(file)) {\n \t\t\t\tif (!this.#has(deleter)) continue;\n@@ -675,10 +689,11 @@\n \t\t}\n \t\tconst order = (a: Child, b: Child) =>\n \t\t\tb.replaces - a.replaces || b.lamport - a.lamport || b.seq - a.seq || a.k - b.k;\n-\t\tconst priority = (a: number, b: number) => graph.lamportOfSeq(a) - graph.lamportOfSeq(b) || a - b;\n+\t\tconst priority = (a: number, b: number) => lamportOf(a) - lamportOf(b) || a - b;\n \t\tconst seq: number[] = [];\n \t\tconst vis: number[] = [];\n \t\tconst visText: (string | null)[] = [];\n+\t\tconst visWriter: number[] = [];\n \t\tconst deletedBy = new Map<number, readonly number[]>();\n \t\tconst stack: number[] = [];\n \t\tconst push = (code: number) => {\n@@ -696,11 +711,20 @@\n \t\t\t} else {\n \t\t\t\tvis.push(n);\n \t\t\t\tvisText.push(texts.get(n) ?? null);\n+\t\t\t\tvisWriter.push(writers.get(n)!);\n \t\t\t}\n \t\t\tif (complete) seq.push(n);\n \t\t\tpush(n);\n \t\t}\n-\t\treturn { attrs, complete, seq: Int32Array.from(seq), vis: Int32Array.from(vis), deletedBy, visText };\n+\t\treturn {\n+\t\t\tattrs,\n+\t\t\tcomplete,\n+\t\t\tseq: Int32Array.from(seq),\n+\t\t\tvis: Int32Array.from(vis),\n+\t\t\tdeletedBy,\n+\t\t\tvisText,\n+\t\t\tvisWriter: Int32Array.from(visWriter),\n+\t\t};\n \t}\n \n \t#attributes(path: string): FileAttrs {\n@@ -859,8 +883,8 @@\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\t// Texts the packed layout already holds are not read again (abso Capacity).\n-\t\tconst { vis, visText } = this.#file(path);\n+\t\t// Texts and writers the packed layout already holds are not read again (abso Capacity).\n+\t\tconst { vis, visText, visWriter } = 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@@ -871,7 +895,7 @@\n \t\t\t\tget text() {\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\tatom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),\n \t\t\t};\n \t\t}\n \t\treturn lines;\n@@ -881,14 +905,14 @@\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, visText } = this.#file(path);\n+\t\tconst { vis, visText, visWriter } = 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] = {\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\tatom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),\n \t\t\t};\n \t\t}\n \t\tthis.#linesCache = { path, lines };\n@@ -1025,6 +1049,7 @@\n \t\t\t\tn += OBJECT_BYTES + OBJECT_BYTES + 2 * ARRAY_HEADER_BYTES;\n \t\t\t\tn += f.seq.byteLength + f.vis.byteLength;\n \t\t\t\tif (f.visText) for (const text of f.visText) n += REFERENCE_BYTES + 2 * (text?.length ?? 0);\n+\t\t\t\tif (f.visWriter) n += 4 * f.visWriter.length;\n \t\t\t\tn += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + ARRAY_HEADER_BYTES) * f.deletedBy.size;\n \t\t\t\tfor (const deleters of f.deletedBy.values()) n += REFERENCE_BYTES * deleters.length;\n \t\t\t\tif (f.seqIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.seqIndex.size;"},{"path":"worker/project/blame.ts","added":22,"removed":2,"diff":"--- a/worker/project/blame.ts\n+++ b/worker/project/blame.ts\n@@ -91,11 +91,21 @@\n \tconst first = Math.max(1, from ?? 1);\n \tconst last = Math.min(all.length, to ?? all.length);\n \tconst graph = project.graph;\n+\t// Each atom's author once (abso Capacity): on a stored writer, graph.atom reads and parses the whole atom, and\n+\t// most lines share a few big atoms.\n+\tconst authors = new Map<AtomId, string>();\n+\tconst authorOf = (id: AtomId): string => {\n+\t\tconst known = authors.get(id);\n+\t\tif (known !== undefined) return known;\n+\t\tconst author = graph.atom(id).author;\n+\t\tauthors.set(id, author);\n+\t\treturn author;\n+\t};\n \tconst rows: BlameLine[] = all.slice(first - 1, last).map((l, i) => ({\n \t\tn: first + i,\n \t\ttext: l.text,\n \t\tatom: l.atom,\n-\t\tauthor: graph.atom(l.atom).author,\n+\t\tauthor: authorOf(l.atom),\n \t\tversion: project.versionOf(l.atom) ?? null,\n \t\t...(project.publishOf(l.atom) === undefined ? { unpublished: true as const } : {}),\n \t}));\n@@ -380,6 +390,16 @@\n \tconst key = pathKey(want.join(\"/\"));\n \tconst graph = project.graph;\n \tconst counts = new Map<string, number>();\n+\t// Each atom's author once (abso Capacity): on a stored writer, graph.atom reads and parses the whole atom, and\n+\t// most lines share a few big atoms.\n+\tconst authors = new Map<AtomId, string>();\n+\tconst authorOf = (id: AtomId): string => {\n+\t\tconst known = authors.get(id);\n+\t\tif (known !== undefined) return known;\n+\t\tconst author = graph.atom(id).author;\n+\t\tauthors.set(id, author);\n+\t\treturn author;\n+\t};\n \tlet files = 0;\n \tlet total = 0;\n \tlet stored: string | undefined;\n@@ -390,7 +410,7 @@\n \t\tstored ??= parts.slice(0, want.length).join(\"/\");\n \t\tfiles++;\n \t\tfor (const l of view.lines(path)) {\n-\t\t\tconst author = graph.atom(l.atom).author;\n+\t\t\tconst author = authorOf(l.atom);\n \t\t\tcounts.set(author, (counts.get(author) ?? 0) + 1);\n \t\t\ttotal++;\n \t\t}"},{"path":"worker/project/history.ts","added":12,"removed":2,"diff":"--- a/worker/project/history.ts\n+++ b/worker/project/history.ts\n@@ -2,7 +2,7 @@\n // (pathLife), and where lines went (follow). They read through HistoryHost, the one seam the derived tables\n // (abso issues 48 and 79) plug into: today the host is the project in memory.\n \n-import type { Graph, LineId, ReadView } from \"../../src/engine/index.ts\";\n+import type { AtomId, Graph, LineId, ReadView } from \"../../src/engine/index.ts\";\n import { pathKey } from \"./pathkey.ts\";\n import { checkReadPath, differs, type LastChange, ProjectError, utf8Bytes } from \"./project.ts\";\n import { last, SHARED, type Space } from \"./spaces.ts\";\n@@ -121,6 +121,16 @@\n \t\treturn e;\n \t};\n \tconst paths = (agent ? undefined : h.keptPaths?.(space, version)) ?? view.paths();\n+\t// Each atom's author once (abso Capacity): on a stored writer, graph.atom reads and parses the whole atom, and\n+\t// most lines share a few big atoms.\n+\tconst authors = new Map<AtomId, string>();\n+\tconst authorOf = (id: AtomId): string => {\n+\t\tconst known = authors.get(id);\n+\t\tif (known !== undefined) return known;\n+\t\tconst author = graph.atom(id).author;\n+\t\tauthors.set(id, author);\n+\t\treturn author;\n+\t};\n \tfor (const path of paths) {\n \t\tconst e = entryOf(path);\n \t\tif (!e) continue;\n@@ -131,7 +141,7 @@\n \t\tif (options.authors) {\n \t\t\tconst counts = (e.authors ??= new Map());\n \t\t\tfor (const l of view.lines(path)) {\n-\t\t\t\tconst author = graph.atom(l.atom).author;\n+\t\t\t\tconst author = authorOf(l.atom);\n \t\t\t\tcounts.set(author, (counts.get(author) ?? 0) + 1);\n \t\t\t}\n \t\t\tconst blob = view.attrs(path).blob;"},{"path":"worker/project/test/authors-stored.test.ts","added":57,"removed":0,"diff":"--- /dev/null\n+++ b/worker/project/test/authors-stored.test.ts\n@@ -0,0 +1,57 @@\n+// Who wrote what, on a writer-backed project (abso Capacity): tree with authors, a folder's blame and a file's blame\n+// take each line's writer from the packed layout and each atom's author once. They must answer as the in-memory\n+// project does, at the head, at an older version and in an agent's draft.\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 { blame, folderBlame } from \"../blame.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+function history(project: Project) {\n+\tlet t = 0;\n+\tproject.init({ \"src/a.ts\": \"one\\ntwo\\nthree\\n\", \"src/b.ts\": \"b\\n\", \"README.md\": \"readme\\n\" }, t);\n+\tproject.record(\"ann\", { \"src/a.ts\": \"one\\nTWO\\nthree\\nfour\\n\" }, ++t);\n+\tassert.equal(project.publish(\"ann\", \"Ann's lines\", ++t).ok, true);\n+\tproject.sync(\"bob\");\n+\tproject.record(\"bob\", { \"src/b.ts\": \"b\\nbob's\\n\", \"src/c.ts\": \"new\\n\" }, ++t);\n+\tassert.equal(project.publish(\"bob\", \"Bob's lines\", ++t).ok, true);\n+\tproject.sync(\"cy\");\n+\tproject.record(\"cy\", { \"src/a.ts\": \"one\\nTWO\\nthree\\nfour\\nfive\\n\" }, ++t);\n+}\n+\n+test(\"tree with authors and blame read the same from disk as from memory\", () => {\n+\tconst oracle = new Project(new MemoryStore());\n+\tconst project = writer();\n+\thistory(oracle);\n+\thistory(project);\n+\tfor (const options of [{ authors: true }, { authors: true, version: 1 }, { authors: true, agent: \"cy\" }])\n+\t\tassert.deepEqual(project.tree(\"\", options), oracle.tree(\"\", options), JSON.stringify(options));\n+\tassert.deepEqual(project.tree(\"src\", { authors: true }), oracle.tree(\"src\", { authors: true }));\n+\tfor (const [folder, version, where] of [\n+\t\t[\"\", undefined, {}],\n+\t\t[\"src\", 1, {}],\n+\t\t[\"src\", undefined, { agent: \"cy\" }],\n+\t] as const)\n+\t\tassert.deepEqual(folderBlame(project, folder, version, where), folderBlame(oracle, folder, version, where));\n+\tassert.deepEqual(blame(project, \"src/a.ts\"), blame(oracle, \"src/a.ts\"));\n+\tassert.deepEqual(\n+\t\tblame(project, \"src/a.ts\", undefined, undefined, undefined, { agent: \"cy\" }),\n+\t\tblame(oracle, \"src/a.ts\", undefined, undefined, undefined, { agent: \"cy\" }),\n+\t);\n+\tconst authors = oracle.tree(\"\", { authors: true }).entries.find((e) => e.name === \"src\")?.authors ?? [];\n+\tassert.ok(authors.length >= 2, \"more than one author wrote src\");\n+});"}],"ci":null}