Status: 📋 Specification
Spec Reference: FW-50-natural-language-workflow-generation.md
Last Updated: 2026-03-20
Overview
FW-50 adds AI-assisted workflow structure suggestions from a short natural-language description. All AI calls go through PF-27 (Platform AI) via@/platform/ai (useAIStructuredOutput). Suggestions are applied by merging into fw_workflow_definitions JSONB nodes/edges columns (no new tables). Pattern aligns with FW-44 (AI form building) and FW-30 (workflow optimization AI).
Integration Points (from Spec)
API / Contracts
- Frontend:
useAIWorkflowSuggestions,useApplyWorkflowSuggestions(spec-defined); AI path uses existing Platform AI /ai-assistantinfrastructure where applicable. - Data writes: Supabase UPDATE to
fw_workflow_definitions(JSONB merge onnodes,edgescolumns) with.eq('organization_id', orgId)RLS; no new edge function required unless platform requires one for this feature module.
Platform Integration Layer Usage
Security and Tenant Isolation
- Permissions: No new keys. UI gated with existing
fw.workflows.create(new draft) andfw.workflows.edit(existing draft), same as Workflow Builder context. - Prompts: workflow name + purpose description only; do not send resident/patient/employee identifiers, existing node labels/config, or free-text field values from existing workflows (Phase 1).
- Mutations: scoped to workflows the user can edit;
.eq('organization_id', orgId)on updates (defense in depth). Apply is all-or-nothing (single row UPDATE on JSONB columns is inherently atomic; no orphaned nodes without edges). - Audit:
ai_workflow_suggestions_applied(canonical) with counts and IDs; no PHI in payload. - Logs: avoid pairing user description with org-identifying detail in plain-text logs where unnecessary.
Event Contracts
- No new cross-core domain events in Phase 1. Optional internal audit event only (see spec).
Related Docs
- FW-50 Spec
- FW-06 Spec
- FW-44 Spec
- FW-30 Spec
- PF-27 (Platform AI)