---
id: TASK-40
title: Port workflow engine (propagators + execution)
status: To Do
assignee: []
created_date: '2026-02-18 19:51'
labels:
  - infrastructure
  - phase-6
  - workflow
milestone: m-0
dependencies:
  - TASK-24
references:
  - canvas-website/src/lib/workflow/
  - canvas-website/src/propagators/WorkflowPropagator.ts
  - canvas-website/src/propagators/ScopedPropagators.ts
  - rspace-online/lib/folk-workflow-block.ts
priority: medium
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Port the workflow execution engine from canvas-website to rspace-online. This powers the existing folk-workflow-block shape with actual data flow and execution.

Source files (3,676 lines total):
- canvas-website/src/lib/workflow/types.ts (159 lines) — type definitions
- canvas-website/src/lib/workflow/blockRegistry.ts (438 lines) — block definition registry
- canvas-website/src/lib/workflow/executor.ts (548 lines) — block execution engine
- canvas-website/src/lib/workflow/portBindings.ts (464 lines) — port connection logic
- canvas-website/src/lib/workflow/validation.ts (417 lines) — graph validation
- canvas-website/src/lib/workflow/serialization.ts (571 lines) — save/load workflows
- canvas-website/src/propagators/WorkflowPropagator.ts (326 lines) — real-time data flow

Target: rspace-online/lib/workflow/ directory

Key adaptation needed: canvas-website uses tldraw store for state; rspace-online uses Automerge. The execution engine needs to read/write shape data through CommunitySync instead of tldraw's store.

Also port relevant propagator concepts:
- canvas-website/src/propagators/ScopedPropagators.ts (314 lines)
- canvas-website/src/propagators/SpatialIndex.ts (164 lines)
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Block registry loads available block types
- [ ] #2 Port connections transfer data between blocks
- [ ] #3 Execution engine runs blocks in correct order
- [ ] #4 Validation catches invalid graph configurations
- [ ] #5 Workflows serialize/deserialize through Automerge
- [ ] #6 Real-time propagation updates connected blocks
<!-- AC:END -->
