# Implementation Readiness Validation Criteria
# Defines systematic validation rules by project level

validation_rules:
  # Level 0-1 Projects (Simple, minimal planning)
  level_0_1:
    required_documents:
      - tech_spec
      - stories_or_tasks

    validations:
      - name: "Tech Spec Completeness"
        checks:
          - "All features defined with implementation approach"
          - "Technical dependencies identified"
          - "API contracts defined if applicable"
          - "Data models specified"

      - name: "Story Coverage"
        checks:
          - "All tech spec features have corresponding stories"
          - "Stories are sequenced logically"
          - "Technical tasks are defined"
          - "No critical gaps in coverage"

  # Level 2 Projects (PRD + Tech Spec, no separate architecture)
  level_2:
    required_documents:
      - prd
      - tech_spec # Includes architecture decisions
      - epics_and_stories

    validations:
      - name: "PRD to Tech Spec Alignment"
        checks:
          - "All PRD requirements addressed in tech spec"
          - "Architecture embedded in tech spec covers PRD needs"
          - "Non-functional requirements are specified"
          - "Technical approach supports business goals"

      - name: "Story Coverage and Alignment"
        checks:
          - "Every PRD requirement has story coverage"
          - "Stories align with tech spec approach"
          - "Epic breakdown is complete"
          - "Acceptance criteria match PRD success criteria"

      - name: "Sequencing Validation"
        checks:
          - "Foundation stories come first"
          - "Dependencies are properly ordered"
          - "Iterative delivery is possible"
          - "No circular dependencies"

  # Level 3-4 Projects (Full planning with separate architecture)
  level_3_4:
    required_documents:
      - prd
      - architecture
      - epics_and_stories

    validations:
      - name: "PRD Completeness"
        checks:
          - "User requirements fully documented"
          - "Success criteria are measurable"
          - "Scope boundaries clearly defined"
          - "Priorities are assigned"

      - name: "Architecture Coverage"
        checks:
          - "All PRD requirements have architectural support"
          - "System design is complete"
          - "Integration points defined"
          - "Security architecture specified"
          - "Performance considerations addressed"
          - "If architecture.md: Implementation patterns defined"
          - "If architecture.md: Technology versions verified and current"
          - "If architecture.md: Starter template command documented (if applicable)"

      - name: "PRD-Architecture Alignment"
        checks:
          - "No architecture gold-plating beyond PRD"
          - "NFRs from PRD reflected in architecture"
          - "Technology choices support requirements"
          - "Scalability matches expected growth"
          - "If UX spec exists: Architecture supports UX requirements"
          - "If UX spec exists: Component library supports interaction patterns"

      - name: "Story Implementation Coverage"
        checks:
          - "All architectural components have stories"
          - "Infrastructure setup stories exist"
          - "Integration implementation planned"
          - "Security implementation stories present"

      - name: "Comprehensive Sequencing"
        checks:
          - "Infrastructure before features"
          - "Authentication before protected resources"
          - "Core features before enhancements"
          - "Dependencies properly ordered"
          - "Allows for iterative releases"

# Special validation contexts
special_contexts:
  greenfield:
    additional_checks:
      - "Project initialization stories exist"
      - "If using architecture.md: First story is starter template initialization"
      - "Development environment setup documented"
      - "CI/CD pipeline stories included"
      - "Initial data/schema setup planned"
      - "Deployment infrastructure stories present"

  ux_workflow_active:
    additional_checks:
      - "UX requirements in PRD"
      - "UX implementation stories exist"
      - "Accessibility requirements covered"
      - "Responsive design addressed"
      - "User flow continuity maintained"

  api_heavy:
    additional_checks:
      - "API contracts fully defined"
      - "Versioning strategy documented"
      - "Authentication/authorization specified"
      - "Rate limiting considered"
      - "API documentation stories included"

# Severity definitions
severity_levels:
  critical:
    description: "Must be resolved before implementation"
    examples:
      - "Missing stories for core requirements"
      - "Conflicting technical approaches"
      - "No infrastructure setup for greenfield"
      - "Security requirements not addressed"

  high:
    description: "Should be addressed to reduce risk"
    examples:
      - "Incomplete acceptance criteria"
      - "Unclear story dependencies"
      - "Missing error handling coverage"
      - "Performance requirements not validated"

  medium:
    description: "Consider addressing for smoother implementation"
    examples:
      - "Documentation gaps"
      - "Test strategy not defined"
      - "Monitoring approach unclear"
      - "Minor sequencing improvements possible"

  low:
    description: "Minor improvements for consideration"
    examples:
      - "Formatting inconsistencies"
      - "Optional enhancements identified"
      - "Style guide compliance"
      - "Nice-to-have features noted"

# Readiness decision criteria
readiness_decisions:
  ready:
    criteria:
      - "No critical issues found"
      - "All required documents present"
      - "Core alignments validated"
      - "Story sequencing logical"
      - "Team can begin implementation"

  ready_with_conditions:
    criteria:
      - "Only high/medium issues found"
      - "Mitigation plans identified"
      - "Core path to MVP clear"
      - "Issues won't block initial stories"

  not_ready:
    criteria:
      - "Critical issues identified"
      - "Major gaps in coverage"
      - "Conflicting approaches found"
      - "Required documents missing"
      - "Blocking dependencies unresolved"
