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

Avoid retaining deleted historical paths in indexed current views

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

Version 117 · Files at version 118

4 files, 31 lines added, 0 removed.

--- a/src/engine/graph.ts
+++ b/src/engine/graph.ts
@@ -705,6 +705,11 @@
705705 return this.#fileAtoms.get(file) ?? EMPTY;
706706 }
707707
708+ /** Unique historical file paths, streamed without collecting their names. */
709+ *knownFiles(): IterableIterator<string> {
710+ yield* this.#fileAtoms.keys();
711+ }
708713 /**
709714 * The files an atom inserts, deletes or moves lines in, or sets attributes
710715 * of, sorted. For lines, the file each was written in (or, for a move to a
--- a/src/engine/state-source.ts
+++ b/src/engine/state-source.ts
@@ -251,6 +251,7 @@
251251}
252252
253253export interface StateMap<K, V> {
254+ keys(): IterableIterator<K>;
254255 get(key: K): V | undefined;
255256 set(key: K, value: V): StateMap<K, V>;
256257 has(key: K): boolean;
@@ -262,6 +263,9 @@
262263export function storedMap<K extends string | number, V>(storage: GraphStateStorage, name: string): StateMap<K, V> {
263264 const keyOf = (key: K) => JSON.stringify([typeof key, key]);
264265 const map: StateMap<K, V> = {
266+ *keys() {
267+ for (const [key] of storage.entries(name)) yield (JSON.parse(key) as [string, K])[1];
268+ },
265269 get: (key) => storage.read(name, keyOf(key)) as V | undefined,
266270 has: (key) => storage.read(name, keyOf(key)) !== undefined,
267271 set(key, value) {
--- a/src/engine/test/view.test.ts
+++ b/src/engine/test/view.test.ts
@@ -8,6 +8,20 @@
88import { lines, Repo } from "./helpers.ts";
99
1010describe("View", () => {
11+ it("current indexed paths do not retain deleted historical file layouts", () => {
12+ const retained = (count: number) => {
13+ const files: Record<string, string> = { "live.txt": "live\n" };
14+ for (let i = 0; i < count; i++) files[`old-${i}.txt`] = "gone\n";
15+ const repo = Repo.init(files);
16+ repo.edit({ edits: Array.from({ length: count }, (_, i) => ({ file: `old-${i}.txt`, old: "gone\n", new: "" })) });
17+ const view = new View(repo.graph, new StableOverlaySet<AtomId>(["a0", "a1"]));
18+ assert.deepEqual(view.files(), { "live.txt": "live\n" });
19+ const weight = view.weight();
20+ assert.equal(view.knownPaths().length, count + 1, "explicit historical enumeration is preserved");
21+ return weight;
22+ };
23+ assert.equal(retained(200), retained(20), "deleted path count must not grow current-view retained state");
24+ });
1125 it("reuses indexed membership across a long run of lines without a history-sized memo", () => {
1226 const repo = Repo.init({ "long.txt": "line\n".repeat(1000) });
1327 class CountingSet extends StableOverlaySet<AtomId> {
--- a/src/engine/view.ts
+++ b/src/engine/view.ts
@@ -386,6 +386,14 @@
386386
387387 /** Files with at least one visible line, sorted. */
388388 paths(): string[] {
389+ if (this.#stable) {
390+ const paths: string[] = [];
391+ for (const path of this.graph.knownFiles()) {
392+ if (this.hasFile(path)) paths.push(path);
393+ else this.#files.delete(path);
394+ }
395+ return paths.sort();
396+ }
389397 return this.#known.filter((p) => this.hasFile(p));
390398 }
391399