name: audit-e2e
description: E2E の全件監査。ユーザーフローとカバレッジ不足を棚卸しし、コード修正なしで Issue 直貼り可能なレポートを作成する
capabilities: readonly
max_steps: 12
initial_step: plan

loop_monitors:
  - cycle:
      - supervise
      - review
    threshold: 3
    judge:
      persona: supervisor
      instruction: |
        e2e audit の supervise → review サイクルが {cycle_count} 回繰り返されました。
        監査レポートと計画レポートを比較し、以下を判断してください:
        - 監査スコープが前回サイクルから拡大しているか（新しいフローが監査されたか）
        - 残りの未監査フローは合理的なサイクル数で完了可能か
      rules:
        - condition: 監査品質・スコープが十分
          next: COMPLETE
        - condition: スコープが拡大しており改善が続いている
          next: review
        - condition: スコープが停滞し改善の見込みがない
          next: ABORT

steps:
  - name: plan
    tags:
      - plan
    persona: test-planner
    policy:
      - contract-change
      - testing
      - architecture
    knowledge:
      - architecture
      - e2e-testing
    instruction: e2e-audit-plan
    edit: false
    output_contracts:
      report:
        - name: 01-e2e-audit-plan.md
          format: e2e-audit-plan
    rules:
      - condition: 監査計画が完了
        next: audit
      - condition: 要件が不明確、情報不足
        next: ABORT

  - name: audit
    tags:
      - review
    edit: false
    persona: testing-reviewer
    policy:
      - contract-change
      - review
      - testing
      - architecture
    knowledge:
      - architecture
      - e2e-testing
    instruction: e2e-audit-team-leader
    team_leader:
      max_parts: 3
      part_persona: testing-reviewer
      part_edit: false
    output_contracts:
      report:
        - name: 02-e2e-audit.md
          format: e2e-audit
    rules:
      - condition: 監査完了
        next: supervise

  - name: supervise
    tags:
      - review
      - supervise
    edit: false
    persona: supervisor
    policy:
      - contract-change
      - review
      - testing
    knowledge:
      - e2e-testing
    instruction: e2e-audit-supervise
    pass_previous_response: false
    rules:
      - condition: 監査が完全で Issue 化できる品質に達している
        next: COMPLETE
      - condition: フロー監査が不完全、または根拠が不足している
        next: review

  - name: review
    tags:
      - review
    edit: false
    persona: testing-reviewer
    policy:
      - contract-change
      - review
      - testing
    knowledge:
      - e2e-testing
    instruction: e2e-audit-review
    output_contracts:
      report:
        - name: 02-e2e-audit.md
          format: e2e-audit
    rules:
      - condition: 再監査完了
        next: supervise
