/** * Final-phase selection + output source attribution (0.2.0 dogfood issue 6). * * Pure, total, host-neutral. Shared by the imperative runtime (`runtime.ts` → * `runTaskflowLayers`) and the event kernel (`exec/driver.ts`) so the two paths * agree on which phase's output becomes `finalOutput`, the fallback when the * designated final phase didn't complete, the no-output default, and the * `outputSourcePhaseId` attribution reported to hosts. * * Kept in its own module (rather than inlined in `runtime.ts`) so the event * kernel can import it without pulling the rest of the runtime into its module * graph — avoiding a static `runtime ↔ exec/driver` import cycle (runtime * already loads driver lazily via a dynamic `import()`). */ import { type Phase } from "./schema.ts"; import type { RunState } from "./store.ts"; /** The run's final output + the id of the phase whose output supplied it. */ export interface FinalOutputResolution { finalOutput: string; /** Id of the phase whose output supplied `finalOutput`; `undefined` when no * phase output is available. See `RuntimeResult.outputSourcePhaseId`. */ outputSourcePhaseId: string | undefined; } /** Blocking-context inputs to {@link resolveFinalOutput}. */ export interface FinalOutputBlockedCtx { gate: boolean; gateReason: string; /** The blocking gate/approval phase's output (included in the gate prefix). */ gateOutput: string; /** Id of the blocking gate/approval phase (the source of `gateOutput`). */ gatePhaseId: string | undefined; budget: boolean; budgetReason: string; } /** * Resolve the run's final output + the id of the phase whose output supplied it. * * Selection uses `finalPhase()` (the designated `final: true` phase, else the * last phase in definition order). A failed final phase with an answer body * distinct from its diagnostic keeps that partial body; skipped, blocked, and * transport-only failures fall back to the last `done` phase in definition order. * * Source attribution (the phase whose output appears in `finalOutput`): * - Normal: the fallback final phase (when it has output). * - Gate blocked: the blocking gate/approval phase (when its output is included * in the prefix), else `undefined`. * - Budget blocked: the fallback final phase (when its output is included), * else `undefined`. * `undefined` whenever no phase answer is available. A designated failed final * phase is a source only when `partialOutput` proves its body is genuine; * attribution always tracks the phase actually present in `finalOutput`. */ export declare function resolveFinalOutput(phases: Phase[], state: RunState, blocked: FinalOutputBlockedCtx): FinalOutputResolution; //# sourceMappingURL=final-output.d.ts.map