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 199 to 200

Compare

+41 −15 in 4 places
Lines 46–51 at 200 (were 46–52 at 199)
4646 readonly publishedIn: Map<AtomId, number>;
4747 /** Atoms a drop took out, and the version of the drop. */
4848 readonly droppedIn: Map<AtomId, number>;
49− readonly atCache: Map<number, ReadonlySet<AtomId>>;
5049 /** For a named draft, the log position of the entry that made it: the change its work belongs to (#44). */
5150 startedAt?: number;
5251}
Lines 61–69 at 200 (were 62–71 at 199)
6261 own: new StoredSet(storage, `${prefix}:own`),
6362 publishedIn: new StoredMap(storage, `${prefix}:published`),
6463 droppedIn: new StoredMap(storage, `${prefix}:dropped`),
65− atCache: new Map(),
6664 };
6765 }
68− return { name, versions: [], own: new Set(), publishedIn: new Map(), droppedIn: new Map(), atCache: new Map() };
66+ return { name, versions: [], own: new Set(), publishedIn: new Map(), droppedIn: new Map() };
6967}
7068
7169export function addVersion(space: Space, version: Published): void {
Lines 202–231 at 200 (were 204–213 at 199)
204202 return space.versions[space.versions.length - 1]!.sharedBase ?? 0;
205203}
206204
205+/**
206+ * How many built membership sets the in-memory path keeps, across every space (abso Capacity). Each named draft's set
207+ * is a whole copy of shared's at its base plus its own atoms, so a cache per space held one copy of shared per draft:
208+ * on prod project abso, 106 drafts kept 37 MB of them. One least-recently-used cache holds at most this many; a set
209+ * that fell out is built again when asked for, in milliseconds at that size. Measured on abso's prod export (81,855
210+ * entries): 96.6 MB after load before, 64.6 MB with 16 kept, 62.0 MB with 8; 16 keeps the load as fast as before.
211+ */
212+export const MEMBERSHIP_SETS_KEPT = 16;
214+/** A number per space object, so a space replaced under the same name (tables/build.ts) never gets the old one's sets. */
215+const spaceIds = new WeakMap<Space, number>();
216+let nextSpaceId = 0;
217+function spaceId(space: Space): number {
218+ let id = spaceIds.get(space);
219+ if (id === undefined) spaceIds.set(space, (id = nextSpaceId++));
220+ return id;
221+}
207223/** Every space, and each one's contents at any of its versions. */
208224export class Membership {
209225 readonly spaces: Map<string, Space>;
210226 readonly #storage?: GraphStateStorage;
227+ /** Built sets by space and version, oldest use first (MEMBERSHIP_SETS_KEPT). */
228+ readonly #sets = new Map<string, ReadonlySet<AtomId>>();
211229 constructor(storage?: GraphStateStorage) {
212230 this.#storage = storage;
213231 if (!storage) {
Lines 368–393 at 200 (were 350–367 at 199)
350368 return new StableUnionSet(base, own);
351369 }
352370 if (space.name === SHARED && version === last(space)) return space.own;
353− let set = space.atCache.get(version);
354− if (!set) {
355− const s = new Set<AtomId>();
356− if (space.name !== SHARED) for (const id of this.at(this.shared, space.versions[version]!.sharedBase!)) s.add(id);
357− for (let v = 0; v <= version; v++) {
358− for (const id of space.versions[v]!.atoms) s.add(id);
359− for (const id of space.versions[v]!.dropped ?? []) s.delete(id);
360− }
361− set = s;
362− if (space.atCache.size > 16) space.atCache.clear();
363− space.atCache.set(version, set);
371+ const key = `${spaceId(space)}:${version}`;
372+ const kept = this.#sets.get(key);
373+ if (kept) {
374+ this.#sets.delete(key);
375+ this.#sets.set(key, kept);
376+ return kept;
364377 }
365− return set;
378+ const s = new Set<AtomId>();
379+ if (space.name !== SHARED) for (const id of this.at(this.shared, space.versions[version]!.sharedBase!)) s.add(id);
380+ for (let v = 0; v <= version; v++) {
381+ for (const id of space.versions[v]!.atoms) s.add(id);
382+ for (const id of space.versions[v]!.dropped ?? []) s.delete(id);
383+ }
384+ this.#sets.set(key, s);
385+ if (this.#sets.size > MEMBERSHIP_SETS_KEPT) this.#sets.delete(this.#sets.keys().next().value!);
386+ return s;
366387 }
389+ /** How many built sets the in-memory cache holds now (for tests). */
390+ get setsKept(): number {
391+ return this.#sets.size;
392+ }
367393}
MCP
compare on this site's /mcp
CLI
abso diff 199 200 worker/project/spaces.ts --json
JSON
/christopher/abso-core/compare/199..200?file=worker%2Fproject%2Fspaces.ts&format=json