polix.triggers.processing

Event processing and trigger firing.

Provides the core event processing loop that evaluates trigger conditions, applies effects, and handles timing (before/instead/after). The main entry point is fire-event which processes all matching triggers for an event.

Conditions are evaluated using polix.unify/unify against a document built from the event and trigger context. This integrates triggers with the unified constraint-based policy system.

fire-event

(fire-event {:keys [state registry]} event)

Fires an event and processes all matching triggers.

Takes a context map containing :registry and :state, plus the event to fire. Returns a FireEventResult with updated state, registry, and processing results.

Processing order: 1. Before triggers (can set :prevented?) 2. Instead triggers (first match only, if not prevented) 3. After triggers (if not prevented) 4. At triggers (always processed)

Example:

(fire-event {:state {} :registry reg}
            {:type :entity/damaged :target-id "e-1" :amount 5})
;; => {:state {...}
;;     :registry {...}
;;     :event {:type :entity/damaged ...}
;;     :results [...]
;;     :prevented? false}