Overview
FW-49 adds execution deadline enforcement for workflow runs using a pg_cron-triggered watchdog (workflow-timeout-watchdog) that invokes the workflow-timeout-checker Edge Function. It integrates with FW execution data, FW-47 dead letter handling, FW-25 compensation, and PF-10 notifications.
Integration Points (from Spec)
API / Edge Function Contracts
- Watchdog edge function:
supabase/functions/workflow-timeout-checker/index.ts- Triggered by pg_cron every 5 minutes.
- Reads timeout settings from
fw_module_settings. - Finds overdue executions (
deadline_at < now()) and applies configuredon_timeoutaction (fail,cancel,escalate). - Finds at-risk executions by warning threshold and emits one-time warning notifications.
- Deadline extension edge function:
supabase/functions/extend-execution-deadline/index.ts- Requires authenticated user and admin authorization.
- Extends
deadline_at, resets warning sent flag, records audit event.
Platform Integration Layer Usage
Security and Tenant Isolation
- Timeout checks operate with service role context for scheduled cross-tenant scanning; tenant identity is preserved in all writes/events.
- User-initiated deadline extensions require role and organization access checks before mutation.
- Notifications and DLQ entries include
organization_idfor downstream tenant-safe handling. - Timeout error messages and extension reasons are sanitized and must not include PHI/PII.
Event Contracts
FW-49 publishes planned workflow timeout events:workflow.execution.timed_out- Consumers: FW-47 (DLQ), FW-25 (compensation), monitoring/analytics listeners.
workflow.execution.deadline_extended- Consumers: audit trail and monitoring listeners.