/** * Graceful shutdown and lease release for the internal sync service bootstrap. * * Owns the stop/retry semantics (stop inbound reads first, then the outbound * worker, ALWAYS expire this runtime's own leases, keep stop() retryable when * a supervisor stop fails) and the CAS-guarded, warn-and-continue lease * releases mirrored from every claim site wired into the bootstrap. */ import type { TypedSheetsEntityWriterOptions } from "../../../contracts/sync-orm/writer.js"; import type { SyncServiceStorage } from "./compositionPorts.js"; import { type EffectWorkerSupervisor, type WriterLeaseHeartbeatHandle } from "@hikoutei/ikisaki"; import type { MappedUserInputPollingReport } from "../../../contracts/sheets/userInputPolling.js"; import type { SyncPollingSupervisor } from "./SyncPollingSupervisor.js"; /** * Expires this runtime's own writer leases on graceful shutdown. * * Each release is CAS-guarded on the exact lease row this runtime holds * (role, writer id, epoch, fencing token), so a concurrent takeover or a * previously crashed runtime's stale row is never expired. The observation * poller and the auto conflict resolver claim under the mapped writer role * with the same writer id, so the single mapped-role release covers them. * A failing release only logs a classified warning and never aborts stop(). */ export declare function expireRuntimeWriterLeases(storage: SyncServiceStorage, writer: TypedSheetsEntityWriterOptions, effectWorkerId: string): Promise; /** Inputs shared with the composition root's supervisors. */ export interface CreateStopHandlerInput { readonly storage: SyncServiceStorage; readonly writer: TypedSheetsEntityWriterOptions; readonly effectWorkerId: string; readonly pollingSupervisor: SyncPollingSupervisor; readonly effectSupervisor: EffectWorkerSupervisor; /** Renew-only entity-writer lease heartbeat; stopped FIRST so shutdown stops renewing. */ readonly entityWriterLeaseHeartbeat?: WriterLeaseHeartbeatHandle; } /** * Builds the idempotent, retryable stop handler for one internal service. * * Stops inbound reads first, then the outbound worker, and ALWAYS expires * this runtime's own leases even when a supervisor stop fails, so a restart * inside the lease window never fails with WRITER_LEASE_UNAVAILABLE. A * failing release only logs and never masks the supervisor error. `stopped` * still flips only when both supervisor stops complete, so a rejected stop * leaves a retryable close() that re-runs the stops and the release. */ export declare function createStopHandler(input: CreateStopHandlerInput): () => Promise; //# sourceMappingURL=shutdown.d.ts.map