Loop Engine

Packages

@loop-engine/signals

@loop-engine/signals detects patterns from LoopEvent[] and emits typed Signal objects.

Install

1npm install @loop-engine/signals

Engine API

1interface SignalEngine {
2 registerRule(rule: SignalRule): void
3 process(events: LoopEvent[]): Signal[]
4 subscribe(handler: (signal: Signal) => void): () => void
5}

Factory:

1createSignalEngine(): SignalEngine

createSignalEngine() pre-registers:

  • threshold-breach
  • state-dwell
  • repeated-guard-failure
  • loop-not-started

Built-in rule factories

1thresholdBreachRule(config: ThresholdRuleConfig): SignalRule
2stateDwellRule(config: StateDwellRuleConfig): SignalRule
3repeatedGuardFailureRule(config: RepeatedGuardFailureConfig): SignalRule
4loopNotStartedRule(config: LoopNotStartedConfig): SignalRule
1import { createSignalEngine } from "@loop-engine/signals"
2 
3const signalEngine = createSignalEngine()
4signalEngine.subscribe((signal) => {
5 console.log(signal.type, signal.subject, signal.confidence)
6})

Detection flow

Signals are detections, not actors. Application code decides what to do with them, including whether to start or transition loops.