import { type JsonValue } from "@decionis/agent-safe-pipeline"; /** The `prev_hash` of a chain's first line. */ export declare const CHAIN_GENESIS: string; export interface ChainHead { readonly seq: number; readonly hash: string; } export type ChainFields = Readonly>; export interface ChainedRecord { readonly seq: number; readonly prev_hash: string; readonly hash: string; /** The line as written: `stream`, `tenant` when there is one, `seq`, `prev_hash`, the fields, then `hash`. */ readonly line: string; } export type ChainWriter = (line: string) => void; /** * A hash chain over the lines of one stream. Each line carries its sequence * number, the hash of the line before it, and its own hash: SHA-256 over * the canonical JSON (keys sorted, recursively) of every field but `hash`. * A deleted, altered, or reordered line is detectable by anyone holding the * lines and nothing else; it is continuity and integrity, not origin, which * a signature over an export provides. Linking is synchronous, so two lines * can never interleave their sequence numbers. * * A chain run for one tenant of a hosted gateway carries the tenant in its * envelope, beside `stream`: covered by every hash, and never overridden by * a field, so a line cannot be moved to another tenant without breaking the * chain, and one process's output holds each tenant's chains apart. */ export declare class HashChain { readonly stream: string; readonly tenant: string | null; private current; private readonly listeners; constructor(stream: string, head?: ChainHead | null, tenant?: string | null); get head(): ChainHead; /** Called after every link with the new head; for the journal that persists it. */ onLink(listener: (head: ChainHead) => void): () => void; /** Links the fields, writes the line, moves the head, then tells the listeners. */ link(fields: ChainFields, write: ChainWriter): ChainedRecord; /** SHA-256 over the canonical JSON of every field but `hash`, as the verifier recomputes it. */ static digest(record: Readonly>): string; } //# sourceMappingURL=HashChain.d.ts.map