import type { TodoOwedOutcome } from "./extensions/builtin/goal/todo-owed-backstop.ts";
import type { TurnEndLivenessInput } from "./extensions/builtin/goal/turn-end-liveness.ts";
import type { LifecycleStop } from "./session-lifecycle-types.ts";
import type { TurnDeadlineKind } from "./turn-deadline.ts";
/** Stop facts the stopping run produced itself, read from that run's own end (senpi#3864). */
export interface RunStopFacts {
    /** The run the turn end belonged to when its agent_end was emitted. */
    readonly runId?: string;
    readonly guard?: {
        readonly reason: string;
        readonly at: number;
    };
    readonly todo?: TodoOwedOutcome;
}
/** A deadline captured when it fired, before its durable write, for the run it stopped. */
export interface DeadlineStopCapture {
    readonly runId: string;
    readonly kind: TurnDeadlineKind;
    readonly at: string;
    readonly persisted?: false;
}
type StopDetail = Omit<LifecycleStop, "runId" | "epoch" | "at"> & {
    readonly at?: string;
};
/**
 * First match wins: the run's own deadline explains its system abort, a guard explains a refused continuation, then
 * the classified abort, and `no_wake` only for a stall no hold or guard owns. Provider failures keep the failed path.
 */
export declare function stopDetail(input: TurnEndLivenessInput | undefined, facts: RunStopFacts | undefined, deadline: DeadlineStopCapture | undefined, stalled: boolean): StopDetail | undefined;
export declare function sameStop(stop: LifecycleStop, detail: StopDetail): boolean;
/** The latest guard appended within one bound end's extension-processing window, including legacy entries. */
export declare function goalGuardAfter(branch: readonly {
    readonly id: string;
    readonly type: string;
    readonly customType?: string;
    readonly data?: unknown;
}[], guardStartLeafId: string | null): RunStopFacts["guard"];
/** Malformed optional detail is dropped; it never invalidates the record that carries it. */
export declare function readLastStop(value: unknown, runId: unknown): LifecycleStop | undefined;
export {};
//# sourceMappingURL=lifecycle-stop.d.ts.map