Loop Engine

Core Concepts

What is a Loop?

The problem

Enterprise AI systems fail when actions are not bounded by explicit state, policy, and traceability.
Loop Engine provides finite states, deterministic transition checks, and event traces that make decisions auditable.

A loop is not a workflow

| | Workflow | Loop | |---|---|---| | Unit of work | Task | Outcome | | State | Implicit | Explicit and named | | Actors | Generic user/system | human / automation / ai-agent / webhook / system | | Failure model | Usually generic step errors | Guard failures and attributed rejections | | Learning | External or absent | Structured signals and measurable outcomes |

Anatomy of a loop (LoopDefinition)

  • id: LoopId
  • version: string
  • description: string
  • domain: string
  • states: StateSpec[]
  • initialState: StateId
  • transitions: TransitionSpec[]
  • outcome: OutcomeSpec
  • participants?: string[]
  • spawnableLoops?: LoopId[]
  • metadata?: Record<string, unknown>

Use optional fields (participants, spawnableLoops, metadata) only when needed by your platform model.

Lifecycle (LoopStatus)

1OPEN -> IN_PROGRESS -> CLOSED
2OPEN -> IN_PROGRESS -> ERROR
3OPEN -> IN_PROGRESS -> CANCELLED

Real example (abbreviated from loops/scm/procurement.yaml)

1id: scm.procurement
2version: 1.0.0
3domain: scm
4description: Purchase order lifecycle from requisition through settlement
5states:
6 - id: OPEN
7 - id: PO_CONFIRMED
8 - id: RECEIVED
9 - id: INVOICE_MATCHED
10 - id: SETTLED
11 isTerminal: true
12initialState: OPEN
13transitions:
14 - id: confirm_po
15 from: OPEN
16 to: PO_CONFIRMED
17 allowedActors: [human, automation, ai-agent]
18 guards:
19 - id: approval_obtained
20 severity: hard
21 evaluatedBy: external
22 description: PO must be approved before confirmation
23 failureMessage: PO confirmation requires explicit approval
24outcome:
25 id: po_settled
26 description: Purchase order fully settled
27 valueUnit: po_settled
28 measurable: true