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 130 --json
JSON
/christopher/abso-core/versions/130?format=json

Stream paged child history into layout filtering

of shared·codex-capacity-chair·

Version 129 · Files at version 130

3 files, 73 lines added, 23 removed.

--- a/src/engine/graph.ts
+++ b/src/engine/graph.ts
@@ -324,7 +324,9 @@
324324 this.#resolversPages = storedLists<AtomId>(storage, "resolvers");
325325 this.#togetherPages = storedLists<TogetherLink>(storage, "together");
326326 this.#fileAtomPages = storedLists<AtomId>(storage, "file-atoms");
327− this.#runStarts = storedMap(storage, "run-starts");
327+ this.#runStartPages = storedLists<number>(storage, "run-starts", (key) =>
328+ JSON.stringify(["number", Number(key)]),
329+ );
328330 this.#relocationPages = storedLists<RelocationInfo>(storage, "relocations");
329331 this.#relocatedToPages = storedLists<RelocationInfo>(storage, "relocated-to");
330332 this.#relocatedToCodePages = storedLists<RelocationInfo>(storage, "relocated-to-code", (key) =>
@@ -441,6 +443,7 @@
441443 #fileAtomPages: ReturnType<typeof storedLists<AtomId>> | undefined;
442444 /** First lines of runs (their n), by the node they were written after: a line's n, or -1 - a path's index. */
443445 #runStarts: StateMap<number, number | number[]> = new Map();
446+ #runStartPages: ReturnType<typeof storedLists<number>> | undefined;
444447 /** 1 for the first line of a run whose atom deleted the line it hangs off: the run replaces it. */
445448 #replacing: NumberIndex = new Ints(true);
446449 #relocations: StateMap<LineId, RelocationInfo[]> = new Map();
@@ -612,18 +615,20 @@
612615 }
613616
614617 /** The lines (their n) written right after a node, as childrenOf, into `out`. */
615619 childrenN(code: number, out: number[]): void {
620+ for (const n of this.eachChildN(code)) out.push(n);
621+ }
622+ *eachChildN(code: number): IterableIterator<number> {
616623 if (
617624 code >= 0 &&
618625 code + 1 < this.#lineTotal &&
619626 this.#lineAtom.at(code + 1) === this.#lineAtom.at(code) &&
620627 this.#lineParent.at(code + 1) === code
621628 )
622− out.push(code + 1);
623− const starts = this.#runStarts.get(code);
624− if (starts === undefined) return;
625− if (Array.isArray(starts)) out.push(...starts);
626− else out.push(starts);
629+ yield code + 1;
630+ if (this.#runStartPages) yield* this.#runStartPages.values(String(code));
631+ else yield* listOf(this.#runStarts.get(code));
627632 }
628633
629634 replacesN(n: number): boolean {
@@ -770,21 +775,10 @@
770775 }
771776
772777 /** Lines written right after a node (not counting moves), in seq order. */
773779 childrenOf(node: NodeId): LineId[] {
774− const out: LineId[] = [];
775780 const code = this.#nodeCode(node);
776− if (code === undefined) return out;
777− // The next line of the same run hangs off this one.
778− if (
779− code >= 0 &&
780− code + 1 < this.#lineTotal &&
781− this.#lineAtom.at(code + 1) === this.#lineAtom.at(code) &&
782− this.#lineParent.at(code + 1) === code
783− ) {
784− out.push(this.#lineName(code + 1));
785− }
786− for (const n of listOf(this.#runStarts.get(code))) out.push(this.#lineName(n));
787− return out;
781+ return code === undefined ? [] : [...this.eachChildN(code)].map((n) => this.#lineName(n));
788782 }
789783
790784 /** Whether a line starts a run whose atom deleted the line it hangs off. */
@@ -1007,7 +1001,8 @@
10071001 const file = this.#pathOf(run.file);
10081002 let parent = isStartNode(run.parent) ? -1 - file : this.#lineN(run.parent);
10091003 const first = this.#lineTotal;
1010− pushOne(this.#runStarts, parent, first);
1004+ if (this.#runStartPages) this.#runStartPages.append(String(parent), first);
1005+ else pushOne(this.#runStarts, parent, first);
10111006 for (let i = 0; i < run.lines.length; i++) {
10121007 const n = this.#lineTotal;
10131008 this.#lineAtom.push(seq);
--- a/src/engine/test/state-source.test.ts
+++ b/src/engine/test/state-source.test.ts
@@ -362,3 +362,60 @@
362362 storage.db.close();
363363 }
364364});
366+test("child indexes stream bounded pages before filtering historical siblings", () => {
367+ class ObservedStorage extends SqlState {
368+ pageReads = 0;
369+ largestPage = 0;
370+ override read(collection: string, key: string): unknown {
371+ if (collection === "run-starts:pages") this.pageReads++;
372+ return super.read(collection, key);
373+ }
374+ override write(collection: string, key: string, value: unknown): void {
375+ if (collection === "run-starts:pages") {
376+ assert.ok(Array.isArray(value));
377+ this.largestPage = Math.max(this.largestPage, value.length);
378+ }
379+ super.write(collection, key, value);
380+ }
381+ }
382+ const storage = new ObservedStorage();
383+ try {
384+ const oracle = Repo.init({ "a.txt": "one\ntwo\n" });
385+ const draft = oracle.draft({ edits: [{ file: "a.txt", old: "one", new: "ONE" }] });
386+ const graph = new Graph({ storage });
387+ graph.add(oracle.graph.atom("a0"));
388+ for (let seq = 1; seq <= 513; seq++) {
389+ const atom = { ...draft, id: `a${seq}`, seq };
390+ graph.add(atom);
391+ oracle.graph.add(atom);
392+ }
393+ const reopened = new Graph({ storage });
394+ const parent = draft.inserts[0]!.parent;
395+ const code = reopened.codeOf(parent)!;
396+ storage.pageReads = 0;
397+ const iterator = reopened.eachChildN(code);
398+ const first = iterator.next().value!;
399+ assert.equal(first, reopened.lineN(oracle.graph.childrenOf(parent)[0]!));
400+ assert.ok(storage.pageReads <= 1);
401+ if (storage.pageReads === 0) {
402+ iterator.next();
403+ assert.equal(storage.pageReads, 1, "the implicit child needs no page; the next sibling needs one");
404+ }
405+ assert.deepEqual(reopened.childrenOf(parent), oracle.graph.childrenOf(parent));
406+ assert.deepEqual(
407+ reopened.childrenOf("a0.0"),
408+ oracle.graph.childrenOf("a0.0"),
409+ "implicit same-run child order is retained",
410+ );
411+ assert.equal(storage.largestPage, 256);
412+ const membership = new StableOverlaySet(["a0"]);
413+ assert.equal(new View(reopened, membership).text("a.txt"), "one\ntwo\n");
414+ assert.deepEqual(
415+ new View(reopened, membership).sequence("a.txt"),
416+ new View(oracle.graph, membership).sequence("a.txt"),
417+ );
418+ } finally {
419+ storage.db.close();
420+ }
421+});
--- a/src/engine/view.ts
+++ b/src/engine/view.ts
@@ -319,10 +319,8 @@
319319 #children(code: number): Child[] {
320320 const graph = this.graph;
321321 const relocs = this.#hasMoves ? this.#relocationsN() : undefined;
322− const ns: number[] = [];
323− graph.childrenN(code, ns);
324322 const out: Child[] = [];
325− for (const n of ns) {
323+ for (const n of graph.eachChildN(code)) {
326324 const seq = graph.writerSeqOf(n);
327325 if (!this.#has(seq) || relocs?.has(n)) continue;
328326 out.push({ n, replaces: graph.replacesN(n) ? 1 : 0, lamport: graph.lamportOfSeq(seq), seq, k: graph.kOf(n) });