import { type EntityState } from './trust.ts'; /** * Trust state persistence. D8. * * Deliberately three operations over an opaque key. D1 makes the entity * reference opaque to SG, so there is nothing to query by, which keeps this * implementable on top of a Map, Redis, or a single SQL table without any of * them needing to understand the model. * * Async throughout (D10), because the caller may be talking to a network store * and the read path is where lazy decay (D3) and lazy expiry (D6) happen anyway. */ export type StateStore = { /** Stored state, or `undefined` if this entity has none. */ get(entity: string): Promise; set(entity: string, state: EntityState): Promise; /** * Remove state for one entity. Used both by retention expiry (D6) and by the * host-facing purge primitive (D22), the same operation, different trigger. */ delete(entity: string): Promise; }; export type MemoryStoreOptions = { /** * Drop expired entries once this many writes have happened. Amortised, so no * timer is held and nothing keeps the process alive. * * Sweeping is about reclaiming memory, never about correctness: expiry is * enforced on read (D6), so a swept and an unswept store answer identically. */ readonly sweepEvery?: number; readonly retentionHours?: number; /** * Hard cap on retained entities. When exceeded after a sweep, the entities * furthest past their last meaningful update are dropped first. * * Present because an unbounded map is a denial-of-service surface: an attacker * who can mint fresh references can grow it without limit, and D1 guarantees SG * cannot tell minted references from legitimate new ones. Dropping state is * safe in a way that running out of memory is not, a dropped entity returns as * `unknown`, which D40 already treats as a well-defined state. */ readonly maxEntities?: number; }; export type MemoryStore = StateStore & { size(): number; /** Drop expired entries now. Returns how many were removed. */ sweep(now: number): number; }; export declare const DEFAULT_SWEEP_EVERY = 512; /** * In-memory store. The default, and a real implementation rather than a stub. * * Process-local by construction: it resets on restart and is invisible to other * instances. That is correct for one process and wrong for anything that restarts * often, so it is no longer the only option, `sqliteStore` (`./sqlite`) is the * durable counterpart behind the same three methods, and both pass the same * conformance kit. This one remains the default because it needs no filesystem * and runs anywhere the core does. */ export declare function memoryStore(options?: MemoryStoreOptions): MemoryStore; //# sourceMappingURL=store.d.ts.map