## ADDED Requirements

### Requirement: Append-only event log
Workflow runs SHALL produce append-only event records. Events SHALL NOT be modified after creation.

#### Scenario: Events are chronological
- **WHEN** a workflow executes
- **THEN** events SHALL be stored with monotonically increasing timestamps or sequence numbers
- **THEN** event order SHALL match execution order

#### Scenario: Events are immutable
- **WHEN** an event has been persisted
- **THEN** it SHALL NOT be updated or deleted

### Requirement: Event types
The event log SHALL support exactly 8 event types: `workflow_started`, `workflow_completed`, `workflow_failed`, `workflow_cancelled`, `node_started`, `node_completed`, `node_failed`, `node_skipped`.

#### Scenario: Workflow lifecycle events
- **WHEN** a workflow run begins
- **THEN** a `workflow_started` event SHALL be recorded
- **WHEN** a workflow run completes successfully
- **THEN** a `workflow_completed` event SHALL be recorded
- **WHEN** a workflow run fails
- **THEN** a `workflow_failed` event SHALL be recorded

#### Scenario: Node lifecycle events
- **WHEN** a node begins execution
- **THEN** a `node_started` event SHALL be recorded
- **WHEN** a node completes successfully
- **THEN** a `node_completed` event SHALL record the node's output
- **WHEN** a node fails
- **THEN** a `node_failed` event SHALL record the error
- **WHEN** a node is skipped (trigger_rule not met)
- **THEN** a `node_skipped` event SHALL be recorded

### Requirement: Deterministic replay for crash recovery
When a workflow run is resumed after an interruption, the engine SHALL load completed node outputs from the event log and skip re-execution of completed nodes.

#### Scenario: Resume skips completed nodes
- **WHEN** a workflow run is resumed after a crash
- **THEN** all nodes with a `node_completed` event SHALL be skipped
- **THEN** execution SHALL begin from the first node without a completed event

#### Scenario: Resume after partial execution
- **WHEN** a workflow had 5 nodes and the first 3 completed before the crash
- **THEN** nodes 1-3 SHALL be skipped (outputs loaded from event log)
- **THEN** node 4 SHALL be re-executed

### Requirement: Event storage via plugable backend
Events SHALL be persisted through the `IWorkflowStore` interface, with at least a filesystem backend.

#### Scenario: Filesystem event store
- **WHEN** using the filesystem backend
- **THEN** each run SHALL have a JSON file at `{runId}/events.jsonl`
- **THEN** events SHALL be appended as newline-delimited JSON

#### Scenario: SQLite event store
- **WHEN** using the SQLite backend
- **THEN** events SHALL be stored in a `workflow_events` table with columns for run_id, sequence, event_type, timestamp, and payload
