Workflow Engine
222 words1 min read4 subsectionsFrom the README at ft 0.15.21
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 toworkflow_executions. Enforces timeout + cancellation. - Lock (
workflows/lock.rs) — per-pane workflow lock. Prevents two workflows from racing each other on the same pane.LockManagerHealthtelemetry 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) — theWorkflowtrait every handler implements. Required methods:name(),description(),handles(detection),steps(),execute_step(ctx, step_idx); defaulted ones includetrigger_event_types(),supported_agent_types()andtrigger_policy()(defaults toallow_all).
Trigger-policy allowlists (ft-j0ufc)
Workflows that act on high-trust panes can declare an allowlist:
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.