Packages
Loading
Loading
Packages
@loop-engine/guards provides deterministic policy checks that run inside transition execution.
1npm install @loop-engine/guardsGuards in this package are synchronous policy assertions wrapped as async functions. They do not call LLMs or network services.
GuardResult:
1interface GuardResult {2 passed: boolean3 code?: string4 message?: string5 metadata?: Record<string, unknown>6}1class GuardRegistry {2 register(guardId: string, evaluator: GuardEvaluator): void3 get(guardId: string): GuardEvaluator | undefined4 registerBuiltIns(): void5}registerBuiltIns() populates the registry with every guard exported from @loop-engine/guards (see "Built-in guards" below). Call it once on a fresh registry, or use the pre-populated defaultRegistry constant.
1import { createGuardRegistry } from "@loop-engine/guards"2import { guardId } from "@loop-engine/core"3 4const registry = createGuardRegistry()5registry.register(guardId("budget_available"), {6 async evaluate(context) {7 return {8 passed: context.evidence?.budget_ok === true,9 message: "Budget check failed"10 }11 }12})defaultRegistry (and GuardRegistry.registerBuiltIns()) pre-registers:
confidence-threshold (ConfidenceThresholdGuard)human-only (HumanOnlyGuard)evidence-required (EvidenceRequiredGuard)cooldown (CooldownGuard)Hard/soft severity is defined on each GuardSpec in @loop-engine/core. Runtime blocks on hard failures and records soft failures under _softGuardWarnings in transition evidence.