Skip to content

Commit 5984498

Browse files
only21milclaude
andcommitted
fix(server): count merge queue removals from the watch's first second
GitHub stamps removedAt to the whole second while the watch start keeps milliseconds, so a removal in the second the watch started was treated as old news, its id recorded, and the watch never woke for it. Compare against the start truncated to the second. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent dd14c98 commit 5984498

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/pullRequestWatch.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,16 @@ describe("evaluatePullRequestWatch", () => {
387387
assert.deepEqual(evaluatePullRequestWatch(watching, before, noRemarks).changes, []);
388388
});
389389

390+
it("reports a merge queue removal stamped in the second the watch started", () => {
391+
const watching = watch({ startedAt: "2026-10-02T12:00:00.500Z" });
392+
const dropped = detail({
393+
mergeQueueRemoval: { id: "first", removedAt: "2026-10-02T12:00:00Z", reason: "CI failed" },
394+
});
395+
assert.deepEqual(evaluatePullRequestWatch(watching, dropped, noRemarks).changes, [
396+
{ kind: "merge-queue-removed", reason: "CI failed" },
397+
]);
398+
});
399+
390400
it("does not spend the comment wake limit on check results", () => {
391401
const tired = watch({ headSha: "aaaaaaaaaa", wakes: PULL_REQUEST_WATCH_WAKE_LIMIT - 1 });
392402
const result = evaluatePullRequestWatch(

‎apps/server/src/orchestration-v2/pullRequestWatch.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ export function evaluatePullRequestWatch(
145145
detail.mergeability === "unknown" ? watch.conflicting : detail.mergeability === "conflicting";
146146

147147
// The queue's checks run on a commit of its own, so its head can stay green after the queue
148-
// drops it. A removal from before the watch started is old news.
148+
// drops it. A removal from before the watch started is old news. Hosts stamp removals to the
149+
// second, so one in the watch's first second still counts.
149150
const removal = detail.mergeQueueRemoval;
150151
if (
151152
removal !== undefined &&
152153
removal.id !== watch.mergeQueueRemovalId &&
153-
Date.parse(removal.removedAt) >= Date.parse(watch.startedAt)
154+
Date.parse(removal.removedAt) >= Math.floor(Date.parse(watch.startedAt) / 1000) * 1000
154155
) {
155156
changes.push({ kind: "merge-queue-removed", reason: removal.reason });
156157
}

0 commit comments

Comments
 (0)