# Engineering Backlog Policy — DAARION.city
#
# Governs auto-generation of platform backlog items from Risk/Pressure digests,
# workflow transitions, ownership, and storage retention.
#
# No LLM. Deterministic generation. Source of truth for engineering priorities.

defaults:
  env: "prod"
  retention_days: 180
  max_items_per_run: 50

# Dedupe scheme: prevents duplicate creation within the same ISO week
dedupe:
  scheme: "YYYY-WW"               # weekly deduplication window
  key_fields: ["service", "category", "env"]
  key_prefix: "platform_backlog"
  # Final key: platform_backlog:{YYYY-WW}:{env}:{service}:{category}

# Per-category defaults
categories:
  arch_review:
    priority: "P1"
    due_days: 14
  refactor:
    priority: "P1"
    due_days: 21
  slo_hardening:
    priority: "P2"
    due_days: 30
  cleanup_followups:
    priority: "P2"
    due_days: 14
  security:
    priority: "P0"
    due_days: 7

# Auto-generation rules (evaluated per-service top-to-bottom; first match wins per category)
generation:
  weekly_from_pressure_digest: true
  daily_from_risk_digest: false
  rules:
    - name: "arch_review_required"
      when:
        pressure_requires_arch_review: true
      create:
        category: "arch_review"
        title_template: "[ARCH] Review required: {service}"

    - name: "high_pressure_refactor"
      when:
        pressure_band_in: ["high", "critical"]
        risk_band_in: ["high", "critical"]
      create:
        category: "refactor"
        title_template: "[REF] Reduce pressure & risk: {service}"

    - name: "slo_violations"
      when:
        risk_has_slo_violations: true
      create:
        category: "slo_hardening"
        title_template: "[SLO] Fix violations: {service}"

    - name: "followup_backlog"
      when:
        followups_overdue_gt: 0
      create:
        category: "cleanup_followups"
        title_template: "[OPS] Close overdue followups: {service}"

# Owner assignments (default + service-level overrides)
ownership:
  default_owner: "oncall"
  overrides:
    gateway: "cto"

# Workflow state machine
workflow:
  statuses: ["open", "in_progress", "blocked", "done", "canceled"]
  allowed_transitions:
    open:        ["in_progress", "blocked", "canceled"]
    in_progress: ["blocked", "done", "canceled"]
    blocked:     ["open", "in_progress", "canceled"]
    done:        []
    canceled:    []
