/**
 * lifecycle.ts
 *
 * Compaction lifecycle state machine for the compaction engine.
 *
 * Provides:
 * - Valid transition map for the 9-state machine
 * - Pure transition helpers (no side-effects)
 * - Strategy selection logic based on trigger and token pressure
 */
import type { CompactionLifecycleState, CompactionStrategy, CompactionTrigger } from './types.js';
/**
 * Returns whether a transition from `from` to `to` is valid.
 */
export declare function canTransition(from: CompactionLifecycleState, to: CompactionLifecycleState): boolean;
/**
 * Returns all states reachable from `from`.
 */
export declare function reachableFrom(from: CompactionLifecycleState): ReadonlySet<CompactionLifecycleState>;
/** Discriminated result of `applyTransition`. */
export type TransitionResult = {
    ok: true;
    state: CompactionLifecycleState;
} | {
    ok: false;
    reason: string;
};
/**
 * Validates and applies a state transition.
 *
 * @returns `{ ok: true, state }` on success, `{ ok: false, reason }` on rejection.
 */
export declare function applyTransition(current: CompactionLifecycleState, target: CompactionLifecycleState): TransitionResult;
/** Returns true if the state is a terminal completion state (done | failed). */
export declare function isTerminal(state: CompactionLifecycleState): boolean;
/** Returns true if the state represents active compaction work in progress. */
export declare function isCompacting(state: CompactionLifecycleState): boolean;
/** Parameters for selecting a compaction strategy. */
export interface StrategySelectionParams {
    /** What triggered compaction. */
    trigger: CompactionTrigger;
    /** Estimated tokens currently in context. */
    currentTokens: number;
    /** Model context window size. */
    contextWindow: number;
    /** Whether a prompt-too-long error was the immediate cause. */
    isPromptTooLong?: boolean | undefined;
}
/**
 * Selects the appropriate compaction strategy based on trigger and token pressure.
 *
 * Selection priority:
 * 1. `reactive`     — any prompt-too-long error (emergency, must shrink now)
 * 2. `microcompact` — token pressure < 50% of context window (light touch)
 * 3. `autocompact`  — token pressure 50–85% (standard auto-compaction)
 * 4. `collapse`     — token pressure > 85% or manual trigger (aggressive shrink)
 */
export declare function selectStrategy(params: StrategySelectionParams): CompactionStrategy;
/**
 * Maps a chosen CompactionStrategy to its corresponding lifecycle state.
 */
export declare function strategyToState(strategy: CompactionStrategy): CompactionLifecycleState;
//# sourceMappingURL=lifecycle.d.ts.map