import { type Stats } from "node:fs"; import { type KnownProcessIdentity, type ProcessIdentityReader, type ProcessObservation, type ProcessObservationReader } from "@claudexor/core"; /** Marker file whose presence turns a lease directory into the permanent * root-authority barrier (issue #165 D1). The barrier directory deliberately * carries NO top-level owner.json: a pre-fix claimant's lease parse fails * closed on it forever, so it can never quarantine the barrier and take over * a data root last served by a fixed runtime. */ export declare const ROOT_AUTHORITY_MARKER_FILE = "root-authority-v2.json"; /** * Filesystem anchor of the single-writer lease for a control endpoint. A Unix * socket FILE anchors its lease right next to itself; a named pipe is not a * filesystem entry (nothing can be created in `\\.\pipe\`), so its lease lives * in the daemon dir under the pipe's own final segment — which already carries * the config-dir digest, keeping concurrent daemons' leases distinct. */ export declare function writerLeaseAnchorPath(socketPath: string): string; /** * Effective single-writer lease address. Once the anchor directory carries the * permanent root-authority barrier marker (issue #165 D1/D4), the live claim * for every FIXED runtime moves to the nested `active.writer` slot inside the * barrier, so inspection, acquisition, termination and operator stop all keep * following one canonical address. Pre-fix runtimes never resolve the nested * slot — they contend on the anchor itself, where the opaque barrier refuses * them. Without a marker the anchor stays the (legacy-compatible) address. */ export declare function writerLeasePath(socketPath: string): string; export interface DaemonWriterLease { readonly path: string; /** Exact owner written into the lease. Runtime replacement binds its * admission and termination proof to this process instance, not just the * closure version shared by successive daemon processes. */ readonly owner: DaemonLeaseOwner; release(): void; } export interface DaemonLeaseOwner { pid: number; token: string; /** Birth identity of the owning daemon, recorded at acquisition so a later * terminator can verify it never signals a recycled pid (W3.5/sol #5). * Absent on legacy leases or when the platform cannot observe identity. */ identity?: KnownProcessIdentity; } export type DaemonLeaseOwnerCapability = { status: "capable"; reason: "identity_match" | "legacy_process_present"; observation: ProcessObservation; } | { status: "proven_stale"; reason: "process_missing" | "identity_mismatch" | "linux_zombie"; observation: ProcessObservation; } | { status: "unknown"; reason: "identity_unavailable" | "presence_unknown"; observation: ProcessObservation; }; export type DaemonWriterLeaseUnknownReason = "lease_unreadable" | "lease_unstable" | "invalid_lease_path" | "owner_missing" | "owner_unreadable" | "owner_malformed"; export type DaemonWriterLeaseStatus = { status: "absent"; path: string; } | { status: "owned"; path: string; owner: DaemonLeaseOwner; capability: DaemonLeaseOwnerCapability; } | { status: "unknown"; path: string; reason: DaemonWriterLeaseUnknownReason; }; /** Narrow synchronous seam used to deterministically exercise failure/race branches. */ export interface DaemonWriterLeaseFilesystem { lstat(path: string): Stats; readText(path: string): string; createLeaseDirectory(path: string): void; writeOwner(path: string, data: string): void; rename(from: string, to: string): void; remove(path: string): void; } export interface DaemonWriterLeaseDependencies { identity?: ProcessIdentityReader; /** Explicit observation capability; never inferred from an identity reader by property name. */ observation?: ProcessObservationReader; /** Signal-zero probe: return for present, throw an errno-bearing error otherwise. */ probeProcess?: (pid: number) => void; filesystem?: Partial; } /** Resolved filesystem seam. The root-authority in-place migration (C4) * shares it so its atomic steps stay deterministically observable in tests. */ export declare function resolveWriterLeaseFilesystem(deps: DaemonWriterLeaseDependencies): DaemonWriterLeaseFilesystem; export declare function classifyDaemonLeaseOwner(owner: DaemonLeaseOwner, deps?: DaemonWriterLeaseDependencies): DaemonLeaseOwnerCapability; /** Strict authority read: only a physically missing lease path is `absent`. */ export declare function inspectDaemonWriterLease(socketPath: string, deps?: DaemonWriterLeaseDependencies): DaemonWriterLeaseStatus; export declare function writerLeaseTombstonePath(leasePath: string, owner: DaemonLeaseOwner): string; /** Claim single-writer authority before any daemon journal is opened. */ export declare function acquireDaemonWriterLease(socketPath: string, deps?: { identity?: ProcessIdentityReader; }, acquisitionDeps?: Omit): DaemonWriterLease; /** * Lossy patch-compatible projection. `null` does not prove the lease path is * physically absent; authority-sensitive callers must use strict inspection. */ export declare function daemonLeaseOwner(socketPath: string): DaemonLeaseOwner | null; /** Raw signal-zero presence helper; daemon serviceability uses the classifier. */ export declare function processIsAlive(pid: number): boolean; //# sourceMappingURL=writer-lease.d.ts.map