|
| 1 | +--- |
| 2 | +allowed-tools: Agent, Read, Bash(gh:*), Bash(git:*) |
| 3 | +description: Run the PPL bugfix harness for a GitHub issue or follow up on an existing PR |
| 4 | +--- |
| 5 | + |
| 6 | +Fix a PPL bug or follow up on an existing PR using the harness in `ppl-bugfix-harness.md`. |
| 7 | + |
| 8 | +## Input |
| 9 | + |
| 10 | +- `/ppl-bugfix #1234` or `/ppl-bugfix 1234` — issue number |
| 11 | +- `/ppl-bugfix PR#5678` or `/ppl-bugfix pr 5678` — PR number |
| 12 | +- `/ppl-bugfix https://github.com/opensearch-project/sql/issues/1234` — URL |
| 13 | + |
| 14 | +If no argument given, ask for an issue or PR number. |
| 15 | + |
| 16 | +## Step 1: Resolve Issue ↔ PR |
| 17 | + |
| 18 | +```bash |
| 19 | +# Issue → PR |
| 20 | +gh pr list --search "Resolves #<issue_number>" --json number,url,state --limit 5 |
| 21 | + |
| 22 | +# PR → Issue |
| 23 | +gh pr view <pr_number> --json body | jq -r '.body' | grep -oP 'Resolves #\K[0-9]+' |
| 24 | +``` |
| 25 | + |
| 26 | +| State | Action | |
| 27 | +|-------|--------| |
| 28 | +| Issue exists, no PR | **Initial Fix** (Step 2A) | |
| 29 | +| Issue exists, open PR found | **Follow-up** (Step 2B) | |
| 30 | +| PR provided directly | **Follow-up** (Step 2B) | |
| 31 | + |
| 32 | +## Step 2A: Initial Fix |
| 33 | + |
| 34 | +1. `gh issue view <issue_number>` |
| 35 | +2. `Read ppl-bugfix-harness.md` |
| 36 | +3. Dispatch subagent: |
| 37 | + |
| 38 | +``` |
| 39 | +Agent( |
| 40 | + mode: "acceptEdits", |
| 41 | + isolation: "worktree", |
| 42 | + name: "bugfix-<issue_number>", |
| 43 | + description: "PPL bugfix #<issue_number>", |
| 44 | + prompt: "<FULL harness content> + <issue details> |
| 45 | + Follow Phase 0 through Phase 3 in order. |
| 46 | + Phase 0.3 defines TDD execution flow. Do NOT skip any phase. |
| 47 | + Post the Decision Log (Phase 3.4) before completing." |
| 48 | +) |
| 49 | +``` |
| 50 | + |
| 51 | +The `isolation: "worktree"` creates a temporary git worktree branched from the current HEAD. The agent works in a clean, isolated copy of the repo — no interference with the user's working directory. If the agent makes changes, the worktree path and branch are returned in the result. |
| 52 | + |
| 53 | +4. Report back: classification, fix summary, PR URL, **worktree branch name**, items needing human attention. |
| 54 | + |
| 55 | +## Step 2B: Follow-up |
| 56 | + |
| 57 | +1. Load PR state: |
| 58 | +```bash |
| 59 | +gh pr view <pr_number> --json title,body,state,reviews,comments,statusCheckRollup,mergeable |
| 60 | +gh pr checks <pr_number> |
| 61 | +``` |
| 62 | + |
| 63 | +2. Categorize: |
| 64 | + |
| 65 | +| Signal | Type | |
| 66 | +|--------|------| |
| 67 | +| `statusCheckRollup` has failures | CI failure | |
| 68 | +| `reviews` has CHANGES_REQUESTED | Review feedback | |
| 69 | +| `mergeable` is CONFLICTING | Merge conflict | |
| 70 | +| All pass + approved | Ready — run `gh pr ready` | |
| 71 | + |
| 72 | +3. `Read ppl-bugfix-harness.md` |
| 73 | +4. Dispatch follow-up subagent: |
| 74 | + |
| 75 | +``` |
| 76 | +Agent( |
| 77 | + mode: "acceptEdits", |
| 78 | + isolation: "worktree", |
| 79 | + name: "bugfix-<issue_number>-followup", |
| 80 | + description: "PPL bugfix #<issue_number> followup", |
| 81 | + prompt: "<Phase 3.5 content from harness> |
| 82 | + PR: <pr_number> (<pr_url>), Issue: #<issue_number> |
| 83 | + Follow-up type: <CI failure / review feedback / merge conflict> |
| 84 | + Read the Decision Log PR comment FIRST before making any changes. |
| 85 | + Checkout the PR branch before starting: git checkout <pr_branch>" |
| 86 | +) |
| 87 | +``` |
| 88 | + |
| 89 | +5. Report back: what was addressed, current PR state, whether another round is needed. |
| 90 | + |
| 91 | +## Subagent Lifecycle |
| 92 | + |
| 93 | +Subagents are task-scoped. They complete and release context — they cannot poll for events. |
| 94 | + |
| 95 | +``` |
| 96 | +Agent A (Phase 0-3) → creates PR → completes |
| 97 | + (CI runs, reviewers comment, conflicts arise) |
| 98 | +Agent B (Phase 3.5) → handles feedback → completes |
| 99 | + (repeat as needed) |
| 100 | +Agent N (Phase 3.5) → gh pr ready → done |
| 101 | +``` |
| 102 | + |
| 103 | +Context is preserved across agents via: |
| 104 | +- **Decision Log** (PR comment) — single source of truth for rejected alternatives, pitfalls, design rationale |
| 105 | +- **GitHub state** (PR diff, review comments, CI logs) — reconstructed by each follow-up agent |
| 106 | + |
| 107 | +## Rules |
| 108 | + |
| 109 | +- Always inline harness content in the subagent prompt — subagents cannot read skill files |
| 110 | +- If bug is not reproducible (Phase 0.1), stop and report — do not proceed |
| 111 | +- Issue ↔ PR auto-resolution means the user never needs to track PR numbers manually |
0 commit comments