Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt

Use this file to discover all available pages before exploring further.

Feature: SLA Management Platform Layer
Spec: PF-83
Last Updated: 2026-03-17

Overview

PF-83 introduced two new tables and extended pf_module_settings with SLA-related configuration columns. The migration was applied via the Supabase MCP execute_sql tool — no .sql file exists on disk in supabase/migrations/.

Tables Created

pf_sla_definitions (20 columns)

ColumnTypeNotes
idUUIDPK, gen_random_uuid()
organization_idUUIDFK → pf_organizations, tenant isolation
nameTEXTNOT NULL
descriptionTEXTNullable
sla_typeTEXTresponse_time, resolution_time, follow_up, custom
owning_coreTEXTWhich module owns this SLA (e.g., ce, hr)
trigger_event_typeTEXTEvent that starts the SLA clock
completion_event_typeTEXTEvent that stops the SLA clock
target_duration_hoursNUMERICDeadline in hours
warning_threshold_pctINTEGERDefault 80
escalation_configJSONBEscalation levels and notification targets
entity_match_configJSONBRules for matching events to entities
priority_overridesJSONBPer-priority deadline adjustments
priority_fieldTEXTWhich field to read priority from
is_activeBOOLEANDefault true
custom_fieldsJSONBDefault '{}'
created_atTIMESTAMPTZDefault now()
updated_atTIMESTAMPTZDefault now()
created_byUUIDFK → pf_profiles
updated_byUUIDFK → pf_profiles

pf_sla_instances (21 columns)

ColumnTypeNotes
idUUIDPK, gen_random_uuid()
organization_idUUIDFK → pf_organizations, tenant isolation
definition_idUUIDFK → pf_sla_definitions
entity_typeTEXTType of entity this instance tracks
entity_idUUIDID of the tracked entity
statusTEXTactive, at_risk, breached, completed, paused
started_atTIMESTAMPTZWhen the SLA clock started
deadline_atTIMESTAMPTZComputed deadline
completed_atTIMESTAMPTZWhen completed (nullable)
breached_atTIMESTAMPTZWhen breached (nullable)
paused_atTIMESTAMPTZWhen paused (nullable)
pause_reasonTEXTReason for pause (nullable)
elapsed_secondsNUMERICTotal elapsed time
remaining_secondsNUMERICTime remaining until deadline
percentage_elapsedNUMERICProgress percentage
trigger_event_idUUIDFK → fw_domain_events that started this instance
completion_event_idUUIDFK → fw_domain_events that completed this instance
custom_fieldsJSONBDefault '{}'
created_atTIMESTAMPTZDefault now()
updated_atTIMESTAMPTZDefault now()
deleted_atTIMESTAMPTZSoft delete (nullable)

RLS Policies

Both tables have RLS enabled with policies using the pf_has_org_access(organization_id) SECURITY DEFINER function:
  • SELECT: Authenticated users with org access
  • INSERT: Authenticated users with org access
  • UPDATE: Authenticated users with org access, WITH CHECK clause
  • DELETE: Authenticated users with org access

Settings Columns Added to pf_module_settings

SLA-related configuration is stored in the existing pf_module_settings table via its custom_fields JSONB column. No new columns were added to the table schema.

Rollback Procedure

To remove PF-83 tables (destructive — all SLA data will be lost):
-- Drop instances first (FK dependency)
DROP TABLE IF EXISTS pf_sla_instances CASCADE;
DROP TABLE IF EXISTS pf_sla_definitions CASCADE;
Warning: This is irreversible. Back up data before executing.

Notes

  • No .sql migration file on disk — The migration was applied directly via Supabase MCP execute_sql. This is a known limitation of the Lovable workflow. The schema is in the live database and reflected in types.ts.
  • PF-84 dependency — Business calendar-aware deadline calculation is deferred until PF-84 is implemented. Current deadlines use simple interval math.
  • Edge function pf-sla-checker — Deferred to Phase 2. Will provide server-side periodic breach detection.

References