/**
 * WorkflowState — persisted runtime state for a workflow run.
 *
 * Story 4.2 — OpenLife v1.2 Royal Stack.
 *
 * Storage: <stateDir>/workflows/<runId>.json (atomic via AtomicWriter).
 * Events: <stateDir>/workflows/events/<runId>.jsonl (append-only,
 * atomic via appendJsonlAtomic).
 */
export type WorkflowRunStatus = 'pending' | 'running' | 'awaiting_input' | 'completed' | 'failed' | 'aborted';
export interface WorkflowStepRecord {
    stepId: string;
    status: 'pending' | 'running' | 'completed' | 'skipped' | 'failed';
    startedAt?: string;
    completedAt?: string;
    /** Artifacts the executor reported producing (creates / updates from schema). */
    artifacts?: string[];
    /** Free-form result payload from the executor — typically a JSON-stringified envelope. */
    result?: string;
    error?: string;
}
export interface WorkflowRunState {
    runId: string;
    workflowId: string;
    status: WorkflowRunStatus;
    startedAt: string;
    lastCheckpointAt?: string;
    completedAt?: string;
    /** Step ids that have reached terminal status (completed or skipped). */
    completedSteps: string[];
    /** Step id currently executing (when status is `running` or `awaiting_input`). */
    currentStep?: string;
    /** Detailed per-step records, keyed by step id. */
    steps: Record<string, WorkflowStepRecord>;
    /** Cumulative artifacts produced across all completed steps. */
    artifacts: string[];
    /** Free-form context passed to the engine at run() time. */
    context?: Record<string, unknown>;
    /** Error envelope when status is `failed`. */
    failureReason?: string;
}
export interface WorkflowEvent {
    ts: string;
    runId: string;
    type: 'run.started' | 'run.completed' | 'run.failed' | 'run.aborted' | 'run.awaiting_input' | 'run.resumed' | 'step.started' | 'step.completed' | 'step.skipped' | 'step.failed';
    stepId?: string;
    detail?: Record<string, unknown>;
}
