Skip to content

Commit 2ba507e

Browse files
committed
fix: add PR review loop and merge step to aw-daily pipeline
- Add Phase 8: Copilot review monitoring, comment remediation, thread resolution, and squash merge as end-to-end pipeline completion - Remove assign-to-agent safe-output (caused competing Copilot PRs) - Update Phase 5 prose to prevent agent from assigning issues to Copilot - Replace "no auto-merge" with active merge in Phase 8 Step 8.5 - Update Phase 9 summary to include review/merge/thread stats - Recompile daily-intelligence.lock.yml with all changes
1 parent 6c88e97 commit 2ba507e

3 files changed

Lines changed: 139 additions & 59 deletions

File tree

.claude/skills/aw-daily/SKILL.md

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,103 @@ When running as a gh-aw workflow, `post-steps` handles marking the draft PR read
334334
gh pr ready {PR_NUMBER}
335335
```
336336

337-
The pipeline does NOT auto-merge. Merging is a separate review decision.
337+
Phase 8 handles review monitoring, remediation, and merge. Do NOT merge here.
338338

339339
**Error mode:** If PR creation fails, report error. Leave branch for manual inspection. Switch back to `ORIGINAL_BRANCH`.
340340

341341
---
342342

343+
## Phase 8: PR Review Monitoring & Remediation
344+
345+
After the PR is created and marked ready, request Copilot review and monitor for feedback. This phase runs a review-fix loop until the PR is approved or the loop limit is reached.
346+
347+
### Step 8.1: Request Copilot Review
348+
349+
```bash
350+
gh pr edit {PR_NUMBER} --repo zircote/github-agentic-workflows --add-reviewer "@copilot" 2>/dev/null || echo "Copilot reviewer not available"
351+
```
352+
353+
### Step 8.2: Wait for Review
354+
355+
Poll for review completion. Check every 30 seconds, up to 10 minutes:
356+
357+
```bash
358+
REVIEW_STATE=$(gh pr view {PR_NUMBER} --repo zircote/github-agentic-workflows --json reviews --jq '.reviews | map(select(.state != "COMMENTED")) | last | .state // "PENDING"')
359+
```
360+
361+
States: `APPROVED` (proceed to 8.5), `CHANGES_REQUESTED` (proceed to 8.3), `PENDING` (keep polling).
362+
363+
If no review after 10 minutes, log "Review timeout — PR left open for async review" and skip to Phase 9.
364+
365+
### Step 8.3: Fetch and Triage Review Comments
366+
367+
Fetch all inline code review comments:
368+
369+
```bash
370+
gh api repos/zircote/github-agentic-workflows/pulls/{PR_NUMBER}/comments --paginate
371+
```
372+
373+
For each comment, assess:
374+
- Is the suggestion correct? (Check against the referenced code)
375+
- Is the fix safe? (Localized change, no cascading effects)
376+
- Confidence score: high (>= 95%) = auto-accept, low = skip with explanation
377+
378+
### Step 8.4: Apply Fixes, Reply, Push, Resolve
379+
380+
For each accepted comment:
381+
1. Read the target file
382+
2. Apply the fix using section headers as anchors
383+
3. If the file has a `.claude/` mirror (or vice versa), apply the same fix to both copies
384+
385+
After all fixes:
386+
```bash
387+
git add {changed files}
388+
git commit -m "fix: address Copilot review feedback
389+
390+
- {bullet per fix}
391+
392+
Resolves review comments on PR #{PR_NUMBER}"
393+
git push origin daily-intelligence-{TODAY}
394+
```
395+
396+
Reply to every comment:
397+
- **Fixed**: `Fixed in {commit-sha-short}.`
398+
- **Rejected**: `Reviewed — not applying because {reason}.`
399+
- **Question**: `{direct answer}`
400+
401+
Resolve all threads via GraphQL:
402+
```bash
403+
gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "{THREAD_ID}"}) { thread { isResolved } } }'
404+
```
405+
406+
**Loop limit:** Maximum 2 review-fix cycles. If Copilot requests changes a third time, log "Review loop limit reached — PR left for manual review" and proceed to Phase 9.
407+
408+
### Step 8.5: Merge the PR
409+
410+
After review is complete (approved, or fixes pushed and all threads resolved), merge the PR:
411+
412+
```bash
413+
gh pr merge {PR_NUMBER} --repo zircote/github-agentic-workflows --squash --delete-branch
414+
```
415+
416+
If direct merge fails (e.g., branch protection requires approvals), fall back to auto-merge:
417+
```bash
418+
gh pr merge {PR_NUMBER} --repo zircote/github-agentic-workflows --squash --auto --delete-branch || echo "Auto-merge enabled — will merge when requirements are met"
419+
```
420+
421+
Verify the merge succeeded:
422+
```bash
423+
gh pr view {PR_NUMBER} --repo zircote/github-agentic-workflows --json state -q '.state'
424+
```
425+
426+
If state is `MERGED`, the pipeline is complete. If state is still `OPEN` with auto-merge enabled, report that and proceed to Phase 9.
427+
428+
If `--no-merge` flag was passed, skip this step entirely and report "PR left open per --no-merge flag."
429+
430+
**Error mode:** If remediation fails for any comment, skip that comment with a reply explaining the issue. Do not block the entire phase on a single comment failure. If merge fails after 2 attempts, leave the PR open and report the error.
431+
432+
---
433+
343434
## Phase 9: Final Summary
344435

345436
```
@@ -354,7 +445,11 @@ The pipeline does NOT auto-merge. Merging is a separate review decision.
354445
| Gaps Found: N (P incorrect, Q outdated, R new)|
355446
| Issues: N created, M skipped (existing) |
356447
| Files Changed: N |
357-
| PR: {PR_URL} (ready for review) |
448+
| PR: {PR_URL} |
449+
| Review: {APPROVED/PENDING/CHANGES_REQ} |
450+
| Fixes Applied: N comments fixed, M rejected |
451+
| Threads: N/M resolved |
452+
| Merge: {MERGED/auto-merge enabled/open} |
358453
+--------------------------------------------------+
359454
```
360455

0 commit comments

Comments
 (0)