/** * * Single top-level command that aggregates lease observability for * the whole project root and returns a summary envelope suitable * for dashboards / pipelines: * * - per-kind counts (same as peaks lease-metrics) * - leak rate (estimatedActive / estimatedLeaked) * - per-rid breakdown: which request ids are still "alive" * (i.e. the rid has a spawn event with no terminal) * - per-role breakdown: lease spawns split by role * - per-isolation breakdown: 'worktree' | 'container' | 'none' * (Part 8 adds 'container') * * The per-rid / per-role / per-isolation breakdowns use the * `rid` / `role` fields on the observability detail (Part 4.A * emitter passes these). The 'isolation' field is read off the * underlying dispatch record via the readObservabilityEvents * reader — but the events themselves don't carry isolation * mode. To get that, we walk the dispatch records (not events) * and join on the dispatch's `isolation` field. This is a * cross-file read but the operation is cheap (each session's * dispatch records are a small JSON set). * * Why this is a separate command from `peaks lease-metrics`: * `lease-metrics` answers "what events did I record?" (event * stream semantics). `lease-stats` answers "what's the project * status right now?" (state semantics). The two compose: * `lease-metrics --all-sessions` is the input, `lease-stats` * is the answer. */ import type { Command } from 'commander'; import { type ProgramIO } from '../cli-helpers.js'; import { type RateStats } from './lease-metrics-commands.js'; type RidCount = { rid: string; count: number; }; type RoleCount = { role: string; count: number; }; type IsolationCount = { isolation: 'worktree' | 'container' | 'none'; count: number; }; type LeaseStats = { readonly projectRoot: string; readonly sessionCount: number; readonly totalLeaseEvents: number; readonly rate: RateStats; readonly perRid: ReadonlyArray; readonly perRole: ReadonlyArray; readonly perIsolation: ReadonlyArray; }; export declare function computeLeaseStats(args: { projectRoot: string; eventsBySession: ReadonlyArray<{ sessionId: string; events: ReadonlyArray; }>; }): LeaseStats; export declare function registerLeaseStatsCommand(parent: Command, io: ProgramIO): void; export {};