Status: ✅ Complete (All Phases)
Spec Reference: FW-16-event-based-workflow-triggers.md
Last Updated: 2026-03-17
Overview
FW-16 provides a domain event system for workflow triggers: an event registry (fw_workflow_events), an organization-scoped event log (fw_domain_events), and platform-layer event publication (publishEvent()). Cores publish events via the Platform Integration Layer; the FW automation engine consumes events and starts workflows. Date-relative triggers and event filtering are supported.
Integration Points (from Spec)
Platform Layer Contract
- Event publication:
publishEvent({ event_name, payload, organization_id, site_id? })insrc/platform/events/publishEvent.ts - Event types:
src/platform/events/types.ts; event names aligned withfw_workflow_events.event_name - Documentation:
src/platform/events/README.mdfor cores integrating with FW-16
Event Contracts
- Event payloads must conform to the JSON Schema in
fw_workflow_events.payload_schemafor the givenevent_name. - New events are registered via seed migrations (insert into
fw_workflow_events). See EVENT_CONTRACTS.md for planned and existing event names. - Idempotency and retry semantics are documented in EVENT_CONTRACTS.md; FW-16 logs events in
fw_domain_eventsand marks them processed viafw_process_domain_event().
Security and Tenant Isolation
- Event registry (
fw_workflow_events) is global and read-only for authenticated users. - Event log (
fw_domain_events) is scoped byorganization_id; RLS useshas_org_access(auth.uid(), organization_id)(or platform equivalent). Insert allowed for authenticated users in org. - Event publication requires organization context; payloads must not contain PHI beyond what is necessary for workflow context.
Phase 2: Event Schema Registry Expansion
Spec: FW-16-PHASE-2-EVENT-SCHEMA-EXPANSION.mdStatus: 📋 Specification (Not Started) Phase 2 adds event governance on top of the FW-16 event system without redefining durable execution (FW-46) or changing the core publish/trigger flow.
Phase 2 Integration Additions
Updated Platform Layer Contract
Related Docs
- FW-16 Spec
- FW-16 Phase 2 Spec
- PLATFORM_INTEGRATION_LAYERS.md — FW-16 Event Publishing Integration Layer
- EVENT_CONTRACTS.md
- CROSS_CORE_INTEGRATIONS.md