export interface WorkerAttribution { kind: 'unit' | 'unit-count' | 'invocation'; id: string; count: number; attribution: 'attributed' | 'unknown' | 'conflicting'; workspace?: string; group?: string; } export interface HostResourceSample { /** Start of collection on the source host; absent on legacy/unavailable snapshots. */ collectedAt?: string; supported: boolean; reason?: string; availMemGb?: number; load1?: number; cores?: number; loadRatio?: number; memPsiAvg10?: number; memPsiAvg60?: number; memPsiAvg300?: number; workerAttributions?: WorkerAttribution[]; workerWorkspace?: string; workerUnknown?: number; workerGroups?: Record; workers?: number; hostCliProcesses?: Record; workerUnits?: number; freeDiskGb?: number; workerCountingSource?: 'systemd-units-and-marked-processes' | 'owned-process-fallback'; } export interface WorkerCensus { attributions?: WorkerAttribution[]; workspace?: string; unknown?: number; byGroup?: Record; total: number; hostCliProcesses?: Record; units?: number; source?: HostResourceSample['workerCountingSource']; } export interface HostResourceReaders { now?: () => number; readText?: (path: string) => string; readDir?: (path: string) => string[]; uid?: number; groupNames?: string[]; workspace?: string; coreCount?: () => number; countWorkers?: () => number | undefined | WorkerCensus; countWorkerUnits?: () => number | undefined; listWorkerUnits?: () => string[] | undefined; statfs?: () => { bavail: number | bigint; bsize: number | bigint }; statfsPath?: (path: string) => { bavail: number | bigint; bsize: number | bigint }; paths?: string[]; } export function readLiveHostResources(readers?: HostResourceReaders): HostResourceSample; export function nearestDispatchPathSync(filename: string, fsOps?: { lstat?: (path: string) => { isDirectory(): boolean }; access?: (path: string, mode: number) => void }): string; export function countWorkerProcesses(readers?: HostResourceReaders): WorkerCensus | undefined; export function defaultCountWorkers(readers?: HostResourceReaders): number | undefined; export function countWorkerUnits(options?: { spawn?: (...args: any[]) => any }): number | undefined; export function listWorkerUnits(options?: { spawn?: (...args: any[]) => any }): string[] | undefined; export function parseMemAvailableGb(text: unknown): number | undefined; export function parseMemoryPsi(text: unknown): { avg10: number; avg60: number; avg300: number } | null; export function parseLoadAverages(text: unknown): { load1: number; load5: number; load15: number } | null; export function evaluateDispatchGate(live: HostResourceSample, thresholds: any): { ok: boolean; failures: any[]; thresholds: any };