# Integration Exit Gate
# Validates integration verification results
#
# 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: spi-tests-pass
    type: exec
    blocking: true
    message: "SPI contract tests must pass"
    command: "cd {project_root} && {test_command} 2>&1 | grep -q 'Tests.*passed'"

  - id: feature-tests-pass
    type: exec
    blocking: true
    message: "Feature acceptance tests must pass"
    command: "cd {project_root} && {test_command} 2>&1 | grep -q 'Tests.*passed'"

  - id: e2e-tests-pass
    type: exec
    blocking: false
    message: "E2E tests should pass"
    command: "cd {project_root} && {test_command} 2>&1 | grep -q 'Tests.*passed'"

  - id: no-open-defects
    type: exec
    blocking: true
    message: "No open defects should remain"
    command: "test $(find {project_root}/defects -name '*.open.md' 2>/dev/null | wc -l) -eq 0"
