import type { KdProduct, ProductProfile } from "../product/profile.ts"; export type KdPhase = "discuss" | "spec" | "plan" | "execute" | "verify" | "ship"; export type KdHarnessMode = "quick" | "normal"; export type KdRisk = "low" | "medium" | "high"; export type KdRunStatus = "active" | "paused" | "done"; export type KdRiskSource = "manual" | "verify" | "ship"; export interface RiskAssessment { level: KdRisk; reason: string; source: KdRiskSource; updatedAt: string; } export interface GateResult { passed: boolean; reason?: string; checkedAt: string; } export interface RepairState { attempts: number; maxAttempts: number; lastFailureEvidence?: string; lastFailureSignature?: string; status: "idle" | "repairing" | "blocked"; goal?: string; updatedAt: string; } export interface KdQuestion { id: string; phase: KdPhase; question: string; reason?: string; contextSummary?: string; sourceRefs?: string[]; factLabel?: string; proposedFactValue?: string; options?: KdQuestionOption[]; choices?: string[]; multiple?: boolean; customAnswer?: boolean; blocking: boolean; status: "open" | "answered"; answer?: string; createdAt: string; answeredAt?: string; } export interface KdQuestionOption { label: string; description?: string; } export interface KdResumeSnapshot { phase: KdPhase; contextSummary: string; sourceRefs?: string[]; gateReason?: string; nextAction: string; pendingQuestionId?: string; status: "open" | "answered" | "archived"; updatedAt: string; } export type KdContextEntryKind = "user-input" | "decision" | "file-finding" | "constraint" | "requirement" | "risk" | "next-action"; export interface KdContextEntry { id: string; phase: KdPhase; kind: KdContextEntryKind; text: string; sourceRefs?: string[]; createdAt: string; } export interface KdWorkingSetFile { path: string; summary: string; source: "tool" | "user" | "artifact"; updatedAt: string; } export interface KdWorkingSet { focus: string; activeGap?: string; currentAction?: string; blockedBy?: string; recentFiles: KdWorkingSetFile[]; forbiddenDrift: string[]; updatedAt: string; } export interface KdToolResultContract { id: string; toolName: string; status: "success" | "blocked" | "failed"; kind: "read" | "search" | "list" | "shell" | "knowledge" | "evidence" | "write" | "other"; summary: string; paths?: string[]; modifiedFiles?: string[]; evidencePaths?: string[]; risk?: string; nextAction?: string; createdAt: string; } export interface KdActionCommit { id: string; phase: KdPhase; focus: string; intent: string; allowed: boolean; reason: string; requiredAction: string; source: "input" | "command" | "tool" | "system"; createdAt: string; } export interface KdWriteTransaction { id: string; path: string; status: "planned" | "blocked" | "written" | "verified"; checks: string[]; reason?: string; createdAt: string; updatedAt: string; } export interface KdSourceAnchorRef { line: number; hash: string; } export interface KdSourceAnchorSnapshot { id: string; path: string; fileHash: string; refs: KdSourceAnchorRef[]; summary?: string; createdAt: string; } export type KdFactStatus = "current" | "superseded" | "rejected"; export type KdFactSource = "question" | "manual"; export interface KdFact { key: string; label: string; value: string; status: KdFactStatus; source: KdFactSource; sourceQuestionId?: string; reason?: string; createdAt: string; updatedAt: string; supersededBy?: string; } export interface ActiveRun { id: string; goal?: string; phase: KdPhase; mode: KdHarnessMode; cwd: string; status?: KdRunStatus; createdAt?: string; updatedAt?: string; product?: KdProduct; version?: string; profile?: ProductProfile; riskAssessment?: RiskAssessment; repair?: RepairState; artifacts: Record; gate: GateResult; questions?: KdQuestion[]; facts?: KdFact[]; contextEntries?: KdContextEntry[]; resumeSnapshot?: KdResumeSnapshot; workingSet?: KdWorkingSet; toolResults?: KdToolResultContract[]; actionCommits?: KdActionCommit[]; writeTransactions?: KdWriteTransaction[]; sourceAnchors?: KdSourceAnchorSnapshot[]; } export declare const PHASE_ORDER: KdPhase[]; export declare const MODE_PHASE_ORDER: Record; export declare const HARNESS_MODES: KdHarnessMode[]; export declare const PHASE_ARTIFACTS: Record; export declare function isKdPhase(value: string): value is KdPhase; export declare function isKdHarnessMode(value: string): value is KdHarnessMode; export declare function phaseOrderForMode(mode: KdHarnessMode): KdPhase[]; export declare function phaseOrderForRun(run: Pick): KdPhase[]; export declare function phaseIndexForRun(run: Pick, phase: KdPhase): number; export declare function phaseIncludedInRun(run: Pick, phase: KdPhase): boolean; export declare function nextPhaseForRun(run: Pick, phase?: KdPhase): KdPhase | undefined;