Status: ✅ Complete (Phase 1 + Phase 2 + Phase 3) — 2026-03-14
Spec Reference: PF-73-workflow-builder-swim-lane-visualization.md
Last Updated: 2026-03-14
Last Verified: 2026-03-14
Overview
PF-73 extends the Platform Workflow layer (@/platform/workflow) with swim lane diagram capabilities: horizontal/vertical lanes, node-in-lane placement, manual builder UI, policy/procedure-based generation (GR-01, GR-11), and AI-assisted generation (PF-27). Diagrams are stored in pf_swim_lane_diagrams and consumed by GR, FW, HR, and other cores for process documentation—visualization only, not workflow execution (FW-06 remains the execution engine).
Quick Reference
Integration Points (from Spec)
API / Data Contracts
Swim Lane Canvas & Types
Import:import { SwimLaneCanvas, useSwimLaneDiagram, useSwimLaneDiagramList, useSwimLaneDiagramMutation } from '@/platform/workflow';
Types (PF-73):
Hooks:
Component:
SwimLaneCanvas— Lane-aware canvas (group nodes or custom panels); lane CRUD, node palette, drag-between-lane, edges. Used by builder page and read-only view.
Generation (Phase 3)
- From procedure (GR-11): Pass procedure id; platform reads
gr_proceduresand steps via allowed integration; returns diagram state with lanes derived fromresponsible_role. No direct core-to-core import; use platform or documented API. - From policy (GR-01) / AI: Pass policy id or pasted text; PHI validation required before calling PF-27/PF-62; AI returns suggested lanes/steps; user confirms; diagram created with
source_type='policy'or'procedure'.
Export
- PDF/PNG: Use existing platform export utilities (e.g.
@/platform/formsor document export). Permission:pf.swim-lane-diagrams.export. - Save as document: Optional upload to PF-11 with title/folder; org-scoped.
RLS Architecture
UPDATE policy: MUST include
WITH CHECK so organization_id cannot be changed (constitution §5.2.4). No RLS policy may query RLS-protected tables directly; use SECURITY DEFINER helpers only (§5.7).
Realtime (Phase 2.2) — Channel and auth
Phase 2.2 collaborative realtime is planned (not yet implemented). The channel contract, presence/subscribe/broadcast semantics, and multi-tenant verification rules are documented in EVENT_CONTRACTS.md#pf-73-realtime-channel. When implemented, Supabase Realtime (broadcast/presence) MUST use the org-scoped channel and authorization-at-subscription-time rules defined there. See also PF-73 Phase 2 Expansion Integration Points for the full contract.Security and Tenant Isolation
- All access filtered by
organization_id; RLS enforces org isolation. - Mutations MUST include
.eq('organization_id', orgId)(defense-in-depth). - No PHI in diagram content or AI prompts; policy text sent to PF-27/PF-62 must pass pre-flight PHI validation.
- Permission keys:
pf.swim-lane-diagrams.view,.create,.update,.delete,.export. All UI gated by these keys.
Settings
Migration must include CHECK (if applicable) and COMMENT ON COLUMN per constitution §5.2.5.
Related Docs
- PF-73 Spec
- PF-73 Plan
- Platform Integration Layers
- GR-11 Procedures Management
- FW-06 Advanced Workflow Builder
- Workflow Selection Guide
- PF-73 Phase 2 Expansion
Phase 2 API Contracts (added 2026-03-14)
Version History (Phase 2.1)
Import:import { useSwimLaneDiagramVersions, useCreateDiagramVersion } from '@/platform/workflow';
Component:
DiagramVersionHistory — Sheet-based panel with version list, read-only preview, and “Restore” action.
Real-Time Collaboration (Phase 2.2)
Import:import { useDiagramPresence, useDiagramBroadcast } from '@/platform/workflow';
Channel:
org:{orgId}:diagram:{diagramId} — org-scoped per PF-66 standards.
BPMN Import (Phase 2.3)
Import:import { parseBpmnToSwimLane } from '@/platform/workflow';
Component:
ImportBpmnDialog — File picker + preview + import action.
Templates Marketplace (Phase 2.4)
Import:import { useSwimLaneTemplates } from '@/platform/workflow';
Components:
SwimLaneTemplateList, SwimLaneTemplatesPage.Route:
/platform/workflows/diagrams/templates (lazy-loaded, permission-gated).
Phase 3 API — ✅ Complete (2026-03-14)
Phase 3 expansion (PF-73-PHASE-3-EXPANSION.md) delivers:Hooks
Utilities
Components
BPMN Export Limitations
- Node positions are NOT preserved (no BPMNDI)
- Lane colors, orientation, and order are lost
- Node type information is lost on round-trip (parser assigns
type: 'default') - Only
start,end,task,decisiontypes map to BPMN elements; others becomebpmn:task
Accessibility
- All node types have
role="img"andaria-label NodePaletteusesrole="toolbar"witharia-label- Canvas wrapped in
role="region"witharia-label - Keyboard shortcuts skip inputs/textareas/selects
- Visible focus rings on all interactive elements
Dependency
@dagrejs/dagre^1.1.4 — auto-layout algorithm
Testing
- Unit tests:
tests/unit/platform/workflow/— diagramValidation (8), serializeSwimLaneToBpmn (5), dagreLayout (5), useDiagramUndoRedo (6) - Integration tests:
tests/integration/platform/workflow/swim-lane-phase3.test.ts— validate→export→reimport, layout→validate (4)