/** * The session-log contract, as a suite a host runs against its own backend. * * A custom log (a database, an object store) is re-implemented against the * `SessionLog` interface and proved against this file. It holds the rules no * type can state: the chain verifies, a superseded lease cannot write, a * live lease is renewed only by the instance holding it (late or not), one * turn is active at a time and its state is `running`, `paused` or * `interrupted`, the fold applies compactions and replacements, a large body * spills and reads back, a torn tail is repaired on the record, and a flipped * byte is refused. * * Like `store/run/conformance.ts`, which it replaces, it takes `describe`, * `it` and `expect` as arguments: the SDK gains no test dependency, and a * caller can pass recording functions to run the suite as ordinary code * (which is how `conformance-fails-a-wrong-log.test.ts` shows a broken log * fails it). * * The assertions are public API: adding or tightening one raises * {@link SESSION_LOG_CONTRACT_VERSION} and ships in a major. */ import type { SessionId } from '../../types/ids/index.js'; import type { SessionLog } from './core.js'; /** The contract revision these assertions express. A host declares the one it wrote against, as a literal. */ export declare const SESSION_LOG_CONTRACT_VERSION = 1; /** Raw access to a backend's bytes, for the integrity cases. Omit it and those cases are skipped. */ export interface SessionLogTamper { /** The log's bytes as stored. */ bytes(): Promise; /** Replace the stored bytes wholesale. */ overwrite(bytes: Uint8Array): Promise; } /** A log to test, over fresh storage. */ export interface SessionLogHandle { readonly log: SessionLog; /** A second instance over the same storage, as another process would open it. */ reopen(): SessionLog; readonly tamper?: SessionLogTamper; dispose?(): void | Promise; } export type MakeSessionLog = (sessionId: SessionId) => SessionLogHandle | Promise; /** The assertions the suite uses, and nothing more. */ export interface SessionLogAssertion { toBe(expected: unknown): void; toEqual(expected: unknown): void; toBeGreaterThan(expected: number): void; toMatch(expected: RegExp): void; } export interface SessionLogConformanceOptions { readonly describe: (name: string, body: () => void) => unknown; readonly it: (name: string, body: () => Promise) => unknown; readonly expect: (actual: unknown) => SessionLogAssertion; /** The contract revision the backend was written against, as a literal. */ readonly contractVersion: number; readonly makeLog: MakeSessionLog; /** Names the backend in test output. */ readonly label?: string; } /** Register the session-log contract against `options.makeLog`. */ export declare function defineSessionLogConformance(options: SessionLogConformanceOptions): void; //# sourceMappingURL=conformance.d.ts.map