import { type ChildProcess } from "node:child_process"; import { type ServiceAdapterStopAbandonment, type ServiceAdapterAttempt, type ServiceAdapterKernelStopPlan, type ServiceAdapterPreservedStop, type ServiceAdapterStopPlan, type ServiceAdapterContext, type ServiceDefinitionInput } from "@cotal-ai/workspace"; import { type LoadedServiceAdapter, type ResolvedServiceAdapter } from "./service-adapters.js"; import { serviceDefinitionStore, type ServiceDefinitionSnapshot } from "./service-definitions.js"; import { type ServiceInstance, type ServiceInstanceSnapshot } from "./service-instances.js"; export declare const PROCESS_SERVICE_CAPABILITIES: Readonly<{ multiInstance: true; foreground: true; logs: true; install: false; }>; /** Record an instance as `failed` when its exact recorded process is proven gone (its PID is dead, * names a later process, or belongs to an earlier boot) and no stop of ours explains the exit. A * native record that retains a stop request (see {@link retainedStopRequest}) is recorded `stopping` * under that request instead, since only that stop's own receipt can settle it. The caller holds * the definition's writer lock, so no launch or stop of it is in flight. Nothing is signalled, * relaunched or removed. Any other record is returned unchanged. */ export declare function settleExitedInstance(row: ServiceInstanceSnapshot): ServiceInstanceSnapshot; /** A record settled by {@link settleExitedInstance} or by its own failed start: its exact process * is gone and no stop receipt explains the exit. */ export declare function exitedWithoutStop(value: ServiceInstance): boolean; export type NativeStopEvidence = { requestId: string; publication: "published" | "unknown"; }; /** The native stop this record retains, or undefined. A native record with a process retains one * while it is `stopping`, or in a state a crash leaves behind, and its launch holds a stop request: * an earlier build recorded such a stop `unknown`. Only the adapter's own request-bound receipt * settles it; no start, stop, crash settlement or exit record replaces it. */ export declare function retainedStopRequest(value: ServiceInstance): NativeStopEvidence | undefined; /** Settle the native stop this record retains from its adapter's own evidence. The caller holds the * definition's writer lock. When the adapter confirms that request's `completed` receipt and the * exact process exit, it has released its reservation, and the record is recorded `stopped` with * that result, as a stop confirmed within its call would be. When it reports the child's refusal, * it has removed the request and released the reservation, and the record returns to what its * process shows, as after a refusal within the call. A record left `stopping` by a stopper that * exited before it published a request handed the child nothing, so it also returns to what its * process shows, as a stop that published nothing does within its call. Any other record, including * one whose adapter confirms less, is returned unchanged. */ export declare function settleRetainedNativeStop(definition: ServiceDefinitionSnapshot, row: ServiceInstanceSnapshot): Promise; /** Abandon the native stop `requestId` this record retains, on an operator's explicit request. The * caller holds the definition's writer lock. The adapter refuses unless no receipt settles the * request and its exact process and the stopper that published it have both exited; it then removes * the request and releases its reservation. The record is recorded `failed`, as a process that exited * without a confirmed stop, because what it stopped before it exited is not confirmed. */ export declare function abandonRetainedNativeStop(definition: ServiceDefinitionSnapshot, row: ServiceInstanceSnapshot, requestId: string): Promise<{ row: ServiceInstanceSnapshot; abandonment: ServiceAdapterStopAbandonment; }>; /** A broker's kernel-exit stop or a generic process stop that its stopper left `stopping` when it * exited before it observed the exit, once that exact process is gone. Only an operator abandons it. */ export declare function abandonableSignalStop(value: ServiceInstance): boolean; /** Abandon, on an operator's explicit request, the signal stop `requestId` this record retains (see * {@link abandonableSignalStop}). The caller holds the definition's writer lock, so the stopper that * recorded the request has exited. The record is recorded `failed`, as a process that exited without * a confirmed stop, because no exit was observed as that stop's own. */ export declare function abandonRetainedSignalStop(row: ServiceInstanceSnapshot, requestId: string): ServiceInstanceSnapshot; /** Settle every instance of one definition under its writer lock. */ export declare function settleExitedInstances(definition: ServiceDefinitionSnapshot): void; export declare function selectServiceInstance(rows: ServiceInstanceSnapshot[], id: string | undefined, allowMissing?: boolean): ServiceInstanceSnapshot | undefined; export declare function serviceLogPath(space: string, id: string, create?: boolean): string | undefined; export declare function serviceReadiness(row: ServiceInstanceSnapshot, definition: ServiceDefinitionInput, adapter?: { provider: LoadedServiceAdapter; context: ServiceAdapterContext; }): Promise; export declare function prepareProcessService(definition: ServiceDefinitionSnapshot): { program: string | undefined; adapter: ResolvedServiceAdapter | undefined; cliInvocation: string[] | undefined; env: NodeJS.ProcessEnv; launcher: import("@cotal-ai/workspace").ProcessIdentityRecord; }; /** A restart stops before it starts, and its start carries no maintenance attempt. Under a * maintenance journal the broker and manager adapters admit such a start only through * `maintenanceAdmitsStackWork`, so a restart either would refuse is refused here, before any stop * is prepared or made. It only reads; a journal written after it can still refuse the start. */ export declare function assertRestartAdmitted(definition: ServiceDefinitionSnapshot): void; type DefinitionHold = ReturnType["pin"]>; export declare function startProcessService(definition: ServiceDefinitionSnapshot, options: { instance?: string; newInstance?: boolean; foreground?: boolean; attempt?: ServiceAdapterAttempt; brokerInstance?: { instanceId: string; launchRequestId: string; }; replacement?: { instanceId: string; launchRequestId: string; }; }, held?: DefinitionHold): Promise<{ instance: ServiceInstanceSnapshot; noOp: boolean; child: undefined; exit: undefined; } | { instance: ServiceInstanceSnapshot; noOp: boolean; child: ChildProcess; exit: { done: Promise; observed: () => boolean; result: () => { code: number | null; signal: NodeJS.Signals | null; }; }; }>; /** Native preview imports only the pinned provider and performs its caller-scoped read. No * process signal, request publication or reservation is part of this pre-confirmation step. */ export declare function prepareNativeServiceStop(definition: ServiceDefinitionSnapshot, selected: ServiceInstanceSnapshot, withAgents?: boolean, preserved?: ServiceAdapterPreservedStop): Promise; /** Kernel-exit preview imports only the pinned provider and reads its exact binding and dependant * guards. No signal, reservation or record write is part of this pre-confirmation step. */ export declare function prepareKernelServiceStop(definition: ServiceDefinitionSnapshot, selected: ServiceInstanceSnapshot): Promise; /** Whole-set eligibility read before any member is stopped. The actual stop retains its own * per-effect checks: a cooperative definition reservation does not freeze a live process. */ export declare function preflightProcessServiceStop(definition: ServiceDefinitionSnapshot, selected: ServiceInstanceSnapshot): void; /** Only the stored creation-pinned process is signalled. Every escalation rechecks its identity. */ export declare function stopProcessService(definition: ServiceDefinitionSnapshot, selected: ServiceInstanceSnapshot, held?: DefinitionHold, native?: { plan?: ServiceAdapterStopPlan; withAgents: boolean; preserved?: ServiceAdapterPreservedStop; requestId?: string; }, kernel?: { plan?: ServiceAdapterKernelStopPlan; }): Promise<{ instance: ServiceInstanceSnapshot; noOp: boolean; kernelStop: import("@cotal-ai/workspace").ServiceAdapterKernelStopResult; } | { instance: import("@cotal-ai/workspace").LocalRecordSnapshot; noOp: boolean; nativeStop: import("@cotal-ai/workspace").ServiceAdapterStopResult; } | { instance: ServiceInstanceSnapshot; noOp: boolean; nativeStop?: undefined; }>; export declare function assertNoServiceUnitAttempts(space: string, name: string): void; export declare function removableServiceInstances(space: string, name: string): ServiceInstanceSnapshot[]; /** Called under the definition writer lock, after stopped/host/supervisor checks for every row. */ export declare function removeStoppedInstanceRecords(space: string, name: string): void; /** Read only bounded regular-file bytes; log data is not promised to be secret-redacted. */ export declare function readServiceLog(space: string, id: string, tail: number): { lines: string[]; omittedBytes: number; path: null; } | { lines: string[]; omittedBytes: number; path: string; }; /** One bounded raw log slice. File identity and byte offsets are local file facts, not global sequences. */ export declare function serviceLogSlice(space: string, id: string, position: { offset: number; dev: number; ino: number; } | undefined, tail: number): { file: { dev: number; ino: number; }; fromOffset: number; toOffset: number; sizeAtRead: number; bytes: Buffer; omittedBytes: number; replaced: boolean; truncated: boolean; } | undefined; export {}; //# sourceMappingURL=service-process.d.ts.map