/**
 * Mechanism Contract Registry — 平台与扩展机制契约（9-28）。
 *
 * 包括 core_engineering_principles、delivery、zero_config_init、input_material、
 * user_feedback、artifact、config_precedence、extension、platform_compatibility、
 * metric_governance、decision_sovereignty、brainstorm、detail_discipline、
 * first_principles、architecture_design、decision_workshop、
 * architecture_decision_workshop、standard_asset_coverage、design_artifact_pack、
 * standard_asset_contract、template_asset_visibility、existing_system_analysis、
 * coding_readiness、local_acceptance、workflow_template_pack、evolution_regression。
 */
/** 平台与扩展 P0 机制契约 */
export const PLATFORM_CONTRACTS = [
    // ── 9. core_engineering_principles ──
    {
        id: "mc-core-engineering-principles",
        name: "Core Engineering Principles",
        owner_module: "src/engine/audit/core_engineering_principles.ts",
        owner_exports: ["checkCorePrinciples", "checkThinkBeforeCoding", "checkSimplicityFirst", "checkSurgicalChanges", "checkGoalDrivenExecution", "validateAntiCircumvention"],
        mechanism_type: "governance",
        status: "enforced",
        trigger: "sf_verify 验证阶段 / sf_governance_report 治理报告",
        required_inputs: ["route", "execution_shape", "changed_files", "declared_scope"],
        preconditions: ["分类已完成，route 和 execution_shape 已确定"],
        outputs: ["CorePrinciplesReport", "CorePrinciplesCheckResult[]", "task_level"],
        downstream_consumers: ["verifier", "governance_report", "adapter_tools"],
        state_transitions: [
            "principles_failed → repair_reverify",
            "principles_passed → advance_next",
        ],
        failure_modes: [
            "required 原则检查失败但被忽略",
            "伪满足: 声称 passed 但无证据引用",
            "blocking 不确定被伪装为 assumption",
        ],
        degradation_behavior: "检查模块不可用时降级为 advisory，不阻断主链路",
        tests: ["tests/engine/core_engineering_principles.test.ts"],
        lifecycle_tests: ["tests/engine/core_engineering_principles.test.ts", "tests/engine/dual_layer_mechanism_registry.test.ts"],
    },
    // ── 交付 ──
    {
        id: "mc-delivery-gate",
        name: "Delivery Gate",
        owner_module: "src/engine/audit/delivery.ts",
        owner_exports: ["deliver", "generateChangelogEntry"],
        mechanism_type: "delivery",
        status: "enforced",
        trigger: "sf_deliver 调用时，verify 通过后",
        required_inputs: ["taskContext", "config"],
        preconditions: ["verification passed", "no active write lease conflict"],
        outputs: ["DeliveryResult", "ChangelogEntry"],
        downstream_consumers: ["adapter_tools", "developer_sovereignty"],
        failure_modes: [
            "delivery without verification",
            "commit conflict during push",
            "PR creation failure",
        ],
        degradation_behavior: "delivery 失败时降级为 manual_required，保留 commit",
        tests: ["tests/engine/delivery.test.ts"],
        lifecycle_tests: ["tests/engine/delivery.test.ts"],
    },
    // ── 11. zero_config_init ──
    {
        id: "mc-zero-config-init",
        name: "零配置初始化",
        owner_module: "src/engine/config/zero_config_init.ts",
        owner_exports: ["detectFingerprint", "generateConfigDraft", "validateConfigDraft"],
        mechanism_type: "initialization",
        status: "enforced",
        trigger: "初始化",
        required_inputs: ["project_path"],
        preconditions: [],
        outputs: ["ProjectConfig"],
        downstream_consumers: ["sf_expand", "sf_verify", "sf_validate"],
        state_transitions: [],
        cleanup_hooks: [],
        failure_modes: ["fingerprint_collision", "config_parse_error"],
        degradation_behavior: "manual config fallback",
        tests: ["tests/engine/zero_config_init.test.ts"],
        lifecycle_tests: ["tests/engine/zero_config_init.test.ts"],
    },
    // ── 12. input_material_contract ──
    {
        id: "mc-input-material-contract",
        name: "输入材料契约",
        owner_module: "src/engine/pipeline/input_material_contract_registry.ts",
        owner_exports: ["canSupportStrongConclusion", "isWriteAllowed"],
        mechanism_type: "safety",
        status: "enforced",
        trigger: "架构设计",
        required_inputs: ["input_materials"],
        preconditions: ["privacy_gate_pass"],
        outputs: ["InputMaterialContract"],
        downstream_consumers: ["sf_expand", "privacy_gate"],
        state_transitions: [],
        cleanup_hooks: [],
        failure_modes: ["unregistered_source", "invalid_material_type"],
        degradation_behavior: "permissive mode fallback",
        tests: ["tests/engine/input_material_contract_registry.test.ts"],
        lifecycle_tests: ["tests/engine/input_material_contract_registry.test.ts"],
    },
    // ── 13. user_feedback ──
    {
        id: "mc-user-feedback",
        name: "用户反馈契约",
        owner_module: "src/engine/contracts/user_feedback_contract.ts",
        owner_exports: ["createUserFeedbackMessage", "validateUserFeedbackContract", "getAllowedFeedbackKinds"],
        mechanism_type: "feedback",
        status: "enforced",
        trigger: "联调验证",
        required_inputs: ["verification_result"],
        preconditions: [],
        outputs: ["UserFeedbackMessage"],
        downstream_consumers: ["sf_learn", "sf_verify"],
        state_transitions: [],
        cleanup_hooks: [],
        failure_modes: ["forbidden_wording", "severity_mismatch"],
        degradation_behavior: "simple message fallback",
        tests: ["tests/engine/user_feedback_contract.test.ts"],
        lifecycle_tests: ["tests/engine/user_feedback_contract.test.ts"],
    },
    // ── 14. artifact_contract ──
    {
        id: "mc-artifact-contract",
        name: "产物契约",
        owner_module: "src/engine/contracts/artifact_contract_registry.ts",
        owner_exports: ["canTransition", "transitionRequiresVerification"],
        mechanism_type: "artifact_management",
        status: "enforced",
        trigger: "架构设计",
        required_inputs: ["output_artifact"],
        preconditions: [],
        outputs: ["ArtifactContract", "OutputArtifact"],
        downstream_consumers: ["sf_verify", "sf_deliver"],
        state_transitions: [],
        cleanup_hooks: [],
        failure_modes: ["missing_contract", "overwrite_violation"],
        degradation_behavior: "manual artifact management fallback",
        tests: ["tests/engine/artifact_contract_registry.test.ts"],
        lifecycle_tests: ["tests/engine/artifact_contract_registry.test.ts"],
    },
    // ── 15. config_precedence ──
    {
        id: "mc-config-precedence",
        name: "配置优先级契约",
        owner_module: "src/engine/config/config_precedence_contract.ts",
        owner_exports: ["listPrecedenceRules", "getPrecedenceRank"],
        mechanism_type: "governance",
        status: "enforced",
        trigger: "初始化",
        required_inputs: ["field_key"],
        preconditions: [],
        outputs: ["ConfigPrecedenceResult"],
        downstream_consumers: ["初始化", "sf_validate"],
        state_transitions: [],
        cleanup_hooks: [],
        failure_modes: ["invalid_override", "circular_dependency"],
        degradation_behavior: "default config fallback",
        tests: ["tests/engine/config_precedence_contract.test.ts"],
        lifecycle_tests: ["tests/engine/config_precedence_contract.test.ts"],
    },
    // ══ 扩展平台机制契约 ══
    // ── 16. extension_contract (problem-39) ──
    {
        id: "mc-extension-contract",
        name: "扩展生命周期与权限管控",
        owner_module: "src/engine/contracts/extension_contract.ts",
        owner_exports: ["validateExtensionManifest", "evaluateExtensionLifecycle", "grantExtensionPermissions"],
        mechanism_type: "safety",
        status: "enforced",
        trigger: "扩展注册与权限申请时",
        required_inputs: ["extension_manifest", "capability_declaration"],
        preconditions: ["extension_id 非空"],
        outputs: ["ExtensionManifest", "ExtensionLifecycleResult", "PermissionGrantResult"],
        downstream_consumers: ["sf_expand", "sf_verify"],
        failure_modes: ["第三方扩展自称 enforced", "高风险权限未审批", "非法生命周期转移"],
        degradation_behavior: "扩展不合规时拒绝注册",
        tests: ["tests/engine/extension_scenario_matrix.test.ts"],
        lifecycle_tests: ["tests/engine/extension_scenario_matrix.test.ts"],
    },
    // ── 17. platform_compatibility (problem-40) ──
    {
        id: "mc-platform-compatibility",
        name: "跨平台路径安全",
        owner_module: "src/engine/contracts/platform_context.ts",
        owner_exports: ["normalizePathRef", "checkPathSafety", "detectPlatformContext"],
        mechanism_type: "safety",
        status: "enforced",
        trigger: "文件路径操作时",
        required_inputs: ["raw_path", "platform_context", "scope_boundary"],
        preconditions: ["scope_boundary 已设定"],
        outputs: ["NormalizedPathRef", "PathSafetyCheck"],
        downstream_consumers: ["sf_expand", "sf_verify"],
        failure_modes: ["路径逃逸未检测", "大小写冲突", "scope 边界绕过"],
        degradation_behavior: "路径不安全时拒绝操作",
        tests: ["tests/engine/extension_scenario_matrix.test.ts"],
        lifecycle_tests: ["tests/engine/extension_scenario_matrix.test.ts"],
    },
    // ── 18. metric_governance (problem-19) ──
    {
        id: "mc-metric-governance",
        name: "指标治理",
        owner_module: "src/engine/contracts/metric_governance.ts",
        owner_exports: ["evaluateMetrics", "evaluateGovernanceAction", "createGovernanceFinding"],
        mechanism_type: "governance",
        status: "enforced",
        trigger: "治理指标评估时",
        required_inputs: ["metric_samples"],
        preconditions: [],
        outputs: ["MetricsEvaluationResult", "GovernanceFinding"],
        downstream_consumers: ["sf_verify", "sf_learn"],
        failure_modes: ["skipped 算 passed", "高风险动作自动触发"],
        degradation_behavior: "指标不合规时标记为 failed",
        tests: ["tests/engine/extension_scenario_matrix.test.ts"],
        lifecycle_tests: ["tests/engine/extension_scenario_matrix.test.ts"],
    },
    // ── 19. decision_sovereignty (problem-16) ──
    {
        id: "mc-decision-sovereignty",
        name: "技术决策主权",
        owner_module: "src/engine/contracts/technology_decision.ts",
        owner_exports: ["validateTechnologyDecision", "evaluateDecisionExecution", "createDecisionRecord"],
        mechanism_type: "governance",
        status: "enforced",
        trigger: "技术决策评估时",
        required_inputs: ["decision_contract", "decision_record"],
        preconditions: [],
        outputs: ["TechnologyDecisionContract", "DecisionValidationResult"],
        downstream_consumers: ["sf_expand", "sf_verify"],
        failure_modes: ["architecture 无 human gate", "推荐状态可执行"],
        degradation_behavior: "决策不合规时拒绝执行",
        tests: ["tests/engine/extension_scenario_matrix.test.ts"],
        lifecycle_tests: ["tests/engine/extension_scenario_matrix.test.ts"],
    },
    // ── 20. brainstorm_contract (problem-41) ──
    {
        id: "mc-brainstorm-contract",
        name: "脑暴与方案探索",
        owner_module: "src/engine/contracts/brainstorm_contract.ts",
        owner_exports: ["validateBrainstormSession", "canBrainstormAutoExecute", "createBrainstormSession"],
        mechanism_type: "governance",
        status: "enforced",
        trigger: "技术选择脑暴时",
        required_inputs: ["problem_statement", "trigger"],
        preconditions: [],
        outputs: ["BrainstormSession", "BrainstormValidationResult"],
        downstream_consumers: ["sf_expand"],
        failure_modes: ["脑暴无候选方案", "脑暴绕过决策主权"],
        degradation_behavior: "脑暴不完整时阻断",
        tests: ["tests/engine/extension_scenario_matrix.test.ts"],
        lifecycle_tests: ["tests/engine/extension_scenario_matrix.test.ts"],
    },
    // ── 21. detail_discipline (problem-26) ──
    {
        id: "mc-detail-discipline",
        name: "细节纪律",
        owner_module: "src/engine/contracts/detail_discipline.ts",
        owner_exports: ["performDetailCheck", "checkDetailGateIntegration", "createDetailDisciplineContract"],
        mechanism_type: "safety",
        status: "enforced",
        trigger: "实现阶段细节检查时",
        required_inputs: ["contract", "task_id", "phase"],
        preconditions: [],
        outputs: ["DetailDisciplineCheck", "DetailGateIntegrationResult"],
        downstream_consumers: ["sf_expand", "sf_verify", "delivery"],
        failure_modes: ["缺失关键维度", "未接入交付 gate"],
        degradation_behavior: "细节不足时阻断",
        tests: ["tests/engine/extension_scenario_matrix.test.ts"],
        lifecycle_tests: ["tests/engine/extension_scenario_matrix.test.ts"],
    },
    // ── 22. first_principles (problem-27) ──
    {
        id: "mc-first-principles",
        name: "第一性原理",
        owner_module: "src/engine/contracts/first_principles.ts",
        owner_exports: ["performFirstPrinciplesCheck", "validateFirstPrinciplesForHighImpact", "createFirstPrinciplesFrame"],
        mechanism_type: "safety",
        status: "enforced",
        trigger: "高影响变更推理时",
        required_inputs: ["problem_id", "user_goal"],
        preconditions: [],
        outputs: ["FirstPrinciplesFrame", "FirstPrinciplesCheckResult"],
        downstream_consumers: ["sf_expand"],
        failure_modes: ["缺少 fundamental_need", "无法阻断错误前提"],
        degradation_behavior: "推理不完整时阻断",
        tests: ["tests/engine/extension_scenario_matrix.test.ts"],
        lifecycle_tests: ["tests/engine/extension_scenario_matrix.test.ts"],
    },
    // ── 23. architecture_design (problem-49) ──
    {
        id: "mc-architecture-design",
        name: "架构设计审查",
        owner_module: "src/engine/contracts/architecture_design_contract.ts",
        owner_exports: ["reviewArchitectureDesign", "validateOutputDirectoryDecision", "validateMermaidDiagrams"],
        mechanism_type: "governance",
        status: "enforced",
        trigger: "架构设计阶段时",
        required_inputs: ["architecture_contract"],
        preconditions: [],
        outputs: ["ArchitectureDesignContract", "ArchitectureReviewResult"],
        downstream_consumers: ["sf_expand", "sf_verify"],
        failure_modes: ["输出目录未确认", "Mermaid 不可渲染"],
        degradation_behavior: "设计不合规时阻断交付",
        tests: ["tests/engine/extension_scenario_matrix.test.ts"],
        lifecycle_tests: ["tests/engine/extension_scenario_matrix.test.ts"],
    },
    // ── 第六批: 通用决策研讨机制（问题六十一） ──
    {
        id: "mc-decision-workshop",
        name: "通用决策研讨机制",
        owner_module: "src/engine/contracts/decision_workshop.ts",
        owner_exports: ["requiresDecisionWorkshop", "createDecisionWorkshop", "evaluateDecisionWorkshop", "applyDecisionWorkshopGate"],
        mechanism_type: "governance",
        status: "enforced",
        trigger: "高影响/不确定任务执行前",
        required_inputs: ["workflow_intent", "task_type", "intent"],
        preconditions: ["任务意图已识别"],
        outputs: ["DecisionWorkshopContract", "DecisionWorkshopGateResult"],
        downstream_consumers: ["sf_expand"],
        failure_modes: ["必须域未确认即执行", "现有系统缺证据", "用户确认引用缺失"],
        degradation_behavior: "缺决策或确认时返回待讨论清单并阻断执行",
        tests: ["tests/engine/decision_workshop.test.ts"],
        lifecycle_tests: ["tests/engine/decision_workshop.test.ts"],
    },
    // ── 第六批: 架构决策研讨机制（问题六十一内置子包） ──
    {
        id: "mc-architecture-decision-workshop",
        name: "架构决策研讨与确认门",
        owner_module: "src/engine/contracts/architecture_decision_workshop.ts",
        owner_exports: ["createArchitectureDecisionWorkshop", "evaluateArchitectureDecisionWorkshop", "requiresArchitectureDecisionWorkshop"],
        mechanism_type: "governance",
        status: "enforced",
        trigger: "architecture_design 正式设计生成前",
        required_inputs: ["workflow_intent", "architecture_decision_workshop"],
        preconditions: ["架构意图已识别"],
        outputs: ["ArchitectureDecisionWorkshopContract", "ArchitectureWorkshopGateResult"],
        downstream_consumers: ["sf_expand", "mc-architecture-design", "mc-design-artifact-pack"],
        failure_modes: ["六类决策域未确认即生成正式架构设计", "现有系统缺现状差距证据", "决策返工未传播"],
        degradation_behavior: "缺决策或确认时返回中文待讨论清单并阻断正式设计 prompt",
        tests: ["tests/engine/architecture_decision_workshop.test.ts"],
        lifecycle_tests: ["tests/adapters/architecture_design_workshop_mainpath.test.ts"],
    },
    // ── 第六批: 标准资产覆盖审计机制（问题六十二） ──
    {
        id: "mc-standard-asset-coverage",
        name: "标准资产覆盖审计",
        owner_module: "src/engine/templates/standard_asset_coverage.ts",
        owner_exports: ["auditStandardAssetCoverage"],
        mechanism_type: "contract_enforcement",
        status: "enforced",
        trigger: "发布门槛验证、validate-release",
        required_inputs: ["rootDir", "consumableAssetPaths", "mechanismOwners"],
        preconditions: ["consumable_asset_registry 已加载"],
        outputs: ["StandardAssetCoverageReport"],
        downstream_consumers: ["validate-release", "sf_verify"],
        failure_modes: ["P0 资产缺少承载路径", "P0 资产未注册", "P0 资产缺少 owner"],
        degradation_behavior: "覆盖缺口时 hard_fail 阻断发布",
        tests: ["tests/engine/standard_asset_coverage.test.ts"],
        lifecycle_tests: ["tests/engine/standard_asset_coverage.test.ts"],
    },
    // ── 第六批: 设计产物包机制（问题六十二子机制） ──
    {
        id: "mc-design-artifact-pack",
        name: "设计产物包与存量复验门",
        owner_module: "src/engine/contracts/design_artifact_pack.ts",
        owner_exports: ["createDesignArtifactPack", "verifyDesignArtifactPack", "defaultDesignArtifactPaths"],
        mechanism_type: "artifact_management",
        status: "enforced",
        trigger: "架构、数据库或 API 设计产物生成、升级和交付前",
        required_inputs: ["confirmed_architecture_decisions", "design_artifact_paths"],
        preconditions: ["架构决策已闭合或旧产物进入复验"],
        outputs: ["DesignArtifactPackContract", "DesignArtifactVerificationResult"],
        downstream_consumers: ["sf_verify", "sf_deliver"],
        failure_modes: ["API 字段规格缺失", "SQL 不可执行", "跨文档冲突", "旧文档未经复验继续编码"],
        degradation_behavior: "产物不一致时标记 verification_failed 并阻断编码/交付",
        tests: ["tests/engine/design_artifact_pack.test.ts"],
        lifecycle_tests: ["tests/adapters/architecture_design_workshop_mainpath.test.ts"],
    },
    // ── 第六批: 标准资产契约化（问题六十三） ──
    {
        id: "mc-standard-asset-contract",
        name: "标准资产契约化",
        owner_module: "src/engine/templates/standard_asset_contract.ts",
        owner_exports: ["verifyStandardAssetContract", "getStandardAssetContractSchema", "matchTemplateContract", "verifyOutputAgainstContract", "createRepairReverifyDirective", "isLowRiskTask", "isDraftDocument"],
        mechanism_type: "contract_enforcement",
        status: "enforced",
        trigger: "正式产物验收、模板同步和交付门",
        required_inputs: ["template_path", "product_path"],
        preconditions: ["产物路由匹配标准资产类型"],
        outputs: ["StandardAssetContract", "ContractVerificationResult", "RepairReverifyDirective"],
        downstream_consumers: ["sf_verify", "sf_deliver", "CLI audit"],
        failure_modes: ["P0 模板缺契约字段", "验收失败未进入 repair_reverify", "草稿被当作正式产物"],
        degradation_behavior: "契约不完整时阻断交付并进入修复闭环",
        tests: ["tests/engine/standard_asset_contract.test.ts"],
        lifecycle_tests: ["tests/engine/standard_asset_contract.test.ts"],
    },
    // ── 第六批: 模板资产可见性与注入边界（问题六十四） ──
    {
        id: "mc-template-asset-visibility",
        name: "模板资产可见性与注入边界",
        owner_module: "src/engine/templates/template_asset_visibility.ts",
        owner_exports: ["isInherentlyInternal", "inferVisibilityFromPath", "parseFrontmatterVisibility", "detectVisibilityConflict", "scanInternalTerms", "filterAssetsForUserProject", "filterSyncAssets", "checkAssetVisibilityGate", "filterByTechStack", "isScaffoldAsset", "isPackageInternalPath", "auditTemplateVisibility", "auditAllTemplateAssets"],
        mechanism_type: "access_control",
        status: "enforced",
        trigger: "init、sync、索引、注入、审计和脚手架入口",
        required_inputs: ["asset_path", "asset_frontmatter"],
        preconditions: [],
        outputs: ["AssetVisibilityReport", "VisibilityConflictResult", "SyncFilterResult"],
        downstream_consumers: ["soloforge init", "sync-templates", "sf_expand", "sf_verify", "sf_scaffold"],
        failure_modes: ["内部资产泄漏到用户项目", "可见性冲突未解决", "fallback 绕过 gate"],
        degradation_behavior: "冲突资产隔离并请求用户确认",
        tests: ["tests/engine/template_asset_visibility.test.ts"],
        lifecycle_tests: ["tests/engine/template_asset_visibility.test.ts"],
    },
];
//# sourceMappingURL=contracts-platform.js.map