import type { FailureType } from "./base.js";
import type { ExecutionContract } from "./execution.js";
import type { EvidenceItem, CoverageMatrix } from "./evidence.js";
import type { UncertaintyTrigger } from "./phase.js";
import type { KnowledgeInjectionReport } from "./knowledge.js";
import type { IngestionEvidence, InputMaterial, PromptInjectionPlan } from "../engine/pipeline/input_material_contract_registry.js";
import type { OutputArtifact } from "../engine/contracts/artifact_contract_registry.js";
import type { DataSensitivityLabel, PrivacyGovernanceFinding, RedactionRecord } from "../engine/audit/privacy_secret_contract.js";
import type { ArchitectureDesignContract } from "../engine/contracts/extension_platform_contracts.js";
import type { IntegrationFinding } from "../engine/audit/main_path_integration_contract.js";
import type { CorePrinciplesReport } from "../engine/audit/core_engineering_principles.js";
import type { CommandContract } from "../engine/contracts/command_execution_contract.js";
/** 意图路由类型 */
export type IntentRoute = "skip_chat" | "direct_answer" | "artifact_generation" | "source_extraction" | "code_change" | "analysis" | "review" | "acceptance" | "planning" | "operation";
/** 执行形态 */
export type ExecutionShape = "none" | "single_artifact" | "multi_stage_plan" | "code_execution" | "read_only_analysis" | "verification_only";
/** 产物操作类型 — 从意图路由和动作信号推导 */
export type OperationType = "extract" | "review" | "fix" | "iterate";
/** 配置生命周期 */
export type ConfigLifetime = "single_invocation" | "task" | "project_persistent" | "global";
/** 规范化解析来源 */
export type ConfigSource = "user_task" | "cli_flag" | "mcp_param" | "confirmed_config" | "project_policy" | "fingerprint" | "blueprint" | "product_profile" | "knowledge_default" | "global_default";
/** 配置值证据 */
export interface ConfigValueEvidence {
    field_path: string;
    value: unknown;
    source: ConfigSource;
    confidence: number;
    evidence_ref?: string;
    updated_at: string;
}
/** 配置冲突 */
export interface ConfigConflict {
    source_a: ConfigSource;
    source_b: ConfigSource;
    field_path: string;
    reason: string;
    requires_human: boolean;
}
/** 配置解析报告 */
export interface ConfigResolutionReport {
    field_path: string;
    selected: ConfigValueEvidence;
    candidates: ConfigValueEvidence[];
    conflicts: ConfigConflict[];
    overridden_by_guard?: string;
    lifetime: ConfigLifetime;
}
/** 工具类别 */
export type ToolCategory = "strict_controlled" | "read_only_bypass" | "normal_controlled";
/** 副作用类型 */
export type SideEffect = "none" | "task_context_write" | "file_write" | "knowledge_write" | "config_write" | "command_execution" | "git_commit" | "git_push" | "pr_create" | "external_write";
/** 违规类型 */
export type ViolationType = "not_allowed_next_tool" | "side_effect_exceeded" | "missing_authorization" | "guard_blocked" | "read_only_bypass_write" | "contract_state_mismatch" | "trace_missing";
/** 违规严重程度 */
export type ViolationSeverity = "warning" | "require_human" | "hard_fail";
/** 工具授权 */
export interface ToolAuthorization {
    required: boolean;
    granted: boolean;
    reason?: string;
}
/** 工具旁路 */
export interface ToolBypass {
    allowed: boolean;
    reason: "read_only" | "user_explicit" | "diagnostic";
}
/** 工具调用追踪 */
export interface ToolTrace {
    tool_name: string;
    invocation_id: string;
    task_id?: string;
    workflow_id?: string;
    route?: IntentRoute;
    execution_shape?: ExecutionShape;
    contract_ids: string[];
    capability_ids: string[];
    guard_report_id?: string;
    degraded: boolean;
    warnings: string[];
    side_effects: SideEffect[];
    next_allowed_tools: string[];
    forbidden_tools: string[];
    authorization?: ToolAuthorization;
    bypass?: ToolBypass;
}
/** 工具调用违规记录 */
export interface ToolInvocationViolation {
    invocation_id: string;
    tool_name: string;
    violation_type: ViolationType;
    severity: ViolationSeverity;
    reason: string;
    recovery: string;
}
/** 工具调用契约 */
export interface ToolInvocationContract {
    tool_name: string;
    category: ToolCategory;
    side_effects: SideEffect[];
    requires_authorization: boolean;
    requires_workflow: boolean;
    description: string;
    default_next_tools: string[];
    forbidden_next_tools: string[];
}
/** 适配器工作流策略规则 */
export interface AdapterWorkflowPolicyRule {
    id: string;
    rule: string;
    enforcement: "hard_fail" | "warning" | "advisory";
    description: string;
}
/** 工具调用治理发现 */
export interface ToolInvocationGovernanceFinding {
    severity: "hard_fail" | "advisory";
    tool_name: string;
    rule: string;
    message: string;
}
/** 变异候选点 */
export interface MutationPoint {
    file_path: string;
    line_number: number;
    original_line: string;
    requirement_point_id?: string;
}
/** 变异审计条目 */
export interface MutationAuditEntry {
    requirement_point_id: string;
    mutation_points: number;
    mutants_killed: number;
    mutants_total: number;
    advisory: string;
    /** 严重级别（防 AI 偷懒门禁硬化） */
    severity?: "hard_fail" | "warning";
}
/** 变异审计证据（R9 需求绑定变异点 + mutant killed 证据） */
export interface MutationAuditEvidence {
    mutant_killed_count: number;
    mutant_total_count: number;
    kill_ratio: number;
    per_requirement: MutationAuditEntry[];
    uncovered_requirements: string[];
    summary: string;
    /** 门禁硬化汇总 */
    hard_fail_count?: number;
    warning_count?: number;
}
/** 工作流追踪*/
export interface WorkflowTrace {
    /** 工作流契约 ID */
    workflow_id: string;
    /** 路由 */
    route: string;
    /** 执行形态 */
    execution_shape: string;
    /** 是否允许变更 */
    mutation_allowed: boolean;
    /** 必需机制列表 */
    required_mechanisms: string[];
    /** 治理检查结果 */
    governance_findings: Array<{
        severity: string;
        rule: string;
        message: string;
    }>;
    /** 是否降级 */
    degraded: boolean;
    /** 状态转换目标 */
    state_transition_target: string;
    /** 审计检查项 — 记录已执行的治理检查 */
    checked_items?: string[];
}
/** scope 解析证据来源 */
export interface ScopeResolutionSource {
    source: string;
    confidence: "high" | "medium" | "low";
    role?: "backend" | "frontend" | "shared" | "output" | "readonly";
    repo_name?: string;
    base_path?: string;
    declared_paths: string[];
    resolved_paths: string[];
    evidence: string[];
}
/** scope 解析审计报告 */
export interface ScopeResolutionReport {
    status: "resolved" | "fallback" | "blocked";
    project_root: string;
    path_semantics: {
        storage_format: "project_relative_posix";
        host_platform: NodeJS.Platform;
        case_sensitive: boolean;
    };
    allowed_paths: string[];
    readonly_paths: string[];
    new_files_allowed: boolean;
    sources: ScopeResolutionSource[];
    discovered_source_roots: string[];
    warnings: string[];
    conflicts: string[];
    recovery_commands: string[];
}
/** 作用域结果 */
export interface ScopeResult {
    /** 允许修改的路径（空 = 不收窄，仅受内置黑名单约束） */
    allowed_paths: string[];
    /** 只读路径 */
    readonly_paths: string[];
    /** 黑名单模式标记 — true 表示仅受内置黑名单约束，不收窄 */
    blacklist_only?: boolean;
    /** 是否允许新建文件 */
    new_files_allowed: boolean;
    /** 新文件命名模式 */
    new_file_patterns?: string[];
    /** scope 解析审计报告 */
    resolution?: ScopeResolutionReport;
}
/** 验收条目 */
export interface AcceptanceItem {
    /** 验收项 ID */
    id: string;
    /** 验收描述 */
    description: string;
    /** 验收类型 */
    type: "automated" | "manual";
    /** 自动化检查命令 */
    check_command?: string;
}
/** 需求点（R9 语义交付证据） */
export interface RequirementPoint {
    /** 需求点 ID */
    id: string;
    /** 需求描述 */
    description: string;
    /** 关联的验收测试 ID 列表 */
    acceptance_test_ids?: string[];
}
/** 语义证据（R9 验证时产出） */
export interface SemanticEvidence {
    /** 变更行为列表 */
    changed_behaviors: Array<{
        file_path: string;
        description: string;
        requirement_point_id?: string;
    }>;
    /** 未变更断言列表 */
    unchanged_assertions: Array<{
        file_path: string;
        assertion_description: string;
        still_valid: boolean;
    }>;
    /** 需求点覆盖状态 */
    requirement_coverage: Array<{
        requirement_point_id: string;
        covered: boolean;
        evidence: string;
    }>;
}
/** 扩展结果，包含完整的任务执行指令 */
export interface ExpandResult {
    /** 任务 ID */
    task_id: string;
    /** 生成的 prompt */
    prompt: string;
    /** 作用域结果 */
    scope: ScopeResult;
    /** scope 解析审计报告 */
    scope_resolution?: ScopeResolutionReport;
    /** 验收条件 */
    acceptance: {
        /** 自动化验收项 */
        automated: AcceptanceItem[];
        /** 人工验收项 */
        manual: AcceptanceItem[];
    };
    /** 匹配的模式列表 */
    matched_patterns: string[];
    /** 匹配的知识条目列表 */
    matched_knowledge: string[];
    /** 是否为遗留代码 */
    is_legacy_code: boolean;
    /** 遗留代码约定 */
    legacy_conventions?: string[];
    /** 是否降级执行 */
    degraded: boolean;
    /** 执行契约 */
    contract?: ExecutionContract;
    /** 不确定性触发器列表 */
    uncertainty_triggers?: UncertaintyTrigger[];
    /** 置信度熔断结果（机制 1） */
    circuit_breaker?: {
        tripped: boolean;
        confidence: number;
        reason?: string;
        brainstorm?: {
            blind_spots: string[];
            evolution_tracks: {
                minimal: string;
                industrial: string;
                radical: string;
            };
            decision_questions: Array<{
                question: string;
                option_a: string;
                option_b: string;
            }>;
        };
    };
    /** 需求点列表（R9 语义交付证据） */
    requirement_points?: RequirementPoint[];
    /** 知识注入边界报告*/
    injection_report?: KnowledgeInjectionReport;
    /** 用户项目知识审计与本次任务选中结果*/
    project_knowledge?: {
        total: number;
        hard_fail_count: number;
        warning_count: number;
        selected: Array<{
            id: string;
            name: string;
            rel_path: string;
            consumption: string;
            identity: string;
        }>;
        selection_decisions?: Array<{
            id: string;
            name: string;
            rel_path: string;
            status: string;
            enforcement: string;
            reason_zh: string;
            matched_signals: string[];
            excluded_reasons: string[];
            verification_command?: string;
        }>;
        findings: Array<{
            rel_path: string;
            code: string;
            severity: string;
            message_zh: string;
        }>;
    };
    /** 工作流追踪*/
    workflow_trace?: WorkflowTrace;
    /** 工具调用追踪*/
    tool_trace?: ToolTrace;
    /** 下一步允许的工具列表*/
    next_allowed_tools?: string[];
    /** 被禁止的工具列表*/
    forbidden_tools?: string[];
    /** 输入材料契约列表*/
    input_materials?: InputMaterial[];
    /** 摄取证据列表*/
    ingestion_evidences?: IngestionEvidence[];
    /** Prompt 注入边界计划*/
    prompt_injection_plan?: PromptInjectionPlan;
    /** 输出产物记录*/
    output_artifact_record?: OutputArtifact;
    /** 配置优先级解析报告*/
    config_resolution_reports?: ConfigResolutionReport[];
    /** 敏感度标签列表（ 隐私） */
    sensitivity_labels?: DataSensitivityLabel[];
    /** 脱敏记录列表（ 隐私） */
    redaction_records?: RedactionRecord[];
    /** 隐私治理发现（ 隐私） */
    privacy_findings?: PrivacyGovernanceFinding[];
    /** 架构决策合同 */
    architecture_contract?: ArchitectureDesignContract;
}
/** 验证结果 */
export interface VerifyResult {
    /** 任务 ID */
    task_id: string;
    /** 检查项分组 */
    checks: {
        /** 构建检查命令列表 */
        build: VerifyCommand[];
        /** 测试检查命令列表 */
        tests: VerifyCommand[];
        /** 验收检查结果 */
        acceptance?: AcceptanceCheckResult[];
    };
    /** 验证摘要 */
    summary: string;
    /** 需人工确认的项 */
    manual_items: string[];
    /** 证据条目列表 */
    evidence?: EvidenceItem[];
    /** 覆盖率矩阵 */
    coverage?: CoverageMatrix;
    /** 三重否定推演结果（机制 2） */
    triple_negation?: {
        crash_scenarios: string[];
        mitigation_suggestions: string[];
        audit_declaration: string;
        passed: boolean;
    };
    /** 语义证据（R9 语义交付证据） */
    semantic_evidence?: SemanticEvidence;
    /** 变异审计证据（R9 需求绑定变异点） */
    mutation_evidence?: MutationAuditEvidence;
    /** 主链路集成检查结果*/
    main_path_integration?: {
        /** 是否通过集成检查 */
        passed: boolean;
        /** 孤岛检测结果 */
        findings: IntegrationFinding[];
        /** 受检模块列表 */
        checked_modules: string[];
        /** 审计报告 */
        summary: string;
    };
    /** 核心工程执行原则检查结果*/
    core_principles?: CorePrinciplesReport;
    /** 命令契约列表*/
    command_contracts?: CommandContract[];
    /** 遗漏扫描结果（防 AI 偷懒） */
    omission_scan?: {
        /** 扫描的文件列表 */
        scanned_files: string[];
        /** 发现项总数 */
        total_findings: number;
        /** 阻塞级发现数 */
        hard_fail_count: number;
        /** 摘要 */
        summary: string;
        /** 对抗性 AI prompt（供后续深度审计） */
        adversarial_prompt?: string;
    };
    /** 代码质量门禁结果（防 AI 偷懒 — sf_verify 步骤 7a-7e） */
    code_quality?: {
        /** 偷懒模式 hard_fail 数（A1） */
        lazy_pattern_findings: number;
        /** 错误处理路径 hard_fail 数（C6） */
        error_path_findings: number;
        /** 测试质量 hard_fail 数（C5） */
        test_quality_hard_fails: number;
        /** 变异审计 hard_fail 数（C7） */
        mutation_hard_fails: number;
        /** 行为覆盖率 warning 数（C8） */
        behavior_coverage_warnings: number;
        /** 摘要 */
        summary: string;
    };
}
/** 验证命令 */
export interface VerifyCommand {
    /** 要执行的命令 */
    command: string;
    /** 工作目录 */
    cwd: string;
    /** 超时提示（毫秒） */
    timeout_hint: number;
    /** 命令描述 */
    description: string;
}
/** 验收检查结果 */
export interface AcceptanceCheckResult {
    /** 验收项 ID */
    id: string;
    /** 验收描述 */
    description: string;
    /** 检查命令 */
    check_command: string;
    /** 工作目录 */
    cwd: string;
}
/** 学习结果 */
export interface LearnResult {
    /** 任务 ID */
    task_id: string;
    /** 是否产生新知识 */
    learned: boolean;
    /** 新知识内容 */
    new_knowledge?: {
        /** 知识类型 */
        type: "pattern" | "procedure" | "rule_upgrade" | "prompt_optimization" | "acceptance_supplement";
        /** 知识内容 */
        content: string;
        /** 适用范围 */
        scope: string[];
        /** 适用产品 */
        products: string[];
    };
    /** 置信度 (0-1) */
    confidence: number;
    /** 状态: accepted=已接受, staged=暂存, skipped=跳过 */
    status: "accepted" | "staged" | "skipped";
    /** 暂存路径 */
    staged_path?: string;
    /** 重试提示 */
    retry_hint?: string;
}
/** 失败分类结果 */
export interface FailureClassifyResult {
    /** 失败类型 */
    failure_type: FailureType;
    /** 是否与上次相同错误 */
    is_same_error: boolean;
    /** 剩余重试次数 */
    retry_remaining: number;
    /** 建议动作: retry=重试, expand_scope=扩大范围, escalate=升级 */
    action: "retry" | "expand_scope" | "escalate";
    /** 发起阶段 */
    phase_origin?: string;
    /** 是否可自动修复 */
    auto_repairable?: boolean;
    /** 升级原因 */
    escalation_reason?: string;
    /** 重复出现次数 */
    recurrence_count?: number;
}
/** 失败记录 */
export interface FailureRecord {
    /** 尝试序号 */
    attempt: number;
    /** 失败类型 */
    type: FailureType;
    /** 失败信息 */
    message: string;
    /** 失败时间戳 */
    timestamp: string;
    /** 失败所处阶段 */
    phase?: string;
}
//# sourceMappingURL=pipeline.d.ts.map