Skip to content

feat(reuse): allow /use to pin any run, warn when outside the PR / 复用:允许 /use 固定任意运行,PR 外的运行给出警告 - #4387

Merged
adibarra merged 8 commits into
mainfrom
docs/recover-ingest-runbook-fixes
Oct 21, 2026
Merged

adibarra merged 8 commits into
mainfrom
docs/recover-ingest-runbook-fixes

Conversation

@adibarra

@adibarra adibarra commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Let a pinned /use <run_id> reuse any run-sweep.yml run, including one whose commit is not part of the PR, and warn instead of rejecting.

Behavior

  • reuse.validate_reusable_run drops the PR commit-list check, and its now-unused pr_number parameter. Every other check stays: pull_request event, completed, success (or failure/cancelled when pinned), run-sweep.yml path, result artifacts present, no evals-only/agentx-fast label, authorized author. The same function gates acknowledgement, the PR reuse gate, and merge-ingest.yml, so all three accept the same runs.
  • Bare /reuse-sweep-run still auto-selects only from the PR's own commits.
  • reuse_comment.py still 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.
  • The run's own PR is identified from 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"), and merge-ingest.yml's Source PR row now shows it instead of the merged PR, or unknown.

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 using merge_with_reuse for recovery PRs (it posts its own /reuse-sweep-run that supersedes the pinned source).
  • codeowner-signoff-verify-prompt.md Check 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.md and .github/workflows/README.md describe 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
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 都使用同一个函数,因此三者接受的运行完全一致。
  • 不带运行 ID 的 /reuse-sweep-run 仍只从 PR 自身的提交中自动选择。
  • reuse_comment.py 仍会回应 👍。来源提交不在 PR 内时,会再发布一条中英双语警告评论,注明运行和提交,并通过隐藏标记保证每个请求和运行只发一次,同时输出 ::warning::。警告评论发布失败不会撤销 👍。
  • 运行所属的 PR 优先从 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 打错,恰好指向另一个有效的扫描,现在会被接受,只有警告评论提示。

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。
@adibarra adibarra changed the title docs: fix recover-failed-ingest /use ordering and add learned checks / 修正 recover-failed-ingest 的 /use 顺序并补充经验检查 feat(reuse): allow /use to pin any run, warn when outside the PR / 复用:允许 /use 固定任意运行,PR 外的运行给出警告 Oct 21, 2026
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 外来源警告中的确认提示语。
@adibarra
adibarra marked this pull request as ready for review October 21, 2026 23:39
@adibarra
adibarra requested a review from a team October 21, 2026 23:39
@github-actions

Copy link
Copy Markdown
Contributor

inferencex-e2e/infx diff: +155 -21

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 包的改动有更高的代码质量要求。

@claude

claude Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @adibarra's task in 53s —— View job


LGTM - no blocking issues found

@adibarra
adibarra merged commit 88190bf into main Oct 21, 2026
7 of 8 checks passed
@adibarra
adibarra deleted the docs/recover-ingest-runbook-fixes branch October 21, 2026 23:39

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /use comment is acknowledged (reuse_comment.py:86). The synchronize gate here re-runs resolve_reusable_run, which no longer checks commit membership, and keeps skip_pr_sweep true without flagging anything. Fix: re-check head_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 sets outside_pr to False, so only a 👍 is posted and no warning comment. The author then rebases or force-pushes, and the commit drops out of GET /pulls/<n>/commits. On the synchronize event, reuse.py:295-313 calls resolve_reusable_run. With the commit-list check gone from validate_reusable_run (reuse.py:192-194), the call passes, so skip-pr-sweep=true and 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, but reuse_comment.py runs only on issue_comment, so the warning never fires on this path.

    Verification: On synchronize, the gate at reuse.py:295-313 calls resolve_reusable_run, whose validate_reusable_run no longer raises when run_head_sha not in pr_shas. It returns skip_pr_sweep=authorized (reuse.py:316) with no warning. At merge, reuse.py:401-405 only uses the check to pick source_pr. On the base branch, both paths failed visibly.

Comment on lines 192 to 194
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.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Comment on lines 242 to 247
validate_reusable_run(
repo,
workflow_id,
pr_number,
run,
token,
allow_failed=pinned_run_id is not None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 (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.

Comment on lines +401 to +405
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 (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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant