export declare const DEFAULT_SEGMENT_TTL_MS: number; export interface SegmentMetadata { readonly partition: string; /** Partition log continuity that produced these bytes (§2.1). */ readonly logEpoch: string; readonly table: string; readonly schemaVersion: number; readonly mediaType: 'rows' | 'sqlite'; readonly scopeDigest: string; readonly asOfCommitSeq: number; readonly rowCount: number; readonly rowCursor: string | null; readonly nextRowCursor: string | null; } export interface SegmentRecord extends SegmentMetadata { readonly segmentId: string; readonly byteLength: number; readonly createdAtMs: number; readonly expiresAtMs: number; } /** * The §5.3 reuse key: sqlite images are not byte-deterministic, so * cross-client dedup is a metadata lookup, not hash convergence — one * stored image per (partition, table, schemaVersion, scope digest, pin). */ export interface SegmentFindKey { readonly partition: string; readonly logEpoch: string; readonly table: string; readonly schemaVersion: number; readonly mediaType: 'rows' | 'sqlite'; readonly scopeDigest: string; readonly asOfCommitSeq: number; } /** * Coarse store-level counters for the admin/console read surface. Optional: * a store that omits `stats()` simply cannot report them. * All counts include expired-but-not-yet-evicted entries (the store's own * bytes on disk), split by media type. */ export interface SegmentStoreStats { readonly count: number; readonly bytes: number; readonly rowsSegments: number; readonly sqliteSegments: number; /** * ADDITIVE marker — present and `true` only on stores whose counters are * approximate (the S3/R2 store's LIST-free pointer accumulator, which can * drift under concurrent writers or after lifecycle GC). Absent on the * exact in-process stores (memory/sqlite). The admin surface carries it * through so the console can label the numbers honestly. */ readonly approximate?: boolean; } export interface SegmentStore { put(metadata: SegmentMetadata, bytes: Uint8Array, nowMs: number): Promise; /** Returns expired records too — expiry is the caller's check (§5.5). */ get(segmentId: string): Promise<{ record: SegmentRecord; bytes: Uint8Array; } | undefined>; /** * Unexpired record for the §5.3 reuse key (whole-table segments only: * `rowCursor` null), or undefined. Servers MUST reuse instead of * rebuilding sqlite images while one exists (§5.3). */ find(key: SegmentFindKey, nowMs: number): Promise; /** Admin/console counters: ADDITIVE, optional. */ stats?(): Promise; } export declare function segmentIdFor(bytes: Uint8Array): Promise; export declare class MemorySegmentStore implements SegmentStore { #private; constructor(options?: { ttlMs?: number; }); put(metadata: SegmentMetadata, bytes: Uint8Array, nowMs: number): Promise; get(segmentId: string): Promise<{ record: SegmentRecord; bytes: Uint8Array; } | undefined>; find(key: SegmentFindKey, nowMs: number): Promise; stats(): Promise; }