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 118 to 119

Compare

+50 −0 in 1 place
Lines 259–314 at 119 (were 259–264 at 118)
259259 values(): IterableIterator<V>;
260260}
261261
262+/** Append-only per-key lists, retaining at most one fixed-size page per iterator. */
263+export function storedLists<V>(storage: GraphStateStorage, name: string) {
264+ const pageSize = 256;
265+ // The previous experimental layout stored one whole historical list per key.
266+ const length = (key: string) => {
267+ const stored = storage.read(`${name}:lengths`, key) as number | undefined;
268+ if (stored === undefined && storage.read(name, JSON.stringify(["string", key])) !== undefined)
269+ throw new Error(`writer list index ${name} requires canonical-log adoption`);
270+ const count = stored ?? 0;
271+ if (!Number.isSafeInteger(count) || count < 0) throw new Error(`invalid writer list count in ${name}`);
272+ return count;
273+ };
274+ const pageKey = (key: string, page: number) => JSON.stringify([key, page]);
275+ const page = (key: string, index: number): V[] => {
276+ const values = storage.read(`${name}:pages`, pageKey(key, index)) as V[] | undefined;
277+ if (!Array.isArray(values) || values.length < 1 || values.length > pageSize)
278+ throw new Error(`missing or invalid writer list page in ${name}`);
279+ return values;
280+ };
281+ return {
282+ length,
283+ *keys(): IterableIterator<string> {
284+ for (const entry of storage.entries(name)) {
285+ void entry;
286+ throw new Error(`writer list index ${name} requires canonical-log adoption`);
287+ }
288+ for (const [key] of storage.entries(`${name}:lengths`)) yield key;
289+ },
290+ *values(key: string): IterableIterator<V> {
291+ const count = length(key);
292+ for (let start = 0; start < count; start += pageSize) {
293+ const values = page(key, start / pageSize);
294+ if (values.length !== Math.min(pageSize, count - start))
295+ throw new Error(`incomplete writer list page in ${name}`);
296+ yield* values;
297+ }
298+ },
299+ append(key: string, value: V): void {
300+ const count = length(key);
301+ const offset = count % pageSize;
302+ const index = Math.floor(count / pageSize);
303+ const values = offset === 0 ? [] : page(key, index);
304+ if (values.length !== offset) throw new Error(`invalid writer list length in ${name}`);
305+ values.push(value);
306+ storage.write(`${name}:pages`, pageKey(key, index), values);
307+ storage.write(`${name}:lengths`, key, count + 1);
308+ },
309+ };
310+}
262312/** Keys are tagged so numeric graph codes cannot collide with string keys. */
263313export function storedMap<K extends string | number, V>(storage: GraphStateStorage, name: string): StateMap<K, V> {
264314 const keyOf = (key: K) => JSON.stringify([typeof key, key]);
MCP
compare on this site's /mcp
CLI
abso diff 118 119 src/engine/state-source.ts --json
JSON
/christopher/abso-core/compare/118..119?file=src%2Fengine%2Fstate-source.ts&format=json