---
id: build-enforced
kind: enforced
gate: build-gate
title: build 阶段确定性底线
sync_policy: engine_only
status: active
extra:
  owner_mechanism: mc-stage-gate-engine
checks:
  - id: BLD-G01
    executor: upstream_gate_check
    rule: "显式声明的 design 上游产物须按当前任务范围通过且保持新鲜"
    severity: error
    check_type: deterministic
    args: ["design"]
    gate: build-gate
    target: self
  - id: BLD-G02
    executor: lazy_pattern_check
    rule: "实际代码中不得以空函数、空 catch 或未实现占位冒充完成"
    severity: error
    non_waivable: true
    check_type: deterministic
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: QUAL-STRUCT
    executor: code_structure_scan
    rule: "可维护性结构指标：方法≤50行、函数参数≤5个、控制流嵌套≤3层、类≤300行（TS/JS/Vue script/Java）；超标先拆职责，长映射表/生成代码等合理场景可按 finding 豁免"
    severity: error
    check_type: deterministic
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: QUAL-LAYERING
    executor: layering_check
    rule: "分层禁令：Controller 层禁 SQL 片段与 @Transactional/MyBatis SQL 注解（事务与数据访问属 Service/Repository）；.vue 组件禁直调 axios/fetch/uni.request/wx.request 等 HTTP 客户端（HTTP 调用收敛到 api/ 模块）"
    severity: error
    check_type: deterministic
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: QUAL-COMMENTS
    executor: comment_noise_check
    rule: "注释噪音禁令：注释中不得出现任务编号/需求号/工单号（追踪由测试名称、报告或变更清单承载）与变更日志式流水账（日期+动作，git log 已承载）——注释只解释代码本身无法表达的意图"
    severity: error
    check_type: deterministic
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: FRONTEND-ROUTE-COVERAGE
    executor: frontend_route_coverage
    rule: "架构设计文档「菜单与路由映射」声明的路由须在前端路由注册中真实存在（悬空路由=菜单入口指向不存在页面）"
    severity: error
    check_type: deterministic
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: UI-STRUCT-CONSIST
    executor: ui_struct_consistency
    rule: "原型说明锚点页与实现页的用户可见特征须一致（文案逐字、表格列标签序列、操作按钮集合；业务数值/mock 演示值不比对）"
    severity: error
    check_type: deterministic
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: TS-Q01
    executor: regex_pattern_scan
    rule: "禁用 as any 绕过类型检查（用具体类型或 unknown 收窄）"
    severity: error
    check_type: deterministic
    pattern: "/\\bas\\s+any\\b/"
    languages: ["ts"]
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: TS-Q02
    executor: regex_pattern_scan
    rule: "禁用 @ts-ignore/@ts-nocheck 绕过类型系统（改类型；@ts-expect-error 带理由是合法逃生）"
    severity: error
    check_type: deterministic
    pattern: "/@ts-(?:ignore|nocheck)\\b/"
    languages: ["ts"]
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: TS-Q03
    executor: regex_pattern_scan
    rule: "禁用 == / != 弱等值（用 === / !==，已排除 >= <= === !==）"
    severity: error
    check_type: deterministic
    pattern: "/(?<![<>=!])==(?!=)|(?<![<>=!])!=(?!=)/"
    languages: ["ts"]
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: TS-Q04
    executor: regex_pattern_scan
    rule: "禁用 var 声明（用 let / const）"
    severity: error
    check_type: deterministic
    pattern: "/\\bvar\\s+/"
    languages: ["ts"]
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: BLD-G04
    executor: configured_command
    command_purpose: build
    rule: "执行严格配置解析得到的真实 build 命令；不按语言或框架猜测"
    severity: error
    non_waivable: true
    check_type: deterministic
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: BLD-G05
    executor: configured_command
    command_purpose: test
    rule: "执行严格配置解析得到的真实 test 命令；测试工具和阈值由项目自身决定"
    severity: error
    non_waivable: true
    check_type: deterministic
    required_artifact: 代码模版
    gate: build-gate
    target: self
  - id: MULTI-ENGINE-STRUCT
    executor: multi_engine_structure_check
    rule: "intent 声明的项目目录必须真实存在；不强制特定源码目录、语言或仓库布局"
    severity: error
    check_type: deterministic
    required_artifact: 代码模版
    gate: build-gate
    target: self

  - id: TESTPLAN-STRUCT
    executor: document_structure
    rule: "测试计划须满足当前 artifact schema；场景、环境、命令和阈值必须来自项目事实"
    severity: error
    check_type: deterministic
    required_artifact: 测试计划模版
    existence_delegated: true
    gate: build-gate
    target: self
  - id: REQ-COVERAGE
    executor: req_coverage_check
    requirement_dimension: all
    rule: "scope.code=true 时，测试计划须覆盖所有本期 REQ-*"
    severity: error
    check_type: deterministic
    required_artifact: 测试计划模版
    evidence_required: ["测试计划模版"]
    gate: build-gate
    target: self
  - id: REQ-BRANCH-COVERAGE
    executor: req_branch_coverage
    rule: "每个需求按实际风险覆盖适用的正常、错误和边界分支；不适用类别须给出具体原因"
    severity: error
    check_type: deterministic
    required_artifact: 测试计划模版
    gate: build-gate
    target: self
  - id: TP-DELIB
    executor: artifact_deliberation_gate
    check_type: deterministic
    severity: error
    non_waivable: true
    gate: build-gate
    required_artifact: 测试计划模版
    rule: "涉及代码时须与用户确认风险、测试类型、项目阈值、数据和 CI 约束"
    target: self

  - id: DEPLOYMENT-STRUCT
    executor: deployment_structure_check
    rule: "deployment.method=docker_compose 时，Compose 服务、本地 build context 与 Dockerfile 必须真实存在；其他部署方式跳过"
    severity: error
    check_type: deterministic
    required_artifact: deploy/docker-compose.yml
    gate: build-gate
    target: self
  - id: DEPLOYMENT-BUILD
    executor: external_command
    command: docker
    args: ["compose", "build"]
    rule: "对当前 project map 定位的 Compose 执行真实镜像构建"
    severity: error
    check_type: deterministic
    required_artifact: deploy/docker-compose.yml
    gate: build-gate
    target: self
  - id: DEPLOYMENT-UP
    executor: docker_deployment
    rule: "对当前 Compose 执行真实启动并确认容器运行/健康；不是 Docker Compose 时跳过"
    severity: error
    check_type: deterministic
    required_artifact: deploy/docker-compose.yml
    gate: build-gate
    target: self
  - id: DEPLOYMENT-HTTP
    executor: local_http_acceptance
    rule: "对 Compose 暴露的真实 HTTP 端口执行可访问性探测；业务正确性由项目测试与验收证明"
    severity: warning
    check_type: deterministic
    required_artifact: deploy/docker-compose.yml
    gate: build-gate
    target: self

  - id: SCOPE-CONSISTENCY
    executor: scope_consistency_check
    check_type: deterministic
    severity: error
    gate: build-gate
    rule: "任务归因制双层判定：本任务验证记录中出现 scope 外产物即矛盾（error）；磁盘存在产物且有其他任务归属（含已 cancel）=历史事实不判矛盾；磁盘存在但无任何任务归属=warning 提示不阻断。范围事实只能由显式任务上下文决定"
    target: self
---

# build-gate 确定性底线

SoloForge 只执行项目声明的构建/测试命令和适用的运行资产验证，不注入通用覆盖率、框架、目录或部署假设。代码行为、测试充分性和风险取舍仍需独立审查。
