{"version":218,"agent":"capacity","message":"why on a stored writer (disk-first 2; abso Capacity).\n\n- A View reads atoms' numbers from their ids instead of reading each atom: building one from a plain set read every atom twice, and every mover once.\n- keptThrough, the settle a line was kept through, looks only among the atoms that write or take out the file's lines (graph.eachAtomIn), and lays out the file just before that settle from a lazy prefix of the view's set when that set is closed. It used to read every atom in the history and list all the earlier ones.\n- publishOf looks in shared before listing the named drafts, since listing them decodes each one's space.\n- view.ts loses #eachMover, unused since 215.\n\nOn abso's export, why for line 1 of issues/src/index.ts went from 41 s to 11 s on one opened writer, matching Project.load. The rest is trail's search for a moved line's origin among nearby changes.\n\nNamed tests: trail, named-drafts, files-reads, project, markers, version-files, draft-reads-stored, view, moves, drop (109 of 109); tsc and biome clean.","time":1792041717647,"timeIso":"2026-10-15T05:21:57.647Z","changes":3,"change":3572,"files":["src/engine/view.ts","worker/project/blame.ts","worker/project/publish-of.ts"],"draft":null,"diff":[{"path":"src/engine/view.ts","added":8,"removed":11,"diff":"--- a/src/engine/view.ts\n+++ b/src/engine/view.ts\n@@ -242,23 +242,24 @@\n \t\t\treturn;\n \t\t}\n \t\tconst inSet = new Uint8Array(graph.size);\n-\t\tfor (const id of set) {\n-\t\t\tconst atom = graph.atom(id);\n-\t\t\tinSet[atom.seq] = 1;\n-\t\t}\n+\t\t// An atom's number is in its id (abso Capacity): reading the atom for it read the whole history on a stored graph.\n+\t\tconst seqIn = (id: AtomId): number => {\n+\t\t\tconst seq = seqOf(id);\n+\t\t\treturn seq >= 0 && seq < inSet.length && graph.idOfSeq(seq) === id ? seq : graph.atom(id).seq;\n+\t\t};\n+\t\tfor (const id of set) inSet[seqIn(id)] = 1;\n \t\t// Validate one atom at a time. Keeping all decoded atoms here defeats\n \t\t// storage-backed Graph reads even though the view only needs membership.\n \t\tfor (let seq = 0; seq < inSet.length; seq++) {\n \t\t\tif (inSet[seq] !== 1) continue;\n \t\t\tconst atom = graph.atom(graph.idOfSeq(seq));\n \t\t\tfor (const d of atom.deps) {\n-\t\t\t\tif (inSet[graph.atom(d).seq] !== 1)\n-\t\t\t\t\tthrow new EngineError(\"not-closed\", `set is not closed: ${atom.id} depends on ${d}`);\n+\t\t\t\tif (inSet[seqIn(d)] !== 1) throw new EngineError(\"not-closed\", `set is not closed: ${atom.id} depends on ${d}`);\n \t\t\t}\n \t\t}\n \t\tthis.graph = graph;\n \t\tthis.#in = inSet;\n-\t\tthis.#movers = graph.movers().filter((id) => inSet[graph.atom(id).seq] === 1);\n+\t\tthis.#movers = graph.movers().filter((id) => inSet[seqOf(id)] === 1);\n \t\tthis.#hasMoves = this.#movers.length > 0;\n \t\tthis.#relocs = this.#movers.length === 0 ? new Map() : undefined;\n \t\tthis.#relocsN = this.#movers.length === 0 ? new Map() : undefined;\n@@ -459,10 +460,6 @@\n \thasMoves(): boolean {\n \t\treturn this.#hasMoves;\n \t}\n-\t*#eachMover(): IterableIterator<AtomId> {\n-\t\tif (this.#movers) yield* this.#movers;\n-\t\telse for (const id of this.graph.movers()) if (this.#stable!.has(id)) yield id;\n-\t}\n \n \t/** The file a line is in, in this set: the one its chain of parents reaches. */\n \tfileOf(line: LineId): string {"},{"path":"worker/project/blame.ts","added":39,"removed":9,"diff":"--- a/worker/project/blame.ts\n+++ b/worker/project/blame.ts\n@@ -4,7 +4,8 @@\n // shared, with its message. Why adds the change's reasons, what it settled,\n // and the reasons other changes give that point at it, and the line's\n // earlier changes (trail.ts).\n-import { type Atom, type AtomId, type LineId, type ReadView, View } from \"../../src/engine/index.ts\";\n+import { type Atom, type AtomId, type LineId, type ReadView, seqOf, View } from \"../../src/engine/index.ts\";\n+import { isClosedSet, markClosed, StableSet } from \"../../src/engine/state-source.ts\";\n import { blocksIn, isMarkerLine } from \"./markers.ts\";\n import { pathKey } from \"./pathkey.ts\";\n import type { Project } from \"./project.ts\";\n@@ -126,21 +127,28 @@\n function keptThrough(project: Project, view: ReadView, file: string, line: LineId, author: Atom): Atom | undefined {\n \tconst graph = project.graph;\n \tconst set = view.set;\n-\tfor (const s of graph.atoms()) {\n-\t\tif (s.seq <= author.seq || s.resolves.length === 0 || !set.has(s.id)) continue;\n+\t// Only atoms that write or take out the file's lines can take out its markers (abso Capacity): every atom in the\n+\t// history was read on a stored graph.\n+\tfor (const id of graph.eachAtomIn(file)) {\n+\t\tif (seqOf(id) <= author.seq) continue;\n+\t\tconst s = graph.atom(id);\n+\t\tif (s.resolves.length === 0 || !set.has(s.id)) continue;\n \t\tconst marks = s.deletes.filter((id) => {\n \t\t\tconst info = graph.line(id);\n \t\t\treturn info !== undefined && info.file === file && isMarkerLine(info.text);\n \t\t});\n \t\tif (marks.length === 0) continue;\n-\t\t// The file just before the settle, markers and all.\n+\t\t// The file just before the settle, markers and all: of a closed set, its atoms before the settle, which a\n+\t\t// stored set answers one by one; otherwise listed.\n \t\tconst before = new View(\n \t\t\tgraph,\n-\t\t\tgraph\n-\t\t\t\t.atoms()\n-\t\t\t\t.slice(0, s.seq)\n-\t\t\t\t.filter((a) => set.has(a.id))\n-\t\t\t\t.map((a) => a.id),\n+\t\t\tisClosedSet(set)\n+\t\t\t\t? markClosed(new BeforeSet(set, s.seq))\n+\t\t\t\t: graph\n+\t\t\t\t\t\t.atoms()\n+\t\t\t\t\t\t.slice(0, s.seq)\n+\t\t\t\t\t\t.filter((a) => set.has(a.id))\n+\t\t\t\t\t\t.map((a) => a.id),\n \t\t);\n \t\tif (!before.hasFile(file)) continue;\n \t\tconst lines = before.lines(file);\n@@ -152,6 +160,28 @@\n \treturn undefined;\n }\n \n+/** A set's atoms numbered below a limit. Atoms depend only on earlier ones, so a closed set's prefix is closed. */\n+class BeforeSet extends StableSet<AtomId> {\n+\treadonly #set: ReadonlySet<AtomId>;\n+\treadonly #limit: number;\n+\treadonly retainedBytes = 32;\n+\tconstructor(set: ReadonlySet<AtomId>, limit: number) {\n+\t\tsuper();\n+\t\tthis.#set = set;\n+\t\tthis.#limit = limit;\n+\t}\n+\thas(id: AtomId): boolean {\n+\t\tconst seq = seqOf(id);\n+\t\treturn seq >= 0 && seq < this.#limit && this.#set.has(id);\n+\t}\n+\t*values(): SetIterator<AtomId> {\n+\t\tfor (const id of this.#set) {\n+\t\t\tconst seq = seqOf(id);\n+\t\t\tif (seq >= 0 && seq < this.#limit) yield id;\n+\t\t}\n+\t}\n+}\n+\n /** The settler's push that was held for this collision, newest first: its message is that side's reason. */\n function heldPush(project: Project, settle: Atom, file: string, after: number) {\n \tconst held = project"},{"path":"worker/project/publish-of.ts","added":6,"removed":5,"diff":"--- a/worker/project/publish-of.ts\n+++ b/worker/project/publish-of.ts\n@@ -18,11 +18,12 @@\n \thost: PublishOfHost,\n \tatom: AtomId,\n ): { draft: string | null; version: number; agent: string; message: string; time: number } | undefined {\n-\tconst spaces = [\n-\t\thost.shared(),\n-\t\t...[...host.spaces.values()].filter((s) => s.name !== SHARED).toSorted((a, b) => (a.name < b.name ? -1 : 1)),\n-\t];\n-\tfor (const space of spaces) {\n+\t// Shared first, and the named drafts only when it isn't there: listing them reads each one's space.\n+\tconst spaces = function* (): Generator<Space> {\n+\t\tyield host.shared();\n+\t\tyield* [...host.spaces.values()].filter((s) => s.name !== SHARED).toSorted((a, b) => (a.name < b.name ? -1 : 1));\n+\t};\n+\tfor (const space of spaces()) {\n \t\tconst version = space.publishedIn.get(atom);\n \t\tif (version === undefined) continue;\n \t\tconst p = space.versions[version]!;"}],"ci":null}