/** * GFI Observability Read Model * * Pure domain model for building workspace-level GFI snapshots. * Partitions sessions into active vs stale and produces an authoritative snapshot * for operator visibility. * * PRI-78: GFI Observability */ import type { GfiPolicy, GfiSource, GfiSnapshot } from './gfi-types.js'; export interface GfiReadModelInput { sessions: { sessionId: string; /** Defaults to 0 if omitted */ currentGfi?: number; gfiBySource?: Partial>; lastErrorSource?: string; /** Defaults to 0 if omitted */ consecutiveErrors?: number; lastGfiDecayAt?: number; dailyGfiPeak?: number; /** Defaults to 0 if omitted — session older than cutoff is classified stale */ lastActivityAt?: number; }[]; nowMs: number; /** Sessions with lastActivityAt < nowMs - staleCutoffMs are classified stale. Default: 2 hours */ staleCutoffMs?: number; policy?: GfiPolicy; } /** * Workspace-level GFI snapshot — partitions sessions into active vs stale. * * Invariant: `active === null` iff `activeSessionCount === 0` (no active sessions exist). * Invariant: `staleGfiRange === null` iff `staleSessionCount === 0` (not an error state). */ export interface GfiWorkspaceSnapshot { /** * Snapshot for the highest-GFI active session. * Null when there are no active sessions (all stale, or no sessions exist). */ active: GfiSnapshot | null; staleSessionCount: number; /** * Min/max GFI across all stale sessions. * Null when staleSessionCount === 0 (no stale sessions — not an error state). */ staleGfiRange: { min: number; max: number; } | null; totalSessionCount: number; activeSessionCount: number; generatedAt: string; } export interface GfiWorkspaceHealthAssessment { status: 'healthy' | 'degraded'; reason: string; staleGfiDegradedThreshold: number; } export declare function classifyGfiWorkspaceHealth(snapshot: GfiWorkspaceSnapshot, options?: { staleGfiDegradedThreshold?: number; }): GfiWorkspaceHealthAssessment; /** * Build a workspace-level GFI snapshot from session data. * * Algorithm: * 1. Default stale cutoff to 2 hours if not provided * 2. Partition sessions into active (lastActivityAt >= nowMs - staleCutoffMs) and stale * 3. Select active session with highest currentGfi (tie-break: most recent lastActivityAt) * 4. Build GfiSnapshot for selected active session using createGfiSnapshot * 5. Compute staleGfiRange from stale sessions' currentGfi values * 6. Return GfiWorkspaceSnapshot * * Key invariant: stale sessions do NOT influence the active snapshot. * This prevents old UAT sessions with GFI=197.8 from making current health look critical. */ export declare function buildGfiWorkspaceSnapshot(input: GfiReadModelInput): GfiWorkspaceSnapshot; //# sourceMappingURL=gfi-read-model.d.ts.map