import type { SpecStatus, Difficulty, RiskLevel, SpecType, SpecScope, SpecTarget, DiagramType, ToolResult } from '../common/index.js';
import type { SpecFormatVersion, SpecHistoryEntry } from './versioning.js';
import type { Estimation, Actuals, ImpactAnalysis } from '../estimation.js';
import type { ConstitutionViolation } from '../project/core.js';
import type { AgentTeamPlan } from '../agent-team.js';
/** A single entry in the status transition history of a spec. */
export interface StatusHistoryEntry {
    readonly status: SpecStatus;
    /** ISO 8601 timestamp of when this status was set. */
    readonly changedAt: string;
}
export interface Spec {
    id: string;
    /** SPEC-601: Globally unique identifier for cross-project portability. */
    uuid?: string;
    title: string;
    slug: string;
    feature?: string;
    type: SpecType;
    scope: SpecScope;
    status: SpecStatus;
    difficulty: Difficulty;
    risk: RiskLevel;
    projectId: string;
    createdAt: string;
    updatedAt: string;
    specPath: string;
    technicalPath: string;
    planPath?: string;
    progressPath?: string;
    executiveReportPath?: string;
    technicalReportPath?: string;
    estimation: Estimation;
    actuals: Actuals | null;
    target: SpecTarget;
    tags: string[];
    dependencies: string[];
    blockedBy: string[];
    gitBranch: string;
    impactAnalysis: ImpactAnalysis | null;
    reviewNotes?: string[];
    /**
     * Ordered log of status transitions, oldest first.
     * Optional for backwards compatibility — absent on specs created before SPEC-529.
     */
    statusHistory?: readonly StatusHistoryEntry[];
    /**
     * Real-time quality indicator computed by spec-health-scorer on every write.
     * Optional for backwards compatibility — absent on specs created before SPEC-571.
     */
    healthScore?: number;
    /** SPEC-612: explicit out-of-scope items declared in spec frontmatter. */
    outOfScope?: string[];
    /** SPEC-615: prior decisions linked to this spec by keyword relevance. */
    priorDecisions?: string[];
    /** SPEC-630: model routing hint derived from difficulty. */
    model?: 'haiku' | 'sonnet' | 'opus';
    /** SPEC-630: token budget derived from devHours. */
    budget?: 800 | 2000 | 4000;
    /** SPEC-766: Generator that produced the initial spec body. */
    generatedWithModel?: string;
    /** SPEC-766: ISO timestamp for initial spec body generation. */
    generatedAt?: string;
    /** SPEC-766: Non-blocking quality warnings emitted by the generator. */
    qualityWarnings?: string[];
    /** SPEC-686: Implementation priority for ROI scoring. Defaults to 'medium'. */
    priority?: 'high' | 'medium' | 'low';
    /**
     * SPEC-717: Version of the spec.md schema/template.
     * Missing on specs created before SPEC-717 — treated as '0.x' (legacy).
     */
    spec_format_version?: SpecFormatVersion;
    /**
     * SPEC-717: SemVer of this spec's content (e.g. "1.0.0").
     * Optional for backward-compat — absent on legacy specs.
     */
    spec_version?: string;
    /**
     * SPEC-717: Machine-readable version history.
     * Optional for backward-compat — absent on legacy specs.
     *
     * NOTE (freeze-on-done): Future SPEC-M2 will enforce that writes to specs
     * with status=done require a preceding bump_spec_version call. The primitive
     * (spec_version field + bump tool) is delivered here; enforcement is deferred.
     */
    history?: readonly SpecHistoryEntry[];
    /**
     * SPEC-770: SHA-256 of (title + projectPath) used for idempotent dedup within a 10-minute window.
     * Prevents duplicate specs when create_spec times out and the client retries.
     */
    idempotencyKey?: string;
    /**
     * SPEC-964: Challenge report stored after running challenge_spec.
     * Contains failure scenarios, addressed count, and overall risk.
     */
    challengeReport?: ChallengeReport;
}
/** SPEC-964: Result of running challenge_spec on a spec. */
export interface ChallengeReport {
    /** When the challenge was run. */
    runAt: string;
    /** Total scenarios generated. */
    totalScenarios: number;
    /** Number of scenarios explicitly addressed (mitigated or accepted). */
    addressedCount: number;
    /** Focus areas that were challenged. */
    focusAreas: string[];
    /** Overall risk level from the challenge. */
    overallRisk: 'low' | 'medium' | 'high' | 'critical';
    /** Whether the challenge passed the mandatory gate. */
    passed: boolean;
}
/** SPEC-630: Model and token budget derived from spec difficulty and devHours. */
export interface ModelBudget {
    model: 'haiku' | 'sonnet' | 'opus';
    budget: 800 | 2000 | 4000;
}
/** SPEC-630: Result of merging technical.md into spec.md. */
export interface UnifiedMigrationResult {
    specDir: string;
    merged: boolean;
    reason: 'ok' | 'already-unified' | 'no-technical-md' | 'error';
    error?: string;
}
export interface SpecSummary {
    specId: string;
    title: string;
    oneLiner: string;
    keyDecisions: string[];
    riskHighlights: string[];
    estimationSummary: string;
    affectedModules: string[];
    criticalDependencies: string[];
    generatedAt: string;
}
export type SummaryFormat = 'executive' | 'technical' | 'oneliner';
export type ChecklistCategory = 'completeness' | 'consistency' | 'feasibility' | 'security' | 'edge-cases' | 'ux';
export interface ChecklistItem {
    id: string;
    question: string;
    category: ChecklistCategory;
    answer: 'yes' | 'no' | 'partial' | 'na' | 'pending';
    evidence?: string;
    autoChecked: boolean;
    passed?: boolean | null;
    detail?: string | null;
}
export interface ChecklistCategoryScore {
    category: ChecklistCategory;
    score: number;
    weight: number;
    items: ChecklistItem[];
}
export interface ChecklistScore {
    overall: number;
    categories: ChecklistCategoryScore[];
    autoCheckedCount: number;
    manualPendingCount: number;
    recommendation: 'approve' | 'review' | 'reject';
}
export interface SpecChecklist {
    specId: string;
    items: ChecklistItem[];
    passedCount: number;
    totalCount: number;
    score: number;
    checklistScore?: ChecklistScore;
    generatedAt: string;
}
export interface ReconcileReport {
    specId: string;
    changes: ReconcileChange[];
    specUpdated: boolean;
    reason: string;
    reconciledAt: string;
}
export interface ReconcileChange {
    section: string;
    originalValue: string;
    newValue: string;
    reason: string;
    approved: boolean;
}
/** Status of a single acceptance criterion during living spec analysis. */
export type CriterionAssessmentStatus = 'met' | 'pending' | 'drift';
/** Assessment of a single acceptance criterion against the codebase. */
export interface CriterionAssessment {
    criterion: string;
    status: CriterionAssessmentStatus;
    evidence: string;
    /** File path where evidence was found (if any). */
    matchedFile?: string;
}
/** Report generated by the living spec analyzer. */
export interface LivingSpecReport {
    specId: string;
    criteria: CriterionAssessment[];
    completionPercent: number;
    metCount: number;
    pendingCount: number;
    driftCount: number;
    analyzedAt: string;
    progressUpdated: boolean;
}
export interface SpecVersion {
    specId: string;
    version: number;
    changes: SpecDiff[];
    changedBy: string;
    timestamp: string;
    reason: string;
}
export interface SpecDiff {
    file: 'spec.md' | 'technical.md' | 'PLAN.md' | 'HU.md' | 'FICHA-TECNICA.md';
    section: string;
    type: 'added' | 'modified' | 'removed';
    before: string;
    after: string;
}
export interface CascadeNotification {
    specId: string;
    title: string;
    status: SpecStatus;
    message: string;
}
export interface CascadeResult {
    affectedSpecs: string[];
    notifications: CascadeNotification[];
    checkedAt: string;
}
export interface VersionHistory {
    specId: string;
    versions: SpecVersion[];
    currentVersion: number;
}
export interface SpecDiagram {
    type: DiagramType;
    title: string;
    format: 'mermaid';
    content: string;
    description: string;
}
export interface SpecSplitSuggestion {
    originalSpecId: string;
    reason: string;
    suggestedSpecs: SpecSplitItem[];
    dependencyOrder: string[];
    totalEstimate: Estimation;
}
export interface SpecSplitItem {
    suggestedTitle: string;
    type: SpecType;
    target: SpecTarget;
    scope: SpecScope;
    description: string;
    criteriaCount: number;
    dependsOn: string[];
    estimatedHours: number;
}
export type ScopeFilter = 'generate_adr' | 'design_schema' | 'define_ui_contract' | 'challenge_spec' | 'generate_execution_plan';
export interface ScopeFilterConfig {
    scope: SpecScope;
    filters: ScopeFilter[];
    allowManualOverride: boolean;
}
/** Result of constitution validation during spec creation. */
export interface ConstitutionCheckResult {
    blocked: boolean;
    errorResult?: ToolResult;
    warnings: ConstitutionViolation[];
}
/** Context gathered during spec construction, passed to post-creation steps. */
export interface SpecBuildContext {
    spec: Spec;
    specDir: string;
    specPath: string;
    technicalPath: string;
    progressPath: string;
    diagrams: SpecDiagram[];
    estimation: Estimation;
    splitSuggestion: SpecSplitSuggestion | null;
    scopeFilters: ScopeFilterConfig;
    duplicate: Spec | undefined;
    projectId: string;
    legalSection: string | null;
    legalCriteria: string[];
    mcpLayerSection: string | null;
    /** Doc-driven criteria from official documentation (SPEC-383) */
    docCriteria?: string[];
    /** SPEC-697: Agent team plan for parallel domain-expert investigation */
    agentTeamPlan?: AgentTeamPlan | null;
}
/** Arguments for the analyze_spec_dependencies tool. */
export interface AnalyzeSpecDepsArgs {
    projectId: string;
    specIds?: string[];
}
/** A node in the spec dependency graph. */
export interface SpecDependencyNode {
    specId: string;
    title: string;
    status: SpecStatus;
    estimate: number;
}
/** Directed graph of spec dependencies. */
export interface SpecDependencyGraph {
    nodes: Map<string, SpecDependencyNode>;
    edges: Map<string, string[]>;
}
/** A dependency suggested by auto-detection of SPEC-NNN cross-references. */
export interface SuggestedDependency {
    /** The spec ID that was referenced in the content. */
    specId: string;
    /**
     * Confidence level of the suggestion.
     * - `explicit`: A literal "SPEC-NNN" pattern was found in the text.
     * - `contextual`: Inferred from semantic context (reserved for future use).
     */
    confidence: 'explicit' | 'contextual';
}
/** Result of analyzing the spec dependency graph. */
export interface SpecDependencyAnalysis {
    criticalPath: string[];
    criticalPathHours: number;
    cycles: string[][];
    executionWaves: string[][];
    mermaidDiagram: string;
    totalSpecs: number;
    totalEdges: number;
    /** Auto-detected cross-references per spec (suggestions only — not auto-added). */
    suggestedDependencies?: Record<string, readonly SuggestedDependency[]>;
}
/** A status entry from the data store, used for divergence detection. */
export interface SpecStatusEntry {
    id: string;
    status: SpecStatus;
}
/** A single status divergence between YAML frontmatter and data store. */
export interface SyncDivergence {
    specId: string;
    yamlStatus: string;
    dataStatus: string;
}
/** Report produced by spec state synchronisation. */
export interface SyncReport {
    synced: number;
    divergences: SyncDivergence[];
    errors: string[];
    /** SPEC-720: File→store status drift entries that were refused. */
    rejected: {
        specId: string;
        reason: string;
    }[];
}
//# sourceMappingURL=core.d.ts.map