/** * Resume overrides + immutable history — 0.2.0 dogfood issue 5. * * Resume creates a NEW RunState (new runId, `parentRunId` pointing at the * original) and never mutates or overwrites the original run file. Reusable * completed phase states are copied into the child; the target failed/paused * phase + its transitive downstream dependents are cleared so they re-run. * * An optional `ResumeOverrides` API re-runs exactly one phase with a patched * task/model/timeout/idleTimeout (applied to the CHILD's def only — the parent * def is untouched). When no overrides are supplied, ordinary resume forks a * new run that preserves all `done` phases and lets the runtime re-run the * non-done (failed/paused/running) ones. * * The fork/apply helpers are pure so they can be unit-tested without touching * the runtime or the filesystem. `forkRunForResume` fails closed when the * stored definition or requested overrides are invalid. The host adapters * (pi / MCP) call it and hand the child RunState to `executeTaskflow`. */ import { type Phase, type Taskflow } from "./schema.ts"; import { type ProcessLiveness, type RunState } from "./store.ts"; /** Overrides for re-running exactly one phase on resume. `phaseId` is required; * at least one of the other fields must be supplied. All values are applied to * the CHILD's def only (the parent def + persisted file are never touched). */ export interface ResumeOverrides { phaseId: string; task?: string; model?: string; timeout?: number; idleTimeout?: number; } /** A durable approval marker is safe only when the graph itself prevents all * other unfinished phases from dispatching before one of these waits settles. * Best-effort progress persistence cannot prove that a concurrent child stopped. * Timed approvals may settle independently of the UI callback, so a stale marker * cannot prove that their downstream children remain blocked. */ export declare function isQuiescentApprovalCheckpoint(prev: RunState, waitingIds: readonly string[]): boolean; /** Prepare an orphaned foreground checkpoint for an immutable resume fork. * Only a valid recorded PID whose OS probe proves ESRCH may be recovered. * PID reuse, EPERM, unavailable birth tokens and missing metadata stay closed. * The parent object/file is never changed and no signal other than 0 is sent. */ export declare function resumeSourceAfterOwnerExit(prev: RunState, options: { cwd: string; inspectProcess?: (pid: number) => ProcessLiveness; }): { ok: true; value: RunState; } | { ok: false; errors: string[]; }; /** Runs are resumable only when execution stopped non-terminally. Completed and * blocked runs are immutable terminal history; use a fresh run or recompute. */ export declare function validateResumeRun(prev: RunState): { ok: boolean; errors: string[]; }; /** Validate resume overrides against a prior run. Returns structured errors. * Checks: phaseId exists, at least one override field is present, and field * values pass the normal Taskflow validator after applying the overrides. */ export declare function validateResumeOverrides(prev: RunState, ov: ResumeOverrides): { ok: boolean; errors: string[]; }; /** One resume validation contract for every host. Overrides are allowed to * repair an invalid stored definition, so callers must not pre-validate the * unpatched parent before dispatching here. */ export declare function validateResumeRequest(prev: RunState, overrides?: ResumeOverrides): { ok: boolean; errors: string[]; }; /** Apply resume overrides to a deep-cloned def (the parent def is never * mutated). Returns the child def. Pure. */ export declare function applyResumeOverrides(def: Taskflow, ov: ResumeOverrides): Taskflow; /** Compute the transitive DOWNSTREAM dependents of `target` (phases that depend * on target, directly or transitively, via `dependsOn` ∪ `from`). Excludes the * target itself. Sorted for deterministic output. */ export declare function transitiveDownstream(phases: Phase[], target: string): string[]; /** Fork a prior run into a NEW child RunState for resume. The child gets a fresh * runId + `parentRunId` pointing at the parent; the parent is never mutated. * * - With `overrides`: the child def is patched (overrides applied to the target * phase); the target + its transitive downstream are cleared (removed) so * they re-run; other `done` phases are copied (within-run resume cache hits). * - Without `overrides` (ordinary resume): the child def is a deep clone of the * parent def; ALL `done` phases are copied; non-done (failed/paused/running) * phases are omitted so the runtime re-runs them. * * `prev` is never mutated. Returns the child RunState (ready for * `executeTaskflow`). */ export declare function forkRunForResume(prev: RunState, opts?: { overrides?: ResumeOverrides; cwd?: string; host?: string; }): RunState; //# sourceMappingURL=resume.d.ts.map