# HITL reference templates, SDLC gates, and cost-model notes.
# Gate instances validate against hitl-gate.yaml; templates are partial instances.

# Predefined gate templates
gate_templates:
  phase_approval:
    description: "Standard phase transition approval"
    gate_type: approval
    behavior:
      mode: CONDITIONAL
      timeout: 86400  # 24 hours
      timeout_action: block
      auto_approve_conditions:
        - condition: "confidence > 0.95 AND no_critical_issues"
          reason: "High confidence with no blockers"
    cost_tracking:
      track_enabled: true
      metrics: [time_to_decision, revision_count]

  artifact_review:
    description: "Artifact quality review"
    gate_type: review
    behavior:
      mode: ALWAYS
      timeout: 3600  # 1 hour
      timeout_action: proceed
    presentation:
      context_window: 100

  budget_checkpoint:
    description: "Cost threshold checkpoint"
    gate_type: escalation
    trigger:
      type: cost_threshold
    behavior:
      mode: CONDITIONAL
      timeout: 0
      timeout_action: abort

  iteration_checkpoint:
    description: "Progress checkpoint after iterations"
    gate_type: checkpoint
    trigger:
      type: iteration_count
      threshold: 5
    behavior:
      mode: CONDITIONAL
      timeout: 300
      timeout_action: proceed

# SDLC phase transition gates
sdlc_gates:
  concept_to_inception:
    id: "GATE-C2I"
    name: "Concept to Inception Gate"
    gate_type: approval
    trigger:
      type: phase_transition
      phase_from: concept
      phase_to: inception
    behavior:
      mode: ALWAYS
      timeout: 172800  # 48 hours
      timeout_action: block
    presentation:
      summary_template: |
        ## Ready for Inception?

        **Intake Form**: {{intake_status}}
        **Solution Profile**: {{solution_status}}
        **Stakeholders**: {{stakeholder_count}} identified

        Approve to begin formal requirements gathering.
      questions:
        - id: "scope_approved"
          question: "Is the project scope approved?"
          options: ["Yes", "No - needs refinement", "Escalate to sponsor"]
          required: true

  inception_to_elaboration:
    id: "GATE-I2E"
    name: "Inception to Elaboration Gate"
    gate_type: approval
    trigger:
      type: phase_transition
      phase_from: inception
      phase_to: elaboration
    behavior:
      mode: ALWAYS
      timeout: 172800
      timeout_action: block
    presentation:
      artifacts_to_show:
        - ".aiwg/requirements/user-stories.md"
        - ".aiwg/requirements/use-cases/"
        - ".aiwg/risks/risk-register.md"

  elaboration_to_construction:
    id: "GATE-E2C"
    name: "Elaboration to Construction Gate"
    gate_type: approval
    trigger:
      type: phase_transition
      phase_from: elaboration
      phase_to: construction
    behavior:
      mode: ALWAYS
      timeout: 172800
      timeout_action: block
    presentation:
      artifacts_to_show:
        - ".aiwg/architecture/software-architecture-doc.md"
        - ".aiwg/architecture/decisions/"
        - ".aiwg/testing/test-strategy.md"

  construction_to_transition:
    id: "GATE-C2T"
    name: "Construction to Transition Gate"
    gate_type: approval
    trigger:
      type: phase_transition
      phase_from: construction
      phase_to: transition
    behavior:
      mode: ALWAYS
      timeout: 86400
      timeout_action: block
    presentation:
      artifacts_to_show:
        - ".aiwg/testing/test-results/"
        - ".aiwg/deployment/deployment-plan.md"
        - ".aiwg/security/security-assessment.md"

# Cost savings tracking
cost_model:
  description: "Based on Agent Laboratory findings"
  baseline:
    fully_autonomous:
      average_cost_multiplier: 6.0
      error_rate: 0.35
      revision_cycles: 4.2
  with_hitl:
    average_cost_multiplier: 1.0
    error_rate: 0.05
    revision_cycles: 0.83
  savings_calculation: |
    savings = (autonomous_cost - hitl_cost) / autonomous_cost
    # Target: 84% cost reduction

# References
references:
  research:
    - "@.aiwg/research/findings/REF-057-agent-laboratory.md"
  implementation:
    - "#96"
  related:
    - "@agentic/code/frameworks/sdlc-complete/flows/"
    - "@agentic/code/frameworks/sdlc-complete/schemas/flows/"
