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

Versions 229 to 230

Compare

+34 −9 in 9 places
Lines 69–76 at 230 (were 69–74 at 229)
6969 readonly deletedBy: ReadonlyMap<number, readonly number[]>;
7070 /** Its visible lines' text, when laid out from the file's packed history: null for a line too long to pack. */
7171 readonly visText?: readonly (string | null)[];
72+ /** Its visible lines' writers' seqs, when laid out from the file's packed history. */
73+ readonly visWriter?: Int32Array;
7274 /** Positions by n, built the first time they're asked for. */
7375 seqIndex?: Map<number, number>;
7476 visIndex?: Map<number, number>;
Lines 647–664 at 230 (were 645–651 at 229)
645647 const files = new Set<number>([-1 - start, ...(this.#movedInFrom().get(path) ?? [])]);
646648 const children = new Map<number, Child[]>();
647649 const texts = new Map<number, string | null>();
650+ const writers = new Map<number, number>();
648651 const deleters = new Map<number, number[]>();
652+ // Each atom's lamport once per layout: most lines share a few atoms, and a stored graph reads it from a page.
653+ const lamports = new Map<number, number>();
654+ const lamportOf = (seq: number): number => {
655+ let lamport = lamports.get(seq);
656+ if (lamport === undefined) {
657+ lamport = graph.lamportOfSeq(seq);
658+ lamports.set(seq, lamport);
659+ }
660+ return lamport;
661+ };
649662 for (const file of files) {
650663 const lineTexts = graph.packedTexts(file);
651664 for (const [n, parent, seq, k, replaces] of graph.packedLines(file)) {
Lines 666–682 at 230 (were 653–668 at 229)
653666 if (!this.#has(seq)) continue;
654667 const moved = relocs?.get(n);
655668 let at = parent;
656− let child: Child = { n, replaces, lamport: graph.lamportOfSeq(seq), seq, k };
669+ let child: Child = { n, replaces, lamport: lamportOf(seq), seq, k };
657670 if (moved) {
658671 const mover = graph.atom(moved.r.atom).seq;
659− child = { n, replaces: 0, lamport: graph.lamportOfSeq(mover), seq: mover, k: moved.r.k };
672+ child = { n, replaces: 0, lamport: lamportOf(mover), seq: mover, k: moved.r.k };
660673 at = moved.parent;
661674 }
662675 const list = children.get(at);
663676 if (list) list.push(child);
664677 else children.set(at, [child]);
665678 texts.set(n, text);
679+ writers.set(n, seq);
666680 }
667681 for (const [n, deleter] of graph.packedDeletes(file)) {
668682 if (!this.#has(deleter)) continue;
Lines 689–699 at 230 (were 675–684 at 229)
675689 }
676690 const order = (a: Child, b: Child) =>
677691 b.replaces - a.replaces || b.lamport - a.lamport || b.seq - a.seq || a.k - b.k;
678− const priority = (a: number, b: number) => graph.lamportOfSeq(a) - graph.lamportOfSeq(b) || a - b;
692+ const priority = (a: number, b: number) => lamportOf(a) - lamportOf(b) || a - b;
679693 const seq: number[] = [];
680694 const vis: number[] = [];
681695 const visText: (string | null)[] = [];
696+ const visWriter: number[] = [];
682697 const deletedBy = new Map<number, readonly number[]>();
683698 const stack: number[] = [];
684699 const push = (code: number) => {
Lines 711–730 at 230 (were 696–706 at 229)
696711 } else {
697712 vis.push(n);
698713 visText.push(texts.get(n) ?? null);
714+ visWriter.push(writers.get(n)!);
699715 }
700716 if (complete) seq.push(n);
701717 push(n);
702718 }
703− return { attrs, complete, seq: Int32Array.from(seq), vis: Int32Array.from(vis), deletedBy, visText };
719+ return {
720+ attrs,
721+ complete,
722+ seq: Int32Array.from(seq),
723+ vis: Int32Array.from(vis),
724+ deletedBy,
725+ visText,
726+ visWriter: Int32Array.from(visWriter),
727+ };
704728 }
705729
706730 #attributes(path: string): FileAttrs {
Lines 883–890 at 230 (were 859–866 at 229)
859883 /** Atom-building line handles; text is loaded only when requested. */
860884 buildLines(path: string): readonly VisibleLine[] {
861885 const graph = this.graph;
862− // Texts the packed layout already holds are not read again (abso Capacity).
863− const { vis, visText } = this.#file(path);
886+ // Texts and writers the packed layout already holds are not read again (abso Capacity).
887+ const { vis, visText, visWriter } = this.#file(path);
864888 const lines: VisibleLine[] = new Array(vis.length);
865889 for (let i = 0; i < vis.length; i++) {
866890 const n = vis[i]!;
Lines 895–901 at 230 (were 871–877 at 229)
871895 get text() {
872896 return packed ?? graph.textOf(n);
873897 },
874− atom: graph.idOfSeq(graph.writerSeqOf(n)),
898+ atom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
875899 };
876900 }
877901 return lines;
Lines 905–918 at 230 (were 881–894 at 229)
881905 lines(path: string): readonly VisibleLine[] {
882906 if (this.#linesCache?.path === path) return this.#linesCache.lines;
883907 const graph = this.graph;
884− const { vis, visText } = this.#file(path);
908+ const { vis, visText, visWriter } = this.#file(path);
885909 const lines: VisibleLine[] = new Array(vis.length);
886910 for (let i = 0; i < vis.length; i++) {
887911 const n = vis[i]!;
888912 lines[i] = {
889913 id: graph.lineIdOf(n),
890914 text: visText?.[i] ?? graph.textOf(n),
891− atom: graph.idOfSeq(graph.writerSeqOf(n)),
915+ atom: graph.idOfSeq(visWriter ? visWriter[i]! : graph.writerSeqOf(n)),
892916 };
893917 }
894918 this.#linesCache = { path, lines };
Lines 1049–1055 at 230 (were 1025–1030 at 229)
10251049 n += OBJECT_BYTES + OBJECT_BYTES + 2 * ARRAY_HEADER_BYTES;
10261050 n += f.seq.byteLength + f.vis.byteLength;
10271051 if (f.visText) for (const text of f.visText) n += REFERENCE_BYTES + 2 * (text?.length ?? 0);
1052+ if (f.visWriter) n += 4 * f.visWriter.length;
10281053 n += MAP_HEADER_BYTES + (MAP_ENTRY_BYTES + ARRAY_HEADER_BYTES) * f.deletedBy.size;
10291054 for (const deleters of f.deletedBy.values()) n += REFERENCE_BYTES * deleters.length;
10301055 if (f.seqIndex) n += MAP_HEADER_BYTES + MAP_ENTRY_BYTES * f.seqIndex.size;
MCP
compare on this site's /mcp
CLI
abso diff 229 230 src/engine/view.ts --json
JSON
/christopher/abso-core/compare/229..230?file=src%2Fengine%2Fview.ts&format=json