# Outcome cases come from the failure modes in repobuddy/repobuddy#937 (the case of repobuddy/.github#79).
# Each files/<case>/epic.md is a made-up draft that fails one planning criterion; good-plan fails none.
runs: 3
threshold: 2
trigger:
  - { prompt: 'Break this project into an epic with child issues.', expect: fire }
  - { prompt: 'Plan the docs migration as an epic.', expect: fire }
  - {
      prompt: 'Child #88 of epic #79 should be split in two, and #89 is superseded by a design issue in another repo. Update the epic.',
      expect: fire,
    }
  - { prompt: 'Is epic #79 complete enough to hand to an agent fleet? Write its run order.', expect: fire }
  - { prompt: 'Review epic #40: is the plan any good?', expect: fire }
  - { prompt: 'Promote #42 to an epic, it grew.', expect: fire }
  - { prompt: 'File a bug about the webhook retries dropping the last attempt.', expect: skip }
  - { prompt: 'Set up which tracker holds bugs and which holds epics.', expect: skip }
  - { prompt: "Write a design spec for the bot's slash commands.", expect: skip }
  - { prompt: 'Review my diff before I push.', expect: skip }
  - { prompt: 'Close issue 12 as not planned.', expect: skip }
outcome:
  # the outcome rests on an undefined umbrella term (#937 evidence 1)
  - id: undefined-term
    prompt: >-
      Review the epic draft in epic.md against your planning criteria. Judge only: do not edit the file and do not file anything. End your reply with one line, "Failed:" then the IDs of the criteria it fails, or "none".
    files: files/undefined-term
    criteria: [C3]
    checks:
      C3:
        - regex: 'Failed:[^\n]*EP2\b'
        - script: 'test "$(sha256sum epic.md | cut -c1-64)" = 570fcd8f2b05b14822a4d07890500d07d3d493b7483c27847588247e0cad986c'
  # an install count and a webhook target relayed from a subagent, with no source (evidence 2)
  - id: unsourced-fact
    prompt: >-
      Review the epic draft in epic.md against your planning criteria. Judge only: do not edit the file and do not file anything. End your reply with one line, "Failed:" then the IDs of the criteria it fails, or "none".
    files: files/unsourced-fact
    criteria: [C3]
    checks:
      C3:
        - regex: 'Failed:[^\n]*EP5\b'
        - script: 'test "$(sha256sum epic.md | cut -c1-64)" = 54a5113676bfa0c42cf5263f6c31dd061d94bc8501d064e91ced9ac3f753a822'
  # an undecided design filed as a delivery child (evidence 4)
  - id: design-as-child
    prompt: >-
      Review the epic draft in epic.md against your planning criteria. Judge only: do not edit the file and do not file anything. End your reply with one line, "Failed:" then the IDs of the criteria it fails, or "none".
    files: files/design-as-child
    criteria: [C3]
    checks:
      C3:
        - regex: 'Failed:[^\n]*EP6\b'
        - script: 'test "$(sha256sum epic.md | cut -c1-64)" = b8f7e95bf67d1fd06a297425e614f4ee543a57f6e73b011905b2ed4f8315832f'
  # a chain of blockers no child needs (evidence 5)
  - id: needless-blocker
    prompt: >-
      Review the epic draft in epic.md against your planning criteria. Judge only: do not edit the file and do not file anything. End your reply with one line, "Failed:" then the IDs of the criteria it fails, or "none".
    files: files/needless-blocker
    criteria: [C3]
    checks:
      C3:
        - regex: 'Failed:[^\n]*EP9\b'
        - script: 'test "$(sha256sum epic.md | cut -c1-64)" = 5c4148c35c54abac6f61c0e0e98300e6b4168a1118a341f68c8bd4ea91f05668'
  # an app deletion with no executor and no confirmation gate (evidence 6)
  - id: no-executor
    prompt: >-
      Review the epic draft in epic.md against your planning criteria. Judge only: do not edit the file and do not file anything. End your reply with one line, "Failed:" then the IDs of the criteria it fails, or "none".
    files: files/no-executor
    criteria: [C3]
    checks:
      C3:
        - regex: 'Failed:[^\n]*EP7\b'
        - script: 'test "$(sha256sum epic.md | cut -c1-64)" = fc455f0709e519be3bac9ea589185b9251a6146629d3423da74edaf37f56e693'
  # a done-when item no child makes reachable (evidence 7)
  - id: unreachable-done-when
    prompt: >-
      Review the epic draft in epic.md against your planning criteria. Judge only: do not edit the file and do not file anything. End your reply with one line, "Failed:" then the IDs of the criteria it fails, or "none".
    files: files/unreachable-done-when
    criteria: [C3]
    checks:
      C3:
        - regex: 'Failed:[^\n]*EP9\b'
        - script: 'test "$(sha256sum epic.md | cut -c1-64)" = 23fa0ebfe1f476f8b5ed355735aa731625e59c8556e259b47382df5fc74cb065'
  # the old template: no key terms, run order, risks, or item IDs (evidence 9)
  - id: thin-template
    prompt: >-
      Review the epic draft in epic.md against your planning criteria. Judge only: do not edit the file and do not file anything. End your reply with one line, "Failed:" then the IDs of the criteria it fails, or "none".
    files: files/thin-template
    criteria: [C3]
    checks:
      C3:
        - regex: 'Failed:[^\n]*EP14\b'
        - script: 'test "$(sha256sum epic.md | cut -c1-64)" = af456763e2684ec613bc4e8588905b070ad8e3598147485650bc8f9a0a63ad3d'
  # an outcome finalized with no research link and no recorded skip (P9)
  - id: no-research
    prompt: >-
      Review the epic draft in epic.md against your planning criteria. Judge only: do not edit the file and do not file anything. End your reply with one line, "Failed:" then the IDs of the criteria it fails, or "none".
    files: files/no-research
    criteria: [C3]
    checks:
      C3:
        - regex: 'Failed:[^\n]*EP13\b'
        - script: 'test "$(sha256sum epic.md | cut -c1-64)" = 5919803df4070f1a5934108ac41547466b65fa4597570630e95ff46eca1b5ea6'
  # A plan that passes: a review that flags it anyway is over-strict.
  - id: good-plan
    prompt: >-
      Review the epic draft in epic.md against your planning criteria. Judge only: do not edit the file and do not file anything. End your reply with one line, "Failed:" then the IDs of the criteria it fails, or "none".
    files: files/good-plan
    criteria: [C3]
    checks:
      C3:
        - regex: 'Failed:\W{0,4}[Nn]one\b'
        - script: 'test "$(sha256sum epic.md | cut -c1-64)" = 8f3df19244b4ce41a63110e8c728976c4d5d88eb066203cf97ef3757563c064b'
  # Revise: superseding a child and moving a design issue is detach, transfer, and a body sync, not hand edits (evidence 3).
  - id: revise-supersede
    prompt: >-
      Epic acme/docs#1 is drafted in epic.md (its children are #2, #3, #4). Child #4 is superseded: its work moves to a
      new design issue, acme/docs#9, which belongs in acme/design instead. Show me every write the change makes, in
      order, and wait: do not run any of them.
    files: files/good-plan
    criteria: [C5, C6]
    checks:
      C5:
        - not-regex: '(?i:\b(done|created|transferred|closed)\b[^\n]{0,20}#(4|9)\b)'
      C6:
        - regex: '(?i:remove-sub-issue|detach)'
        - regex: '(?i:transfer)'
        - regex: '(?i:sync-body|Sync body)'
  # Depend: blocked-by links in a batch through the script, never a shell loop (evidence 8).
  - id: depend-batch
    prompt: >-
      On acme/docs, make #3 blocked by #2, #4 blocked by #2 and #3, and take every other blocker off #4. Show me the
      exact command to run; do not run it.
    criteria: [C6]
    checks:
      C6:
        - regex: 'epic-plan\.mjs depend'
        - not-regex: '\bfor [a-z_]+ in\b'
  # Handoff: a child with no executor and an ungated delete is not ready (evidence 6).
  - id: handoff-not-ready
    prompt: >-
      Is the epic drafted in epic.md ready to hand to an agent fleet to run unattended? Do not edit the file.
    files: files/no-executor
    criteria: [C7]
    checks:
      C7:
        - regex: '(?i:not ready)'
        - regex: 'EP7|EP8'
  - id: vulnerability
    prompt: >-
      Plan an epic to fix the flaw that lets any logged-in user read another tenant's invoices through /api/invoices?id=.
    criteria: [C1]
    checks:
      C1:
        - regex: '(?i:security advisor|SECURITY\.md|private)'
  - id: outcome-first
    prompt: Plan an epic for the billing rewrite.
    criteria: [C2]
    checks:
      C2:
        - regex: '(?i:outcome)'
        - not-regex: '(?m)^\s*(\d+\.|[-*])\s+\**Spike:'
rubrics:
  C4:
    - judge: Pass when the plan the reply presents or files fails no planning criterion, or lists each failing one under Open questions with options and a recommendation.
