import { type RecordedPidLiveness } from './pid.js'; /** The single `canvas_meta` key this module exclusively owns. No other module * may read or write this key. */ export declare const DAEMON_OWNER_META_KEY = "daemon_owner"; /** The exact shape persisted as `canvas_meta.value` for `DAEMON_OWNER_META_KEY`. * `token` is an unpredictable per-invocation string minted by the caller * (`crtrd.ts`) — this module never generates, inspects, or compares it beyond * exact-string equality of the whole serialized claim. */ export interface DaemonOwnerClaim { readonly pid: number; readonly pid_identity: string; readonly token: string; } /** Every terminal, non-retriable way `claimDaemonOwnership` can lose. A loss * never deletes or otherwise mutates the incumbent row — only a positively * DEAD incumbent is ever CAS-replaced. */ export type DaemonOwnerClaimLossReason = /** This invocation's OWN pid identity couldn't be captured before any write * was attempted — no identity-less claim is ever installed. */ 'own_identity_indeterminate' /** The incumbent row's `value` failed validated parsing. */ | 'incumbent_malformed' /** The incumbent's recorded pid is confirmed alive under its recorded * identity. */ | 'incumbent_alive' /** The incumbent's liveness could not be confirmed either way (a failed * `ps` probe) — treated the same as alive: never reclaimed on mere * uncertainty. */ | 'incumbent_indeterminate'; export type DaemonOwnerClaimResult = { readonly claimed: true; readonly claim: DaemonOwnerClaim; } | { readonly claimed: false; readonly reason: DaemonOwnerClaimLossReason; /** The incumbent's recorded pid, present whenever a parsed incumbent * claim was actually read (absent for `own_identity_indeterminate`). */ readonly incumbentPid?: number; /** The liveness verdict against the incumbent's recorded identity, * present for `incumbent_alive`/`incumbent_indeterminate`. */ readonly verdict?: RecordedPidLiveness; }; /** Attempt to claim exclusive daemon ownership for this process, using * `token` as the unpredictable per-invocation discriminator the caller * generated. Synchronous — every underlying operation (identity capture, * liveness probe, sqlite) is synchronous, and this must complete before the * caller does any other fallible startup work. * * Only a `dead` incumbent is ever reclaimed, via a snapshot-conditioned * compare-and-set; `alive` and `indeterminate` incumbents cause an immediate * loss with no row mutation at all. A malformed incumbent also loses without * deletion or probing — this primitive never repairs or clears a bad row; a * future winning claimant's CAS naturally supersedes it once its OWN pid is * confirmed dead... except a malformed row can never be proven dead (no pid * to probe), so a malformed incumbent can only ever be lost against, never * reclaimed, by this primitive alone. That is intentional: this module never * guesses at repair. */ export declare function claimDaemonOwnership(token: string): DaemonOwnerClaimResult; /** Release exclusive daemon ownership, iff the persisted row still equals * `claim` EXACTLY (key present and value byte-identical to this invocation's * own winning claim). This is a conditional delete, not an unconditional one: * a caller must never release a row a successor has since won (e.g. after * this invocation's claim was already reclaimed via the dead-incumbent CAS * path while this process lingered mid-teardown). */ export declare function releaseDaemonOwnership(claim: DaemonOwnerClaim): { readonly released: boolean; };