Versions 37 to 318
new file, 757 lines
15+
18+ * pages, immutable scalars and serialized objects preserve the copy contract. Discard it after an outer host
26+
34+ * The keys written or removed in each open transaction, innermost last (abso Capacity). A rollback drops only those:
35+ * every projection scratch scope ends in a rollback, and dropping the whole cache there read the same rows from
40+ * The biggest one row may be and still be kept (abso Capacity). A few big rows read on every call (each agent with
41+ * all the news it was told: 4.3 MB for abso's 109 agents) otherwise push every small page out of the cache.
44+ constructor(source: GraphStateStorage, maxBytes = 1_048_576, maxEntries = 4096, maxEntryBytes = maxBytes) {
96+ entry = { kind: "scalar", value, bytes: overhead + (typeof value === "string" ? 2 * value.length : 16) };
111+ // A projection scope's own rows are never read again once it ends in its rollback: forget them with it.
156+ // What the transaction wrote, and anything read back after it wrote it, is gone with the rollback.
162+
164+ * Sets known to be closed under dependencies (abso Capacity): every atom's deps are in the set. A view or a project
175+
203+
230+
250+
257+
264+
282+
285+
296+ const values = storage.read(`${name}:pages`, String(Math.floor(index / pageSize))) as number[] | undefined;
312+ if (!Number.isSafeInteger(value)) throw new Error("writer numeric indexes require safe integers");
318+ if (values.length !== offset) throw new Error(`invalid writer numeric page length in ${name}`);
325+ if (!Number.isSafeInteger(value)) throw new Error("writer numeric indexes require safe integers");
329+ if (index % pageSize >= values.length) throw new Error(`incomplete writer numeric page in ${name}`);
335+
351+ // No length read first (abso Capacity): set writes the row and the length together and nothing shrinks, so no
382+
391+
405+ if (!Number.isSafeInteger(count) || count < 0) throw new Error(`invalid writer list count in ${name}`);
424+ /** Values [index * PAGE, (index + 1) * PAGE) of `key`'s list: one page, not the whole list (abso Capacity). */
465+ if (values.length !== count % pageSize) throw new Error(`invalid writer list length in ${name}`);
478+
480+export function storedMap<K extends string | number, V>(storage: GraphStateStorage, name: string): StateMap<K, V> {
503+
529+ return this.#storage.read(this.#name, this.#key(key)) as { slot: number; value: unknown } | undefined;
583+ override forEach(callback: (value: V, key: K, map: Map<K, V>) => void, thisArg?: unknown): void {
587+
627+
631+
632+/** Write a list as readonlyPagedArray reads it: its values LIST_PAGE to a row, and its length. */
633+export function writePagedArray(storage: GraphStateStorage, name: string, values: readonly unknown[]): void {
635+ storage.write(`${name}:pages`, String(start / LIST_PAGE), values.slice(start, start + LIST_PAGE));
638+
640+ * A stored list read a page of LIST_PAGE values at a time (abso Capacity): an atom's long lists, which
641+ * readonlyStoredArray reads a row per value. Collisions read every key a draft's atoms write; a draft deleting a big
647+ if (!Number.isSafeInteger(count) || (count as number) < 0) throw Error("invalid stored list length");
692+
700+ if (!Number.isSafeInteger(count) || (count as number) < 0) throw Error("invalid stored list length");
710+ // In order, with the length read once (abso Capacity): the array iterator reads it again before every element, a
730+ if (key === "length") return { ...Reflect.getOwnPropertyDescriptor(target, key)!, value: length() };
- MCP
- compare on this site's /mcp
- CLI
- abso diff 37 318 src/engine/state-source.ts --json
- JSON
- /christopher/abso-core/compare/37..318?file=src%2Fengine%2Fstate-source.ts&format=json