/** * Pure bookkeeping for `NodeExecution.outputHistory` and the bounded * automatic-retry budget derived from `control.retries`. * * `retries: N` means the first attempt plus N automatic retries — so an * automatic retry remains available while fewer than N attempts have * already failed. The budget is derived from `outputHistory` itself (a * count of prior `'failed'` entries) rather than a separate durable * counter, so it composes for free with hydration and needs no new field. * * The manual `retryNode` operator override never pushes an entry here (it * only flips `status` back to `available`). The agent's own * `doFailNode(recoverable: true)` self-retry DOES push an entry — every * actual start closes out an attempt — but marks it `selfRetry` so * `countFailedAttempts` excludes it: neither self-retry nor the manual * override consumes the automatic budget this module tracks. * * @docLink packages/flow-engine/concepts#node-attempts */ import type { CheckEvidence, NodeError, NodeExecutionAttempt, NodeOutput } from "@skaile/workspaces/types"; /** Next 1-based attempt number given the attempts already recorded. */ export declare function nextAttemptNumber(history: NodeExecutionAttempt[] | undefined): number; /** Rarely-set trailing facts about one appended attempt. */ export interface AppendAttemptOptions { /** True for the agent's own `doFailNode(recoverable: true)` self-retry: the * entry still records a genuine start-to-failure attempt, but is excluded * from {@link countFailedAttempts} so it never consumes the automatic * `control.retries` budget. */ selfRetry?: boolean; /** Derived check evidence, when this attempt belongs to a `check` node that * actually produced a verdict (pass or fail). Omit for every other node * kind and for a check's infrastructure failure, which produced no verdict * to attach. */ check?: CheckEvidence; } /** * Appends one terminal attempt to `history`, numbered `max(attempt) + 1`. * Never mutates `history` — returns a fresh array so callers can assign it * straight onto a cloned `NodeExecution`. * * @param history - Existing attempt history, oldest first (or `undefined`). * @param result - True outcome of this attempt — independent of any * compatibility status degrade the caller applies separately (e.g. an * optional node's failed execution still records `'failed'` here even * though its `NodeExecution.status` becomes `'skipped'`). * @param startedAtIso - This attempt's actual start time. * @param completedAtIso - This attempt's terminal outcome time. * @param options - See {@link AppendAttemptOptions}. Both fields default to absent. * @docLink packages/flow-engine/concepts#append-attempt */ export declare function appendAttempt(history: NodeExecutionAttempt[] | undefined, result: NodeExecutionAttempt["result"], startedAtIso: string, completedAtIso: string, output: NodeOutput | undefined, error: NodeError | undefined, options?: AppendAttemptOptions): NodeExecutionAttempt[]; /** * Count of attempts in `history` whose true outcome was `'failed'`, * excluding self-retry entries (see {@link appendAttempt}) — this feeds only * the automatic-retry budget, which self-retry sits outside of. */ export declare function countFailedAttempts(history: NodeExecutionAttempt[] | undefined): number; /** * Whether an automatic retry remains, given how many attempts have already * failed and the authored `control.retries` budget. `retries: N` allows the * first attempt plus N automatic retries — so a retry remains available * while `priorFailedAttempts < N`. No `retries` (or `0`) means no automatic * retry ever. * * @docLink packages/flow-engine/concepts#has-automatic-retry-budget */ export declare function hasAutomaticRetryBudget(priorFailedAttempts: number, retries: number | undefined): boolean; //# sourceMappingURL=node-attempts.d.ts.map