Goal: Monitor for post-merge follow-up requests
When a PR is merged, reviewers or stakeholders may post follow-up comments asking for additional work, reporting related issues, or requesting improvements. The bot monitors merged PRs on an exponential backoff schedule to catch these requests.
Merged stories are rechecked at these intervals after merge:
- 1 day after merge
- 2 days after first check (3 days total)
- 4 days after second check (7 days total)
- 8 days after third check (15 days total)
- Final state - no more checking
When a story transitions to "merged", add these fields:
{
"status": "merged",
"mergedAt": "2026-02-02T10:00:00Z",
"nextMergedCheck": "2026-02-03T10:00:00Z",
"mergedCheckCount": 0,
"mergedCheckFinalState": false
}After merging a PR (in the "pushed" → "merged" transition):
- Set
mergedAtto current timestamp - Set
nextMergedChecktomergedAt + 1 day - Set
mergedCheckCountto0 - Set
mergedCheckFinalStatetofalse
Before picking active stories, check for merged stories that need rechecking:
-
Filter stories where:
status: "merged"mergedCheckFinalState: falsenextMergedCheckis in the past (current time >= nextMergedCheck)
-
If any merged stories need rechecking, pick the one with the OLDEST
nextMergedChecktimestamp -
This has priority BELOW all active work (pushed PRs, committed code, and pending development):
- URGENT:
status: "pushed"+lastActivityBy: "reviewer" - HIGH:
status: "committed" - MEDIUM:
status: "pushed"+lastActivityBy: "bot" - NORMAL:
status: "pending" - LOW (Post-Merge Monitoring):
status: "merged"+ needs recheck (only when enabled via run-state.json)
- URGENT:
When a merged story is picked for rechecking:
$BOT_DIR/scripts/filter-pr-reviews.sh <pr-number> markdown <pr-repository>- Only look at comments with timestamp >
mergedAt - Only consider comments from Brave org members (filtered script handles this)
- Look for requests for new features, related fixes, or follow-up issues
- Look for reports of problems introduced by the merged PR
- Look for requests to file tracking issues
When a post-merge comment suggests follow-up work, but you determine it's not necessary for a valid reason:
-
Evaluate the suggestion: Determine if it's:
- A minor optional style improvement (not a bug or functional issue)
- Already addressed or not applicable
- A reasonable enhancement but not critical
-
Post an explanatory comment: Reply to the comment thread explaining your decision.
Finding comment IDs in filtered PR data:
The filtered PR reviews script returns JSON with three comment types:
review_comments[]- Inline code review comments (haveidfield)issue_comments[]- General PR discussion comments (haveidfield)reviews[]- Review summaries (use review ID, different API endpoint)
To extract comment IDs from JSON output:
# Get review comments (inline code comments)
REVIEW_COMMENT_IDS=$(echo "$FILTERED_DATA" | jq -r '.review_comments[].id')
# Get discussion comment IDs
ISSUE_COMMENT_IDS=$(echo "$FILTERED_DATA" | jq -r '.issue_comments[].id')
# Get specific comment ID for a user (e.g., @goodov)
COMMENT_ID=$(echo "$FILTERED_DATA" | jq -r '.issue_comments[] | select(.user.login == "goodov") | .id')Posting the reply:
# Get PR repository from bot config (provided in prompt)
PR_REPO="<project.prRepository from bot config>"
# Calculate next check timespan based on current mergedCheckCount
# mergedCheckCount 0 (just did first check): next in 2 days
# mergedCheckCount 1 (just did second check): next in 4 days
# mergedCheckCount 2 (just did third check): next in 8 days
CURRENT_CHECK_COUNT=$(jq -r '.mergedCheckCount' <<< "$STORY_JSON")
case $CURRENT_CHECK_COUNT in
0) NEXT_CHECK_DAYS="2 days";;
1) NEXT_CHECK_DAYS="4 days";;
2) NEXT_CHECK_DAYS="8 days";;
*) NEXT_CHECK_DAYS="the final check period";;
esac
# For review comments (inline code comments), use the pull request comment replies API:
gh api \
--method POST \
"/repos/$PR_REPO/pulls/comments/<comment-id>/replies" \
-f body="$(cat <<'EOF'
@[username] Thank you for the suggestion. I've evaluated this and determined it's not necessary to create a follow-up task because:
[Your specific reasoning - e.g., "This is a minor optional style improvement that doesn't affect functionality or correctness"]
If you believe this change is important and should be prioritized, please let me know within the next [timespan] and I'll create a follow-up task for it.
I'll continue monitoring this PR for [timespan] as part of the post-merge review process.
EOF
)"
# For discussion comments (issue comments), reply using the issue comment API:
gh api \
--method POST \
"/repos/$PR_REPO/issues/comments/<comment-id>/replies" \
-f body="[same body as above]"Replace:
<comment-id>: The GitHub comment ID from the filtered PR reviews[username]: The GitHub username who made the suggestion (without @)[Your specific reasoning]: Clear explanation of why follow-up work isn't needed[timespan]: The time until next check (e.g., "2 days", "4 days", "8 days")
Important notes:
- Always provide a clear, specific reason for declining the follow-up
- Be respectful and acknowledge the reviewer's input
- If it's a borderline case or reasonable suggestion, explicitly invite them to indicate importance
- Try the appropriate reply API first (review comment vs issue comment)
- If the reply API fails (not all comment types support threaded replies), fall back to a top-level comment:
gh pr comment <pr-number> --body "[same body as above]"For each follow-up task requested in post-merge comments:
Get the issue repository from the bot config provided in the prompt (project.issueRepository).
Create a detailed GitHub issue:
gh issue create --repo "$ISSUE_REPO" \
--title "[Follow-up] Brief description of the follow-up task" \
--body "$(cat <<'EOF'
## Context
This is a follow-up task from PR #[original-pr-number] which fixed [original-story-title].
## Post-Merge Request
[Quote the relevant comment from the reviewer/stakeholder requesting this work]
- Requested by: @[username]
- Comment timestamp: [timestamp]
- Original PR: [PR URL]
## What Needs to Be Done
[Detailed description of the follow-up work requested]
[If applicable: Why this follow-up is necessary]
## Acceptance Criteria
- [ ] [Specific requirement 1]
- [ ] [Specific requirement 2]
- [ ] [Test to verify the fix]
## Related
- Original Story: [original-story-id]
- Original PR: #[pr-number]
- Post-merge comment: [link to specific comment]
EOF
)"Capture the issue number from the output.
Create a new story entry following the same format as existing stories:
{
"id": "US-XXX",
"title": "Brief title matching the GitHub issue",
"description": "Follow-up from US-[original] PR #[pr-number]: [Description of what needs to be done]",
"acceptanceCriteria": [
"Read [bestPractices.docsDir]/[bestPractices.indexFile] (path from config.json)",
"[Specific test or verification step]",
"[Additional requirements]"
],
"status": "pending",
"priority": [appropriate-number],
"issueUrl": "https://github.com/[issue-repo]/issues/[issue-number]",
"issueNumber": [issue-number],
"relatedStories": ["US-[original-story-id]"],
"relatedPRs": ["#[original-pr-number]"]
}Key fields:
id: Next available US-XXX number in sequencetitle: Clear, concise title matching the GitHub issuedescription: Include context from original story and PRacceptanceCriteria: Start with the best practices index file (path =bestPractices.docsDir+bestPractices.indexFilefrom config.json), then specific requirements from the post-merge requeststatus: Always"pending"for new storiespriority: Set based on urgency (if blocker/critical: low number, if enhancement: higher number)issueUrl: Full URL to the GitHub issue you just createdissueNumber: The issue number as an integerrelatedStories: Array with original story IDrelatedPRs: Array with original PR number
Write the updated prd.json with the new story added to the stories array.
From the filtered PR reviews data, you have the comment ID of the post-merge comment requesting follow-up work.
Reply directly to that comment using the GitHub API:
# Get PR repository from bot config (provided in prompt)
PR_REPO="<project.prRepository from bot config>"
# Reply to the specific comment (creates a threaded reply)
gh api \
--method POST \
"/repos/$PR_REPO/pulls/comments/<comment-id>/replies" \
-f body="$(cat <<'EOF'
@[username] Thank you for the follow-up request. I've created a tracking issue for this work:
🔗 [Issue #[issue-number]: [issue-title]]([issue-url])
This has been added to the work queue as story US-XXX and will be prioritized accordingly.
EOF
)"Replace:
<comment-id>: The GitHub comment ID from the filtered PR reviews (the comment that requested follow-up)[username]: The GitHub username who requested the follow-up (without @)[issue-number]: The issue number from step a[issue-title]: The issue title[issue-url]: Full URL to the issueUS-XXX: The story ID from step b
Important: The filtered PR reviews data includes comment IDs. Use the ID of the specific comment requesting the follow-up so your reply appears in the same thread as their request.
If the comment type doesn't support replies (e.g., review comments vs PR comments), fall back to a top-level comment:
gh pr comment <pr-number> --body "[same body as above]"Run the merged-check command to increment the count and recalculate the backoff:
python3 $BOT_DIR/scripts/update-prd-status.py merged-check <story-id>This handles the exponential backoff schedule (2d, 4d, 8d) and sets mergedCheckFinalState: true after the fourth check.
See progress-reporting.md for the post-merge check format.
- Post-merge rechecking does NOT require GitHub API calls during task selection - the decision is based purely on timestamps in prd.json
- Merged stories in final state (
mergedCheckFinalState: true) are never picked during task selection - This system is independent from the main workflow and doesn't block other work
- If no merged stories need rechecking, task selection proceeds normally to active/pending stories