You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -700,7 +701,63 @@ Before submitting a complex workflow request, confirm you have specified:
700
701
701
702
---
702
703
703
-
## Quick Reference
704
+
## PR Deduplication Protocol
705
+
706
+
Repeated closed PR attempts on the same topic waste CI resources and agent context. Follow this protocol every time you are about to create a pull request.
707
+
708
+
### Pre-flight Duplicate PR Check
709
+
710
+
Before opening a PR, search for existing closed PRs with a similar topic using the GitHub MCP `search_pull_requests` tool:
711
+
712
+
1. Extract 2–4 keywords from the feature/fix title.
713
+
2. Run a search such as:
714
+
- `is:pr is:closed head:copilot/ <keywords>`
715
+
- `is:pr is:closed <keywords>`
716
+
3. If **no** closed PR is found, proceed normally.
717
+
4. If **one or more** closed PRs are found, move to the [Prior Failure Analysis](#prior-failure-analysis) step before writing any code.
718
+
719
+
### Prior Failure Analysis
720
+
721
+
When a closed PR exists on the same topic, perform this analysis at the start of the session — before any code exploration or implementation:
722
+
723
+
1. Read the closed PR description, review comments, and timeline.
724
+
2. Identify the **root cause of closure**:
725
+
- Reviewer requested changes → list them explicitly
726
+
- CI/test failures → identify failing checks and root cause
727
+
- Scope mismatch → clarify what was actually requested
728
+
- Duplicate of another fix → link to that fix
729
+
3. Verify that the root cause will be addressed in the new implementation.
730
+
4. Include a "## Prior Attempts" section in the new PR description that summarizes:
731
+
- Link(s) to prior closed PR(s)
732
+
- Why each was closed
733
+
- What is different this time
734
+
735
+
**Example PR description section:**
736
+
737
+
```markdown
738
+
## Prior Attempts
739
+
740
+
- #1234 (closed): CI failed on `TestFoo` due to missing nil check — fixed in this PR
741
+
- #1189 (closed): Reviewer requested scope reduction — this PR limits change to X only
742
+
```
743
+
744
+
### Retry Limit Circuit Breaker
745
+
746
+
If **two or more** closed PRs already exist on the same topic:
747
+
748
+
1.**Do not open a third PR** without explicit human review.
749
+
2. Post a comment on the originating issue that:
750
+
- Lists all prior closed PRs and their close reasons
751
+
- Explains what changed (if anything) in the new approach
752
+
- Requests explicit maintainer approval to proceed
753
+
3. Label the issue `copilot-retry-blocked` to signal that human review is required.
754
+
4. Wait for a maintainer to remove the label or leave an approving comment before creating the new PR.
755
+
756
+
**Rationale:** Two consecutive failed PR attempts indicate a systemic problem (unclear requirements, missing context, fundamental design issue) that code changes alone cannot resolve.
757
+
758
+
---
759
+
760
+
704
761
705
762
### File Locations
706
763
@@ -792,4 +849,4 @@ For detailed specifications, see individual files in `scratchpad/`:
4. Optionally correlate findings with Copilot PR patterns from `/tmp/gh-aw/pr-data/copilot-prs.json` when useful.
81
-
5. Generate **exactly three** recommendations:
81
+
4.**Always** correlate findings with Copilot PR patterns from `/tmp/gh-aw/pr-data/copilot-prs.json`.
82
+
5.**Always** perform duplicate PR pattern detection (see Phase 3) and surface retry-blocked topics.
83
+
6. Generate **exactly three** recommendations:
82
84
- each recommendation must target a distinct root cause
83
85
- each recommendation must be concrete and actionable
84
86
- each recommendation must include expected impact
85
-
6. Create **exactly three GitHub issues** (one per recommendation).
87
+
7. Create **exactly three GitHub issues** (one per recommendation).
86
88
87
89
If data is incomplete, proceed with available evidence and clearly state data quality limitations.
88
90
@@ -127,15 +129,53 @@ For each session summary:
127
129
128
130
Aggregate across all sessions to identify recurring systemic patterns.
129
131
130
-
## Phase 3 — Optional PR Cross-Analysis
132
+
## Phase 3 — PR Cross-Analysis and Duplicate Pattern Detection
131
133
132
-
If `/tmp/gh-aw/pr-data/copilot-prs.json` is present and non-empty:
134
+
This phase is **mandatory**. `/tmp/gh-aw/pr-data/copilot-prs.json` is always present from the imported `shared/copilot-pr-data-fetch.md` step.
135
+
136
+
### 3a — General PR Failure Signals
133
137
134
138
1. Extract recurring failure/friction signals from recent Copilot PRs.
135
-
2. Correlate with session-derived patterns.
139
+
2. Correlate with session-derived patterns from Phase 2.
136
140
3. Increase priority for overlapping problem areas.
137
141
138
-
If PR data is unavailable, continue without this phase and note that in evidence.
142
+
### 3b — Duplicate PR Pattern Detection
143
+
144
+
Identify topics where Copilot PRs were closed without merging and then re-attempted. This is the costliest waste pattern because each retry consumes a full agent session.
145
+
146
+
**Detection procedure:**
147
+
148
+
```bash
149
+
# Find closed (not merged) PRs grouped by normalized title
150
+
jq '[.[] | select(.state == "CLOSED" and .mergedAt == null)]
For each topic with **two or more** closed-without-merge PRs (retry-blocked topics):
158
+
159
+
1. Record the PR numbers, titles, and close dates.
160
+
2. Use the GitHub MCP `get_pull_request` or `search_pull_requests` tool to read the most recent closed PR and identify the close reason (review comments, CI failures, or reviewer request).
161
+
3. Classify the close reason into one of:
162
+
-`ci-failure` — tests or lint failed
163
+
-`reviewer-rejected` — maintainer closed without merging and left a reason
164
+
-`scope-mismatch` — implementation did not match what was requested
165
+
-`duplicate` — a separate fix was merged that covers the same change
166
+
-`unknown` — no clear close reason found
167
+
4. Build a **retry-blocked topics table**:
168
+
169
+
| Topic (PR title keywords) | Closed PRs | Close reason | Retry count |
- Topics with **exactly two** closed PRs: flag as **high-risk retry**. Include in recommendations if the close reason is actionable.
176
+
- Topics with **three or more** closed PRs: flag as **retry-blocked**. These must produce a recommendation that explicitly calls for human review before any further agent attempt.
177
+
178
+
If PR data is unexpectedly unavailable (file missing or empty), skip Phase 3 and note that in all three issue bodies.
139
179
140
180
## Phase 4 — Recommendation Selection
141
181
@@ -145,6 +185,7 @@ Selection rules:
145
185
146
186
- cover distinct root causes (no overlap)
147
187
- prioritize high-frequency and high-severity patterns
188
+
-**retry-blocked topics (≥2 closed PRs) are automatically elevated to high priority** — if any exist, at least one recommendation must address them unless all three slots are taken by higher-impact findings from Phase 2
148
189
- include evidence (counts, rates, or representative examples)
149
190
- include expected impact and a concrete change proposal
150
191
@@ -155,6 +196,7 @@ Possible recommendation domains:
When an issue covers a retry-blocked topic (from Phase 3b), **append** the following section to the body:
240
+
241
+
```markdown
242
+
### Prior Failed Attempts
243
+
244
+
The following Copilot PRs on this topic were closed without merging before this issue was created:
245
+
246
+
| PR | Closed (YYYY-MM-DD) | Close reason |
247
+
|----|---------------------|--------------|
248
+
| #N | YYYY-MM-DD |[reason]|
249
+
| #M | YYYY-MM-DD |[reason]|
250
+
251
+
**Retry count: [N] — human review required before a new implementation attempt.**
252
+
Any agent attempting to implement this recommendation MUST read this section and the linked PRs, address all close reasons, and post a plan comment on this issue before opening a new PR.
253
+
```
254
+
255
+
### Labels for Retry-Blocked Issues
256
+
257
+
When creating an issue that covers a retry-blocked topic, add `copilot-retry-blocked` to the labels list in the `create_issue` safe-output call alongside the standard labels.
258
+
195
259
## Items That Should Not Be Addressed
196
260
197
261
The following items are out of scope because they are not actionable by repository users:
@@ -215,8 +279,12 @@ Before creating issues, verify:
215
279
-[ ] last-14-day filtering was applied
216
280
-[ ]`events.jsonl` parsing was attempted across all in-scope sessions
217
281
-[ ] tool latency/payload, validation timing, context size, orchestration, and prompt drift were analyzed
282
+
-[ ] Phase 3 PR cross-analysis was performed (not skipped)
283
+
-[ ] duplicate PR pattern detection was run and retry-blocked topics table was built
284
+
-[ ] retry-blocked topics (≥2 closed PRs) are reflected in at least one recommendation when present
218
285
-[ ] exactly three recommendations selected
219
286
-[ ] each recommendation has evidence + proposed change + expected impact
287
+
-[ ] retry-blocked issues include the "Prior Failed Attempts" addendum and `copilot-retry-blocked` label
0 commit comments