fix: clear stale pr-queue-hygiene conflict marker and paginate comments - #433
Merged
Merged
Conversation
Fixes two defects in scripts/pr-queue-hygiene.mjs from the review of #240: - On the non-conflicting path, the loop previously continued without clearing the first-conflict marker or the needs-rebase-or-close label. If the PR later reconflicted, hoursSince() was computed from the stale marker's timestamp, so the PR was flagged as stale immediately instead of getting a fresh 48-hour window. A trusted 'resolved' marker is now posted when a PR stops conflicting, and findFirstConflictObservedAt() ignores any first-conflict marker predating the latest trusted resolved marker. - The comment lookup only read a single per_page=100 page. Since issue comments sort ascending, a PR with more than 100 comments could have its marker on an earlier page that was never fetched, causing a duplicate marker to be posted every run and the 48h gate to never fire. fetchAllIssueComments() now paginates through every page, the same way fetchAllOpenPRs() already does for PRs. Fixes #432 Signed-off-by: copilot <223556219+Copilot@users.noreply.github.com>
mrbobbytables
deleted the
fix/pr-queue-hygiene-marker-clear-pagination
branch
September 25, 2026 17:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two pre-existing defects in
scripts/pr-queue-hygiene.mjsflagged in the review of #240 (issue #427 / #429 follow-up).1. Stale marker never cleared on deconflict
In
main(), when a PR stopped conflicting the loopcontinued without removing the first-conflict marker comment or theneeds-rebase-or-closelabel. If the PR later reconflicted,hoursSince()was computed from the old marker's timestamp, so the PR was flagged as stale (>48h) immediately instead of getting a fresh 48-hour grace window.Fix: when a previously-conflicting PR is observed as no longer conflicting, the job now removes the
needs-rebase-or-closelabel (if present) and posts a trusted "resolved" marker comment.findFirstConflictObservedAt()now ignores any first-conflict marker that predates the latest trusted resolved marker, so a later reconflict starts a fresh 48h window. The resolved marker is subject to the same bot-authorship trust check as the first-conflict marker, so it can't be spoofed by an arbitrary commenter.2. Comment lookup reads a single unpaginated page
The comment lookup called
issues/{n}/comments?per_page=100once. Since issue comments sort ascending, a PR with more than 100 comments could have its marker on an earlier page that was never fetched -- every run would then post a duplicate marker and the 48h gate would never fire.Fix: added
fetchAllIssueComments(), which paginates through every page the same wayfetchAllOpenPRs()already does for PRs, andmain()now uses it instead of a single bounded call.Both changes are covered by new unit tests in
tests/pr-queue-hygiene.test.mjs. Blast radius remains labels/comments only -- the script never closes PRs.Fixes #432
— hive: backend=copilot model=claude-fable-5
🐝 Hive Agent:
contributor| SHA:fa5fa25