/** * On-demand performance snapshot — the SINGLE implementation behind both * `doctor --perf` (printed locally for the customer) and the `perf_snapshot` * remote machine action (uploaded to the console via uploadDiagnostics). * * Lightness principle (per the monitor-mode contract): measurement is PULL * only. Nothing here installs a profiler, starts a timer, or samples in the * background — every number is collected in one shot, in a few seconds, and * the process that collected it exits. * * NON-BLOCKING BY CONTRACT: everything here uses async `spawn`, never * `spawnSync`. The remote action runs INSIDE the daemon — the same process * that answers verdict IPC for every live hook. A spawnSync benchmark froze * the daemon's event loop, so each benchmarked hook child asked the daemon, * got silence, waited out the full IPC response timeout (~2.5s) and fell back * to local evaluation: the snapshot reported "hook median 2605ms" on a machine * whose real per-event cost was milliseconds — the measurement was poisoning * itself. Async spawns keep the daemon answering during the benchmark, so the * number is the true production path (and real developer hooks keep their * fast path while a snapshot is being collected). */ export interface PerfProcessInfo { pid: number; name: string; /** Working set (resident) in MB. */ workingSetMB: number; /** Cumulative CPU seconds since process start. */ cpuSec: number; /** Process uptime in seconds (undefined when the OS query omits it). */ uptimeSec?: number; handleCount?: number; /** Command line, truncated — enough to identify daemon/gateway/watcher. */ cmd: string; } export interface PerfHotPathBench { /** Median ms to spawn a bare `node -e 0` — the OS+AV floor any per-event process pays. */ nodeSpawnFloorMs: number; /** Median end-to-end hook latency (live caches, live install). */ hookMedianMs: number; hookMinMs: number; hookMaxMs: number; hookRuns: number; /** cmd.exe doskey guard overhead vs a direct command (Windows, when installed). */ cmdGuardOverheadMs?: number; } export interface PerfDiskState { hookLogKB?: number; hookLogRotatedKB?: number; daemonLogKB?: number; discoverLogKB?: number; spoolKB?: number; /** Number of spooled (undelivered) telemetry events waiting for a flush. */ spoolBacklogCount?: number; /** Present when the machine has recorded failed update attempts. */ updateAttempts?: unknown; } export interface PerfSnapshot { collectedAt: string; cliVersion?: string; host: { platform: string; arch: string; cpus: number; totalMemMB: number; node: string; }; /** Resolved enforcement state — the numbers are only interpretable per mode. */ enforcement: { mode?: string; source?: string; policyHash?: string; }; hotPath: PerfHotPathBench; processes: PerfProcessInfo[]; totalWorkingSetMB: number; disk: PerfDiskState; /** Recent distress signals (machine's own root-cause ledger). */ distress: unknown[]; } /** Micro-bench of the per-event hot path: node spawn floor, hook end-to-end, cmd guard. */ export declare function benchHotPath(entryJs?: string): Promise; /** * Per-process footprint of every FullCourtDefense-owned process (daemon, MCP * gateways, desktop chat watcher, watchdog): working set, cumulative CPU, * uptime, handle count. On-demand only — this spawns ONE OS query and exits. */ export declare function collectProcessFootprint(): Promise; /** Disk footprint: our logs/spool sizes, spool backlog, update-attempt markers. */ export declare function collectDiskState(): PerfDiskState; export interface CollectPerfSnapshotInput { cliVersion?: string; /** Resolved enforcement state, supplied by the caller (daemon has the bundle already). */ mode?: string; source?: string; policyHash?: string; /** Entry JS for the hook micro-bench (defaults to process.argv[1]). */ entryJs?: string; } /** One-shot collection of the full snapshot. Completes in a few seconds. */ export declare function collectPerfSnapshot(input?: CollectPerfSnapshotInput): Promise; /** One-line human summary for machine-action result reporting. */ export declare function summarizePerfSnapshot(s: PerfSnapshot): string;