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 thecl_pm_events channel and matches rules by trigger_type and trigger_config.
Note on channel naming: TheKey behavior:cl_pm_eventschannel uses acl_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 topm_eventsmay be considered if the channel scope is formalized.
- Trigger type:
pm_event(stored astrigger_type: 'pm_event'infw_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
- Receive PM event on
cl_pm_events. - Load rules where
trigger_type = 'pm_event'. - Match
trigger_config.event_typeto payloadevent_type. - Apply optional filters (
new_status,payer_id) when configured. - 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.mddefinitions.
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 infw_automation_rules.trigger_config (or equivalent):
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):
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 tocl_pm_events).
References
- EVENT_CONTRACTS.md — Payload schemas and channel
cl_pm_events - PM-19 Spec
- Constitution §12 (Automation Governance)