Skip to content

Commit fb2b478

Browse files
Merge remote-tracking branch 'upstream/main' into HEAD
# Conflicts: # package.json
2 parents 6088f40 + 05d01f3 commit fb2b478

485 files changed

Lines changed: 24575 additions & 9063 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.coderabbit.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ reviews:
7979
Require regression coverage at the lowest valid harness with behavior-focused
8080
assertions, including relevant negative, error, false/unset, and boundary cases.
8181
Check cleanup and deterministic async behavior and prefer shared typed test helpers.
82+
For guards and validators, require tests for both the accept path and the reject path
83+
through every public entry point; a reject-only matrix cannot catch a guard that rejects
84+
good input.
8285
Visible webview changes require a durable Playwright component snapshot; behavior-only
8386
changes do not.
8487
Reject weak assertions on values that could take multiple forms: .toBeDefined() or

‎.github/workflows/cli-release.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,11 @@ jobs:
9696
type: 'module',
9797
dependencies: {
9898
'@inkjs/ui': pkg.dependencies['@inkjs/ui'],
99-
'@trpc/client': pkg.dependencies['@trpc/client'],
10099
'commander': pkg.dependencies.commander,
101100
'fuzzysort': pkg.dependencies.fuzzysort,
102101
'ink': pkg.dependencies.ink,
103102
'p-wait-for': pkg.dependencies['p-wait-for'],
104103
'react': pkg.dependencies.react,
105-
'superjson': pkg.dependencies.superjson,
106104
'zustand': pkg.dependencies.zustand
107105
}
108106
};

‎.github/workflows/code-qa.yml‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ jobs:
7676
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7777
- name: Setup Node.js and pnpm
7878
uses: ./.github/actions/setup-node-pnpm
79+
- name: Verify Knip guardrails
80+
run: pnpm test:knip-policy
7981
- name: Run knip checks
8082
run: pnpm knip
83+
- name: Run production Knip checks
84+
run: pnpm knip:production
8185

