import { type Notice } from './notice.js'; import { type DocState } from './state.js'; import type { StoreEvent } from './store-types.js'; export type ReworkCaps = Readonly>; export interface ReworkThread { doc: string; type: string; /** The section that publishes the document. */ producer_section: string; /** The consuming section that rejected, and whose cap applies. */ consumer: string; /** Versions of the document the consumer rejected. */ rounds: number; cap: number; exhausted: boolean; /** Commit sequence of the rejection that reached the cap. */ exhausted_seq?: number; /** Version numbers rejected, ascending. */ rejected_versions: number[]; } /** The positive-integer `max_rework_rounds` of every section that sets one, keyed by section. Unset: no entry, no cap. */ export declare function capsFromDef(def: { sections?: unknown; }): Record; /** * Every (document, consuming section) thread with at least one rejection whose consumer has a cap * (`caps[consumer]`; a section with no entry has no cap and no thread), ordered by document id then consumer. */ export declare function reworkThreads(state: DocState, caps: Readonly>): ReworkThread[]; /** The exhausted threads, in the order they were exhausted (by commit sequence). */ export declare function reworkStatus(state: DocState, caps: Readonly>): ReworkThread[]; /** What the notice engine needs of the enforcement: the caps now, and who is told. */ export interface ReworkEscalation { caps(): ReworkCaps; /** The root: it gets the full notice; the other recipients get the short copy. */ root: string | undefined; /** The roles owed the exhaustion notice for a thread, in order, without repeats. */ recipients(t: ReworkThread): string[]; } export interface ReworkFact extends ReworkThread { /** Exhausted and the head is not accepted: a publish superseding the document is refused. */ frozen: boolean; /** The head version the root may decide. */ head: number; } /** Every thread with a rejection and a cap, each with whether it is frozen. A pure function of the state and the caps. */ export declare function reworkFacts(state: DocState, caps: ReworkCaps): ReworkFact[]; /** The frozen threads of one document. */ export declare const frozenThreads: (state: DocState, caps: ReworkCaps, doc: string) => ReworkFact[]; /** The consuming section the root may decide for on `doc` version `version`: that of a frozen thread whose head it is. */ export declare const rootMayDecide: (state: DocState, caps: ReworkCaps, doc: string, version: number) => string | undefined; /** * The exhaustion notices the committed log obliges under `esc.caps()`, in order: at each committed rejection that * brings a thread to its cap, one notice per recipient. Replays the log, so it is deterministic. */ export declare function deriveReworkNotices(events: readonly StoreEvent[], esc: ReworkEscalation): Notice[]; /** Copy each existing section's `max_rework_rounds` from the proposed definition into the running one; returns the * `changed` entries. Only the cap moves: the rest of `sections` is not reloadable here. */ export declare function syncReworkCaps(live: { sections?: unknown; }, next: { sections?: unknown; }): string[]; /** What a reload needs of the documents runtime. */ export interface ReworkHost { enableRework(): void; notices?: { retry(): Promise; }; } /** A reload: carry the changed caps into the running definition, install the enforcement if a cap now exists, and * give the notice engine a pass (a lowered cap can owe a notice). Returns the `changed` entries. */ export declare function reloadReworkCaps(live: { sections?: unknown; }, next: { sections?: unknown; }, docs: ReworkHost | undefined): string[]; //# sourceMappingURL=rework.d.ts.map