export type ProcessIdentityPlatform = "linux" | "darwin" | "win32"; export type ProcessIdentitySource = "procfs_stat" | "proc_pidinfo" | "win32_process_times"; export type ProcessIdentityUnknownReason = "invalid_pid" | "unsupported_platform" | "permission_denied" | "malformed_response" | "helper_unavailable" | "helper_failed" | "io_error"; export interface KnownProcessIdentity { status: "known"; pid: number; platform: ProcessIdentityPlatform; source: ProcessIdentitySource; /** Opaque locale-independent kernel birth token, compared byte-for-byte. */ startToken: string; /** Kernel-observed process-group id at the same observation. */ processGroupId: number; } export interface MissingProcessIdentity { status: "missing"; pid: number; platform: string; } export interface UnknownProcessIdentity { status: "unknown"; pid: number; platform: string; reason: ProcessIdentityUnknownReason; } export type ProcessIdentity = KnownProcessIdentity | MissingProcessIdentity | UnknownProcessIdentity; export type ProcessIdentityComparison = "same" | "different" | "missing" | "unknown"; export type LinuxProcessState = "R" | "S" | "D" | "Z" | "T" | "t" | "X" | "x" | "K" | "W" | "P" | "I"; export interface ProcessObservation { readonly identity: ProcessIdentity; /** Mutable Linux execution state from the same proc-stat read as identity. */ readonly linuxState: LinuxProcessState | null; } export interface ProcessIdentityReader { read(pid: number): ProcessIdentity; self(): ProcessIdentity; } export interface ProcessObservationReader { observe(pid: number): ProcessObservation; } export interface ProcessHelperExecution { status: number | null; stdout: string; stderr: string; errorCode?: string; } /** @deprecated Use {@link ProcessHelperExecution} — the shape is not Darwin-specific. */ export type DarwinHelperExecution = ProcessHelperExecution; export interface ProcessIdentityServiceOptions { platform?: string; selfPid?: number; readTextFile?: (path: string) => string; /** Absolute path to the bundled proc_pidinfo helper; null disables it. */ darwinHelperPath?: string | null; runDarwinHelper?: (path: string, pid: number) => ProcessHelperExecution; /** * OPT-IN win32 birth-time reader. Absent (the production default) keeps * win32 `unsupported_platform`, so every consumer that fails closed there * today — run capture, the orphan reaper, the daemon writer lease — is * untouched. A lane that needs a Windows identity passes * {@link executeWin32ProcessTimes} explicitly and owns the cost. */ runWin32Reader?: (pid: number) => ProcessHelperExecution; } /** Parse Linux proc stat fields 3 (state), 5 (pgrp), and 22 (starttime). */ export declare function parseLinuxProcStatObservation(raw: string, expectedPid: number): ProcessObservation; /** Legacy identity-only projection; persisted and wire-facing bytes stay unchanged. */ export declare function parseLinuxProcStat(raw: string, expectedPid: number): ProcessIdentity; export declare function observeProcess(identity: ProcessIdentityReader, pid: number, observation?: ProcessObservationReader): ProcessObservation; /** Strict parser for the bundled Darwin helper's locale-independent protocol. */ export declare function parseDarwinHelperOutput(raw: string, expectedPid: number): ProcessIdentity; export declare function compareProcessIdentity(expected: KnownProcessIdentity, observed: ProcessIdentity): ProcessIdentityComparison; export declare function isKnownProcessIdentity(value: unknown): value is KnownProcessIdentity; /** * Windows birth-time reader. Windows exposes no `/proc`, so the kernel's own * `GetProcessTimes` creation time is read through the absolute System32 * PowerShell (same pinned-path discipline as the `taskkill` owner) and printed * as a locale-independent FILETIME. Blocking — warm it is sub-second, but a * cold PowerShell on a loaded host takes many seconds — so it is opt-in per * lane rather than a default for every spawn. */ export declare function executeWin32ProcessTimes(pid: number): ProcessHelperExecution; /** Strict parser for the win32 reader's locale-independent protocol. */ export declare function parseWin32ReaderOutput(raw: string, expectedPid: number): ProcessIdentity; export declare class ProcessIdentityService implements ProcessIdentityReader { private readonly platform; private readonly selfPid; private readonly readTextFile; private readonly darwinHelperPath; private readonly runDarwinHelper; private readonly runWin32Reader?; private cachedSelf; constructor(options?: ProcessIdentityServiceOptions); read(pid: number): ProcessIdentity; self(): ProcessIdentity; private readLinux; private readDarwin; private readWin32; } export declare const defaultProcessIdentityService: ProcessIdentityService; export declare function createProcessObservationReader(options?: ProcessIdentityServiceOptions): ProcessObservationReader; export declare const defaultProcessObservationReader: ProcessObservationReader; //# sourceMappingURL=process-identity.d.ts.map