Skip to content

Commit e29e94b

Browse files
Rhinomcdclaude
andcommitted
fix(server): owed checks stay owed while they run, whatever the gate
When a failed check turned required, the gate shrank to the required checks and an owed advisory check still running was dropped, sending checks-finished early. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 006682a commit e29e94b

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ describe("evaluatePullRequestWatch", () => {
220220
assert.deepEqual(final.changes, [{ kind: "checks-finished", failing: [sonar] }]);
221221
assert.deepEqual(evaluatePullRequestWatch(final.next, done, noRemarks).changes, []);
222222

223+
// An owed check stays owed while it runs, even when the failed one turns required.
224+
const gated = detail({
225+
checks: [{ ...sonar, required: true }, check("unit", "success"), check("e2e", "pending")],
226+
});
227+
const still = evaluatePullRequestWatch(waiting.next, gated, noRemarks);
228+
assert.deepEqual(still.changes, []);
229+
assert.deepEqual(still.next.owedChecks, ["e2e"]);
230+
223231
// A later failure is its own wake and leaves nothing more owed.
224232
const broke = detail({ checks: [sonar, check("unit", "success"), check("e2e", "failure")] });
225233
const failure = evaluatePullRequestWatch(waiting.next, broke, noRemarks);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,13 @@ export function evaluatePullRequestWatch(
8989
} else if (gate.some(isFailedCheck)) {
9090
// Gate checks still running when one failed are owed one wake when they finish, since
9191
// the gate can no longer pass and so never sends the checks-passed wake.
92-
const running = gate.filter((check) => check.status === "pending").map((check) => check.name);
92+
const running = detail.checks
93+
.filter((check) => check.status === "pending")
94+
.map((check) => check.name);
9395
const gateNewlyFailed = newlyFailed.some((check) => gateNames.includes(check.name));
94-
owedChecks = gateNewlyFailed ? running : owedBefore.filter((name) => running.includes(name));
96+
owedChecks = gateNewlyFailed
97+
? running.filter((name) => gateNames.includes(name))
98+
: owedBefore.filter((name) => running.includes(name));
9599
if (newlyFailed.length === 0 && owedBefore.length > 0 && owedChecks.length === 0) {
96100
changes.push({ kind: "checks-finished", failing: gate.filter(isFailedCheck) });
97101
}

0 commit comments

Comments
 (0)