# Development Entry Gate
# Validates inputs before TDD cycle starts.
#
# Rules split into two tiers:
#   tier 1 (blocking=true, error): task-split / arch SPI / CONTEXT — required for any implementable work
#   tier 2 (blocking=false, hint): the 8 "facts" AI must locate before generating production code
#     (see docs/architecture/l0/10-governance/change-governance.md — Capability / Module Card /
#      State Owner / ICD / Scenario / Invariant / Harness Spec / Verification Matrix row).
# Tier-2 rules are non-blocking so projects without a full L0/T1 doc hierarchy can still run.

rules:
  - id: task-split-ready
    type: yaml-field-check
    blocking: true
    message: "task-split.md must exist with features and tasks"
    file: "{task_split}"
    required_fields:
      - features
      - tasks

  - id: arch-outputs-ready
    type: yaml-field-check
    blocking: true
    message: "Architecture SPI must be defined"
    file: "{arch_doc}"
    required_fields:
      - spi

  - id: context-md-exists
    type: exec
    blocking: false
    message: "CONTEXT.md should exist for domain vocabulary"
    command: "test -f {context}"

  # --- 8 Facts (change-governance.md) — non-blocking hints ---

  - id: fact-capability-map
    type: exec
    blocking: false
    severity: hint
    message: "Capability map should be located before generating implementation tasks"
    command: "test -f {capability_map}"

  - id: fact-module-card
    type: exec
    blocking: false
    severity: hint
    message: "Module responsibility card should be located"
    command: "test -f {module_card}"

  - id: fact-state-owner
    type: exec
    blocking: false
    severity: hint
    message: "State ownership matrix should be located"
    command: "test -f {state_matrix}"

  - id: fact-icd
    type: exec
    blocking: false
    severity: hint
    message: "Inter-module contract (ICD) should be located"
    command: "test -f {icd}"

  - id: fact-scenario
    type: exec
    blocking: false
    severity: hint
    message: "Scenario spec should be located"
    command: "test -f {scenario}"

  - id: fact-invariant
    type: exec
    blocking: false
    severity: hint
    message: "Architecture invariant should be located"
    command: "test -f {invariant}"

  - id: fact-harness-spec
    type: exec
    blocking: false
    severity: hint
    message: "Harness spec should be located"
    command: "test -f {harness_spec}"

  - id: fact-verification-matrix
    type: exec
    blocking: false
    severity: hint
    message: "Verification matrix row should be located"
    command: "test -f {verification_matrix}"
