/** * Copyright (c) 2025 Elara AI Pty Ltd * Licensed under BSL 1.1. See LICENSE for details. */ import type { StorageBackend } from '../../storage/interfaces.js'; import type { DataflowOrchestrator, ExecutionHandle, ExecutionStatus, OrchestratorStartOptions, ResumeOptions } from './interfaces.js'; import type { ExecutionStateStore } from '../state-store/interfaces.js'; import type { ExecutionEvent, FinalizeResult } from '../types.js'; /** * Local orchestrator for in-process dataflow execution. * * @remarks * - Uses step functions for each operation * - Per-dataset ref writes are atomic and independent (no mutex needed) * - Supports AbortSignal for cancellation * - Persists state through the provided state store * - Reactive: detects input changes after each task, invalidates and * re-executes affected tasks until fixpoint */ export declare class LocalOrchestrator implements DataflowOrchestrator { private readonly stateStore?; private executions; /** * Create a new LocalOrchestrator. * * @param stateStore - Optional state store for persistence. * If not provided, state is only kept in memory. */ constructor(stateStore?: ExecutionStateStore | undefined); start(storage: StorageBackend, repo: string, workspace: string, options?: OrchestratorStartOptions): Promise; /** * Resume an execution that yielded (shouldYield checkpoint) or whose host * died mid-run. See DataflowOrchestrator.resume. */ resume(storage: StorageBackend, repo: string, workspace: string, executionId: string, options?: ResumeOptions): Promise; /** * Shared tail of start() and resume(): register the RunningExecution, * wire the abort listener, and kick off the loop (non-blocking). */ private beginExecution; wait(handle: ExecutionHandle): Promise; getStatus(handle: ExecutionHandle): Promise; cancel(handle: ExecutionHandle): Promise; getEvents(handle: ExecutionHandle, sinceSeq: number): Promise; /** * Main execution loop with reactive fixpoint. * * After each task completes, checks for input changes and invalidates * affected tasks. Uses version vector consistency checks to defer tasks * whose inputs have conflicting provenance. Execution continues until * fixpoint (no more ready, running, or deferred tasks). */ private runExecutionLoop; /** * Take a yield checkpoint: reset in-flight tasks to pending, persist the * still-'running' state, and stage the yielded FinalizeResult (resolved * from the loop's finally, after locks are released). * * Runs under the mutex so completion handlers already queued ahead of it * land their results first (and ARE included in the checkpoint); handlers * settling after it only mutate memory — persistState is suppressed by * the yielded flag, keeping the checkpoint as the last persisted word. */ private checkpointYield; /** * Detect input changes and invalidate affected tasks. * * Called after each task completion to implement the reactive loop. */ private handleInputChanges; /** * Execute a single task. */ private executeTask; /** * Build partial results for abort error. */ private buildPartialResults; /** * Build output versions map from completed task states. */ private buildOutputVersions; /** * Read workspace structure from storage. */ private readStructure; /** * Persist state, skipping the write when execution has been aborted * and the state doesn't yet reflect cancellation (defense-in-depth). */ private persistState; /** * Generate unique key for an execution. */ private executionKey; } //# sourceMappingURL=LocalOrchestrator.d.ts.map