/** * cpu-triage — start/read pair for the device CPU diagnostic. * * The measurement samples for at least one full 120 s reconcile cycle, because * anything shorter catches a random phase of a sawtooth and produces * contradictory answers (see `platform/scripts/cpu-triage.sh`). No admin tool * exceeds a 12 s envelope, so the run is detached and the caller polls. * * Three files per run live under `/logs/`: * * cpu-triage-.meta.json written here at start * cpu-triage-.json written by the runner, STREAMING * cpu-triage-.status written by the runner, last * * `.status` is the only readiness signal. The result file exists from the first * byte of output and is half-written for the whole window, so keying on it * reports a sampling run as complete. */ /** Shortest window the measurement is trustworthy over — one reconcile cycle. */ export declare const MIN_WINDOW_SEC = 120; /** Runs retained on disk. Older runs are pruned when a new one starts. */ export declare const RETAINED_RUNS = 20; export interface CpuTriagePaths { /** `platform/scripts/cpu-triage.sh` */ scriptPath: string; /** `platform/scripts/cpu-triage-run.sh` */ runnerPath: string; /** `/logs` — where per-run files live */ logsDir: string; /** brand log receiving the op=start line */ serverLog: string; } export interface StartOptions { windowSec?: number; intervalSec?: number; thresholdPct?: number; /** A peer brand on the previous build, for like-for-like comparison. */ control?: string; } export interface RunMeta { runId: string; startedAt: string; expectedCompleteAt: string; windowSec: number; args: string[]; } /** * `fault` separates a genuine defect the operator must act on (a missing * script) from an ordinary empty state (nothing has been started yet). Only a * fault is surfaced as an MCP error. */ export interface Refusal { ok: false; reason: "script-missing" | "runner-missing" | "window-too-short" | "no-runs" | "run-not-found"; fault: boolean; detail: string; } export type StartOutcome = ({ ok: true; resultPath: string; } & RunMeta) | Refusal; export type ReadOutcome = { ok: true; status: "running"; runId: string; startedAt: string; expectedCompleteAt: string; windowSec: number; } | { ok: true; status: "complete"; runId: string; exitCode: number; report: unknown; } | { ok: true; status: "failed"; runId: string; exitCode: number; stderr: string; detail?: string; } | Refusal; /** Injection seam so tests drive start without spawning a real process. */ export type SpawnRunner = (command: string, args: string[]) => void; /** * Start a detached triage run. Returns as soon as the run handle is on disk; * the measurement continues in a process this one does not hold open. */ export declare function startCpuTriage(paths: CpuTriagePaths, opts: StartOptions, spawnRunner?: SpawnRunner): StartOutcome; /** Read a triage run. Defaults to the most recent. */ export declare function readCpuTriage(paths: CpuTriagePaths, opts: { runId?: string; }): ReadOutcome; //# sourceMappingURL=cpu-triage.d.ts.map