/** * JSON Execution Model implementation * * Provides deterministic JSON-based workflow execution with proper * serialization, validation, and execution semantics as defined in * the execution-semantics.md specification. */ import type { ExecutionError, ResiliencePolicy, StepResult, Workflow, WorkflowResult } from '@orchestr8/schema'; import type { Logger } from './types.js'; /** * JSON-serializable execution state */ export interface ExecutionState { executionId: string; workflowId: string; status: 'pending' | 'validating' | 'running' | 'completed' | 'failed' | 'cancelled'; startTime: string; endTime?: string; duration?: number; currentLevel?: number; completedSteps: string[]; failedSteps: string[]; skippedSteps: string[]; cancelledSteps: string[]; stepResults: Record; variables: Record; errors?: ExecutionError[]; metadata?: Record; } /** * JSON-serializable step execution state */ export interface StepExecutionState { stepId: string; status: 'pending' | 'validating' | 'executing' | 'success' | 'failed' | 'timeout' | 'cancelled' | 'skipped' | 'retrying'; startTime?: string; endTime?: string; duration?: number; attempt?: number; maxAttempts?: number; lastError?: ExecutionError; input?: unknown; output?: unknown; metadata?: Record; } /** * Execution journal entry */ export interface ExecutionJournalEntry { timestamp: string; executionId: string; stepId?: string; event: string; data?: unknown; error?: ExecutionError; } /** * JSON Execution Model configuration */ export interface JsonExecutionConfig { maxPayloadSize?: number; maxJournalSize?: number; enableJournal?: boolean; strictValidation?: boolean; deterministicIds?: boolean; logger?: Logger; } /** * JSON Execution Model implementation */ export declare class JsonExecutionModel { private readonly maxPayloadSize; private readonly maxJournalSize; private readonly enableJournal; private readonly strictValidation; private readonly deterministicIds; private readonly logger; private readonly journal; constructor(config?: JsonExecutionConfig); /** * Serialize workflow to JSON */ serializeWorkflow(workflow: Workflow): string; /** * Deserialize workflow from JSON */ deserializeWorkflow(json: string): Workflow; /** * Create initial execution state */ createExecutionState(workflow: Workflow, variables?: Record): ExecutionState; /** * Serialize execution state to JSON */ serializeExecutionState(state: ExecutionState): string; /** * Deserialize execution state from JSON */ deserializeExecutionState(json: string): ExecutionState; /** * Create step execution state */ createStepExecutionState(stepId: string): StepExecutionState; /** * Update execution state after step completion */ updateExecutionStateForStep(state: ExecutionState, stepState: StepExecutionState, result: StepResult): ExecutionState; /** * Update step execution state in execution state */ updateStepExecutionState(state: ExecutionState, stepId: string, status: 'completed' | 'failed' | 'cancelled' | 'skipped', result?: StepResult): ExecutionState; /** * Finalize execution state */ finalizeExecutionState(state: ExecutionState): ExecutionState; /** * Convert execution state to workflow result */ toWorkflowResult(state: ExecutionState): WorkflowResult; /** * Get execution journal */ getJournal(): ReadonlyArray; /** * Export journal as JSON */ exportJournal(): string; /** * Clear journal */ clearJournal(): void; /** * Normalize resilience policy for JSON serialization */ normalizeResiliencePolicy(policy: unknown): ResiliencePolicy | undefined; /** * Validate workflow structure */ private validateWorkflow; /** * Validate payload size */ private validatePayloadSize; /** * Generate deterministic ID */ generateDeterministicId(seed: string, timestamp: number): string; /** * Add journal entry */ private addJournalEntry; } /** * Create HTTP execution context with proper headers and limits */ export declare class HTTPExecutionContext { private readonly syncMaxSize; private readonly asyncMaxSize; private readonly journalMaxSize; generateETag(content: unknown): string; generateLocationHeader(executionId: string): string; calculateRetryAfter(attempt: number): string; validatePayload(payload: unknown, mode: 'sync' | 'async' | 'journal'): void; private getMaxSize; setExecutionHeaders(response: { setHeader: (name: string, value: string) => void; }, executionId: string, status: string, content?: unknown): void; } //# sourceMappingURL=json-execution-model.d.ts.map