import {
  riskDataGapSeconds,
  riskDeltaAbs,
  riskDrawdownPct,
  riskHedgeFailures,
  riskStatus
} from "./metrics";

export interface RiskMetricSnapshot {
  deltaAbs: number;
  hedgeFailures: number;
  dataGapSeconds: number;
  drawdownPct: number;
  halted: boolean;
  haltReason?: string;
}

export function observeRiskMetrics(snapshot: RiskMetricSnapshot): void {
  riskDeltaAbs.set(snapshot.deltaAbs);
  riskHedgeFailures.set(snapshot.hedgeFailures);
  riskDataGapSeconds.set(snapshot.dataGapSeconds);
  riskDrawdownPct.set(snapshot.drawdownPct);

  const reason = snapshot.halted ? snapshot.haltReason ?? "unknown" : "running";
  riskStatus.set({ reason }, snapshot.halted ? 1 : 0);
}
