Spec:
specs/fw/specs/FW-56-workflow-execution-replay-time-travel.mdStatus: 📝 Planned
Owner Core: FW (Forms & Workflow)
Purpose
Defines integration contracts for read-only historical replay of workflow executions using FW-48 step checkpoints, what-if forks into FW-24 sandbox executions, comparison of two runs of the same workflow, and single-execution export (JSON/PDF) aligned with FW-43 retention posture.Integration Matrix
Data Contracts
Replay bundle query
Inputs:execution_id, organization_idReads:
fw_workflow_executions(single row, tenant filter)fw_execution_steps—SELECT * WHERE execution_id = ? AND organization_id = ? ORDER BY step_index ASC, attempt_number ASC- Optional
fw_execution_logs— filterexecution_id, ascending time
execution,steps[],logs[]for UI layers
What-if fork write
Table:fw_sandbox_executionsRequired fields (minimum):
organization_id,rule_id(from source execution),execution_type = 'what_if'forked_from_execution_id,forked_from_step_idmodified_variables(JSON object)input_data— deterministic merge (spec FR-3.4): shallow copyfw_workflow_executions.variables; for eachfw_execution_stepsrow in order through the fork step (inclusive), shallow-merge that step’soutput_datainto the accumulator; then shallow-mergemodified_variables; result =input_datafor the sandbox row.
sandbox-execute edge function (or equivalent RPC) with sandbox row id after insert.
Comparison query
Inputs:execution_id_a, execution_id_b, organization_idPrecondition: Both rows share the same
rule_id (client + server validation).Reads: Two step lists; align by
step_index for divergence detection.
Export
MVP: Client-assembled JSON download from replay bundle; PDF via jsPDF.Redaction: Sanitize all
error_message fields via sanitizeErrorMessage before serialization; variable bodies match on-screen replay (spec FR-5.3).No new storage bucket required unless product later moves to signed URLs (defer).
Workflow definition for canvas
- If
fw_workflow_executions.workflow_versionis set: loadfw_workflow_definitionswhere(rule_id, version)matches. - If null: load the row with maximum
versionforrule_id+ org; show UI banner that layout may differ from run-time graph (spec FR-2.1).
API / Edge Contracts
Security & Tenancy
- All queries:
.eq('organization_id', orgId)in application code in addition to RLS. - Permission:
fw.workflow-executions.replayfor replay UI, compare, what-if launch, single-execution export (see spec). - No PHI in audit payloads — identifiers only.
Consumer Notes
- FW-22: Remove or bypass client-only replay simulation in
ExecutionDetailDialog.handleReplayonce FW-56 ships. - FW-48: If step retention deletes rows, replay must show empty state with explanation (link to FW settings / retention doc).