version: 1

feature_states:
  allowed: [pending, in_progress, blocked, done]

stages:
  - name: intake
    owner: leader
    input:
      - backlog/features.json
      - work/current.md
    output:
      - work/current.md

  - name: design
    owner: architect
    optional: true
    input:
      - work/current.md
      - spec/product.md
      - spec/tech.md
      - spec/acceptance.md
    output:
      - work/artifacts/<feature_id>/architect.md

  - name: build
    owner: implementer
    input:
      - work/current.md
      - spec/product.md
      - spec/tech.md
      - spec/acceptance.md
      - work/artifacts/<feature_id>/architect.md
    output:
      - work/artifacts/<feature_id>/implementer.md

  - name: review_gate
    owner: reviewer
    required: true
    input:
      - work/current.md
      - spec/acceptance.md
      - work/artifacts/<feature_id>/implementer.md
    output:
      - work/artifacts/<feature_id>/reviewer.json

  - name: security_gate
    owner: security
    required: true
    input:
      - work/current.md
      - work/artifacts/<feature_id>/implementer.md
      - work/artifacts/<feature_id>/reviewer.json
    output:
      - work/artifacts/<feature_id>/security.json

  - name: qa_gate
    owner: qa
    required: true
    input:
      - work/current.md
      - spec/acceptance.md
      - work/artifacts/<feature_id>/implementer.md
      - work/artifacts/<feature_id>/reviewer.json
      - work/artifacts/<feature_id>/security.json
    output:
      - work/artifacts/<feature_id>/qa.json

  - name: document
    owner: documenter
    optional: true
    when: docs/API/contracts/user-facing behavior changed
    input:
      - work/current.md
      - work/artifacts/<feature_id>/implementer.md
      - work/artifacts/<feature_id>/reviewer.json
      - work/artifacts/<feature_id>/security.json
      - work/artifacts/<feature_id>/qa.json
    output:
      - work/artifacts/<feature_id>/documenter.md

  - name: close
    owner: leader
    required: true
    input:
      - work/current.md
      - work/artifacts/<feature_id>/implementer.md
      - work/artifacts/<feature_id>/reviewer.json
      - work/artifacts/<feature_id>/security.json
      - work/artifacts/<feature_id>/qa.json
      - work/artifacts/<feature_id>/documenter.md
    output:
      - work/artifacts/<feature_id>/leader-close.json
      - work/history.md
    post_actions:
      - scripts/close_feature.py <feature_id>

close_requirements:
  - reviewer.json.verdict == "APPROVED"
  - security.json.verdict == "APPROVED"
  - qa.json.verdict == "APPROVED"
  - scripts/verify.sh exit_code == 0
