Skip to content

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

TypeScript

fix(ci): skip fork spec-owner review reconciliation (#5799)

Cindy Zhangba1aebe8e666
diff --git a/.github/REVIEW_GATE.md b/.github/REVIEW_GATE.md
index 6e98703375..a731475bd3 100644
--- a/.github/REVIEW_GATE.md
+++ b/.github/REVIEW_GATE.md
@@ -27,9 +27,11 @@ family, design, or system spec waits on `spec-owner-approval` for its exact
current head. `cixzhang` or `imdreamrunner` can approve every record kind.
Current design records and normative design assets may also be approved by any
handle in `.github/DESIGNOWNERS`. Mixed PRs still require `cixzhang` or
-`imdreamrunner` for non-design current records. When an approver is also the
-author, the explicit equivalent is a comment containing
-`/approve-spec <full-head-sha>`; a new commit invalidates it.
+`imdreamrunner` for non-design current records. Same-repository owner reviews
+update the exact-head approval automatically. Fork review events cannot write
+with their read-only token, so an approver uses an issue comment containing
+`/approve-spec <full-head-sha>` instead; that command runs from the trusted
+default branch and a new commit invalidates it.
A PR changes only spec records when every changed path is one of:
diff --git a/.github/scripts/spec-owner-reconcile.cjs b/.github/scripts/spec-owner-reconcile.cjs
index e71ec3152f..3ae9fbd8d7 100644
--- a/.github/scripts/spec-owner-reconcile.cjs
+++ b/.github/scripts/spec-owner-reconcile.cjs
@@ -52,6 +52,18 @@ async function reconcileSpecOwnerGate({
workspace = process.env.GITHUB_WORKSPACE,
env = process.env,
}) {
+ const {owner, repo} = context.repo;
+ const repository = `${owner}/${repo}`;
+ if (
+ context.eventName === 'pull_request_review' &&
+ context.payload.pull_request?.head?.repo?.full_name !== repository
+ ) {
+ core.info(
+ 'Skipping fork pull request review; use an exact-head owner command to reconcile.',
+ );
+ return;
+ }
+
const specOwners = env.SPEC_OWNERS.split(',').map(ownerName =>
ownerName.toLowerCase(),
);
@@ -64,8 +76,6 @@ async function reconcileSpecOwnerGate({
return;
}
- const {owner, repo} = context.repo;
- const repository = `${owner}/${repo}`;
const pullNumber = Number(
context.payload.pull_request?.number ??
context.payload.issue?.number ??
diff --git a/.github/scripts/spec-owner-reconcile.test.mjs b/.github/scripts/spec-owner-reconcile.test.mjs
index 06f427e17c..dc03ff1968 100644
--- a/.github/scripts/spec-owner-reconcile.test.mjs
+++ b/.github/scripts/spec-owner-reconcile.test.mjs
@@ -30,6 +30,7 @@ function context({
actor = 'cixzhang',
author = 'cixzhang',
headSha = head,
+ headRepository = repository,
comment,
review,
}) {
@@ -51,7 +52,10 @@ function context({
number: 17,
updated_at: '2026-08-30T10:00:00Z',
user: {login: author},
- head: {sha: headSha},
+ head: {
+ sha: headSha,
+ repo: {full_name: headRepository},
+ },
},
},
};
@@ -78,6 +82,7 @@ function trustedStatus({
function createHarness({
author = 'cixzhang',
+ headRepository = repository,
statuses = [],
comments = [],
reviews = [],
@@ -100,7 +105,7 @@ function createHarness({
number: 17,
node_id: 'PR_node',
user: {login: author},
- head: {sha: head, repo: {full_name: repository}},
+ head: {sha: head, repo: {full_name: headRepository}},
base: {
sha: '2222222222222222222222222222222222222222',
repo: {full_name: repository},
@@ -406,6 +411,92 @@ describe('spec owner workflow reconciliation', () => {
).toBe(true);
});
+ it('skips fork owner reviews before any GitHub API work', async () => {
+ const review = {
+ user: {login: 'cixzhang'},
+ state: 'APPROVED',
+ commit_id: head,
+ submitted_at: '2026-08-30T10:00:00Z',
+ };
+ const messages = [];
+ const github = new Proxy(
+ {},
+ {
+ get() {
+ throw new Error('GitHub API accessed');
+ },
+ },
+ );
+
+ await reconcileSpecOwnerGate({
+ github,
+ context: context({
+ runId: 100n,
+ eventName: 'pull_request_review',
+ action: 'submitted',
+ headRepository: 'contributor/astryx',
+ review,
+ }),
+ core: {info: message => messages.push(message)},
+ workspace,
+ env,
+ });
+
+ expect(messages).toEqual([
+ 'Skipping fork pull request review; use an exact-head owner command to reconcile.',
+ ]);
+ });
+
+ it('reconciles same-repository owner reviews automatically', async () => {
+ const review = {
+ user: {login: 'cixzhang'},
+ state: 'APPROVED',
+ commit_id: head,
+ submitted_at: '2026-08-30T10:00:00Z',
+ };
+ const harness = createHarness({reviews: [review]});
+
+ await run(
+ harness,
+ context({
+ runId: 100n,
+ eventName: 'pull_request_review',
+ action: 'submitted',
+ review,
+ }),
+ );
+
+ expect(harness.state.pullGets).toBeGreaterThan(0);
+ expect(latestGateStatus(harness.state).state).toBe('success');
+ expect(harness.state.calls).toContain('enable-auto-merge');
+ });
+
+ it('reconciles an exact-head owner command for a fork current-spec PR', async () => {
+ const comment = {
+ user: {login: 'cixzhang'},
+ body: `/approve-spec ${head}`,
+ created_at: '2026-08-30T10:00:00Z',
+ };
+ const harness = createHarness({
+ headRepository: 'contributor/astryx',
+ comments: [comment],
+ });
+
+ await run(
+ harness,
+ context({
+ runId: 100n,
+ eventName: 'issue_comment',
+ action: 'created',
+ comment,
+ }),
+ );
+
+ expect(harness.state.pullGets).toBeGreaterThan(0);
+ expect(latestGateStatus(harness.state).state).toBe('success');
+ expect(harness.state.calls).toContain('enable-auto-merge');
+ });
+
it('rejects valid-shaped non-owner commands before API work', async () => {
const harness = createHarness();
const comment = {
diff --git a/.github/scripts/spec-owner-workflow.test.mjs b/.github/scripts/spec-owner-workflow.test.mjs
index 71736df947..48226514f3 100644
--- a/.github/scripts/spec-owner-workflow.test.mjs
+++ b/.github/scripts/spec-owner-workflow.test.mjs
@@ -90,6 +90,21 @@ describe('spec-only workflow contract', () => {
'reconcileSpecOwnerGate({github, context, core})',
);
expect(workflow).not.toContain('concurrency:');
+ const reconcileCondition = workflow
+ .slice(
+ workflow.indexOf(' if: >-', workflow.indexOf(' reconcile:')),
+ workflow.indexOf(' runs-on:', workflow.indexOf(' reconcile:')),
+ )
+ .replace(/^ if: >-\s*/, '')
+ .replace(/\s+/g, ' ')
+ .trim();
+ expect(reconcileCondition).toBe(
+ "(github.event_name != 'pull_request_review' || github.event.pull_request.head.repo.full_name == github.repository) && (github.event_name != 'issue_comment' || (github.event.issue.pull_request != null && (startsWith(github.event.comment.body, '/approve-spec ') || startsWith(github.event.comment.body, '/revoke-spec '))))",
+ );
+ expect(workflow).toContain('pull_request_review:');
+ expect(workflow).toContain('issue_comment:');
+ expect(workflow).toContain('permissions: {}');
+ expect(workflow).not.toContain('pull_request_review_target');
expect(workflow).toContain(
"startsWith(github.event.comment.body, '/approve-spec ')",
);
diff --git a/.github/workflows/spec-owner-gate.yml b/.github/workflows/spec-owner-gate.yml
index b591eb2aa9..8685cd733d 100644
--- a/.github/workflows/spec-owner-gate.yml
+++ b/.github/workflows/spec-owner-gate.yml
@@ -41,12 +41,15 @@ env:
jobs:
reconcile:
- # Keep ordinary PR discussion outside the privileged pull_request_target path.
+ # Fork review events have read-only tokens. Same-repo reviews reconcile
+ # automatically; fork approvals use the trusted issue_comment command path.
if: >-
- github.event_name != 'issue_comment' ||
- (github.event.issue.pull_request != null &&
- (startsWith(github.event.comment.body, '/approve-spec ') ||
- startsWith(github.event.comment.body, '/revoke-spec ')))
+ (github.event_name != 'pull_request_review' ||
+ github.event.pull_request.head.repo.full_name == github.repository) &&
+ (github.event_name != 'issue_comment' ||
+ (github.event.issue.pull_request != null &&
+ (startsWith(github.event.comment.body, '/approve-spec ') ||
+ startsWith(github.event.comment.body, '/revoke-spec '))))
runs-on: ubuntu-slim
permissions:
contents: read