pwrl-review-sync-status — GitHub PR Integration & Reporting
Purpose: Final phase of review workflow. Takes the report artifact from Phase 4 and synchronizes all review findings back to GitHub:
- Posts detailed review findings as PR comment
- Creates formal GitHub review (APPROVE or REQUEST_CHANGES)
- Updates PR labels based on verdict and quality scores
- Resolves review workflow by posting status to GitHub
Interaction Method
- Minimal user interaction (status updates only)
- Display confirmation of GitHub updates posted
- If GitHub API fails, provide fallback: "Review findings saved locally. Manual GitHub posting may be needed."
- Ask one question if needed: "Post this review to GitHub? [yes/no]"
Input: Report Artifact
Expects artifact from pwrl-review-report with:
report_id: YYYY-MM-DD-UNN-report
created: ISO-8601-timestamp
# Executive Summary
verdict: APPROVED | REQUEST CHANGES | REJECTED
critical_issues: [count]
major_issues: [count]
minor_issues: [count]
# Quality Scores
overall_score: [0-100]%
code_quality_score: [0-100]%
security_score: [0-100]%
test_coverage_score: [0-100]%
documentation_score: [0-100]%
# Detailed findings organized by category
code_quality_findings: [list]
security_findings: [list]
test_coverage_findings: [list]
documentation_findings: [list]
integration_findings: [list]
# Sign-off
approved_by: [user/reviewer]
approval_date: ISO-8601-timestamp
Plus: PR number or branch reference from original input context
Output: GitHub PR Updates
Primary Output:
- GitHub PR comment with formatted review findings and metrics
- Formal GitHub review (APPROVE or REQUEST_CHANGES action)
- PR labels updated (review-approved, review-changes-requested, security-concerns, coverage-low, etc.)
Status Output:
- Sync status logged: "Review findings posted to GitHub PR [#N]"
- All updates timestamp for audit trail
Workflow
Step 1: Validate Report Artifact & PR Context
Check report artifact has:
- Valid
report_id
- Verdict (APPROVED/REQUEST_CHANGES/REJECTED)
- All quality scores
- Findings populated (even if empty lists)
- Sign-off metadata
Resolve PR context:
- Extract PR number from original input (argument or context)
- Verify PR exists in GitHub
- Get current PR metadata (title, description, base branch)
If validation fails:
- Return error: "Report artifact invalid or PR context missing"
- Optionally fall back to local file storage
Step 2: Format Review for GitHub
Comment Header:
- Verdict prominently displayed (✅ APPROVED / ⚠️ REQUEST CHANGES / ❌ REJECTED)
- Link to full report artifact (if stored)
- Execution timestamp
Quality Metrics Section:
Findings Section:
- Group by severity (CRITICAL, MAJOR, MINOR)
- For each finding:
- File:line reference (clickable)
- Issue description
- Category (Code Quality, Security, Tests, Docs, Integration)
- Severity badge
- Limit to top 20 findings (full list in linked artifact if deep review)
Action Items (for REQUEST CHANGES only):
- Numbered list of top 3-5 fixes required
- Specific: not vague ("Remove unused variable" not "clean up")
- Actionable: includes file:line if applicable
Next Steps:
- For APPROVED: "Ready to merge ✅"
- For REQUEST CHANGES: "Please fix the above items and request re-review"
- For REJECTED: "Please discuss approach with team before resubmitting"
Step 3: Post Comment to GitHub PR
Construct comment with formatted findings (Step 2)
Post to PR using GitHub API:
POST /repos/{owner}/{repo}/issues/{issue_number}/comments
{
"body": "[formatted comment]"
}
Handle errors:
- If rate-limited: Retry after rate limit reset
- If PR doesn't exist: Log error, save locally
- If auth fails: Provide OAuth re-auth instructions
Success: Store comment ID for potential updates/edits later
Step 4: Create Formal GitHub Review
Review Action: Based on verdict (see review-verdict-mapping.md)
| Verdict |
GitHub Action |
Reason |
| APPROVED |
APPROVE |
Code ready to merge |
| REQUEST CHANGES |
REQUEST_CHANGES |
Issues found, please fix |
| REJECTED |
REQUEST_CHANGES (blocking) |
Major blockers, discuss first |
Post review using GitHub API:
POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews
{
"body": "[summary of review]",
"event": "APPROVE" | "REQUEST_CHANGES" | "COMMENT"
}
Review body: Brief summary (2-3 lines) of key findings
- APPROVED: "All checks passed. Code is ready to merge."
- REQUEST CHANGES: "X critical/major issues require fixes before merge"
- REJECTED: "Blocking issues found. Please discuss before resubmitting."
Handle errors:
- If already reviewed: Skip (don't duplicate)
- If auth fails: Fall back to comment only
Step 5: Update PR Labels
Label Assignment Rules: (see review-verdict-mapping.md)
Auto-add labels:
review-approved (if APPROVED)
review-changes-requested (if REQUEST CHANGES)
review-rejected (if REJECTED)
security-concerns (if security CRITICAL/MAJOR found)
coverage-low (if coverage < threshold)
docs-incomplete (if documentation issues found)
build-failing (if integration check failed)
Auto-remove old labels:
- Remove
review-approved if new review is REQUEST CHANGES/REJECTED
- Remove
review-changes-requested if new review is APPROVED
- Remove
coverage-low if new coverage meets threshold
- Keep:
security-concerns, docs-incomplete, build-failing (must be manually cleared)
Label persistence:
- Save labels applied for audit trail
- Log removed labels for history
- Allow user override if needed
Step 6: Post Status & Wrap Up
Final Status Message:
✅ Review posted to GitHub PR #{number}
- Comment with findings: ✓
- Formal review (APPROVE/REQUEST_CHANGES): ✓
- Labels updated: ✓
- Ready for merge? [Based on verdict]
Completion Logging:
- Log timestamp of all GitHub updates
- Store PR number and link for reference
- Record any GitHub API errors or retries
- Indicate local fallback if needed
Next Action (by Verdict):
- APPROVED: "PR is ready to merge"
- REQUEST CHANGES: "Author should fix issues and request re-review"
- REJECTED: "Team discussion recommended before resubmitting"
Error Handling
| Error |
Recovery Strategy |
| PR not found |
Return error; confirm PR number with user |
| Auth token invalid/expired |
Request OAuth re-auth; provide link to GitHub settings |
| Rate limited |
Wait and retry; inform user of delay |
| GitHub API unavailable |
Fall back to local artifact save; suggest manual posting |
| Report artifact invalid |
Return error; return to pwrl-review-report |
| Formatting fails |
Use plain text fallback; post unformatted findings |
| Comment too large |
Truncate to 60KB limit; link to full artifact |
| Label doesn't exist |
Create label with standard format or skip |
| Already reviewed |
Skip formal review; post comment only (avoid duplicates) |
Retry Policy:
- Max 3 retries for transient errors (rate limit, timeout)
- Exponential backoff: 1s → 2s → 4s
- After 3 retries: Fall back to local save and inform user
Testing Coverage
Happy Path Tests:
- ✅ APPROVED verdict → APPROVE action, correct labels
- ✅ REQUEST CHANGES verdict → REQUEST_CHANGES action, action items clear
- ✅ REJECTED verdict → REQUEST_CHANGES action, blocking issues noted
- ✅ Comment formatted correctly → Markdown renders properly
- ✅ Labels applied and old labels removed
- ✅ All 5 quality metrics shown correctly
Edge Cases:
- ✅ Very large findings list (truncate to top 20)
- ✅ No findings (empty lists, APPROVED with zero issues)
- ✅ All CRITICAL issues (REJECTED, clear escalation)
- ✅ Mixed findings (some pass, some fail)
- ✅ Security CRITICAL (triggers security label + warning)
- ✅ PR already has review (skip duplicate, post comment only)
Error Cases:
- ✅ GitHub rate limited (retry with backoff)
- ✅ Auth token expired (request re-auth)
- ✅ PR doesn't exist (error + local save)
- ✅ Comment too large (truncate to 60KB)
- ✅ Network timeout (retry and fallback)
Output Validation:
- ✅ Comment posted successfully
- ✅ GitHub review created (correct action)
- ✅ Labels match verdict + findings
- ✅ All updates timestamped
- ✅ Audit trail logged
When to Use
- Always: As final phase of pwrl-review orchestrator (after Phase 4)
- Manual trigger: If GitHub sync was skipped and findings need posting
- Retry scenario: If initial sync failed, retry after resolving errors
- PR updates: When re-running review on same PR, updates existing comment + review
Related Documentation
- review-verdict-mapping.md — Verdict → GitHub action & label mappings
- github-pr-sync-protocol.md — GitHub API details, OAuth, retry strategy
- artifact-schemas.md — Report artifact structure
- verdict-criteria.md — Verdict decision logic
Dependencies
GitHub Integration:
- GitHub account with repo access
- GitHub OAuth token (PAT) with PR read/write permissions
gh CLI or direct API access via library
Artifacts:
- Report artifact from Phase 4 (pwrl-review-report)
- PR number from original input context
External Services:
- GitHub API:
api.github.com (rate limits: 60 req/hr unauthenticated, 5000 req/hr authenticated)
- Network connectivity for GitHub API calls
1---2name: pwrl-review-sync-status3description: Post review findings back to GitHub PR with comments, formal reviews, and labels. Final phase of pwrl-review orchestrator.4---56# pwrl-review-sync-status — GitHub PR Integration & Reporting78**Purpose:** Final phase of review workflow. Takes the report artifact from Phase 4 and synchronizes all review findings back to GitHub:9- Posts detailed review findings as PR comment10- Creates formal GitHub review (APPROVE or REQUEST_CHANGES)11- Updates PR labels based on verdict and quality scores12- Resolves review workflow by posting status to GitHub1314## Interaction Method1516- Minimal user interaction (status updates only)17- Display confirmation of GitHub updates posted18- If GitHub API fails, provide fallback: "Review findings saved locally. Manual GitHub posting may be needed."19- Ask one question if needed: "Post this review to GitHub? [yes/no]"2021## Input: Report Artifact2223Expects artifact from `pwrl-review-report` with:2425```yaml26report_id: YYYY-MM-DD-UNN-report27created: ISO-8601-timestamp2829# Executive Summary30verdict: APPROVED | REQUEST CHANGES | REJECTED31critical_issues: [count]32major_issues: [count]33minor_issues: [count]3435# Quality Scores36overall_score: [0-100]%37code_quality_score: [0-100]%38security_score: [0-100]%39test_coverage_score: [0-100]%40documentation_score: [0-100]%4142# Detailed findings organized by category43code_quality_findings: [list]44security_findings: [list]45test_coverage_findings: [list]46documentation_findings: [list]47integration_findings: [list]4849# Sign-off50approved_by: [user/reviewer]51approval_date: ISO-8601-timestamp52```5354Plus: PR number or branch reference from original input context5556## Output: GitHub PR Updates5758**Primary Output:**59- GitHub PR comment with formatted review findings and metrics60- Formal GitHub review (APPROVE or REQUEST_CHANGES action)61- PR labels updated (review-approved, review-changes-requested, security-concerns, coverage-low, etc.)6263**Status Output:**64- Sync status logged: "Review findings posted to GitHub PR [#N]"65- All updates timestamp for audit trail6667## Workflow6869### Step 1: Validate Report Artifact & PR Context70711. Check report artifact has:72 - Valid `report_id`73 - Verdict (APPROVED/REQUEST_CHANGES/REJECTED)74 - All quality scores75 - Findings populated (even if empty lists)76 - Sign-off metadata77782. Resolve PR context:79 - Extract PR number from original input (argument or context)80 - Verify PR exists in GitHub81 - Get current PR metadata (title, description, base branch)82833. **If validation fails:**84 - Return error: "Report artifact invalid or PR context missing"85 - Optionally fall back to local file storage8687### Step 2: Format Review for GitHub8889**Comment Header:**90- Verdict prominently displayed (✅ APPROVED / ⚠️ REQUEST CHANGES / ❌ REJECTED)91- Link to full report artifact (if stored)92- Execution timestamp9394**Quality Metrics Section:**95- Display as visual progress bars:96 ```97 📊 Code Quality: ████████░░ 85%98 📊 Security: ██████████ 100%99 📊 Test Coverage: ███████░░░ 75%100 📊 Documentation: █████████░ 90%101 ─────────────────────────────102 Overall Score: ████████░░ 87%103 ```104- Critical / Major / Minor issue counts with emoji severity105- Pass/Fail status for each dimension106107**Findings Section:**108- Group by severity (CRITICAL, MAJOR, MINOR)109- For each finding:110 - File:line reference (clickable)111 - Issue description112 - Category (Code Quality, Security, Tests, Docs, Integration)113 - Severity badge114- Limit to top 20 findings (full list in linked artifact if deep review)115116**Action Items (for REQUEST CHANGES only):**117- Numbered list of top 3-5 fixes required118- Specific: not vague ("Remove unused variable" not "clean up")119- Actionable: includes file:line if applicable120121**Next Steps:**122- For APPROVED: "Ready to merge ✅"123- For REQUEST CHANGES: "Please fix the above items and request re-review"124- For REJECTED: "Please discuss approach with team before resubmitting"125126### Step 3: Post Comment to GitHub PR1271281. **Construct comment** with formatted findings (Step 2)1292. **Post to PR** using GitHub API:130 ```131 POST /repos/{owner}/{repo}/issues/{issue_number}/comments132 {133 "body": "[formatted comment]"134 }135 ```1363. **Handle errors:**137 - If rate-limited: Retry after rate limit reset138 - If PR doesn't exist: Log error, save locally139 - If auth fails: Provide OAuth re-auth instructions1401414. **Success:** Store comment ID for potential updates/edits later142143### Step 4: Create Formal GitHub Review144145**Review Action:** Based on verdict (see [review-verdict-mapping.md](references/review-verdict-mapping.md))146147| Verdict | GitHub Action | Reason |148|---------|---|---|149| APPROVED | **APPROVE** | Code ready to merge |150| REQUEST CHANGES | **REQUEST_CHANGES** | Issues found, please fix |151| REJECTED | **REQUEST_CHANGES** (blocking) | Major blockers, discuss first |1521531. **Post review** using GitHub API:154 ```155 POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews156 {157 "body": "[summary of review]",158 "event": "APPROVE" | "REQUEST_CHANGES" | "COMMENT"159 }160 ```1611622. **Review body:** Brief summary (2-3 lines) of key findings163 - APPROVED: "All checks passed. Code is ready to merge."164 - REQUEST CHANGES: "X critical/major issues require fixes before merge"165 - REJECTED: "Blocking issues found. Please discuss before resubmitting."1661673. **Handle errors:**168 - If already reviewed: Skip (don't duplicate)169 - If auth fails: Fall back to comment only170171### Step 5: Update PR Labels172173**Label Assignment Rules:** (see [review-verdict-mapping.md](references/review-verdict-mapping.md))174175**Auto-add labels:**176- `review-approved` (if APPROVED)177- `review-changes-requested` (if REQUEST CHANGES)178- `review-rejected` (if REJECTED)179- `security-concerns` (if security CRITICAL/MAJOR found)180- `coverage-low` (if coverage < threshold)181- `docs-incomplete` (if documentation issues found)182- `build-failing` (if integration check failed)183184**Auto-remove old labels:**185- Remove `review-approved` if new review is REQUEST CHANGES/REJECTED186- Remove `review-changes-requested` if new review is APPROVED187- Remove `coverage-low` if new coverage meets threshold188- Keep: `security-concerns`, `docs-incomplete`, `build-failing` (must be manually cleared)189190**Label persistence:**191- Save labels applied for audit trail192- Log removed labels for history193- Allow user override if needed194195### Step 6: Post Status & Wrap Up196197**Final Status Message:**198```199✅ Review posted to GitHub PR #{number}200 - Comment with findings: ✓201 - Formal review (APPROVE/REQUEST_CHANGES): ✓202 - Labels updated: ✓203 - Ready for merge? [Based on verdict]204```205206**Completion Logging:**207- Log timestamp of all GitHub updates208- Store PR number and link for reference209- Record any GitHub API errors or retries210- Indicate local fallback if needed211212**Next Action (by Verdict):**213- APPROVED: "PR is ready to merge"214- REQUEST CHANGES: "Author should fix issues and request re-review"215- REJECTED: "Team discussion recommended before resubmitting"216217---218219## Error Handling220221| Error | Recovery Strategy |222|-------|-------------------|223| **PR not found** | Return error; confirm PR number with user |224| **Auth token invalid/expired** | Request OAuth re-auth; provide link to GitHub settings |225| **Rate limited** | Wait and retry; inform user of delay |226| **GitHub API unavailable** | Fall back to local artifact save; suggest manual posting |227| **Report artifact invalid** | Return error; return to pwrl-review-report |228| **Formatting fails** | Use plain text fallback; post unformatted findings |229| **Comment too large** | Truncate to 60KB limit; link to full artifact |230| **Label doesn't exist** | Create label with standard format or skip |231| **Already reviewed** | Skip formal review; post comment only (avoid duplicates) |232233**Retry Policy:**234- Max 3 retries for transient errors (rate limit, timeout)235- Exponential backoff: 1s → 2s → 4s236- After 3 retries: Fall back to local save and inform user237238---239240## Testing Coverage241242**Happy Path Tests:**243- ✅ APPROVED verdict → APPROVE action, correct labels244- ✅ REQUEST CHANGES verdict → REQUEST_CHANGES action, action items clear245- ✅ REJECTED verdict → REQUEST_CHANGES action, blocking issues noted246- ✅ Comment formatted correctly → Markdown renders properly247- ✅ Labels applied and old labels removed248- ✅ All 5 quality metrics shown correctly249250**Edge Cases:**251- ✅ Very large findings list (truncate to top 20)252- ✅ No findings (empty lists, APPROVED with zero issues)253- ✅ All CRITICAL issues (REJECTED, clear escalation)254- ✅ Mixed findings (some pass, some fail)255- ✅ Security CRITICAL (triggers security label + warning)256- ✅ PR already has review (skip duplicate, post comment only)257258**Error Cases:**259- ✅ GitHub rate limited (retry with backoff)260- ✅ Auth token expired (request re-auth)261- ✅ PR doesn't exist (error + local save)262- ✅ Comment too large (truncate to 60KB)263- ✅ Network timeout (retry and fallback)264265**Output Validation:**266- ✅ Comment posted successfully267- ✅ GitHub review created (correct action)268- ✅ Labels match verdict + findings269- ✅ All updates timestamped270- ✅ Audit trail logged271272---273274## When to Use275276- **Always:** As final phase of pwrl-review orchestrator (after Phase 4)277- **Manual trigger:** If GitHub sync was skipped and findings need posting278- **Retry scenario:** If initial sync failed, retry after resolving errors279- **PR updates:** When re-running review on same PR, updates existing comment + review280281---282283## Related Documentation284285- [review-verdict-mapping.md](references/review-verdict-mapping.md) — Verdict → GitHub action & label mappings286- [github-pr-sync-protocol.md](references/github-pr-sync-protocol.md) — GitHub API details, OAuth, retry strategy287- [artifact-schemas.md](../pwrl-review/references/artifact-schemas.md) — Report artifact structure288- [verdict-criteria.md](../pwrl-review/references/verdict-criteria.md) — Verdict decision logic289290---291292## Dependencies293294**GitHub Integration:**295- GitHub account with repo access296- GitHub OAuth token (PAT) with PR read/write permissions297- `gh` CLI or direct API access via library298299**Artifacts:**300- Report artifact from Phase 4 (pwrl-review-report)301- PR number from original input context302303**External Services:**304- GitHub API: `api.github.com` (rate limits: 60 req/hr unauthenticated, 5000 req/hr authenticated)305- Network connectivity for GitHub API calls306