{"file":"src/engine/view.ts","version":318,"total":1373,"from":1,"to":1373,"lines":[{"n":1,"text":"// Projection: the files a closed set of atoms produces. A pure function of the","atom":"a0","author":"init","version":0},{"n":2,"text":"// set. Each file is a tree of lines hanging off its start node; linearizing it","atom":"a0","author":"init","version":0},{"n":3,"text":"// depth-first, children in descending priority, gives the file's sequence. A","atom":"a0","author":"init","version":0},{"n":4,"text":"// line hangs off the node it was written after, unless a move in the set gave","atom":"a0","author":"init","version":0},{"n":5,"text":"// it another parent (#28): then the newest such move decides.","atom":"a0","author":"init","version":0},{"n":6,"text":"//","atom":"a0","author":"init","version":0},{"n":7,"text":"// A laid-out file is kept as arrays of line numbers (the graph's n), not as a","atom":"a0","author":"init","version":0},{"n":8,"text":"// record per line (#46): a record, its id and two index entries cost about","atom":"a0","author":"init","version":0},{"n":9,"text":"// 370 bytes a line, and the view cache holds up to 200,000 lines. Records are","atom":"a0","author":"init","version":0},{"n":10,"text":"// made when a caller asks for them, and the latest asked for is kept.","atom":"a0","author":"init","version":0},{"n":11,"text":"","atom":"a0","author":"init","version":0},{"n":12,"text":"import type { Graph, RelocationInfo } from \"./graph.ts\";","atom":"a0","author":"init","version":0},{"n":13,"text":"import { atomId, isStartNode, lineId, seqOf } from \"./keys.ts\";","atom":"a3014","author":"capacity","version":317},{"n":14,"text":"import { resolveScratchMoves, scratchLayoutNodes } from \"./relocation-scratch.ts\";","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":15,"text":"import { isClosedSet, StableSet } from \"./state-source.ts\";","atom":"a2302","author":"capacity","version":205},{"n":16,"text":"import { joinLines } from \"./text.ts\";","atom":"a0","author":"init","version":0},{"n":17,"text":"import { type AtomId, type AtomSet, EngineError, type LineId, type NodeId } from \"./types.ts\";","atom":"a0","author":"init","version":0},{"n":18,"text":"","atom":"a0","author":"init","version":0},{"n":19,"text":"/** A line in a file's full sequence, tombstones included. */","atom":"a0","author":"init","version":0},{"n":20,"text":"export interface SeqLine {","atom":"a0","author":"init","version":0},{"n":21,"text":"\treadonly id: LineId;","atom":"a0","author":"init","version":0},{"n":22,"text":"\treadonly text: string;","atom":"a0","author":"init","version":0},{"n":23,"text":"\t/** The atom that wrote it. */","atom":"a0","author":"init","version":0},{"n":24,"text":"\treadonly atom: AtomId;","atom":"a0","author":"init","version":0},{"n":25,"text":"\t/** Atoms in the set that delete it, by seq. Empty when it is visible. */","atom":"a0","author":"init","version":0},{"n":26,"text":"\treadonly deletedBy: readonly AtomId[];","atom":"a0","author":"init","version":0},{"n":27,"text":"\treadonly visible: boolean;","atom":"a0","author":"init","version":0},{"n":28,"text":"}","atom":"a0","author":"init","version":0},{"n":29,"text":"","atom":"a0","author":"init","version":0},{"n":30,"text":"/** A visible line of a projected file. */","atom":"a0","author":"init","version":0},{"n":31,"text":"export interface VisibleLine {","atom":"a0","author":"init","version":0},{"n":32,"text":"\treadonly textChunks?: () => Iterable<string>;","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":33,"text":"\treadonly id: LineId;","atom":"a0","author":"init","version":0},{"n":34,"text":"\treadonly text: string;","atom":"a0","author":"init","version":0},{"n":35,"text":"\treadonly atom: AtomId;","atom":"a0","author":"init","version":0},{"n":36,"text":"}","atom":"a0","author":"init","version":0},{"n":37,"text":"","atom":"a0","author":"init","version":0},{"n":38,"text":"/** A file's attributes in a view. */","atom":"a0","author":"init","version":0},{"n":39,"text":"export interface FileAttrs {","atom":"a0","author":"init","version":0},{"n":40,"text":"\t/** Kept with no lines (an empty file). */","atom":"a0","author":"init","version":0},{"n":41,"text":"\treadonly exists: boolean;","atom":"a0","author":"init","version":0},{"n":42,"text":"\treadonly exec: boolean;","atom":"a0","author":"init","version":0},{"n":43,"text":"\t/** The target, when the file is a symbolic link. */","atom":"a0","author":"init","version":0},{"n":44,"text":"\treadonly link: string | null;","atom":"a0","author":"init","version":0},{"n":45,"text":"\t/** The SHA-256 of its bytes, when the file is binary. */","atom":"a0","author":"init","version":0},{"n":46,"text":"\treadonly blob: string | null;","atom":"a0","author":"init","version":0},{"n":47,"text":"}","atom":"a0","author":"init","version":0},{"n":48,"text":"","atom":"a0","author":"init","version":0},{"n":49,"text":"/** Structural read boundary shared by historical and transaction-bound projections. */","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":50,"text":"export type ReadView = Omit<","atom":"a2350","author":"capacity","version":212},{"n":51,"text":"\tPick<View, keyof View>,","atom":"a2350","author":"capacity","version":212},{"n":52,"text":"\t| \"sameText\"","atom":"a2498","author":"capacity","version":245},{"n":53,"text":"\t| \"visibleCount\"","atom":"a2498","author":"capacity","version":245},{"n":54,"text":"\t| \"shareMoves\"","atom":"a2498","author":"capacity","version":245},{"n":55,"text":"\t| \"shareFiles\"","atom":"a2498","author":"capacity","version":245},{"n":56,"text":"\t| \"knowPaths\"","atom":"a2498","author":"capacity","version":245},{"n":57,"text":"\t| \"laidOut\"","atom":"a2668","author":"capacity","version":263},{"n":58,"text":"\t| \"forget\"","atom":"a2668","author":"capacity","version":263},{"n":59,"text":"\t| \"placedDifferently\"","atom":"a2676","author":"capacity","version":266},{"n":60,"text":"\t| \"fileOfNumber\"","atom":"a2498","author":"capacity","version":245},{"n":61,"text":"\t| \"lineNumberOf\"","atom":"a2498","author":"capacity","version":245},{"n":62,"text":"\t| \"visibleWriters\"","atom":"a2498","author":"capacity","version":245},{"n":63,"text":"> & {","atom":"a2350","author":"capacity","version":212},{"n":64,"text":"\tsameText(path: string, other: ReadView): boolean;","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":65,"text":"};","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":66,"text":"","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":67,"text":"const NO_ATTRS: FileAttrs = {","atom":"a2736","author":"capacity","version":276},{"n":68,"text":"\texists: false,","atom":"a2736","author":"capacity","version":276},{"n":69,"text":"\texec: false,","atom":"a2736","author":"capacity","version":276},{"n":70,"text":"\tlink: null,","atom":"a2736","author":"capacity","version":276},{"n":71,"text":"\tblob: null,","atom":"a2736","author":"capacity","version":276},{"n":72,"text":"};","atom":"a2736","author":"capacity","version":276},{"n":73,"text":"","atom":"a2473","author":"capacity","version":241},{"n":74,"text":"/**","atom":"a2473","author":"capacity","version":241},{"n":75,"text":" * A file layout's bytes, less its lookup indexes, worked out once per layout (abso Capacity): a layout never changes","atom":"a2473","author":"capacity","version":241},{"n":76,"text":" * once made, and the view cache weighs every view it holds on every lookup, which summed every line's text again.","atom":"a2473","author":"capacity","version":241},{"n":77,"text":" */","atom":"a2473","author":"capacity","version":241},{"n":78,"text":"const layoutSizes = new WeakMap<FileState, number>();","atom":"a2473","author":"capacity","version":241},{"n":79,"text":"function layoutBytes(f: FileState): number {","atom":"a2473","author":"capacity","version":241},{"n":80,"text":"\tlet n = layoutSizes.get(f);","atom":"a2473","author":"capacity","version":241},{"n":81,"text":"\tif (n !== undefined) return n;","atom":"a2473","author":"capacity","version":241},{"n":82,"text":"\t// FileState and FileAttrs are per laid-out file; typed-array headers are separate from their payload byte lengths.","atom":"a2473","author":"capacity","version":241},{"n":83,"text":"\tn = OBJECT_BYTES + OBJECT_BYTES + 2 * ARRAY_HEADER_BYTES;","atom":"a2473","author":"capacity","version":241},{"n":84,"text":"\tn += f.seq.byteLength + f.vis.byteLength;","atom":"a2473","author":"capacity","version":241},{"n":85,"text":"\tif (f.visText) for (const text of f.visText) n += REFERENCE_BYTES + (text === null ? 0 : stringBytes(text));","atom":"a2519","author":"capacity","version":247},{"n":86,"text":"\tif (f.visWriter) n += 4 * f.visWriter.length;","atom":"a2473","author":"capacity","version":241},{"n":87,"text":"\tif (f.visK) n += 4 * f.visK.length;","atom":"a2473","author":"capacity","version":241},{"n":88,"text":"\tif (f.seqWriter) n += 4 * f.seqWriter.length;","atom":"a2473","author":"capacity","version":241},{"n":89,"text":"\tif (f.seqK) n += 4 * f.seqK.length;","atom":"a2473","author":"capacity","version":241},{"n":90,"text":"\tn += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + ARRAY_HEADER_BYTES) * f.deletedBy.size;","atom":"a2473","author":"capacity","version":241},{"n":91,"text":"\tfor (const deleters of f.deletedBy.values()) n += REFERENCE_BYTES * deleters.length;","atom":"a2473","author":"capacity","version":241},{"n":92,"text":"\tlayoutSizes.set(f, n);","atom":"a2473","author":"capacity","version":241},{"n":93,"text":"\treturn n;","atom":"a2473","author":"capacity","version":241},{"n":94,"text":"}","atom":"a2473","author":"capacity","version":241},{"n":95,"text":"const NONE: readonly never[] = Object.freeze([]);","atom":"a0","author":"init","version":0},{"n":96,"text":"","atom":"a0","author":"init","version":0},{"n":97,"text":"interface FileState {","atom":"a0","author":"init","version":0},{"n":98,"text":"\treadonly attrs: FileAttrs;","atom":"a0","author":"init","version":0},{"n":99,"text":"\t/** Full history is retained only when a sequence caller explicitly requests it. */","atom":"a1006","author":"codex-capacity-chair","version":110},{"n":100,"text":"\treadonly complete: boolean;","atom":"a1006","author":"codex-capacity-chair","version":110},{"n":101,"text":"\t/** The file's sequence, tombstones included: each line's n. */","atom":"a0","author":"init","version":0},{"n":102,"text":"\treadonly seq: Int32Array;","atom":"a0","author":"init","version":0},{"n":103,"text":"\t/** Its visible lines' n, in order. */","atom":"a0","author":"init","version":0},{"n":104,"text":"\treadonly vis: Int32Array;","atom":"a0","author":"init","version":0},{"n":105,"text":"\t/** For each deleted position in seq: the seqs of the atoms in the set that delete it, by priority. */","atom":"a0","author":"init","version":0},{"n":106,"text":"\treadonly deletedBy: ReadonlyMap<number, readonly number[]>;","atom":"a0","author":"init","version":0},{"n":107,"text":"\t/** Its visible lines' text, when laid out from the file's packed history: null for a line too long to pack. */","atom":"a2312","author":"capacity","version":206},{"n":108,"text":"\treadonly visText?: readonly (string | null)[];","atom":"a2312","author":"capacity","version":206},{"n":109,"text":"\t/** Its visible lines' writers' seqs, when laid out from the file's packed history. */","atom":"a2436","author":"capacity","version":230},{"n":110,"text":"\treadonly visWriter?: Int32Array;","atom":"a2436","author":"capacity","version":230},{"n":111,"text":"\t/** Its visible lines' places in their writers (a line id's k), when laid out from packed history. */","atom":"a2443","author":"capacity","version":232},{"n":112,"text":"\treadonly visK?: Int32Array;","atom":"a2443","author":"capacity","version":232},{"n":113,"text":"\t/** The same for every line of seq, when complete and laid out from packed history. */","atom":"a2443","author":"capacity","version":232},{"n":114,"text":"\treadonly seqWriter?: Int32Array;","atom":"a2443","author":"capacity","version":232},{"n":115,"text":"\treadonly seqK?: Int32Array;","atom":"a2443","author":"capacity","version":232},{"n":116,"text":"\t/** Positions by n, built the first time they're asked for. */","atom":"a0","author":"init","version":0},{"n":117,"text":"\tseqIndex?: Map<number, number>;","atom":"a0","author":"init","version":0},{"n":118,"text":"\tvisIndex?: Map<number, number>;","atom":"a0","author":"init","version":0},{"n":119,"text":"}","atom":"a0","author":"init","version":0},{"n":120,"text":"","atom":"a0","author":"init","version":0},{"n":121,"text":"interface Child {","atom":"a0","author":"init","version":0},{"n":122,"text":"\treadonly n: number;","atom":"a0","author":"init","version":0},{"n":123,"text":"\t/** 1 when the child's atom deleted the parent (the child replaces it), else 0. A moved line is 0. */","atom":"a0","author":"init","version":0},{"n":124,"text":"\treadonly replaces: number;","atom":"a0","author":"init","version":0},{"n":125,"text":"\treadonly lamport: number;","atom":"a0","author":"init","version":0},{"n":126,"text":"\treadonly seq: number;","atom":"a0","author":"init","version":0},{"n":127,"text":"\treadonly k: number;","atom":"a0","author":"init","version":0},{"n":128,"text":"}","atom":"a0","author":"init","version":0},{"n":129,"text":"","atom":"a0","author":"init","version":0},{"n":130,"text":"const EMPTY_INTS = new Int32Array(0);","atom":"a0","author":"init","version":0},{"n":131,"text":"const NO_FILE: FileState = {","atom":"a2736","author":"capacity","version":276},{"n":132,"text":"\tattrs: NO_ATTRS,","atom":"a2736","author":"capacity","version":276},{"n":133,"text":"\tcomplete: true,","atom":"a2736","author":"capacity","version":276},{"n":134,"text":"\tseq: EMPTY_INTS,","atom":"a2736","author":"capacity","version":276},{"n":135,"text":"\tvis: EMPTY_INTS,","atom":"a2736","author":"capacity","version":276},{"n":136,"text":"\tdeletedBy: new Map(),","atom":"a2736","author":"capacity","version":276},{"n":137,"text":"};","atom":"a2736","author":"capacity","version":276},{"n":138,"text":"","atom":"a0","author":"init","version":0},{"n":139,"text":"/** A count of file uses shared by every view, so a cache can tell which layout across its views was used longest ago. */","atom":"a2668","author":"capacity","version":263},{"n":140,"text":"let fileUses = 0;","atom":"a2668","author":"capacity","version":263},{"n":141,"text":"","atom":"a2668","author":"capacity","version":263},{"n":142,"text":"// Approximate retained-container costs for View.weight(): reference slots,","atom":"a934","author":"codex-capacity-policy","version":103},{"n":143,"text":"// object headers, and map/set entries. These are cache-budget units, not V8","atom":"a934","author":"codex-capacity-policy","version":103},{"n":144,"text":"// heap measurements. Referenced Graph strings and records are not charged.","atom":"a934","author":"codex-capacity-policy","version":103},{"n":145,"text":"const ARRAY_HEADER_BYTES = 24;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":146,"text":"const OBJECT_BYTES = 32;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":147,"text":"const MAP_HEADER_BYTES = 32;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":148,"text":"const MAP_ENTRY_BYTES = 40;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":149,"text":"const SET_ENTRY_BYTES = 32;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":150,"text":"const REFERENCE_BYTES = 8;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":151,"text":"const STRING_HEADER_BYTES = 16;","atom":"a2519","author":"capacity","version":247},{"n":152,"text":"/**","atom":"a2519","author":"capacity","version":247},{"n":153,"text":" * What V8 holds for a string of its own (abso Capacity, measured on abso's layouts): a header, then one byte a","atom":"a2519","author":"capacity","version":247},{"n":154,"text":" * character when every character fits in Latin-1 and two otherwise, rounded up to 8.","atom":"a2519","author":"capacity","version":247},{"n":155,"text":" */","atom":"a2519","author":"capacity","version":247},{"n":156,"text":"export function stringBytes(text: string): number {","atom":"a2539","author":"capacity","version":249},{"n":157,"text":"\tconst chars = /[^\\u0000-\\u00ff]/.test(text) ? 2 * text.length : text.length;","atom":"a2519","author":"capacity","version":247},{"n":158,"text":"\treturn (STRING_HEADER_BYTES + chars + 7) & ~7;","atom":"a2519","author":"capacity","version":247},{"n":159,"text":"}","atom":"a2519","author":"capacity","version":247},{"n":160,"text":"/**","atom":"a2302","author":"capacity","version":205},{"n":161,"text":" * Moved lines a view resolves once and keeps (abso Capacity): a stored graph otherwise resolved every move again on","atom":"a2302","author":"capacity","version":205},{"n":162,"text":" * disk for each file it laid out. Game's whole history has 290; past this many, the view goes back to that.","atom":"a2302","author":"capacity","version":205},{"n":163,"text":" */","atom":"a2302","author":"capacity","version":205},{"n":164,"text":"export const MOVED_LINES_KEPT = 20_000;","atom":"a2302","author":"capacity","version":205},{"n":165,"text":"class TooManyMoves extends Error {}","atom":"a2302","author":"capacity","version":205},{"n":166,"text":"const NO_LINES: readonly number[] = Object.freeze([]);","atom":"a2302","author":"capacity","version":205},{"n":167,"text":"/** Nodes whose nearest moved line above a graph remembers, at most: about 40 bytes each. */","atom":"a2368","author":"capacity","version":215},{"n":168,"text":"const CLIMB_MEMO = 200_000;","atom":"a2368","author":"capacity","version":215},{"n":169,"text":"","atom":"a934","author":"codex-capacity-policy","version":103},{"n":170,"text":"/** One relocation of a moved line, with its line's number and its new parent's code. */","atom":"a2368","author":"capacity","version":215},{"n":171,"text":"interface MoveEntry {","atom":"a2368","author":"capacity","version":215},{"n":172,"text":"\treadonly n: number;","atom":"a2368","author":"capacity","version":215},{"n":173,"text":"\treadonly r: RelocationInfo;","atom":"a2368","author":"capacity","version":215},{"n":174,"text":"\treadonly parent: number;","atom":"a2368","author":"capacity","version":215},{"n":175,"text":"}","atom":"a2368","author":"capacity","version":215},{"n":176,"text":"","atom":"a2368","author":"capacity","version":215},{"n":177,"text":"/**","atom":"a0","author":"init","version":0},{"n":178,"text":" * A graph's moves, whatever the set (abso Capacity): each mover's moved lines, each moved line's relocations in seq","atom":"a2368","author":"capacity","version":215},{"n":179,"text":" * order, and for any node the nearest node at or above it, by where lines were written, that a move ever relocated,","atom":"a2368","author":"capacity","version":215},{"n":180,"text":" * or its file's start. Worked out once per graph and extended as it grows. A view's moves then resolve over the moved","atom":"a2368","author":"capacity","version":215},{"n":181,"text":" * lines alone: before, every view walked each moved line's file up to its start, a read per line.","atom":"a2368","author":"capacity","version":215},{"n":182,"text":" */","atom":"a2368","author":"capacity","version":215},{"n":183,"text":"class MoveSkeleton {","atom":"a2368","author":"capacity","version":215},{"n":184,"text":"\treadonly #graph: Graph;","atom":"a2368","author":"capacity","version":215},{"n":185,"text":"\t#seen = 0;","atom":"a2368","author":"capacity","version":215},{"n":186,"text":"\t/** Movers in seq order, with the numbers of the lines each moves, in its moves' order. */","atom":"a2368","author":"capacity","version":215},{"n":187,"text":"\treadonly movers: {","atom":"a2736","author":"capacity","version":276},{"n":188,"text":"\t\treadonly seq: number;","atom":"a2736","author":"capacity","version":276},{"n":189,"text":"\t\treadonly lines: readonly number[];","atom":"a2736","author":"capacity","version":276},{"n":190,"text":"\t}[] = [];","atom":"a2736","author":"capacity","version":276},{"n":191,"text":"\t/** Every relocation of each moved line, by the line's number, in seq order. */","atom":"a2368","author":"capacity","version":215},{"n":192,"text":"\treadonly byLine = new Map<number, MoveEntry[]>();","atom":"a2368","author":"capacity","version":215},{"n":193,"text":"\treadonly #climbed = new Map<number, number>();","atom":"a2368","author":"capacity","version":215},{"n":194,"text":"","atom":"a2368","author":"capacity","version":215},{"n":195,"text":"\tconstructor(graph: Graph) {","atom":"a2368","author":"capacity","version":215},{"n":196,"text":"\t\tthis.#graph = graph;","atom":"a2368","author":"capacity","version":215},{"n":197,"text":"\t}","atom":"a2368","author":"capacity","version":215},{"n":198,"text":"","atom":"a2368","author":"capacity","version":215},{"n":199,"text":"\t/** The graph's accepted count when movers were last taken in: nothing to read while it's the same. */","atom":"a2463","author":"capacity","version":238},{"n":200,"text":"\t#stamp = -1;","atom":"a2463","author":"capacity","version":238},{"n":201,"text":"","atom":"a2463","author":"capacity","version":238},{"n":202,"text":"\t/** Take in movers the graph gained since. */","atom":"a2368","author":"capacity","version":215},{"n":203,"text":"\tupdate(): this {","atom":"a2368","author":"capacity","version":215},{"n":204,"text":"\t\tconst graph = this.#graph;","atom":"a2368","author":"capacity","version":215},{"n":205,"text":"\t\tif (this.#stamp === graph.accepted) return this;","atom":"a2463","author":"capacity","version":238},{"n":206,"text":"\t\tthis.#stamp = graph.accepted;","atom":"a2463","author":"capacity","version":238},{"n":207,"text":"\t\tconst all = graph.movers();","atom":"a2368","author":"capacity","version":215},{"n":208,"text":"\t\tif (this.#seen === all.length) return this;","atom":"a2368","author":"capacity","version":215},{"n":209,"text":"\t\tfor (; this.#seen < all.length; this.#seen++) {","atom":"a2368","author":"capacity","version":215},{"n":210,"text":"\t\t\tconst id = all[this.#seen]!;","atom":"a2368","author":"capacity","version":215},{"n":211,"text":"\t\t\tconst lines: number[] = [];","atom":"a2368","author":"capacity","version":215},{"n":212,"text":"\t\t\tgraph.atom(id).moves!.forEach((m, k) => {","atom":"a2368","author":"capacity","version":215},{"n":213,"text":"\t\t\t\tconst n = graph.lineN(m.line);","atom":"a2368","author":"capacity","version":215},{"n":214,"text":"\t\t\t\tconst r: RelocationInfo = Object.freeze({","atom":"a2736","author":"capacity","version":276},{"n":215,"text":"\t\t\t\t\tatom: id,","atom":"a2736","author":"capacity","version":276},{"n":216,"text":"\t\t\t\t\tline: m.line,","atom":"a2736","author":"capacity","version":276},{"n":217,"text":"\t\t\t\t\tparent: m.parent,","atom":"a2736","author":"capacity","version":276},{"n":218,"text":"\t\t\t\t\tk,","atom":"a2736","author":"capacity","version":276},{"n":219,"text":"\t\t\t\t});","atom":"a2736","author":"capacity","version":276},{"n":220,"text":"\t\t\t\tconst entry: MoveEntry = { n, r, parent: graph.codeOf(m.parent)! };","atom":"a2368","author":"capacity","version":215},{"n":221,"text":"\t\t\t\tconst list = this.byLine.get(n);","atom":"a2368","author":"capacity","version":215},{"n":222,"text":"\t\t\t\tif (list) list.push(entry);","atom":"a2368","author":"capacity","version":215},{"n":223,"text":"\t\t\t\telse this.byLine.set(n, [entry]);","atom":"a2368","author":"capacity","version":215},{"n":224,"text":"\t\t\t\tlines.push(n);","atom":"a2368","author":"capacity","version":215},{"n":225,"text":"\t\t\t});","atom":"a2368","author":"capacity","version":215},{"n":226,"text":"\t\t\tthis.movers.push({ seq: seqOf(id), lines });","atom":"a2368","author":"capacity","version":215},{"n":227,"text":"\t\t}","atom":"a2368","author":"capacity","version":215},{"n":228,"text":"\t\t// A new moved line can sit between a node and the one it climbed to.","atom":"a2368","author":"capacity","version":215},{"n":229,"text":"\t\tthis.#climbed.clear();","atom":"a2368","author":"capacity","version":215},{"n":230,"text":"\t\treturn this;","atom":"a2368","author":"capacity","version":215},{"n":231,"text":"\t}","atom":"a2368","author":"capacity","version":215},{"n":232,"text":"","atom":"a2368","author":"capacity","version":215},{"n":233,"text":"\t/** The nearest node at or above this one, by where lines were written, that a move ever relocated; or its file's start. */","atom":"a2368","author":"capacity","version":215},{"n":234,"text":"\tclimb(code: number): number {","atom":"a2368","author":"capacity","version":215},{"n":235,"text":"\t\tconst walked: number[] = [];","atom":"a2368","author":"capacity","version":215},{"n":236,"text":"\t\tlet c = code;","atom":"a2368","author":"capacity","version":215},{"n":237,"text":"\t\twhile (c >= 0 && !this.byLine.has(c)) {","atom":"a2368","author":"capacity","version":215},{"n":238,"text":"\t\t\tconst known = this.#climbed.get(c);","atom":"a2368","author":"capacity","version":215},{"n":239,"text":"\t\t\tif (known !== undefined) {","atom":"a2368","author":"capacity","version":215},{"n":240,"text":"\t\t\t\tc = known;","atom":"a2368","author":"capacity","version":215},{"n":241,"text":"\t\t\t\tbreak;","atom":"a2368","author":"capacity","version":215},{"n":242,"text":"\t\t\t}","atom":"a2368","author":"capacity","version":215},{"n":243,"text":"\t\t\twalked.push(c);","atom":"a2368","author":"capacity","version":215},{"n":244,"text":"\t\t\tc = this.#graph.parentCodeOf(c);","atom":"a2368","author":"capacity","version":215},{"n":245,"text":"\t\t}","atom":"a2368","author":"capacity","version":215},{"n":246,"text":"\t\tif (this.#climbed.size + walked.length > CLIMB_MEMO) this.#climbed.clear();","atom":"a2368","author":"capacity","version":215},{"n":247,"text":"\t\tfor (const w of walked) this.#climbed.set(w, c);","atom":"a2368","author":"capacity","version":215},{"n":248,"text":"\t\treturn c;","atom":"a2368","author":"capacity","version":215},{"n":249,"text":"\t}","atom":"a2368","author":"capacity","version":215},{"n":250,"text":"}","atom":"a2368","author":"capacity","version":215},{"n":251,"text":"","atom":"a2368","author":"capacity","version":215},{"n":252,"text":"const skeletons = new WeakMap<Graph, MoveSkeleton>();","atom":"a2368","author":"capacity","version":215},{"n":253,"text":"function skeletonOf(graph: Graph): MoveSkeleton {","atom":"a2368","author":"capacity","version":215},{"n":254,"text":"\tlet skeleton = skeletons.get(graph);","atom":"a2368","author":"capacity","version":215},{"n":255,"text":"\tif (!skeleton) skeletons.set(graph, (skeleton = new MoveSkeleton(graph)));","atom":"a2368","author":"capacity","version":215},{"n":256,"text":"\treturn skeleton.update();","atom":"a2368","author":"capacity","version":215},{"n":257,"text":"}","atom":"a2368","author":"capacity","version":215},{"n":258,"text":"","atom":"a2368","author":"capacity","version":215},{"n":259,"text":"/**","atom":"a2368","author":"capacity","version":215},{"n":260,"text":" * The projection of a closed set. Construct once, then ask for files, lines","atom":"a0","author":"init","version":0},{"n":261,"text":" * and sequences. Throws `not-closed` if some atom's dependency is missing.","atom":"a0","author":"init","version":0},{"n":262,"text":" * Each file is laid out the first time it is asked for, so a view of a large","atom":"a0","author":"init","version":0},{"n":263,"text":" * set costs little until files are read.","atom":"a0","author":"init","version":0},{"n":264,"text":" */","atom":"a0","author":"init","version":0},{"n":265,"text":"export class View {","atom":"a0","author":"init","version":0},{"n":266,"text":"\treadonly graph: Graph;","atom":"a0","author":"init","version":0},{"n":267,"text":"\t/** The set, made from #in the first time it's asked for: a view keeps a byte per atom, not a copy of the set (#46). */","atom":"a0","author":"init","version":0},{"n":268,"text":"\t#set: AtomSet | undefined;","atom":"a998","author":"codex-capacity-chair","version":109},{"n":269,"text":"\treadonly #stable: StableSet<AtomId> | undefined;","atom":"a998","author":"codex-capacity-chair","version":109},{"n":270,"text":"\t/** Fixed-size memo for immutable indexed membership, independent of history size. */","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":271,"text":"\t#membershipSeq = new Float64Array(256).fill(-1);","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":272,"text":"\t#membershipValue = new Uint8Array(256);","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":273,"text":"\t#files = new Map<string, FileState>();","atom":"a0","author":"init","version":0},{"n":274,"text":"\t/** Every file the set wrote in, sorted; worked out the first time it's asked for. */","atom":"a0","author":"init","version":0},{"n":275,"text":"\t#knownList: string[] | undefined;","atom":"a0","author":"init","version":0},{"n":276,"text":"\t/** 1 for each atom (by seq) in the set. */","atom":"a0","author":"init","version":0},{"n":277,"text":"\t#in: Uint8Array;","atom":"a0","author":"init","version":0},{"n":278,"text":"\t/** Atoms in the set that move lines. */","atom":"a0","author":"init","version":0},{"n":279,"text":"\t#movers: AtomId[] | undefined;","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":280,"text":"\t#hasMoves = false;","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":281,"text":"\t/** Each moved line's relocation that counts in this set; built on first use. */","atom":"a0","author":"init","version":0},{"n":282,"text":"\t#relocs: Map<LineId, RelocationInfo> | undefined;","atom":"a0","author":"init","version":0},{"n":283,"text":"\t/** The same, by n, with the new parent's code. */","atom":"a0","author":"init","version":0},{"n":284,"text":"\t#relocsN: Map<number, { readonly r: RelocationInfo; readonly parent: number }> | undefined;","atom":"a0","author":"init","version":0},{"n":285,"text":"\t/** The moved lines under each node, by its code, made from the relocations on first use. */","atom":"a2302","author":"capacity","version":205},{"n":286,"text":"\t#movedInto: Map<number, number[]> | undefined;","atom":"a2302","author":"capacity","version":205},{"n":287,"text":"\t/** Whether this view's moves are too many to keep, so they're resolved on disk per layout; undefined until asked. */","atom":"a2302","author":"capacity","version":205},{"n":288,"text":"\t#movesOnDisk: boolean | undefined;","atom":"a2302","author":"capacity","version":205},{"n":289,"text":"\t/** The latest records asked for: one file's lines, one file's sequence, one file's text. */","atom":"a0","author":"init","version":0},{"n":290,"text":"\t#linesCache: { path: string; lines: readonly VisibleLine[] } | undefined;","atom":"a0","author":"init","version":0},{"n":291,"text":"\t#seqCache: { path: string; seq: readonly SeqLine[] } | undefined;","atom":"a0","author":"init","version":0},{"n":292,"text":"\t#textCache: { path: string; text: string } | undefined;","atom":"a0","author":"init","version":0},{"n":293,"text":"","atom":"a0","author":"init","version":0},{"n":294,"text":"\tconstructor(graph: Graph, set: Iterable<AtomId>) {","atom":"a0","author":"init","version":0},{"n":295,"text":"\t\tthis.graph = graph;","atom":"a998","author":"codex-capacity-chair","version":109},{"n":296,"text":"\t\tif (set instanceof StableSet) {","atom":"a998","author":"codex-capacity-chair","version":109},{"n":297,"text":"\t\t\tthis.#stable = set;","atom":"a998","author":"codex-capacity-chair","version":109},{"n":298,"text":"\t\t\tthis.#set = set;","atom":"a998","author":"codex-capacity-chair","version":109},{"n":299,"text":"\t\t\tthis.#in = new Uint8Array(0);","atom":"a998","author":"codex-capacity-chair","version":109},{"n":300,"text":"\t\t\t// A set kept closed when it was written needs no proof here (abso Capacity).","atom":"a2302","author":"capacity","version":205},{"n":301,"text":"\t\t\tfor (const id of isClosedSet(set) ? [] : set) {","atom":"a2302","author":"capacity","version":205},{"n":302,"text":"\t\t\t\tconst atom = graph.atom(id);","atom":"a998","author":"codex-capacity-chair","version":109},{"n":303,"text":"\t\t\t\tfor (const dependency of atom.deps) {","atom":"a998","author":"codex-capacity-chair","version":109},{"n":304,"text":"\t\t\t\t\tgraph.atom(dependency);","atom":"a998","author":"codex-capacity-chair","version":109},{"n":305,"text":"\t\t\t\t\tif (!set.has(dependency))","atom":"a998","author":"codex-capacity-chair","version":109},{"n":306,"text":"\t\t\t\t\t\tthrow new EngineError(\"not-closed\", `set is not closed: ${id} depends on ${dependency}`);","atom":"a998","author":"codex-capacity-chair","version":109},{"n":307,"text":"\t\t\t\t}","atom":"a998","author":"codex-capacity-chair","version":109},{"n":308,"text":"\t\t\t}","atom":"a998","author":"codex-capacity-chair","version":109},{"n":309,"text":"\t\t\tfor (const id of graph.movers()) {","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":310,"text":"\t\t\t\tif (set.has(id)) {","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":311,"text":"\t\t\t\t\tthis.#hasMoves = true;","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":312,"text":"\t\t\t\t\tbreak;","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":313,"text":"\t\t\t\t}","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":314,"text":"\t\t\t}","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":315,"text":"\t\t\tthis.#relocs = this.#hasMoves ? undefined : new Map();","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":316,"text":"\t\t\tthis.#relocsN = this.#hasMoves ? undefined : new Map();","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":317,"text":"\t\t\treturn;","atom":"a998","author":"codex-capacity-chair","version":109},{"n":318,"text":"\t\t}","atom":"a998","author":"codex-capacity-chair","version":109},{"n":319,"text":"\t\tconst inSet = new Uint8Array(graph.size);","atom":"a0","author":"init","version":0},{"n":320,"text":"\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.","atom":"a2383","author":"capacity","version":218},{"n":321,"text":"\t\tconst seqIn = (id: AtomId): number => {","atom":"a2383","author":"capacity","version":218},{"n":322,"text":"\t\t\tconst seq = seqOf(id);","atom":"a2383","author":"capacity","version":218},{"n":323,"text":"\t\t\treturn seq >= 0 && seq < inSet.length && graph.idOfSeq(seq) === id ? seq : graph.atom(id).seq;","atom":"a2383","author":"capacity","version":218},{"n":324,"text":"\t\t};","atom":"a2383","author":"capacity","version":218},{"n":325,"text":"\t\tfor (const id of set) inSet[seqIn(id)] = 1;","atom":"a2383","author":"capacity","version":218},{"n":326,"text":"\t\t// Validate one atom at a time. Keeping all decoded atoms here defeats","atom":"a979","author":"codex-capacity-chair","version":109},{"n":327,"text":"\t\t// storage-backed Graph reads even though the view only needs membership.","atom":"a979","author":"codex-capacity-chair","version":109},{"n":328,"text":"\t\tfor (let seq = 0; seq < inSet.length; seq++) {","atom":"a979","author":"codex-capacity-chair","version":109},{"n":329,"text":"\t\t\tif (inSet[seq] !== 1) continue;","atom":"a979","author":"codex-capacity-chair","version":109},{"n":330,"text":"\t\t\tconst atom = graph.atom(graph.idOfSeq(seq));","atom":"a979","author":"codex-capacity-chair","version":109},{"n":331,"text":"\t\t\tfor (const d of atom.deps) {","atom":"a0","author":"init","version":0},{"n":332,"text":"\t\t\t\tif (inSet[seqIn(d)] !== 1) throw new EngineError(\"not-closed\", `set is not closed: ${atom.id} depends on ${d}`);","atom":"a2383","author":"capacity","version":218},{"n":333,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":334,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":335,"text":"\t\tthis.graph = graph;","atom":"a0","author":"init","version":0},{"n":336,"text":"\t\tthis.#in = inSet;","atom":"a0","author":"init","version":0},{"n":337,"text":"\t\tthis.#movers = graph.movers().filter((id) => inSet[seqOf(id)] === 1);","atom":"a2383","author":"capacity","version":218},{"n":338,"text":"\t\tthis.#hasMoves = this.#movers.length > 0;","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":339,"text":"\t\tthis.#relocs = this.#movers.length === 0 ? new Map() : undefined;","atom":"a0","author":"init","version":0},{"n":340,"text":"\t\tthis.#relocsN = this.#movers.length === 0 ? new Map() : undefined;","atom":"a0","author":"init","version":0},{"n":341,"text":"\t}","atom":"a0","author":"init","version":0},{"n":342,"text":"","atom":"a0","author":"init","version":0},{"n":343,"text":"\t/** The set of atoms this view projects. */","atom":"a0","author":"init","version":0},{"n":344,"text":"\tget set(): AtomSet {","atom":"a0","author":"init","version":0},{"n":345,"text":"\t\tif (!this.#set) {","atom":"a0","author":"init","version":0},{"n":346,"text":"\t\t\tconst out = new Set<AtomId>();","atom":"a0","author":"init","version":0},{"n":347,"text":"\t\t\tfor (let seq = 0; seq < this.#in.length; seq++) if (this.#in[seq] === 1) out.add(this.graph.idOfSeq(seq));","atom":"a0","author":"init","version":0},{"n":348,"text":"\t\t\tthis.#set = out;","atom":"a0","author":"init","version":0},{"n":349,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":350,"text":"\t\treturn this.#set;","atom":"a0","author":"init","version":0},{"n":351,"text":"\t}","atom":"a0","author":"init","version":0},{"n":352,"text":"","atom":"a0","author":"init","version":0},{"n":353,"text":"\t/** Whether the atom with this seq is in the set. */","atom":"a0","author":"init","version":0},{"n":354,"text":"\t#has(seq: number): boolean {","atom":"a0","author":"init","version":0},{"n":355,"text":"\t\tif (this.#stable) {","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":356,"text":"\t\t\tconst slot = seq % this.#membershipSeq.length;","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":357,"text":"\t\t\tif (this.#membershipSeq[slot] === seq) return this.#membershipValue[slot] === 1;","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":358,"text":"\t\t\tconst present = this.#stable.has(this.graph.idOfSeq(seq));","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":359,"text":"\t\t\tthis.#membershipSeq[slot] = seq;","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":360,"text":"\t\t\tthis.#membershipValue[slot] = present ? 1 : 0;","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":361,"text":"\t\t\treturn present;","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":362,"text":"\t\t}","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":363,"text":"\t\treturn seq < this.#in.length && this.#in[seq] === 1;","atom":"a0","author":"init","version":0},{"n":364,"text":"\t}","atom":"a0","author":"init","version":0},{"n":365,"text":"","atom":"a0","author":"init","version":0},{"n":366,"text":"\t/**","atom":"a0","author":"init","version":0},{"n":367,"text":"\t * The relocation that counts for each moved line: the newest (by priority)","atom":"a0","author":"init","version":0},{"n":368,"text":"\t * in the set. Two moves made apart can loop lines into each other, so no","atom":"a0","author":"init","version":0},{"n":369,"text":"\t * start node reaches them; then the oldest relocation on the loop is","atom":"a0","author":"init","version":0},{"n":370,"text":"\t * ignored, and the next newest of that line counts, until none loop.","atom":"a0","author":"init","version":0},{"n":371,"text":"\t */","atom":"a0","author":"init","version":0},{"n":372,"text":"\t#relocations(): Map<LineId, RelocationInfo> {","atom":"a0","author":"init","version":0},{"n":373,"text":"\t\tif (this.#relocs) return this.#relocs;","atom":"a0","author":"init","version":0},{"n":374,"text":"\t\tthis.#takeShared();","atom":"a2377","author":"capacity","version":216},{"n":375,"text":"\t\tif (this.#relocs) return this.#relocs;","atom":"a2377","author":"capacity","version":216},{"n":376,"text":"\t\tconst graph = this.graph;","atom":"a0","author":"init","version":0},{"n":377,"text":"\t\tconst skeleton = skeletonOf(graph);","atom":"a2368","author":"capacity","version":215},{"n":378,"text":"\t\tconst stronger = (a: RelocationInfo, b: RelocationInfo): boolean => graph.comparePriority(a.atom, b.atom) > 0;","atom":"a0","author":"init","version":0},{"n":379,"text":"\t\tconst identity = (r: RelocationInfo): string => JSON.stringify([r.atom, r.k]);","atom":"a1075","author":"codex-capacity-chair","version":126},{"n":380,"text":"\t\tconst ignored = new Set<string>();","atom":"a1075","author":"codex-capacity-chair","version":126},{"n":381,"text":"\t\tconst pick = (n: number): MoveEntry | undefined => {","atom":"a2368","author":"capacity","version":215},{"n":382,"text":"\t\t\tlet best: MoveEntry | undefined;","atom":"a2368","author":"capacity","version":215},{"n":383,"text":"\t\t\tfor (const e of skeleton.byLine.get(n) ?? []) {","atom":"a2368","author":"capacity","version":215},{"n":384,"text":"\t\t\t\tif (this.#has(seqOf(e.r.atom)) && !ignored.has(identity(e.r)) && (!best || stronger(e.r, best.r))) best = e;","atom":"a2368","author":"capacity","version":215},{"n":385,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":386,"text":"\t\t\treturn best;","atom":"a0","author":"init","version":0},{"n":387,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":388,"text":"\t\t// By the moved line's number, in the order its movers come (seq order, then each mover's moves).","atom":"a2368","author":"capacity","version":215},{"n":389,"text":"\t\tconst relocs = new Map<number, MoveEntry>();","atom":"a2368","author":"capacity","version":215},{"n":390,"text":"\t\tfor (const mover of skeleton.movers) {","atom":"a2368","author":"capacity","version":215},{"n":391,"text":"\t\t\tif (!this.#has(mover.seq)) continue;","atom":"a2368","author":"capacity","version":215},{"n":392,"text":"\t\t\tfor (const n of mover.lines) {","atom":"a2368","author":"capacity","version":215},{"n":393,"text":"\t\t\t\tif (!relocs.has(n)) relocs.set(n, pick(n)!);","atom":"a2368","author":"capacity","version":215},{"n":394,"text":"\t\t\t\tif (graph.hasOrderedChildren && relocs.size > MOVED_LINES_KEPT) throw new TooManyMoves();","atom":"a2302","author":"capacity","version":205},{"n":395,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":396,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":397,"text":"\t\t// From a node, the next node that matters for loops: a line moved in this set, or a file's start.","atom":"a2368","author":"capacity","version":215},{"n":398,"text":"\t\tconst hop = (code: number): number => {","atom":"a2368","author":"capacity","version":215},{"n":399,"text":"\t\t\tlet c = skeleton.climb(code);","atom":"a2368","author":"capacity","version":215},{"n":400,"text":"\t\t\twhile (c >= 0 && !relocs.has(c)) c = skeleton.climb(graph.parentCodeOf(c));","atom":"a2368","author":"capacity","version":215},{"n":401,"text":"\t\t\treturn c;","atom":"a2368","author":"capacity","version":215},{"n":402,"text":"\t\t};","atom":"a2368","author":"capacity","version":215},{"n":403,"text":"\t\tconst step = (n: number): number => {","atom":"a2368","author":"capacity","version":215},{"n":404,"text":"\t\t\tconst e = relocs.get(n);","atom":"a2368","author":"capacity","version":215},{"n":405,"text":"\t\t\treturn hop(e ? e.parent : graph.parentCodeOf(n));","atom":"a2368","author":"capacity","version":215},{"n":406,"text":"\t\t};","atom":"a2368","author":"capacity","version":215},{"n":407,"text":"\t\t// Two moves made apart can loop lines into each other, so no start node reaches them; then the oldest","atom":"a2368","author":"capacity","version":215},{"n":408,"text":"\t\t// relocation on the loop is ignored, and the next newest of that line counts, until none loop.","atom":"a2368","author":"capacity","version":215},{"n":409,"text":"\t\tconst reaches = new Set<number>();","atom":"a2368","author":"capacity","version":215},{"n":410,"text":"\t\tfor (const line of [...relocs.keys()]) {","atom":"a0","author":"init","version":0},{"n":411,"text":"\t\t\tfor (;;) {","atom":"a0","author":"init","version":0},{"n":412,"text":"\t\t\t\tconst path: number[] = [];","atom":"a2368","author":"capacity","version":215},{"n":413,"text":"\t\t\t\tconst onPath = new Map<number, number>();","atom":"a2368","author":"capacity","version":215},{"n":414,"text":"\t\t\t\tlet cur = line;","atom":"a2368","author":"capacity","version":215},{"n":415,"text":"\t\t\t\tlet loopAt = -1;","atom":"a0","author":"init","version":0},{"n":416,"text":"\t\t\t\twhile (cur >= 0 && !reaches.has(cur)) {","atom":"a2368","author":"capacity","version":215},{"n":417,"text":"\t\t\t\t\tconst at = onPath.get(cur);","atom":"a0","author":"init","version":0},{"n":418,"text":"\t\t\t\t\tif (at !== undefined) {","atom":"a0","author":"init","version":0},{"n":419,"text":"\t\t\t\t\t\tloopAt = at;","atom":"a0","author":"init","version":0},{"n":420,"text":"\t\t\t\t\t\tbreak;","atom":"a0","author":"init","version":0},{"n":421,"text":"\t\t\t\t\t}","atom":"a0","author":"init","version":0},{"n":422,"text":"\t\t\t\t\tonPath.set(cur, path.length);","atom":"a0","author":"init","version":0},{"n":423,"text":"\t\t\t\t\tpath.push(cur);","atom":"a0","author":"init","version":0},{"n":424,"text":"\t\t\t\t\tcur = step(cur);","atom":"a2368","author":"capacity","version":215},{"n":425,"text":"\t\t\t\t}","atom":"a0","author":"init","version":0},{"n":426,"text":"\t\t\t\tif (loopAt < 0) {","atom":"a0","author":"init","version":0},{"n":427,"text":"\t\t\t\t\tfor (const l of path) reaches.add(l);","atom":"a0","author":"init","version":0},{"n":428,"text":"\t\t\t\t\tbreak;","atom":"a0","author":"init","version":0},{"n":429,"text":"\t\t\t\t}","atom":"a0","author":"init","version":0},{"n":430,"text":"\t\t\t\tlet weakest: MoveEntry | undefined;","atom":"a2368","author":"capacity","version":215},{"n":431,"text":"\t\t\t\tfor (const l of path.slice(loopAt)) {","atom":"a0","author":"init","version":0},{"n":432,"text":"\t\t\t\t\tconst e = relocs.get(l);","atom":"a2368","author":"capacity","version":215},{"n":433,"text":"\t\t\t\t\tif (e && (!weakest || stronger(weakest.r, e.r))) weakest = e;","atom":"a2368","author":"capacity","version":215},{"n":434,"text":"\t\t\t\t}","atom":"a0","author":"init","version":0},{"n":435,"text":"\t\t\t\tignored.add(identity(weakest!.r));","atom":"a2368","author":"capacity","version":215},{"n":436,"text":"\t\t\t\tconst next = pick(weakest!.n);","atom":"a2368","author":"capacity","version":215},{"n":437,"text":"\t\t\t\tif (next) relocs.set(weakest!.n, next);","atom":"a2368","author":"capacity","version":215},{"n":438,"text":"\t\t\t\telse relocs.delete(weakest!.n);","atom":"a2368","author":"capacity","version":215},{"n":439,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":440,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":441,"text":"\t\tthis.#relocsN = new Map([...relocs].map(([n, e]) => [n, { r: e.r, parent: e.parent }]));","atom":"a2368","author":"capacity","version":215},{"n":442,"text":"\t\tthis.#relocs = new Map([...relocs.values()].map((e) => [e.r.line, e.r]));","atom":"a2368","author":"capacity","version":215},{"n":443,"text":"\t\treturn this.#relocs;","atom":"a2368","author":"capacity","version":215},{"n":444,"text":"\t}","atom":"a0","author":"init","version":0},{"n":445,"text":"","atom":"a2319","author":"capacity","version":207},{"n":446,"text":"\t/** The view whose moves this one may take, until it needs them all; then the view it took them from. */","atom":"a2377","author":"capacity","version":216},{"n":447,"text":"\t#movesFrom: View | undefined;","atom":"a2377","author":"capacity","version":216},{"n":448,"text":"\t#movesTaken: View | undefined;","atom":"a2377","author":"capacity","version":216},{"n":449,"text":"","atom":"a2377","author":"capacity","version":216},{"n":450,"text":"\t/**","atom":"a2319","author":"capacity","version":207},{"n":451,"text":"\t * Take another view's resolved moves (abso Capacity), when both sets hold the very same atoms that move lines: the","atom":"a2350","author":"capacity","version":212},{"n":452,"text":"\t * moves then resolve the same, and every line sits where it sits there. Checked when this view first needs all its","atom":"a2377","author":"capacity","version":216},{"n":453,"text":"\t * moves, so any caller may ask, and a view that only finds a few lines' files never resolves them.","atom":"a2377","author":"capacity","version":216},{"n":454,"text":"\t */","atom":"a2319","author":"capacity","version":207},{"n":455,"text":"\tshareMoves(from: View): void {","atom":"a2319","author":"capacity","version":207},{"n":456,"text":"\t\tif (from.graph !== this.graph || from.#hasMoves !== this.#hasMoves || !this.#hasMoves || this.#relocs) return;","atom":"a2377","author":"capacity","version":216},{"n":457,"text":"\t\tthis.#movesFrom = from;","atom":"a2377","author":"capacity","version":216},{"n":458,"text":"\t}","atom":"a2377","author":"capacity","version":216},{"n":459,"text":"","atom":"a2377","author":"capacity","version":216},{"n":460,"text":"\t/**","atom":"a2451","author":"capacity","version":235},{"n":461,"text":"\t * Files laid out as another view lays them out (abso Capacity): a draft's view over its base's, for every file the","atom":"a2451","author":"capacity","version":235},{"n":462,"text":"\t * draft doesn't touch. The caller knows what the draft is; `except` is asked once, when a file is first needed, for","atom":"a2451","author":"capacity","version":235},{"n":463,"text":"\t * the files the draft touches, or undefined when nothing can be shared (a draft that moves lines). Without it, an","atom":"a2451","author":"capacity","version":235},{"n":464,"text":"\t * agent's tree, files and blame laid out every file of the project again for each agent.","atom":"a2451","author":"capacity","version":235},{"n":465,"text":"\t */","atom":"a2451","author":"capacity","version":235},{"n":466,"text":"\tshareFiles(from: View, except: () => ReadonlySet<string> | undefined): void {","atom":"a2451","author":"capacity","version":235},{"n":467,"text":"\t\tif (from.graph !== this.graph || from === this || this.#filesFrom !== undefined) return;","atom":"a2451","author":"capacity","version":235},{"n":468,"text":"\t\tthis.#filesFrom = { from, except };","atom":"a2451","author":"capacity","version":235},{"n":469,"text":"\t}","atom":"a2451","author":"capacity","version":235},{"n":470,"text":"\t#filesFrom: { from: View; except: () => ReadonlySet<string> | undefined } | null | undefined;","atom":"a2451","author":"capacity","version":235},{"n":471,"text":"","atom":"a2498","author":"capacity","version":245},{"n":472,"text":"\t/**","atom":"a2498","author":"capacity","version":245},{"n":473,"text":"\t * The files this view's set has, from what the project keeps for a published version (abso Capacity): hasFile","atom":"a2498","author":"capacity","version":245},{"n":474,"text":"\t * answers from it, not a layout of the file. Collisions resolving an import tried up to seven names, and each one","atom":"a2498","author":"capacity","version":245},{"n":475,"text":"\t * laid its file out. `paths` is asked once, when first needed; undefined lays files out as before.","atom":"a2498","author":"capacity","version":245},{"n":476,"text":"\t */","atom":"a2498","author":"capacity","version":245},{"n":477,"text":"\tknowPaths(paths: () => ReadonlySet<string> | undefined): void {","atom":"a2498","author":"capacity","version":245},{"n":478,"text":"\t\tif (this.#pathsFrom === undefined) this.#pathsFrom = paths;","atom":"a2498","author":"capacity","version":245},{"n":479,"text":"\t}","atom":"a2498","author":"capacity","version":245},{"n":480,"text":"\t#pathsFrom: (() => ReadonlySet<string> | undefined) | undefined;","atom":"a2498","author":"capacity","version":245},{"n":481,"text":"\t#knownPaths: ReadonlySet<string> | null | undefined;","atom":"a2498","author":"capacity","version":245},{"n":482,"text":"\t#filesShared: { from: View; except: ReadonlySet<string> } | null | undefined;","atom":"a2451","author":"capacity","version":235},{"n":483,"text":"\t#sharedFiles(): { from: View; except: ReadonlySet<string> } | null {","atom":"a2451","author":"capacity","version":235},{"n":484,"text":"\t\tif (this.#filesShared === undefined) {","atom":"a2451","author":"capacity","version":235},{"n":485,"text":"\t\t\tconst share = this.#filesFrom;","atom":"a2451","author":"capacity","version":235},{"n":486,"text":"\t\t\tconst except = share ? share.except() : undefined;","atom":"a2451","author":"capacity","version":235},{"n":487,"text":"\t\t\tthis.#filesShared = share && except ? { from: share.from, except } : null;","atom":"a2451","author":"capacity","version":235},{"n":488,"text":"\t\t}","atom":"a2451","author":"capacity","version":235},{"n":489,"text":"\t\treturn this.#filesShared;","atom":"a2451","author":"capacity","version":235},{"n":490,"text":"\t}","atom":"a2451","author":"capacity","version":235},{"n":491,"text":"","atom":"a2451","author":"capacity","version":235},{"n":492,"text":"\t#takeShared(): void {","atom":"a2377","author":"capacity","version":216},{"n":493,"text":"\t\tconst from = this.#movesFrom;","atom":"a2377","author":"capacity","version":216},{"n":494,"text":"\t\tif (!from) return;","atom":"a2377","author":"capacity","version":216},{"n":495,"text":"\t\tthis.#movesFrom = undefined;","atom":"a2377","author":"capacity","version":216},{"n":496,"text":"\t\tif (from.#scratchMoves()) return;","atom":"a2377","author":"capacity","version":216},{"n":497,"text":"\t\tfor (const id of this.graph.movers()) {","atom":"a2350","author":"capacity","version":212},{"n":498,"text":"\t\t\tconst seq = seqOf(id);","atom":"a2350","author":"capacity","version":212},{"n":499,"text":"\t\t\tif (this.#has(seq) !== from.#has(seq)) return;","atom":"a2350","author":"capacity","version":212},{"n":500,"text":"\t\t}","atom":"a2350","author":"capacity","version":212},{"n":501,"text":"\t\tthis.#relocs = from.#relocations();","atom":"a2319","author":"capacity","version":207},{"n":502,"text":"\t\tthis.#relocsN = from.#relocationsN();","atom":"a2319","author":"capacity","version":207},{"n":503,"text":"\t\tthis.#movesOnDisk = false;","atom":"a2319","author":"capacity","version":207},{"n":504,"text":"\t\tthis.#movesTaken = from;","atom":"a2377","author":"capacity","version":216},{"n":505,"text":"\t}","atom":"a2319","author":"capacity","version":207},{"n":506,"text":"","atom":"a2377","author":"capacity","version":216},{"n":507,"text":"\t/** Moved lines' relocations picked one at a time, before the view resolves them all (null: not moved here). */","atom":"a2377","author":"capacity","version":216},{"n":508,"text":"\treadonly #picked = new Map<number, MoveEntry | null>();","atom":"a2377","author":"capacity","version":216},{"n":509,"text":"","atom":"a2319","author":"capacity","version":207},{"n":510,"text":"\t/**","atom":"a2377","author":"capacity","version":216},{"n":511,"text":"\t * The relocation of moved line n that counts here, as #relocations picks it before any loop: right whenever the","atom":"a2377","author":"capacity","version":216},{"n":512,"text":"\t * walk that reached n goes on to a file's start, since only lines on a loop have their relocation set aside.","atom":"a2377","author":"capacity","version":216},{"n":513,"text":"\t */","atom":"a2377","author":"capacity","version":216},{"n":514,"text":"\t#pickOne(n: number): MoveEntry | undefined {","atom":"a2377","author":"capacity","version":216},{"n":515,"text":"\t\tlet picked = this.#picked.get(n);","atom":"a2377","author":"capacity","version":216},{"n":516,"text":"\t\tif (picked === undefined) {","atom":"a2377","author":"capacity","version":216},{"n":517,"text":"\t\t\tconst graph = this.graph;","atom":"a2377","author":"capacity","version":216},{"n":518,"text":"\t\t\tlet best: MoveEntry | undefined;","atom":"a2377","author":"capacity","version":216},{"n":519,"text":"\t\t\tfor (const e of skeletonOf(graph).byLine.get(n) ?? []) {","atom":"a2377","author":"capacity","version":216},{"n":520,"text":"\t\t\t\tif (this.#has(seqOf(e.r.atom)) && (!best || graph.comparePriority(e.r.atom, best.r.atom) > 0)) best = e;","atom":"a2377","author":"capacity","version":216},{"n":521,"text":"\t\t\t}","atom":"a2377","author":"capacity","version":216},{"n":522,"text":"\t\t\tthis.#picked.set(n, (picked = best ?? null));","atom":"a2377","author":"capacity","version":216},{"n":523,"text":"\t\t}","atom":"a2377","author":"capacity","version":216},{"n":524,"text":"\t\treturn picked ?? undefined;","atom":"a2377","author":"capacity","version":216},{"n":525,"text":"\t}","atom":"a2377","author":"capacity","version":216},{"n":526,"text":"","atom":"a2377","author":"capacity","version":216},{"n":527,"text":"\t/** Whether moves are resolved on disk for each layout: only a stored graph's view with more than MOVED_LINES_KEPT. */","atom":"a2302","author":"capacity","version":205},{"n":528,"text":"\t#scratchMoves(): boolean {","atom":"a2302","author":"capacity","version":205},{"n":529,"text":"\t\tif (!this.#hasMoves || !this.graph.hasOrderedChildren) return false;","atom":"a2302","author":"capacity","version":205},{"n":530,"text":"\t\tif (this.#movesOnDisk === undefined) {","atom":"a2302","author":"capacity","version":205},{"n":531,"text":"\t\t\ttry {","atom":"a2302","author":"capacity","version":205},{"n":532,"text":"\t\t\t\tthis.#relocations();","atom":"a2302","author":"capacity","version":205},{"n":533,"text":"\t\t\t\tthis.#movesOnDisk = false;","atom":"a2302","author":"capacity","version":205},{"n":534,"text":"\t\t\t} catch (error) {","atom":"a2302","author":"capacity","version":205},{"n":535,"text":"\t\t\t\tif (!(error instanceof TooManyMoves)) throw error;","atom":"a2302","author":"capacity","version":205},{"n":536,"text":"\t\t\t\tthis.#movesOnDisk = true;","atom":"a2302","author":"capacity","version":205},{"n":537,"text":"\t\t\t}","atom":"a2302","author":"capacity","version":205},{"n":538,"text":"\t\t}","atom":"a2302","author":"capacity","version":205},{"n":539,"text":"\t\treturn this.#movesOnDisk;","atom":"a2302","author":"capacity","version":205},{"n":540,"text":"\t}","atom":"a2302","author":"capacity","version":205},{"n":541,"text":"","atom":"a2302","author":"capacity","version":205},{"n":542,"text":"\t/** The relocations by n, with each new parent's code. */","atom":"a0","author":"init","version":0},{"n":543,"text":"\t#relocationsN(): Map<number, { readonly r: RelocationInfo; readonly parent: number }> {","atom":"a0","author":"init","version":0},{"n":544,"text":"\t\tif (this.#relocsN) return this.#relocsN;","atom":"a0","author":"init","version":0},{"n":545,"text":"\t\tconst out = new Map<number, { readonly r: RelocationInfo; readonly parent: number }>();","atom":"a0","author":"init","version":0},{"n":546,"text":"\t\tfor (const [line, r] of this.#relocations())","atom":"a0","author":"init","version":0},{"n":547,"text":"\t\t\tout.set(this.graph.lineN(line), {","atom":"a2736","author":"capacity","version":276},{"n":548,"text":"\t\t\t\tr,","atom":"a2736","author":"capacity","version":276},{"n":549,"text":"\t\t\t\tparent: this.graph.codeOf(r.parent)!,","atom":"a2736","author":"capacity","version":276},{"n":550,"text":"\t\t\t});","atom":"a2736","author":"capacity","version":276},{"n":551,"text":"\t\tthis.#relocsN = out;","atom":"a0","author":"init","version":0},{"n":552,"text":"\t\treturn out;","atom":"a0","author":"init","version":0},{"n":553,"text":"\t}","atom":"a0","author":"init","version":0},{"n":554,"text":"","atom":"a0","author":"init","version":0},{"n":555,"text":"\t/** The node a line hangs off in this set: where it was written, or where a move put it. */","atom":"a0","author":"init","version":0},{"n":556,"text":"\tparentOf(line: LineId): NodeId {","atom":"a0","author":"init","version":0},{"n":557,"text":"\t\tif (this.graph.lineParent(line) === undefined) throw new EngineError(\"unknown-line\", `no line ${line}`);","atom":"a1114","author":"codex-capacity-chair","version":132},{"n":558,"text":"\t\tif (this.#scratchMoves())","atom":"a2302","author":"capacity","version":205},{"n":559,"text":"\t\t\treturn this.graph.withProjectionScratch((scratch) =>","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":560,"text":"\t\t\t\tresolveScratchMoves(this.graph, (id) => this.#has(this.graph.atom(id).seq), scratch).parent(line),","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":561,"text":"\t\t\t);","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":562,"text":"\t\tconst r = this.#hasMoves ? this.#relocations().get(line) : undefined;","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":563,"text":"\t\tif (r) return r.parent;","atom":"a0","author":"init","version":0},{"n":564,"text":"\t\tconst parent = this.graph.lineParent(line);","atom":"a0","author":"init","version":0},{"n":565,"text":"\t\tif (parent === undefined) throw new EngineError(\"unknown-line\", `no line ${line}`);","atom":"a0","author":"init","version":0},{"n":566,"text":"\t\treturn parent;","atom":"a0","author":"init","version":0},{"n":567,"text":"\t}","atom":"a2676","author":"capacity","version":266},{"n":568,"text":"","atom":"a2676","author":"capacity","version":266},{"n":569,"text":"\t/**","atom":"a2676","author":"capacity","version":266},{"n":570,"text":"\t * The files where a moved line sits, in this view or in `other`, when the two place it differently: a different","atom":"a2676","author":"capacity","version":266},{"n":571,"text":"\t * relocation wins, or a different parent (abso Capacity). Besides the files a draft's atoms name, these are the only","atom":"a2676","author":"capacity","version":266},{"n":572,"text":"\t * ones a draft's moves can lay out differently from its base, since a line's descendants follow it. Undefined when","atom":"a2676","author":"capacity","version":266},{"n":573,"text":"\t * either view resolves its moves in scratch, which keeps no map of them to compare.","atom":"a2676","author":"capacity","version":266},{"n":574,"text":"\t */","atom":"a2676","author":"capacity","version":266},{"n":575,"text":"\tplacedDifferently(other: View): Set<string> | undefined {","atom":"a2676","author":"capacity","version":266},{"n":576,"text":"\t\tif (this.#scratchMoves() || other.#scratchMoves()) return undefined;","atom":"a2676","author":"capacity","version":266},{"n":577,"text":"\t\tconst here = this.#hasMoves ? this.#relocationsN() : undefined;","atom":"a2676","author":"capacity","version":266},{"n":578,"text":"\t\tconst there = other.#hasMoves ? other.#relocationsN() : undefined;","atom":"a2676","author":"capacity","version":266},{"n":579,"text":"\t\tconst files = new Set<string>();","atom":"a2676","author":"capacity","version":266},{"n":580,"text":"\t\tconst add = (n: number) => {","atom":"a2676","author":"capacity","version":266},{"n":581,"text":"\t\t\tfiles.add(this.#fileOfN(n));","atom":"a2676","author":"capacity","version":266},{"n":582,"text":"\t\t\tfiles.add(other.#fileOfN(n));","atom":"a2676","author":"capacity","version":266},{"n":583,"text":"\t\t};","atom":"a2676","author":"capacity","version":266},{"n":584,"text":"\t\tfor (const [n, x] of here ?? []) {","atom":"a2676","author":"capacity","version":266},{"n":585,"text":"\t\t\tconst y = there?.get(n);","atom":"a2676","author":"capacity","version":266},{"n":586,"text":"\t\t\tif (!y || y.parent !== x.parent || y.r.atom !== x.r.atom) add(n);","atom":"a2676","author":"capacity","version":266},{"n":587,"text":"\t\t}","atom":"a2676","author":"capacity","version":266},{"n":588,"text":"\t\tfor (const n of there?.keys() ?? []) if (!here?.has(n)) add(n);","atom":"a2676","author":"capacity","version":266},{"n":589,"text":"\t\treturn files;","atom":"a2676","author":"capacity","version":266},{"n":590,"text":"\t}","atom":"a0","author":"init","version":0},{"n":591,"text":"","atom":"a0","author":"init","version":0},{"n":592,"text":"\t/** Whether any atom in the set moves lines. */","atom":"a0","author":"init","version":0},{"n":593,"text":"\thasMoves(): boolean {","atom":"a0","author":"init","version":0},{"n":594,"text":"\t\treturn this.#hasMoves;","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":595,"text":"\t}","atom":"a0","author":"init","version":0},{"n":596,"text":"","atom":"a0","author":"init","version":0},{"n":597,"text":"\t/** The file a line is in, in this set: the one its chain of parents reaches. */","atom":"a0","author":"init","version":0},{"n":598,"text":"\tfileOf(line: LineId): string {","atom":"a0","author":"init","version":0},{"n":599,"text":"\t\tconst n = this.graph.lineN(line);","atom":"a0","author":"init","version":0},{"n":600,"text":"\t\tif (n < 0) throw new EngineError(\"unknown-line\", `no line ${line}`);","atom":"a0","author":"init","version":0},{"n":601,"text":"\t\treturn this.#fileOfN(n);","atom":"a0","author":"init","version":0},{"n":602,"text":"\t}","atom":"a0","author":"init","version":0},{"n":603,"text":"","atom":"a0","author":"init","version":0},{"n":604,"text":"\t#fileOfN(n: number): string {","atom":"a0","author":"init","version":0},{"n":605,"text":"\t\tconst graph = this.graph;","atom":"a0","author":"init","version":0},{"n":606,"text":"\t\tif (!this.#hasMoves) return graph.writtenIn(n);","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":607,"text":"\t\tif (this.#scratchMoves())","atom":"a2302","author":"capacity","version":205},{"n":608,"text":"\t\t\treturn graph.withProjectionScratch((scratch) => {","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":609,"text":"\t\t\t\tconst moves = resolveScratchMoves(graph, (id) => this.#has(graph.atom(id).seq), scratch);","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":610,"text":"\t\t\t\tlet current = graph.nodeOf(n);","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":611,"text":"\t\t\t\twhile (!isStartNode(current)) current = moves.parent(current);","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":612,"text":"\t\t\t\treturn current.slice(1);","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":613,"text":"\t\t\t});","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":614,"text":"\t\treturn this.#fileOfCode(n);","atom":"a2368","author":"capacity","version":215},{"n":615,"text":"\t}","atom":"a2368","author":"capacity","version":215},{"n":616,"text":"","atom":"a2368","author":"capacity","version":215},{"n":617,"text":"\t/** The file a node sits in, in this set: up by where lines were written, through the moves that count here. */","atom":"a2368","author":"capacity","version":215},{"n":618,"text":"\t#fileOfCode(code: number): string {","atom":"a2368","author":"capacity","version":215},{"n":619,"text":"\t\tconst graph = this.graph;","atom":"a2368","author":"capacity","version":215},{"n":620,"text":"\t\tconst skeleton = skeletonOf(graph);","atom":"a2368","author":"capacity","version":215},{"n":621,"text":"\t\tif (!this.#relocsN) {","atom":"a2377","author":"capacity","version":216},{"n":622,"text":"\t\t\t// One moved line at a time, until a walk comes back to a line it passed: then moves loop, and are resolved whole.","atom":"a2377","author":"capacity","version":216},{"n":623,"text":"\t\t\tconst passed = new Set<number>();","atom":"a2377","author":"capacity","version":216},{"n":624,"text":"\t\t\tlet c = code;","atom":"a2377","author":"capacity","version":216},{"n":625,"text":"\t\t\tfor (;;) {","atom":"a2377","author":"capacity","version":216},{"n":626,"text":"\t\t\t\tc = skeleton.climb(c);","atom":"a2377","author":"capacity","version":216},{"n":627,"text":"\t\t\t\tif (c < 0) return graph.nodeOf(c).slice(1);","atom":"a2377","author":"capacity","version":216},{"n":628,"text":"\t\t\t\tif (passed.has(c)) break;","atom":"a2377","author":"capacity","version":216},{"n":629,"text":"\t\t\t\tpassed.add(c);","atom":"a2377","author":"capacity","version":216},{"n":630,"text":"\t\t\t\tconst e = this.#pickOne(c);","atom":"a2377","author":"capacity","version":216},{"n":631,"text":"\t\t\t\tc = e ? e.parent : graph.parentCodeOf(c);","atom":"a2377","author":"capacity","version":216},{"n":632,"text":"\t\t\t}","atom":"a2377","author":"capacity","version":216},{"n":633,"text":"\t\t}","atom":"a2377","author":"capacity","version":216},{"n":634,"text":"\t\tconst relocs = this.#relocationsN();","atom":"a0","author":"init","version":0},{"n":635,"text":"\t\tlet c = code;","atom":"a2368","author":"capacity","version":215},{"n":636,"text":"\t\tfor (;;) {","atom":"a2368","author":"capacity","version":215},{"n":637,"text":"\t\t\tc = skeleton.climb(c);","atom":"a2368","author":"capacity","version":215},{"n":638,"text":"\t\t\tif (c < 0) return graph.nodeOf(c).slice(1);","atom":"a2368","author":"capacity","version":215},{"n":639,"text":"\t\t\tconst e = relocs.get(c);","atom":"a2368","author":"capacity","version":215},{"n":640,"text":"\t\t\tc = e ? e.parent : graph.parentCodeOf(c);","atom":"a2368","author":"capacity","version":215},{"n":641,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":642,"text":"\t}","atom":"a0","author":"init","version":0},{"n":643,"text":"","atom":"a0","author":"init","version":0},{"n":644,"text":"\t/** The lines hanging off a node in this set, in layout order. */","atom":"a0","author":"init","version":0},{"n":645,"text":"\t#children(code: number): Child[] {","atom":"a0","author":"init","version":0},{"n":646,"text":"\t\tconst graph = this.graph;","atom":"a0","author":"init","version":0},{"n":647,"text":"\t\tconst relocs = this.#hasMoves ? this.#relocationsN() : undefined;","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":648,"text":"\t\tconst out: Child[] = [];","atom":"a0","author":"init","version":0},{"n":649,"text":"\t\tfor (const n of graph.eachChildN(code)) {","atom":"a1091","author":"codex-capacity-chair","version":130},{"n":650,"text":"\t\t\tconst seq = graph.writerSeqOf(n);","atom":"a0","author":"init","version":0},{"n":651,"text":"\t\t\tif (!this.#has(seq) || relocs?.has(n)) continue;","atom":"a0","author":"init","version":0},{"n":652,"text":"\t\t\tout.push({","atom":"a2736","author":"capacity","version":276},{"n":653,"text":"\t\t\t\tn,","atom":"a2736","author":"capacity","version":276},{"n":654,"text":"\t\t\t\treplaces: graph.replacesN(n) ? 1 : 0,","atom":"a2736","author":"capacity","version":276},{"n":655,"text":"\t\t\t\tlamport: graph.lamportOfSeq(seq),","atom":"a2736","author":"capacity","version":276},{"n":656,"text":"\t\t\t\tseq,","atom":"a2736","author":"capacity","version":276},{"n":657,"text":"\t\t\t\tk: graph.kOf(n),","atom":"a2736","author":"capacity","version":276},{"n":658,"text":"\t\t\t});","atom":"a2736","author":"capacity","version":276},{"n":659,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":660,"text":"\t\tif (relocs) {","atom":"a0","author":"init","version":0},{"n":661,"text":"\t\t\t// The lines this set's moves put under each node, from the moves it already resolved: no row read per node","atom":"a2302","author":"capacity","version":205},{"n":662,"text":"\t\t\t// (abso Capacity).","atom":"a2302","author":"capacity","version":205},{"n":663,"text":"\t\t\tif (!this.#movedInto) {","atom":"a2302","author":"capacity","version":205},{"n":664,"text":"\t\t\t\tthis.#movedInto = new Map();","atom":"a2302","author":"capacity","version":205},{"n":665,"text":"\t\t\t\tfor (const [n, { parent }] of relocs) {","atom":"a2302","author":"capacity","version":205},{"n":666,"text":"\t\t\t\t\tconst into = this.#movedInto.get(parent);","atom":"a2302","author":"capacity","version":205},{"n":667,"text":"\t\t\t\t\tif (into) into.push(n);","atom":"a2302","author":"capacity","version":205},{"n":668,"text":"\t\t\t\t\telse this.#movedInto.set(parent, [n]);","atom":"a2302","author":"capacity","version":205},{"n":669,"text":"\t\t\t\t}","atom":"a2302","author":"capacity","version":205},{"n":670,"text":"\t\t\t}","atom":"a2302","author":"capacity","version":205},{"n":671,"text":"\t\t\tfor (const n of this.#movedInto.get(code) ?? NO_LINES) {","atom":"a2302","author":"capacity","version":205},{"n":672,"text":"\t\t\t\tconst r = relocs.get(n)!.r;","atom":"a2302","author":"capacity","version":205},{"n":673,"text":"\t\t\t\tconst seq = graph.atom(r.atom).seq;","atom":"a0","author":"init","version":0},{"n":674,"text":"\t\t\t\tout.push({","atom":"a2736","author":"capacity","version":276},{"n":675,"text":"\t\t\t\t\tn,","atom":"a2736","author":"capacity","version":276},{"n":676,"text":"\t\t\t\t\treplaces: 0,","atom":"a2736","author":"capacity","version":276},{"n":677,"text":"\t\t\t\t\tlamport: graph.lamportOfSeq(seq),","atom":"a2736","author":"capacity","version":276},{"n":678,"text":"\t\t\t\t\tseq,","atom":"a2736","author":"capacity","version":276},{"n":679,"text":"\t\t\t\t\tk: r.k,","atom":"a2736","author":"capacity","version":276},{"n":680,"text":"\t\t\t\t});","atom":"a2736","author":"capacity","version":276},{"n":681,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":682,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":683,"text":"\t\t// A line's replacements (runs of atoms that deleted it) first, then the","atom":"a0","author":"init","version":0},{"n":684,"text":"\t\t// rest; each group in descending priority (lamport, then seq); lines of","atom":"a0","author":"init","version":0},{"n":685,"text":"\t\t// one atom keep k order. A replacement already outranks every insertion","atom":"a0","author":"init","version":0},{"n":686,"text":"\t\t// after the line that reads it (it depends on them, or conflicts with","atom":"a0","author":"init","version":0},{"n":687,"text":"\t\t// them); the grouping also puts it above a `before` insertion, which","atom":"a0","author":"init","version":0},{"n":688,"text":"\t\t// doesn't read the line above, so the new text lands in the replaced","atom":"a0","author":"init","version":0},{"n":689,"text":"\t\t// line's place. A moved line ranks like an insertion by the moving atom.","atom":"a0","author":"init","version":0},{"n":690,"text":"\t\tif (out.length > 1)","atom":"a0","author":"init","version":0},{"n":691,"text":"\t\t\tout.sort((a, b) => b.replaces - a.replaces || b.lamport - a.lamport || b.seq - a.seq || a.k - b.k);","atom":"a0","author":"init","version":0},{"n":692,"text":"\t\treturn out;","atom":"a0","author":"init","version":0},{"n":693,"text":"\t}","atom":"a0","author":"init","version":0},{"n":694,"text":"","atom":"a0","author":"init","version":0},{"n":695,"text":"\t/** Parent/successor traversal keeps no history-sized ancestry or sibling frontier. */","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":696,"text":"\t*#layoutNodes(start: number): IterableIterator<number> {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":697,"text":"\t\tconst graph = this.graph;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":698,"text":"\t\tif (graph.hasOrderedChildren && !this.#hasMoves) {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":699,"text":"\t\t\tconst first = (parent: number, after?: number): number | undefined => {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":700,"text":"\t\t\t\tfor (const n of graph.orderedChildrenN(parent, after)) if (this.#has(graph.writerSeqOf(n))) return n;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":701,"text":"\t\t\t\treturn undefined;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":702,"text":"\t\t\t};","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":703,"text":"\t\t\tlet n = first(start);","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":704,"text":"\t\t\twhile (n !== undefined) {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":705,"text":"\t\t\t\tyield n;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":706,"text":"\t\t\t\tconst child = first(n);","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":707,"text":"\t\t\t\tif (child !== undefined) {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":708,"text":"\t\t\t\t\tn = child;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":709,"text":"\t\t\t\t\tcontinue;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":710,"text":"\t\t\t\t}","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":711,"text":"\t\t\t\tlet previous = n;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":712,"text":"\t\t\t\tfor (;;) {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":713,"text":"\t\t\t\t\tconst parent = graph.parentCodeOf(previous);","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":714,"text":"\t\t\t\t\tconst sibling = first(parent, previous);","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":715,"text":"\t\t\t\t\tif (sibling !== undefined) {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":716,"text":"\t\t\t\t\t\tn = sibling;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":717,"text":"\t\t\t\t\t\tbreak;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":718,"text":"\t\t\t\t\t}","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":719,"text":"\t\t\t\t\tif (parent === start) {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":720,"text":"\t\t\t\t\t\tn = undefined;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":721,"text":"\t\t\t\t\t\tbreak;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":722,"text":"\t\t\t\t\t}","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":723,"text":"\t\t\t\t\tif (parent < 0 || parent >= previous) throw new Error(\"invalid persistent layout ancestry\");","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":724,"text":"\t\t\t\t\tprevious = parent;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":725,"text":"\t\t\t\t}","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":726,"text":"\t\t\t}","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":727,"text":"\t\t\treturn;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":728,"text":"\t\t}","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":729,"text":"\t\tconst stack: number[] = [];","atom":"a0","author":"init","version":0},{"n":730,"text":"\t\tconst push = (parent: number): void => {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":731,"text":"\t\t\tconst children = this.#children(parent);","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":732,"text":"\t\t\tfor (let i = children.length - 1; i >= 0; i--) stack.push(children[i]!.n);","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":733,"text":"\t\t};","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":734,"text":"\t\tpush(start);","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":735,"text":"\t\twhile (stack.length) {","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":736,"text":"\t\t\tconst n = stack.pop()!;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":737,"text":"\t\t\tyield n;","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":738,"text":"\t\t\tpush(n);","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":739,"text":"\t\t}","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":740,"text":"\t}","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":741,"text":"","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":742,"text":"\t/** Lay out one file: its line tree from the set's atoms, linearized. */","atom":"a0","author":"init","version":0},{"n":743,"text":"\t#layout(path: string, complete: boolean): FileState {","atom":"a1006","author":"codex-capacity-chair","version":110},{"n":744,"text":"\t\tconst graph = this.graph;","atom":"a0","author":"init","version":0},{"n":745,"text":"\t\tif (graph.packedLayout && !this.#scratchMoves()) return this.#layoutPacked(path, complete);","atom":"a2399","author":"capacity","version":221},{"n":746,"text":"\t\tif (this.#scratchMoves())","atom":"a2302","author":"capacity","version":205},{"n":747,"text":"\t\t\treturn graph.withProjectionScratch((scratch) =>","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":748,"text":"\t\t\t\tthis.#layoutResolved(","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":749,"text":"\t\t\t\t\tpath,","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":750,"text":"\t\t\t\t\tcomplete,","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":751,"text":"\t\t\t\t\tscratchLayoutNodes(graph, (id) => this.#has(graph.atom(id).seq), scratch, `^${path}`),","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":752,"text":"\t\t\t\t),","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":753,"text":"\t\t\t);","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":754,"text":"\t\treturn this.#layoutResolved(path, complete);","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":755,"text":"\t}","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":756,"text":"","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":757,"text":"\t/** For each path, the files that lines moved into it were written in: worked out once per view. */","atom":"a2312","author":"capacity","version":206},{"n":758,"text":"\t#movedFrom: Map<string, Set<number>> | undefined;","atom":"a2312","author":"capacity","version":206},{"n":759,"text":"\t#movedInFrom(): Map<string, Set<number>> {","atom":"a2312","author":"capacity","version":206},{"n":760,"text":"\t\tif (this.#movedFrom) return this.#movedFrom;","atom":"a2312","author":"capacity","version":206},{"n":761,"text":"\t\tthis.#relocations();","atom":"a2377","author":"capacity","version":216},{"n":762,"text":"\t\tif (this.#movesTaken) return (this.#movedFrom = this.#movesTaken.#movedInFrom());","atom":"a2377","author":"capacity","version":216},{"n":763,"text":"\t\tconst graph = this.graph;","atom":"a2312","author":"capacity","version":206},{"n":764,"text":"\t\tconst out = new Map<string, Set<number>>();","atom":"a2312","author":"capacity","version":206},{"n":765,"text":"\t\tif (this.#hasMoves) {","atom":"a2312","author":"capacity","version":206},{"n":766,"text":"\t\t\tconst relocs = this.#relocationsN();","atom":"a2312","author":"capacity","version":206},{"n":767,"text":"\t\t\tconst fileOf = (code: number): string => this.#fileOfCode(code);","atom":"a2368","author":"capacity","version":215},{"n":768,"text":"\t\t\tfor (const [n, { parent }] of relocs) {","atom":"a2312","author":"capacity","version":206},{"n":769,"text":"\t\t\t\tconst into = fileOf(parent);","atom":"a2312","author":"capacity","version":206},{"n":770,"text":"\t\t\t\tlet from = out.get(into);","atom":"a2312","author":"capacity","version":206},{"n":771,"text":"\t\t\t\tif (!from) out.set(into, (from = new Set()));","atom":"a2312","author":"capacity","version":206},{"n":772,"text":"\t\t\t\tfrom.add(graph.writtenInIndex(n));","atom":"a2312","author":"capacity","version":206},{"n":773,"text":"\t\t\t}","atom":"a2312","author":"capacity","version":206},{"n":774,"text":"\t\t}","atom":"a2312","author":"capacity","version":206},{"n":775,"text":"\t\tthis.#movedFrom = out;","atom":"a2312","author":"capacity","version":206},{"n":776,"text":"\t\treturn out;","atom":"a2312","author":"capacity","version":206},{"n":777,"text":"\t}","atom":"a2312","author":"capacity","version":206},{"n":778,"text":"","atom":"a2312","author":"capacity","version":206},{"n":779,"text":"\t/**","atom":"a2312","author":"capacity","version":206},{"n":780,"text":"\t * Lay one file out from its packed history (abso Capacity, Graph.packedLines): the lines written in it, in the files","atom":"a2399","author":"capacity","version":221},{"n":781,"text":"\t * its moved-in lines came from, and in the files runs under any of those lines were written in, read a page at a","atom":"a2399","author":"capacity","version":221},{"n":782,"text":"\t * time; the same tree and order as #layoutResolved, built in memory with no read per line.","atom":"a2399","author":"capacity","version":221},{"n":783,"text":"\t */","atom":"a2312","author":"capacity","version":206},{"n":784,"text":"\t#layoutPacked(path: string, complete: boolean): FileState {","atom":"a2312","author":"capacity","version":206},{"n":785,"text":"\t\tconst graph = this.graph;","atom":"a2312","author":"capacity","version":206},{"n":786,"text":"\t\tconst attrs = this.#attributes(path);","atom":"a2312","author":"capacity","version":206},{"n":787,"text":"\t\tconst start = graph.startCodeOf(path);","atom":"a2312","author":"capacity","version":206},{"n":788,"text":"\t\tif (start === undefined)","atom":"a2736","author":"capacity","version":276},{"n":789,"text":"\t\t\treturn {","atom":"a2736","author":"capacity","version":276},{"n":790,"text":"\t\t\t\tattrs,","atom":"a2736","author":"capacity","version":276},{"n":791,"text":"\t\t\t\tcomplete,","atom":"a2736","author":"capacity","version":276},{"n":792,"text":"\t\t\t\tseq: EMPTY_INTS,","atom":"a2736","author":"capacity","version":276},{"n":793,"text":"\t\t\t\tvis: EMPTY_INTS,","atom":"a2736","author":"capacity","version":276},{"n":794,"text":"\t\t\t\tdeletedBy: new Map(),","atom":"a2736","author":"capacity","version":276},{"n":795,"text":"\t\t\t};","atom":"a2736","author":"capacity","version":276},{"n":796,"text":"\t\tconst relocs = this.#hasMoves ? this.#relocationsN() : undefined;","atom":"a2312","author":"capacity","version":206},{"n":797,"text":"\t\tconst files = new Set<number>([-1 - start, ...(this.#movedInFrom().get(path) ?? [])]);","atom":"a2312","author":"capacity","version":206},{"n":798,"text":"\t\tconst children = new Map<number, Child[]>();","atom":"a2312","author":"capacity","version":206},{"n":799,"text":"\t\t// Where each line's text is: its file and its place in that file's packed history. Texts are read after the walk,","atom":"a2727","author":"capacity","version":274},{"n":800,"text":"\t\t// only for the lines it shows (abso Capacity): every text a file and its moved-in sources ever had was read for","atom":"a2727","author":"capacity","version":274},{"n":801,"text":"\t\t// every layout, and abso's worker files, split out of index.ts, read all of index.ts's history each.","atom":"a2727","author":"capacity","version":274},{"n":802,"text":"\t\tconst textFile = new Map<number, number>();","atom":"a2727","author":"capacity","version":274},{"n":803,"text":"\t\tconst textPlace = new Map<number, number>();","atom":"a2727","author":"capacity","version":274},{"n":804,"text":"\t\tconst writers = new Map<number, number>();","atom":"a2436","author":"capacity","version":230},{"n":805,"text":"\t\tconst places = new Map<number, number>();","atom":"a2443","author":"capacity","version":232},{"n":806,"text":"\t\tconst deleters = new Map<number, number[]>();","atom":"a2312","author":"capacity","version":206},{"n":807,"text":"\t\t// Each atom's lamport once per layout: most lines share a few atoms, and a stored graph reads it from a page.","atom":"a2436","author":"capacity","version":230},{"n":808,"text":"\t\tconst lamports = new Map<number, number>();","atom":"a2436","author":"capacity","version":230},{"n":809,"text":"\t\tconst lamportOf = (seq: number): number => {","atom":"a2436","author":"capacity","version":230},{"n":810,"text":"\t\t\tlet lamport = lamports.get(seq);","atom":"a2436","author":"capacity","version":230},{"n":811,"text":"\t\t\tif (lamport === undefined) {","atom":"a2436","author":"capacity","version":230},{"n":812,"text":"\t\t\t\tlamport = graph.lamportOfSeq(seq);","atom":"a2436","author":"capacity","version":230},{"n":813,"text":"\t\t\t\tlamports.set(seq, lamport);","atom":"a2436","author":"capacity","version":230},{"n":814,"text":"\t\t\t}","atom":"a2436","author":"capacity","version":230},{"n":815,"text":"\t\t\treturn lamport;","atom":"a2436","author":"capacity","version":230},{"n":816,"text":"\t\t};","atom":"a2436","author":"capacity","version":230},{"n":817,"text":"\t\tfor (const file of files) {","atom":"a2312","author":"capacity","version":206},{"n":818,"text":"\t\t\t// The file's history decoded once and kept by the graph (abso Capacity): each view of it read every page again.","atom":"a2736","author":"capacity","version":276},{"n":819,"text":"\t\t\tconst history = graph.packedHistory(file);","atom":"a2736","author":"capacity","version":276},{"n":820,"text":"\t\t\tconst lines = history.lines;","atom":"a2736","author":"capacity","version":276},{"n":821,"text":"\t\t\tfor (let i = 0, place = 0; i < lines.length; i += 5, place++) {","atom":"a2736","author":"capacity","version":276},{"n":822,"text":"\t\t\t\tconst n = lines[i]!;","atom":"a2736","author":"capacity","version":276},{"n":823,"text":"\t\t\t\tconst parent = lines[i + 1]!;","atom":"a2736","author":"capacity","version":276},{"n":824,"text":"\t\t\t\tconst seq = lines[i + 2]!;","atom":"a2736","author":"capacity","version":276},{"n":825,"text":"\t\t\t\tconst k = lines[i + 3]!;","atom":"a2736","author":"capacity","version":276},{"n":826,"text":"\t\t\t\tconst replaces = lines[i + 4]!;","atom":"a2736","author":"capacity","version":276},{"n":827,"text":"\t\t\t\tif (!this.#has(seq)) continue;","atom":"a2312","author":"capacity","version":206},{"n":828,"text":"\t\t\t\tconst moved = relocs?.get(n);","atom":"a2312","author":"capacity","version":206},{"n":829,"text":"\t\t\t\tlet at = parent;","atom":"a2312","author":"capacity","version":206},{"n":830,"text":"\t\t\t\tlet child: Child = { n, replaces, lamport: lamportOf(seq), seq, k };","atom":"a2436","author":"capacity","version":230},{"n":831,"text":"\t\t\t\tif (moved) {","atom":"a2312","author":"capacity","version":206},{"n":832,"text":"\t\t\t\t\tconst mover = graph.atom(moved.r.atom).seq;","atom":"a2312","author":"capacity","version":206},{"n":833,"text":"\t\t\t\t\tchild = {","atom":"a2736","author":"capacity","version":276},{"n":834,"text":"\t\t\t\t\t\tn,","atom":"a2736","author":"capacity","version":276},{"n":835,"text":"\t\t\t\t\t\treplaces: 0,","atom":"a2736","author":"capacity","version":276},{"n":836,"text":"\t\t\t\t\t\tlamport: lamportOf(mover),","atom":"a2736","author":"capacity","version":276},{"n":837,"text":"\t\t\t\t\t\tseq: mover,","atom":"a2736","author":"capacity","version":276},{"n":838,"text":"\t\t\t\t\t\tk: moved.r.k,","atom":"a2736","author":"capacity","version":276},{"n":839,"text":"\t\t\t\t\t};","atom":"a2736","author":"capacity","version":276},{"n":840,"text":"\t\t\t\t\tat = moved.parent;","atom":"a2312","author":"capacity","version":206},{"n":841,"text":"\t\t\t\t}","atom":"a2312","author":"capacity","version":206},{"n":842,"text":"\t\t\t\tconst list = children.get(at);","atom":"a2312","author":"capacity","version":206},{"n":843,"text":"\t\t\t\tif (list) list.push(child);","atom":"a2312","author":"capacity","version":206},{"n":844,"text":"\t\t\t\telse children.set(at, [child]);","atom":"a2312","author":"capacity","version":206},{"n":845,"text":"\t\t\t\ttextFile.set(n, file);","atom":"a2727","author":"capacity","version":274},{"n":846,"text":"\t\t\t\ttextPlace.set(n, place);","atom":"a2727","author":"capacity","version":274},{"n":847,"text":"\t\t\t\twriters.set(n, seq);","atom":"a2436","author":"capacity","version":230},{"n":848,"text":"\t\t\t\tplaces.set(n, k);","atom":"a2443","author":"capacity","version":232},{"n":849,"text":"\t\t\t}","atom":"a2312","author":"capacity","version":206},{"n":850,"text":"\t\t\tconst dels = history.deletes;","atom":"a2736","author":"capacity","version":276},{"n":851,"text":"\t\t\tfor (let at = 0; at < dels.length; at += 2) {","atom":"a2736","author":"capacity","version":276},{"n":852,"text":"\t\t\t\tconst n = dels[at]!;","atom":"a2736","author":"capacity","version":276},{"n":853,"text":"\t\t\t\tconst deleter = dels[at + 1]!;","atom":"a2736","author":"capacity","version":276},{"n":854,"text":"\t\t\t\tif (!this.#has(deleter)) continue;","atom":"a2312","author":"capacity","version":206},{"n":855,"text":"\t\t\t\tconst by = deleters.get(n);","atom":"a2312","author":"capacity","version":206},{"n":856,"text":"\t\t\t\tif (by) by.push(deleter);","atom":"a2312","author":"capacity","version":206},{"n":857,"text":"\t\t\t\telse deleters.set(n, [deleter]);","atom":"a2312","author":"capacity","version":206},{"n":858,"text":"\t\t\t}","atom":"a2312","author":"capacity","version":206},{"n":859,"text":"\t\t\t// Runs written elsewhere under this file's lines follow them; the loop reads their files too.","atom":"a2399","author":"capacity","version":221},{"n":860,"text":"\t\t\tconst crossings = history.crossings;","atom":"a2736","author":"capacity","version":276},{"n":861,"text":"\t\t\tfor (let at = 0; at < crossings.length; at += 2) if (writers.has(crossings[at]!)) files.add(crossings[at + 1]!);","atom":"a2736","author":"capacity","version":276},{"n":862,"text":"\t\t}","atom":"a2312","author":"capacity","version":206},{"n":863,"text":"\t\tconst order = (a: Child, b: Child) =>","atom":"a2312","author":"capacity","version":206},{"n":864,"text":"\t\t\tb.replaces - a.replaces || b.lamport - a.lamport || b.seq - a.seq || a.k - b.k;","atom":"a2312","author":"capacity","version":206},{"n":865,"text":"\t\tconst priority = (a: number, b: number) => lamportOf(a) - lamportOf(b) || a - b;","atom":"a2436","author":"capacity","version":230},{"n":866,"text":"\t\tconst seq: number[] = [];","atom":"a2312","author":"capacity","version":206},{"n":867,"text":"\t\tconst vis: number[] = [];","atom":"a2312","author":"capacity","version":206},{"n":868,"text":"\t\tconst visText: (string | null)[] = [];","atom":"a2312","author":"capacity","version":206},{"n":869,"text":"\t\tconst visWriter: number[] = [];","atom":"a2436","author":"capacity","version":230},{"n":870,"text":"\t\tconst visK: number[] = [];","atom":"a2443","author":"capacity","version":232},{"n":871,"text":"\t\tconst seqWriter: number[] = [];","atom":"a2443","author":"capacity","version":232},{"n":872,"text":"\t\tconst seqK: number[] = [];","atom":"a2443","author":"capacity","version":232},{"n":873,"text":"\t\tconst deletedBy = new Map<number, readonly number[]>();","atom":"a2312","author":"capacity","version":206},{"n":874,"text":"\t\t// The text pages read for this layout, by file and page: each at most once.","atom":"a2727","author":"capacity","version":274},{"n":875,"text":"\t\tconst pages = new Map<number, Map<number, readonly (string | null)[]>>();","atom":"a2727","author":"capacity","version":274},{"n":876,"text":"\t\tconst textOf = (n: number): string | null => {","atom":"a2727","author":"capacity","version":274},{"n":877,"text":"\t\t\tconst file = textFile.get(n)!;","atom":"a2727","author":"capacity","version":274},{"n":878,"text":"\t\t\tconst place = textPlace.get(n)!;","atom":"a2727","author":"capacity","version":274},{"n":879,"text":"\t\t\tconst page = Math.floor(place / 256);","atom":"a2727","author":"capacity","version":274},{"n":880,"text":"\t\t\tlet byPage = pages.get(file);","atom":"a2727","author":"capacity","version":274},{"n":881,"text":"\t\t\tif (!byPage) pages.set(file, (byPage = new Map()));","atom":"a2727","author":"capacity","version":274},{"n":882,"text":"\t\t\tlet texts = byPage.get(page);","atom":"a2727","author":"capacity","version":274},{"n":883,"text":"\t\t\tif (!texts) byPage.set(page, (texts = graph.packedTextPage(file, page)));","atom":"a2727","author":"capacity","version":274},{"n":884,"text":"\t\t\treturn texts[place % 256] ?? null;","atom":"a2727","author":"capacity","version":274},{"n":885,"text":"\t\t};","atom":"a2727","author":"capacity","version":274},{"n":886,"text":"\t\tconst stack: number[] = [];","atom":"a2312","author":"capacity","version":206},{"n":887,"text":"\t\tconst push = (code: number) => {","atom":"a2312","author":"capacity","version":206},{"n":888,"text":"\t\t\tconst list = children.get(code);","atom":"a2312","author":"capacity","version":206},{"n":889,"text":"\t\t\tif (!list) return;","atom":"a2312","author":"capacity","version":206},{"n":890,"text":"\t\t\tif (list.length > 1) list.sort(order);","atom":"a2312","author":"capacity","version":206},{"n":891,"text":"\t\t\tfor (let i = list.length - 1; i >= 0; i--) stack.push(list[i]!.n);","atom":"a2312","author":"capacity","version":206},{"n":892,"text":"\t\t};","atom":"a2312","author":"capacity","version":206},{"n":893,"text":"\t\tpush(start);","atom":"a2312","author":"capacity","version":206},{"n":894,"text":"\t\twhile (stack.length) {","atom":"a2312","author":"capacity","version":206},{"n":895,"text":"\t\t\tconst n = stack.pop()!;","atom":"a2312","author":"capacity","version":206},{"n":896,"text":"\t\t\tconst by = deleters.get(n);","atom":"a2312","author":"capacity","version":206},{"n":897,"text":"\t\t\tif (by) {","atom":"a2312","author":"capacity","version":206},{"n":898,"text":"\t\t\t\tif (complete) deletedBy.set(seq.length, by.length > 1 ? by.sort(priority) : by);","atom":"a2312","author":"capacity","version":206},{"n":899,"text":"\t\t\t} else {","atom":"a2312","author":"capacity","version":206},{"n":900,"text":"\t\t\t\tvis.push(n);","atom":"a2312","author":"capacity","version":206},{"n":901,"text":"\t\t\t\tvisText.push(textOf(n));","atom":"a2727","author":"capacity","version":274},{"n":902,"text":"\t\t\t\tvisWriter.push(writers.get(n)!);","atom":"a2436","author":"capacity","version":230},{"n":903,"text":"\t\t\t\tvisK.push(places.get(n)!);","atom":"a2443","author":"capacity","version":232},{"n":904,"text":"\t\t\t}","atom":"a2312","author":"capacity","version":206},{"n":905,"text":"\t\t\tif (complete) {","atom":"a2443","author":"capacity","version":232},{"n":906,"text":"\t\t\t\tseq.push(n);","atom":"a2443","author":"capacity","version":232},{"n":907,"text":"\t\t\t\tseqWriter.push(writers.get(n)!);","atom":"a2443","author":"capacity","version":232},{"n":908,"text":"\t\t\t\tseqK.push(places.get(n)!);","atom":"a2443","author":"capacity","version":232},{"n":909,"text":"\t\t\t}","atom":"a2443","author":"capacity","version":232},{"n":910,"text":"\t\t\tpush(n);","atom":"a2312","author":"capacity","version":206},{"n":911,"text":"\t\t}","atom":"a2312","author":"capacity","version":206},{"n":912,"text":"\t\treturn {","atom":"a2436","author":"capacity","version":230},{"n":913,"text":"\t\t\tattrs,","atom":"a2436","author":"capacity","version":230},{"n":914,"text":"\t\t\tcomplete,","atom":"a2436","author":"capacity","version":230},{"n":915,"text":"\t\t\tseq: Int32Array.from(seq),","atom":"a2436","author":"capacity","version":230},{"n":916,"text":"\t\t\tvis: Int32Array.from(vis),","atom":"a2436","author":"capacity","version":230},{"n":917,"text":"\t\t\tdeletedBy,","atom":"a2436","author":"capacity","version":230},{"n":918,"text":"\t\t\tvisText,","atom":"a2436","author":"capacity","version":230},{"n":919,"text":"\t\t\tvisWriter: Int32Array.from(visWriter),","atom":"a2436","author":"capacity","version":230},{"n":920,"text":"\t\t\tvisK: Int32Array.from(visK),","atom":"a2443","author":"capacity","version":232},{"n":921,"text":"\t\t\t...(complete ? { seqWriter: Int32Array.from(seqWriter), seqK: Int32Array.from(seqK) } : {}),","atom":"a2443","author":"capacity","version":232},{"n":922,"text":"\t\t};","atom":"a2436","author":"capacity","version":230},{"n":923,"text":"\t}","atom":"a2312","author":"capacity","version":206},{"n":924,"text":"","atom":"a2312","author":"capacity","version":206},{"n":925,"text":"\t#attributes(path: string): FileAttrs {","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":926,"text":"\t\tconst graph = this.graph;","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":927,"text":"\t\t// For each attribute, the highest-priority setter in the set wins.","atom":"a0","author":"init","version":0},{"n":928,"text":"\t\tconst setters = new Map<string, { id: AtomId; value: string | null }>();","atom":"a0","author":"init","version":0},{"n":929,"text":"\t\tconst file = graph.packedFiles ? graph.pathIndexOf(path) : undefined;","atom":"a2312","author":"capacity","version":206},{"n":930,"text":"\t\tif (graph.packedFiles) {","atom":"a2312","author":"capacity","version":206},{"n":931,"text":"\t\t\tfor (const [seq, name, value] of file === undefined ? [] : graph.packedAttrs(file)) {","atom":"a2312","author":"capacity","version":206},{"n":932,"text":"\t\t\t\tif (!this.#has(seq)) continue;","atom":"a2312","author":"capacity","version":206},{"n":933,"text":"\t\t\t\tconst id = graph.idOfSeq(seq);","atom":"a2312","author":"capacity","version":206},{"n":934,"text":"\t\t\t\tconst best = setters.get(name);","atom":"a2312","author":"capacity","version":206},{"n":935,"text":"\t\t\t\tif (!best || graph.comparePriority(best.id, id) < 0) setters.set(name, { id, value });","atom":"a2312","author":"capacity","version":206},{"n":936,"text":"\t\t\t}","atom":"a2312","author":"capacity","version":206},{"n":937,"text":"\t\t\treturn {","atom":"a2312","author":"capacity","version":206},{"n":938,"text":"\t\t\t\texists: setters.get(\"exists\")?.value === \"1\",","atom":"a2312","author":"capacity","version":206},{"n":939,"text":"\t\t\t\texec: setters.get(\"exec\")?.value === \"1\",","atom":"a2312","author":"capacity","version":206},{"n":940,"text":"\t\t\t\tlink: setters.get(\"link\")?.value ?? null,","atom":"a2312","author":"capacity","version":206},{"n":941,"text":"\t\t\t\tblob: setters.get(\"blob\")?.value ?? null,","atom":"a2312","author":"capacity","version":206},{"n":942,"text":"\t\t\t};","atom":"a2312","author":"capacity","version":206},{"n":943,"text":"\t\t}","atom":"a2312","author":"capacity","version":206},{"n":944,"text":"\t\tfor (const id of graph.eachAtomIn(path)) {","atom":"a1045","author":"codex-capacity-chair","version":119},{"n":945,"text":"\t\t\tif (!this.#has(graph.atom(id).seq)) continue;","atom":"a0","author":"init","version":0},{"n":946,"text":"\t\t\tfor (const a of graph.atom(id).attrs ?? []) {","atom":"a0","author":"init","version":0},{"n":947,"text":"\t\t\t\tif (a.file !== path) continue;","atom":"a0","author":"init","version":0},{"n":948,"text":"\t\t\t\tconst best = setters.get(a.name);","atom":"a0","author":"init","version":0},{"n":949,"text":"\t\t\t\tif (!best || graph.comparePriority(best.id, id) < 0) setters.set(a.name, { id, value: a.value });","atom":"a0","author":"init","version":0},{"n":950,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":951,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":952,"text":"","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":953,"text":"\t\treturn {","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":954,"text":"\t\t\texists: setters.get(\"exists\")?.value === \"1\",","atom":"a0","author":"init","version":0},{"n":955,"text":"\t\t\texec: setters.get(\"exec\")?.value === \"1\",","atom":"a0","author":"init","version":0},{"n":956,"text":"\t\t\tlink: setters.get(\"link\")?.value ?? null,","atom":"a0","author":"init","version":0},{"n":957,"text":"\t\t\tblob: setters.get(\"blob\")?.value ?? null,","atom":"a0","author":"init","version":0},{"n":958,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":959,"text":"\t}","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":960,"text":"","atom":"a0","author":"init","version":0},{"n":961,"text":"\t#layoutResolved(path: string, complete: boolean, nodes?: Iterable<number>): FileState {","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":962,"text":"\t\tconst graph = this.graph;","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":963,"text":"\t\tconst attrs = this.#attributes(path);","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":964,"text":"\t\tconst seq: number[] = [];","atom":"a0","author":"init","version":0},{"n":965,"text":"\t\tconst vis: number[] = [];","atom":"a0","author":"init","version":0},{"n":966,"text":"\t\tconst deletedBy = new Map<number, readonly number[]>();","atom":"a0","author":"init","version":0},{"n":967,"text":"","atom":"a1105","author":"codex-capacity-chair","version":131},{"n":968,"text":"\t\tconst start = graph.startCodeOf(path);","atom":"a0","author":"init","version":0},{"n":969,"text":"\t\tconst priority = (a: number, b: number) => graph.lamportOfSeq(a) - graph.lamportOfSeq(b) || a - b;","atom":"a0","author":"init","version":0},{"n":970,"text":"\t\tfor (const n of nodes ?? (start === undefined ? [] : this.#layoutNodes(start))) {","atom":"a1112","author":"codex-capacity-chair","version":132},{"n":971,"text":"\t\t\tlet deleted = false;","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":972,"text":"\t\t\tconst by: number[] = [];","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":973,"text":"\t\t\tfor (const deleter of graph.eachDeleterSeqOf(n)) {","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":974,"text":"\t\t\t\tif (!this.#has(deleter)) continue;","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":975,"text":"\t\t\t\tdeleted = true;","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":976,"text":"\t\t\t\tif (!complete) break;","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":977,"text":"\t\t\t\tby.push(deleter);","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":978,"text":"\t\t\t}","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":979,"text":"\t\t\tif (deleted) {","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":980,"text":"\t\t\t\tif (complete) deletedBy.set(seq.length, by.length > 1 ? by.sort(priority) : by);","atom":"a1083","author":"codex-capacity-chair","version":128},{"n":981,"text":"\t\t\t} else vis.push(n);","atom":"a1006","author":"codex-capacity-chair","version":110},{"n":982,"text":"\t\t\tif (complete) seq.push(n);","atom":"a1006","author":"codex-capacity-chair","version":110},{"n":983,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":984,"text":"","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":985,"text":"\t\treturn {","atom":"a2736","author":"capacity","version":276},{"n":986,"text":"\t\t\tattrs,","atom":"a2736","author":"capacity","version":276},{"n":987,"text":"\t\t\tcomplete,","atom":"a2736","author":"capacity","version":276},{"n":988,"text":"\t\t\tseq: Int32Array.from(seq),","atom":"a2736","author":"capacity","version":276},{"n":989,"text":"\t\t\tvis: Int32Array.from(vis),","atom":"a2736","author":"capacity","version":276},{"n":990,"text":"\t\t\tdeletedBy,","atom":"a2736","author":"capacity","version":276},{"n":991,"text":"\t\t};","atom":"a2736","author":"capacity","version":276},{"n":992,"text":"\t}","atom":"a0","author":"init","version":0},{"n":993,"text":"","atom":"a0","author":"init","version":0},{"n":994,"text":"\tget #known(): string[] {","atom":"a0","author":"init","version":0},{"n":995,"text":"\t\tif (!this.#knownList) {","atom":"a0","author":"init","version":0},{"n":996,"text":"\t\t\tconst known = new Set<string>();","atom":"a0","author":"init","version":0},{"n":997,"text":"\t\t\tif (this.#stable) {","atom":"a998","author":"codex-capacity-chair","version":109},{"n":998,"text":"\t\t\t\tfor (const id of this.#stable) for (const file of this.graph.filesOf(id)) known.add(file);","atom":"a998","author":"codex-capacity-chair","version":109},{"n":999,"text":"\t\t\t} else {","atom":"a998","author":"codex-capacity-chair","version":109},{"n":1000,"text":"\t\t\t\tfor (let seq = 0; seq < this.#in.length; seq++)","atom":"a998","author":"codex-capacity-chair","version":109},{"n":1001,"text":"\t\t\t\t\tif (this.#in[seq] === 1) for (const file of this.graph.filesOf(this.graph.idOfSeq(seq))) known.add(file);","atom":"a998","author":"codex-capacity-chair","version":109},{"n":1002,"text":"\t\t\t}","atom":"a998","author":"codex-capacity-chair","version":109},{"n":1003,"text":"\t\t\tthis.#knownList = [...known].sort();","atom":"a0","author":"init","version":0},{"n":1004,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":1005,"text":"\t\treturn this.#knownList;","atom":"a0","author":"init","version":0},{"n":1006,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1007,"text":"","atom":"a0","author":"init","version":0},{"n":1008,"text":"\t/** Files with at least one visible line, sorted. */","atom":"a0","author":"init","version":0},{"n":1009,"text":"\tpaths(): string[] {","atom":"a0","author":"init","version":0},{"n":1010,"text":"\t\t// Without walking every file the graph has ever had (abso Capacity): a draft's view over its base's has the base's","atom":"a2585","author":"capacity","version":252},{"n":1011,"text":"\t\t// files, with the ones its draft touches checked here; a published version's are kept (knowPaths).","atom":"a2585","author":"capacity","version":252},{"n":1012,"text":"\t\tconst shared = this.#filesFrom === undefined ? null : this.#sharedFiles();","atom":"a2585","author":"capacity","version":252},{"n":1013,"text":"\t\tif (shared) {","atom":"a2585","author":"capacity","version":252},{"n":1014,"text":"\t\t\tconst out = shared.from.paths().filter((p) => !shared.except.has(p));","atom":"a2585","author":"capacity","version":252},{"n":1015,"text":"\t\t\tfor (const p of shared.except) if (this.hasFile(p)) out.push(p);","atom":"a2585","author":"capacity","version":252},{"n":1016,"text":"\t\t\treturn out.sort();","atom":"a2585","author":"capacity","version":252},{"n":1017,"text":"\t\t}","atom":"a2585","author":"capacity","version":252},{"n":1018,"text":"\t\tif (this.#pathsFrom !== undefined) {","atom":"a2585","author":"capacity","version":252},{"n":1019,"text":"\t\t\tif (this.#knownPaths === undefined) this.#knownPaths = this.#pathsFrom() ?? null;","atom":"a2585","author":"capacity","version":252},{"n":1020,"text":"\t\t\tif (this.#knownPaths) return [...this.#knownPaths].sort();","atom":"a2585","author":"capacity","version":252},{"n":1021,"text":"\t\t}","atom":"a2585","author":"capacity","version":252},{"n":1022,"text":"\t\tif (this.#stable) {","atom":"a1039","author":"codex-capacity-chair","version":118},{"n":1023,"text":"\t\t\tconst paths: string[] = [];","atom":"a1039","author":"codex-capacity-chair","version":118},{"n":1024,"text":"\t\t\tfor (const path of this.graph.knownFiles()) {","atom":"a1039","author":"codex-capacity-chair","version":118},{"n":1025,"text":"\t\t\t\tif (this.hasFile(path)) paths.push(path);","atom":"a1039","author":"codex-capacity-chair","version":118},{"n":1026,"text":"\t\t\t\telse {","atom":"a2668","author":"capacity","version":263},{"n":1027,"text":"\t\t\t\t\tthis.#files.delete(path);","atom":"a2668","author":"capacity","version":263},{"n":1028,"text":"\t\t\t\t\tthis.#used.delete(path);","atom":"a2668","author":"capacity","version":263},{"n":1029,"text":"\t\t\t\t}","atom":"a2668","author":"capacity","version":263},{"n":1030,"text":"\t\t\t}","atom":"a1039","author":"codex-capacity-chair","version":118},{"n":1031,"text":"\t\t\treturn paths.sort();","atom":"a1039","author":"codex-capacity-chair","version":118},{"n":1032,"text":"\t\t}","atom":"a1039","author":"codex-capacity-chair","version":118},{"n":1033,"text":"\t\treturn this.#known.filter((p) => this.hasFile(p));","atom":"a0","author":"init","version":0},{"n":1034,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1035,"text":"","atom":"a0","author":"init","version":0},{"n":1036,"text":"\t/** Every file the set has ever written a line in, including fully deleted ones. */","atom":"a0","author":"init","version":0},{"n":1037,"text":"\tknownPaths(): string[] {","atom":"a0","author":"init","version":0},{"n":1038,"text":"\t\treturn [...this.#known];","atom":"a0","author":"init","version":0},{"n":1039,"text":"\t}","atom":"a2319","author":"capacity","version":207},{"n":1040,"text":"","atom":"a2319","author":"capacity","version":207},{"n":1041,"text":"\t/** The file line n sits in, in this set: fileOf by the line's number, with no lookup of its id. */","atom":"a2350","author":"capacity","version":212},{"n":1042,"text":"\tfileOfNumber(n: number): string {","atom":"a2350","author":"capacity","version":212},{"n":1043,"text":"\t\treturn this.#fileOfN(n);","atom":"a2350","author":"capacity","version":212},{"n":1044,"text":"\t}","atom":"a2350","author":"capacity","version":212},{"n":1045,"text":"","atom":"a2350","author":"capacity","version":212},{"n":1046,"text":"\t/** How many visible lines a file has. */","atom":"a2319","author":"capacity","version":207},{"n":1047,"text":"\tvisibleCount(path: string): number {","atom":"a2319","author":"capacity","version":207},{"n":1048,"text":"\t\treturn this.#file(path).vis.length;","atom":"a2319","author":"capacity","version":207},{"n":1049,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1050,"text":"","atom":"a0","author":"init","version":0},{"n":1051,"text":"\t/** Whether the file exists in this projection (has a visible line). */","atom":"a0","author":"init","version":0},{"n":1052,"text":"\thasFile(path: string): boolean {","atom":"a0","author":"init","version":0},{"n":1053,"text":"\t\tif (!this.#files.has(path)) {","atom":"a2498","author":"capacity","version":245},{"n":1054,"text":"\t\t\t// A file the draft doesn't touch exists as it does in the base; a published version's files are kept.","atom":"a2498","author":"capacity","version":245},{"n":1055,"text":"\t\t\tconst shared = this.#filesFrom === undefined ? null : this.#sharedFiles();","atom":"a2498","author":"capacity","version":245},{"n":1056,"text":"\t\t\tif (shared && !shared.except.has(path)) return shared.from.hasFile(path);","atom":"a2498","author":"capacity","version":245},{"n":1057,"text":"\t\t\tif (this.#pathsFrom !== undefined) {","atom":"a2498","author":"capacity","version":245},{"n":1058,"text":"\t\t\t\tif (this.#knownPaths === undefined) this.#knownPaths = this.#pathsFrom() ?? null;","atom":"a2498","author":"capacity","version":245},{"n":1059,"text":"\t\t\t\tif (this.#knownPaths) return this.#knownPaths.has(path);","atom":"a2498","author":"capacity","version":245},{"n":1060,"text":"\t\t\t}","atom":"a2498","author":"capacity","version":245},{"n":1061,"text":"\t\t}","atom":"a2498","author":"capacity","version":245},{"n":1062,"text":"\t\tconst attrs = this.attrs(path);","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":1063,"text":"\t\treturn attrs.exists || attrs.link !== null || attrs.blob !== null || this.#file(path).vis.length > 0;","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":1064,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1065,"text":"","atom":"a0","author":"init","version":0},{"n":1066,"text":"\t/** A file's attributes: kept while empty, executable, a link's target. */","atom":"a0","author":"init","version":0},{"n":1067,"text":"\tattrs(path: string): FileAttrs {","atom":"a0","author":"init","version":0},{"n":1068,"text":"\t\treturn this.#files.get(path)?.attrs ?? this.#attributes(path);","atom":"a1152","author":"codex-capacity-chair","version":140},{"n":1069,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1070,"text":"","atom":"a0","author":"init","version":0},{"n":1071,"text":"\t/** The projected text of a file (\"\" if it has no visible lines). */","atom":"a0","author":"init","version":0},{"n":1072,"text":"\ttext(path: string): string {","atom":"a0","author":"init","version":0},{"n":1073,"text":"\t\tif (this.#textCache?.path === path) return this.#textCache.text;","atom":"a0","author":"init","version":0},{"n":1074,"text":"\t\tconst { vis, visText } = this.#file(path);","atom":"a2312","author":"capacity","version":206},{"n":1075,"text":"\t\tconst lines: string[] = new Array(vis.length);","atom":"a0","author":"init","version":0},{"n":1076,"text":"\t\tfor (let i = 0; i < vis.length; i++) lines[i] = visText?.[i] ?? this.graph.textOf(vis[i]!);","atom":"a2312","author":"capacity","version":206},{"n":1077,"text":"\t\tconst text = joinLines(lines);","atom":"a0","author":"init","version":0},{"n":1078,"text":"\t\tthis.#textCache = { path, text };","atom":"a0","author":"init","version":0},{"n":1079,"text":"\t\treturn text;","atom":"a0","author":"init","version":0},{"n":1080,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1081,"text":"","atom":"a0","author":"init","version":0},{"n":1082,"text":"\t/** Whether a file reads the same here and in `other` (of the same graph), compared line by line without joining either (#46). */","atom":"a0","author":"init","version":0},{"n":1083,"text":"\tsameText(path: string, other: ReadView): boolean {","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":1084,"text":"\t\tif (!(other instanceof View)) {","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":1085,"text":"\t\t\tconst a = this.lines(path),","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":1086,"text":"\t\t\t\tb = other.lines(path);","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":1087,"text":"\t\t\treturn a.length === b.length && a.every((line, i) => line.text === b[i]!.text);","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":1088,"text":"\t\t}","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":1089,"text":"\t\tconst a = this.#file(path).vis;","atom":"a0","author":"init","version":0},{"n":1090,"text":"\t\tconst b = other.#file(path).vis;","atom":"a0","author":"init","version":0},{"n":1091,"text":"\t\tif (a.length !== b.length) return false;","atom":"a0","author":"init","version":0},{"n":1092,"text":"\t\tfor (let i = 0; i < a.length; i++)","atom":"a0","author":"init","version":0},{"n":1093,"text":"\t\t\tif (a[i] !== b[i] && this.graph.textOf(a[i]!) !== this.graph.textOf(b[i]!)) return false;","atom":"a0","author":"init","version":0},{"n":1094,"text":"\t\treturn true;","atom":"a0","author":"init","version":0},{"n":1095,"text":"\t}","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1096,"text":"","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1097,"text":"\t*lineChunks(path: string): IterableIterator<() => Iterable<string>> {","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1098,"text":"\t\t// The texts the packed layout already holds, read a page at a time (abso Capacity, 714): a record's diff read each","atom":"a3004","author":"capacity","version":315},{"n":1099,"text":"\t\t// line's own row, 11,873 statements for abso's index.ts. Only a line too long to pack is read in chunks.","atom":"a3004","author":"capacity","version":315},{"n":1100,"text":"\t\tconst { vis, visText } = this.#file(path);","atom":"a3004","author":"capacity","version":315},{"n":1101,"text":"\t\tfor (let i = 0; i < vis.length; i++) {","atom":"a3004","author":"capacity","version":315},{"n":1102,"text":"\t\t\tconst packed = visText?.[i];","atom":"a3004","author":"capacity","version":315},{"n":1103,"text":"\t\t\tif (packed != null) yield () => [packed];","atom":"a3004","author":"capacity","version":315},{"n":1104,"text":"\t\t\telse yield () => this.graph.textChunks(vis[i]!);","atom":"a3004","author":"capacity","version":315},{"n":1105,"text":"\t\t}","atom":"a3004","author":"capacity","version":315},{"n":1106,"text":"\t}","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1107,"text":"","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1108,"text":"\t/** Visible lines without retaining their text in the view cache. */","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1109,"text":"\t*visibleLines(path: string): IterableIterator<VisibleLine> {","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1110,"text":"\t\tconst graph = this.graph;","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1111,"text":"\t\tfor (const n of this.#file(path).vis)","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1112,"text":"\t\t\tyield {","atom":"a2736","author":"capacity","version":276},{"n":1113,"text":"\t\t\t\tid: graph.lineIdOf(n),","atom":"a2736","author":"capacity","version":276},{"n":1114,"text":"\t\t\t\ttext: graph.textOf(n),","atom":"a2736","author":"capacity","version":276},{"n":1115,"text":"\t\t\t\tatom: atomId(graph.writerSeqOf(n)),","atom":"a3014","author":"capacity","version":317},{"n":1116,"text":"\t\t\t};","atom":"a2736","author":"capacity","version":276},{"n":1117,"text":"\t}","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1118,"text":"","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1119,"text":"\t/** Atom-building line handles; text is loaded only when requested. */","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1120,"text":"\tbuildLines(path: string): readonly VisibleLine[] {","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1121,"text":"\t\tconst graph = this.graph;","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1122,"text":"\t\t// Texts and writers the packed layout already holds are not read again (abso Capacity).","atom":"a2436","author":"capacity","version":230},{"n":1123,"text":"\t\tconst { vis, visText, visWriter, visK } = this.#file(path);","atom":"a2443","author":"capacity","version":232},{"n":1124,"text":"\t\tconst lines: VisibleLine[] = new Array(vis.length);","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1125,"text":"\t\tfor (let i = 0; i < vis.length; i++) {","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1126,"text":"\t\t\tconst n = vis[i]!;","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1127,"text":"\t\t\tconst packed = visText?.[i];","atom":"a2431","author":"capacity","version":229},{"n":1128,"text":"\t\t\tlines[i] = {","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1129,"text":"\t\t\t\tid: visWriter && visK ? lineId(atomId(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),","atom":"a3014","author":"capacity","version":317},{"n":1130,"text":"\t\t\t\ttextChunks: () => graph.textChunks(n),","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1131,"text":"\t\t\t\tget text() {","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1132,"text":"\t\t\t\t\treturn packed ?? graph.textOf(n);","atom":"a2431","author":"capacity","version":229},{"n":1133,"text":"\t\t\t\t},","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1134,"text":"\t\t\t\tatom: atomId(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),","atom":"a3014","author":"capacity","version":317},{"n":1135,"text":"\t\t\t};","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1136,"text":"\t\t}","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1137,"text":"\t\treturn lines;","atom":"a1890","author":"codex-capacity-chair","version":175},{"n":1138,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1139,"text":"","atom":"a0","author":"init","version":0},{"n":1140,"text":"\t/** Visible lines with their ids. */","atom":"a0","author":"init","version":0},{"n":1141,"text":"\tlines(path: string): readonly VisibleLine[] {","atom":"a0","author":"init","version":0},{"n":1142,"text":"\t\tif (this.#linesCache?.path === path) return this.#linesCache.lines;","atom":"a0","author":"init","version":0},{"n":1143,"text":"\t\tconst graph = this.graph;","atom":"a0","author":"init","version":0},{"n":1144,"text":"\t\tconst { vis, visText, visWriter, visK } = this.#file(path);","atom":"a2443","author":"capacity","version":232},{"n":1145,"text":"\t\tconst lines: VisibleLine[] = new Array(vis.length);","atom":"a0","author":"init","version":0},{"n":1146,"text":"\t\t// Writer seqs come from the graph's own layout, so they're named with atomId, not checked by idOfSeq (abso 738):","atom":"a3014","author":"capacity","version":317},{"n":1147,"text":"\t\t// on a stored graph its check read the atom count once a line, about 0.9 s of a warm draft-state on abso.","atom":"a3014","author":"capacity","version":317},{"n":1148,"text":"\t\tfor (let i = 0; i < vis.length; i++) {","atom":"a0","author":"init","version":0},{"n":1149,"text":"\t\t\tconst n = vis[i]!;","atom":"a0","author":"init","version":0},{"n":1150,"text":"\t\t\tlines[i] = {","atom":"a2431","author":"capacity","version":229},{"n":1151,"text":"\t\t\t\tid: visWriter && visK ? lineId(atomId(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),","atom":"a3014","author":"capacity","version":317},{"n":1152,"text":"\t\t\t\ttext: visText?.[i] ?? graph.textOf(n),","atom":"a2431","author":"capacity","version":229},{"n":1153,"text":"\t\t\t\tatom: atomId(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),","atom":"a3014","author":"capacity","version":317},{"n":1154,"text":"\t\t\t};","atom":"a2431","author":"capacity","version":229},{"n":1155,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":1156,"text":"\t\tthis.#linesCache = { path, lines };","atom":"a0","author":"init","version":0},{"n":1157,"text":"\t\treturn lines;","atom":"a0","author":"init","version":0},{"n":1158,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1159,"text":"","atom":"a0","author":"init","version":0},{"n":1160,"text":"\t/** The full linearized sequence of a file, tombstones included. */","atom":"a0","author":"init","version":0},{"n":1161,"text":"\tsequence(path: string): readonly SeqLine[] {","atom":"a0","author":"init","version":0},{"n":1162,"text":"\t\tif (this.#seqCache?.path === path) return this.#seqCache.seq;","atom":"a0","author":"init","version":0},{"n":1163,"text":"\t\tconst graph = this.graph;","atom":"a0","author":"init","version":0},{"n":1164,"text":"\t\tconst f = this.#file(path, true);","atom":"a1006","author":"codex-capacity-chair","version":110},{"n":1165,"text":"\t\tconst out: SeqLine[] = new Array(f.seq.length);","atom":"a0","author":"init","version":0},{"n":1166,"text":"\t\t// Ids and writers from the packed layout, and each text read only when asked (abso Capacity): callers walk a few","atom":"a2443","author":"capacity","version":232},{"n":1167,"text":"\t\t// lines of a file's history, and reading every line's text was a row each on a stored graph.","atom":"a2443","author":"capacity","version":232},{"n":1168,"text":"\t\tconst { seqWriter, seqK } = f;","atom":"a2443","author":"capacity","version":232},{"n":1169,"text":"\t\tfor (let i = 0; i < f.seq.length; i++) {","atom":"a0","author":"init","version":0},{"n":1170,"text":"\t\t\tconst n = f.seq[i]!;","atom":"a0","author":"init","version":0},{"n":1171,"text":"\t\t\tconst by = f.deletedBy.get(i);","atom":"a0","author":"init","version":0},{"n":1172,"text":"\t\t\tconst writer = seqWriter ? seqWriter[i]! : graph.writerSeqOf(n);","atom":"a2443","author":"capacity","version":232},{"n":1173,"text":"\t\t\tlet text: string | undefined;","atom":"a2443","author":"capacity","version":232},{"n":1174,"text":"\t\t\tout[i] = {","atom":"a0","author":"init","version":0},{"n":1175,"text":"\t\t\t\tid: seqWriter && seqK ? lineId(atomId(writer), seqK[i]!) : graph.lineIdOf(n),","atom":"a3014","author":"capacity","version":317},{"n":1176,"text":"\t\t\t\tget text() {","atom":"a2443","author":"capacity","version":232},{"n":1177,"text":"\t\t\t\t\ttext ??= graph.textOf(n);","atom":"a2443","author":"capacity","version":232},{"n":1178,"text":"\t\t\t\t\treturn text;","atom":"a2443","author":"capacity","version":232},{"n":1179,"text":"\t\t\t\t},","atom":"a2443","author":"capacity","version":232},{"n":1180,"text":"\t\t\t\tatom: atomId(writer),","atom":"a3014","author":"capacity","version":317},{"n":1181,"text":"\t\t\t\tdeletedBy: by ? by.map((s) => atomId(s)) : NONE,","atom":"a3014","author":"capacity","version":317},{"n":1182,"text":"\t\t\t\tvisible: by === undefined,","atom":"a0","author":"init","version":0},{"n":1183,"text":"\t\t\t};","atom":"a0","author":"init","version":0},{"n":1184,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":1185,"text":"\t\tthis.#seqCache = { path, seq: out };","atom":"a0","author":"init","version":0},{"n":1186,"text":"\t\treturn out;","atom":"a0","author":"init","version":0},{"n":1187,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1188,"text":"","atom":"a0","author":"init","version":0},{"n":1189,"text":"\t/** Two visible neighbours without retaining the file's historical sequence. */","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1190,"text":"\tvisibleNeighbours(path: string, line: LineId): LineId[] {","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1191,"text":"\t\tconst graph = this.graph;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1192,"text":"\t\tconst target = graph.lineN(line);","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1193,"text":"\t\tconst start = graph.startCodeOf(path);","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1194,"text":"\t\tif (target < 0 || start === undefined) return [];","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1195,"text":"\t\tconst scan = (nodes: Iterable<number>): LineId[] => {","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1196,"text":"\t\t\tlet previous: LineId | undefined;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1197,"text":"\t\t\tlet found = false;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1198,"text":"\t\t\tfor (const n of nodes) {","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1199,"text":"\t\t\t\tif (n === target) {","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1200,"text":"\t\t\t\t\tfound = true;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1201,"text":"\t\t\t\t\tcontinue;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1202,"text":"\t\t\t\t}","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1203,"text":"\t\t\t\tlet deleted = false;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1204,"text":"\t\t\t\tfor (const seq of graph.eachDeleterSeqOf(n))","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1205,"text":"\t\t\t\t\tif (this.#has(seq)) {","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1206,"text":"\t\t\t\t\t\tdeleted = true;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1207,"text":"\t\t\t\t\t\tbreak;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1208,"text":"\t\t\t\t\t}","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1209,"text":"\t\t\t\tif (deleted) continue;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1210,"text":"\t\t\t\tconst id = graph.lineIdOf(n);","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1211,"text":"\t\t\t\tif (found) return previous === undefined ? [id] : [previous, id];","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1212,"text":"\t\t\t\tprevious = id;","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1213,"text":"\t\t\t}","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1214,"text":"\t\t\treturn found && previous !== undefined ? [previous] : [];","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1215,"text":"\t\t};","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1216,"text":"\t\tif (this.#scratchMoves())","atom":"a2302","author":"capacity","version":205},{"n":1217,"text":"\t\t\treturn graph.withProjectionScratch((scratch) =>","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1218,"text":"\t\t\t\tscan(scratchLayoutNodes(graph, (id) => this.#has(graph.atom(id).seq), scratch, graph.nodeOf(start))),","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1219,"text":"\t\t\t);","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1220,"text":"\t\treturn scan(this.#layoutNodes(start));","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1221,"text":"\t}","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1222,"text":"","atom":"a1143","author":"codex-capacity-chair","version":138},{"n":1223,"text":"\t/** Index of a line in `sequence(path)`, or -1. */","atom":"a0","author":"init","version":0},{"n":1224,"text":"\tsequenceIndex(path: string, line: LineId): number {","atom":"a0","author":"init","version":0},{"n":1225,"text":"\t\tconst f = this.#file(path, true);","atom":"a1006","author":"codex-capacity-chair","version":110},{"n":1226,"text":"\t\tif (!f.seqIndex) {","atom":"a0","author":"init","version":0},{"n":1227,"text":"\t\t\tf.seqIndex = new Map();","atom":"a0","author":"init","version":0},{"n":1228,"text":"\t\t\tfor (let i = 0; i < f.seq.length; i++) f.seqIndex.set(f.seq[i]!, i);","atom":"a0","author":"init","version":0},{"n":1229,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":1230,"text":"\t\treturn f.seqIndex.get(this.graph.lineN(line)) ?? -1;","atom":"a0","author":"init","version":0},{"n":1231,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1232,"text":"","atom":"a0","author":"init","version":0},{"n":1233,"text":"\t/** Index of a line in `lines(path)` (0-based visible line number), or -1 if not visible. */","atom":"a0","author":"init","version":0},{"n":1234,"text":"\tlineNumber(path: string, line: LineId): number {","atom":"a0","author":"init","version":0},{"n":1235,"text":"\t\treturn this.lineNumberOf(path, this.graph.lineN(line));","atom":"a2350","author":"capacity","version":212},{"n":1236,"text":"\t}","atom":"a2350","author":"capacity","version":212},{"n":1237,"text":"","atom":"a2350","author":"capacity","version":212},{"n":1238,"text":"\t/** lineNumber by the line's number, with no lookup of its id. */","atom":"a2350","author":"capacity","version":212},{"n":1239,"text":"\tlineNumberOf(path: string, n: number): number {","atom":"a2350","author":"capacity","version":212},{"n":1240,"text":"\t\tconst f = this.#file(path);","atom":"a0","author":"init","version":0},{"n":1241,"text":"\t\tif (!f.visIndex) {","atom":"a0","author":"init","version":0},{"n":1242,"text":"\t\t\tf.visIndex = new Map();","atom":"a0","author":"init","version":0},{"n":1243,"text":"\t\t\tfor (let i = 0; i < f.vis.length; i++) f.visIndex.set(f.vis[i]!, i);","atom":"a0","author":"init","version":0},{"n":1244,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":1245,"text":"\t\treturn f.visIndex.get(n) ?? -1;","atom":"a2350","author":"capacity","version":212},{"n":1246,"text":"\t}","atom":"a2350","author":"capacity","version":212},{"n":1247,"text":"","atom":"a2350","author":"capacity","version":212},{"n":1248,"text":"\t/** The seq of the atom that wrote each visible line, in order: lines() without ids or text. */","atom":"a2350","author":"capacity","version":212},{"n":1249,"text":"\tvisibleWriters(path: string): number[] {","atom":"a2350","author":"capacity","version":212},{"n":1250,"text":"\t\tconst graph = this.graph;","atom":"a2350","author":"capacity","version":212},{"n":1251,"text":"\t\tconst { vis, visWriter } = this.#file(path);","atom":"a2441","author":"capacity","version":231},{"n":1252,"text":"\t\t// The packed layout keeps them (abso Capacity): looking each up again read a page per few lines on a stored graph.","atom":"a2441","author":"capacity","version":231},{"n":1253,"text":"\t\tif (visWriter) return Array.from(visWriter);","atom":"a2441","author":"capacity","version":231},{"n":1254,"text":"\t\treturn Array.from(vis, (n) => graph.writerSeqOf(n));","atom":"a2441","author":"capacity","version":231},{"n":1255,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1256,"text":"","atom":"a0","author":"init","version":0},{"n":1257,"text":"\t/** All projected text files, path -> text, in path order. Binary files are in `blobs()`. */","atom":"a0","author":"init","version":0},{"n":1258,"text":"\tfiles(): Record<string, string> {","atom":"a0","author":"init","version":0},{"n":1259,"text":"\t\tconst out: Record<string, string> = {};","atom":"a0","author":"init","version":0},{"n":1260,"text":"\t\tfor (const path of this.paths()) if (this.#file(path).attrs.blob === null) out[path] = this.text(path);","atom":"a0","author":"init","version":0},{"n":1261,"text":"\t\treturn out;","atom":"a0","author":"init","version":0},{"n":1262,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1263,"text":"","atom":"a0","author":"init","version":0},{"n":1264,"text":"\t/** Binary files, path -> the SHA-256 of their bytes, in path order. */","atom":"a0","author":"init","version":0},{"n":1265,"text":"\tblobs(): Record<string, string> {","atom":"a0","author":"init","version":0},{"n":1266,"text":"\t\t// From attributes alone (abso Capacity): a file with a blob exists, so no file is laid out to find them. Going","atom":"a2445","author":"capacity","version":233},{"n":1267,"text":"\t\t// through paths() laid out every file in the set, and shared() asks for blobs on every call.","atom":"a2445","author":"capacity","version":233},{"n":1268,"text":"\t\tconst out: Record<string, string> = {};","atom":"a0","author":"init","version":0},{"n":1269,"text":"\t\tconst candidates = this.#stable ? [...this.graph.knownFiles()].sort() : this.#known;","atom":"a2445","author":"capacity","version":233},{"n":1270,"text":"\t\tfor (const path of candidates) {","atom":"a2445","author":"capacity","version":233},{"n":1271,"text":"\t\t\tconst blob = this.attrs(path).blob;","atom":"a2445","author":"capacity","version":233},{"n":1272,"text":"\t\t\tif (blob !== null) out[path] = blob;","atom":"a0","author":"init","version":0},{"n":1273,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":1274,"text":"\t\treturn out;","atom":"a0","author":"init","version":0},{"n":1275,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1276,"text":"","atom":"a0","author":"init","version":0},{"n":1277,"text":"\t/**","atom":"a0","author":"init","version":0},{"n":1278,"text":"\t * About how many bytes of retained state this view costs (#46). This uses","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1279,"text":"\t * approximate ownership costs for containers and wrappers, not V8 heap","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1280,"text":"\t * measurements. Graph-owned strings and records count only as references.","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1281,"text":"\t * This method only inspects already-created state: it does not lay out files,","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1282,"text":"\t * populate lazy caches, enumerate the graph, or count temporary traversal","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1283,"text":"\t * containers and shared empty singleton payloads as retained view state.","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1284,"text":"\t */","atom":"a0","author":"init","version":0},{"n":1285,"text":"\tweight(seen?: Set<object>): number {","atom":"a2473","author":"capacity","version":241},{"n":1286,"text":"\t\tlet n = this.#in.byteLength;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1287,"text":"\t\tn += 2 * ARRAY_HEADER_BYTES + this.#membershipSeq.byteLength + this.#membershipValue.byteLength;","atom":"a1030","author":"codex-capacity-chair","version":116},{"n":1288,"text":"\t\tif (this.#movers) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#movers.length;","atom":"a1061","author":"codex-capacity-chair","version":123},{"n":1289,"text":"\t\tn += MAP_HEADER_BYTES; // #files exists from construction.","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1290,"text":"\t\tif (this.#stable) n += this.#stable.retainedBytes;","atom":"a998","author":"codex-capacity-chair","version":109},{"n":1291,"text":"\t\telse if (this.#set) n += OBJECT_BYTES + SET_ENTRY_BYTES * this.#set.size;","atom":"a998","author":"codex-capacity-chair","version":109},{"n":1292,"text":"\t\tif (this.#knownList) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#knownList.length;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1293,"text":"\t\tif (this.#relocs) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * this.#relocs.size;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1294,"text":"\t\tif (this.#relocsN) n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + OBJECT_BYTES) * this.#relocsN.size;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1295,"text":"\t\tn += MAP_ENTRY_BYTES * this.#picked.size;","atom":"a2377","author":"capacity","version":216},{"n":1296,"text":"\t\tn += MAP_ENTRY_BYTES * this.#used.size;","atom":"a2668","author":"capacity","version":263},{"n":1297,"text":"\t\tfor (const f of this.#files.values()) {","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1298,"text":"\t\t\tn += MAP_ENTRY_BYTES;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1299,"text":"\t\t\tif (f !== NO_FILE) {","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1300,"text":"\t\t\t\t// A layout another view counted already (`seen`, across a cache's views) isn't counted again.","atom":"a2473","author":"capacity","version":241},{"n":1301,"text":"\t\t\t\tif (!seen?.has(f)) n += layoutBytes(f);","atom":"a2473","author":"capacity","version":241},{"n":1302,"text":"\t\t\t\tseen?.add(f);","atom":"a2473","author":"capacity","version":241},{"n":1303,"text":"\t\t\t\tif (f.seqIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.seqIndex.size;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1304,"text":"\t\t\t\tif (f.visIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.visIndex.size;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1305,"text":"\t\t\t}","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1306,"text":"\t\t}","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1307,"text":"\t\tif (this.#linesCache)","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1308,"text":"\t\t\tn += OBJECT_BYTES + REFERENCE_BYTES + ARRAY_HEADER_BYTES + 100 * this.#linesCache.lines.length;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1309,"text":"\t\tif (this.#seqCache) {","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1310,"text":"\t\t\tn += OBJECT_BYTES + REFERENCE_BYTES + ARRAY_HEADER_BYTES + 120 * this.#seqCache.seq.length;","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1311,"text":"\t\t\tfor (const line of this.#seqCache.seq)","atom":"a938","author":"codex-capacity-policy","version":103},{"n":1312,"text":"\t\t\t\tif (line.deletedBy !== NONE) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * line.deletedBy.length;","atom":"a938","author":"codex-capacity-policy","version":103},{"n":1313,"text":"\t\t}","atom":"a934","author":"codex-capacity-policy","version":103},{"n":1314,"text":"\t\tif (this.#textCache) n += OBJECT_BYTES + REFERENCE_BYTES + ARRAY_HEADER_BYTES + 2 * this.#textCache.text.length;","atom":"a938","author":"codex-capacity-policy","version":103},{"n":1315,"text":"\t\treturn n;","atom":"a0","author":"init","version":0},{"n":1316,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1317,"text":"","atom":"a0","author":"init","version":0},{"n":1318,"text":"\t#file(path: string, complete = false): FileState {","atom":"a1006","author":"codex-capacity-chair","version":110},{"n":1319,"text":"\t\tlet state = this.#files.get(path);","atom":"a0","author":"init","version":0},{"n":1320,"text":"\t\tif (!state || (complete && !state.complete)) {","atom":"a1006","author":"codex-capacity-chair","version":110},{"n":1321,"text":"\t\t\tconst shared = this.#filesFrom === undefined ? null : this.#sharedFiles();","atom":"a2451","author":"capacity","version":235},{"n":1322,"text":"\t\t\tif (shared && !shared.except.has(path)) state = shared.from.#file(path, complete);","atom":"a2451","author":"capacity","version":235},{"n":1323,"text":"\t\t\telse state = this.graph.hasAtomsIn(path) ? this.#layout(path, complete) : NO_FILE;","atom":"a2451","author":"capacity","version":235},{"n":1324,"text":"\t\t\tthis.#files.set(path, state);","atom":"a0","author":"init","version":0},{"n":1325,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":1326,"text":"\t\tif (state !== NO_FILE) this.#used.set(path, ++fileUses);","atom":"a2668","author":"capacity","version":263},{"n":1327,"text":"\t\treturn state;","atom":"a0","author":"init","version":0},{"n":1328,"text":"\t}","atom":"a2668","author":"capacity","version":263},{"n":1329,"text":"","atom":"a2668","author":"capacity","version":263},{"n":1330,"text":"\t/** When each laid-out file was last used (fileUses). */","atom":"a2668","author":"capacity","version":263},{"n":1331,"text":"\treadonly #used = new Map<string, number>();","atom":"a2668","author":"capacity","version":263},{"n":1332,"text":"","atom":"a2668","author":"capacity","version":263},{"n":1333,"text":"\t/**","atom":"a2668","author":"capacity","version":263},{"n":1334,"text":"\t * Each laid-out file: its layout, when it was last used (a count shared by every view) and what it holds, for a","atom":"a2668","author":"capacity","version":263},{"n":1335,"text":"\t * cache that trims the least recently used layouts across its views before whole views (views.ts, abso Capacity).","atom":"a2668","author":"capacity","version":263},{"n":1336,"text":"\t */","atom":"a2668","author":"capacity","version":263},{"n":1337,"text":"\t*laidOut(): IterableIterator<{","atom":"a2736","author":"capacity","version":276},{"n":1338,"text":"\t\tpath: string;","atom":"a2736","author":"capacity","version":276},{"n":1339,"text":"\t\tlayout: object;","atom":"a2736","author":"capacity","version":276},{"n":1340,"text":"\t\tused: number;","atom":"a2736","author":"capacity","version":276},{"n":1341,"text":"\t\tbytes: number;","atom":"a2736","author":"capacity","version":276},{"n":1342,"text":"\t}> {","atom":"a2736","author":"capacity","version":276},{"n":1343,"text":"\t\tfor (const [path, f] of this.#files) {","atom":"a2668","author":"capacity","version":263},{"n":1344,"text":"\t\t\tif (f === NO_FILE) continue;","atom":"a2668","author":"capacity","version":263},{"n":1345,"text":"\t\t\tlet bytes = 2 * MAP_ENTRY_BYTES + layoutBytes(f);","atom":"a2668","author":"capacity","version":263},{"n":1346,"text":"\t\t\tif (f.seqIndex) bytes += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.seqIndex.size;","atom":"a2668","author":"capacity","version":263},{"n":1347,"text":"\t\t\tif (f.visIndex) bytes += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.visIndex.size;","atom":"a2668","author":"capacity","version":263},{"n":1348,"text":"\t\t\tyield { path, layout: f, used: this.#used.get(path) ?? 0, bytes };","atom":"a2668","author":"capacity","version":263},{"n":1349,"text":"\t\t}","atom":"a2668","author":"capacity","version":263},{"n":1350,"text":"\t}","atom":"a2668","author":"capacity","version":263},{"n":1351,"text":"","atom":"a2668","author":"capacity","version":263},{"n":1352,"text":"\t/** Let go of a file's layout: the next ask lays it out again, the same. */","atom":"a2668","author":"capacity","version":263},{"n":1353,"text":"\tforget(path: string): void {","atom":"a2668","author":"capacity","version":263},{"n":1354,"text":"\t\tthis.#files.delete(path);","atom":"a2668","author":"capacity","version":263},{"n":1355,"text":"\t\tthis.#used.delete(path);","atom":"a2668","author":"capacity","version":263},{"n":1356,"text":"\t\tif (this.#linesCache?.path === path) this.#linesCache = undefined;","atom":"a2668","author":"capacity","version":263},{"n":1357,"text":"\t\tif (this.#seqCache?.path === path) this.#seqCache = undefined;","atom":"a2668","author":"capacity","version":263},{"n":1358,"text":"\t\tif (this.#textCache?.path === path) this.#textCache = undefined;","atom":"a2668","author":"capacity","version":263},{"n":1359,"text":"\t}","atom":"a0","author":"init","version":0},{"n":1360,"text":"}","atom":"a0","author":"init","version":0},{"n":1361,"text":"","atom":"a0","author":"init","version":0},{"n":1362,"text":"/** The files of a closed set, path -> text. */","atom":"a0","author":"init","version":0},{"n":1363,"text":"export function project(graph: Graph, set: Iterable<AtomId>): Record<string, string> {","atom":"a0","author":"init","version":0},{"n":1364,"text":"\treturn new View(graph, set).files();","atom":"a0","author":"init","version":0},{"n":1365,"text":"}","atom":"a0","author":"init","version":0},{"n":1366,"text":"","atom":"a0","author":"init","version":0},{"n":1367,"text":"/** Where a node sits in a file's sequence: the index just after it (0 for a start node). */","atom":"a0","author":"init","version":0},{"n":1368,"text":"export function indexAfter(view: Pick<ReadView, \"sequenceIndex\">, path: string, node: NodeId): number {","atom":"a1327","author":"codex-capacity-chair","version":143},{"n":1369,"text":"\tif (isStartNode(node)) return 0;","atom":"a0","author":"init","version":0},{"n":1370,"text":"\tconst i = view.sequenceIndex(path, node);","atom":"a0","author":"init","version":0},{"n":1371,"text":"\tif (i < 0) throw new EngineError(\"not-in-view\", `line ${node} is not in ${path} in this view`);","atom":"a0","author":"init","version":0},{"n":1372,"text":"\treturn i + 1;","atom":"a0","author":"init","version":0},{"n":1373,"text":"}","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a934","author":"codex-capacity-policy","message":"","time":1791757356684,"timeIso":"2026-10-11T22:22:36.684Z","publish":{"draft":null,"version":103,"agent":"codex-capacity-policy","message":"Test deterministic replay and account view cache weight","time":1791758093484,"timeIso":"2026-10-11T22:34:53.484Z"}},{"atom":"a938","author":"codex-capacity-policy","message":"","time":1791757780561,"timeIso":"2026-10-11T22:29:40.561Z","publish":{"draft":null,"version":103,"agent":"codex-capacity-policy","message":"Test deterministic replay and account view cache weight","time":1791758093484,"timeIso":"2026-10-11T22:34:53.484Z"}},{"atom":"a979","author":"codex-capacity-chair","message":"","time":1791824286794,"timeIso":"2026-10-12T16:58:06.794Z","publish":{"draft":null,"version":109,"agent":"codex-capacity-chair","message":"Add opt-in persistent writer state, checked reopen and bounded adoption","time":1791825459416,"timeIso":"2026-10-12T17:17:39.416Z"}},{"atom":"a998","author":"codex-capacity-chair","message":"","time":1791825397225,"timeIso":"2026-10-12T17:16:37.225Z","publish":{"draft":null,"version":109,"agent":"codex-capacity-chair","message":"Add opt-in persistent writer state, checked reopen and bounded adoption","time":1791825459416,"timeIso":"2026-10-12T17:17:39.416Z"}},{"atom":"a1006","author":"codex-capacity-chair","message":"","time":1791826635046,"timeIso":"2026-10-12T17:37:15.046Z","publish":{"draft":null,"version":110,"agent":"codex-capacity-chair","message":"Keep current-file views and key scans from retaining historical state","time":1791826888785,"timeIso":"2026-10-12T17:41:28.785Z"}},{"atom":"a1030","author":"codex-capacity-chair","message":"","time":1791829993612,"timeIso":"2026-10-12T18:33:13.612Z","publish":{"draft":null,"version":116,"agent":"codex-capacity-chair","message":"Bound repeated indexed view membership lookups","time":1791830067862,"timeIso":"2026-10-12T18:34:27.862Z"}},{"atom":"a1039","author":"codex-capacity-chair","message":"","time":1791830965974,"timeIso":"2026-10-12T18:49:25.974Z","publish":{"draft":null,"version":118,"agent":"codex-capacity-chair","message":"Avoid retaining deleted historical paths in indexed current views","time":1791831208035,"timeIso":"2026-10-12T18:53:28.035Z"}},{"atom":"a1045","author":"codex-capacity-chair","message":"","time":1791832874791,"timeIso":"2026-10-12T19:21:14.791Z","publish":{"draft":null,"version":119,"agent":"codex-capacity-chair","message":"Page per-file atom indexes and stream current-view attribute scans","time":1791832938431,"timeIso":"2026-10-12T19:22:18.431Z"}},{"atom":"a1061","author":"codex-capacity-chair","message":"","time":1791835105494,"timeIso":"2026-10-12T19:58:25.494Z","publish":{"draft":null,"version":123,"agent":"codex-capacity-chair","message":"Stream mover history when opening persisted views","time":1791835165952,"timeIso":"2026-10-12T19:59:25.952Z"}},{"atom":"a1075","author":"codex-capacity-chair","message":"","time":1791837487244,"timeIso":"2026-10-12T20:38:07.244Z","publish":{"draft":null,"version":126,"agent":"codex-capacity-chair","message":"Identify suppressed relocation cycles across persistent reads","time":1791837654331,"timeIso":"2026-10-12T20:40:54.331Z"}},{"atom":"a1083","author":"codex-capacity-chair","message":"","time":1791838569201,"timeIso":"2026-10-12T20:56:09.201Z","publish":{"draft":null,"version":128,"agent":"codex-capacity-chair","message":"Page deletion history and short-circuit current visibility","time":1791838722988,"timeIso":"2026-10-12T20:58:42.988Z"}},{"atom":"a1091","author":"codex-capacity-chair","message":"","time":1791840276400,"timeIso":"2026-10-12T21:24:36.400Z","publish":{"draft":null,"version":130,"agent":"codex-capacity-chair","message":"Stream paged child history into layout filtering","time":1791840531495,"timeIso":"2026-10-12T21:28:51.495Z"}},{"atom":"a1105","author":"codex-capacity-chair","message":"","time":1791841517646,"timeIso":"2026-10-12T21:45:17.646Z","publish":{"draft":null,"version":131,"agent":"codex-capacity-chair","message":"Bound persisted no-move layout with ordered successor traversal","time":1791841517646,"timeIso":"2026-10-12T21:45:17.646Z"}},{"atom":"a1112","author":"codex-capacity-chair","message":"","time":1791842213961,"timeIso":"2026-10-12T21:56:53.961Z","publish":{"draft":null,"version":132,"agent":"codex-capacity-chair","message":"Bound persistent relocation projection memory with rollback-only scratch","time":1791842416230,"timeIso":"2026-10-12T22:00:16.230Z"}},{"atom":"a1114","author":"codex-capacity-chair","message":"","time":1791842283610,"timeIso":"2026-10-12T21:58:03.610Z","publish":{"draft":null,"version":132,"agent":"codex-capacity-chair","message":"Bound persistent relocation projection memory with rollback-only scratch","time":1791842416230,"timeIso":"2026-10-12T22:00:16.230Z"}},{"atom":"a1143","author":"codex-capacity-chair","message":"","time":1791844562011,"timeIso":"2026-10-12T22:36:02.011Z","publish":{"draft":null,"version":138,"agent":"codex-capacity-chair","message":"Find reason-warning neighbors without materializing file history","time":1791844690202,"timeIso":"2026-10-12T22:38:10.202Z"}},{"atom":"a1152","author":"codex-capacity-chair","message":"","time":1791845368566,"timeIso":"2026-10-12T22:49:28.566Z","publish":{"draft":null,"version":140,"agent":"codex-capacity-chair","message":"Avoid line projection for file attribute queries","time":1791845368566,"timeIso":"2026-10-12T22:49:28.566Z"}},{"atom":"a1327","author":"codex-capacity-chair","message":"","time":1791854964720,"timeIso":"2026-10-13T01:29:24.720Z","publish":{"draft":null,"version":143,"agent":"codex-capacity-chair","message":"Add inactive disk projection provider and verified transactional readers (#16)","time":1791855032023,"timeIso":"2026-10-13T01:30:32.023Z"}},{"atom":"a1890","author":"codex-capacity-chair","message":"","time":1791967583646,"timeIso":"2026-10-14T08:46:23.646Z","publish":{"draft":null,"version":175,"agent":"codex-capacity-chair","message":"Reduce disk-backed record and publish allocations; reviewed in core ask 52 with parsed-code budget and exact aligned-line follow-ups. Keep disk-first activation off.","time":1791967673854,"timeIso":"2026-10-14T08:47:53.854Z"}},{"atom":"a2302","author":"capacity","message":"","time":1792030074826,"timeIso":"2026-10-15T02:07:54.826Z","publish":{"draft":null,"version":205,"agent":"capacity","message":"Disk-first reads stop walking the whole history (disk-first 2, stage 1; abso Capacity). Shared's closure is kept on disk per version (spaces.ts indexClosure): the atoms a version needs beyond what it published, as events like membership's, with drops handled; views and Project.#closed trust a set marked closed, and over a closed stored base only a draft's own atoms are walked. A view resolves its moves once in memory (up to MOVED_LINES_KEPT, 20,000 moved lines) instead of again on disk for every file it lays out, and finds lines moved under a node from them. Graph.eachChildN skips the per-line children lookup when the paged child counts say none. On game's export (writer adopted, lock held): shared() went from not finishing in 8 minutes to 9-13 s cold and 0.15-0.25 s warm, 291,000 queries to 57,000; pathsAt(head) 0.1-0.2 s.","time":1792030075730,"timeIso":"2026-10-15T02:07:55.730Z"}},{"atom":"a2312","author":"capacity","message":"","time":1792031851172,"timeIso":"2026-10-15T02:37:31.172Z","publish":{"draft":null,"version":206,"agent":"capacity","message":"Each file's line history packed (disk-first 2, lines by file; abso Capacity). A stored graph appends every line written in a file ([n, parent code, writer seq, k, replaces]) and its text, every delete of one of its lines, and every attribute set on it to that file's pages as atoms are added, a run at a time (storedLists appendAll). A view lays a file out from those pages in memory: membership checked once per atom, moves followed from the ones it already resolved, lines moved in from other files read from theirs. Same tree and order as before (packed-files.test.ts checks it against the in-memory graph through edits, deletes and moves). Graphs adopted before have no packs and lay out line by line as before; packFiles: false keeps that path for its tests. On game's export: first shared() 13 s to 2-3.6 s at 20,000 queries, warm 56-82 ms, pathsAt(head) 29-119 ms; files at a version 14 s to 3 s, compare 26 s to 11 s, a path's log 27 s to 4.5 s; every answer the harness finished matches Project.load.","time":1792031851789,"timeIso":"2026-10-15T02:37:31.789Z"}},{"atom":"a2319","author":"capacity","message":"","time":1792033263147,"timeIso":"2026-10-15T03:01:03.147Z","publish":{"draft":null,"version":207,"agent":"capacity","message":"Each shared version's changed files kept as it lands (disk-first 2; abso Capacity, version-files.ts). A version's files are decided from what it touched: visible lines in and out per file, their texts' balance, a running count of each file's visible lines for made and taken out, and mode and blob; a version with moves, drops or a closure change, or whose lines in and out have the same texts, is laid out as before. Views of consecutive versions share resolved moves and where lines sit (View.shareMoves). PathIndex.keep records them, into the shapes table when the host gives one. version-files.test.ts checks log, path logs and every show against the in-memory project through edits, new and removed files, same text put back, a move and a drop. On game's export all 27 harness answers now match Project.load: the log 70 ms (was over 30 s), a path's history 0.56 s (was over 30 s), the tree 3.1-3.4 s (was over 30 s); adoption about 85 s; heap 14.4 MB at most.","time":1792033264009,"timeIso":"2026-10-15T03:01:04.009Z"}},{"atom":"a2350","author":"capacity","message":"","time":1792036931359,"timeIso":"2026-10-15T04:02:11.359Z","publish":{"draft":null,"version":212,"agent":"capacity","message":"Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export.\n\n- where looks deleted lines up by number (graph.deletedNumbers, View.fileOfNumber, View.lineNumberOf). It takes the agent's view once instead of once per line, since each read weighed every cached view. It finds the draft's lines by writer (View.visibleWriters), with no text or id read per line.\n- Draft files (overlaps.ts) go by number the same way.\n- An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this).\n- Draft collisions:\n  - build the union view only when two drafts share a file;\n  - work out each agent's touched files and its \"shared now plus draft\" view once;\n  - find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history;\n  - have the definition rule keep a draft's uses, and the newer work's definitions, across partners.\n- A stored list read in order reads its length once, not before every element.\n\ndraft-reads-stored.test.ts checks where and collisions against the in-memory project. It covers edits, a whole file deleted, a line collision, one name defined twice, and bases before and after a move. 135 of 136 related tests pass; none fail.\n\nOn website's export (1,387 entries) the answers match Project.load:\n- status: 17 s to 4.5 s\n- where: over 60 s to 8.8 s\n- drafts: 14 s to 5.3 s\n- collisions: over 60 s to 54 s, measured under the profiler before the last two changes","time":1792036932387,"timeIso":"2026-10-15T04:02:12.387Z"}},{"atom":"a2368","author":"capacity","message":"","time":1792039881156,"timeIso":"2026-10-15T04:51:21.156Z","publish":{"draft":null,"version":215,"agent":"capacity","message":"Moves resolved over the moved lines alone, and closure over a named draft's own atoms (disk-first 2; abso Capacity), for abso's status and drafts.\n\n- view.ts MoveSkeleton: once per graph, and extended as it grows, each mover's moved lines, each moved line's relocations, and for any node the nearest node above it that a move ever relocated (or its file's start), memoised up to 200,000 nodes. A view's relocations and its loop check now hop between moved lines instead of walking every moved line's file up to its start, and fileOf hops the same way. The per-view location memos are gone. On abso's export (1,687 moved lines, 972 movers), status went from 104 s to 41 s under the profiler; agent views no longer re-walk each base's moves.\n- project.ts #closed opens unions down to their closed parts. An agent in a named draft has the draft's atoms over a closed shared base, one union deeper than #closed looked, so it walked all of shared's atoms and their dependencies.\n\nTests: 97 of 97 across moves, relocation, projection-move-resolution, packed-files, view, drop, queued-moves, named-drafts, stored-closure, stored-membership, version-files, draft-reads-stored and writer storage. tsc clean.","time":1792039881566,"timeIso":"2026-10-15T04:51:21.566Z"}},{"atom":"a2377","author":"capacity","message":"","time":1792040841430,"timeIso":"2026-10-15T05:07:21.430Z","publish":{"draft":null,"version":216,"agent":"capacity","message":"Moves picked as walks reach them, and shared's file list from kept shapes (disk-first 2; abso Capacity), for abso's status, drafts and file list.\n\n- view.ts: a view picks a moved line's relocation only when a walk to find a line's file reaches that line. That is #relocations' own pick, right whenever the walk goes on to a file's start, since only lines on a loop have their relocation set aside; a walk that comes back to a line it passed resolves every move as before. shareMoves now takes the other view's moves only when this view first needs all of them, such as for a layout, so a view that only finds a few lines' files never resolves them. weight() counts the picks.\n- pathindex.ts keptPaths: shared's files at a version, folded from version 0 over each version's kept files made and taken out, with no file laid out. Only on a stored writer, and only when every version up to it has a kept row that describes it; otherwise the version is laid out as before. pathsAt uses it.\n\nOn abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load:\n- status: 104 s to 5.8 s (under the profiler)\n- drafts: over 60 s to 5.7 s\n- files at head: over 60 s to 1.2 s\n- files at 612: 54 s to 0.3 s\n\nversion-files.test.ts now also checks the file list at every version against the in-memory project. 124 of 124 related tests pass; tsc clean.","time":1792040841430,"timeIso":"2026-10-15T05:07:21.430Z"}},{"atom":"a2383","author":"capacity","message":"","time":1792041717296,"timeIso":"2026-10-15T05:21:57.296Z","publish":{"draft":null,"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"}},{"atom":"a2399","author":"capacity","message":"","time":1792048744488,"timeIso":"2026-10-15T07:19:04.488Z","publish":{"draft":null,"version":221,"agent":"capacity","message":"Packed layout follows lines written in another file (disk-first 2; abso Capacity).\n\nwhere {} on typescript-rs left 11 lines out of erasable_syntax.rs in cloud-ts-12's draft. cloud-ts-12 moved one block between files several times, wrote lines under its last line while it sat in uninitialized_props_forms.rs, then moved the block on. Those lines followed their parent with no move of their own. The packed layout read only the file's own lines and the files its moved-in lines were written in, so it never read them.\n\n- Each file's packed history also keeps the runs written in another file under one of its lines (file-crossings). The packed layout follows them until no new file turns up.\n- New adoptions write packed format 2. A graph packed at format 1 has no such list, so it lays files out line by line: correct, but slower until it is adopted again.\n- packed-crossings.test.ts moves c.ts to d.ts, adds a line in d.ts, moves d.ts to e.ts, and checks files, where and every draft's text against the in-memory project.\n\nNamed tests: packed-crossings, packed-files, state-source, draft-reads-stored, version-files, project-writer-storage, writer-adoption, moves, queued-moves, files-reads, move-reconstruction (60 of 60); tsc and biome clean.","time":1792048744878,"timeIso":"2026-10-15T07:19:04.878Z"}},{"atom":"a2431","author":"capacity","message":"","time":1792054426099,"timeIso":"2026-10-15T08:53:46.099Z","publish":{"draft":null,"version":229,"agent":"capacity","message":"Draft collisions without copying shared's atoms per pair (disk-first 2; abso Capacity).\n\nOn typescript-rs, with one opened writer, collisions ran past 5 minutes with 2.5 million row reads; replay takes 5 s.\n\n- Each pair of agents built a new set of all of shared's atoms plus both drafts, and each agent's view of shared-now did the same. On a stored writer that read every one of shared's atoms, per pair, and the view then proved the copy closed by walking it. The pair's set is now a lookup over shared's own atoms and the two drafts (same membership as before). The views are built over shared's view's own closed set plus the drafts, which closes to the same atoms and walks only the drafts.\n- View.lines and buildLines use the texts the packed layout already holds, instead of reading each line's text again.\n- The definition rule takes a line's atom and place from its id, and collisions use graph.lineAtom; graph.line read each line's text as well.\n\nOn typescript-rs adopted fresh, cold: collisions finishes in 71 s with 299,000 reads, matching replay. Still slow: most of what's left is laying the same files out again for each agent's view.\n\nNamed tests: every engine test (288 of 288), changed-definition, collision-streaming, definition-code, definitions, draft-reads-stored, same-line, spelling-clash, review-fixes, membership-pages, stored-closure, packed-crossings, project-writer-storage, writer-adoption, moves, version-files, where-many-agents (67 of 67); tsc and biome clean.","time":1792054426575,"timeIso":"2026-10-15T08:53:46.575Z"}},{"atom":"a2436","author":"capacity","message":"","time":1792055493481,"timeIso":"2026-10-15T09:11:33.481Z","publish":{"draft":null,"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"}},{"atom":"a2441","author":"capacity","message":"","time":1792056158021,"timeIso":"2026-10-15T09:22:38.021Z","publish":{"draft":null,"version":231,"agent":"capacity","message":"visibleWriters uses the writers the packed layout keeps (disk-first 2; abso Capacity).\n\nwhere asks each agent's view for its visible lines' writers in every file the draft touches. visibleWriters looked each one up again (graph.writerSeqOf), which on a stored graph read the line-atom pages: on typescript-rs that was 2.6 s of where's 4 s in SQLite. The packed layout already keeps them since 230 (visWriter).\n\nOn typescript-rs adopted fresh, cold: where 39,000 reads to 20,000 and 6.5 s to 3.8 s, matching replay.\n\nNamed tests: every engine test (288 of 288), where-many-agents, draft-reads-stored, authors-stored, packed-crossings, membership-pages, view-cache, files-reads, project (39 of 39); tsc and biome clean.","time":1792056158354,"timeIso":"2026-10-15T09:22:38.354Z"}},{"atom":"a2443","author":"capacity","message":"","time":1792056629256,"timeIso":"2026-10-15T09:30:29.256Z","publish":{"draft":null,"version":232,"agent":"capacity","message":"Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity).\n\nCollisions on typescript-rs spent about 21 s in the definition rule's #replacedNames. It asks the base view for a file's whole sequence, then walks back from one line through a few. View.sequence read every line's text, deleted lines included, one row each on a stored graph (about 35,000 line-text reads). lines() and sequence() also looked up each line's id and writer again, two more reads per line.\n\n- The packed layout keeps each line's writer and place in it (visWriter, visK, and seqWriter and seqK for a complete layout). lines(), buildLines() and sequence() build ids and writers from them.\n- sequence() reads each line's text when it is first asked for.\n\nOn typescript-rs adopted fresh, cold: collisions 70 s to 46 s; where about 3 s. All 27 answers match replay. Run alone, why is about 0.95 s.\n\nNamed tests: every engine test (288 of 288), changed-definition, collision-streaming, definitions, draft-reads-stored, authors-stored, packed-crossings, view-cache, files-reads, project, trail, history, moves (82 of 82); tsc and biome clean.","time":1792056629629,"timeIso":"2026-10-15T09:30:29.629Z"}},{"atom":"a2445","author":"capacity","message":"","time":1792057743003,"timeIso":"2026-10-15T09:49:03.003Z","publish":{"draft":null,"version":233,"agent":"capacity","message":"A view's blobs come from file attributes alone (disk-first 2; abso Capacity).\n\nEngineProject.shared() lists shared's binary files on every call, and the Worker reads shared().version before and after most operations. View.blobs went through paths(), which lays out every file in the set to see whether it exists. On abso's export with a fresh writer, that was about 15 s on the first call.\n\nA file with a blob attribute exists, so blobs now reads each candidate path's attributes (the packed attribute history) and lays nothing out. Same files, same order.\n\nOn abso adopted fresh: the harness's first read (status, shared, paths) went from about 20 s to 3 s.\n\nNew test blobs-stored: a file binary from the start, one that turns binary and back to text, and one deleted; a stored writer's blob list matches the in-memory project's at every version and in each agent's draft. Named tests: every engine test (288 of 288), blobs-stored, blobs, attributes, project-file, files-reads, draft-reads-stored, authors-stored, project, version-files (46 of 46); tsc and biome clean.","time":1792057743326,"timeIso":"2026-10-15T09:49:03.326Z"}},{"atom":"a2451","author":"capacity","message":"","time":1792064261469,"timeIso":"2026-10-15T11:37:41.469Z","publish":{"draft":null,"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"}},{"atom":"a2463","author":"capacity","message":"","time":1792065681199,"timeIso":"2026-10-15T12:01:21.199Z","publish":{"draft":null,"version":238,"agent":"capacity","message":"Collisions: deleted lines found by number, and the move index skips graphs that gained nothing (disk-first 2; abso Capacity).\n\nCollisions on website took 20.7 s cold with one opened writer (replay 0.4 s), and 46 s on typescript-rs (replay 5 s).\n\n- touchedFiles finds each deleted line's file by its number where the view can (fileOfNumber). A draft deleting a big file has thousands; making each one's id only to look its number up again was most of the time.\n- Graph.accepted counts the atoms a graph object has taken in, in memory. The move index (MoveSkeleton) is brought up to date on every lookup of a line's file. It now reads the movers list only when that count has changed: checking the stored list's length and last mover each time cost 3.3 s of collisions on website. A rolled-back add still counts, which only makes it look again.\n\nOn website adopted fresh, cold: collisions 20.7 s to 9.6 s. On typescript-rs: 46 s to 11.7 s. Both match replay, and all 27 typescript-rs answers match. Still slow: reading every draft atom's write keys, a row per key once there are more than 256 (75,000 rows on website).\n\nNamed tests: every engine test (288 of 288), every worker/project test (341 of 341); tsc and biome clean.","time":1792065681704,"timeIso":"2026-10-15T12:01:21.704Z"}},{"atom":"a2473","author":"capacity","message":"","time":1792070260254,"timeIso":"2026-10-15T13:17:40.254Z","publish":{"draft":null,"version":241,"agent":"capacity","message":"The view cache counts a file layout two views share once (disk-first 2; abso Capacity).\n\nTesting found collisions on abso slower with 240 than with 234 (warm 7.3 to 12.3 s). Since 235 a draft's view takes its base view's layout of every file the draft doesn't touch, so many cached views hold the same layouts. The cache counted each view's layouts in full, so the 24 MB budget filled with copies. That evicted views the next call needed, and a kept writer laid abso's drafts out again on every collisions call.\n\n- ViewCache keeps the newest views that fit the budget, as evicting oldest first does, counting a layout already counted for a newer view once (View.weight(seen)).\n- A layout's own bytes are worked out once per layout (layoutBytes): the cache weighs every view on every lookup, which summed every line's text again.\n\nOn abso adopted fresh, one kept writer, against 240 on the same database: collisions 17.5 s to 11.9 s cold, 11.3 s to 6.1 s on the next call (49,000 and 19,000 reads, from 71,000 and 41,000). Both match replay. Heap after the run is the same with and without (about 125 to 130 MB with the kept writer); that's not from this change, and I'm reporting it separately.\n\nNamed tests: view-cache (the eviction tests as before), every engine test (290 of 290), every worker/project test (341 of 341); tsc and biome clean.","time":1792070260689,"timeIso":"2026-10-15T13:17:40.689Z"}},{"atom":"a2498","author":"capacity","message":"","time":1792080128384,"timeIso":"2026-10-15T16:02:08.384Z","publish":{"draft":null,"version":245,"agent":"capacity","message":"Collisions step 1: whether a file exists, without laying it out (abso Capacity, issue 664).\n\nA published version's view on a writer answers hasFile from the kept path list (PathIndex.keptPathSet, the set pathsAt already answers from), and a draft's view asks its base for every file the draft doesn't touch. Resolving an import tried up to seven file names in collisions, and each check laid the whole file out.\n\nOn the abso export (collisions, my machine): the first call lays out 130 files instead of 407, 13.4 s instead of 15.2 s; a warm call 7.7 s instead of 8.3 s (step 2 is most of what's left). Same answer as replay. Heap after a full warm run: 76.9 MB against 76.5 MB on 244.\n\ntest/known-paths.test.ts: every name at versions 0 to 2 and in four drafts, against the in-memory project, before and after every file is read: a version that deletes a file and renames one with record, one that moves lines into a new file, and drafts that delete, rename, move lines and add.","time":1792080130564,"timeIso":"2026-10-15T16:02:10.564Z"}},{"atom":"a2519","author":"capacity","message":"","time":1792081232971,"timeIso":"2026-10-15T16:20:32.971Z","publish":{"draft":null,"version":247,"agent":"capacity","message":"A kept reader settles after each read; line texts weigh what V8 holds (abso Capacity, issue 664).\n\nWhat a kept reader held on abso, measured per question without the answer itself (heap snapshot after tree with authors, 56.9 MB held): the view cache 38.3 MB against its 24 MB budget, the agents read 6.5 to 7.7 MB, the move skeleton 2.4 MB, the state cache 2.3 MB; the rest is the engine's indexes.\n\n- Project.afterRead: the view cache trimmed to its budget (ViewCache.trim) and the agents the read decoded let go (WriterAgents.release). Views grow while a call lays files out and the cache weighed them only when asked for again; a read-only reader never flushed its agents, so it held every agent's news told.\n- View weight: a laid-out line's text counts a 16-byte header and a byte a character (two outside Latin-1), rounded to 8, as V8 holds it. It counted 8 and two a character, so abso's whole shared layout (22.7 MB held) weighed about 28 MB, over the budget alone: once trimmed, it was laid out again for every question (blame folder 2.5 s became 14.4 s).\n\nFull warm run on the abso export: held heap at most 41.7 MB (was 56.9), 24 to 29 MB between the big reads (was 32 to 37); every answer the same. Status and drafts take about 30 ms more (agents read again); blame folder 1.7 s instead of 2.5 s.\n\nTests: view-cache (trim reweighs growth with no further hit), after-read (new: reads before and after it, and a write after it, against the in-memory project), and the collision, path and compare tests: 21 of 21.","time":1792081233526,"timeIso":"2026-10-15T16:20:33.526Z"}},{"atom":"a2539","author":"capacity","message":"","time":1792081981664,"timeIso":"2026-10-15T16:33:01.664Z","publish":{"draft":null,"version":249,"agent":"capacity","message":"Collisions step 3: each draft's definition work kept between calls, under a hard 4 MB budget (abso Capacity, issue 664).\n\nKeptParts (kept-parts.ts) holds what draft collisions work out about each draft and each pair of drafts: the names a draft's new lines use, the definitions a draft's changes touch before and after (the changed-definition rule), and the names two drafts both define in a file. Each entry is weighed as the view cache weighs views (line ids, texts, names: view.ts's stringBytes) and the whole stays under 4 MB, oldest out first; an entry over the budget isn't kept. Keys name everything an entry depends on: shared's version, the draft's base and its atoms. Each collisions call drops every entry it didn't use, so a draft that changes, an agent that leaves or shared moving on drops theirs at once. On a stored writer only; the publish check (land.ts) and the in-memory project work as before.\n\nOn the abso export (my machine): a warm collisions call takes 322 ms instead of 3.4 s, with the same answer as replay. A full warm run's held heap is at most 42.9 MB (41.7 MB without it), and all 33 answers match.\n\nTests: kept-parts (new: the budget, oldest out first, an oversized entry never kept, a round dropping what it didn't use) and collisions-kept-views, which now runs through the kept parts on the writer (a draft changing, shared moving on, a draft dropped, each asked twice against the in-memory project). With the collision, definition, path and view tests: 47 of 47.","time":1792081982267,"timeIso":"2026-10-15T16:33:02.267Z"}},{"atom":"a2585","author":"capacity","message":"","time":1792088659554,"timeIso":"2026-10-15T18:24:19.554Z","publish":{"draft":null,"version":252,"agent":"capacity","message":"Folder blame from author totals; an agent's tree compares only its draft's files; file lists without a full walk; one space object per stored row (abso Capacity, issue 664).\n\n- Folder blame counts each file's kept author totals where they answer (Project.authorTotalsFor: shared at a version, or an agent's view for the files its draft doesn't touch), and lays out the rest as before.\n- An agent's tree marked a file changed by comparing it in both views, which laid every file out twice (13 s of 14.6 s on abso). Only a file the draft touches can differ from its base (touchedBeyond, as the view's layout sharing uses), so only those are compared; a draft that moves lines compares every file as before.\n- View.paths: a draft's view over its base's takes the base's file list and checks only the files its draft touches; a published version's view answers from its kept file list. Both walked every file the graph ever had.\n- PathIndex.keptPathSet works an older version's file list back from the newest one (undoing each version's made and gone files), and keeps a few, instead of folding from version 0 again for every agent's base.\n- Membership's stored spaces decode to the same object for the same stored row. A space reads everything else through to storage; a new object on every read emptied every cache kept by space (the path index, versions' files and shapes, the kept file lists) on every call.\n\nOn a fresh abso adoption (my machine): an agent's tree with authors 582 ms first and 762 ms again (12.5 s and 0.6 to 1.5 s before); folder blame for an agent 404 ms and 248 ms (1.8 s and 2.0 s); tree with authors at 1224 again 19 ms. A full run matches 33 of 33 answers; held heap at most 40.2 MB.\n\nTests: author-totals now also compares folder blame at every version and in every agent's view, against the in-memory project. All of worker/project/test: 349 of 349 pass (one skipped).","time":1792089011644,"timeIso":"2026-10-15T18:30:11.644Z"}},{"atom":"a2668","author":"capacity","message":"","time":1792096799565,"timeIso":"2026-10-15T20:39:59.565Z","publish":{"draft":null,"version":263,"agent":"capacity","message":"The view cache trims the least recently used file layouts across its views before whole views (abso Capacity, issue 664).\n\nAfter each read, a kept reader's trim (ViewCache.trim, from afterRead) now lets go of file layouts in the order they were last used, across every cached view, until the views fit; a layout several views share (a draft's view borrows its base's) counts once and goes from all of them. Only then does it evict whole views. It evicted whole views before, so a call that laid out two big versions lost one of them entirely. Within a read, the cache trims whole views as before. A forgotten layout is laid out again, the same, when next asked.\n\nOn the abso export, collisions then compare 612 to 1224 asked again (Testing's order): 4.4 s and 17,349 queries, from 7.4 to 9.5 s. Compare alone needs about 25 MB of layouts, more than the 24 MB budget, so about half are laid out again; the rest needs a bigger budget or lighter layouts.\n\nView records each file's last use (a count shared by all views) and can forget one (laidOut, forget); ViewCache takes an optional budget, for tests. Tests: view-cache (new: the least recently used layout goes first, both views stay cached, and the forgotten file reads the same); view's retained-state test still holds. All of src/engine/test (294) and worker/project/test (354) pass.","time":1792096802015,"timeIso":"2026-10-15T20:40:02.015Z"}},{"atom":"a2676","author":"capacity","message":"","time":1792098674856,"timeIso":"2026-10-15T21:11:14.856Z","publish":{"draft":null,"version":266,"agent":"capacity","message":"A draft that moves lines shares its base's layouts too (abso Capacity, issue 664).\n\ntouchedBeyond gave up on any draft with moves, so such an agent's view shared nothing with its base: it laid out every file, took no author totals, compared every file to mark what it changed, and its file list walked every file the graph ever had, laying each out (and, dropping the absent ones again, re-laying them on every call). View.placedDifferently now says where the two views place a moved line differently (a different relocation wins, or a different parent), in either view; besides the files the draft's atoms name, those are the only files its moves can change, since a line's descendants follow it. touchedBeyond adds them, and gives up only when a view resolves its moves in scratch.\n\nOn typescript-rs (Testing's fresh 262 adoption, cloud-ts-01, a draft with two moving atoms; my machine): the draft now touches 3 files. Agent tree with authors 432 ms first and 19 ms again (2.7 s and 579 ms before); agent folder blame 388 ms and 14 ms (1.7 s and 525 ms); agent files 374 ms and 0 ms (1.5 s and 350 ms).\n\nExactness: the tests with drafts that move lines (agent-views-shared's fay, author-totals' fay, known-paths' dee, moves, touched-beyond) compare every read against the in-memory project. All of src/engine/test (294) and worker/project/test (354) pass.","time":1792098679168,"timeIso":"2026-10-15T21:11:19.168Z"}},{"atom":"a2727","author":"capacity","message":"","time":1792103592572,"timeIso":"2026-10-15T22:33:12.572Z","publish":{"draft":null,"version":274,"agent":"capacity","message":"Cold reads (abso Capacity, issue 664): a packed layout reads only the text pages holding a line it shows; definition code stays in memory up to 4 MB; a stored array's element read skips its length read.\n\n- Layout: each line's file and place are kept and texts are read after the walk, a page at a time, only for shown lines. Every text a file and the files its moved-in lines came from ever had was read for every layout; abso's worker files, split out of index.ts, each read all of index.ts's history. Cold compare 612 to 1224 on abso read text pages 17,080 times, now 2,856.\n- Definition code: at 64 KB every large file's parsed code went row by row into scratch and back (25,000 rows each for index.ts). The visible lines are already in memory, so 4 MB at most doubles a file's text for the call. withDefinitionCode takes the limit; its scratch test passes 64 KB.\n- storedArray: set writes the row and the length together and nothing shrinks, so no row lies past the length; half of a cold layout's reads were the length.\n\nSide by side on abso's export, same machine, three rounds: cold collisions 10.5 s to 6.2 s, cold compare 12.6 s to 8.6 s. tsc clean; view, state-cache, state-source, graph, graph-long-text, graph-line-chunks, graph-move-write-membership, definition-code, definitions, changed-definition, collisions-kept-views and draft-reads-stored tests: 73 pass.","time":1792103593251,"timeIso":"2026-10-15T22:33:13.251Z"}},{"atom":"a2736","author":"capacity","message":"","time":1792104390274,"timeIso":"2026-10-15T22:46:30.274Z","publish":{"draft":null,"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"}},{"atom":"a3004","author":"capacity","message":"","time":1792223903950,"timeIso":"2026-10-17T07:58:23.950Z","publish":{"draft":null,"version":315,"agent":"capacity","message":"Record scales with its change (abso 714). spellingOf found a new path's twin among the view's known paths, which read every atom's membership and file list: 36,360 of a 1470-shaped record's 53,664 statements on abso's Oct 14 tables. It now looks among the graph's own known paths, kept only where the view has a file, as clashIn does; same answers. View.lineChunks yields the texts the packed layout already holds, read a page at a time, instead of each line's row (11,873 statements); a line too long to pack is still read in chunks. Record on the tables: 53,664 to 8,078 statements; record, publish and shared's files after are identical by hash.","time":1792224422170,"timeIso":"2026-10-17T08:07:02.170Z"}},{"atom":"a3014","author":"capacity","message":"","time":1792226502941,"timeIso":"2026-10-17T08:41:42.941Z","publish":{"draft":null,"version":317,"agent":"capacity","message":"A draft-state or land on a stored graph no longer reads a row per line to describe its collisions, or a row per claimant to pair them (abso 738).\n\n- View's line readers (lines, sequence and the uncached visible lines) name each line's writer with atomId, not graph.idOfSeq. The seq comes from the graph's own layout. idOfSeq's bounds check read the stored atom count once per line, and describing reads both sides' files in full. That was about 0.9 s of a warm draft-state on abso.\n- The claimant walk (orderedClaimants) and hasCommonResolver take each atom's seq from its id, as graph.atom itself does, instead of loading the stored atom to read it.\n\nOn abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610:\n- warm: 8,863 statements and 2.3 s become 7,820 and 0.92 s. Describing goes from 0.6 s to under 0.1 s, and pairing from 0.4 s to 0.1 s.\n- read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s.\nWhat's left of the warm read is mostly the draft's own lines' uses (0.3 s, in proportion to the draft), the clash check and membership values.\n\nChecks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.","time":1792226803138,"timeIso":"2026-10-17T08:46:43.138Z"}}]}