name: audit-e2e
description: Comprehensive E2E audit. Enumerate user flows and coverage gaps, then produce an issue-ready report without modifying code
capabilities: readonly
max_steps: 12
initial_step: plan

loop_monitors:
  - cycle:
      - supervise
      - review
    threshold: 3
    judge:
      persona: supervisor
      instruction: |
        The supervise → review cycle for the E2E audit has repeated {cycle_count} times.
        Compare the audit report against the plan report and judge:
        - Whether the audit scope has expanded since the previous cycle (new flows audited)
        - Whether remaining unaudited flows can be completed in a reasonable number of cycles
      rules:
        - condition: Audit quality and scope are sufficient
          next: COMPLETE
        - condition: Scope is expanding and progress continues
          next: review
        - condition: Scope is stalled with no prospect of improvement
          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: Audit plan complete
        next: audit
      - condition: Requirements unclear or insufficient information
        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: Audit complete
        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: Audit is complete and issue-ready
        next: COMPLETE
      - condition: Flow audit is incomplete or evidence is insufficient
        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: Re-audit complete
        next: supervise
