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
show on this site's /mcp
CLI
abso show 232 --json
JSON
/christopher/abso-core/versions/232?format=json

Line ids and writers from the packed layout, and a sequence's text read only when used (disk-first 2; abso Capacity).

of shared·capacity··Not checked

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.

Version 231 · Files at version 232

1 file, 37 lines added, 9 removed.

--- a/src/engine/view.ts
+++ b/src/engine/view.ts
@@ -10,7 +10,7 @@
1010// made when a caller asks for them, and the latest asked for is kept.
1111
1212import type { Graph, RelocationInfo } from "./graph.ts";
13−import { isStartNode, seqOf } from "./keys.ts";
13+import { isStartNode, lineId, seqOf } from "./keys.ts";
1414import { resolveScratchMoves, scratchLayoutNodes } from "./relocation-scratch.ts";
1515import { isClosedSet, StableSet } from "./state-source.ts";
1616import { joinLines } from "./text.ts";
@@ -71,6 +71,11 @@
7171 readonly visText?: readonly (string | null)[];
7272 /** Its visible lines' writers' seqs, when laid out from the file's packed history. */
7373 readonly visWriter?: Int32Array;
74+ /** Its visible lines' places in their writers (a line id's k), when laid out from packed history. */
75+ readonly visK?: Int32Array;
76+ /** The same for every line of seq, when complete and laid out from packed history. */
77+ readonly seqWriter?: Int32Array;
78+ readonly seqK?: Int32Array;
7479 /** Positions by n, built the first time they're asked for. */
7580 seqIndex?: Map<number, number>;
7681 visIndex?: Map<number, number>;
@@ -648,6 +653,7 @@
648653 const children = new Map<number, Child[]>();
649654 const texts = new Map<number, string | null>();
650655 const writers = new Map<number, number>();
656+ const places = new Map<number, number>();
651657 const deleters = new Map<number, number[]>();
652658 // Each atom's lamport once per layout: most lines share a few atoms, and a stored graph reads it from a page.
653659 const lamports = new Map<number, number>();
@@ -677,6 +683,7 @@
677683 else children.set(at, [child]);
678684 texts.set(n, text);
679685 writers.set(n, seq);
686+ places.set(n, k);
680687 }
681688 for (const [n, deleter] of graph.packedDeletes(file)) {
682689 if (!this.#has(deleter)) continue;
@@ -694,6 +701,9 @@
694701 const vis: number[] = [];
695702 const visText: (string | null)[] = [];
696703 const visWriter: number[] = [];
704+ const visK: number[] = [];
705+ const seqWriter: number[] = [];
706+ const seqK: number[] = [];
697707 const deletedBy = new Map<number, readonly number[]>();
698708 const stack: number[] = [];
699709 const push = (code: number) => {
@@ -712,8 +722,13 @@
712722 vis.push(n);
713723 visText.push(texts.get(n) ?? null);
714724 visWriter.push(writers.get(n)!);
725+ visK.push(places.get(n)!);
715726 }
716− if (complete) seq.push(n);
727+ if (complete) {
728+ seq.push(n);
729+ seqWriter.push(writers.get(n)!);
730+ seqK.push(places.get(n)!);
731+ }
717732 push(n);
718733 }
719734 return {
@@ -724,6 +739,8 @@
724739 deletedBy,
725740 visText,
726741 visWriter: Int32Array.from(visWriter),
742+ visK: Int32Array.from(visK),
743+ ...(complete ? { seqWriter: Int32Array.from(seqWriter), seqK: Int32Array.from(seqK) } : {}),
727744 };
728745 }
729746
@@ -884,13 +901,13 @@
884901 buildLines(path: string): readonly VisibleLine[] {
885902 const graph = this.graph;
886903 // Texts and writers the packed layout already holds are not read again (abso Capacity).
887− const { vis, visText, visWriter } = this.#file(path);
904+ const { vis, visText, visWriter, visK } = this.#file(path);
888905 const lines: VisibleLine[] = new Array(vis.length);
889906 for (let i = 0; i < vis.length; i++) {
890907 const n = vis[i]!;
891908 const packed = visText?.[i];
892909 lines[i] = {
893− id: graph.lineIdOf(n),
910+ id: visWriter && visK ? lineId(graph.idOfSeq(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),
894911 textChunks: () => graph.textChunks(n),
895912 get text() {
896913 return packed ?? graph.textOf(n);
@@ -905,12 +922,12 @@
905922 lines(path: string): readonly VisibleLine[] {
906923 if (this.#linesCache?.path === path) return this.#linesCache.lines;
907924 const graph = this.graph;
908− const { vis, visText, visWriter } = this.#file(path);
925+ const { vis, visText, visWriter, visK } = this.#file(path);
909926 const lines: VisibleLine[] = new Array(vis.length);
910927 for (let i = 0; i < vis.length; i++) {
911928 const n = vis[i]!;
912929 lines[i] = {
913− id: graph.lineIdOf(n),
930+ id: visWriter && visK ? lineId(graph.idOfSeq(visWriter[i]!), visK[i]!) : graph.lineIdOf(n),
914931 text: visText?.[i] ?? graph.textOf(n),
915932 atom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
916933 };
@@ -925,13 +942,21 @@
925942 const graph = this.graph;
926943 const f = this.#file(path, true);
927944 const out: SeqLine[] = new Array(f.seq.length);
945+ // Ids and writers from the packed layout, and each text read only when asked (abso Capacity): callers walk a few
946+ // lines of a file's history, and reading every line's text was a row each on a stored graph.
947+ const { seqWriter, seqK } = f;
928948 for (let i = 0; i < f.seq.length; i++) {
929949 const n = f.seq[i]!;
930950 const by = f.deletedBy.get(i);
951+ const writer = seqWriter ? seqWriter[i]! : graph.writerSeqOf(n);
952+ let text: string | undefined;
931953 out[i] = {
932− id: graph.lineIdOf(n),
933− text: graph.textOf(n),
934− atom: graph.idOfSeq(graph.writerSeqOf(n)),
954+ id: seqWriter && seqK ? lineId(graph.idOfSeq(writer), seqK[i]!) : graph.lineIdOf(n),
955+ get text() {
956+ text ??= graph.textOf(n);
957+ return text;
958+ },
959+ atom: graph.idOfSeq(writer),
935960 deletedBy: by ? by.map((s) => graph.idOfSeq(s)) : NONE,
936961 visible: by === undefined,
937962 };
@@ -1053,6 +1078,9 @@
10531078 n += f.seq.byteLength + f.vis.byteLength;
10541079 if (f.visText) for (const text of f.visText) n += REFERENCE_BYTES + 2 * (text?.length ?? 0);
10551080 if (f.visWriter) n += 4 * f.visWriter.length;
1081+ if (f.visK) n += 4 * f.visK.length;
1082+ if (f.seqWriter) n += 4 * f.seqWriter.length;
1083+ if (f.seqK) n += 4 * f.seqK.length;
10561084 n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + ARRAY_HEADER_BYTES) * f.deletedBy.size;
10571085 for (const deleters of f.deletedBy.values()) n += REFERENCE_BYTES * deleters.length;
10581086 if (f.seqIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.seqIndex.size;