FrankenTerm

Workflow Engine

222 words1 min read4 subsectionsFrom the README at ft 0.15.21

On this page4
ComponentsTrigger-policy allowlists (ft-j0ufc)Workflow lifecycleIdempotency

A workflow is a registered handler that triggers on detected patterns. The engine runs them safely:

Components

  • Engine (workflows/engine.rs) — the orchestrator. Registers handlers, listens to the event bus, dispatches matching events to handlers.
  • Runner (workflows/runner.rs) — runs a single workflow execution. Persists state to workflow_executions. Enforces timeout + cancellation.
  • Lock (workflows/lock.rs) — per-pane workflow lock. Prevents two workflows from racing each other on the same pane. LockManagerHealth telemetry surface (ft-rai3h) tracks lock acquisition latency, hold time, and contention.
  • Handlers (workflows/handlers.rs) — built-in workflow implementations (HandleCompaction, HandleUsageLimits, HandleAuthRequired, HandleOnErrorCassSearch, others; see the Built-in Workflow Handler Catalog for the full list).
  • Traits (workflows/traits.rs) — the Workflow trait every handler implements. Required methods: name(), description(), handles(detection), steps(), execute_step(ctx, step_idx); defaulted ones include trigger_event_types(), supported_agent_types() and trigger_policy() (defaults to allow_all).

Trigger-policy allowlists (ft-j0ufc)

Workflows that act on high-trust panes can declare an allowlist:

rust
fn trigger_policy(&self) -> WorkflowTriggerPolicy {
    WorkflowTriggerPolicy::allowlist([trusted_pane_id])
}

The runner enforces the allowlist before any lock, audit row, or engine state is created. Refused triggers surface as WorkflowStartResult::SourcePaneNotTrusted and the originating source_pane_id is recorded for post-incident forensics. This closes the privilege-amplification class where a low-trust pane's output could fire a high-trust workflow whose actions land on a different pane.

Workflow lifecycle

TriggerEvent → trigger_policy check
                   │
                   ▼ pass
              acquire pane lock
                   │
                   ▼
              persist WorkflowExecution(state=Started)
                   │
                   ▼
              handler.execute(ctx)
                   │
              ┌────┼────┐
              ▼    ▼    ▼
          Success Failure Cancel
              │    │    │
              └────┼────┘
                   ▼
              persist WorkflowExecution(state=Final)
                   │
                   ▼ emit WorkflowCompleted event
              release pane lock

Idempotency

A workflow can declare itself idempotent. The engine then deduplicates triggers within a configurable window, so the same (pane_id, rule_id) event firing twice in 100 ms only runs the handler once.