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 136 to 137

Compare

+11 −5 in 7 places
Lines 2–8 at 137 (were 2–7 at 136)
22// the codebase) are separate values; the graph only answers questions about
33// atoms and keeps indexes so those questions are cheap.
44
5+import { ChildCounts } from "./child-counts.ts";
56import {
67 atomId,
78 attrKey,
Lines 255–261 at 137 (were 254–259 at 136)
254255
255256export class Graph {
256257 readonly #storage?: GraphStateStorage;
258+ readonly #childCounts?: ChildCounts;
257259 #atoms: Atom[] = [];
258260 #lamport: number[] = [];
259261 // Lines, packed (#46): line n is the k-th line atom seq wrote, n = #lineBase[seq] + k. Each holds its
Lines 295–301 at 137 (were 293–298 at 136)
293295 }
294296 if (options.lists) this.#lists = options.lists;
295297 this.#storage = options.storage;
298+ if (options.storage) this.#childCounts = new ChildCounts(options.storage);
296299 if (options.storage) {
297300 const storage = options.storage;
298301 const numbers = (name: string): NumberIndex => storedNumbers(storage, name);
Lines 666–676 at 137 (were 663–672 at 136)
663666 *orderedChildrenN(code: number, after?: number): IterableIterator<number> {
664667 if (!this.#storage) throw new Error("ordered children require indexed storage");
665668 const index = new OrderedIndex(this.#storage, "ordered-children", String(code));
666− if (this.#storage.read("ordered-children", "format") !== 1)
669+ if (this.#storage.read("ordered-children", "format") !== 2)
667670 throw new Error("ordered children require fresh adoption");
668− const count = index.size;
669− if (count !== this.#runStartPages!.length(String(code))) throw new Error("ordered child index count mismatch");
671+ const count = code >= 0 ? this.#childCounts!.at(code, this.#lineTotal) : index.size;
672+ if ((code < 0 || count > 0) && (count !== index.size || count !== this.#runStartPages!.length(String(code))))
673+ throw new Error("ordered child index count mismatch");
670674 let implicit: number | undefined;
671675 if (
672676 code >= 0 &&
Lines 971–979 at 137 (were 967–975 at 136)
967971 }
968972
969973 #add(atom: Atom): void {
970− if (this.#storage && this.#storage.read("ordered-children", "format") !== 1) {
974+ if (this.#storage && this.#storage.read("ordered-children", "format") !== 2) {
971975 if (this.#atoms.length !== 0) throw new Error("ordered children require fresh adoption");
972− this.#storage.write("ordered-children", "format", 1);
976+ this.#storage.write("ordered-children", "format", 2);
973977 }
974978
975979 validateShape(atom);
Lines 1073–1079 at 137 (were 1069–1074 at 136)
10691073 const file = this.#pathOf(run.file);
10701074 let parent = isStartNode(run.parent) ? -1 - file : this.#lineN(run.parent);
10711075 const first = this.#lineTotal;
1076+ if (parent >= 0) this.#childCounts?.increment(parent, first);
10721077 if (this.#storage)
10731078 new OrderedIndex(this.#storage, "ordered-children", String(parent)).insert(
10741079 orderedChildKey({
Lines 1090–1096 at 137 (were 1085–1090 at 136)
10851090 else pushOne(this.#runStarts, parent, first);
10861091 for (let i = 0; i < run.lines.length; i++) {
10871092 const n = this.#lineTotal;
1093+ this.#childCounts?.append(n);
10881094 this.#lineAtom.push(seq);
10891095 this.#lineFile.push(file);
10901096 this.#lineParent.push(parent);
MCP
compare on this site's /mcp
CLI
abso diff 136 137 src/engine/graph.ts --json
JSON
/christopher/abso-core/compare/136..137?file=src%2Fengine%2Fgraph.ts&format=json