/**
 * Fallback Events — structured event emission for model fallback lifecycle.
 *
 * Events are emitted via ctx.ui.notify() with structured JSON payloads
 * (the activity log writer is session-scoped JSONL and not suitable for
 * cross-session event queries). The notify channel is observable by tests
 * and by the dashboard.
 */
// ─── Emit ─────────────────────────────────────────────────────────────────────
/**
 * Emit a structured fallback event via ctx.ui.notify().
 * The event is JSON-serialized so tests can parse and assert on the shape.
 */
export function emitFallbackEvent(ctx, event) {
    const tag = `[fallback-event] `;
    ctx.ui.notify(`${tag}${JSON.stringify(event)}`, "info");
}
// ─── Convenience Builders ─────────────────────────────────────────────────────
/** Build a fallback event for when the model switches to a fallback. */
export function buildFallbackEvent(from, to, reason, unitType) {
    return {
        type: "nerf.model.fallback",
        from,
        to,
        reason,
        unitType,
        timestamp: new Date().toISOString(),
    };
}
/** Build an event for when the primary model is restored. */
export function buildRestoredEvent(from, to, unitType) {
    return {
        type: "nerf.model.restored",
        from,
        to,
        reason: "primary_restored",
        unitType,
        timestamp: new Date().toISOString(),
    };
}
/** Build an event for when all fallbacks are exhausted. */
export function buildExhaustedEvent(from, reason, unitType) {
    return {
        type: "nerf.model.fallback_exhausted",
        from,
        to: "",
        reason,
        unitType,
        timestamp: new Date().toISOString(),
    };
}
