# SLOPE Sprint Standard Workflow
# Full lifecycle: briefing → plan review → tickets → scorecard → review
name: sprint-standard
version: "1"
description: Standard sprint lifecycle with pre-hole, plan review, per-ticket, and post-hole phases

variables:
  sprint_id:
    required: true
    type: string
    pattern: "^S\\d+$"
  tickets:
    required: true
    type: array

phases:
  # --- Pre-Hole: Sprint setup ---
  - id: pre_hole
    steps:
      - id: briefing
        type: command
        command: slope briefing --sprint=${sprint_id}
        checkpoint: exit_code_0
        blocks_next: true

      - id: verify_previous
        type: validation
        prompt: Verify previous sprint scorecard exists
        conditions:
          - previous_scorecard_exists

  # --- Plan Review: Write and review the sprint plan ---
  - id: plan_review
    steps:
      - id: write_plan
        type: agent_work
        prompt: "Write the sprint plan as a file in docs/backlog/. Use EnterPlanMode before writing. Include ticket list, clubs, approach, and hazard watch for each ticket."
        rules:
          - "Enter plan mode before writing the plan file"
          - "Plan file triggers review-tier guard which determines review tier"
        blocks_next: true
        completion_conditions:
          files_exist:
            - "docs/backlog/sprint-*-plan.md"
            - ".slope/review-state.json"

      - id: review_plan
        type: agent_input
        prompt: "Review the plan. The review-tier guard determines the tier (skip/light/standard/deep). Complete required review rounds before proceeding."
        required_fields:
          - review_tier
          - review_complete

      - id: revise_plan
        type: agent_work
        prompt: "Address review findings if any. Skip if no findings or review tier was skip."

  # --- Per-Ticket: Execute each ticket ---
  - id: per_ticket
    repeat_for: tickets
    timeout_per_item: 600
    on_timeout: log_blocker_and_skip
    steps:
      - id: pre_shot
        type: agent_input
        prompt: "Select club and declare approach for ticket"
        required_fields:
          - club
          - approach

      - id: implement
        type: agent_work
        prompt: "Implement the ticket according to the declared approach"
        rules:
          - "Run tests after each change"
          - "Commit after each file creation or feature completion"
          - "Push after ticket completion"
        blocks_next: true

      - id: post_shot
        type: agent_input
        prompt: "Score the shot — record result, hazards, and penalties"
        required_fields:
          - result
          - hazards

  # --- Post-Hole: Sprint wrap-up ---
  - id: post_hole
    steps:
      - id: validate_scorecard
        type: command
        command: slope validate
        checkpoint: exit_code_0
        blocks_next: true

      - id: review
        type: command
        command: slope review --sprint=${sprint_id}
        checkpoint: exit_code_0

      - id: codification_sweep
        type: agent_input
        prompt: "Sweep for recurring workarounds before closeout. If you routed around structural friction that will recur, log it with `slope review findings add --type=workaround --recurs --cost=s|m|l --description=\"...\"`."
        required_fields:
          - codification_candidates_logged_or_none

      - id: update_map
        type: command
        command: slope map
