Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
blame on this site's /mcp
CLI
abso blame src/engine/view.ts --json
JSON
/christopher/abso-core/blame/src/engine/view.ts?format=json
1,373 linescapacity 53% · First import 27% · codex-capacity-chair 17% · codex-capacity-policy 3%Last change capacity in version 317,

1,373 lines from 46 changes in 43 versions.

init0Start the project1// Projection: the files a closed set of atoms produces. A pure function of the
2// set. Each file is a tree of lines hanging off its start node; linearizing it
3// depth-first, children in descending priority, gives the file's sequence. A
4// line hangs off the node it was written after, unless a move in the set gave
5// it another parent (#28): then the newest such move decides.
6//
7// A laid-out file is kept as arrays of line numbers (the graph's n), not as a
8// record per line (#46): a record, its id and two index entries cost about
9// 370 bytes a line, and the view cache holds up to 200,000 lines. Records are
10// made when a caller asks for them, and the latest asked for is kept.
12import type { Graph, RelocationInfo } from "./graph.ts";
capacity317A 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). - 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. - 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. On abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610: - 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. - read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s. What'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. Checks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.Compare13import { atomId, isStartNode, lineId, seqOf } from "./keys.ts";
codex-capacity-chair132Bound persistent relocation projection memory with rollback-only scratchCompare14import { resolveScratchMoves, scratchLayoutNodes } from "./relocation-scratch.ts";
capacity205Disk-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.Compare15import { isClosedSet, StableSet } from "./state-source.ts";
init0Start the project16import { joinLines } from "./text.ts";
17import { type AtomId, type AtomSet, EngineError, type LineId, type NodeId } from "./types.ts";
19/** A line in a file's full sequence, tombstones included. */
20export interface SeqLine {
21 readonly id: LineId;
22 readonly text: string;
23 /** The atom that wrote it. */
24 readonly atom: AtomId;
25 /** Atoms in the set that delete it, by seq. Empty when it is visible. */
26 readonly deletedBy: readonly AtomId[];
27 readonly visible: boolean;
30/** A visible line of a projected file. */
31export interface VisibleLine {
codex-capacity-chair175Reduce 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.Compare32 readonly textChunks?: () => Iterable<string>;
init0Start the project33 readonly id: LineId;
34 readonly text: string;
35 readonly atom: AtomId;
38/** A file's attributes in a view. */
39export interface FileAttrs {
40 /** Kept with no lines (an empty file). */
41 readonly exists: boolean;
42 readonly exec: boolean;
43 /** The target, when the file is a symbolic link. */
44 readonly link: string | null;
45 /** The SHA-256 of its bytes, when the file is binary. */
46 readonly blob: string | null;
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare49/** Structural read boundary shared by historical and transaction-bound projections. */
capacity212Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export. - 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. - Draft files (overlaps.ts) go by number the same way. - An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this). - Draft collisions: - build the union view only when two drafts share a file; - work out each agent's touched files and its "shared now plus draft" view once; - find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history; - have the definition rule keep a draft's uses, and the newer work's definitions, across partners. - A stored list read in order reads its length once, not before every element. draft-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. On website's export (1,387 entries) the answers match Project.load: - status: 17 s to 4.5 s - where: over 60 s to 8.8 s - drafts: 14 s to 5.3 s - collisions: over 60 s to 54 s, measured under the profiler before the last two changesCompare50export type ReadView = Omit<
51 Pick<View, keyof View>,
capacity245Collisions step 1: whether a file exists, without laying it out (abso Capacity, issue 664). A 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. On 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. test/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.Compare52 | "sameText"
53 | "visibleCount"
54 | "shareMoves"
55 | "shareFiles"
56 | "knowPaths"
capacity263The view cache trims the least recently used file layouts across its views before whole views (abso Capacity, issue 664). After 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. On 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. View 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.Compare57 | "laidOut"
58 | "forget"
capacity266A draft that moves lines shares its base's layouts too (abso Capacity, issue 664). touchedBeyond 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. On 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). Exactness: 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.Compare59 | "placedDifferently"
capacity245Collisions step 1: whether a file exists, without laying it out (abso Capacity, issue 664). A 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. On 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. test/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.Compare60 | "fileOfNumber"
61 | "lineNumberOf"
62 | "visibleWriters"
capacity212Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export. - 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. - Draft files (overlaps.ts) go by number the same way. - An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this). - Draft collisions: - build the union view only when two drafts share a file; - work out each agent's touched files and its "shared now plus draft" view once; - find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history; - have the definition rule keep a draft's uses, and the newer work's definitions, across partners. - A stored list read in order reads its length once, not before every element. draft-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. On website's export (1,387 entries) the answers match Project.load: - status: 17 s to 4.5 s - where: over 60 s to 8.8 s - drafts: 14 s to 5.3 s - collisions: over 60 s to 54 s, measured under the profiler before the last two changesCompare63> & {
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare64 sameText(path: string, other: ReadView): boolean;
65};
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare67const NO_ATTRS: FileAttrs = {
68 exists: false,
69 exec: false,
70 link: null,
71 blob: null,
72};
capacity241The view cache counts a file layout two views share once (disk-first 2; abso Capacity). Testing 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. - 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)). - 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. On 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. Named 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.Compare73
74/**
75 * A file layout's bytes, less its lookup indexes, worked out once per layout (abso Capacity): a layout never changes
76 * once made, and the view cache weighs every view it holds on every lookup, which summed every line's text again.
77 */
78const layoutSizes = new WeakMap<FileState, number>();
79function layoutBytes(f: FileState): number {
80 let n = layoutSizes.get(f);
81 if (n !== undefined) return n;
82 // FileState and FileAttrs are per laid-out file; typed-array headers are separate from their payload byte lengths.
83 n = OBJECT_BYTES + OBJECT_BYTES + 2 * ARRAY_HEADER_BYTES;
84 n += f.seq.byteLength + f.vis.byteLength;
capacity247A kept reader settles after each read; line texts weigh what V8 holds (abso Capacity, issue 664). What 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. - 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. - 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). Full 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. Tests: 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.Compare85 if (f.visText) for (const text of f.visText) n += REFERENCE_BYTES + (text === null ? 0 : stringBytes(text));
capacity241The view cache counts a file layout two views share once (disk-first 2; abso Capacity). Testing 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. - 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)). - 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. On 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. Named 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.Compare86 if (f.visWriter) n += 4 * f.visWriter.length;
87 if (f.visK) n += 4 * f.visK.length;
88 if (f.seqWriter) n += 4 * f.seqWriter.length;
89 if (f.seqK) n += 4 * f.seqK.length;
90 n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + ARRAY_HEADER_BYTES) * f.deletedBy.size;
91 for (const deleters of f.deletedBy.values()) n += REFERENCE_BYTES * deleters.length;
92 layoutSizes.set(f, n);
93 return n;
init0Start the project95const NONE: readonly never[] = Object.freeze([]);
97interface FileState {
98 readonly attrs: FileAttrs;
codex-capacity-chair110Keep current-file views and key scans from retaining historical stateCompare99 /** Full history is retained only when a sequence caller explicitly requests it. */
100 readonly complete: boolean;
init0Start the project101 /** The file's sequence, tombstones included: each line's n. */
102 readonly seq: Int32Array;
103 /** Its visible lines' n, in order. */
104 readonly vis: Int32Array;
105 /** For each deleted position in seq: the seqs of the atoms in the set that delete it, by priority. */
106 readonly deletedBy: ReadonlyMap<number, readonly number[]>;
capacity206Each 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.Compare107 /** Its visible lines' text, when laid out from the file's packed history: null for a line too long to pack. */
108 readonly visText?: readonly (string | null)[];
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare109 /** Its visible lines' writers' seqs, when laid out from the file's packed history. */
110 readonly visWriter?: Int32Array;
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare111 /** Its visible lines' places in their writers (a line id's k), when laid out from packed history. */
112 readonly visK?: Int32Array;
113 /** The same for every line of seq, when complete and laid out from packed history. */
114 readonly seqWriter?: Int32Array;
115 readonly seqK?: Int32Array;
init0Start the project116 /** Positions by n, built the first time they're asked for. */
117 seqIndex?: Map<number, number>;
118 visIndex?: Map<number, number>;
121interface Child {
122 readonly n: number;
123 /** 1 when the child's atom deleted the parent (the child replaces it), else 0. A moved line is 0. */
124 readonly replaces: number;
125 readonly lamport: number;
126 readonly seq: number;
127 readonly k: number;
130const EMPTY_INTS = new Int32Array(0);
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare131const NO_FILE: FileState = {
132 attrs: NO_ATTRS,
133 complete: true,
134 seq: EMPTY_INTS,
135 vis: EMPTY_INTS,
136 deletedBy: new Map(),
137};
init0Start the project138
capacity263The view cache trims the least recently used file layouts across its views before whole views (abso Capacity, issue 664). After 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. On 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. View 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.Compare139/** A count of file uses shared by every view, so a cache can tell which layout across its views was used longest ago. */
140let fileUses = 0;
codex-capacity-policy103Test deterministic replay and account view cache weightCompare142// Approximate retained-container costs for View.weight(): reference slots,
143// object headers, and map/set entries. These are cache-budget units, not V8
144// heap measurements. Referenced Graph strings and records are not charged.
145const ARRAY_HEADER_BYTES = 24;
146const OBJECT_BYTES = 32;
147const MAP_HEADER_BYTES = 32;
148const MAP_ENTRY_BYTES = 40;
149const SET_ENTRY_BYTES = 32;
150const REFERENCE_BYTES = 8;
capacity247A kept reader settles after each read; line texts weigh what V8 holds (abso Capacity, issue 664). What 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. - 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. - 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). Full 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. Tests: 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.Compare151const STRING_HEADER_BYTES = 16;
152/**
153 * What V8 holds for a string of its own (abso Capacity, measured on abso's layouts): a header, then one byte a
154 * character when every character fits in Latin-1 and two otherwise, rounded up to 8.
155 */
capacity249Collisions step 3: each draft's definition work kept between calls, under a hard 4 MB budget (abso Capacity, issue 664). KeptParts (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. On 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. Tests: 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.Compare156export function stringBytes(text: string): number {
capacity247A kept reader settles after each read; line texts weigh what V8 holds (abso Capacity, issue 664). What 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. - 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. - 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). Full 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. Tests: 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.Compare157 const chars = /[^\u0000-\u00ff]/.test(text) ? 2 * text.length : text.length;
158 return (STRING_HEADER_BYTES + chars + 7) & ~7;
capacity205Disk-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.Compare160/**
161 * Moved lines a view resolves once and keeps (abso Capacity): a stored graph otherwise resolved every move again on
162 * disk for each file it laid out. Game's whole history has 290; past this many, the view goes back to that.
163 */
164export const MOVED_LINES_KEPT = 20_000;
165class TooManyMoves extends Error {}
166const NO_LINES: readonly number[] = Object.freeze([]);
capacity215Moves 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. - 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. - 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. Tests: 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.Compare167/** Nodes whose nearest moved line above a graph remembers, at most: about 40 bytes each. */
168const CLIMB_MEMO = 200_000;
codex-capacity-policy103Test deterministic replay and account view cache weightCompare169
capacity215Moves 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. - 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. - 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. Tests: 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.Compare170/** One relocation of a moved line, with its line's number and its new parent's code. */
171interface MoveEntry {
172 readonly n: number;
173 readonly r: RelocationInfo;
174 readonly parent: number;
init0Start the project177/**
capacity215Moves 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. - 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. - 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. Tests: 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.Compare178 * A graph's moves, whatever the set (abso Capacity): each mover's moved lines, each moved line's relocations in seq
179 * order, and for any node the nearest node at or above it, by where lines were written, that a move ever relocated,
180 * or its file's start. Worked out once per graph and extended as it grows. A view's moves then resolve over the moved
181 * lines alone: before, every view walked each moved line's file up to its start, a read per line.
182 */
183class MoveSkeleton {
184 readonly #graph: Graph;
185 #seen = 0;
186 /** Movers in seq order, with the numbers of the lines each moves, in its moves' order. */
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare187 readonly movers: {
188 readonly seq: number;
189 readonly lines: readonly number[];
190 }[] = [];
capacity215Moves 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. - 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. - 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. Tests: 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.Compare191 /** Every relocation of each moved line, by the line's number, in seq order. */
192 readonly byLine = new Map<number, MoveEntry[]>();
193 readonly #climbed = new Map<number, number>();
195 constructor(graph: Graph) {
196 this.#graph = graph;
197 }
capacity238Collisions: deleted lines found by number, and the move index skips graphs that gained nothing (disk-first 2; abso Capacity). Collisions on website took 20.7 s cold with one opened writer (replay 0.4 s), and 46 s on typescript-rs (replay 5 s). - 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. - 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. On 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). Named tests: every engine test (288 of 288), every worker/project test (341 of 341); tsc and biome clean.Compare199 /** The graph's accepted count when movers were last taken in: nothing to read while it's the same. */
200 #stamp = -1;
capacity215Moves 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. - 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. - 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. Tests: 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.Compare202 /** Take in movers the graph gained since. */
203 update(): this {
204 const graph = this.#graph;
capacity238Collisions: deleted lines found by number, and the move index skips graphs that gained nothing (disk-first 2; abso Capacity). Collisions on website took 20.7 s cold with one opened writer (replay 0.4 s), and 46 s on typescript-rs (replay 5 s). - 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. - 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. On 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). Named tests: every engine test (288 of 288), every worker/project test (341 of 341); tsc and biome clean.Compare205 if (this.#stamp === graph.accepted) return this;
206 this.#stamp = graph.accepted;
capacity215Moves 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. - 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. - 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. Tests: 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.Compare207 const all = graph.movers();
208 if (this.#seen === all.length) return this;
209 for (; this.#seen < all.length; this.#seen++) {
210 const id = all[this.#seen]!;
211 const lines: number[] = [];
212 graph.atom(id).moves!.forEach((m, k) => {
213 const n = graph.lineN(m.line);
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare214 const r: RelocationInfo = Object.freeze({
215 atom: id,
216 line: m.line,
217 parent: m.parent,
218 k,
219 });
capacity215Moves 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. - 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. - 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. Tests: 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.Compare220 const entry: MoveEntry = { n, r, parent: graph.codeOf(m.parent)! };
221 const list = this.byLine.get(n);
222 if (list) list.push(entry);
223 else this.byLine.set(n, [entry]);
224 lines.push(n);
225 });
226 this.movers.push({ seq: seqOf(id), lines });
227 }
228 // A new moved line can sit between a node and the one it climbed to.
229 this.#climbed.clear();
230 return this;
231 }
233 /** The nearest node at or above this one, by where lines were written, that a move ever relocated; or its file's start. */
234 climb(code: number): number {
235 const walked: number[] = [];
236 let c = code;
237 while (c >= 0 && !this.byLine.has(c)) {
238 const known = this.#climbed.get(c);
239 if (known !== undefined) {
240 c = known;
241 break;
242 }
243 walked.push(c);
244 c = this.#graph.parentCodeOf(c);
245 }
246 if (this.#climbed.size + walked.length > CLIMB_MEMO) this.#climbed.clear();
247 for (const w of walked) this.#climbed.set(w, c);
248 return c;
249 }
252const skeletons = new WeakMap<Graph, MoveSkeleton>();
253function skeletonOf(graph: Graph): MoveSkeleton {
254 let skeleton = skeletons.get(graph);
255 if (!skeleton) skeletons.set(graph, (skeleton = new MoveSkeleton(graph)));
256 return skeleton.update();
259/**
init0Start the project260 * The projection of a closed set. Construct once, then ask for files, lines
261 * and sequences. Throws `not-closed` if some atom's dependency is missing.
262 * Each file is laid out the first time it is asked for, so a view of a large
263 * set costs little until files are read.
264 */
265export class View {
266 readonly graph: Graph;
267 /** 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). */
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare268 #set: AtomSet | undefined;
269 readonly #stable: StableSet<AtomId> | undefined;
codex-capacity-chair116Bound repeated indexed view membership lookupsCompare270 /** Fixed-size memo for immutable indexed membership, independent of history size. */
271 #membershipSeq = new Float64Array(256).fill(-1);
272 #membershipValue = new Uint8Array(256);
init0Start the project273 #files = new Map<string, FileState>();
274 /** Every file the set wrote in, sorted; worked out the first time it's asked for. */
275 #knownList: string[] | undefined;
276 /** 1 for each atom (by seq) in the set. */
277 #in: Uint8Array;
278 /** Atoms in the set that move lines. */
codex-capacity-chair123Stream mover history when opening persisted viewsCompare279 #movers: AtomId[] | undefined;
280 #hasMoves = false;
init0Start the project281 /** Each moved line's relocation that counts in this set; built on first use. */
282 #relocs: Map<LineId, RelocationInfo> | undefined;
283 /** The same, by n, with the new parent's code. */
284 #relocsN: Map<number, { readonly r: RelocationInfo; readonly parent: number }> | undefined;
capacity205Disk-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.Compare285 /** The moved lines under each node, by its code, made from the relocations on first use. */
286 #movedInto: Map<number, number[]> | undefined;
287 /** Whether this view's moves are too many to keep, so they're resolved on disk per layout; undefined until asked. */
288 #movesOnDisk: boolean | undefined;
init0Start the project289 /** The latest records asked for: one file's lines, one file's sequence, one file's text. */
290 #linesCache: { path: string; lines: readonly VisibleLine[] } | undefined;
291 #seqCache: { path: string; seq: readonly SeqLine[] } | undefined;
292 #textCache: { path: string; text: string } | undefined;
294 constructor(graph: Graph, set: Iterable<AtomId>) {
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare295 this.graph = graph;
296 if (set instanceof StableSet) {
297 this.#stable = set;
298 this.#set = set;
299 this.#in = new Uint8Array(0);
capacity205Disk-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.Compare300 // A set kept closed when it was written needs no proof here (abso Capacity).
301 for (const id of isClosedSet(set) ? [] : set) {
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare302 const atom = graph.atom(id);
303 for (const dependency of atom.deps) {
304 graph.atom(dependency);
305 if (!set.has(dependency))
306 throw new EngineError("not-closed", `set is not closed: ${id} depends on ${dependency}`);
307 }
308 }
codex-capacity-chair123Stream mover history when opening persisted viewsCompare309 for (const id of graph.movers()) {
310 if (set.has(id)) {
311 this.#hasMoves = true;
312 break;
313 }
314 }
315 this.#relocs = this.#hasMoves ? undefined : new Map();
316 this.#relocsN = this.#hasMoves ? undefined : new Map();
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare317 return;
318 }
init0Start the project319 const inSet = new Uint8Array(graph.size);
capacity218why on a stored writer (disk-first 2; abso Capacity). - 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. - 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. - publishOf looks in shared before listing the named drafts, since listing them decodes each one's space. - view.ts loses #eachMover, unused since 215. On 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. Named tests: trail, named-drafts, files-reads, project, markers, version-files, draft-reads-stored, view, moves, drop (109 of 109); tsc and biome clean.Compare320 // An atom's number is in its id (abso Capacity): reading the atom for it read the whole history on a stored graph.
321 const seqIn = (id: AtomId): number => {
322 const seq = seqOf(id);
323 return seq >= 0 && seq < inSet.length && graph.idOfSeq(seq) === id ? seq : graph.atom(id).seq;
324 };
325 for (const id of set) inSet[seqIn(id)] = 1;
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare326 // Validate one atom at a time. Keeping all decoded atoms here defeats
327 // storage-backed Graph reads even though the view only needs membership.
328 for (let seq = 0; seq < inSet.length; seq++) {
329 if (inSet[seq] !== 1) continue;
330 const atom = graph.atom(graph.idOfSeq(seq));
init0Start the project331 for (const d of atom.deps) {
capacity218why on a stored writer (disk-first 2; abso Capacity). - 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. - 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. - publishOf looks in shared before listing the named drafts, since listing them decodes each one's space. - view.ts loses #eachMover, unused since 215. On 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. Named tests: trail, named-drafts, files-reads, project, markers, version-files, draft-reads-stored, view, moves, drop (109 of 109); tsc and biome clean.Compare332 if (inSet[seqIn(d)] !== 1) throw new EngineError("not-closed", `set is not closed: ${atom.id} depends on ${d}`);
init0Start the project333 }
334 }
335 this.graph = graph;
336 this.#in = inSet;
capacity218why on a stored writer (disk-first 2; abso Capacity). - 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. - 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. - publishOf looks in shared before listing the named drafts, since listing them decodes each one's space. - view.ts loses #eachMover, unused since 215. On 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. Named tests: trail, named-drafts, files-reads, project, markers, version-files, draft-reads-stored, view, moves, drop (109 of 109); tsc and biome clean.Compare337 this.#movers = graph.movers().filter((id) => inSet[seqOf(id)] === 1);
codex-capacity-chair123Stream mover history when opening persisted viewsCompare338 this.#hasMoves = this.#movers.length > 0;
init0Start the project339 this.#relocs = this.#movers.length === 0 ? new Map() : undefined;
340 this.#relocsN = this.#movers.length === 0 ? new Map() : undefined;
341 }
343 /** The set of atoms this view projects. */
344 get set(): AtomSet {
345 if (!this.#set) {
346 const out = new Set<AtomId>();
347 for (let seq = 0; seq < this.#in.length; seq++) if (this.#in[seq] === 1) out.add(this.graph.idOfSeq(seq));
348 this.#set = out;
349 }
350 return this.#set;
351 }
353 /** Whether the atom with this seq is in the set. */
354 #has(seq: number): boolean {
codex-capacity-chair116Bound repeated indexed view membership lookupsCompare355 if (this.#stable) {
356 const slot = seq % this.#membershipSeq.length;
357 if (this.#membershipSeq[slot] === seq) return this.#membershipValue[slot] === 1;
358 const present = this.#stable.has(this.graph.idOfSeq(seq));
359 this.#membershipSeq[slot] = seq;
360 this.#membershipValue[slot] = present ? 1 : 0;
361 return present;
362 }
init0Start the project363 return seq < this.#in.length && this.#in[seq] === 1;
364 }
366 /**
367 * The relocation that counts for each moved line: the newest (by priority)
368 * in the set. Two moves made apart can loop lines into each other, so no
369 * start node reaches them; then the oldest relocation on the loop is
370 * ignored, and the next newest of that line counts, until none loop.
371 */
372 #relocations(): Map<LineId, RelocationInfo> {
373 if (this.#relocs) return this.#relocs;
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare374 this.#takeShared();
375 if (this.#relocs) return this.#relocs;
init0Start the project376 const graph = this.graph;
capacity215Moves 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. - 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. - 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. Tests: 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.Compare377 const skeleton = skeletonOf(graph);
init0Start the project378 const stronger = (a: RelocationInfo, b: RelocationInfo): boolean => graph.comparePriority(a.atom, b.atom) > 0;
codex-capacity-chair126Identify suppressed relocation cycles across persistent readsCompare379 const identity = (r: RelocationInfo): string => JSON.stringify([r.atom, r.k]);
380 const ignored = new Set<string>();
capacity215Moves 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. - 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. - 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. Tests: 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.Compare381 const pick = (n: number): MoveEntry | undefined => {
382 let best: MoveEntry | undefined;
383 for (const e of skeleton.byLine.get(n) ?? []) {
384 if (this.#has(seqOf(e.r.atom)) && !ignored.has(identity(e.r)) && (!best || stronger(e.r, best.r))) best = e;
init0Start the project385 }
386 return best;
387 };
capacity215Moves 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. - 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. - 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. Tests: 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.Compare388 // By the moved line's number, in the order its movers come (seq order, then each mover's moves).
389 const relocs = new Map<number, MoveEntry>();
390 for (const mover of skeleton.movers) {
391 if (!this.#has(mover.seq)) continue;
392 for (const n of mover.lines) {
393 if (!relocs.has(n)) relocs.set(n, pick(n)!);
capacity205Disk-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.Compare394 if (graph.hasOrderedChildren && relocs.size > MOVED_LINES_KEPT) throw new TooManyMoves();
init0Start the project395 }
396 }
capacity215Moves 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. - 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. - 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. Tests: 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.Compare397 // From a node, the next node that matters for loops: a line moved in this set, or a file's start.
398 const hop = (code: number): number => {
399 let c = skeleton.climb(code);
400 while (c >= 0 && !relocs.has(c)) c = skeleton.climb(graph.parentCodeOf(c));
401 return c;
402 };
403 const step = (n: number): number => {
404 const e = relocs.get(n);
405 return hop(e ? e.parent : graph.parentCodeOf(n));
406 };
407 // Two moves made apart can loop lines into each other, so no start node reaches them; then the oldest
408 // relocation on the loop is ignored, and the next newest of that line counts, until none loop.
409 const reaches = new Set<number>();
init0Start the project410 for (const line of [...relocs.keys()]) {
411 for (;;) {
capacity215Moves 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. - 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. - 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. Tests: 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.Compare412 const path: number[] = [];
413 const onPath = new Map<number, number>();
414 let cur = line;
init0Start the project415 let loopAt = -1;
capacity215Moves 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. - 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. - 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. Tests: 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.Compare416 while (cur >= 0 && !reaches.has(cur)) {
init0Start the project417 const at = onPath.get(cur);
418 if (at !== undefined) {
419 loopAt = at;
420 break;
421 }
422 onPath.set(cur, path.length);
423 path.push(cur);
capacity215Moves 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. - 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. - 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. Tests: 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.Compare424 cur = step(cur);
init0Start the project425 }
426 if (loopAt < 0) {
427 for (const l of path) reaches.add(l);
428 break;
429 }
capacity215Moves 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. - 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. - 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. Tests: 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.Compare430 let weakest: MoveEntry | undefined;
init0Start the project431 for (const l of path.slice(loopAt)) {
capacity215Moves 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. - 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. - 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. Tests: 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.Compare432 const e = relocs.get(l);
433 if (e && (!weakest || stronger(weakest.r, e.r))) weakest = e;
init0Start the project434 }
capacity215Moves 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. - 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. - 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. Tests: 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.Compare435 ignored.add(identity(weakest!.r));
436 const next = pick(weakest!.n);
437 if (next) relocs.set(weakest!.n, next);
438 else relocs.delete(weakest!.n);
init0Start the project439 }
440 }
capacity215Moves 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. - 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. - 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. Tests: 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.Compare441 this.#relocsN = new Map([...relocs].map(([n, e]) => [n, { r: e.r, parent: e.parent }]));
442 this.#relocs = new Map([...relocs.values()].map((e) => [e.r.line, e.r]));
443 return this.#relocs;
init0Start the project444 }
capacity207Each 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.Compare445
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare446 /** The view whose moves this one may take, until it needs them all; then the view it took them from. */
447 #movesFrom: View | undefined;
448 #movesTaken: View | undefined;
capacity207Each 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.Compare450 /**
capacity212Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export. - 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. - Draft files (overlaps.ts) go by number the same way. - An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this). - Draft collisions: - build the union view only when two drafts share a file; - work out each agent's touched files and its "shared now plus draft" view once; - find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history; - have the definition rule keep a draft's uses, and the newer work's definitions, across partners. - A stored list read in order reads its length once, not before every element. draft-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. On website's export (1,387 entries) the answers match Project.load: - status: 17 s to 4.5 s - where: over 60 s to 8.8 s - drafts: 14 s to 5.3 s - collisions: over 60 s to 54 s, measured under the profiler before the last two changesCompare451 * Take another view's resolved moves (abso Capacity), when both sets hold the very same atoms that move lines: the
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare452 * moves then resolve the same, and every line sits where it sits there. Checked when this view first needs all its
453 * moves, so any caller may ask, and a view that only finds a few lines' files never resolves them.
capacity207Each 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.Compare454 */
455 shareMoves(from: View): void {
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare456 if (from.graph !== this.graph || from.#hasMoves !== this.#hasMoves || !this.#hasMoves || this.#relocs) return;
457 this.#movesFrom = from;
458 }
capacity235A draft's view takes its base view's layout of every file the draft doesn't touch (disk-first 2; abso Capacity). An 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. - 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. - 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. On 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. New 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.Compare460 /**
461 * Files laid out as another view lays them out (abso Capacity): a draft's view over its base's, for every file the
462 * draft doesn't touch. The caller knows what the draft is; `except` is asked once, when a file is first needed, for
463 * the files the draft touches, or undefined when nothing can be shared (a draft that moves lines). Without it, an
464 * agent's tree, files and blame laid out every file of the project again for each agent.
465 */
466 shareFiles(from: View, except: () => ReadonlySet<string> | undefined): void {
467 if (from.graph !== this.graph || from === this || this.#filesFrom !== undefined) return;
468 this.#filesFrom = { from, except };
469 }
470 #filesFrom: { from: View; except: () => ReadonlySet<string> | undefined } | null | undefined;
capacity245Collisions step 1: whether a file exists, without laying it out (abso Capacity, issue 664). A 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. On 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. test/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.Compare471
472 /**
473 * The files this view's set has, from what the project keeps for a published version (abso Capacity): hasFile
474 * answers from it, not a layout of the file. Collisions resolving an import tried up to seven names, and each one
475 * laid its file out. `paths` is asked once, when first needed; undefined lays files out as before.
476 */
477 knowPaths(paths: () => ReadonlySet<string> | undefined): void {
478 if (this.#pathsFrom === undefined) this.#pathsFrom = paths;
479 }
480 #pathsFrom: (() => ReadonlySet<string> | undefined) | undefined;
481 #knownPaths: ReadonlySet<string> | null | undefined;
capacity235A draft's view takes its base view's layout of every file the draft doesn't touch (disk-first 2; abso Capacity). An 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. - 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. - 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. On 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. New 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.Compare482 #filesShared: { from: View; except: ReadonlySet<string> } | null | undefined;
483 #sharedFiles(): { from: View; except: ReadonlySet<string> } | null {
484 if (this.#filesShared === undefined) {
485 const share = this.#filesFrom;
486 const except = share ? share.except() : undefined;
487 this.#filesShared = share && except ? { from: share.from, except } : null;
488 }
489 return this.#filesShared;
490 }
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare492 #takeShared(): void {
493 const from = this.#movesFrom;
494 if (!from) return;
495 this.#movesFrom = undefined;
496 if (from.#scratchMoves()) return;
capacity212Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export. - 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. - Draft files (overlaps.ts) go by number the same way. - An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this). - Draft collisions: - build the union view only when two drafts share a file; - work out each agent's touched files and its "shared now plus draft" view once; - find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history; - have the definition rule keep a draft's uses, and the newer work's definitions, across partners. - A stored list read in order reads its length once, not before every element. draft-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. On website's export (1,387 entries) the answers match Project.load: - status: 17 s to 4.5 s - where: over 60 s to 8.8 s - drafts: 14 s to 5.3 s - collisions: over 60 s to 54 s, measured under the profiler before the last two changesCompare497 for (const id of this.graph.movers()) {
498 const seq = seqOf(id);
499 if (this.#has(seq) !== from.#has(seq)) return;
500 }
capacity207Each 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.Compare501 this.#relocs = from.#relocations();
502 this.#relocsN = from.#relocationsN();
503 this.#movesOnDisk = false;
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare504 this.#movesTaken = from;
capacity207Each 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.Compare505 }
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare506
507 /** Moved lines' relocations picked one at a time, before the view resolves them all (null: not moved here). */
508 readonly #picked = new Map<number, MoveEntry | null>();
capacity207Each 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.Compare509
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare510 /**
511 * The relocation of moved line n that counts here, as #relocations picks it before any loop: right whenever the
512 * walk that reached n goes on to a file's start, since only lines on a loop have their relocation set aside.
513 */
514 #pickOne(n: number): MoveEntry | undefined {
515 let picked = this.#picked.get(n);
516 if (picked === undefined) {
517 const graph = this.graph;
518 let best: MoveEntry | undefined;
519 for (const e of skeletonOf(graph).byLine.get(n) ?? []) {
520 if (this.#has(seqOf(e.r.atom)) && (!best || graph.comparePriority(e.r.atom, best.r.atom) > 0)) best = e;
521 }
522 this.#picked.set(n, (picked = best ?? null));
523 }
524 return picked ?? undefined;
525 }
capacity205Disk-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.Compare527 /** Whether moves are resolved on disk for each layout: only a stored graph's view with more than MOVED_LINES_KEPT. */
528 #scratchMoves(): boolean {
529 if (!this.#hasMoves || !this.graph.hasOrderedChildren) return false;
530 if (this.#movesOnDisk === undefined) {
531 try {
532 this.#relocations();
533 this.#movesOnDisk = false;
534 } catch (error) {
535 if (!(error instanceof TooManyMoves)) throw error;
536 this.#movesOnDisk = true;
537 }
538 }
539 return this.#movesOnDisk;
540 }
init0Start the project542 /** The relocations by n, with each new parent's code. */
543 #relocationsN(): Map<number, { readonly r: RelocationInfo; readonly parent: number }> {
544 if (this.#relocsN) return this.#relocsN;
545 const out = new Map<number, { readonly r: RelocationInfo; readonly parent: number }>();
546 for (const [line, r] of this.#relocations())
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare547 out.set(this.graph.lineN(line), {
548 r,
549 parent: this.graph.codeOf(r.parent)!,
550 });
init0Start the project551 this.#relocsN = out;
552 return out;
553 }
555 /** The node a line hangs off in this set: where it was written, or where a move put it. */
556 parentOf(line: LineId): NodeId {
codex-capacity-chair132Bound persistent relocation projection memory with rollback-only scratchCompare557 if (this.graph.lineParent(line) === undefined) throw new EngineError("unknown-line", `no line ${line}`);
capacity205Disk-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.Compare558 if (this.#scratchMoves())
codex-capacity-chair132Bound persistent relocation projection memory with rollback-only scratchCompare559 return this.graph.withProjectionScratch((scratch) =>
560 resolveScratchMoves(this.graph, (id) => this.#has(this.graph.atom(id).seq), scratch).parent(line),
561 );
codex-capacity-chair123Stream mover history when opening persisted viewsCompare562 const r = this.#hasMoves ? this.#relocations().get(line) : undefined;
init0Start the project563 if (r) return r.parent;
564 const parent = this.graph.lineParent(line);
565 if (parent === undefined) throw new EngineError("unknown-line", `no line ${line}`);
566 return parent;
capacity266A draft that moves lines shares its base's layouts too (abso Capacity, issue 664). touchedBeyond 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. On 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). Exactness: 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.Compare567 }
569 /**
570 * The files where a moved line sits, in this view or in `other`, when the two place it differently: a different
571 * relocation wins, or a different parent (abso Capacity). Besides the files a draft's atoms name, these are the only
572 * ones a draft's moves can lay out differently from its base, since a line's descendants follow it. Undefined when
573 * either view resolves its moves in scratch, which keeps no map of them to compare.
574 */
575 placedDifferently(other: View): Set<string> | undefined {
576 if (this.#scratchMoves() || other.#scratchMoves()) return undefined;
577 const here = this.#hasMoves ? this.#relocationsN() : undefined;
578 const there = other.#hasMoves ? other.#relocationsN() : undefined;
579 const files = new Set<string>();
580 const add = (n: number) => {
581 files.add(this.#fileOfN(n));
582 files.add(other.#fileOfN(n));
583 };
584 for (const [n, x] of here ?? []) {
585 const y = there?.get(n);
586 if (!y || y.parent !== x.parent || y.r.atom !== x.r.atom) add(n);
587 }
588 for (const n of there?.keys() ?? []) if (!here?.has(n)) add(n);
589 return files;
init0Start the project590 }
592 /** Whether any atom in the set moves lines. */
593 hasMoves(): boolean {
codex-capacity-chair123Stream mover history when opening persisted viewsCompare594 return this.#hasMoves;
init0Start the project595 }
597 /** The file a line is in, in this set: the one its chain of parents reaches. */
598 fileOf(line: LineId): string {
599 const n = this.graph.lineN(line);
600 if (n < 0) throw new EngineError("unknown-line", `no line ${line}`);
601 return this.#fileOfN(n);
602 }
604 #fileOfN(n: number): string {
605 const graph = this.graph;
codex-capacity-chair123Stream mover history when opening persisted viewsCompare606 if (!this.#hasMoves) return graph.writtenIn(n);
capacity205Disk-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.Compare607 if (this.#scratchMoves())
codex-capacity-chair132Bound persistent relocation projection memory with rollback-only scratchCompare608 return graph.withProjectionScratch((scratch) => {
609 const moves = resolveScratchMoves(graph, (id) => this.#has(graph.atom(id).seq), scratch);
610 let current = graph.nodeOf(n);
611 while (!isStartNode(current)) current = moves.parent(current);
612 return current.slice(1);
613 });
capacity215Moves 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. - 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. - 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. Tests: 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.Compare614 return this.#fileOfCode(n);
615 }
617 /** The file a node sits in, in this set: up by where lines were written, through the moves that count here. */
618 #fileOfCode(code: number): string {
619 const graph = this.graph;
620 const skeleton = skeletonOf(graph);
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare621 if (!this.#relocsN) {
622 // One moved line at a time, until a walk comes back to a line it passed: then moves loop, and are resolved whole.
623 const passed = new Set<number>();
624 let c = code;
625 for (;;) {
626 c = skeleton.climb(c);
627 if (c < 0) return graph.nodeOf(c).slice(1);
628 if (passed.has(c)) break;
629 passed.add(c);
630 const e = this.#pickOne(c);
631 c = e ? e.parent : graph.parentCodeOf(c);
632 }
633 }
init0Start the project634 const relocs = this.#relocationsN();
capacity215Moves 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. - 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. - 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. Tests: 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.Compare635 let c = code;
636 for (;;) {
637 c = skeleton.climb(c);
638 if (c < 0) return graph.nodeOf(c).slice(1);
639 const e = relocs.get(c);
640 c = e ? e.parent : graph.parentCodeOf(c);
init0Start the project641 }
642 }
644 /** The lines hanging off a node in this set, in layout order. */
645 #children(code: number): Child[] {
646 const graph = this.graph;
codex-capacity-chair123Stream mover history when opening persisted viewsCompare647 const relocs = this.#hasMoves ? this.#relocationsN() : undefined;
init0Start the project648 const out: Child[] = [];
codex-capacity-chair130Stream paged child history into layout filteringCompare649 for (const n of graph.eachChildN(code)) {
init0Start the project650 const seq = graph.writerSeqOf(n);
651 if (!this.#has(seq) || relocs?.has(n)) continue;
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare652 out.push({
653 n,
654 replaces: graph.replacesN(n) ? 1 : 0,
655 lamport: graph.lamportOfSeq(seq),
656 seq,
657 k: graph.kOf(n),
658 });
init0Start the project659 }
660 if (relocs) {
capacity205Disk-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.Compare661 // The lines this set's moves put under each node, from the moves it already resolved: no row read per node
662 // (abso Capacity).
663 if (!this.#movedInto) {
664 this.#movedInto = new Map();
665 for (const [n, { parent }] of relocs) {
666 const into = this.#movedInto.get(parent);
667 if (into) into.push(n);
668 else this.#movedInto.set(parent, [n]);
669 }
670 }
671 for (const n of this.#movedInto.get(code) ?? NO_LINES) {
672 const r = relocs.get(n)!.r;
init0Start the project673 const seq = graph.atom(r.atom).seq;
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare674 out.push({
675 n,
676 replaces: 0,
677 lamport: graph.lamportOfSeq(seq),
678 seq,
679 k: r.k,
680 });
init0Start the project681 }
682 }
683 // A line's replacements (runs of atoms that deleted it) first, then the
684 // rest; each group in descending priority (lamport, then seq); lines of
685 // one atom keep k order. A replacement already outranks every insertion
686 // after the line that reads it (it depends on them, or conflicts with
687 // them); the grouping also puts it above a `before` insertion, which
688 // doesn't read the line above, so the new text lands in the replaced
689 // line's place. A moved line ranks like an insertion by the moving atom.
690 if (out.length > 1)
691 out.sort((a, b) => b.replaces - a.replaces || b.lamport - a.lamport || b.seq - a.seq || a.k - b.k);
692 return out;
693 }
codex-capacity-chair131Bound persisted no-move layout with ordered successor traversalCompare695 /** Parent/successor traversal keeps no history-sized ancestry or sibling frontier. */
696 *#layoutNodes(start: number): IterableIterator<number> {
697 const graph = this.graph;
698 if (graph.hasOrderedChildren && !this.#hasMoves) {
699 const first = (parent: number, after?: number): number | undefined => {
700 for (const n of graph.orderedChildrenN(parent, after)) if (this.#has(graph.writerSeqOf(n))) return n;
701 return undefined;
702 };
703 let n = first(start);
704 while (n !== undefined) {
705 yield n;
706 const child = first(n);
707 if (child !== undefined) {
708 n = child;
709 continue;
710 }
711 let previous = n;
712 for (;;) {
713 const parent = graph.parentCodeOf(previous);
714 const sibling = first(parent, previous);
715 if (sibling !== undefined) {
716 n = sibling;
717 break;
718 }
719 if (parent === start) {
720 n = undefined;
721 break;
722 }
723 if (parent < 0 || parent >= previous) throw new Error("invalid persistent layout ancestry");
724 previous = parent;
725 }
726 }
727 return;
728 }
init0Start the project729 const stack: number[] = [];
codex-capacity-chair131Bound persisted no-move layout with ordered successor traversalCompare730 const push = (parent: number): void => {
731 const children = this.#children(parent);
732 for (let i = children.length - 1; i >= 0; i--) stack.push(children[i]!.n);
733 };
734 push(start);
735 while (stack.length) {
736 const n = stack.pop()!;
737 yield n;
738 push(n);
739 }
740 }
init0Start the project742 /** Lay out one file: its line tree from the set's atoms, linearized. */
codex-capacity-chair110Keep current-file views and key scans from retaining historical stateCompare743 #layout(path: string, complete: boolean): FileState {
init0Start the project744 const graph = this.graph;
capacity221Packed layout follows lines written in another file (disk-first 2; abso Capacity). where {} 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. - 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. - 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. - 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. Named 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.Compare745 if (graph.packedLayout && !this.#scratchMoves()) return this.#layoutPacked(path, complete);
capacity205Disk-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.Compare746 if (this.#scratchMoves())
codex-capacity-chair132Bound persistent relocation projection memory with rollback-only scratchCompare747 return graph.withProjectionScratch((scratch) =>
748 this.#layoutResolved(
749 path,
750 complete,
751 scratchLayoutNodes(graph, (id) => this.#has(graph.atom(id).seq), scratch, `^${path}`),
752 ),
753 );
754 return this.#layoutResolved(path, complete);
755 }
capacity206Each 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.Compare757 /** For each path, the files that lines moved into it were written in: worked out once per view. */
758 #movedFrom: Map<string, Set<number>> | undefined;
759 #movedInFrom(): Map<string, Set<number>> {
760 if (this.#movedFrom) return this.#movedFrom;
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare761 this.#relocations();
762 if (this.#movesTaken) return (this.#movedFrom = this.#movesTaken.#movedInFrom());
capacity206Each 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.Compare763 const graph = this.graph;
764 const out = new Map<string, Set<number>>();
765 if (this.#hasMoves) {
766 const relocs = this.#relocationsN();
capacity215Moves 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. - 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. - 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. Tests: 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.Compare767 const fileOf = (code: number): string => this.#fileOfCode(code);
capacity206Each 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.Compare768 for (const [n, { parent }] of relocs) {
769 const into = fileOf(parent);
770 let from = out.get(into);
771 if (!from) out.set(into, (from = new Set()));
772 from.add(graph.writtenInIndex(n));
773 }
774 }
775 this.#movedFrom = out;
776 return out;
777 }
779 /**
capacity221Packed layout follows lines written in another file (disk-first 2; abso Capacity). where {} 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. - 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. - 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. - 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. Named 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.Compare780 * Lay one file out from its packed history (abso Capacity, Graph.packedLines): the lines written in it, in the files
781 * its moved-in lines came from, and in the files runs under any of those lines were written in, read a page at a
782 * time; the same tree and order as #layoutResolved, built in memory with no read per line.
capacity206Each 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.Compare783 */
784 #layoutPacked(path: string, complete: boolean): FileState {
785 const graph = this.graph;
786 const attrs = this.#attributes(path);
787 const start = graph.startCodeOf(path);
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare788 if (start === undefined)
789 return {
790 attrs,
791 complete,
792 seq: EMPTY_INTS,
793 vis: EMPTY_INTS,
794 deletedBy: new Map(),
795 };
capacity206Each 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.Compare796 const relocs = this.#hasMoves ? this.#relocationsN() : undefined;
797 const files = new Set<number>([-1 - start, ...(this.#movedInFrom().get(path) ?? [])]);
798 const children = new Map<number, Child[]>();
capacity274Cold 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. - 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. - 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. - 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. Side 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.Compare799 // Where each line's text is: its file and its place in that file's packed history. Texts are read after the walk,
800 // only for the lines it shows (abso Capacity): every text a file and its moved-in sources ever had was read for
801 // every layout, and abso's worker files, split out of index.ts, read all of index.ts's history each.
802 const textFile = new Map<number, number>();
803 const textPlace = new Map<number, number>();
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare804 const writers = new Map<number, number>();
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare805 const places = new Map<number, number>();
capacity206Each 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.Compare806 const deleters = new Map<number, number[]>();
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare807 // Each atom's lamport once per layout: most lines share a few atoms, and a stored graph reads it from a page.
808 const lamports = new Map<number, number>();
809 const lamportOf = (seq: number): number => {
810 let lamport = lamports.get(seq);
811 if (lamport === undefined) {
812 lamport = graph.lamportOfSeq(seq);
813 lamports.set(seq, lamport);
814 }
815 return lamport;
816 };
capacity206Each 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.Compare817 for (const file of files) {
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare818 // The file's history decoded once and kept by the graph (abso Capacity): each view of it read every page again.
819 const history = graph.packedHistory(file);
820 const lines = history.lines;
821 for (let i = 0, place = 0; i < lines.length; i += 5, place++) {
822 const n = lines[i]!;
823 const parent = lines[i + 1]!;
824 const seq = lines[i + 2]!;
825 const k = lines[i + 3]!;
826 const replaces = lines[i + 4]!;
capacity206Each 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.Compare827 if (!this.#has(seq)) continue;
828 const moved = relocs?.get(n);
829 let at = parent;
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare830 let child: Child = { n, replaces, lamport: lamportOf(seq), seq, k };
capacity206Each 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.Compare831 if (moved) {
832 const mover = graph.atom(moved.r.atom).seq;
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare833 child = {
834 n,
835 replaces: 0,
836 lamport: lamportOf(mover),
837 seq: mover,
838 k: moved.r.k,
839 };
capacity206Each 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.Compare840 at = moved.parent;
841 }
842 const list = children.get(at);
843 if (list) list.push(child);
844 else children.set(at, [child]);
capacity274Cold 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. - 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. - 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. - 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. Side 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.Compare845 textFile.set(n, file);
846 textPlace.set(n, place);
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare847 writers.set(n, seq);
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare848 places.set(n, k);
capacity206Each 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.Compare849 }
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare850 const dels = history.deletes;
851 for (let at = 0; at < dels.length; at += 2) {
852 const n = dels[at]!;
853 const deleter = dels[at + 1]!;
capacity206Each 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.Compare854 if (!this.#has(deleter)) continue;
855 const by = deleters.get(n);
856 if (by) by.push(deleter);
857 else deleters.set(n, [deleter]);
858 }
capacity221Packed layout follows lines written in another file (disk-first 2; abso Capacity). where {} 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. - 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. - 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. - 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. Named 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.Compare859 // Runs written elsewhere under this file's lines follow them; the loop reads their files too.
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare860 const crossings = history.crossings;
861 for (let at = 0; at < crossings.length; at += 2) if (writers.has(crossings[at]!)) files.add(crossings[at + 1]!);
capacity206Each 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.Compare862 }
863 const order = (a: Child, b: Child) =>
864 b.replaces - a.replaces || b.lamport - a.lamport || b.seq - a.seq || a.k - b.k;
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare865 const priority = (a: number, b: number) => lamportOf(a) - lamportOf(b) || a - b;
capacity206Each 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.Compare866 const seq: number[] = [];
867 const vis: number[] = [];
868 const visText: (string | null)[] = [];
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare869 const visWriter: number[] = [];
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare870 const visK: number[] = [];
871 const seqWriter: number[] = [];
872 const seqK: number[] = [];
capacity206Each 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.Compare873 const deletedBy = new Map<number, readonly number[]>();
capacity274Cold 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. - 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. - 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. - 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. Side 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.Compare874 // The text pages read for this layout, by file and page: each at most once.
875 const pages = new Map<number, Map<number, readonly (string | null)[]>>();
876 const textOf = (n: number): string | null => {
877 const file = textFile.get(n)!;
878 const place = textPlace.get(n)!;
879 const page = Math.floor(place / 256);
880 let byPage = pages.get(file);
881 if (!byPage) pages.set(file, (byPage = new Map()));
882 let texts = byPage.get(page);
883 if (!texts) byPage.set(page, (texts = graph.packedTextPage(file, page)));
884 return texts[place % 256] ?? null;
885 };
capacity206Each 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.Compare886 const stack: number[] = [];
887 const push = (code: number) => {
888 const list = children.get(code);
889 if (!list) return;
890 if (list.length > 1) list.sort(order);
891 for (let i = list.length - 1; i >= 0; i--) stack.push(list[i]!.n);
892 };
893 push(start);
894 while (stack.length) {
895 const n = stack.pop()!;
896 const by = deleters.get(n);
897 if (by) {
898 if (complete) deletedBy.set(seq.length, by.length > 1 ? by.sort(priority) : by);
899 } else {
900 vis.push(n);
capacity274Cold 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. - 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. - 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. - 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. Side 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.Compare901 visText.push(textOf(n));
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare902 visWriter.push(writers.get(n)!);
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare903 visK.push(places.get(n)!);
capacity206Each 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.Compare904 }
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare905 if (complete) {
906 seq.push(n);
907 seqWriter.push(writers.get(n)!);
908 seqK.push(places.get(n)!);
909 }
capacity206Each 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.Compare910 push(n);
911 }
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare912 return {
913 attrs,
914 complete,
915 seq: Int32Array.from(seq),
916 vis: Int32Array.from(vis),
917 deletedBy,
918 visText,
919 visWriter: Int32Array.from(visWriter),
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare920 visK: Int32Array.from(visK),
921 ...(complete ? { seqWriter: Int32Array.from(seqWriter), seqK: Int32Array.from(seqK) } : {}),
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare922 };
capacity206Each 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.Compare923 }
codex-capacity-chair140Avoid line projection for file attribute queriesCompare925 #attributes(path: string): FileAttrs {
codex-capacity-chair132Bound persistent relocation projection memory with rollback-only scratchCompare926 const graph = this.graph;
init0Start the project927 // For each attribute, the highest-priority setter in the set wins.
928 const setters = new Map<string, { id: AtomId; value: string | null }>();
capacity206Each 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.Compare929 const file = graph.packedFiles ? graph.pathIndexOf(path) : undefined;
930 if (graph.packedFiles) {
931 for (const [seq, name, value] of file === undefined ? [] : graph.packedAttrs(file)) {
932 if (!this.#has(seq)) continue;
933 const id = graph.idOfSeq(seq);
934 const best = setters.get(name);
935 if (!best || graph.comparePriority(best.id, id) < 0) setters.set(name, { id, value });
936 }
937 return {
938 exists: setters.get("exists")?.value === "1",
939 exec: setters.get("exec")?.value === "1",
940 link: setters.get("link")?.value ?? null,
941 blob: setters.get("blob")?.value ?? null,
942 };
943 }
codex-capacity-chair119Page per-file atom indexes and stream current-view attribute scansCompare944 for (const id of graph.eachAtomIn(path)) {
init0Start the project945 if (!this.#has(graph.atom(id).seq)) continue;
946 for (const a of graph.atom(id).attrs ?? []) {
947 if (a.file !== path) continue;
948 const best = setters.get(a.name);
949 if (!best || graph.comparePriority(best.id, id) < 0) setters.set(a.name, { id, value: a.value });
950 }
951 }
codex-capacity-chair140Avoid line projection for file attribute queriesCompare952
953 return {
init0Start the project954 exists: setters.get("exists")?.value === "1",
955 exec: setters.get("exec")?.value === "1",
956 link: setters.get("link")?.value ?? null,
957 blob: setters.get("blob")?.value ?? null,
958 };
codex-capacity-chair140Avoid line projection for file attribute queriesCompare959 }
init0Start the project960
codex-capacity-chair132Bound persistent relocation projection memory with rollback-only scratchCompare961 #layoutResolved(path: string, complete: boolean, nodes?: Iterable<number>): FileState {
codex-capacity-chair140Avoid line projection for file attribute queriesCompare962 const graph = this.graph;
963 const attrs = this.#attributes(path);
init0Start the project964 const seq: number[] = [];
965 const vis: number[] = [];
966 const deletedBy = new Map<number, readonly number[]>();
codex-capacity-chair131Bound persisted no-move layout with ordered successor traversalCompare967
init0Start the project968 const start = graph.startCodeOf(path);
969 const priority = (a: number, b: number) => graph.lamportOfSeq(a) - graph.lamportOfSeq(b) || a - b;
codex-capacity-chair132Bound persistent relocation projection memory with rollback-only scratchCompare970 for (const n of nodes ?? (start === undefined ? [] : this.#layoutNodes(start))) {
codex-capacity-chair128Page deletion history and short-circuit current visibilityCompare971 let deleted = false;
972 const by: number[] = [];
973 for (const deleter of graph.eachDeleterSeqOf(n)) {
974 if (!this.#has(deleter)) continue;
975 deleted = true;
976 if (!complete) break;
977 by.push(deleter);
978 }
979 if (deleted) {
980 if (complete) deletedBy.set(seq.length, by.length > 1 ? by.sort(priority) : by);
codex-capacity-chair110Keep current-file views and key scans from retaining historical stateCompare981 } else vis.push(n);
982 if (complete) seq.push(n);
init0Start the project983 }
codex-capacity-chair140Avoid line projection for file attribute queriesCompare984
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare985 return {
986 attrs,
987 complete,
988 seq: Int32Array.from(seq),
989 vis: Int32Array.from(vis),
990 deletedBy,
991 };
init0Start the project992 }
994 get #known(): string[] {
995 if (!this.#knownList) {
996 const known = new Set<string>();
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare997 if (this.#stable) {
998 for (const id of this.#stable) for (const file of this.graph.filesOf(id)) known.add(file);
999 } else {
1000 for (let seq = 0; seq < this.#in.length; seq++)
1001 if (this.#in[seq] === 1) for (const file of this.graph.filesOf(this.graph.idOfSeq(seq))) known.add(file);
init0Start the project1003 this.#knownList = [...known].sort();
1005 return this.#knownList;
1008 /** Files with at least one visible line, sorted. */
1009 paths(): string[] {
capacity252Folder 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). - 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. - 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. - 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. - 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. - 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. On 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. Tests: 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).Compare1010 // Without walking every file the graph has ever had (abso Capacity): a draft's view over its base's has the base's
1011 // files, with the ones its draft touches checked here; a published version's are kept (knowPaths).
1012 const shared = this.#filesFrom === undefined ? null : this.#sharedFiles();
1013 if (shared) {
1014 const out = shared.from.paths().filter((p) => !shared.except.has(p));
1015 for (const p of shared.except) if (this.hasFile(p)) out.push(p);
1016 return out.sort();
1018 if (this.#pathsFrom !== undefined) {
1019 if (this.#knownPaths === undefined) this.#knownPaths = this.#pathsFrom() ?? null;
1020 if (this.#knownPaths) return [...this.#knownPaths].sort();
codex-capacity-chair118Avoid retaining deleted historical paths in indexed current viewsCompare1022 if (this.#stable) {
1023 const paths: string[] = [];
1024 for (const path of this.graph.knownFiles()) {
1025 if (this.hasFile(path)) paths.push(path);
capacity263The view cache trims the least recently used file layouts across its views before whole views (abso Capacity, issue 664). After 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. On 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. View 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.Compare1026 else {
1027 this.#files.delete(path);
1028 this.#used.delete(path);
codex-capacity-chair118Avoid retaining deleted historical paths in indexed current viewsCompare1030 }
1031 return paths.sort();
init0Start the project1033 return this.#known.filter((p) => this.hasFile(p));
1036 /** Every file the set has ever written a line in, including fully deleted ones. */
1037 knownPaths(): string[] {
1038 return [...this.#known];
capacity207Each 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.Compare1039 }
capacity212Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export. - 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. - Draft files (overlaps.ts) go by number the same way. - An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this). - Draft collisions: - build the union view only when two drafts share a file; - work out each agent's touched files and its "shared now plus draft" view once; - find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history; - have the definition rule keep a draft's uses, and the newer work's definitions, across partners. - A stored list read in order reads its length once, not before every element. draft-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. On website's export (1,387 entries) the answers match Project.load: - status: 17 s to 4.5 s - where: over 60 s to 8.8 s - drafts: 14 s to 5.3 s - collisions: over 60 s to 54 s, measured under the profiler before the last two changesCompare1041 /** The file line n sits in, in this set: fileOf by the line's number, with no lookup of its id. */
1042 fileOfNumber(n: number): string {
1043 return this.#fileOfN(n);
capacity207Each 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.Compare1046 /** How many visible lines a file has. */
1047 visibleCount(path: string): number {
1048 return this.#file(path).vis.length;
init0Start the project1049 }
1051 /** Whether the file exists in this projection (has a visible line). */
1052 hasFile(path: string): boolean {
capacity245Collisions step 1: whether a file exists, without laying it out (abso Capacity, issue 664). A 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. On 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. test/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.Compare1053 if (!this.#files.has(path)) {
1054 // A file the draft doesn't touch exists as it does in the base; a published version's files are kept.
1055 const shared = this.#filesFrom === undefined ? null : this.#sharedFiles();
1056 if (shared && !shared.except.has(path)) return shared.from.hasFile(path);
1057 if (this.#pathsFrom !== undefined) {
1058 if (this.#knownPaths === undefined) this.#knownPaths = this.#pathsFrom() ?? null;
1059 if (this.#knownPaths) return this.#knownPaths.has(path);
codex-capacity-chair140Avoid line projection for file attribute queriesCompare1062 const attrs = this.attrs(path);
1063 return attrs.exists || attrs.link !== null || attrs.blob !== null || this.#file(path).vis.length > 0;
init0Start the project1064 }
1066 /** A file's attributes: kept while empty, executable, a link's target. */
1067 attrs(path: string): FileAttrs {
codex-capacity-chair140Avoid line projection for file attribute queriesCompare1068 return this.#files.get(path)?.attrs ?? this.#attributes(path);
init0Start the project1069 }
1071 /** The projected text of a file ("" if it has no visible lines). */
1072 text(path: string): string {
1073 if (this.#textCache?.path === path) return this.#textCache.text;
capacity206Each 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.Compare1074 const { vis, visText } = this.#file(path);
init0Start the project1075 const lines: string[] = new Array(vis.length);
capacity206Each 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.Compare1076 for (let i = 0; i < vis.length; i++) lines[i] = visText?.[i] ?? this.graph.textOf(vis[i]!);
init0Start the project1077 const text = joinLines(lines);
1078 this.#textCache = { path, text };
1079 return text;
1082 /** Whether a file reads the same here and in `other` (of the same graph), compared line by line without joining either (#46). */
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare1083 sameText(path: string, other: ReadView): boolean {
1084 if (!(other instanceof View)) {
1085 const a = this.lines(path),
1086 b = other.lines(path);
1087 return a.length === b.length && a.every((line, i) => line.text === b[i]!.text);
init0Start the project1089 const a = this.#file(path).vis;
1090 const b = other.#file(path).vis;
1091 if (a.length !== b.length) return false;
1092 for (let i = 0; i < a.length; i++)
1093 if (a[i] !== b[i] && this.graph.textOf(a[i]!) !== this.graph.textOf(b[i]!)) return false;
1094 return true;
codex-capacity-chair175Reduce 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.Compare1095 }
1097 *lineChunks(path: string): IterableIterator<() => Iterable<string>> {
capacity315Record 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.Compare1098 // The texts the packed layout already holds, read a page at a time (abso Capacity, 714): a record's diff read each
1099 // line's own row, 11,873 statements for abso's index.ts. Only a line too long to pack is read in chunks.
1100 const { vis, visText } = this.#file(path);
1101 for (let i = 0; i < vis.length; i++) {
1102 const packed = visText?.[i];
1103 if (packed != null) yield () => [packed];
1104 else yield () => this.graph.textChunks(vis[i]!);
codex-capacity-chair175Reduce 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.Compare1106 }
1108 /** Visible lines without retaining their text in the view cache. */
1109 *visibleLines(path: string): IterableIterator<VisibleLine> {
1110 const graph = this.graph;
1111 for (const n of this.#file(path).vis)
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare1112 yield {
1113 id: graph.lineIdOf(n),
1114 text: graph.textOf(n),
capacity317A 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). - 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. - 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. On abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610: - 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. - read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s. What'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. Checks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.Compare1115 atom: atomId(graph.writerSeqOf(n)),
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare1116 };
codex-capacity-chair175Reduce 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.Compare1117 }
1119 /** Atom-building line handles; text is loaded only when requested. */
1120 buildLines(path: string): readonly VisibleLine[] {
1121 const graph = this.graph;
capacity230Who wrote what, read from the packed layout and each atom's author once (disk-first 2; abso Capacity). On 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. - 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. - 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. - The packed layout reads each atom's lamport number once per layout instead of once per line. On 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. New 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.Compare1122 // Texts and writers the packed layout already holds are not read again (abso Capacity).
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare1123 const { vis, visText, visWriter, visK } = this.#file(path);
codex-capacity-chair175Reduce 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.Compare1124 const lines: VisibleLine[] = new Array(vis.length);
1125 for (let i = 0; i < vis.length; i++) {
1126 const n = vis[i]!;
capacity229Draft collisions without copying shared's atoms per pair (disk-first 2; abso Capacity). On typescript-rs, with one opened writer, collisions ran past 5 minutes with 2.5 million row reads; replay takes 5 s. - 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. - View.lines and buildLines use the texts the packed layout already holds, instead of reading each line's text again. - 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. On 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. Named 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.Compare1127 const packed = visText?.[i];
codex-capacity-chair175Reduce 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.Compare1128 lines[i] = {
capacity317A 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). - 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. - 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. On abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610: - 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. - read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s. What'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. Checks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.Compare1129 id: visWriter && visK ? lineId(atomId(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),
codex-capacity-chair175Reduce 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.Compare1130 textChunks: () => graph.textChunks(n),
1131 get text() {
capacity229Draft collisions without copying shared's atoms per pair (disk-first 2; abso Capacity). On typescript-rs, with one opened writer, collisions ran past 5 minutes with 2.5 million row reads; replay takes 5 s. - 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. - View.lines and buildLines use the texts the packed layout already holds, instead of reading each line's text again. - 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. On 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. Named 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.Compare1132 return packed ?? graph.textOf(n);
codex-capacity-chair175Reduce 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.Compare1133 },
capacity317A 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). - 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. - 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. On abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610: - 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. - read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s. What'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. Checks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.Compare1134 atom: atomId(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
codex-capacity-chair175Reduce 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.Compare1135 };
1137 return lines;
init0Start the project1138 }
1140 /** Visible lines with their ids. */
1141 lines(path: string): readonly VisibleLine[] {
1142 if (this.#linesCache?.path === path) return this.#linesCache.lines;
1143 const graph = this.graph;
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare1144 const { vis, visText, visWriter, visK } = this.#file(path);
init0Start the project1145 const lines: VisibleLine[] = new Array(vis.length);
capacity317A 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). - 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. - 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. On abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610: - 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. - read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s. What'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. Checks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.Compare1146 // Writer seqs come from the graph's own layout, so they're named with atomId, not checked by idOfSeq (abso 738):
1147 // on a stored graph its check read the atom count once a line, about 0.9 s of a warm draft-state on abso.
init0Start the project1148 for (let i = 0; i < vis.length; i++) {
1149 const n = vis[i]!;
capacity229Draft collisions without copying shared's atoms per pair (disk-first 2; abso Capacity). On typescript-rs, with one opened writer, collisions ran past 5 minutes with 2.5 million row reads; replay takes 5 s. - 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. - View.lines and buildLines use the texts the packed layout already holds, instead of reading each line's text again. - 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. On 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. Named 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.Compare1150 lines[i] = {
capacity317A 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). - 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. - 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. On abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610: - 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. - read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s. What'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. Checks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.Compare1151 id: visWriter && visK ? lineId(atomId(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),
capacity229Draft collisions without copying shared's atoms per pair (disk-first 2; abso Capacity). On typescript-rs, with one opened writer, collisions ran past 5 minutes with 2.5 million row reads; replay takes 5 s. - 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. - View.lines and buildLines use the texts the packed layout already holds, instead of reading each line's text again. - 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. On 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. Named 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.Compare1152 text: visText?.[i] ?? graph.textOf(n),
capacity317A 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). - 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. - 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. On abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610: - 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. - read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s. What'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. Checks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.Compare1153 atom: atomId(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
capacity229Draft collisions without copying shared's atoms per pair (disk-first 2; abso Capacity). On typescript-rs, with one opened writer, collisions ran past 5 minutes with 2.5 million row reads; replay takes 5 s. - 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. - View.lines and buildLines use the texts the packed layout already holds, instead of reading each line's text again. - 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. On 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. Named 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.Compare1154 };
init0Start the project1155 }
1156 this.#linesCache = { path, lines };
1157 return lines;
1160 /** The full linearized sequence of a file, tombstones included. */
1161 sequence(path: string): readonly SeqLine[] {
1162 if (this.#seqCache?.path === path) return this.#seqCache.seq;
1163 const graph = this.graph;
codex-capacity-chair110Keep current-file views and key scans from retaining historical stateCompare1164 const f = this.#file(path, true);
init0Start the project1165 const out: SeqLine[] = new Array(f.seq.length);
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare1166 // Ids and writers from the packed layout, and each text read only when asked (abso Capacity): callers walk a few
1167 // lines of a file's history, and reading every line's text was a row each on a stored graph.
1168 const { seqWriter, seqK } = f;
init0Start the project1169 for (let i = 0; i < f.seq.length; i++) {
1170 const n = f.seq[i]!;
1171 const by = f.deletedBy.get(i);
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare1172 const writer = seqWriter ? seqWriter[i]! : graph.writerSeqOf(n);
1173 let text: string | undefined;
init0Start the project1174 out[i] = {
capacity317A 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). - 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. - 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. On abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610: - 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. - read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s. What'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. Checks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.Compare1175 id: seqWriter && seqK ? lineId(atomId(writer), seqK[i]!) : graph.lineIdOf(n),
capacity232Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity). Collisions 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. - 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. - sequence() reads each line's text when it is first asked for. On 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. Named 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.Compare1176 get text() {
1177 text ??= graph.textOf(n);
1178 return text;
1179 },
capacity317A 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). - 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. - 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. On abso's Oct 14 tables, both named drafts' states are identical by hash (codex-prose-authorship-610: 71db868585a419a4). codex-prose-authorship-610: - 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. - read cold after the other draft: 12,688 statements and 4.1 s become 11,645 and 2.25 s. What'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. Checks: 1,450 tests pass, 0 fail, 2 skipped. tsc is clean and biome is clean.Compare1180 atom: atomId(writer),
1181 deletedBy: by ? by.map((s) => atomId(s)) : NONE,
init0Start the project1182 visible: by === undefined,
1183 };
1185 this.#seqCache = { path, seq: out };
1186 return out;
codex-capacity-chair138Find reason-warning neighbors without materializing file historyCompare1189 /** Two visible neighbours without retaining the file's historical sequence. */
1190 visibleNeighbours(path: string, line: LineId): LineId[] {
1191 const graph = this.graph;
1192 const target = graph.lineN(line);
1193 const start = graph.startCodeOf(path);
1194 if (target < 0 || start === undefined) return [];
1195 const scan = (nodes: Iterable<number>): LineId[] => {
1196 let previous: LineId | undefined;
1197 let found = false;
1198 for (const n of nodes) {
1199 if (n === target) {
1200 found = true;
1201 continue;
1203 let deleted = false;
1204 for (const seq of graph.eachDeleterSeqOf(n))
1205 if (this.#has(seq)) {
1206 deleted = true;
1207 break;
1209 if (deleted) continue;
1210 const id = graph.lineIdOf(n);
1211 if (found) return previous === undefined ? [id] : [previous, id];
1212 previous = id;
1214 return found && previous !== undefined ? [previous] : [];
1215 };
capacity205Disk-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.Compare1216 if (this.#scratchMoves())
codex-capacity-chair138Find reason-warning neighbors without materializing file historyCompare1217 return graph.withProjectionScratch((scratch) =>
1218 scan(scratchLayoutNodes(graph, (id) => this.#has(graph.atom(id).seq), scratch, graph.nodeOf(start))),
1219 );
1220 return scan(this.#layoutNodes(start));
init0Start the project1223 /** Index of a line in `sequence(path)`, or -1. */
1224 sequenceIndex(path: string, line: LineId): number {
codex-capacity-chair110Keep current-file views and key scans from retaining historical stateCompare1225 const f = this.#file(path, true);
init0Start the project1226 if (!f.seqIndex) {
1227 f.seqIndex = new Map();
1228 for (let i = 0; i < f.seq.length; i++) f.seqIndex.set(f.seq[i]!, i);
1230 return f.seqIndex.get(this.graph.lineN(line)) ?? -1;
1233 /** Index of a line in `lines(path)` (0-based visible line number), or -1 if not visible. */
1234 lineNumber(path: string, line: LineId): number {
capacity212Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export. - 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. - Draft files (overlaps.ts) go by number the same way. - An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this). - Draft collisions: - build the union view only when two drafts share a file; - work out each agent's touched files and its "shared now plus draft" view once; - find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history; - have the definition rule keep a draft's uses, and the newer work's definitions, across partners. - A stored list read in order reads its length once, not before every element. draft-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. On website's export (1,387 entries) the answers match Project.load: - status: 17 s to 4.5 s - where: over 60 s to 8.8 s - drafts: 14 s to 5.3 s - collisions: over 60 s to 54 s, measured under the profiler before the last two changesCompare1235 return this.lineNumberOf(path, this.graph.lineN(line));
1238 /** lineNumber by the line's number, with no lookup of its id. */
1239 lineNumberOf(path: string, n: number): number {
init0Start the project1240 const f = this.#file(path);
1241 if (!f.visIndex) {
1242 f.visIndex = new Map();
1243 for (let i = 0; i < f.vis.length; i++) f.visIndex.set(f.vis[i]!, i);
capacity212Draft reads on a stored writer (disk-first 2; abso Capacity): where, drafts, status and collisions on website's export. - 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. - Draft files (overlaps.ts) go by number the same way. - An agent's view takes its base's resolved moves when both hold the same atoms that move lines (View.shareMoves checks this). - Draft collisions: - build the union view only when two drafts share a file; - work out each agent's touched files and its "shared now plus draft" view once; - find claimants among the drafts from the drafts' own keys (collisions.ts claimantsAmong) instead of walking each key's history; - have the definition rule keep a draft's uses, and the newer work's definitions, across partners. - A stored list read in order reads its length once, not before every element. draft-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. On website's export (1,387 entries) the answers match Project.load: - status: 17 s to 4.5 s - where: over 60 s to 8.8 s - drafts: 14 s to 5.3 s - collisions: over 60 s to 54 s, measured under the profiler before the last two changesCompare1245 return f.visIndex.get(n) ?? -1;
1248 /** The seq of the atom that wrote each visible line, in order: lines() without ids or text. */
1249 visibleWriters(path: string): number[] {
1250 const graph = this.graph;
capacity231visibleWriters uses the writers the packed layout keeps (disk-first 2; abso Capacity). where 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). On typescript-rs adopted fresh, cold: where 39,000 reads to 20,000 and 6.5 s to 3.8 s, matching replay. Named 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.Compare1251 const { vis, visWriter } = this.#file(path);
1252 // The packed layout keeps them (abso Capacity): looking each up again read a page per few lines on a stored graph.
1253 if (visWriter) return Array.from(visWriter);
1254 return Array.from(vis, (n) => graph.writerSeqOf(n));
init0Start the project1255 }
1257 /** All projected text files, path -> text, in path order. Binary files are in `blobs()`. */
1258 files(): Record<string, string> {
1259 const out: Record<string, string> = {};
1260 for (const path of this.paths()) if (this.#file(path).attrs.blob === null) out[path] = this.text(path);
1261 return out;
1264 /** Binary files, path -> the SHA-256 of their bytes, in path order. */
1265 blobs(): Record<string, string> {
capacity233A view's blobs come from file attributes alone (disk-first 2; abso Capacity). EngineProject.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. A 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. On abso adopted fresh: the harness's first read (status, shared, paths) went from about 20 s to 3 s. New 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.Compare1266 // From attributes alone (abso Capacity): a file with a blob exists, so no file is laid out to find them. Going
1267 // through paths() laid out every file in the set, and shared() asks for blobs on every call.
init0Start the project1268 const out: Record<string, string> = {};
capacity233A view's blobs come from file attributes alone (disk-first 2; abso Capacity). EngineProject.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. A 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. On abso adopted fresh: the harness's first read (status, shared, paths) went from about 20 s to 3 s. New 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.Compare1269 const candidates = this.#stable ? [...this.graph.knownFiles()].sort() : this.#known;
1270 for (const path of candidates) {
1271 const blob = this.attrs(path).blob;
init0Start the project1272 if (blob !== null) out[path] = blob;
1274 return out;
1277 /**
codex-capacity-policy103Test deterministic replay and account view cache weightCompare1278 * About how many bytes of retained state this view costs (#46). This uses
1279 * approximate ownership costs for containers and wrappers, not V8 heap
1280 * measurements. Graph-owned strings and records count only as references.
1281 * This method only inspects already-created state: it does not lay out files,
1282 * populate lazy caches, enumerate the graph, or count temporary traversal
1283 * containers and shared empty singleton payloads as retained view state.
init0Start the project1284 */
capacity241The view cache counts a file layout two views share once (disk-first 2; abso Capacity). Testing 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. - 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)). - 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. On 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. Named 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.Compare1285 weight(seen?: Set<object>): number {
codex-capacity-policy103Test deterministic replay and account view cache weightCompare1286 let n = this.#in.byteLength;
codex-capacity-chair116Bound repeated indexed view membership lookupsCompare1287 n += 2 * ARRAY_HEADER_BYTES + this.#membershipSeq.byteLength + this.#membershipValue.byteLength;
codex-capacity-chair123Stream mover history when opening persisted viewsCompare1288 if (this.#movers) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#movers.length;
codex-capacity-policy103Test deterministic replay and account view cache weightCompare1289 n += MAP_HEADER_BYTES; // #files exists from construction.
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare1290 if (this.#stable) n += this.#stable.retainedBytes;
1291 else if (this.#set) n += OBJECT_BYTES + SET_ENTRY_BYTES * this.#set.size;
codex-capacity-policy103Test deterministic replay and account view cache weightCompare1292 if (this.#knownList) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#knownList.length;
1293 if (this.#relocs) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * this.#relocs.size;
1294 if (this.#relocsN) n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + OBJECT_BYTES) * this.#relocsN.size;
capacity216Moves 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. - 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. - 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. On abso's export (81,855 entries, 1,224 versions), one opened project, answers matching Project.load: - status: 104 s to 5.8 s (under the profiler) - drafts: over 60 s to 5.7 s - files at head: over 60 s to 1.2 s - files at 612: 54 s to 0.3 s version-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.Compare1295 n += MAP_ENTRY_BYTES * this.#picked.size;
capacity263The view cache trims the least recently used file layouts across its views before whole views (abso Capacity, issue 664). After 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. On 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. View 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.Compare1296 n += MAP_ENTRY_BYTES * this.#used.size;
codex-capacity-policy103Test deterministic replay and account view cache weightCompare1297 for (const f of this.#files.values()) {
1298 n += MAP_ENTRY_BYTES;
1299 if (f !== NO_FILE) {
capacity241The view cache counts a file layout two views share once (disk-first 2; abso Capacity). Testing 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. - 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)). - 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. On 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. Named 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.Compare1300 // A layout another view counted already (`seen`, across a cache's views) isn't counted again.
1301 if (!seen?.has(f)) n += layoutBytes(f);
1302 seen?.add(f);
codex-capacity-policy103Test deterministic replay and account view cache weightCompare1303 if (f.seqIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.seqIndex.size;
1304 if (f.visIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.visIndex.size;
1307 if (this.#linesCache)
1308 n += OBJECT_BYTES + REFERENCE_BYTES + ARRAY_HEADER_BYTES + 100 * this.#linesCache.lines.length;
1309 if (this.#seqCache) {
1310 n += OBJECT_BYTES + REFERENCE_BYTES + ARRAY_HEADER_BYTES + 120 * this.#seqCache.seq.length;
1311 for (const line of this.#seqCache.seq)
1312 if (line.deletedBy !== NONE) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * line.deletedBy.length;
1314 if (this.#textCache) n += OBJECT_BYTES + REFERENCE_BYTES + ARRAY_HEADER_BYTES + 2 * this.#textCache.text.length;
init0Start the project1315 return n;
codex-capacity-chair110Keep current-file views and key scans from retaining historical stateCompare1318 #file(path: string, complete = false): FileState {
init0Start the project1319 let state = this.#files.get(path);
codex-capacity-chair110Keep current-file views and key scans from retaining historical stateCompare1320 if (!state || (complete && !state.complete)) {
capacity235A draft's view takes its base view's layout of every file the draft doesn't touch (disk-first 2; abso Capacity). An 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. - 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. - 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. On 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. New 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.Compare1321 const shared = this.#filesFrom === undefined ? null : this.#sharedFiles();
1322 if (shared && !shared.except.has(path)) state = shared.from.#file(path, complete);
1323 else state = this.graph.hasAtomsIn(path) ? this.#layout(path, complete) : NO_FILE;
init0Start the project1324 this.#files.set(path, state);
capacity263The view cache trims the least recently used file layouts across its views before whole views (abso Capacity, issue 664). After 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. On 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. View 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.Compare1326 if (state !== NO_FILE) this.#used.set(path, ++fileUses);
init0Start the project1327 return state;
capacity263The view cache trims the least recently used file layouts across its views before whole views (abso Capacity, issue 664). After 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. On 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. View 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.Compare1328 }
1330 /** When each laid-out file was last used (fileUses). */
1331 readonly #used = new Map<string, number>();
1333 /**
1334 * Each laid-out file: its layout, when it was last used (a count shared by every view) and what it holds, for a
1335 * cache that trims the least recently used layouts across its views before whole views (views.ts, abso Capacity).
1336 */
capacity276A stored graph keeps files' decoded line histories between layouts (abso Capacity, issue 664): Graph.packedHistory, under 4 MB. Every 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. Side 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. Tests: 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.Compare1337 *laidOut(): IterableIterator<{
1338 path: string;
1339 layout: object;
1340 used: number;
1341 bytes: number;
1342 }> {
capacity263The view cache trims the least recently used file layouts across its views before whole views (abso Capacity, issue 664). After 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. On 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. View 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.Compare1343 for (const [path, f] of this.#files) {
1344 if (f === NO_FILE) continue;
1345 let bytes = 2 * MAP_ENTRY_BYTES + layoutBytes(f);
1346 if (f.seqIndex) bytes += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.seqIndex.size;
1347 if (f.visIndex) bytes += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.visIndex.size;
1348 yield { path, layout: f, used: this.#used.get(path) ?? 0, bytes };
1352 /** Let go of a file's layout: the next ask lays it out again, the same. */
1353 forget(path: string): void {
1354 this.#files.delete(path);
1355 this.#used.delete(path);
1356 if (this.#linesCache?.path === path) this.#linesCache = undefined;
1357 if (this.#seqCache?.path === path) this.#seqCache = undefined;
1358 if (this.#textCache?.path === path) this.#textCache = undefined;
init0Start the project1359 }
1362/** The files of a closed set, path -> text. */
1363export function project(graph: Graph, set: Iterable<AtomId>): Record<string, string> {
1364 return new View(graph, set).files();
1367/** Where a node sits in a file's sequence: the index just after it (0 for a start node). */
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare1368export function indexAfter(view: Pick<ReadView, "sequenceIndex">, path: string, node: NodeId): number {
init0Start the project1369 if (isStartNode(node)) return 0;
1370 const i = view.sequenceIndex(path, node);
1371 if (i < 0) throw new EngineError("not-in-view", `line ${node} is not in ${path} in this view`);
1372 return i + 1;