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 175 to 318

Compare

+108 −3 in 4 places
Lines 23–31 at 318 (were 23–28 at 175)
2323 readonly shapes: ProjectOptions["shapes"];
2424}
2525
26+/** Older versions' file lists kept per space (a few agents' bases): about 1,000 paths each on abso. */
27+const OLDER_PATH_SETS = 8;
2629export class PathIndex {
2730 readonly #deps: PathIndexDeps;
2831
Lines 44–129 at 318 (were 41–46 at 175)
4144 /** Each version's files made and taken out, and moves (#41), worked out with its files. */
4245 readonly #shapeCache = new WeakMap<Space, Map<number, VersionShape>>();
4346
47+ /** The files at the newest version folded so far from kept shapes, per space (keptPaths). */
48+ readonly #keptPaths = new WeakMap<Space, { version: number; files: Set<string> }>();
49+ /** The files at a few older versions, worked back from the newest (agents' bases, mostly), most recent last. */
50+ readonly #olderPaths = new WeakMap<Space, Map<number, Set<string>>>();
52+ /**
53+ * The files at a version older than the newest folded (abso Capacity): the newest's files with each version since
54+ * undone, its made files taken out and its gone ones put back. Folding from version 0 again for an agent's base
55+ * read every version's kept row on each call.
56+ */
57+ #olderPathSet(
58+ space: Space,
59+ fold: { version: number; files: Set<string> },
60+ version: number,
61+ ): ReadonlySet<string> | undefined {
62+ let older = this.#olderPaths.get(space);
63+ if (!older) this.#olderPaths.set(space, (older = new Map()));
64+ const known = older.get(version);
65+ if (known) {
66+ older.delete(version);
67+ older.set(version, known);
68+ return known;
69+ }
70+ const files = new Set(fold.files);
71+ for (let v = fold.version; v > version; v--) {
72+ if (!this.#keptFiles(space, v)) return undefined;
73+ const shape = this.#shapeCache.get(space)?.get(v);
74+ if (!shape) return undefined;
75+ for (const f of shape.made) files.delete(f);
76+ for (const f of shape.gone) files.add(f);
77+ }
78+ older.set(version, files);
79+ if (older.size > OLDER_PATH_SETS) older.delete(older.keys().next().value!);
80+ return files;
81+ }
83+ /**
84+ * The files a space has at a version, from the kept rows of every version up to it: each one's files made and
85+ * taken out, folded from version 0 (abso Capacity). Undefined when a version has no kept row that describes it;
86+ * then the caller lays the version out.
87+ */
88+ keptPaths(space: Space, version: number): string[] | undefined {
89+ const files = this.keptPathSet(space, version);
90+ return files && [...files].sort();
91+ }
93+ /**
94+ * The files the versions after `from`, up to `to`, changed, from each version's kept row (abso 738): undefined when one
95+ * has none, and the caller works them out from the atoms. Every file whose text differs between the two versions is
96+ * in it, since some version between changed it.
97+ */
98+ keptChangesSince(space: Space, from: number, to: number): ReadonlySet<string> | undefined {
99+ const out = new Set<string>();
100+ for (let v = from + 1; v <= to; v++) {
101+ const files = this.#keptFiles(space, v);
102+ if (!files) return undefined;
103+ for (const f of files) out.add(f);
104+ }
105+ return out;
106+ }
108+ /** keptPaths as a set, kept for the newest version asked: never changed once made, so a view can hold it. */
109+ keptPathSet(space: Space, version: number): ReadonlySet<string> | undefined {
110+ let fold = this.#keptPaths.get(space);
111+ if (fold?.version === version) return fold.files;
112+ if (fold && fold.version > version) return this.#olderPathSet(space, fold, version);
113+ if (!fold) fold = { version: -1, files: new Set() };
114+ const files = new Set(fold.files);
115+ for (let v = fold.version + 1; v <= version; v++) {
116+ if (!this.#keptFiles(space, v)) return undefined;
117+ // Not yet when the version is still being kept (keep asks its views which files exist).
118+ const shape = this.#shapeCache.get(space)?.get(v);
119+ if (!shape) return undefined;
120+ for (const f of shape.gone) files.delete(f);
121+ for (const f of shape.made) files.add(f);
122+ }
123+ this.#keptPaths.set(space, { version, files });
124+ return files;
125+ }
44127 /** Each space's path index (#41): built the first time it's asked for, then kept up as versions land. */
45128 readonly #pathIndex = new WeakMap<Space, { upTo: number; paths: Map<string, PathLife> }>();
46129
Lines 147–180 at 318 (were 64–74 at 175)
64147 // Net changes only, as show has them: a file made and removed again before the publish isn't one (#37).
65148 const touched = this.#deps.touchedFiles([...p.atoms, ...(p.dropped ?? [])], [before, after]);
66149 const files = [...touched].filter((path) => differs(before, after, path)).sort();
150+ this.keep(space, version, files, before, after);
151+ return files;
152+ }
154+ /**
155+ * Keep a version's changed files, with its files made and taken out and its moves: worked out here, or as the
156+ * version landed (version-files.ts, abso Capacity), which says which files existed before and after.
157+ */
158+ keep(
159+ space: Space,
160+ version: number,
161+ files: string[],
162+ before: ReadView,
163+ after: ReadView,
164+ exists?: ReadonlyMap<string, readonly [boolean, boolean]>,
165+ ): void {
166+ let cache = this.#filesCache.get(space);
167+ if (!cache) this.#filesCache.set(space, (cache = new Map()));
168+ let shapes = this.#shapeCache.get(space);
169+ if (!shapes) this.#shapeCache.set(space, (shapes = new Map()));
170+ const p = space.versions[version]!;
67171 cache.set(version, files);
68172 // Files made and taken out, and which of those are one file moved (#41): an atom that moves lines
69173 // names both files, and a binary or empty file moved keeps its blob.
70− const made = files.filter((f) => !before.hasFile(f) && after.hasFile(f));
71− const gone = files.filter((f) => before.hasFile(f) && !after.hasFile(f));
174+ const had = (f: string) => exists?.get(f)?.[0] ?? before.hasFile(f);
175+ const has = (f: string) => exists?.get(f)?.[1] ?? after.hasFile(f);
176+ const made = files.filter((f) => !had(f) && has(f));
177+ const gone = files.filter((f) => had(f) && !has(f));
72178 const moves: [string, string][] = [];
73179 if (made.length > 0 && gone.length > 0) {
74180 const movers = new Set(this.#deps.graph.movers());
Lines 193–198 at 318 (were 87–93 at 175)
87193 }
88194 shapes.set(version, { made, gone, moves });
89195 this.#deps.shapes?.put(space.name, version, JSON.stringify({ stamp: shapeStamp(p), files, made, gone, moves }));
90− return files;
91196 }
92197
93198 /** A version's files kept from an earlier load (#41), when the row describes this very version; into the caches. */
MCP
compare on this site's /mcp
CLI
abso diff 175 318 worker/project/pathindex.ts --json
JSON
/christopher/abso-core/compare/175..318?file=worker%2Fproject%2Fpathindex.ts&format=json