Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

ci(review-signal): the review gate waits while a spec run decides, and a yield keeps the newer run's link (#9087)

Cindy Zhang2c65e56b7b82
diff --git a/.github/scripts/spec-owner-reconcile.cjs b/.github/scripts/spec-owner-reconcile.cjs
index 4dc3cfd43c..881188618f 100644
--- a/.github/scripts/spec-owner-reconcile.cjs
+++ b/.github/scripts/spec-owner-reconcile.cjs
@@ -470,8 +470,9 @@ async function reconcileSpecOwnerGate({
codeDescription: code.description,
spec,
});
- // The details link names the spec decision run (a newer one on yield).
- const targetUrl = gate.target_url ?? runUrl;
+ // The details link names the spec decision run: a newer one on yield,
+ // whether the gate it restores waits or succeeds.
+ const targetUrl = gate.target_url ?? spec?.url ?? runUrl;
const current = live.find(
status => status.context === REVIEW_GATE_CONTEXT,
);
@@ -595,6 +596,11 @@ async function reconcileSpecOwnerGate({
state: 'pending',
description: `Reconciling exact head ${initialHead.slice(0, 7)}.`,
});
+ // The spec half is unknown until this run decides it, so the review gate
+ // waits meanwhile: a run that fails part-way (after a /revoke-spec, say)
+ // leaves it pending, never an earlier success. Written before the yield
+ // check, like the mirror, so a newer run's decision is restored over it.
+ await publishReviewGate(initialHead, readSpecGate([]));
if (await restoreNewerStatus(initialHead)) return;
const commentAuthor = context.payload.comment?.user?.login?.toLowerCase();
diff --git a/.github/scripts/spec-owner-reconcile.test.mjs b/.github/scripts/spec-owner-reconcile.test.mjs
index 9c6c2e2922..470bc96808 100644
--- a/.github/scripts/spec-owner-reconcile.test.mjs
+++ b/.github/scripts/spec-owner-reconcile.test.mjs
@@ -683,6 +683,76 @@ describe('spec owner workflow reconciliation', () => {
});
});
+ it('keeps the newer run\u2019s link when it yields to a newer success', async () => {
+ const harness = createHarness({
+ statuses: [
+ trustedStatus({
+ runId: 101n,
+ state: 'success',
+ description: 'Mirrors review-required \u00b7 spec ok (@cixzhang)',
+ }),
+ ],
+ });
+
+ await run(harness, context({runId: 100n}));
+
+ expect(latestReviewGate(harness.state)).toMatchObject({
+ state: 'success',
+ target_url: canonicalRunUrl(repository, '101', '1'),
+ });
+ });
+
+ it('restores a newer decision that lands just before the waiting write', async () => {
+ let landed = false;
+ const harness = createHarness({
+ onCreateStatus: (input, state) => {
+ if (landed || input.context !== 'review-required') return;
+ landed = true;
+ // A newer run decides success just before this run's waiting write.
+ state.statuses.unshift(
+ trustedStatus({
+ runId: 101n,
+ state: 'success',
+ description: 'Mirrors review-required \u00b7 spec ok (@cixzhang)',
+ }),
+ );
+ },
+ });
+
+ await run(harness, context({runId: 100n}));
+
+ expect(latestReviewGate(harness.state)).toMatchObject({
+ state: 'success',
+ target_url: canonicalRunUrl(repository, '101', '1'),
+ });
+ });
+
+ it('keeps the review gate waiting when a run fails part-way', async () => {
+ // An approved head: the gate succeeded on the earlier run.
+ const harness = createHarness({
+ statuses: [
+ {
+ sha: head,
+ context: 'review-required',
+ state: 'success',
+ description:
+ '\u2705 Spec approved by @cixzhang \u00b7 No code review required.',
+ creator: {login: 'github-actions[bot]'},
+ },
+ ],
+ });
+ harness.github.rest.pulls.listFiles = async () => {
+ throw new Error('listFiles failed');
+ };
+
+ await expect(run(harness, context({runId: 100n}))).rejects.toThrow();
+
+ expect(latestReviewGate(harness.state)).toMatchObject({
+ state: 'pending',
+ description: '\u23f3 Checking for spec changes\u2026',
+ });
+ });
+
it('leads with code review, and relinks the same text to a newer run', async () => {
const harness = createHarness({
headContent: 'kind: architecture\nauthority: current\n',