2.8 KiB
2.8 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| reactive/workflow-root | Implement WorkflowReactiveRoot — signal graph, EventLogProjection, lifecycle, abort, dispose | completed |
|
broad | high | phase | implementation |
Description
Implement the WorkflowReactiveRoot class that wraps reactive state for an entire workflow execution. It takes the structural DAG, creates signal-backed state for each operation node, and implements the EventLogProjection interface from ADR-005. The reactive root owns all signals and is responsible for their lifecycle.
Acceptance Criteria
src/reactive/workflow.tsexportsWorkflowReactiveRootclass implementingEventLogProjectionEventLogProjectioninterface:append(event),getStatus(nodeId),getResult(nodeId),getEvents(nodeId)- Constructor takes
DirectedGraphand optional{ failurePolicy?: FailurePolicy }, callsinitializeSignals() FailurePolicy:"continue-running" | "abort-dependents"(default:"continue-running")initializeSignals(): iterates all DAG nodes, createssignal<NodeStatus>("idle"),computed<boolean>preconditions (all predecessors completed/skipped),computed<boolean>blockedByFailure (any predecessor failed/aborted),computed<CallResult | undefined>result from event lognodeKeyToRequestId: Map<string, string>— maps template node keys to call protocol requestIdsstatusMap: Map<string, Signal<NodeStatus>>,preconditions,blockedByFailure— owned by this classappend(event: CallEventMapValue): processes event, updates status via projection (idempotent)getStatus(nodeId): hybrid model — checks event log first for call-level statuses, falls back to signal map for workflow-level statusesgetResult(nodeId): derives from most recentcall.responded/call.error/call.abortedevent per nodeabortAll(): sets all non-terminal nodes (not completed/failed) to"aborted"abortNode(nodeId): aborts a specific nodedispose(): calls all effect disposers, clears all maps (critical for preventing signal leaks)isComplete(): boolean— all nodes in terminal stategetAggregateStatus(): count breakdown by status- Unit tests: signal initialization for known DAG, append event → status update, getResult derived from events, abort cascade, dispose clears all, failurePolicy behavior
References
- docs/architecture/reactive-execution.md — WorkflowReactiveRoot full specification, EventLogProjection, lifecycle, ownership, disposal
- docs/architecture/host-configs.md — ReactiveContext structure, signal-graph → WorkflowNode wiring
Notes
To be filled by implementation agent
Summary
To be filled on completion