import { type RuntimeDeliver } from './deliver.js'; import type { DeliverableChange } from './deliverable-guards.js'; import { type Notice } from './notice.js'; import { type CopyTo, type RelayFact } from './relay.js'; import { type ReworkEscalation } from './rework.js'; import type { DocumentStore } from './store.js'; export declare const DEFAULT_MAX_FAILURES = 5; export interface NoticeSink { deliver: RuntimeDeliver; /** True when the recipient's live mailbox still holds a message with this subject (it is not re-sent). */ queued?: (to: string, subject: string) => boolean; /** Told of failures and re-deliveries (the bus audit trail). */ emit?: (e: { reason: string; msg: string; data: Record; }) => void; } export interface NoticeEngineOptions { /** `/docs/`. */ dir: string; store: DocumentStore; now?: () => Date; maxFailures?: number; /** Producer relay (P3.9): who gets the short copy of a relay for a type produced by a section. */ copyTo?: CopyTo; } export type NoticeState = 'pending' | 'delivered' | 'exhausted'; /** What lead-watch (P3.13) needs of one published version: when it was published, whether and when each * decision maker was told, and when each first read it. */ export interface DocFact { doc: string; version: number; type: string; published_at: string; notices: { role: string; key: string; state: NoticeState; delivered_at?: string; failures: number; }[]; first_read_at: Record; } export declare class NoticeEngine { private readonly opts; private readonly journal; private readonly events; private readonly maxFailures; private readonly now; private derived; private rework; private capsKey; private sink; private enabled; private closed; private chain; private queuedPass; private readonly memoryOwed; private readonly unsubscribe; constructor(opts: NoticeEngineOptions); /** Turn on the max_rework_rounds enforcement (P4.7): the relay says the round, and a spent thread owes the * root and the leads one notice. The caps are read at every derivation, so a reload moves them. */ useRework(esc: ReworkEscalation): void; /** Test-only switch: with notices off nothing is sent and the obligations stay pending (the deadlock regression). */ setEnabledForTest(on: boolean): void; /** Attach the delivery path and run the start pass: send what was never delivered, re-send what was not acted on. */ start(sink: NoticeSink): void; /** The next opportunity for a failed or unsent notice (the lead-watch tick of P3.13 calls this). */ retry(): Promise; /** Resolves when every delivery pass scheduled so far has finished. */ idle(): Promise; close(): void; private types; /** Every notice and relay the committed log (and the journalled refused accepts) oblige, in order. */ notices(): Notice[]; private derive; /** * A refused accept (deliverable files changed, P3.10) has no committed event, so its relay obligation is * journalled whole the moment the guard refuses, before any delivery: a crash after this line still sends it * at the next start, and a crash before it means the consumer never got the refusal either (it will retry). * One relay per version and difference. If the journal write fails the obligation is kept in memory only (sent * by this process, lost with it). */ owe(c: DeliverableChange): void; /** Per producer relay: when it was delivered and whether and when the producer republished (P3.13). */ relayFacts(): RelayFact[]; private stateOf; /** The notices not yet delivered and not given up on. */ pending(): Notice[]; /** Per published version: the facts lead-watch needs. */ facts(): DocFact[]; private schedule; /** True when `n`'s decision maker has read or decided that document version (or a later one). */ private acted; private headVersion; /** A delivered obligation worth sending again at a start: the recipient has not acted on it. A publish notice * stands until its decision maker reads or decides that version; a relay until the producer publishes again. */ private resendable; /** The root has accepted this version (the override of a spent rework cap): an instruction to revise or * to wait for the root is stale. */ private accepted; /** The instruction to the producer is moot once it has replaced the version or the root has accepted it; the * copy to the lead is an audit record and is still sent. */ private moot; private pass; private at; private record; } //# sourceMappingURL=notices.d.ts.map