Lines 21–34 at 318 (were 21–32 at 238)
2121import { withProjectionScratch } from "./projection-scratch.ts"; 2323 type GraphStateStorage, 2425 readonlyStoredArray, 3032} from "./state-source.ts"; 3133import { StoredText } from "./stored-text.ts"; Lines 266–304 at 318 (were 264–270 at 238)
264266export type PackedAttr = [number, string, string | null]; 265267/** A run written in another file under one of a file's lines: [the parent's n, the run's file index]. */ 266268export type PackedCrossing = [number, number]; 271+ * A file's packed history decoded, without texts (Graph.packedHistory): PackedLine's five numbers per line, then 272+ * PackedDelete's two per delete and PackedCrossing's two per crossing, each list flat. 274+export interface PackedHistory { 275+ readonly lines: ArrayLike<number>; 276+ readonly deletes: ArrayLike<number>; 277+ readonly crossings: ArrayLike<number>; 281+ * Bytes of decoded file histories a stored graph keeps between layouts (abso Capacity). Every view of a file read its 282+ * whole history from pages: compare lays each file out once per side, collisions once per draft touching it, and a 283+ * file whose lines moved in from another read that one's history too (abso's worker files, split out of index.ts). 284+ * abso's index.ts, 46,000 lines of history, takes about 1 MB. 286+export const PACKED_HISTORY_BUDGET = 4_000_000; 288+/** Numbers packed flat: 4 bytes each while they fit in 32 bits, else 8. */ 289+function packNumbers(rows: Iterable<readonly number[]>): Int32Array | Float64Array { 290+ const flat: number[] = []; 292+ for (const row of rows) 293+ for (const value of row) { 294+ if ((value | 0) !== value) small = false; 297+ return small ? Int32Array.from(flat) : Float64Array.from(flat); 267299const EMPTY_NUMBERS: readonly number[] = Object.freeze([]); 300+/** At most this many path names kept in memory (Graph.#pathName). */ 301+const PATH_NAMES = 4096; 268302/** Lines longer than this aren't packed with their file; their text is read on its own. */ 269303const PACKED_TEXT = 4096; Lines 387–393 at 318 (were 353–359 at 238)
353387 insertionFormat?: 1; 354388 insertionRuns?: string; 356− listFormat?: 1;
357391 listCount?: number; 358392 lists?: Partial<Record<(typeof listFields)[number], string>>; Lines 399–407 at 318 (were 365–373 at 238)
365399 const encoded = value as unknown as Partial<EncodedAtom>; 366400 if (encoded.textFormat !== undefined && encoded.textFormat !== 1) 367401 throw Error("invalid stored atom text format"); 368− if (encoded.listFormat !== undefined && encoded.listFormat !== 1)
402+ if (encoded.listFormat !== undefined && encoded.listFormat !== 1 && encoded.listFormat !== 2) 369403 throw Error("invalid stored atom list format"); 370− if (encoded.listFormat === 1) {
404+ if (encoded.listFormat === 1 || encoded.listFormat === 2) { 373407 typeof encoded.lists !== "object" || Lines 416–425 at 318 (were 382–388 at 238)
382416 if (encoded.insertionFormat !== undefined && encoded.insertionFormat !== 1) 383417 throw Error("invalid stored insertion format"); 385− encoded.textFormat === 1 || encoded.listFormat === 1 || encoded.insertionFormat === 1
419+ encoded.textFormat === 1 || 420+ encoded.listFormat === 1 || 421+ encoded.listFormat === 2 || 422+ encoded.insertionFormat === 1 388425 if (encoded.insertionFormat === 1 && (!Array.isArray(atom.inserts) || atom.inserts.length !== 0)) Lines 470–480 at 318 (were 433–439 at 238)
433470 if (encoded.insertionFormat === 1) { 434471 const collection = `atom-inserts:${atom.seq}`; 435472 inserts = readonlyStoredArray(storage, collection, (raw, index) => { 436− const run = raw as { file: string; parent: string; lines: string };
473+ const run = raw as { 437478 const lines = `${collection}:lines:${index}`; 438479 if (run.lines !== lines || typeof run.file !== "string" || typeof run.parent !== "string") 439480 throw Error("invalid stored insertion run"); Lines 503–520 at 318 (were 462–474 at 238)
462503 (author) => author, 465− if (encoded.listFormat !== 1 && encoded.insertionFormat !== 1) return streamed(frozen);
506+ if (encoded.listFormat !== 1 && encoded.listFormat !== 2 && encoded.insertionFormat !== 1) 507+ return streamed(frozen); 466508 const result = { ...frozen }; 467509 if (encoded.insertionFormat === 1) { 468510 const collection = `atom-inserts:${atom.seq}`; 469511 if (encoded.insertionRuns !== collection) throw Error("invalid stored insertion reference"); 470512 const inserts = readonlyStoredArray<InsertRun>(storage, collection, (raw, index) => { 471− const run = raw as { file: string; parent: InsertRun["parent"]; lines: string };
513+ const run = raw as { 515+ parent: InsertRun["parent"]; 472518 const lines = `${collection}:lines:${index}`; 473519 if (run.lines !== lines || typeof run.file !== "string" || typeof run.parent !== "string") 474520 throw Error("invalid stored insertion run"); Lines 531–554 at 318 (were 485–498 at 238)
488− Object.defineProperty(result, "inserts", { value: inserts, enumerable: true });
534+ Object.defineProperty(result, "inserts", { 490539 for (const field of listFields) { 491540 const collection = encoded.lists?.[field]; 492541 if (collection === undefined) continue; 493542 if (typeof collection !== "string" || collection !== `atom-list:${atom.seq}:${field}`) 494543 throw Error("invalid stored atom list reference"); 495− Object.defineProperty(result, field, { value: readonlyStoredArray(storage, collection), enumerable: true });
545+ encoded.listFormat === 2 546+ ? readonlyPagedArray(storage, collection) 547+ : readonlyStoredArray(storage, collection); 548+ Object.defineProperty(result, field, { 497553 return streamed(Object.freeze(result)); Lines 558–566 at 318 (were 502–510 at 238)
502558 for (const field of listFields) { 503559 const values = input[field]; 504560 if (!values || values.length <= 256) continue; 561+ // 256 to a row from list format 2 on (abso Capacity); an atom stored before keeps a row per value. 505562 const collection = `atom-list:${input.seq}:${field}`; 506− const saved = storedArray<unknown>(storage, collection);
507− for (const value of values) saved.push(value);
563+ writePagedArray(storage, collection, values); 508564 lists[field] = collection; 509565 Object.defineProperty(atom, field, { value: [], enumerable: true }); Lines 586–606 at 318 (were 530–546 at 238)
530586 lines.push({ text }); 531587 } else lines.push(line); 533− runs.push({ file: run.file, parent: run.parent, lines: lineCollection });
592+ lines: lineCollection, 536596 insertionFormat: 1, 537597 insertionRuns: collection, 538− ...(hasLists ? { listFormat: 1, listCount, lists } : {}),
598+ ...(hasLists ? { listFormat: 2, listCount, lists } : {}), 539599 atom: { ...atom, inserts: [] }, 542602 if (!atom.inserts.some((run) => run.lines.some((line) => line.length > StoredText.chunkCharacters))) 543− return hasLists ? { listFormat: 1, listCount, lists, atom } : atom;
603+ return hasLists ? { listFormat: 2, listCount, lists, atom } : atom; 545605 const inserts = atom.inserts.map((run) => ({ Lines 613–619 at 318 (were 553–559 at 238)
556− ...(hasLists ? { listFormat: 1, listCount, lists } : {}),
616+ ...(hasLists ? { listFormat: 2, listCount, lists } : {}), 557617 atom: { ...atom, inserts }, Lines 636–645 at 318 (were 576–582 at 238)
578638 if (typeof value === "string") return value; 579− const reference = value as unknown as { format: number; text: string };
639+ const reference = value as unknown as { 580643 if (reference?.format !== 1 || typeof reference.text !== "string") throw Error("invalid long line reference"); 581644 return longText.read(reference.text); Lines 663–669 at 318 (were 600–605 at 238)
600663 this.#dependentsPages = storedLists<AtomId>(storage, "dependents"); 601664 this.#resolversPages = storedLists<AtomId>(storage, "resolvers"); 602665 this.#togetherPages = storedLists<TogetherLink>(storage, "together"); 666+ this.#reasonsInPages = storedLists<AtomId>(storage, "reasons-in"); 603667 this.#fileAtomPages = storedLists<AtomId>(storage, "file-atoms"); 604668 this.#runStartPages = storedLists<number>(storage, "run-starts", (key) => 605669 JSON.stringify(["number", Number(key)]), Lines 742–754 at 318 (were 678–683 at 238)
678742 *packedTexts(file: number): IterableIterator<string | null> { 679743 yield* this.#fileTexts!.values(String(file)); 746+ * The texts at positions [page * 256, (page + 1) * 256) of packedTexts(file) (abso Capacity): a layout reads only the 747+ * pages holding a line it shows. 749+ packedTextPage(file: number, page: number): readonly (string | null)[] { 750+ return this.#fileTexts!.pageAt(String(file), page); 681752 *packedDeletes(file: number): IterableIterator<PackedDelete> { 682753 yield* this.#fileDeletes!.values(String(file)); Lines 759–811 at 318 (were 688–693 at 238)
688759 yield* this.#fileCrossings!.values(String(file)); 762+ /** Decoded file histories by path index, most recently used last, under PACKED_HISTORY_BUDGET bytes. */ 763+ readonly #histories = new Map<number, { counts: string; history: PackedHistory; bytes: number }>(); 767+ * A file's line, delete and crossing history, decoded once and kept while it fits (abso Capacity). Kept under its 768+ * three lists' lengths: the lists only grow, and add() lets every kept history go, so a kept one is always whole. 770+ packedHistory(file: number): PackedHistory { 771+ const key = String(file); 772+ const counts = `${this.#fileLines!.length(key)} ${this.#fileDeletes!.length(key)} ${this.#fileCrossings!.length(key)}`; 773+ const kept = this.#histories.get(file); 775+ this.#histories.delete(file); 776+ if (kept.counts === counts) { 777+ this.#histories.set(file, kept); 778+ return kept.history; 780+ this.#historyBytes -= kept.bytes; 782+ const history: PackedHistory = { 783+ lines: packNumbers(this.#fileLines!.values(key)), 784+ deletes: packNumbers(this.#fileDeletes!.values(key)), 785+ crossings: packNumbers(this.#fileCrossings!.values(key)), 788+ (history.lines as Int32Array).byteLength + 789+ (history.deletes as Int32Array).byteLength + 790+ (history.crossings as Int32Array).byteLength + 792+ if (bytes <= PACKED_HISTORY_BUDGET) { 793+ this.#histories.set(file, { counts, history, bytes }); 794+ this.#historyBytes += bytes; 795+ for (const [old, entry] of this.#histories) { 796+ if (this.#historyBytes <= PACKED_HISTORY_BUDGET) break; 797+ this.#histories.delete(old); 798+ this.#historyBytes -= entry.bytes; 804+ /** Bytes of decoded file histories kept (packedHistory). */ 805+ get historyBytes(): number { 806+ return this.#historyBytes; 691809 /** Where an atom's key and delete lists are when the graph doesn't keep them (#46): the stored atom. */ 692810 #lists: ((seq: number) => AtomLists) | undefined; 693811 /** Recently read atoms' lists, most recent last, up to LIST_CACHE atoms. */ Lines 909–924 at 318 (were 791–796 at 238)
791909 #resolversPages: ReturnType<typeof storedLists<AtomId>> | undefined; 792910 #together: StateMap<AtomId, TogetherLink[]> = new Map(); 793911 #togetherPages: ReturnType<typeof storedLists<TogetherLink>> | undefined; 912+ /** The atoms whose reasons point at each atom, in seq order, once each (abso Capacity). */ 913+ #reasonsIn = new Map<AtomId, AtomId[]>(); 914+ #reasonsInPages: ReturnType<typeof storedLists<AtomId>> | undefined; 915+ /** Whether a stored graph keeps reasons-in: from a fresh graph on, worked out when first needed. */ 916+ #reasonsInKnown: boolean | undefined; 917+ get #reasonsInKept(): boolean { 918+ if (!this.#storage) return true; 919+ this.#reasonsInKnown ??= this.#storage.read("reasons-in:meta", "kept") === 1; 920+ return this.#reasonsInKnown; 794922 #fileAtoms: StateMap<string, AtomId[]> = new Map(); 795923 #fileAtomPages: ReturnType<typeof storedLists<AtomId>> | undefined; 796924 /** First lines of runs (their n), by the node they were written after: a line's n, or -1 - a path's index. */ Lines 999–1005 at 318 (were 871–877 at 238)
8721000 atom: this.idOfSeq(seq), 8731001 k: n - this.#lineBase[seq]!, 874− file: this.#paths[this.#lineFile.at(n)]!,
1002+ file: this.#pathName(this.#lineFile.at(n)), 8751003 parent: this.#nodeName(this.#lineParent.at(n)), 8761004 text: this.#text(n), Lines 1020–1026 at 318 (were 892–898 at 238)
8921020 /** The file a line was written in, or undefined: line(id).file without making the record. */ 8931021 lineFile(id: LineId): string | undefined { 8941022 const n = this.#lineN(id); 895− return n < 0 ? undefined : this.#paths[this.#lineFile.at(n)];
1023+ return n < 0 ? undefined : this.#pathName(this.#lineFile.at(n)); 8981026 /** The node a line was written after, or undefined: line(id).parent without making the record. */ Lines 1132–1138 at 318 (were 1004–1010 at 238)
10051133 /** The file line n was written in. */ 10061134 writtenIn(n: number): string { 1007− return this.#paths[this.#lineFile.at(n)]!;
1135+ return this.#pathName(this.#lineFile.at(n)); 10101138 /** The code of the node line n was written after. */ Lines 1295–1324 at 318 (were 1167–1175 at 238)
11691297 #nodeName(code: number): NodeId { 1170− return code >= 0 ? this.#lineName(code) : startNode(this.#paths[-1 - code]!);
1298+ return code >= 0 ? this.#lineName(code) : startNode(this.#pathName(-1 - code)); 1302+ * A path's name by its index, kept in memory once read (abso Capacity): finding a deleted line's file names the file 1303+ * it reaches, and a stored graph read the path list each time. Cleared when the graph accepts an atom, so a name a 1304+ * rolled-back add made never stays. 1306+ #pathName(index: number): string { 1307+ if (this.#pathNamesAt !== this.#accepted) { 1308+ this.#pathNames.clear(); 1309+ this.#pathNamesAt = this.#accepted; 1311+ let name = this.#pathNames.get(index); 1312+ if (name === undefined) { 1313+ name = this.#paths[index]!; 1314+ if (this.#pathNames.size >= PATH_NAMES) this.#pathNames.clear(); 1315+ this.#pathNames.set(index, name); 1319+ readonly #pathNames = new Map<number, string>(); 11731322 #pathOf(file: string): number { 11741323 let p = this.#pathIndex.get(file); 11751324 if (p === undefined) { Lines 1461–1476 at 318 (were 1312–1317 at 238)
13121461 else yield* listOf(this.#resolvers.get(id)); 1465+ * The atoms whose reasons point at this one, in seq order, once each; or undefined when a stored graph made before 1466+ * this index keeps none, and the caller looks at every atom (abso Capacity). 1468+ reasonsTo(id: AtomId): readonly AtomId[] | undefined { 1469+ if (!this.#reasonsInKept) return undefined; 1470+ if (this.#reasonsInPages) return [...this.#reasonsInPages.values(id)]; 1471+ return this.#reasonsIn.get(id) ?? []; 13151474 /** `together` reasons touching this atom, in either direction. */ 13161475 togetherLinks(id: AtomId): readonly TogetherLink[] { 13171476 return [...this.eachTogetherLink(id)]; Lines 1524–1562 at 318 (were 1365–1407 at 238)
13651524 * the search never descends below the target's lamport. 13671526 #reaches(from: Iterable<AtomId>, target: AtomId): boolean { 1368− const floor = this.#lamportAt(this.#seq(target));
1369− if (this.#storage) {
1370− return this.withProjectionScratch((scratch) => {
1371− let length = 0;
1372− const push = (id: AtomId): void => {
1373− if (scratch.read("seen", id)) return;
1374− scratch.write("seen", id, true);
1375− scratch.write("stack", String(length++), id);
1376− };
1377− for (const id of from) {
1378− if (id === target) return true;
1379− if (this.#lamportAt(this.#seq(id)) > floor) push(id);
1380− }
1381− while (length > 0) {
1382− const key = String(--length);
1383− const current = scratch.read("stack", key) as AtomId;
1384− scratch.remove("stack", key);
1385− if (this.#lamportAt(this.#seq(current)) <= floor) continue;
1386− for (const dependency of this.atom(current).deps) {
1387− if (dependency === target) return true;
1388− push(dependency);
1389− }
1390− }
1391− return false;
1392− });
1527+ return this.#reachable(from, new Set([target])).has(target); 1531+ * Which of `targets` are reachable along deps from any of `from` (themselves included), in one walk: it never 1532+ * descends below the lowest target's lamport, and stops once every target is found (abso 714, piece 4: record 1533+ * walked once per line writer). 1534+ * The walk's seen marks and stack are in memory, by atom number: one byte and four bytes an atom at most, so about 1535+ * 62 KB on abso's 12,454 atoms and 50 MB at 10 million, under a Worker's 128 MB. They were scratch rows in storage 1536+ * (abso-core 139, bounding memory with the graph), which cost a read and a write per atom visited: on abso's Oct 14 1537+ * tables, 41,000 of a 1470-shaped record's 77,767 statements. 1539+ #reachable(from: Iterable<AtomId>, targets: ReadonlySet<AtomId>): Set<AtomId> { 1540+ const found = new Set<AtomId>(); 1541+ let floor = Number.POSITIVE_INFINITY; 1542+ for (const target of targets) floor = Math.min(floor, this.#lamportAt(this.#seq(target))); 1543+ const seen = new Uint8Array(this.#atoms.length); 1544+ const stack = new Int32Array(this.#atoms.length); 1546+ const visit = (id: AtomId): void => { 1547+ if (targets.has(id)) found.add(id); 1548+ const seq = this.#seq(id); 1549+ if (seen[seq]) return; 1551+ stack[length++] = seq; 1553+ for (const id of from) visit(id); 1554+ while (length > 0 && found.size < targets.size) { 1555+ const seq = stack[--length]!; 1556+ if (this.#lamportAt(seq) <= floor) continue; 1557+ for (const dependency of this.atom(atomId(seq)).deps) visit(dependency); 1394− const seen = new Set<AtomId>();
1395− const stack = [...from];
1396− while (stack.length > 0) {
1397− const cur = stack.pop()!;
1398− if (cur === target) return true;
1399− if (seen.has(cur)) continue;
1400− seen.add(cur);
1401− if (this.#lamportAt(this.#seq(cur)) <= floor) continue;
1402− for (const d of this.atom(cur).deps) if (!seen.has(d)) stack.push(d);
1403− }
1404− return false;
Lines 1565–1573 at 318 (were 1410–1415 at 238)
14101565 * The atom is frozen. Adding to the graph does not add it to any set. 14121567 add(atom: Atom): void { 1568+ // A new atom appends to its files' histories; a failed one may leave a kept history longer than the lists. 1569+ this.#histories.clear(); 1570+ this.#historyBytes = 0; 14131571 if (this.#storage) 14141572 this.#storage.transaction(() => { 14151573 this.#add(atom); Lines 1581–1590 at 318 (were 1423–1429 at 238)
14231581 #validateAcceptedAtom(atom: Atom, scratch?: GraphStateStorage): void { 14241582 const membership = <T extends string>(name: string): { has(key: T): boolean; add(key: T): unknown } => { 14251583 if (!scratch) return new Set<T>(); 1426− return { has: (key) => scratch.read(name, key) === true, add: (key) => scratch.write(name, key, true) };
1585+ has: (key) => scratch.read(name, key) === true, 1586+ add: (key) => scratch.write(name, key, true), 14281589 validateShape(atom); 14291590 const seq = this.#atoms.length; Lines 1606–1633 at 318 (were 1445–1467 at 238)
14451606 for (const r of atom.reasons) if (!this.has(r.to)) bad(`reason points at unknown atom ${r.to}`); 14471608 // Everything it touches must come from its closure. Derived deps name the 1448− // writers directly, so this is usually one lookup per writer.
1449− const memoryBelow = scratch ? undefined : new Map<AtomId, boolean>();
1450− const below = {
1451− get: (key: AtomId) => (scratch ? (scratch.read("below", key) as boolean | undefined) : memoryBelow!.get(key)),
1452− set: (key: AtomId, value: boolean) => {
1453− if (scratch) scratch.write("below", key, value);
1454− else memoryBelow!.set(key, value);
1455− },
1456− };
1457− const inClosure = (writer: AtomId): boolean => {
1458− let hit = below.get(writer);
1459− if (hit === undefined) {
1460− hit = deps.has(writer) || this.#reaches(atom.deps, writer);
1461− below.set(writer, hit);
1609+ // writers directly, so this is usually one lookup per writer. The writers 1610+ // that aren't deps are walked for together, once (abso 714, piece 4). 1611+ const touched: LineId[] = []; 1612+ for (const run of atom.inserts) if (!isStartNode(run.parent)) touched.push(run.parent); 1613+ for (const m of atom.moves ?? []) { 1614+ touched.push(m.line); 1615+ if (!isStartNode(m.parent)) touched.push(m.parent); 1617+ touched.push(...atom.deletes); 1618+ for (const list of [atom.writes, atom.reads, atom.holds]) 1619+ for (const key of list) { 1620+ const parsed = parseKey(key); 1621+ if (parsed.kind === "line" || ((parsed.kind === "gap" || parsed.kind === "pos") && !isStartNode(parsed.node))) 1622+ touched.push(parsed.node); 1463− return hit;
1464− };
1624+ const beyond = new Set<AtomId>(); 1625+ for (const line of touched) { 1626+ const writer = this.lineAtom(line); 1627+ if (writer !== undefined && !deps.has(writer)) beyond.add(writer); 1629+ const reached = beyond.size > 0 ? this.#reachable(atom.deps, beyond) : beyond; 1630+ const inClosure = (writer: AtomId): boolean => deps.has(writer) || reached.has(writer); 14651631 const checkLine = (line: LineId, what: string): void => { 14661632 const writer = this.lineAtom(line); 14671633 if (writer === undefined) return bad(`${what} names unknown line ${line}`); Lines 1679–1686 at 318 (were 1513–1518 at 238)
15141680 if (this.#storage && this.#atoms.length === 0 && this.#packFiles) { 15151681 this.#storage.write("file-lines:meta", "format", 2); 1682+ this.#storage.write("reasons-in:meta", "kept", 1); 1683+ this.#reasonsInKnown = true; 15161684 this.#formatKnown = 2; Lines 1803–1814 at 318 (were 1635–1641 at 238)
16371805 (frozen.moves ?? []).forEach((m, i) => { 1638− const info: RelocationInfo = Object.freeze({ atom: frozen.id, line: m.line, parent: m.parent, k: i });
1806+ const info: RelocationInfo = Object.freeze({ 16391812 if (this.#relocationPages) this.#relocationPages.append(m.line, info); 16401813 else pushIndex(this.#relocations, m.line, info); 16411814 if (this.#relocatedToPages) this.#relocatedToPages.append(m.parent, info); Lines 1852–1858 at 318 (were 1679–1685 at 238)
16801853 const files = new Set<string>(); 16811854 for (const run of atom.inserts) files.add(run.file); 1682− for (const n of deletedNumbers(this)) files.add(this.#paths[this.#lineFile.at(n)]!);
1855+ for (const n of deletedNumbers(this)) files.add(this.#pathName(this.#lineFile.at(n))); 16831856 for (const a of frozen.attrs ?? []) files.add(a.file); 16841857 for (const m of frozen.moves ?? []) { 16851858 files.add(this.lineFile(m.line)!); Lines 1863–1877 at 318 (were 1690–1695 at 238)
16901863 if (this.#fileAtomPages) this.#fileAtomPages.append(file, frozen.id); 16911864 else pushIndex(this.#fileAtoms, file, frozen.id); 1866+ if (this.#reasonsInKept) { 1867+ const pointed = new Set<AtomId>(); 1868+ for (const r of frozen.reasons) { 1869+ if (pointed.has(r.to)) continue; 1871+ if (this.#reasonsInPages) this.#reasonsInPages.append(r.to, frozen.id); 1872+ else pushIndex(this.#reasonsIn, r.to, frozen.id); 16931875 for (const r of frozen.reasons) { 16941876 if (r.kind !== "together" || r.to === frozen.id) continue; Lines 1956–1967 at 318 (were 1774–1780 at 238)
17741956 // JSON ------------------------------------------------------------------- 17761958 toJSON(): GraphJSON { 1777− return { format: GRAPH_FORMAT, version: 1, atoms: this.#atoms, labels: this.labels() };
1960+ format: GRAPH_FORMAT, 1962+ atoms: this.#atoms, 1963+ labels: this.labels(), 17801967 /** Load a saved graph. Every atom is re-validated as it is added. */ Lines 2061–2072 at 318 (were 1874–1880 at 238)
18742061 // With text kept elsewhere (#46), a run's lines are read when asked for. 18762063 const run = (r: InsertRun): InsertRun => { 1877− if (!text) return Object.freeze({ file: r.file, parent: r.parent, lines: Object.freeze([...r.lines]) });
2065+ return Object.freeze({ 2068+ lines: Object.freeze([...r.lines]), 18782070 const start = k; 18792071 const length = r.lines.length; Lines 2081–2105 at 318 (were 1889–1904 at 238)
18892081 inserts: Object.freeze(atom.inserts.map(run)), 1892− : { deletes: list(atom.deletes), writes: list(atom.writes), reads: list(atom.reads), holds: list(atom.holds) }),
2085+ deletes: list(atom.deletes), 2086+ writes: list(atom.writes), 2087+ reads: list(atom.reads), 2088+ holds: list(atom.holds), 18932090 needs: list(atom.needs, canon), 18942091 resolves: list(atom.resolves, canon), 18952092 reasons: list(atom.reasons, (r) => Object.freeze({ to: canon(r.to), kind: r.kind, text: r.text })), 18962093 deps: list(atom.deps, canon), 18972094 ...(atom.attrs && atom.attrs.length > 0 1898− ? { attrs: Object.freeze(atom.attrs.map((a) => Object.freeze({ file: a.file, name: a.name, value: a.value }))) }
2096+ attrs: Object.freeze(atom.attrs.map((a) => Object.freeze({ file: a.file, name: a.name, value: a.value }))), 1901− ? { moves: Object.freeze(atom.moves.map((m) => Object.freeze({ line: m.line, parent: m.parent }))) }
2101+ moves: Object.freeze(atom.moves.map((m) => Object.freeze({ line: m.line, parent: m.parent }))), 19042105 return Object.freeze(lists ? (new ListedAtom(copy, lists) as unknown as Atom) : copy);