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 112 to 113

Compare

+50 −0 in 1 place
Lines 160–215 at 113 (were 160–165 at 112)
160160const indexKey = (key: PropertyKey): key is string =>
161161 typeof key === "string" && /^(0|[1-9][0-9]*)$/.test(key) && Number.isSafeInteger(Number(key));
162162
163+/** Fixed-size numeric pages; callers retain no pages outside the bounded storage cache. */
164+export function storedNumbers(storage: GraphStateStorage, name: string) {
165+ const pageSize = 256;
166+ const meta = `${name}:meta`;
167+ const length = () => (storage.read(meta, "length") as number | undefined) ?? 0;
168+ // Older experimental writer indexes must be rebuilt from their canonical log.
169+ // Never interpret per-element rows as pages or silently lose existing history.
170+ const page = (index: number): number[] => {
171+ if (storage.read(meta, "format") !== 2)
172+ throw new Error(`writer numeric index ${name} requires canonical-log adoption`);
173+ const values = storage.read(`${name}:pages`, String(Math.floor(index / pageSize))) as number[] | undefined;
174+ if (!values) throw new Error(`missing writer numeric page in ${name}`);
175+ return values;
176+ };
177+ return {
178+ get length() {
179+ return length();
180+ },
181+ at(index: number): number {
182+ if (!Number.isSafeInteger(index) || index < 0 || index >= length())
183+ throw new Error(`writer numeric index out of bounds in ${name}`);
184+ const value = page(index)[index % pageSize];
185+ if (value === undefined) throw new Error(`incomplete writer numeric page in ${name}`);
186+ return value;
187+ },
188+ push(value: number): void {
189+ if (!Number.isSafeInteger(value)) throw new Error("writer numeric indexes require safe integers");
190+ const index = length();
191+ if (index > 0 && storage.read(meta, "format") !== 2)
192+ throw new Error(`writer numeric index ${name} requires canonical-log adoption`);
193+ const offset = index % pageSize;
194+ const values = offset === 0 ? [] : page(index);
195+ if (values.length !== offset) throw new Error(`invalid writer numeric page length in ${name}`);
196+ values.push(value);
197+ storage.write(`${name}:pages`, String(Math.floor(index / pageSize)), values);
198+ if (index === 0) storage.write(meta, "format", 2);
199+ storage.write(meta, "length", index + 1);
200+ },
201+ set(index: number, value: number): void {
202+ if (!Number.isSafeInteger(value)) throw new Error("writer numeric indexes require safe integers");
203+ if (!Number.isSafeInteger(index) || index < 0 || index >= length())
204+ throw new Error(`writer numeric index out of bounds in ${name}`);
205+ const values = page(index);
206+ if (index % pageSize >= values.length) throw new Error(`incomplete writer numeric page in ${name}`);
207+ values[index % pageSize] = value;
208+ storage.write(`${name}:pages`, String(Math.floor(index / pageSize)), values);
209+ },
210+ };
211+}
163213/** Array-shaped access without retaining its historical values in memory. */
164214export function storedArray<T>(storage: GraphStateStorage, name: string, decode?: (value: T) => T): T[] {
165215 const length = () => (storage.read(`${name}:meta`, "length") as number | undefined) ?? 0;
MCP
compare on this site's /mcp
CLI
abso diff 112 113 src/engine/state-source.ts --json
JSON
/christopher/abso-core/compare/112..113?file=src%2Fengine%2Fstate-source.ts&format=json