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

Page together relationship history for bounded traversal

of shared·codex-capacity-chair··Not checked

Version 128 · Files at version 129

3 files, 65 lines added, 5 removed.

--- a/src/engine/conflicts.ts
+++ b/src/engine/conflicts.ts
@@ -261,7 +261,7 @@
261261 const seen = new Set<string>();
262262 for (const a of [...changed].sort(bySeq(graph))) {
263263 if (a === atom.id) continue;
264− for (const link of graph.togetherLinks(a)) {
264+ for (const link of graph.eachTogetherLink(a)) {
265265 const b = link.other;
266266 if (b === atom.id || !set.has(b) || acknowledged.has(b)) continue;
267267 const tag = `${a} ${b}`;
--- a/src/engine/graph.ts
+++ b/src/engine/graph.ts
@@ -322,7 +322,7 @@
322322 this.#holdersPages = storedLists<AtomId>(storage, "holders", (key) => key);
323323 this.#dependentsPages = storedLists<AtomId>(storage, "dependents");
324324 this.#resolversPages = storedLists<AtomId>(storage, "resolvers");
325− this.#together = storedMap(storage, "together");
325+ this.#togetherPages = storedLists<TogetherLink>(storage, "together");
326326 this.#fileAtomPages = storedLists<AtomId>(storage, "file-atoms");
327327 this.#runStarts = storedMap(storage, "run-starts");
328328 this.#relocationPages = storedLists<RelocationInfo>(storage, "relocations");
@@ -436,6 +436,7 @@
436436 #resolvers: StateMap<AtomId, AtomId | AtomId[]> = new Map();
437437 #resolversPages: ReturnType<typeof storedLists<AtomId>> | undefined;
438438 #together: StateMap<AtomId, TogetherLink[]> = new Map();
439+ #togetherPages: ReturnType<typeof storedLists<TogetherLink>> | undefined;
439440 #fileAtoms: StateMap<string, AtomId[]> = new Map();
440441 #fileAtomPages: ReturnType<typeof storedLists<AtomId>> | undefined;
441442 /** First lines of runs (their n), by the node they were written after: a line's n, or -1 - a path's index. */
@@ -833,8 +834,12 @@
833834
834835 /** `together` reasons touching this atom, in either direction. */
835836 togetherLinks(id: AtomId): readonly TogetherLink[] {
836− return this.#together.get(id) ?? EMPTY;
837+ return [...this.eachTogetherLink(id)];
837838 }
839+ *eachTogetherLink(id: AtomId): IterableIterator<TogetherLink> {
840+ if (this.#togetherPages) yield* this.#togetherPages.values(id);
841+ else yield* this.#together.get(id) ?? EMPTY;
842+ }
838843
839844 /**
840845 * The atom plus everything it depends on, transitively. Computed on demand
@@ -1068,8 +1073,16 @@
10681073 }
10691074 for (const r of frozen.reasons) {
10701075 if (r.kind !== "together" || r.to === frozen.id) continue;
1071− pushIndex(this.#together, frozen.id, { other: r.to, text: r.text, from: frozen.id });
1072− pushIndex(this.#together, r.to, { other: frozen.id, text: r.text, from: frozen.id });
1077+ const forward = { other: r.to, text: r.text, from: frozen.id };
1078+ const reverse = { other: frozen.id, text: r.text, from: frozen.id };
1079+ if (this.#togetherPages) {
1080+ this.#togetherPages.append(frozen.id, forward);
1081+ this.#togetherPages.append(r.to, reverse);
1082+ } else {
1083+ pushIndex(this.#together, frozen.id, forward);
1084+ pushIndex(this.#together, r.to, reverse);
1085+ }
10731086 }
10741087 }
10751088
--- a/src/engine/test/state-source.test.ts
+++ b/src/engine/test/state-source.test.ts
@@ -315,3 +315,50 @@
315315 assert.equal(new Graph({ storage }).label("child")?.base, "a0");
316316 storage.db.close();
317317});
319+test("together links stream bounded pages in both directions after storage reopen", () => {
320+ class ObservedStorage extends SqlState {
321+ pageReads = 0;
322+ largestPage = 0;
323+ override read(collection: string, key: string): unknown {
324+ if (collection === "together:pages") this.pageReads++;
325+ return super.read(collection, key);
326+ }
327+ override write(collection: string, key: string, value: unknown): void {
328+ if (collection === "together:pages") {
329+ assert.ok(Array.isArray(value));
330+ this.largestPage = Math.max(this.largestPage, value.length);
331+ }
332+ super.write(collection, key, value);
333+ }
334+ }
335+ const storage = new ObservedStorage();
336+ try {
337+ const oracle = Repo.init({ "a.txt": "one\n" });
338+ const draft = oracle.draft({ edits: [{ file: "a.txt", old: "one", new: "ONE" }] });
339+ const graph = new Graph({ storage });
340+ graph.add(oracle.graph.atom("a0"));
341+ for (let seq = 1; seq <= 513; seq++) {
342+ const atom = {
343+ ...draft,
344+ id: `a${seq}`,
345+ seq,
346+ reasons: [{ to: "a0", kind: "together" as const, text: `reason ${seq}` }],
347+ };
348+ graph.add(atom);
349+ oracle.graph.add(atom);
350+ }
351+ const reopened = new Graph({ storage });
352+ storage.pageReads = 0;
353+ const iterator = reopened.eachTogetherLink("a0");
354+ assert.deepEqual(iterator.next().value, oracle.graph.togetherLinks("a0")[0]);
355+ assert.equal(storage.pageReads, 1);
356+ storage.pageReads = 0;
357+ assert.deepEqual(reopened.togetherLinks("a0"), oracle.graph.togetherLinks("a0"));
358+ assert.equal(storage.pageReads, 3);
359+ assert.deepEqual(reopened.togetherLinks("a513"), oracle.graph.togetherLinks("a513"));
360+ assert.equal(storage.largestPage, 256);
361+ } finally {
362+ storage.db.close();
363+ }
364+});