Repository navigation
feat(reuse): allow /use to pin any run, warn when outside the PR / 复用:允许 /use 固定任意运行,PR 外的运行给出警告 - #4387
Conversation
Post /use only after pushing the source-ancestry carrier, because the acknowledgement bot rejects a source that is not yet in the PR commit list. Also clarify agentic request accounting, scoped source parity diffs, sign-off-cited run selection, and merging without merge_with_reuse. 中文:修正 recover-failed-ingest 中 /use 的顺序。必须先推送携带来源提交的 carrier 提交再发布 /use,否则确认机器人会因来源提交不在 PR 提交列表中而拒绝。同时补充 AgentX 请求统计的解读、限定文件范围的来源一致性比对、不要直接采用签核引用的运行,以及不使用 merge_with_reuse 直接合并的说明。
A pinned /use <run_id> no longer requires the run's commit to be part of the PR. The acknowledgement bot still reacts 👍, then adds 😕 and a workflow warning when the source commit is outside the PR. Bare /reuse-sweep-run still auto-selects only from the PR's own commits. Drop the now-obsolete source-ancestry carrier from the recovery runbook and update the verifier prompt, CONTRIBUTING, and the workflows README. 中文:/use <run_id> 固定的运行不再要求其提交属于当前 PR。确认机器人仍会回应 👍,若来源提交不在 PR 内,会额外添加 😕 并输出 workflow 警告。不带运行 ID 的 /reuse-sweep-run 仍只从 PR 自身的提交中自动选择。同时从恢复流程中删除已不再需要的来源祖先 carrier 提交步骤,并同步更新签核校验 prompt、CONTRIBUTING 和 workflows README。
Replace the 😕 reaction with a single bilingual warning comment per request and run (deduplicated by a hidden marker). A failed warning post does not undo the 👍. 中文:将 PR 外来源运行的 😕 反应改为一条中英双语警告评论,每个请求和运行只发布一次(通过隐藏标记去重)。警告评论发布失败不会撤销 👍。
…n outside-PR warning 中文:PR 外来源警告评论去掉请求链接,中文部分改用与 PR 正文一致的「中文说明」小节。
中文:将警告评论的中文内容放入可折叠的 details 区块。
中文:PR 外来源警告评论的折叠标题改为仓库规范的「中文」。
Identify the run's PR from run.pull_requests, falling back to the PRs that contain its commit on the run's head branch. The warning comment names it, and merge-ingest's Source PR row now shows the run's PR instead of the merged PR (or 'unknown'). 中文:识别 /use 指定运行所属的 PR:优先使用 run.pull_requests,否则查找包含该提交且分支与运行一致的 PR。警告评论会注明来源 PR,merge-ingest 摘要中的 Source PR 也改为显示运行所属的 PR(无法识别时显示 unknown),不再显示被合并的 PR。
中文:去掉 PR 外来源警告中的确认提示语。
|
Generally most InferenceX submissions don't need to add changes to the infx package. On the off chance they do, generally the diff is small. Please prompt your agent to clean your PR to keep your diff to only necessary & minimal changes too. We have an increased code quality bar for changes to the infx package. 中文大多数 InferenceX 提交通常不需要修改 infx 包。即使确实需要,改动通常也很小。请让你的 agent 清理 PR,使改动只包含必要且最小的内容。infx 包的改动有更高的代码质量要求。 |
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟡
inferencex-e2e/infx/workflows/reuse.py— A pinned run whose commit later leaves the PR through a rebase or force-push is now reused at merge with no rejection and no warning. The warning is only computed when the/usecomment is acknowledged (reuse_comment.py:86). The synchronize gate here re-runsresolve_reusable_run, which no longer checks commit membership, and keepsskip_pr_sweeptrue without flagging anything. Fix: re-checkhead_sha in pr_commit_shas(...)on every revalidation, and emit a::warning::plus step-summary line when it fails. That covers both the synchronize gate here and the merge path at reuse.py:402.Why this was flagged
A maintainer posts
/use <run_id>while the run's commit is still in the PR. reuse_comment.py:86 setsoutside_prto False, so only a 👍 is posted and no warning comment. The author then rebases or force-pushes, and the commit drops out ofGET /pulls/<n>/commits. On thesynchronizeevent, reuse.py:295-313 callsresolve_reusable_run. With the commit-list check gone fromvalidate_reusable_run(reuse.py:192-194), the call passes, soskip-pr-sweep=trueand no new sweep runs. At merge, reuse.py:402-405 sees the commit is outside the PR but only uses that to pick the Source PR label. It emits no warning, and merge-ingest ingests results from code that is no longer in the PR. On the base branch, the gate at synchronize and merge-ingest both raised "is not in PR #N's commit list", so the change failed closed. The PR presents the warning comment as the replacement safeguard, butreuse_comment.pyruns only onissue_comment, so the warning never fires on this path.Verification: On
synchronize, the gate at reuse.py:295-313 callsresolve_reusable_run, whosevalidate_reusable_runno longer raises whenrun_head_sha not in pr_shas. It returnsskip_pr_sweep=authorized(reuse.py:316) with no warning. At merge, reuse.py:401-405 only uses the check to picksource_pr. On the base branch, both paths failed visibly.
| run_head_sha = str(run.get("head_sha") or "") | ||
| if not run_head_sha: | ||
| raise RuntimeError(f"Reusable source run {run_id} has no head_sha.") |
There was a problem hiding this comment.
🔴 A pinned /use <run_id> can now publish results from a fork PR's run, whose workflow file and artifacts the fork author controls. With the PR commit-list check gone, validate_reusable_run never checks which repository the run came from. Fork PRs run their own copy of .github/workflows/run-sweep.yml, so the event, path, conclusion and artifact-name checks all pass. Fix: accept only runs whose head_repository.full_name equals repo, at acknowledge, the PR gate and merge. This matches the same-repo guard in run-sweep.yml check-changelog.
Why this was flagged
The trigger is an OWNER/MEMBER/COLLABORATOR posting /use <run_id> with the ID of a run from a fork PR, through a typo or because someone asked them to. Fork pull_request runs use the fork's workflow definition, so a fork can drop the head.repo.full_name == github.repository guard in run-sweep.yml and upload a results_bmk artifact. That run has event pull_request, path .github/workflows/run-sweep.yml, conclusion success and a reusable artifact name, so validate_reusable_run (reuse.py:166-200) accepts it. resolve_reusable_run (reuse.py:221-222) fetches pinned runs with no repository or PR filter. At merge, merge-ingest.yml sends source-run-id to the production ingest. On the base branch the removed pr_commit_shas check required the run's head SHA to be in the merged PR's reviewed commit list, which ruled out runs from unrelated forks. The only safeguard left is the warning comment, which posts after the 👍 and does not block the merge.
Verification: After this diff, validate_reusable_run (reuse.py:166-200) checks only event, status, conclusion, path and result artifacts, and nothing checks head_repository. A fork can remove run-sweep.yml's guard (lines 44 and 178) and still pass every remaining check. On merge, merge-ingest.yml:97-116 dispatches ingest-results with that run.
| validate_reusable_run( | ||
| repo, | ||
| workflow_id, | ||
| pr_number, | ||
| run, | ||
| token, | ||
| allow_failed=pinned_run_id is not None, |
There was a problem hiding this comment.
🟡 (optional) A pinned run from another PR labeled evals-only or agentx-fast is now accepted and ingested at merge, even though such partial sweeps are meant to be ineligible. The incompatible-label check reads only label_names(pr) of the PR being merged (reuse.py:215). Before this change the source commit had to belong to that PR, so that label check also covered the source run. Fix: when the source run is outside the PR, resolve its PR (run_pr_number) and apply incompatible_labels to that PR too, in resolve_reusable_run, so acknowledgement, the sync gate and merge-ingest all reject it.
Why this was flagged
A maintainer posts /use <run_id> on PR A, pinning a run-sweep.yml run from PR B, which carries evals-only. resolve_reusable_run (reuse.py:215-221) checks incompatible labels only on PR A. validate_reusable_run no longer requires the run's head_sha to be in PR A's commits. has_reusable_result_artifacts accepts eval-only artifacts (reuse.py:196-200). So acknowledgement gives 👍 and merge-ingest ingests B's partial evals-only or agentx-fast results as PR A's sweep. On the base branch the commit-list check (removed at old reuse.py:194-199) tied the source to PR A's own commits, so PR A's label check also covered it, and this run was rejected with 👎. The only new safeguard is the outside-PR warning comment, and it does not mention labels.
Verification: resolve_reusable_run (reuse.py:215) runs the label check only on the target PR. validate_reusable_run (reuse.py:166-200) no longer has the pr_commit_shas membership check that the diff removes. The new run_pr_number lookup at reuse.py:405 only fills in source_pr_number and is never checked against the incompatible labels.
| head_sha = str(run.get("head_sha") or "") | ||
| if head_sha in pr_commit_shas(args.repo, pr_number, token): | ||
| source_pr: int | None = pr_number | ||
| else: | ||
| source_pr = run_pr_number(args.repo, run, token) |
There was a problem hiding this comment.
🟡 (optional) A merge can now fail to ingest because a lookup that only fills the job-summary label fails. That PR's reused results then never get published. At merge time, main() calls run_pr_number when the source commit is outside the PR. That call hits /commits/{sha}/pulls with no error handling, so any API error aborts the "Resolve reused sweep" step. Fix: make the source-PR lookup best-effort on this path. Catch failures from run_pr_number and the extra pr_commit_shas call and fall back to an empty source_pr_number, which the summary step already shows as 'unknown'.
Why this was flagged
The trigger is a push to main whose merged PR has a pinned /use <run_id> pointing at a run outside the PR. merge-ingest.yml runs python3 -m infx.workflows.reuse in the "Resolve reused sweep" step (merge-ingest.yml:42-52). After resolve_reusable_run succeeds, reuse.py:402 calls pr_commit_shas again. reuse.py:405 then calls sweep_runs.run_pr_number, which calls github.api(repo, f"/commits/{head_sha}/pulls", token) (sweep_runs.py:56). Neither call is wrapped in try/except. If gh api errors, the exception escapes main(). The step then fails and no ingest happens. On the base branch these calls did not exist. The value is used only by the cosmetic "Summarize reused source" table (merge-ingest.yml:64-69), which already handles an empty value. The acknowledgement path does isolate its equivalent lookup (warn_outside_pr sits in a try/except in reuse_comment.py), but this merge path does not.
Verification: Trigger: a pinned /use run outside the PR with an empty run.pull_requests, then an API error on /commits/{sha}/pulls. In main() (reuse.py:401-405), run_pr_number calls github.api and nothing catches errors. cli() turns any exception into exit 1. That fails the "Resolve reused sweep" step in merge-ingest.yml:42-52, so the "Trigger database ingest" dispatch never runs.
Let a pinned
/use <run_id>reuse anyrun-sweep.ymlrun, including one whose commit is not part of the PR, and warn instead of rejecting.Behavior
reuse.validate_reusable_rundrops the PR commit-list check, and its now-unusedpr_numberparameter. Every other check stays:pull_requestevent, completed, success (or failure/cancelled when pinned),run-sweep.ymlpath, result artifacts present, noevals-only/agentx-fastlabel, authorized author. The same function gates acknowledgement, the PR reuse gate, andmerge-ingest.yml, so all three accept the same runs./reuse-sweep-runstill auto-selects only from the PR's own commits.reuse_comment.pystill reacts 👍. When the source commit is outside the PR, it then posts one bilingual warning comment naming the run and commit, deduplicated per request and run by a hidden marker, and prints a::warning::. If posting the comment fails, the 👍 stands.run.pull_requests, falling back to the PRs containing its commit on the run's head branch. The warning names it (e.g. "from PR Optimize DSv4 MI355X disaggregated AgentX / 优化 DSv4 MI355X 分离式 AgentX #4186"), andmerge-ingest.yml's Source PR row now shows it instead of the merged PR, orunknown.Docs
recover-failed-ingest.md: the two-parent source-ancestry carrier existed only to satisfy the commit-list rule, so it's removed. The flow is now: append the entry, push,/use, expect 👍 plus the warning comment, merge. It also includes the lessons from the Optimize DSv4 MI355X disaggregated AgentX / 优化 DSv4 MI355X 分离式 AgentX #4186 recovery: agentic request accounting, a scoped parity diff, not trusting the sign-off-cited run, and not usingmerge_with_reusefor recovery PRs (it posts its own/reuse-sweep-runthat supersedes the pinned source).codeowner-signoff-verify-prompt.mdCheck 1 no longer claims merge-time validation enforces "sweep on a commit in this PR". The check itself is unchanged and is now the enforcement point.CONTRIBUTING.mdand.github/workflows/README.mddescribe the new rule and the warning comment.Not changed:
stage-results.yml(also triggered by/use) keeps its own commit-list rule, so staging may still reject an outside run. Reuse and merge are unaffected.Risk: a mistyped run ID that hits another valid sweep is now accepted, flagged only by the warning comment.
Validation details
pytest infx/tests/workflows: 572 passed. 5 tests needtabulate, which my local env lacked. They pass with it and are unrelated.orphanrejection case: an outside run gets 👍 and exactly one warning comment across a redelivery, a failed warning post keeps the 👍, and an in-PR run posts no warning. Suite: 572 passed.resolve_reusable_runon PR fix(signoff): explicit WARN for missing /use reuse command / 签核校验:缺少 /use 复用命令时给出明确警告 #4385 pinned to Optimize DSv4 MI355X disaggregated AgentX / 优化 DSv4 MI355X 分离式 AgentX #4186's run 39588593657 now accepts it, and the outside-PR check reportsTrue.AI model disclosure
Prepared with anthropic/claude-opus-5-5 (Claude Code agent), which wrote the code, tests, and docs. No delegated agents.
中文
允许
/use <run_id>固定任意run-sweep.yml运行,包括提交不属于当前 PR 的运行。遇到这种情况时只给出警告,不再拒绝。行为变化
reuse.validate_reusable_run删除了 PR 提交列表检查,以及因此不再使用的pr_number参数。其余检查全部保留:pull_request事件、已完成、成功(固定运行时也接受 failure/cancelled)、run-sweep.yml路径、存在结果产物、没有evals-only/agentx-fast标签、作者有权限。确认机器人、PR 复用门禁和merge-ingest.yml都使用同一个函数,因此三者接受的运行完全一致。/reuse-sweep-run仍只从 PR 自身的提交中自动选择。reuse_comment.py仍会回应 👍。来源提交不在 PR 内时,会再发布一条中英双语警告评论,注明运行和提交,并通过隐藏标记保证每个请求和运行只发一次,同时输出::warning::。警告评论发布失败不会撤销 👍。run.pull_requests获取,否则查找包含该提交且分支一致的 PR。警告评论会注明来源(例如“来自 PR Optimize DSv4 MI355X disaggregated AgentX / 优化 DSv4 MI355X 分离式 AgentX #4186”),merge-ingest.yml摘要中的 Source PR 也改为显示该 PR,而不是被合并的 PR,无法识别时显示unknown。文档
recover-failed-ingest.md:双父来源祖先 carrier 提交只是为了满足提交列表规则,现已删除。流程改为:追加条目、推送、发布/use、确认 👍 和警告评论、合并。同时加入 Optimize DSv4 MI355X disaggregated AgentX / 优化 DSv4 MI355X 分离式 AgentX #4186 恢复过程中的经验:AgentX 请求统计的解读、限定范围的一致性比对、不要直接采用签核引用的运行,以及恢复 PR 不要使用merge_with_reuse(它会发布自己的/reuse-sweep-run,覆盖固定的来源)。codeowner-signoff-verify-prompt.md的 Check 1 不再声称合并时会强制要求“扫描运行在本 PR 的提交上”。检查本身不变,现在它就是唯一的把关点。CONTRIBUTING.md和.github/workflows/README.md已说明新规则和警告评论。未改动: 同样由
/use触发的stage-results.yml保留自己的提交列表规则,因此 staging 仍可能拒绝 PR 外的运行。复用和合并不受影响。风险: 如果运行 ID 打错,恰好指向另一个有效的扫描,现在会被接受,只有警告评论提示。