/** * RuntimeOwner — the detached per-session process that makes live control honest. * * Responsibilities: * - hold the {@link SessionLease} (single writer), * - own an injected SDK session transport, * - serve owner-routed primitives over the {@link ControlServer} endpoint, * - be the SOLE writer of the severity event stream, * - heartbeat the lease. * * Stateless `gjc harness` CLI calls reach the owner via {@link resolveOwner} + the endpoint. */ import { ControlServer, type EndpointHandler } from "./control-endpoint"; import { type FinalizeChecks, type ValidationCommandSpec } from "./finalize"; import { heartbeat, releaseLease, type SessionLease } from "./session-lease"; import { type HarnessSessionTransport } from "./session-transport"; import { appendEvent, writeSessionState } from "./storage"; export interface OwnerOptions { root: string; sessionId: string; transport: HarnessSessionTransport; ownerId?: string; ttlMs?: number; heartbeatMs?: number; acceptanceTimeoutMs?: number; clock?: () => number; finalizeChecks?: FinalizeChecks; validationCommands?: ValidationCommandSpec[]; /** Test seam for deterministic control-endpoint teardown failures. */ controlServerFactory?: (socketPath: string, handler: EndpointHandler) => ControlServer; /** Test seam for deterministic lease-release teardown failures. */ leaseRelease?: typeof releaseLease; /** Test seam for deterministic lease-heartbeat behavior (e.g. renewal barriers). */ leaseHeartbeat?: typeof heartbeat; /** Test seams for frame persistence failures. */ framePersistence?: { appendEvent?: typeof appendEvent; writeSessionState?: typeof writeSessionState; }; /** Test seams; production retries verified shutdown without a finite limit. */ cleanupRetryMs?: number; cleanupRetryLimit?: number; } export interface OwnerStartInfo { ownerId: string; socketPath: string; leaseEpoch: number; } export declare class RuntimeOwner { #private; readonly ownerId: string; constructor(opts: OwnerOptions); start(): Promise; stop(): Promise; } export interface ResolvedOwner { live: boolean; socketPath: string | null; lease: SessionLease | null; } /** Determine whether a live owner currently holds the session (for CLI routing). */ export declare function resolveOwner(root: string, sessionId: string): Promise; /** * Owner liveness for verbs that do not route to the owner (e.g. `classify`): a routable owner * has a live lease and a socket endpoint. This is the same lease/socket probe `observe` uses to * decide routing, so non-routing verbs derive `ownerLive` consistently instead of assuming the * owner is gone (which would misclassify a live owner as vanished/restart-clean). */ export declare function resolveOwnerLive(root: string, sessionId: string): Promise;