# Development Exit Gate
# Validates TDD cycle outputs
#
# test_command 来源：gate-engine 从 .harness/architecture-envelopes/{REQ-ID}/step-2-code-scan-evidence.yaml#stack.test_command 读取并替换 {test_command}（X-6）
# 禁止在此写死具体测试命令（npx vitest run / mvn test 等）— P-1 修复

rules:
  - id: all-tasks-committed
    type: regex-check
    blocking: true
    message: "All tasks must have committed code with task ID in commit message"
    file: "{task_split}"
    pattern: "T-\\d+"

  - id: tests-pass
    type: exec
    blocking: true
    message: "All tests must pass"
    command: "cd {project_root} && {test_command} 2>&1 | grep -q 'Tests.*passed'"

  - id: no-todo-comments
    type: regex-check
    blocking: false
    message: "Implementation should not contain TODO/FIXME placeholders"
    file: "{arch_doc}"
    pattern: "(?!TODO|FIXME)"

  # REQ-2026-001 envelope drift-check (inline per step-4-gate-derive SKILL — development-exit uses rules: array, not rules_files binding)
  - id: drift-envelope-REQ-2026-001
    type: drift-check
    blocking: true
    severity: error
    scope: full-only
    envelope_path: ".harness/architecture-envelopes/REQ-2026-001/step-3-architecture-envelope.yaml"
    message: "变更须在 envelope writable 内；read_only/forbidden 不得改动"
