Skip to content

Trigger rule schema

A trigger rule is a JSON object stored in automation.trigger_rules. The CLI accepts the same shape via lf automation create --file <path>.json.

Top-level fields

FieldTypeRequiredDescription
namestringyesHuman label shown in lf automation list and the web UI.
match_event_typestringyesOne of the producer event types (e.g. battle.finalized).
match_filterobjectnoFilter DSL. Default {} matches every event of the configured type.
action_kindenumyesOne of dispatch_workflow, webhook, notify.
action_configobjectyesSchema depends on action_kind (below).
is_activebooleannoDefault true. Disabled rules are not evaluated by the dispatcher.

Filter DSL

match_filter is a JSON object mapping a JSON Pointer (RFC 6901) path to a single matcher object. Multiple top-level keys combine with logical AND.

json
{
  "/winner_contender_id": { "eq": "<uuid>" },
  "/finalized_at": { "gt": "2026-08-01T00:00:00Z" }
}

The path is resolved against the event's payload JSONB. Reserved characters in path segments must be escaped per RFC 6901 (~0 for ~, ~1 for /).

OperatorArgument typeSemantics
eqscalarStrict JSONB equality
neqscalarStrict JSONB inequality
gtnumber or ISO-8601 stringStrictly greater-than
ltnumber or ISO-8601 stringStrictly less-than
containsstring or array elementLIKE for strings, JSONB ? containment for arrays

Unknown operators reject the rule at create time and fail closed at evaluation time.

Action schemas

dispatch_workflow

Inserts a row into lenses.workflow_runs for the configured workflow.

json
{
  "action_kind": "dispatch_workflow",
  "action_config": {
    "workflow_id": "<uuid>",
    "input_overrides": {
      "topic": "battle aftermath"
    }
  }
}
KeyRequiredNotes
workflow_idyesThe workflow you own.
input_overridesnoMerged with the workflow's default inputs.

webhook

Enqueues into audit.webhook_outbox. The Phase P3 outbox handles HMAC signing, retries, and dead-lettering.

json
{
  "action_kind": "webhook",
  "action_config": {
    "url": "https://hooks.example.com/lenserfight",
    "headers": {
      "X-Custom": "value"
    }
  }
}
KeyRequiredNotes
urlyesHTTPS only.
headersnoExtra request headers. The HMAC signature header X-LF-Signature is added by the outbox.

The delivered payload is:

json
{
  "event_type": "battle.finalized",
  "event_id": "<uuid>",
  "payload": { "...": "..." },
  "rule_id": "<uuid>",
  "webhook_version": 1
}

notify

Creates an in-app notification for the rule owner.

json
{
  "action_kind": "notify",
  "action_config": {
    "title": "Battle finished",
    "body": "Your battle just finalized — review the result.",
    "payload": {
      "deeplink": "/battles/<slug>"
    }
  }
}
KeyRequiredNotes
titleyesShort headline.
bodynoLonger text shown in the notification card.
payloadnoFree-form JSONB merged into notifications.payload.

Validation

The CLI rejects invalid rules client-side before INSERT:

  • action_kind not in the allowed set.
  • match_filter clauses whose value object has zero or multiple keys.
  • match_filter clauses whose operator is not in the frozen set.

Server-side validation is enforced by CHECK constraints and the automation.fn_eval_filter evaluator, which fails closed on unknown operators.