/** * Attempt-fenced settlement for the application command mailbox (WFT-84): * lease renewal, acknowledgement, rejection, cancellation, and the bounded * cleanup wait. * * Every function here proves the caller holds the current attempt before it * writes anything, and every one re-reads durable state after a lost * compare-and-swap rather than retrying with stale bytes. A stale claimant * therefore cannot acknowledge, reject, cancel, extend, or heartbeat a newer * attempt — it gets a `stale` result carrying the authoritative receipt. * * Renewal is the one mutation that emits no fleet event. It is liveness * evidence, not a state transition: the record's disposition is unchanged, so * publishing an event per heartbeat would flood the feed without telling a * consumer anything a receipt read does not already say. * * @module core/mailbox-settlement */ import type { JSONValue } from './json.ts'; import type { ApplicationCommandCancellationResult, ApplicationCommandCleanupResult, ApplicationCommandRenewalResult, ApplicationCommandSettleResult } from './mailbox-contract.ts'; import { type MailboxRuntime } from './mailbox-internals.ts'; import type { ApplicationCommandFailure } from './mailbox-types.ts'; /** * Extend a lease and report liveness for the current attempt. * * The returned `cancellationRequested` flag is the cross-process cancellation * channel. A claimant in another process never sees the attempt-scoped * `AbortSignal`, so renewal is where it learns that cancellation was requested. */ export declare function renewClaim(runtime: MailboxRuntime, options: { readonly commandId: string; readonly attemptToken: string; readonly progress?: JSONValue | undefined; }): Promise; /** Settle a claimed command successfully. */ export declare function acknowledgeClaim(runtime: MailboxRuntime, options: { readonly commandId: string; readonly attemptToken: string; readonly outcome?: JSONValue | undefined; }): Promise; /** * Settle a claimed command as failed, optionally scheduling a retry at the * command's original FIFO position. */ export declare function rejectClaim(runtime: MailboxRuntime, options: { readonly commandId: string; readonly attemptToken: string; readonly failure: ApplicationCommandFailure; readonly retry: boolean; }): Promise; /** * Record a durable cancellation request and, when the claimant is in this * process, abort its attempt-scoped signal. * * Cancellation is durable before any acknowledgement: the abort fires only * after the record commits, so a crash between the two cannot leave a claimant * aborted without the request being persisted. */ export declare function requestCancellation(runtime: MailboxRuntime, options: { readonly commandId: string; readonly reason?: string | undefined; }): Promise; /** * Read whether a cancelled command's claimant has finished. * * `pending` means the mailbox has not seen the attempt settle. It never claims * the handler stopped — only that cleanup is still outstanding. */ export declare function readCleanupState(runtime: MailboxRuntime, commandId: string): Promise;