/** * Recovery — implements `vines/spec.md` §4.2. * * On service initialisation, find every orchestration in an unfinished state * (init | planning | executing), and for each cross-reference its * `linear_parent_id` with Linear to figure out the last completed sub-task * and the next pending one. The result is a report; resumption policy is * the caller's decision. * * Importantly, recovery distinguishes three failure modes: * * - **truly missing** — Linear returned `issue: null`. The parent no * longer exists; safe to mark the orchestration * failed. * - **lookup failed** — Linear API errored (network, 5xx, auth). * Recovery shouldn't destroy state on a * transient outage; surface for the operator * to retry. * - **present** — fragments cross-referenced normally. * * The discriminator lives on `RecoveryItem.lookupStatus` so callers can * distinguish "issue truly missing" from "issue lookup failed". */ import type { Ledger } from "./persistence.js"; import type { LinearClient } from "./linear-client.js"; import type { LinearIssue, OrchestrationRow } from "./types.js"; /** Linear workflow-state names considered "done" by default. */ export declare const DEFAULT_DONE_STATE_NAMES: ReadonlySet; /** * How the recovery scan was able to look up the parent issue. * - `ok` — `parentIssue` is present, children list is reliable. * - `missing` — Linear definitively returned no issue; orphaned. * - `lookup_failed` — Linear API errored. Treat as transient; don't * auto-fail the orchestration. * - `no_parent_id` — Ledger row had no `linear_parent_id` to look up. */ export type LookupStatus = "ok" | "missing" | "lookup_failed" | "no_parent_id"; export interface RecoveryItem { ledgerRow: OrchestrationRow; parentIssue: LinearIssue | null; children: LinearIssue[]; lastCompletedChild: LinearIssue | null; nextPendingChild: LinearIssue | null; lookupStatus: LookupStatus; lookupError?: string; } export interface RecoveryReport { items: RecoveryItem[]; } export declare function isResumable(item: RecoveryItem): boolean; /** * Truly orphaned: ledger row pointed at a Linear issue, and Linear * **definitively** said the issue doesn't exist (not "lookup_failed"). */ export declare function isLinearOrphaned(item: RecoveryItem): boolean; /** Lookup failed transiently — caller should retry, not fail. */ export declare function isLookupFailed(item: RecoveryItem): boolean; export declare function scanRecovery(ledger: Ledger, linear: LinearClient, doneStateNames?: ReadonlySet): Promise; export declare function resumable(report: RecoveryReport): RecoveryItem[]; export declare function orphaned(report: RecoveryReport): RecoveryItem[]; /** Items where the Linear lookup failed transiently — don't auto-fail. */ export declare function lookupFailed(report: RecoveryReport): RecoveryItem[]; /** * Helper: if Linear definitively reports the parent is missing, the * orchestration cannot be cross-referenced and is effectively abandoned. * Move it to `failed`. **Does not** fail transient-lookup items, by design. */ export declare function markFailedIfOrphaned(ledger: Ledger, item: RecoveryItem): Promise; //# sourceMappingURL=recovery.d.ts.map