Skip to content

fix: clear stale pr-queue-hygiene conflict marker and paginate comments - #433

Merged
mrbobbytables merged 1 commit into
mainfrom
fix/pr-queue-hygiene-marker-clear-pagination
Sep 22, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
fix/pr-queue-hygiene-marker-clear-pagination

Conversation

@mrbobbytables

Copy link
Copy Markdown
Member

Fixes two pre-existing defects in scripts/pr-queue-hygiene.mjs flagged 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 loop continued without removing the first-conflict marker comment or the needs-rebase-or-close label. 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-close label (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=100 once. 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 way fetchAllOpenPRs() already does for PRs, and main() 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

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
mrbobbytables added this pull request to the merge queue Sep 22, 2026
Merged via the queue into main with commit 10d1030 Sep 22, 2026
2 checks passed
@mrbobbytables
mrbobbytables deleted the fix/pr-queue-hygiene-marker-clear-pagination branch September 25, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pr-queue-hygiene: stale conflict marker never cleared on deconflict; comment lookup unpaginated

2 participants