8286
compile:
8387
runs-on: ubuntu-latest
@@ -173,10 +177,11 @@ jobs:
173177
- name: Run extension test lanes
174178
if: ${{ !matrix.collect-coverage }}
175179
run: pnpm turbo run test:api test:core test:services test:misc test:tree-sitter --filter="zoo-code" --concurrency=2 --log-order grouped --output-logs new-only
176-
# Runs outside Turbo so changes to .coderabbit.yaml and
177-
# .github/workflows/label-pr-review-state.yml always bust the
178-
# result — those files are outside the src/ package boundary and
179-
# cannot be declared as Turbo inputs.
180+
# Runs outside Turbo so changes to .coderabbit.yaml,
181+
# .github/workflows/label-pr-review-state.yml, and
182+
# .github/workflows/stale.yml always bust the result. Those files
183+
# sit outside the src/ package boundary and cannot be declared as
184+
# Turbo inputs.
180185
- name: Run workflow config tests
181186
run: pnpm --dir src run test:workflow
182187
- name: Verify extension coverage contract
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Label PR review state fork review follow-up
2+
3+
on:
4+
# Fork pull_request_review runs of "Label PR review state" get a read-only
5+
# token and skip their label writes (issue #2046). When such a run
6+
# completes, this privileged follow-up resolves the fork PRs and dispatches
7+
# a workflow_dispatch run of "Label PR review state", which reconciles them
8+
# and writes the computed labels. The follow-up lives in its own workflow
9+
# because GitHub rejects a workflow that lists itself in
10+
# workflow_run.workflows (issue #2086). It takes no artifact input and
11+
# never checks out code, so no untrusted PR code or artifacts are touched.
12+
workflow_run:
13+
workflows: ["Label PR review state"]
14+
types: [completed]
15+
16+
permissions:
17+
# This privileged workflow only reads PR metadata and dispatches the
18+
# reconciliation workflow. All unspecified permissions, including contents,
19+
# are none; no fork code or configuration is checked out or executed.
20+
actions: write
21+
pull-requests: read
22+
23+
# Each completed run gets its own group: one run can resolve several PRs, and
24+
# a shared key would let an unrelated completion supersede queued dispatches.
25+
concurrency:
26+
group: label-pr-review-state-fork-review-followup-${{ github.event.workflow_run.id }}
27+
cancel-in-progress: false
28+
29+
jobs:
30+
dispatch:
31+
name: Zoo Code / dispatch fork review reconciliation
32+
# Loop guard (issue #2046): follow up only on runs triggered by
33+
# pull_request_review. The runs this workflow dispatches have event
34+
# 'workflow_dispatch', so their completion is filtered out here and
35+
# the chain stops after one hop.
36+
if: github.event.workflow_run.event == 'pull_request_review'
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Resolve fork PRs and dispatch reconciliation
40+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
41+
with:
42+
retries: 3
43+
script: |
44+
const { owner, repo } = context.repo;
45+
const run = context.payload.workflow_run;
46+
47+
// Mirrors the job-level `if`: only runs triggered by
48+
// pull_request_review need a follow-up, so the chain
49+
// stops after one hop.
50+
if (run?.event !== 'pull_request_review') {
51+
core.info(`Ignoring workflow_run with event '${run?.event}'`);
52+
return;
53+
}
54+
55+
// GitHub reports the base repository as head_repository on
56+
// every pull_request_review run, fork PR or not (issue
57+
// #2133), so the payload cannot tell fork from same-repo
58+
// runs. Dispatching for a same-repo PR is idempotent: the
59+
// reconciliation writes the same labels, and its completion
60+
// carries event 'workflow_dispatch', which the guard above
61+
// filters out.
62+
//
63+
// Resolve which PRs the completed run targeted. Review runs
64+
// backfill pull_requests empty for fork PRs, and the head
65+
// owner is not recoverable from head_repository, so the
66+
// fallback lists open PRs and matches the exact head branch,
67+
// SHA, and base repository. The workflow_run branch of
68+
// label-pr-review-state.yml keeps an owner-and-branch query
69+
// instead: its runs are CI runs triggered by pull_request,
70+
// whose head_repository is the real fork.
71+
let prNumbers = [];
72+
if (run.pull_requests?.length > 0) {
73+
prNumbers = run.pull_requests.map(pr => pr.number);
74+
} else if (run.head_branch && run.head_sha) {
75+
const candidates = await github.paginate(github.rest.pulls.list, {
76+
owner,
77+
repo,
78+
state: 'open',
79+
per_page: 100,
80+
});
81+
const baseRepository = `${owner}/${repo}`.toLowerCase();
82+
prNumbers = candidates
83+
.filter(pr =>
84+
pr.head?.sha === run.head_sha &&
85+
pr.head?.ref === run.head_branch &&
86+
pr.base?.repo?.full_name?.toLowerCase() === baseRepository
87+
)
88+
.map(pr => pr.number);
89+
core.info(
90+
`Resolved workflow_run ${run.id ?? '(unknown)'} to ` +
91+
`${prNumbers.length} PR(s) by exact head branch, SHA, and base repository`
92+
);
93+
}
94+
95+
// Each dispatch starts a privileged workflow_dispatch run of the
96+
// reconciliation workflow for one PR. Its completion re-triggers
97+
// this workflow, but the loop guard above filters it out.
98+
// A failed dispatch must not skip the PRs after it: collect the
99+
// failures and fail the step once, naming each PR.
100+
const failures = [];
101+
for (const prNumber of prNumbers) {
102+
try {
103+
await github.rest.actions.createWorkflowDispatch({
104+
owner,
105+
repo,
106+
workflow_id: 'label-pr-review-state.yml',
107+
ref: 'main',
108+
inputs: { pull_request_number: String(prNumber) },
109+
});
110+
core.info(`Dispatched label-pr-review-state.yml for PR #${prNumber}`);
111+
} catch (error) {
112+
failures.push(`#${prNumber}: ${error.message}`);
113+
}
114+
}
115+
if (failures.length > 0) {
116+
core.setFailed(`Failed to dispatch ${failures.length} PR(s): ${failures.join('; ')}`);
117+
}

0 commit comments

Comments
 (0)