/**
 * Failure phenotype classifier + outcome taxonomy for the traces insight engine.
 *
 * Both functions are pure: they take a redacted {@link SessionDetail} (the same
 * shape the traces sync writes to `sessions/<id>.json`) and return a decision
 * derived only from the already-derived step/gap/meta signal. They never read
 * raw transcript text and never fabricate a signal that is not in the data.
 *
 * The rubrics are expressed as data-driven tables of conditions, not as
 * if/else-by-name chains. Each table row is a named phenotype/outcome with a
 * declarative predicate; the classifier walks the table in priority order and
 * returns the first match, or the honest lower-confidence default when no
 * high-confidence signal is present.
 */
import type { SessionDetail } from './sync.js';
/** A failure mode detectable from the derived trajectory of a session. */
export type FailurePhenotype = 'false-termination' | 'premature-completion' | 'out-of-order' | 'failure-to-act';
/**
 * The coarse outcome of a session's work.
 *
 * - `merged`       : explicit PR/branch merge signal in the steps (high confidence).
 * - `tests-green`  : explicit test command returned ok with no later failure (high confidence).
 * - `partial`      : progress was made but no landing/test signal is present (low confidence default).
 * - `abandoned`    : errored, stalled, and unresolved.
 * - `human-takeover`: the final substantive action was a human-facing ask/wait.
 * - `invalid-env`  : environment/setup failures dominated the session.
 */
export type TraceOutcome = 'merged' | 'tests-green' | 'partial' | 'abandoned' | 'human-takeover' | 'invalid-env';
export interface PhenotypeResult {
    phenotype: FailurePhenotype | null;
    reason: string;
}
export interface OutcomeResult {
    outcome: TraceOutcome;
    confidence: 'high' | 'medium' | 'low';
    reason: string;
}
/**
 * Did a run that hit tool errors nonetheless *recover and finish*?
 *
 * The causal recovery test: a **substantive** tool step (not a human-facing
 * `AskUserQuestion` / `SendMessage` / `wait`) SUCCEEDED strictly AFTER the last
 * error's ordinal, AND that success resolves the failed work — its
 * {@link workSignature} matches an errored step's. A later success of *unrelated*
 * work does NOT count: a `bun test` failure followed by an incidental `ls` leaves
 * the failed test unresolved, so the run stays errored, even though the `ls`
 * succeeded after it. A punt to a human is excluded twice over — human-facing
 * tools are outside the substantive set, and they never match a failed signature.
 *
 * This is the single source of truth for "did this finish", shared by the
 * false-termination phenotype below and `sync.ts`'s `deriveRunOutcome` — so a
 * run's console outcome and its failure phenotype can never disagree about
 * whether it recovered. It reads only the derived steps, never `meta.outcome`,
 * precisely so `deriveRunOutcome` can call it while it is still *computing*
 * `meta.outcome`.
 */
export declare function recoveredAfterErrors(session: Pick<SessionDetail, 'steps'>): boolean;
/**
 * Classify the failure phenotype of a session from its derived trajectory.
 *
 * Definitions (from agent-failure research):
 * - `false-termination`  — stopped with an unresolved error (did not causally recover).
 * - `premature-completion` — declared done with no verification step for the
 *   engineering work.
 * - `out-of-order` — a write/edit step occurred before any read/plan of the
 *   target.
 * - `failure-to-act` — stalled or produced no meaningful tool use.
 *
 * Returns `null` when none of the failure phenotypes apply.
 */
export declare function classifyPhenotype(session: SessionDetail): FailurePhenotype | null;
/** Detailed phenotype result with a human-readable reason. */
export declare function classifyPhenotypeDetailed(session: SessionDetail): PhenotypeResult;
/**
 * Derive the coarse outcome of a session from its end state + tool signals.
 *
 * `merged` and `tests-green` are high-confidence only when an explicit signal
 * is present in the derived steps. When that signal is genuinely not in the
 * data, the function returns the honest lower-confidence value (`partial` for
 * completed work without a landing signal, `abandoned` for errored/unresolved
 * work, `invalid-env` for setup-dominant failures, `human-takeover` when the
 * session ends on a human-facing ask).
 */
export declare function deriveOutcome(session: SessionDetail): TraceOutcome;
/** Detailed outcome result with confidence and a human-readable reason. */
export declare function deriveOutcomeDetailed(session: SessionDetail): OutcomeResult;
export type { SessionDetail } from './sync.js';
