Files
electric-cherry/src/lib/watchdog.ts
T
josh 981fb27c1c Preserve deleted server history
Retain historical server identities, results, and evidence after deletion. Mark archived entries as Deleted and prevent old work from targeting servers that reuse the same name.

Fixes #16.
2026-09-27 21:48:55 -04:00

51 lines
1.5 KiB
TypeScript

import type { DriftPlanFile } from './drift-plan.js';
export type WatchdogState = 'open' | 'recovering' | 'attention' | 'resolved' | 'dismissed';
export interface WatchdogIncident {
id: string;
server: string;
server_deleted_at?: string | null;
kind: 'health' | 'drift';
state: WatchdogState;
summary: string;
details: string;
first_seen_at: string;
last_seen_at: string;
finished_at: string | null;
failures: number;
cycle: number;
operation_stage?: string | null;
}
export interface WatchdogEvidence {
reason?: string;
containerState?: string | null;
files?: DriftPlanFile[];
fingerprint?: string;
}
export interface WatchdogAction {
id: string;
incident_id: string;
action: 'restart' | 'rebuild';
operation_id: string;
campaign_id: string | null;
created_at: string;
cycle: number;
operation_state: string | null;
operation_stage: string | null;
operation_error: string | null;
}
export interface WatchdogOverview {
enabled: boolean;
lastScanAt: string | null;
scanError: string | null;
incidents: WatchdogIncident[];
}
export interface WatchdogDetail {
incident: WatchdogIncident;
events: { id: number; created_at: string; message: string }[];
actions: WatchdogAction[];
}
export const watchdogStateLabels: Record<WatchdogState, string> = {
open: 'Detected', recovering: 'Recovering', attention: 'Needs attention', resolved: 'Resolved', dismissed: 'Dismissed'
};