From 697f209d9aaed1b02b5ed96b4fe3591146881cec Mon Sep 17 00:00:00 2001 From: Aditya-linux Date: Mon, 16 Nov 2026 15:11:27 +0530 Subject: [PATCH] fix(pstack): wait for pending CI reruns --- .../scripts/watch-pr/policy.test.ts | 29 +++++++++++++++++++ .../poteto-mode/scripts/watch-pr/policy.ts | 4 ++- .../scripts/watch-pr/policy.test.ts | 29 +++++++++++++++++++ .../poteto-mode/scripts/watch-pr/policy.ts | 4 ++- 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/harness/pstack/claude-code/skills/poteto-mode/scripts/watch-pr/policy.test.ts b/harness/pstack/claude-code/skills/poteto-mode/scripts/watch-pr/policy.test.ts index 966b753675..d2afd99892 100644 --- a/harness/pstack/claude-code/skills/poteto-mode/scripts/watch-pr/policy.test.ts +++ b/harness/pstack/claude-code/skills/poteto-mode/scripts/watch-pr/policy.test.ts @@ -89,6 +89,35 @@ describe("readiness truth table", () => { blocker: { kind: "failing-checks" }, }); }); + + it("waits while GitHub replaces draft-time failures", async () => { + const reader = fakeReader({ + facts: { mergeStateStatus: "BLOCKED" }, + fastPath: { + kind: "checks", + checks: [failedCheck("Jest"), pendingCheck("Run: Jest")], + }, + commitRollups: [{ oid: "head", state: "PENDING" }], + }); + const snapshot = await readSnapshot({ + reader, + context: context(2), + pendingHistory: "omit", + allowDraft: false, + }); + + expect(snapshot.kind).toBe("open"); + if (snapshot.kind !== "open") throw new Error("expected open snapshot"); + expect(snapshot.ci).toMatchObject({ + kind: "ci-pending", + failed: [], + pending: [{ name: "Run: Jest" }], + }); + expect(classifyPr(snapshot)).toMatchObject({ + kind: "waiting", + pending: [{ name: "Run: Jest" }], + }); + }); }); describe("snapshot query planning", () => { diff --git a/harness/pstack/claude-code/skills/poteto-mode/scripts/watch-pr/policy.ts b/harness/pstack/claude-code/skills/poteto-mode/scripts/watch-pr/policy.ts index 8179f2d8ba..960a053361 100644 --- a/harness/pstack/claude-code/skills/poteto-mode/scripts/watch-pr/policy.ts +++ b/harness/pstack/claude-code/skills/poteto-mode/scripts/watch-pr/policy.ts @@ -96,7 +96,9 @@ export async function readSnapshot(args: { all: checks.checks, hadPreviousPassingCi: merge.hadPreviousPassingCi, }; - if (failed !== null) + if (pending !== null && merge.github.headRollupState === "PENDING") + ci = { ...base, kind: "ci-pending", failed: [], pending }; + else if (failed !== null) ci = { ...base, kind: "ci-failing", diff --git a/pstack/skills/poteto-mode/scripts/watch-pr/policy.test.ts b/pstack/skills/poteto-mode/scripts/watch-pr/policy.test.ts index 966b753675..d2afd99892 100644 --- a/pstack/skills/poteto-mode/scripts/watch-pr/policy.test.ts +++ b/pstack/skills/poteto-mode/scripts/watch-pr/policy.test.ts @@ -89,6 +89,35 @@ describe("readiness truth table", () => { blocker: { kind: "failing-checks" }, }); }); + + it("waits while GitHub replaces draft-time failures", async () => { + const reader = fakeReader({ + facts: { mergeStateStatus: "BLOCKED" }, + fastPath: { + kind: "checks", + checks: [failedCheck("Jest"), pendingCheck("Run: Jest")], + }, + commitRollups: [{ oid: "head", state: "PENDING" }], + }); + const snapshot = await readSnapshot({ + reader, + context: context(2), + pendingHistory: "omit", + allowDraft: false, + }); + + expect(snapshot.kind).toBe("open"); + if (snapshot.kind !== "open") throw new Error("expected open snapshot"); + expect(snapshot.ci).toMatchObject({ + kind: "ci-pending", + failed: [], + pending: [{ name: "Run: Jest" }], + }); + expect(classifyPr(snapshot)).toMatchObject({ + kind: "waiting", + pending: [{ name: "Run: Jest" }], + }); + }); }); describe("snapshot query planning", () => { diff --git a/pstack/skills/poteto-mode/scripts/watch-pr/policy.ts b/pstack/skills/poteto-mode/scripts/watch-pr/policy.ts index 8179f2d8ba..960a053361 100644 --- a/pstack/skills/poteto-mode/scripts/watch-pr/policy.ts +++ b/pstack/skills/poteto-mode/scripts/watch-pr/policy.ts @@ -96,7 +96,9 @@ export async function readSnapshot(args: { all: checks.checks, hadPreviousPassingCi: merge.hadPreviousPassingCi, }; - if (failed !== null) + if (pending !== null && merge.github.headRollupState === "PENDING") + ci = { ...base, kind: "ci-pending", failed: [], pending }; + else if (failed !== null) ci = { ...base, kind: "ci-failing",