/** * Gate, loop, and kernel event type constants. * * These are string-literal unions used as discriminators in ledger and * kernel-level event records. Keeping them as `const` arrays lets us derive * both the union type and a runtime membership set from a single source. */ // ── Gate events ────────────────────────────────────────────────────── export const GATE_EVENT_TYPES = [ "gate.requested", "gate.decision", "gate.blocked", "gate.warning", ] as const; export type GateEventType = (typeof GATE_EVENT_TYPES)[number]; // ── Loop events ────────────────────────────────────────────────────── export const LOOP_EVENT_TYPES = [ "loop.start", "loop.step", "loop.blocked", "loop.completed", "loop.stuck", "loop.budget_exhausted", ] as const; export type LoopEventType = (typeof LOOP_EVENT_TYPES)[number]; // ── Kernel events ──────────────────────────────────────────────────── export const KERNEL_EVENT_TYPES = [ "kernel.snapshot", "kernel.invalidated", "kernel.updated", ] as const; export type KernelEventType = (typeof KERNEL_EVENT_TYPES)[number]; // ── Union of all kernel-level event types ──────────────────────────── export type KernelLevelEventType = GateEventType | LoopEventType | KernelEventType; // ── Runtime membership checks ──────────────────────────────────────── const GATE_SET = new Set(GATE_EVENT_TYPES); const LOOP_SET = new Set(LOOP_EVENT_TYPES); const KERNEL_SET = new Set(KERNEL_EVENT_TYPES); export function isGateEventType(value: string): value is GateEventType { return GATE_SET.has(value); } export function isLoopEventType(value: string): value is LoopEventType { return LOOP_SET.has(value); } export function isKernelEventType(value: string): value is KernelEventType { return KERNEL_SET.has(value); }