{"version":276,"agent":"capacity","message":"A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB.\n\nEvery view of a file read its whole history from pages again: compare lays each file out once per side, collisions once per draft touching it, and a file whose lines moved in from another reads that one's history too (abso's worker files, split out of index.ts). The history (lines, deletes and crossings, no texts) is decoded once into flat 32-bit arrays, kept under its three lists' lengths, most recently used last, and add() lets every kept history go. abso's index.ts, 46,000 lines of history, takes about 1 MB.\n\nSide by side on abso's export, same machine, two rounds, against 273: cold compare 612 to 1224 from 12.4 s to 5.0-6.5 s, cold collisions from 10.4 s to 5.0-6.9 s, cold where from 4.4 s to 1.5-2.6 s.\n\nTests: packed-files.test.ts adds a test that a kept history saves reads, add() lets it go, and the next layout matches the in-memory graph. tsc and Biome clean; view, state-cache, state-source, graph, graph-long-text, graph-line-chunks, graph-move-write-membership, graph-replacement-membership, graph-insertion-storage, packed-files, definition-code, definitions, changed-definition, collisions-kept-views, draft-reads-stored and collision-streaming pass.","time":1792104390892,"timeIso":"2026-10-15T22:46:30.892Z","changes":3,"change":4147,"files":["src/engine/graph.ts","src/engine/test/packed-files.test.ts","src/engine/view.ts"],"draft":null,"diff":[{"path":"src/engine/graph.ts","added":141,"removed":13,"diff":"--- a/src/engine/graph.ts\n+++ b/src/engine/graph.ts\n@@ -266,6 +266,36 @@\n export type PackedAttr = [number, string, string | null];\n /** A run written in another file under one of a file's lines: [the parent's n, the run's file index]. */\n export type PackedCrossing = [number, number];\n+\n+/**\n+ * A file's packed history decoded, without texts (Graph.packedHistory): PackedLine's five numbers per line, then\n+ * PackedDelete's two per delete and PackedCrossing's two per crossing, each list flat.\n+ */\n+export interface PackedHistory {\n+\treadonly lines: ArrayLike<number>;\n+\treadonly deletes: ArrayLike<number>;\n+\treadonly crossings: ArrayLike<number>;\n+}\n+\n+/**\n+ * Bytes of decoded file histories a stored graph keeps between layouts (abso Capacity). Every view of a file read its\n+ * whole history from pages: compare lays each file out once per side, collisions once per draft touching it, and a\n+ * file whose lines moved in from another read that one's history too (abso's worker files, split out of index.ts).\n+ * abso's index.ts, 46,000 lines of history, takes about 1 MB.\n+ */\n+export const PACKED_HISTORY_BUDGET = 4_000_000;\n+\n+/** Numbers packed flat: 4 bytes each while they fit in 32 bits, else 8. */\n+function packNumbers(rows: Iterable<readonly number[]>): Int32Array | Float64Array {\n+\tconst flat: number[] = [];\n+\tlet small = true;\n+\tfor (const row of rows)\n+\t\tfor (const value of row) {\n+\t\t\tif ((value | 0) !== value) small = false;\n+\t\t\tflat.push(value);\n+\t\t}\n+\treturn small ? Int32Array.from(flat) : Float64Array.from(flat);\n+}\n const EMPTY_NUMBERS: readonly number[] = Object.freeze([]);\n /** At most this many path names kept in memory (Graph.#pathName). */\n const PATH_NAMES = 4096;\n@@ -440,7 +470,11 @@\n \t\t\t\t\t\t\tif (encoded.insertionFormat === 1) {\n \t\t\t\t\t\t\t\tconst collection = `atom-inserts:${atom.seq}`;\n \t\t\t\t\t\t\t\tinserts = readonlyStoredArray(storage, collection, (raw, index) => {\n-\t\t\t\t\t\t\t\t\tconst run = raw as { file: string; parent: string; lines: string };\n+\t\t\t\t\t\t\t\t\tconst run = raw as {\n+\t\t\t\t\t\t\t\t\t\tfile: string;\n+\t\t\t\t\t\t\t\t\t\tparent: string;\n+\t\t\t\t\t\t\t\t\t\tlines: string;\n+\t\t\t\t\t\t\t\t\t};\n \t\t\t\t\t\t\t\t\tconst lines = `${collection}:lines:${index}`;\n \t\t\t\t\t\t\t\t\tif (run.lines !== lines || typeof run.file !== \"string\" || typeof run.parent !== \"string\")\n \t\t\t\t\t\t\t\t\t\tthrow Error(\"invalid stored insertion run\");\n@@ -476,7 +510,11 @@\n \t\t\t\t\t\tconst collection = `atom-inserts:${atom.seq}`;\n \t\t\t\t\t\tif (encoded.insertionRuns !== collection) throw Error(\"invalid stored insertion reference\");\n \t\t\t\t\t\tconst inserts = readonlyStoredArray<InsertRun>(storage, collection, (raw, index) => {\n-\t\t\t\t\t\t\tconst run = raw as { file: string; parent: InsertRun[\"parent\"]; lines: string };\n+\t\t\t\t\t\t\tconst run = raw as {\n+\t\t\t\t\t\t\t\tfile: string;\n+\t\t\t\t\t\t\t\tparent: InsertRun[\"parent\"];\n+\t\t\t\t\t\t\t\tlines: string;\n+\t\t\t\t\t\t\t};\n \t\t\t\t\t\t\tconst lines = `${collection}:lines:${index}`;\n \t\t\t\t\t\t\tif (run.lines !== lines || typeof run.file !== \"string\" || typeof run.parent !== \"string\")\n \t\t\t\t\t\t\t\tthrow Error(\"invalid stored insertion run\");\n@@ -493,7 +531,10 @@\n \t\t\t\t\t\t\t\t}),\n \t\t\t\t\t\t\t});\n \t\t\t\t\t\t});\n-\t\t\t\t\t\tObject.defineProperty(result, \"inserts\", { value: inserts, enumerable: true });\n+\t\t\t\t\t\tObject.defineProperty(result, \"inserts\", {\n+\t\t\t\t\t\t\tvalue: inserts,\n+\t\t\t\t\t\t\tenumerable: true,\n+\t\t\t\t\t\t});\n \t\t\t\t\t}\n \t\t\t\t\tfor (const field of listFields) {\n \t\t\t\t\t\tconst collection = encoded.lists?.[field];\n@@ -504,7 +545,10 @@\n \t\t\t\t\t\t\tencoded.listFormat === 2\n \t\t\t\t\t\t\t\t? readonlyPagedArray(storage, collection)\n \t\t\t\t\t\t\t\t: readonlyStoredArray(storage, collection);\n-\t\t\t\t\t\tObject.defineProperty(result, field, { value: list, enumerable: true });\n+\t\t\t\t\t\tObject.defineProperty(result, field, {\n+\t\t\t\t\t\t\tvalue: list,\n+\t\t\t\t\t\t\tenumerable: true,\n+\t\t\t\t\t\t});\n \t\t\t\t\t}\n \t\t\t\t\treturn streamed(Object.freeze(result));\n \t\t\t\t},\n@@ -542,7 +586,11 @@\n \t\t\t\t\t\t\t\t\tlines.push({ text });\n \t\t\t\t\t\t\t\t} else lines.push(line);\n \t\t\t\t\t\t\t}\n-\t\t\t\t\t\t\truns.push({ file: run.file, parent: run.parent, lines: lineCollection });\n+\t\t\t\t\t\t\truns.push({\n+\t\t\t\t\t\t\t\tfile: run.file,\n+\t\t\t\t\t\t\t\tparent: run.parent,\n+\t\t\t\t\t\t\t\tlines: lineCollection,\n+\t\t\t\t\t\t\t});\n \t\t\t\t\t\t}\n \t\t\t\t\t\treturn {\n \t\t\t\t\t\t\tinsertionFormat: 1,\n@@ -588,7 +636,10 @@\n \t\t\t\t\"line-text\",\n \t\t\t\t(value) => {\n \t\t\t\t\tif (typeof value === \"string\") return value;\n-\t\t\t\t\tconst reference = value as unknown as { format: number; text: string };\n+\t\t\t\t\tconst reference = value as unknown as {\n+\t\t\t\t\t\tformat: number;\n+\t\t\t\t\t\ttext: string;\n+\t\t\t\t\t};\n \t\t\t\t\tif (reference?.format !== 1 || typeof reference.text !== \"string\") throw Error(\"invalid long line reference\");\n \t\t\t\t\treturn longText.read(reference.text);\n \t\t\t\t},\n@@ -708,6 +759,53 @@\n \t\tyield* this.#fileCrossings!.values(String(file));\n \t}\n \n+\t/** Decoded file histories by path index, most recently used last, under PACKED_HISTORY_BUDGET bytes. */\n+\treadonly #histories = new Map<number, { counts: string; history: PackedHistory; bytes: number }>();\n+\t#historyBytes = 0;\n+\n+\t/**\n+\t * A file's line, delete and crossing history, decoded once and kept while it fits (abso Capacity). Kept under its\n+\t * three lists' lengths: the lists only grow, and add() lets every kept history go, so a kept one is always whole.\n+\t */\n+\tpackedHistory(file: number): PackedHistory {\n+\t\tconst key = String(file);\n+\t\tconst counts = `${this.#fileLines!.length(key)} ${this.#fileDeletes!.length(key)} ${this.#fileCrossings!.length(key)}`;\n+\t\tconst kept = this.#histories.get(file);\n+\t\tif (kept) {\n+\t\t\tthis.#histories.delete(file);\n+\t\t\tif (kept.counts === counts) {\n+\t\t\t\tthis.#histories.set(file, kept);\n+\t\t\t\treturn kept.history;\n+\t\t\t}\n+\t\t\tthis.#historyBytes -= kept.bytes;\n+\t\t}\n+\t\tconst history: PackedHistory = {\n+\t\t\tlines: packNumbers(this.#fileLines!.values(key)),\n+\t\t\tdeletes: packNumbers(this.#fileDeletes!.values(key)),\n+\t\t\tcrossings: packNumbers(this.#fileCrossings!.values(key)),\n+\t\t};\n+\t\tconst bytes =\n+\t\t\t(history.lines as Int32Array).byteLength +\n+\t\t\t(history.deletes as Int32Array).byteLength +\n+\t\t\t(history.crossings as Int32Array).byteLength +\n+\t\t\t200;\n+\t\tif (bytes <= PACKED_HISTORY_BUDGET) {\n+\t\t\tthis.#histories.set(file, { counts, history, bytes });\n+\t\t\tthis.#historyBytes += bytes;\n+\t\t\tfor (const [old, entry] of this.#histories) {\n+\t\t\t\tif (this.#historyBytes <= PACKED_HISTORY_BUDGET) break;\n+\t\t\t\tthis.#histories.delete(old);\n+\t\t\t\tthis.#historyBytes -= entry.bytes;\n+\t\t\t}\n+\t\t}\n+\t\treturn history;\n+\t}\n+\n+\t/** Bytes of decoded file histories kept (packedHistory). */\n+\tget historyBytes(): number {\n+\t\treturn this.#historyBytes;\n+\t}\n+\n \t/** Where an atom's key and delete lists are when the graph doesn't keep them (#46): the stored atom. */\n \t#lists: ((seq: number) => AtomLists) | undefined;\n \t/** Recently read atoms' lists, most recent last, up to LIST_CACHE atoms. */\n@@ -1471,6 +1569,9 @@\n \t * The atom is frozen. Adding to the graph does not add it to any set.\n \t */\n \tadd(atom: Atom): void {\n+\t\t// A new atom appends to its files' histories; a failed one may leave a kept history longer than the lists.\n+\t\tthis.#histories.clear();\n+\t\tthis.#historyBytes = 0;\n \t\tif (this.#storage)\n \t\t\tthis.#storage.transaction(() => {\n \t\t\t\tthis.#add(atom);\n@@ -1484,7 +1585,10 @@\n \t#validateAcceptedAtom(atom: Atom, scratch?: GraphStateStorage): void {\n \t\tconst membership = <T extends string>(name: string): { has(key: T): boolean; add(key: T): unknown } => {\n \t\t\tif (!scratch) return new Set<T>();\n-\t\t\treturn { has: (key) => scratch.read(name, key) === true, add: (key) => scratch.write(name, key, true) };\n+\t\t\treturn {\n+\t\t\t\thas: (key) => scratch.read(name, key) === true,\n+\t\t\t\tadd: (key) => scratch.write(name, key, true),\n+\t\t\t};\n \t\t};\n \t\tvalidateShape(atom);\n \t\tconst seq = this.#atoms.length;\n@@ -1698,7 +1802,12 @@\n \t\t\t}\n \t\t}\n \t\t(frozen.moves ?? []).forEach((m, i) => {\n-\t\t\tconst info: RelocationInfo = Object.freeze({ atom: frozen.id, line: m.line, parent: m.parent, k: i });\n+\t\t\tconst info: RelocationInfo = Object.freeze({\n+\t\t\t\tatom: frozen.id,\n+\t\t\t\tline: m.line,\n+\t\t\t\tparent: m.parent,\n+\t\t\t\tk: i,\n+\t\t\t});\n \t\t\tif (this.#relocationPages) this.#relocationPages.append(m.line, info);\n \t\t\telse pushIndex(this.#relocations, m.line, info);\n \t\t\tif (this.#relocatedToPages) this.#relocatedToPages.append(m.parent, info);\n@@ -1846,7 +1955,12 @@\n \t// JSON -------------------------------------------------------------------\n \n \ttoJSON(): GraphJSON {\n-\t\treturn { format: GRAPH_FORMAT, version: 1, atoms: this.#atoms, labels: this.labels() };\n+\t\treturn {\n+\t\t\tformat: GRAPH_FORMAT,\n+\t\t\tversion: 1,\n+\t\t\tatoms: this.#atoms,\n+\t\t\tlabels: this.labels(),\n+\t\t};\n \t}\n \n \t/** Load a saved graph. Every atom is re-validated as it is added. */\n@@ -1946,7 +2060,12 @@\n \t// With text kept elsewhere (#46), a run's lines are read when asked for.\n \tlet k = 0;\n \tconst run = (r: InsertRun): InsertRun => {\n-\t\tif (!text) return Object.freeze({ file: r.file, parent: r.parent, lines: Object.freeze([...r.lines]) });\n+\t\tif (!text)\n+\t\t\treturn Object.freeze({\n+\t\t\t\tfile: r.file,\n+\t\t\t\tparent: r.parent,\n+\t\t\t\tlines: Object.freeze([...r.lines]),\n+\t\t\t});\n \t\tconst start = k;\n \t\tconst length = r.lines.length;\n \t\tk += length;\n@@ -1961,16 +2080,25 @@\n \t\tinserts: Object.freeze(atom.inserts.map(run)),\n \t\t...(lists\n \t\t\t? {}\n-\t\t\t: { deletes: list(atom.deletes), writes: list(atom.writes), reads: list(atom.reads), holds: list(atom.holds) }),\n+\t\t\t: {\n+\t\t\t\t\tdeletes: list(atom.deletes),\n+\t\t\t\t\twrites: list(atom.writes),\n+\t\t\t\t\treads: list(atom.reads),\n+\t\t\t\t\tholds: list(atom.holds),\n+\t\t\t\t}),\n \t\tneeds: list(atom.needs, canon),\n \t\tresolves: list(atom.resolves, canon),\n \t\treasons: list(atom.reasons, (r) => Object.freeze({ to: canon(r.to), kind: r.kind, text: r.text })),\n \t\tdeps: list(atom.deps, canon),\n \t\t...(atom.attrs && atom.attrs.length > 0\n-\t\t\t? { attrs: Object.freeze(atom.attrs.map((a) => Object.freeze({ file: a.file, name: a.name, value: a.value }))) }\n+\t\t\t? {\n+\t\t\t\t\tattrs: Object.freeze(atom.attrs.map((a) => Object.freeze({ file: a.file, name: a.name, value: a.value }))),\n+\t\t\t\t}\n \t\t\t: {}),\n \t\t...(atom.moves\n-\t\t\t? { moves: Object.freeze(atom.moves.map((m) => Object.freeze({ line: m.line, parent: m.parent }))) }\n+\t\t\t? {\n+\t\t\t\t\tmoves: Object.freeze(atom.moves.map((m) => Object.freeze({ line: m.line, parent: m.parent }))),\n+\t\t\t\t}\n \t\t\t: {}),\n \t} as Atom;\n \treturn Object.freeze(lists ? (new ListedAtom(copy, lists) as unknown as Atom) : copy);"},{"path":"src/engine/test/packed-files.test.ts","added":28,"removed":0,"diff":"--- a/src/engine/test/packed-files.test.ts\n+++ b/src/engine/test/packed-files.test.ts\n@@ -54,3 +54,31 @@\n \t\tstorage.db.close();\n \t}\n });\n+\n+test(\"a file's decoded history is kept between views and let go when an atom is added\", () => {\n+\tconst oracle = Repo.init({ \"a.txt\": lines(\"one\", \"two\", \"three\"), \"b.txt\": lines(\"bee\") });\n+\tconst storage = new SqlState();\n+\ttry {\n+\t\tconst graph = new Graph({ storage });\n+\t\tfor (const atom of oracle.graph.atoms()) graph.add(atom);\n+\t\tconst first = new View(graph, new StableOverlaySet(oracle.shared));\n+\t\tassert.equal(first.text(\"a.txt\"), \"one\\ntwo\\nthree\\n\");\n+\t\tassert.ok(graph.historyBytes > 0, \"the first layout keeps a.txt's history\");\n+\t\t// Another view of the same file reads only what its membership needs, not the history's pages again.\n+\t\tconst before = storage.reads;\n+\t\tassert.equal(new View(graph, new StableOverlaySet(oracle.shared)).sequence(\"a.txt\").length, 3);\n+\t\tconst pages = storage.reads - before;\n+\t\tconst cold = new Graph({ storage });\n+\t\tconst coldBefore = storage.reads;\n+\t\tnew View(cold, new StableOverlaySet(oracle.shared)).sequence(\"a.txt\");\n+\t\tassert.ok(pages < storage.reads - coldBefore, \"the kept history saved reads\");\n+\t\t// A new atom lets every kept history go; the next layout sees its lines.\n+\t\toracle.edit({ edits: [{ file: \"a.txt\", old: \"two\", new: \"TWO\" }] });\n+\t\tgraph.add(oracle.graph.atom([...oracle.shared].at(-1)!));\n+\t\tassert.equal(graph.historyBytes, 0);\n+\t\tconst after = new View(graph, new StableOverlaySet(oracle.shared));\n+\t\tassert.equal(after.text(\"a.txt\"), new View(oracle.graph, oracle.shared).text(\"a.txt\"));\n+\t} finally {\n+\t\tstorage.db.close();\n+\t}\n+});"},{"path":"src/engine/view.ts","added":89,"removed":17,"diff":"--- a/src/engine/view.ts\n+++ b/src/engine/view.ts\n@@ -64,7 +64,12 @@\n \tsameText(path: string, other: ReadView): boolean;\n };\n \n-const NO_ATTRS: FileAttrs = { exists: false, exec: false, link: null, blob: null };\n+const NO_ATTRS: FileAttrs = {\n+\texists: false,\n+\texec: false,\n+\tlink: null,\n+\tblob: null,\n+};\n \n /**\n  * A file layout's bytes, less its lookup indexes, worked out once per layout (abso Capacity): a layout never changes\n@@ -123,7 +128,13 @@\n }\n \n const EMPTY_INTS = new Int32Array(0);\n-const NO_FILE: FileState = { attrs: NO_ATTRS, complete: true, seq: EMPTY_INTS, vis: EMPTY_INTS, deletedBy: new Map() };\n+const NO_FILE: FileState = {\n+\tattrs: NO_ATTRS,\n+\tcomplete: true,\n+\tseq: EMPTY_INTS,\n+\tvis: EMPTY_INTS,\n+\tdeletedBy: new Map(),\n+};\n \n /** A count of file uses shared by every view, so a cache can tell which layout across its views was used longest ago. */\n let fileUses = 0;\n@@ -173,7 +184,10 @@\n \treadonly #graph: Graph;\n \t#seen = 0;\n \t/** Movers in seq order, with the numbers of the lines each moves, in its moves' order. */\n-\treadonly movers: { readonly seq: number; readonly lines: readonly number[] }[] = [];\n+\treadonly movers: {\n+\t\treadonly seq: number;\n+\t\treadonly lines: readonly number[];\n+\t}[] = [];\n \t/** Every relocation of each moved line, by the line's number, in seq order. */\n \treadonly byLine = new Map<number, MoveEntry[]>();\n \treadonly #climbed = new Map<number, number>();\n@@ -197,7 +211,12 @@\n \t\t\tconst lines: number[] = [];\n \t\t\tgraph.atom(id).moves!.forEach((m, k) => {\n \t\t\t\tconst n = graph.lineN(m.line);\n-\t\t\t\tconst r: RelocationInfo = Object.freeze({ atom: id, line: m.line, parent: m.parent, k });\n+\t\t\t\tconst r: RelocationInfo = Object.freeze({\n+\t\t\t\t\tatom: id,\n+\t\t\t\t\tline: m.line,\n+\t\t\t\t\tparent: m.parent,\n+\t\t\t\t\tk,\n+\t\t\t\t});\n \t\t\t\tconst entry: MoveEntry = { n, r, parent: graph.codeOf(m.parent)! };\n \t\t\t\tconst list = this.byLine.get(n);\n \t\t\t\tif (list) list.push(entry);\n@@ -525,7 +544,10 @@\n \t\tif (this.#relocsN) return this.#relocsN;\n \t\tconst out = new Map<number, { readonly r: RelocationInfo; readonly parent: number }>();\n \t\tfor (const [line, r] of this.#relocations())\n-\t\t\tout.set(this.graph.lineN(line), { r, parent: this.graph.codeOf(r.parent)! });\n+\t\t\tout.set(this.graph.lineN(line), {\n+\t\t\t\tr,\n+\t\t\t\tparent: this.graph.codeOf(r.parent)!,\n+\t\t\t});\n \t\tthis.#relocsN = out;\n \t\treturn out;\n \t}\n@@ -627,7 +649,13 @@\n \t\tfor (const n of graph.eachChildN(code)) {\n \t\t\tconst seq = graph.writerSeqOf(n);\n \t\t\tif (!this.#has(seq) || relocs?.has(n)) continue;\n-\t\t\tout.push({ n, replaces: graph.replacesN(n) ? 1 : 0, lamport: graph.lamportOfSeq(seq), seq, k: graph.kOf(n) });\n+\t\t\tout.push({\n+\t\t\t\tn,\n+\t\t\t\treplaces: graph.replacesN(n) ? 1 : 0,\n+\t\t\t\tlamport: graph.lamportOfSeq(seq),\n+\t\t\t\tseq,\n+\t\t\t\tk: graph.kOf(n),\n+\t\t\t});\n \t\t}\n \t\tif (relocs) {\n \t\t\t// The lines this set's moves put under each node, from the moves it already resolved: no row read per node\n@@ -643,7 +671,13 @@\n \t\t\tfor (const n of this.#movedInto.get(code) ?? NO_LINES) {\n \t\t\t\tconst r = relocs.get(n)!.r;\n \t\t\t\tconst seq = graph.atom(r.atom).seq;\n-\t\t\t\tout.push({ n, replaces: 0, lamport: graph.lamportOfSeq(seq), seq, k: r.k });\n+\t\t\t\tout.push({\n+\t\t\t\t\tn,\n+\t\t\t\t\treplaces: 0,\n+\t\t\t\t\tlamport: graph.lamportOfSeq(seq),\n+\t\t\t\t\tseq,\n+\t\t\t\t\tk: r.k,\n+\t\t\t\t});\n \t\t\t}\n \t\t}\n \t\t// A line's replacements (runs of atoms that deleted it) first, then the\n@@ -751,7 +785,14 @@\n \t\tconst graph = this.graph;\n \t\tconst attrs = this.#attributes(path);\n \t\tconst start = graph.startCodeOf(path);\n-\t\tif (start === undefined) return { attrs, complete, seq: EMPTY_INTS, vis: EMPTY_INTS, deletedBy: new Map() };\n+\t\tif (start === undefined)\n+\t\t\treturn {\n+\t\t\t\tattrs,\n+\t\t\t\tcomplete,\n+\t\t\t\tseq: EMPTY_INTS,\n+\t\t\t\tvis: EMPTY_INTS,\n+\t\t\t\tdeletedBy: new Map(),\n+\t\t\t};\n \t\tconst relocs = this.#hasMoves ? this.#relocationsN() : undefined;\n \t\tconst files = new Set<number>([-1 - start, ...(this.#movedInFrom().get(path) ?? [])]);\n \t\tconst children = new Map<number, Child[]>();\n@@ -774,16 +815,28 @@\n \t\t\treturn lamport;\n \t\t};\n \t\tfor (const file of files) {\n-\t\t\tlet place = -1;\n-\t\t\tfor (const [n, parent, seq, k, replaces] of graph.packedLines(file)) {\n-\t\t\t\tplace++;\n+\t\t\t// The file's history decoded once and kept by the graph (abso Capacity): each view of it read every page again.\n+\t\t\tconst history = graph.packedHistory(file);\n+\t\t\tconst lines = history.lines;\n+\t\t\tfor (let i = 0, place = 0; i < lines.length; i += 5, place++) {\n+\t\t\t\tconst n = lines[i]!;\n+\t\t\t\tconst parent = lines[i + 1]!;\n+\t\t\t\tconst seq = lines[i + 2]!;\n+\t\t\t\tconst k = lines[i + 3]!;\n+\t\t\t\tconst replaces = lines[i + 4]!;\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: 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: lamportOf(mover), seq: mover, k: moved.r.k };\n+\t\t\t\t\tchild = {\n+\t\t\t\t\t\tn,\n+\t\t\t\t\t\treplaces: 0,\n+\t\t\t\t\t\tlamport: lamportOf(mover),\n+\t\t\t\t\t\tseq: mover,\n+\t\t\t\t\t\tk: moved.r.k,\n+\t\t\t\t\t};\n \t\t\t\t\tat = moved.parent;\n \t\t\t\t}\n \t\t\t\tconst list = children.get(at);\n@@ -794,14 +847,18 @@\n \t\t\t\twriters.set(n, seq);\n \t\t\t\tplaces.set(n, k);\n \t\t\t}\n-\t\t\tfor (const [n, deleter] of graph.packedDeletes(file)) {\n+\t\t\tconst dels = history.deletes;\n+\t\t\tfor (let at = 0; at < dels.length; at += 2) {\n+\t\t\t\tconst n = dels[at]!;\n+\t\t\t\tconst deleter = dels[at + 1]!;\n \t\t\t\tif (!this.#has(deleter)) continue;\n \t\t\t\tconst by = deleters.get(n);\n \t\t\t\tif (by) by.push(deleter);\n \t\t\t\telse deleters.set(n, [deleter]);\n \t\t\t}\n \t\t\t// Runs written elsewhere under this file's lines follow them; the loop reads their files too.\n-\t\t\tfor (const [parent, into] of graph.packedCrossings(file)) if (writers.has(parent)) files.add(into);\n+\t\t\tconst crossings = history.crossings;\n+\t\t\tfor (let at = 0; at < crossings.length; at += 2) if (writers.has(crossings[at]!)) files.add(crossings[at + 1]!);\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@@ -925,7 +982,13 @@\n \t\t\tif (complete) seq.push(n);\n \t\t}\n \n-\t\treturn { attrs, complete, seq: Int32Array.from(seq), vis: Int32Array.from(vis), deletedBy };\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};\n \t}\n \n \tget #known(): string[] {\n@@ -1039,7 +1102,11 @@\n \t*visibleLines(path: string): IterableIterator<VisibleLine> {\n \t\tconst graph = this.graph;\n \t\tfor (const n of this.#file(path).vis)\n-\t\t\tyield { id: graph.lineIdOf(n), text: graph.textOf(n), atom: graph.idOfSeq(graph.writerSeqOf(n)) };\n+\t\t\tyield {\n+\t\t\t\tid: graph.lineIdOf(n),\n+\t\t\t\ttext: graph.textOf(n),\n+\t\t\t\tatom: graph.idOfSeq(graph.writerSeqOf(n)),\n+\t\t\t};\n \t}\n \n \t/** Atom-building line handles; text is loaded only when requested. */\n@@ -1258,7 +1325,12 @@\n \t * Each laid-out file: its layout, when it was last used (a count shared by every view) and what it holds, for a\n \t * cache that trims the least recently used layouts across its views before whole views (views.ts, abso Capacity).\n \t */\n-\t*laidOut(): IterableIterator<{ path: string; layout: object; used: number; bytes: number }> {\n+\t*laidOut(): IterableIterator<{\n+\t\tpath: string;\n+\t\tlayout: object;\n+\t\tused: number;\n+\t\tbytes: number;\n+\t}> {\n \t\tfor (const [path, f] of this.#files) {\n \t\t\tif (f === NO_FILE) continue;\n \t\t\tlet bytes = 2 * MAP_ENTRY_BYTES + layoutBytes(f);"}],"ci":null}