Examples
Workflow engine + Loop Engine
Runtime flow
| Stage | Role in this pattern |
| --- | --- |
| Provider | AI agent inside a workflow activity proposes a transition (recommendation + evidence) |
| Loop + Guards | Loop Engine evaluates policy before the workflow schedules downstream side effects |
| Channel | Human approval activity (Slack, ticketing UI, or in-app) resumes workflow only after governed transition |
| Integration | Temporal activity / Salesforce flow step executes durable work after executed status |
| Evidence | Loop transition evidence linked to workflow run id / Salesforce record id for audit |
1Workflow (Temporal / Salesforce)2 │3 ├─ activity: propose AI decision4 │ ↓5 │ Provider6 │ ↓7 │ Loop + Guards ←── Loop Engine (governance)8 │ ↓9 │ Channel (human)10 │ ↓11 └─ activity: execute approved work ←── Integration (durable execution)12 ↓13 Evidence (both layers)Temporal composition
Temporal owns: retries, timers, sagas, long-running coordination.
Loop Engine owns: whether a named transition may commit, with which actor, and with what evidence.
Typical sequence:
- Workflow reaches a decision checkpoint activity.
- Activity calls Provider adapter → submits transition candidate.
engine.transitionruns guards; may returnpendingfor human Channel step.- On
executed, workflow continues to side-effect activities (deploy, CRM update, ticket close).
1"cmt">// @no-typecheck2"cmt">// After Loop Engine returns executed — Temporal runs durable side effects.3const decision = await engine.transition({4 aggregateId: workflowRunId as never,5 transitionId: "approve_change" as never,6 actor: resolvedHumanActor,7 evidence: { workflowId: ctx.workflowId, runId: ctx.runId }8});9 10if (decision.status !== "executed") {11 throw new ApplicationFailure("Governance blocked", "GOVERNANCE_BLOCKED");12}13"cmt">// continue workflow: call external Integration APIsSalesforce composition
Salesforce Flow / Apex often owns record updates and UI. Loop Engine governs approval transitions that Flow must not bypass:
- Provider step: classify opportunity risk or draft terms (AI agent actor).
- Loop + Guards: credit-policy guards, evidence-required fields.
- Channel: approver in Salesforce approval process or Slack via Cloud connector.
- Integration: Flow updates Opportunity only when loop instance is in approved state.
Same rule: Flow executes; Loop governs commit.
What this teaches
- Governance differentiation — workflows coordinate; loops authorize state changes.
- Deterministic boundaries — activities must check
executedvs. blocked/pending. - Human escalation — workflow waits on Channel, not on model stream end.
- Evidence — audit ties workflow id to loop transition evidence.
What this is not
- Loop Engine as a workflow engine replacement.
- Salesforce or Temporal “plugins” that hide guards behind prompts.
- An implied single npm package that embeds both runtimes — you compose explicitly.
Related
- Loop Engine vs Workflow Engines
- What is a Loop?
- Architecture
- Infrastructure Change Approval — SRE Channel + rollout Integration