/** * `recoverAll()`'s per-`(type, revision)` preload barrier (WFT-17/WFT-18), * replacing the per-`type`-only barrier `recovery-dynamic-sources.ts` used * to own. Split out of `transition.ts`, which has no headroom under the * repository's 500-line implementation-file ceiling for this logic inline * — the same reason `recovery-dynamic-sources.ts` was split out for * WFT-15/16. * * Recovery scans non-terminal workflow states, groups them by their exact * `(type, revision)` pin (a legacy record with no persisted `revision` * groups under `undefined` for its type), and preloads/classifies every * group BEFORE any group's runs advance — ready, or unavailable with the * error every run in that group fails with. Grouping and classification use * nested `Map>` structures rather than a * delimiter-joined composite key, so an arbitrary workflow `type` or * `revision` string can never collide with a delimiter. * * @module core/engine/lifecycle/recovery-revision-groups */ import { DynamicWorkflowSourceUnavailableError } from '../dynamic-source-errors.ts'; import type { EngineInternals } from '../internals.ts'; import { WorkflowRevisionUnavailableError } from '../revision-errors.ts'; import type { LifecycleCallbacks } from './shared.ts'; /** One preflight-recoverable entry's identity, as `transition.ts`'s preflight scan produces it. */ export type RecoverableRevisionEntry = { readonly workflowId: string; readonly type: string; readonly revision: string | undefined; }; /** One `(type, revision)` group: every non-terminal run pinned to that exact revision. */ export type RecoveryRevisionGroup = { readonly type: string; readonly revision: string | undefined; readonly workflowIds: readonly string[]; }; /** `type -> revision -> group`. A legacy entry (no persisted `revision`) groups under the `undefined` key. */ export type RecoveryRevisionGroups = ReadonlyMap>; /** * Group preflight-recoverable entries by their exact `(type, revision)` pin. * Every non-terminal run pinned to the same revision of the same type lands * in one group, regardless of scan order. */ export declare function buildRecoveryRevisionGroups(entries: readonly RecoverableRevisionEntry[]): RecoveryRevisionGroups; /** Outcome of classifying one `(type, revision)` group. */ export type RevisionGroupClassification = { readonly status: 'ready'; } | { readonly status: 'unavailable'; readonly error: WorkflowRevisionUnavailableError | DynamicWorkflowSourceUnavailableError; }; /** `type -> revision -> classification`, mirroring {@link RecoveryRevisionGroups}'s shape. */ export type RevisionGroupClassifications = ReadonlyMap>; /** * Resolve every `(type, revision)` group to `'ready'` or `'unavailable'`, * concurrently, one `resolveExecutableRegistrationForRevision()` call per * group — even when many non-terminal runs share the same pin. An eager * type's groups are omitted from the result entirely (eager is always * ready and needs no preload call); only dynamic-source groups are * classified. A disposal mid-preload aborts the whole barrier by * rethrowing, matching `recoverEntryOrIsolateFailure`'s own un-isolated * treatment of {@link EngineDisposedError}. */ export declare function classifyRevisionGroups(internals: EngineInternals, callbacks: LifecycleCallbacks, groups: RecoveryRevisionGroups): Promise; /** * Wrap `callbacks` so `recoverAll()`'s own per-entry `resume()` calls below * see a batch's cached `classifyRevisionGroups()` failure for the entry's * `(type, revision)` group, WITHOUT touching any state shared with other * callers. `classifications` is a plain, closure-local `Map` structure — * nothing outside `recoverAll()` ever sees it, so a concurrent, unrelated * `engine.start()`, `engine.resume()`, or a second concurrent `recoverAll()` * batch for the SAME `(type, revision)` keeps using the real, un-wrapped * `callbacks.resolveExecutableRegistrationForRevision` and can never observe * (or race the reset of) this batch's classification. */ export declare function createRecoveryScopedRevisionCallbacks(callbacks: LifecycleCallbacks, classifications: RevisionGroupClassifications): LifecycleCallbacks;