import { type LoopConfig } from "./loop.js"; import type { LifecycleRoutedStage, ThinkingLevel } from "./config.js"; import type { RecoveryLedger } from "./recovery.js"; import type { GraphCheckpointRef, GraphExecutionState } from "./scheduler.js"; import type { SchedulerRecoveryBinding } from "./schedulerRecovery.js"; export type LifecyclePhase = "idle" | "defining" | "awaiting_spec_approval" | "planning" | "awaiting_plan_approval" | "building" | "verifying" | "reviewing" | "debugging" | "shipping" | "awaiting_ship_approval" | "finalizing" | "done" | "failed"; export type LifecycleVerdictStage = "verify" | "review" | "ship"; export type LifecycleVerdict = "approve" | "reject"; export interface LifecycleOriginalModelState { provider: string; id: string; thinking: ThinkingLevel; } export interface LifecycleStageVerdict { stage: LifecycleVerdictStage; verdict: LifecycleVerdict; reasons: string; requiredFixes?: string; } export interface LifecycleModelSelection { stage: LifecycleRoutedStage | "build"; provider: string; model: string; family?: string; thinking: ThinkingLevel; reason: string; selectedAt: string; routing?: { decisionId: string; engine: "legacy" | "capability-shadow" | "capability"; policyVersion: string; profileVersion?: string; taskFeaturesHash: string; phaseEntryKey?: string; selectedRank: number; score?: number; separation: "not-applicable" | "different-model" | "different-family"; fallbackCount: number; attemptedModels: string[]; failureCategories: string[]; }; } export interface LifecycleRecoveryArtifactBinding { version: 1; semanticRef: string; sha256: string; sizeBytes: number; storageRef: Readonly; } export interface LifecycleRecoveryActionExecution { version: 1; failureFingerprint: string; failurePhase: "verifying" | "reviewing"; action: "retry" | "repair"; status: "pending" | "completed"; requestRef?: string; intentRef?: Readonly; resultRef?: Readonly; } export interface LifecycleRecoveryEnvelope { version: 1; failurePhase: "verifying" | "reviewing"; binding: Readonly; occurrenceBindings: readonly Readonly[]; ledger: Readonly; artifacts: readonly Readonly[]; actionHistory: readonly Readonly[]; action?: Readonly; } export interface LifecycleState { version: 1 | 2; runId: string; phase: LifecyclePhase; task: string; specPath?: string; planPath?: string; debugPath?: string; debugDiagnosisVerdictIndex?: number; buildIterations: number; consecutiveRejections: number; verdicts: LifecycleStageVerdict[]; modelSelections: LifecycleModelSelection[]; rejectionFingerprints: string[]; buildEvidenceFingerprints: string[]; planFingerprint?: string; pendingCheckerVerdict?: { phase: "verifying" | "reviewing" | "shipping"; kind: "verify" | "review" | "ship"; verdict: LifecycleVerdict; reasons: string; requiredFixes?: string; }; routingPolicyVersion?: string; baselinePaths?: string[]; baselineStagedPaths?: string[]; modelRestored?: boolean; finalization?: { commitSha?: string; commitBaseSha?: string; commitMessage?: string; prUrl?: string; prHead?: string; }; shipReport?: string; yolo: boolean; originalModel?: LifecycleOriginalModelState; recovery?: Readonly; graphExecution?: GraphExecutionState; envelopeRevision?: number; previousEnvelopeHash?: string; envelopeHash?: string; revisionFeedback?: { artifact: "spec" | "plan"; feedback: string; recordedAt: string; }; reminder?: { phase: LifecyclePhase; kind: "artifact" | "verdict" | "debug"; recordedAt: string; }; } export type LifecycleEvent = { type: "start"; task: string; yolo: boolean; } | { type: "spec_produced"; specPath?: string; } | { type: "spec_approved"; } | { type: "spec_rejected_by_user"; } | { type: "plan_produced"; planPath?: string; } | { type: "plan_approved"; } | { type: "plan_rejected_by_user"; } | { type: "build_produced"; } | { type: "debug_produced"; debugPath?: string; recoveryAction?: "retry" | "repair" | "replan" | "fail"; retryPhase?: "verifying" | "reviewing"; } | { type: "recovery_failed"; } | { type: "verdict"; stage: LifecycleVerdictStage; verdict: LifecycleVerdict; reasons?: string; requiredFixes?: string; } | { type: "ship_confirmed"; } | { type: "ship_declined"; } | { type: "finalize_complete"; } | { type: "cancelled"; }; export declare function createIdleLifecycleState(overrides?: Partial): LifecycleState; export declare function nextStage(state: LifecycleState, event: LifecycleEvent, config: LoopConfig): LifecycleState;