- MCP
- blame on this site's /mcp
- CLI
- abso blame src/engine/view.ts --version 109 --json
- JSON
- /christopher/abso-core/blame/src/engine/view.ts?version=109&format=json
552 linesFirst import 85% · codex-capacity-policy 8% · codex-capacity-chair 7%Last change codex-capacity-chair in version 109,
552 lines from 6 changes in 3 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";
13import { isStartNode } from "./keys.ts";
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare14import { StableSet } from "./state-source.ts";
16import { type AtomId, type AtomSet, EngineError, type LineId, type NodeId } from "./types.ts";
18/** A line in a file's full sequence, tombstones included. */
19export interface SeqLine {
20 readonly id: LineId;
21 readonly text: string;
22 /** The atom that wrote it. */
23 readonly atom: AtomId;
24 /** Atoms in the set that delete it, by seq. Empty when it is visible. */
25 readonly deletedBy: readonly AtomId[];
26 readonly visible: boolean;
27}
29/** A visible line of a projected file. */
30export interface VisibleLine {
31 readonly id: LineId;
32 readonly text: string;
33 readonly atom: AtomId;
34}
36/** A file's attributes in a view. */
37export interface FileAttrs {
38 /** Kept with no lines (an empty file). */
39 readonly exists: boolean;
40 readonly exec: boolean;
41 /** The target, when the file is a symbolic link. */
42 readonly link: string | null;
43 /** The SHA-256 of its bytes, when the file is binary. */
44 readonly blob: string | null;
45}
47const NO_ATTRS: FileAttrs = { exists: false, exec: false, link: null, blob: null };
48const NONE: readonly never[] = Object.freeze([]);
50interface FileState {
51 readonly attrs: FileAttrs;
52 /** The file's sequence, tombstones included: each line's n. */
53 readonly seq: Int32Array;
54 /** Its visible lines' n, in order. */
55 readonly vis: Int32Array;
56 /** For each deleted position in seq: the seqs of the atoms in the set that delete it, by priority. */
57 readonly deletedBy: ReadonlyMap<number, readonly number[]>;
58 /** Positions by n, built the first time they're asked for. */
59 seqIndex?: Map<number, number>;
60 visIndex?: Map<number, number>;
61}
63interface Child {
64 readonly n: number;
65 /** 1 when the child's atom deleted the parent (the child replaces it), else 0. A moved line is 0. */
66 readonly replaces: number;
67 readonly lamport: number;
68 readonly seq: number;
69 readonly k: number;
70}
72const EMPTY_INTS = new Int32Array(0);
73const NO_FILE: FileState = { attrs: NO_ATTRS, seq: EMPTY_INTS, vis: EMPTY_INTS, deletedBy: new Map() };
codex-capacity-policy103Test deterministic replay and account view cache weightCompare75// Approximate retained-container costs for View.weight(): reference slots,
76// object headers, and map/set entries. These are cache-budget units, not V8
77// heap measurements. Referenced Graph strings and records are not charged.
78const ARRAY_HEADER_BYTES = 24;
79const OBJECT_BYTES = 32;
80const MAP_HEADER_BYTES = 32;
81const MAP_ENTRY_BYTES = 40;
82const SET_ENTRY_BYTES = 32;
83const REFERENCE_BYTES = 8;
86 * The projection of a closed set. Construct once, then ask for files, lines
87 * and sequences. Throws `not-closed` if some atom's dependency is missing.
88 * Each file is laid out the first time it is asked for, so a view of a large
89 * set costs little until files are read.
90 */
91export class View {
92 readonly graph: Graph;
93 /** 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 adoptionCompare94 #set: AtomSet | undefined;
95 readonly #stable: StableSet<AtomId> | undefined;
97 /** Every file the set wrote in, sorted; worked out the first time it's asked for. */
98 #knownList: string[] | undefined;
99 /** 1 for each atom (by seq) in the set. */
100 #in: Uint8Array;
101 /** Atoms in the set that move lines. */
102 #movers: AtomId[];
103 /** Each moved line's relocation that counts in this set; built on first use. */
104 #relocs: Map<LineId, RelocationInfo> | undefined;
105 /** The same, by n, with the new parent's code. */
106 #relocsN: Map<number, { readonly r: RelocationInfo; readonly parent: number }> | undefined;
107 #fileOf = new Map<number, string>();
108 /** The latest records asked for: one file's lines, one file's sequence, one file's text. */
109 #linesCache: { path: string; lines: readonly VisibleLine[] } | undefined;
110 #seqCache: { path: string; seq: readonly SeqLine[] } | undefined;
111 #textCache: { path: string; text: string } | undefined;
113 constructor(graph: Graph, set: Iterable<AtomId>) {
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare114 this.graph = graph;
115 if (set instanceof StableSet) {
116 this.#stable = set;
117 this.#set = set;
118 this.#in = new Uint8Array(0);
119 for (const id of set) {
120 const atom = graph.atom(id);
121 for (const dependency of atom.deps) {
122 graph.atom(dependency);
123 if (!set.has(dependency))
124 throw new EngineError("not-closed", `set is not closed: ${id} depends on ${dependency}`);
125 }
126 }
127 this.#movers = graph.movers().filter((id) => set.has(id));
128 this.#relocs = this.#movers.length === 0 ? new Map() : undefined;
129 this.#relocsN = this.#movers.length === 0 ? new Map() : undefined;
130 return;
131 }
133 for (const id of set) {
134 const atom = graph.atom(id);
135 inSet[atom.seq] = 1;
136 }
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare137 // Validate one atom at a time. Keeping all decoded atoms here defeats
138 // storage-backed Graph reads even though the view only needs membership.
139 for (let seq = 0; seq < inSet.length; seq++) {
140 if (inSet[seq] !== 1) continue;
141 const atom = graph.atom(graph.idOfSeq(seq));
143 if (inSet[graph.atom(d).seq] !== 1)
144 throw new EngineError("not-closed", `set is not closed: ${atom.id} depends on ${d}`);
145 }
146 }
147 this.graph = graph;
148 this.#in = inSet;
149 this.#movers = graph.movers().filter((id) => inSet[graph.atom(id).seq] === 1);
150 this.#relocs = this.#movers.length === 0 ? new Map() : undefined;
151 this.#relocsN = this.#movers.length === 0 ? new Map() : undefined;
152 }
154 /** The set of atoms this view projects. */
155 get set(): AtomSet {
156 if (!this.#set) {
157 const out = new Set<AtomId>();
158 for (let seq = 0; seq < this.#in.length; seq++) if (this.#in[seq] === 1) out.add(this.graph.idOfSeq(seq));
159 this.#set = out;
160 }
161 return this.#set;
162 }
164 /** Whether the atom with this seq is in the set. */
165 #has(seq: number): boolean {
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare166 if (this.#stable) return this.#stable.has(this.graph.idOfSeq(seq));
168 }
170 /**
171 * The relocation that counts for each moved line: the newest (by priority)
172 * in the set. Two moves made apart can loop lines into each other, so no
173 * start node reaches them; then the oldest relocation on the loop is
174 * ignored, and the next newest of that line counts, until none loop.
175 */
176 #relocations(): Map<LineId, RelocationInfo> {
177 if (this.#relocs) return this.#relocs;
178 const graph = this.graph;
179 const stronger = (a: RelocationInfo, b: RelocationInfo): boolean => graph.comparePriority(a.atom, b.atom) > 0;
180 const ignored = new Set<RelocationInfo>();
181 const pick = (line: LineId): RelocationInfo | undefined => {
182 let best: RelocationInfo | undefined;
183 for (const r of graph.relocationsOf(line)) {
184 if (this.#has(graph.atom(r.atom).seq) && !ignored.has(r) && (!best || stronger(r, best))) best = r;
185 }
186 return best;
187 };
188 const relocs = new Map<LineId, RelocationInfo>();
189 for (const id of this.#movers) {
190 for (const m of graph.atom(id).moves!) {
191 if (!relocs.has(m.line)) relocs.set(m.line, pick(m.line)!);
192 }
193 }
194 const parentOf = (line: LineId): NodeId => relocs.get(line)?.parent ?? graph.lineParent(line)!;
195 const reaches = new Set<LineId>();
196 for (const line of [...relocs.keys()]) {
197 for (;;) {
198 const path: LineId[] = [];
199 const onPath = new Map<LineId, number>();
200 let cur: NodeId = line;
201 let loopAt = -1;
202 while (!isStartNode(cur) && !reaches.has(cur)) {
203 const at = onPath.get(cur);
204 if (at !== undefined) {
205 loopAt = at;
206 break;
207 }
208 onPath.set(cur, path.length);
209 path.push(cur);
210 cur = parentOf(cur);
211 }
212 if (loopAt < 0) {
213 for (const l of path) reaches.add(l);
214 break;
215 }
216 let weakest: RelocationInfo | undefined;
217 for (const l of path.slice(loopAt)) {
218 const r = relocs.get(l);
219 if (r && (!weakest || stronger(weakest, r))) weakest = r;
220 }
221 ignored.add(weakest!);
222 const next = pick(weakest!.line);
223 if (next) relocs.set(weakest!.line, next);
224 else relocs.delete(weakest!.line);
225 }
226 }
227 this.#relocs = relocs;
228 return relocs;
229 }
231 /** The relocations by n, with each new parent's code. */
232 #relocationsN(): Map<number, { readonly r: RelocationInfo; readonly parent: number }> {
233 if (this.#relocsN) return this.#relocsN;
234 const out = new Map<number, { readonly r: RelocationInfo; readonly parent: number }>();
235 for (const [line, r] of this.#relocations())
236 out.set(this.graph.lineN(line), { r, parent: this.graph.codeOf(r.parent)! });
237 this.#relocsN = out;
238 return out;
239 }
241 /** The node a line hangs off in this set: where it was written, or where a move put it. */
242 parentOf(line: LineId): NodeId {
243 const r = this.#movers.length === 0 ? undefined : this.#relocations().get(line);
244 if (r) return r.parent;
245 const parent = this.graph.lineParent(line);
246 if (parent === undefined) throw new EngineError("unknown-line", `no line ${line}`);
247 return parent;
248 }
250 /** Whether any atom in the set moves lines. */
251 hasMoves(): boolean {
252 return this.#movers.length > 0;
253 }
255 /** The file a line is in, in this set: the one its chain of parents reaches. */
256 fileOf(line: LineId): string {
257 const n = this.graph.lineN(line);
258 if (n < 0) throw new EngineError("unknown-line", `no line ${line}`);
259 return this.#fileOfN(n);
260 }
262 #fileOfN(n: number): string {
263 const graph = this.graph;
264 if (this.#movers.length === 0) return graph.writtenIn(n);
265 const relocs = this.#relocationsN();
266 const path: number[] = [];
267 let cur = n;
268 let file: string | undefined;
269 while (file === undefined) {
270 if (cur < 0) file = graph.nodeOf(cur).slice(1);
271 else {
272 file = this.#fileOf.get(cur);
273 if (file === undefined) {
274 path.push(cur);
275 cur = relocs.get(cur)?.parent ?? graph.parentCodeOf(cur);
276 }
277 }
278 }
279 for (const l of path) this.#fileOf.set(l, file);
280 return file;
281 }
283 /** The lines hanging off a node in this set, in layout order. */
284 #children(code: number): Child[] {
285 const graph = this.graph;
286 const relocs = this.#movers.length === 0 ? undefined : this.#relocationsN();
287 const ns: number[] = [];
288 graph.childrenN(code, ns);
289 const out: Child[] = [];
290 for (const n of ns) {
291 const seq = graph.writerSeqOf(n);
292 if (!this.#has(seq) || relocs?.has(n)) continue;
293 out.push({ n, replaces: graph.replacesN(n) ? 1 : 0, lamport: graph.lamportOfSeq(seq), seq, k: graph.kOf(n) });
294 }
295 if (relocs) {
296 for (const r of graph.relocatedToCode(code)) {
297 const n = graph.lineN(r.line);
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare298 const selected = relocs.get(n)?.r;
299 if (!selected || selected.atom !== r.atom || selected.k !== r.k) continue;
301 out.push({ n, replaces: 0, lamport: graph.lamportOfSeq(seq), seq, k: r.k });
302 }
303 }
304 // A line's replacements (runs of atoms that deleted it) first, then the
305 // rest; each group in descending priority (lamport, then seq); lines of
306 // one atom keep k order. A replacement already outranks every insertion
307 // after the line that reads it (it depends on them, or conflicts with
308 // them); the grouping also puts it above a `before` insertion, which
309 // doesn't read the line above, so the new text lands in the replaced
310 // line's place. A moved line ranks like an insertion by the moving atom.
311 if (out.length > 1)
312 out.sort((a, b) => b.replaces - a.replaces || b.lamport - a.lamport || b.seq - a.seq || a.k - b.k);
313 return out;
314 }
316 /** Lay out one file: its line tree from the set's atoms, linearized. */
317 #layout(path: string): FileState {
318 const graph = this.graph;
319 // For each attribute, the highest-priority setter in the set wins.
320 const setters = new Map<string, { id: AtomId; value: string | null }>();
321 for (const id of graph.atomsIn(path)) {
322 if (!this.#has(graph.atom(id).seq)) continue;
323 for (const a of graph.atom(id).attrs ?? []) {
324 if (a.file !== path) continue;
325 const best = setters.get(a.name);
326 if (!best || graph.comparePriority(best.id, id) < 0) setters.set(a.name, { id, value: a.value });
327 }
328 }
330 const seq: number[] = [];
331 const vis: number[] = [];
332 const deletedBy = new Map<number, readonly number[]>();
333 // Depth-first, iteratively (a file of n lines can be a chain n deep).
334 const stack: number[] = [];
335 const pushChildren = (code: number): void => {
336 const list = this.#children(code);
337 for (let i = list.length - 1; i >= 0; i--) stack.push(list[i]!.n);
338 };
339 const start = graph.startCodeOf(path);
340 if (start !== undefined) pushChildren(start);
341 const priority = (a: number, b: number) => graph.lamportOfSeq(a) - graph.lamportOfSeq(b) || a - b;
342 while (stack.length > 0) {
343 const n = stack.pop()!;
344 const deleters = graph.deleterSeqsOf(n);
345 const by = deleters.length === 0 ? NONE : deleters.filter((d) => this.#has(d));
346 if (by.length > 0) deletedBy.set(seq.length, by.length > 1 ? [...by].sort(priority) : by);
347 else vis.push(n);
348 seq.push(n);
349 pushChildren(n);
350 }
351 const attrs: FileAttrs = {
352 exists: setters.get("exists")?.value === "1",
353 exec: setters.get("exec")?.value === "1",
354 link: setters.get("link")?.value ?? null,
355 blob: setters.get("blob")?.value ?? null,
356 };
357 return { attrs, seq: Int32Array.from(seq), vis: Int32Array.from(vis), deletedBy };
358 }
360 get #known(): string[] {
361 if (!this.#knownList) {
362 const known = new Set<string>();
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare363 if (this.#stable) {
364 for (const id of this.#stable) for (const file of this.graph.filesOf(id)) known.add(file);
365 } else {
366 for (let seq = 0; seq < this.#in.length; seq++)
367 if (this.#in[seq] === 1) for (const file of this.graph.filesOf(this.graph.idOfSeq(seq))) known.add(file);
368 }
370 }
371 return this.#knownList;
372 }
374 /** Files with at least one visible line, sorted. */
375 paths(): string[] {
376 return this.#known.filter((p) => this.hasFile(p));
377 }
379 /** Every file the set has ever written a line in, including fully deleted ones. */
380 knownPaths(): string[] {
381 return [...this.#known];
382 }
384 /** Whether the file exists in this projection (has a visible line). */
385 hasFile(path: string): boolean {
386 const f = this.#file(path);
387 return f.vis.length > 0 || f.attrs.exists || f.attrs.link !== null || f.attrs.blob !== null;
388 }
390 /** A file's attributes: kept while empty, executable, a link's target. */
391 attrs(path: string): FileAttrs {
392 return this.#file(path).attrs;
393 }
395 /** The projected text of a file ("" if it has no visible lines). */
396 text(path: string): string {
397 if (this.#textCache?.path === path) return this.#textCache.text;
398 const vis = this.#file(path).vis;
399 const lines: string[] = new Array(vis.length);
400 for (let i = 0; i < vis.length; i++) lines[i] = this.graph.textOf(vis[i]!);
401 const text = joinLines(lines);
402 this.#textCache = { path, text };
403 return text;
404 }
406 /** Whether a file reads the same here and in `other` (of the same graph), compared line by line without joining either (#46). */
407 sameText(path: string, other: View): boolean {
408 const a = this.#file(path).vis;
409 const b = other.#file(path).vis;
410 if (a.length !== b.length) return false;
411 for (let i = 0; i < a.length; i++)
412 if (a[i] !== b[i] && this.graph.textOf(a[i]!) !== this.graph.textOf(b[i]!)) return false;
413 return true;
414 }
416 /** Visible lines with their ids. */
417 lines(path: string): readonly VisibleLine[] {
418 if (this.#linesCache?.path === path) return this.#linesCache.lines;
419 const graph = this.graph;
420 const vis = this.#file(path).vis;
421 const lines: VisibleLine[] = new Array(vis.length);
422 for (let i = 0; i < vis.length; i++) {
423 const n = vis[i]!;
424 lines[i] = { id: graph.lineIdOf(n), text: graph.textOf(n), atom: graph.idOfSeq(graph.writerSeqOf(n)) };
425 }
426 this.#linesCache = { path, lines };
427 return lines;
428 }
430 /** The full linearized sequence of a file, tombstones included. */
431 sequence(path: string): readonly SeqLine[] {
432 if (this.#seqCache?.path === path) return this.#seqCache.seq;
433 const graph = this.graph;
434 const f = this.#file(path);
435 const out: SeqLine[] = new Array(f.seq.length);
436 for (let i = 0; i < f.seq.length; i++) {
437 const n = f.seq[i]!;
438 const by = f.deletedBy.get(i);
439 out[i] = {
440 id: graph.lineIdOf(n),
441 text: graph.textOf(n),
442 atom: graph.idOfSeq(graph.writerSeqOf(n)),
443 deletedBy: by ? by.map((s) => graph.idOfSeq(s)) : NONE,
444 visible: by === undefined,
445 };
446 }
447 this.#seqCache = { path, seq: out };
448 return out;
449 }
451 /** Index of a line in `sequence(path)`, or -1. */
452 sequenceIndex(path: string, line: LineId): number {
453 const f = this.#file(path);
454 if (!f.seqIndex) {
455 f.seqIndex = new Map();
456 for (let i = 0; i < f.seq.length; i++) f.seqIndex.set(f.seq[i]!, i);
457 }
458 return f.seqIndex.get(this.graph.lineN(line)) ?? -1;
459 }
461 /** Index of a line in `lines(path)` (0-based visible line number), or -1 if not visible. */
462 lineNumber(path: string, line: LineId): number {
463 const f = this.#file(path);
464 if (!f.visIndex) {
465 f.visIndex = new Map();
466 for (let i = 0; i < f.vis.length; i++) f.visIndex.set(f.vis[i]!, i);
467 }
468 return f.visIndex.get(this.graph.lineN(line)) ?? -1;
469 }
471 /** All projected text files, path -> text, in path order. Binary files are in `blobs()`. */
472 files(): Record<string, string> {
473 const out: Record<string, string> = {};
474 for (const path of this.paths()) if (this.#file(path).attrs.blob === null) out[path] = this.text(path);
475 return out;
476 }
478 /** Binary files, path -> the SHA-256 of their bytes, in path order. */
479 blobs(): Record<string, string> {
480 const out: Record<string, string> = {};
481 for (const path of this.paths()) {
482 const blob = this.#file(path).attrs.blob;
483 if (blob !== null) out[path] = blob;
484 }
485 return out;
486 }
488 /**
codex-capacity-policy103Test deterministic replay and account view cache weightCompare489 * About how many bytes of retained state this view costs (#46). This uses
490 * approximate ownership costs for containers and wrappers, not V8 heap
491 * measurements. Graph-owned strings and records count only as references.
492 * This method only inspects already-created state: it does not lay out files,
493 * populate lazy caches, enumerate the graph, or count temporary traversal
494 * containers and shared empty singleton payloads as retained view state.
496 weight(): number {
codex-capacity-policy103Test deterministic replay and account view cache weightCompare497 let n = this.#in.byteLength;
498 n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#movers.length;
499 n += MAP_HEADER_BYTES; // #files exists from construction.
500 n += MAP_HEADER_BYTES; // #fileOf exists from construction.
codex-capacity-chair109Add opt-in persistent writer state, checked reopen and bounded adoptionCompare501 if (this.#stable) n += this.#stable.retainedBytes;
502 else if (this.#set) n += OBJECT_BYTES + SET_ENTRY_BYTES * this.#set.size;
codex-capacity-policy103Test deterministic replay and account view cache weightCompare503 if (this.#knownList) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * this.#knownList.length;
504 if (this.#relocs) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * this.#relocs.size;
505 if (this.#relocsN) n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + OBJECT_BYTES) * this.#relocsN.size;
506 n += MAP_ENTRY_BYTES * this.#fileOf.size;
507 for (const f of this.#files.values()) {
508 n += MAP_ENTRY_BYTES;
509 if (f !== NO_FILE) {
510 // FileState and FileAttrs are per laid-out file; typed-array
511 // headers are separate from their payload byte lengths below.
512 n += OBJECT_BYTES + OBJECT_BYTES + 2 * ARRAY_HEADER_BYTES;
513 n += f.seq.byteLength + f.vis.byteLength;
514 n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + ARRAY_HEADER_BYTES) * f.deletedBy.size;
515 for (const deleters of f.deletedBy.values()) n += REFERENCE_BYTES * deleters.length;
516 if (f.seqIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.seqIndex.size;
517 if (f.visIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.visIndex.size;
518 }
519 }
520 if (this.#linesCache)
521 n += OBJECT_BYTES + REFERENCE_BYTES + ARRAY_HEADER_BYTES + 100 * this.#linesCache.lines.length;
522 if (this.#seqCache) {
523 n += OBJECT_BYTES + REFERENCE_BYTES + ARRAY_HEADER_BYTES + 120 * this.#seqCache.seq.length;
524 for (const line of this.#seqCache.seq)
525 if (line.deletedBy !== NONE) n += ARRAY_HEADER_BYTES + REFERENCE_BYTES * line.deletedBy.length;
526 }
527 if (this.#textCache) n += OBJECT_BYTES + REFERENCE_BYTES + ARRAY_HEADER_BYTES + 2 * this.#textCache.text.length;
529 }
531 #file(path: string): FileState {
532 let state = this.#files.get(path);
533 if (!state) {
534 state = this.graph.atomsIn(path).length === 0 ? NO_FILE : this.#layout(path);
535 this.#files.set(path, state);
536 }
537 return state;
538 }
539}
541/** The files of a closed set, path -> text. */
542export function project(graph: Graph, set: Iterable<AtomId>): Record<string, string> {
543 return new View(graph, set).files();
544}
546/** Where a node sits in a file's sequence: the index just after it (0 for a start node). */
547export function indexAfter(view: View, path: string, node: NodeId): number {
548 if (isStartNode(node)) return 0;
549 const i = view.sequenceIndex(path, node);
550 if (i < 0) throw new EngineError("not-in-view", `line ${node} is not in ${path} in this view`);
551 return i + 1;
552}