Repository navigation
fix(review): resolve fork pull-request runs in review snapshot - #564
tietoumiao wants to merge 1 commit into
Conversation
A pull_request run from a fork reports no pull_requests link, so the exact head-SHA match was dropped and the PR showed unknown CI. Accept such a run only when its head repository and head branch match the PR head, keep runs linked to another PR out, and expose GitHub mergeable/mergeStateStatus as githubMerge so merge evidence does not need local commit objects.
Haoming9527
left a comment
There was a problem hiding this comment.
The fork-run association work addresses the same #495 path as #538, which is already included in the reviewed integration #557. Please compare the two alternatives before merging both.
One correctness issue remains in the merge-evidence fallback: GitHub's mergeable describes the PR's actual base, while this command accepts a different requested --base. The new partial-status condition treats any known GitHub mergeability as sufficient, without requiring the two base identities to match.
Reproduced against head 566b6d15 with an injected API runner: requested main SHA 111…, PR base release SHA 444…, GitHub MERGEABLE/CLEAN, and no local checkout. This implementation returns status: completed even though its local probe is unknown and no merge evidence covers the requested base. The #538 implementation returns partial and records githubMerge.matchesRequestedBase: false for the same response.
Please carry the GitHub assessment's base ref/SHA and only use it to satisfy the requested-base evidence when both identities match. Add a mismatched-base regression alongside the new fork cases. This finding does not assert that a conflict exists; it prevents reporting an unrelated base's merge assessment as complete evidence.
Nicholas023
left a comment
There was a problem hiding this comment.
审查结论:REQUEST_CHANGES — 建议关闭
fork CI 关联这部分是有效的,但 merge 证据有一个会让审查者误判的缺陷。
1. mergeable 评估的是 PR 的真实 base,而不是请求的 --base(阻断)
用真实 GitHub 数据(issue #495 自己的复现对象 PR #487):
text $ node bin/dsh-ops.mjs review snapshot --repo T-Auto/dsh-ops --prs 487 --base main "status":"completed" "prBaseRef":"master" ← PR 实际基于 master "githubMerge":{"mergeable":false,"state":"DIRTY"} ← 这是对 master 的评估 "merge":{"status":"unknown","reason":"No --checkout supplied; no local merge probe."}
请求的是 main 的证据,拿到的是 master 的合并评估,却报 completed,而 githubMerge 里没有任何 base 身份字段可供核对。
根因在 partial 判定:
ts || (pr.merge.status === 'unknown' && pr.githubMerge.mergeable === null))
只判断 GitHub 是否「知道」合并状态,从不比较 GitHub 评估的 base 与 --base 是否同一 SHA。#538 的实现返回 partial 并记录 matchesRequestedBase:false。
2. 删除了「用户显式要求本地探针」的 partial 条件
基线在 --checkout 探测失败时返回 partial,本 PR 返回 completed。这是未在 body 中声明的行为变化。
已核实为真的部分
- 0.5.0 基线对该 fork PR 确实报
"ci":{"status":"unknown","reason":"No matching run in the latest 20 results; absence is not a pass."}(问题真实存在) node test/run.mjs review-snapshot→ 6/6 passed- revert-red(只撤
src/review/snapshot.ts)→ 4/6 failed,与声明一致 - 与 #538 的 5 个重叠文件全部冲突
处置建议
关闭。 由 #538 承接。若想保留「空关联时再用 head 仓库+分支佐证」这一更严格守卫,应在 #538 上做小补丁,而不是保留本 PR。
|
Closing — #538 now owns the review-snapshot change and is in |
Closes #495
What was wrong
src/review/snapshot.ts:47-48treated the workflow run'spull_requestsarray as a required joinkey. For a
pull_requestrun triggered from a fork, GitHub returnspull_requests: []on the runobject even though the run, its conclusion and the PR's
mergeablefact all exist. The snapshottherefore reported the fork PR's CI/merge state as
unknown, which is the state reviewers are toldto treat as "evidence missing".
Reproduced with the snapshot fixtures on Windows 11 x64 at main
065cd7f; the fork case was absentfrom
test/review-snapshot.test.mjseven though the suite title claims fork/claim coverage.The change
src/review/snapshot.ts— whenpull_requestsis empty, link the run through the facts the runactually carries (
head_repository+head_branch) and record which association was used(
ci.association: "pull_requests" | "head"). The GraphQL query now also asks formergeable/mergeStateStatusand ships them asgithubMerge, so merge evidence is only "missing" when bothgithubMergeand the local probe are unresolved.test/review-snapshot.test.mjs— fork coverage: a run withpull_requests: []resolves to itsreal state; an
action_requiredfork run surfacesaction_requiredinstead ofunknown; a runthat cannot be corroborated still fails closed to
unknown.docs/review-snapshot.md+docs/审阅快照.md+docs/CHANGELOG.md.Deliberately not done: no change to how the local probe works, and no guessing from
head_branchalone — an unverifiable association still yieldsunknown(fail-closed, never a falsegreen).
Validation
review-snapshot的 fork 三条 + 未验证关联守卫docs/CHANGELOG.md## [Unreleased]:已加(EN+ZH)pull_request事件触发,届时回填CI required的 run URLEnvironment
065cd7fnpm ci --ignore-scripts未验证 / 风险披露
head_repository.full_name/head_branch的存在性取自 issue 的现场(run
40901867835),以及 GraphQL 对headRefName/mergeable/mergeStateStatus的接受度。若某个字段缺失或对不上,结果是
unknown(fail-closed),不会误报绿。CI