Skip to main content
Version: 1.0.0
Status: 🔨 In Progress
Last Updated: 2026-02-23
Spec: PM-19 PM-Triggered Business Rule Automation
Constitution Reference: Section 1.3 (Integration Patterns), Section 12 (Automation Governance)

Overview

PM-19 extends the FW-03 Automation Engine to support PM events as automation triggers. Billing admins can create rules that run when claim status changes (e.g. denied), charge is approved, or payment is posted. The automation executor subscribes to the cl_pm_events channel and matches rules by trigger_type and trigger_config.
Note on channel naming: The cl_pm_events channel uses a cl_ prefix because it was originally established for CL↔PM cross-core events. PM-only events reuse this channel for consistency with EVENT_CONTRACTS.md. A future rename to pm_events may be considered if the channel scope is formalized.
Key behavior:
  • Trigger type: pm_event (stored as trigger_type: 'pm_event' in fw_automation_rules)
  • Trigger config (JSONB): { "event_type": string, "new_status"?: string, "payer_id"?: string | null }
  • Channel: cl_pm_events (EVENT_CONTRACTS)
  • Governance: All executions logged to fw_automation_logs; circuit breaker and dry-run per constitution §12.

Quick Reference

Decision Tree

  1. Receive PM event on cl_pm_events.
  2. Load rules where trigger_type = 'pm_event'.
  3. Match trigger_config.event_type to payload event_type.
  4. Apply optional filters (new_status, payer_id) when configured.
  5. Execute actions for matching rules and persist run logs to fw_automation_logs.

Pattern Library

  • Event subscriber pattern: FW-03 consumes PM events and drives automation dispatch.
  • Publisher pattern: PM-07/PM-08/PM-09 emit domain events with automation-ready payloads.
  • Contract-first pattern: Payload shape governed by EVENT_CONTRACTS.md.

Common Mistakes

Pre-Flight Checklist

  • Event payload includes organization_id.
  • Rule execution enforces rule.organization_id = event.organization_id.
  • Runtime writes execution trails to fw_automation_logs.
  • Dry-run/circuit-breaker behavior validated for high-volume bursts.
  • Payload schema matches EVENT_CONTRACTS.md definitions.

Integration Points


Event Contracts (Consumed by FW-03)

Payload schemas are defined in EVENT_CONTRACTS.md. This section summarizes the PM events as automation triggers contract for PM-19.

Event types available as triggers

Trigger config shape (FW-03 rule)

Stored in fw_automation_rules.trigger_config (or equivalent):
Matching rules: Executor loads rules where trigger_type = 'pm_event' and trigger_config.event_type matches the event; then applies optional filters new_status and payer_id. Omitted filter = any value. Example rule (persisted for Executor to load and match):
The Executor subscribes to cl_pm_events, receives an event, loads rules where trigger_type = 'pm_event' and trigger_config.event_type matches (e.g. claim_status_changed), then applies optional filters (new_status, payer_id). Matching rules are executed in order; actions run with event payload for context.

Multi-tenancy and security

  • Event payloads MUST include organization_id.
  • Automation executor MUST only run rules where rule.organization_id = event.organization_id.
  • Payloads use IDs only (no PII/PHI); actions resolve display data via authorized APIs.

API Contracts

No new synchronous APIs. All integration is event-based (subscribe to cl_pm_events).

References