Skip to content

ci: show live PR merge requirements - #427

Merged
SigureMo merged 8 commits into
mainfrom
codex/pr-merge-status
Oct 10, 2026
Merged

SigureMo merged 8 commits into
mainfrom
codex/pr-merge-status

Conversation

@SigureMo

@SigureMo SigureMo commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

What

复用 welcome bot,在原有贡献指南和 CI 指令旁增加一个「🔎 合入条件」<details>。所有折叠标题加 emoji;欢迎语 mention 作者,审批区域的用户名使用反引号包裹。条件表仅展示「审批人数」「团队审批(relax-block-reviewers)」「CI」三类。审批人数的最低要求和仓库 write 或更高权限要求放在右侧状态列;修改意见也并入这一行。指定 Team 尚未审批时列出可联系成员,满足后显示已审批者。CI 仅显示整体是否通过。Approve、Request changes、撤销审批、PR 更新和 CI 状态变化都会原位刷新同一条评论。

Why

Team 审批门禁会阻止合入,但贡献者不容易知道该找谁审批。评论需要根据当前规则和 Team 成员明确展示要求,同时保持欢迎评论简洁。

How

  • 新增通用 Review Signal,监听 pull_request_review 的 submitted、edited、dismissed,权限为空。其他 workflow 可通过 workflow_run 订阅;welcome 同时监听 CI、GPU Unit Tests、Integration Tests 的开始和结束。
  • 按 PR 串行更新评论;fork run 缺少 PR 关联时,同时匹配来源仓库和分支。发布端只执行默认分支代码,使用现有 WELCOME_BOT_TOKEN 并核对账号身份;内容不变时不写入,发布前再次校验 PR head/base。
  • Team、候选成员、审批数量和必需检查来自当前 API。候选人排除 PR 作者,审批只计入 GitHub 标记为有仓库 push 权限的 review。读取 Team 成员需要组织 read:org,或细粒度 token 的 Members read 权限。
  • CI 使用 GraphQL status-check contexts 和 GitHub 的 isRequired(pullRequestNumber) 标记,省去手工比对检查来源;同名检查优先使用 test merge 结果,缺失的必需检查保持等待。非预期 API 错误直接让刷新失败,仅保留未配置 classic branch protection、Team 权限不足的处理。
  • 条件表限定为审批人数、团队审批和 CI;删除最近推送、review 对话与其他规则的逐项展示、专用 API 查询和不再使用的字段。保留 GitHub 整体合入状态。规则和 Team 成员变更会在下一次触发时反映。

API 覆盖范围

分页调用 GET /repos/{owner}/{repo}/rules/branches/{branch} 获取目标分支全部 active rules,包含仓库和组织层级;另查 classic branch protection。接口的范围见 GitHub 文档。

规则读取是全量;评论只逐项展示审批人数、团队审批和 CI。行名称与状态映射由脚本实现,最低人数、write 资格、Team 成员、审批状态和必需检查使用当前 API 数据。其余条件由 GitHub 的整体合入状态体现。

条件式 Team 文件匹配尚未实现完整的逐项判定,团队行显示“GitHub 判定”。

整体状态使用 GraphQL mergeStateStatus,最终合入资格及 bypass 权限以 GitHub 合入区域为准。

Testing

  • Node.js 24 语法检查通过;基于实际 API 快照验证三个条件行、具有 write 权限的审批、Team 成员审批、PR 作者和无 write 权限者的排除,以及修改意见并入审批人数行。
  • pre-commit run --all-files 全部通过;actionlint v1.7.12 校验修改后的 CI workflow 通过。
  • 使用显式 rai-studio-bot gh 凭据,对 ci: show live PR merge requirements #427 调用实际读取/渲染逻辑生成只读预览,并用 GitHub Markdown API 校验折叠块、表格和用户名渲染。

未运行 Python/GPU/NPU 集成测试:本次仅修改 GitHub 自动化,没有训练代码变更。端到端 review 信号和 bot 评论发布需要合入默认分支后验证。

Type of Change

  • New feature
  • CI/CD or build changes

Screenshots / Logs — 预计评论样式

以下由本 PR 的实际模板和渲染逻辑对 #427 生成,快照时间为 2026-10-10T20:28:31+08:00,head 为 d3c8da9。后续审批和 CI 变化会刷新状态。

Thanks for contributing to Relax, @SigureMo! 感谢你为 Relax 做出贡献!

📚 Contribution guide / 贡献指南

Describe the problem, your changes, and how you validated them. Keep each PR focused and run pre-commit run --all-files before submitting.

请说明问题、改动和验证方式,保持 PR 聚焦,并在提交前运行 pre-commit run --all-files。

English contribution guide · 中文贡献指南

🛠️ CI commands / CI 指令
Command / 指令 Usage / 用途
/rerun Retry failed CI / 重跑失败的 CI
/rerun <target> Rerun a workflow or check / 重跑指定 workflow 或检查
/cancel <workflow> Cancel an entire workflow / 取消整个 workflow
/help Show commands and targets / 查看指令和 target
/review Request a code review / 请求代码 review

Put one command on the first line of a new PR comment. Rerun/cancel require PR authorship or repository write access.

在新 PR 评论的首行写一条指令。PR 作者或有仓库写权限的贡献者可以重跑、取消 CI。

CI usage and targets · CI 用法与 target

🔎 Merge requirements / 合入条件

GitHub:⏳ 合入条件未满足

Requirement / 条件 Status / 状态
审批人数 ⏳ 0/1 · 至少 1 位有仓库 write 或更高权限的人 Approve
团队审批(relax-block-reviewers) ⏳ 0/1 · 可联系:Aurelius84, Yangruipis, yuanlehome, NINGBENZHE
CI ⏳ 等待通过

当指定 Team 的有效成员 Approve 后,团队行变为 ✅ 1/1,用反引号显示已审批者,并收起候选人名单。CI 保留一行整体状态。

This PR is co-authored with @codex (GPT-6)

# ⭐ Feature

- Refresh the existing welcome comment with live rules, team reviewers, approvals and required checks.
- Relay all review state changes through an unprivileged Review Signal workflow and publish from trusted default-branch code.
- Resolve fork workflow runs and serialize updates per PR without rewriting identical comments.

# ✅ Tests

- Cover eligible approvals, review dismissal, check sources, fork resolution and comment update behavior with Node.js tests.
- Run the behavior tests in the existing pre-commit CI job and document API visibility limits.

Co-authored-by: Codex <[email protected]>
@SigureMo
SigureMo requested a review from a team October 10, 2026 09:08
@rai-studio-bot

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @SigureMo! 感谢你为 Relax 做出贡献!

Contribution guide / 贡献指南

Describe the problem, your changes, and how you validated them. Keep each PR focused and run pre-commit run --all-files before submitting.

请说明问题、改动和验证方式,保持 PR 聚焦,并在提交前运行 pre-commit run --all-files。

English contribution guide · 中文贡献指南

CI commands / CI 指令
Command / 指令 Usage / 用途
/rerun Retry failed CI / 重跑失败的 CI
/rerun <target> Rerun a workflow or check / 重跑指定 workflow 或检查
/cancel <workflow> Cancel an entire workflow / 取消整个 workflow
/help Show commands and targets / 查看指令和 target
/review Request a code review / 请求代码 review

Put one command on the first line of a new PR comment. Rerun/cancel require PR authorship or repository write access.

在新 PR 评论的首行写一条指令。PR 作者或有仓库写权限的贡献者可以重跑、取消 CI。

CI usage and targets · CI 用法与 target

@rai-studio-bot

rai-studio-bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: 🚧 需要修改

审查版本: d3c8da9

目标分支: main

第六轮审查完成(head d3c8da9):条件表收敛为审批人数、团队审批、CI 三行的删减复核为正确简化,维护文档同步一致,端到端渲染正常,CI 当前无失败。确认并发布 P1(F2):reviewQuery 在同一 GraphQL 查询中请求 mergeStateStatus 与 latestOpinionatedReviews 时后者恒返回空节点(本 PR 与仓库另 5 个 PR 复现,今日 ~12:05 UTC 前同查询尚正常;拆分为两个查询并行请求已验证可恢复),审批人数行在任何有 write 及以上权限用户 Approve 时失真为 0/1。已提交 REQUEST_CHANGES 并附行级评论与已验证的修复方案。

审查阶段进度范围与结果
常规审查 ✅ 已完成 完成:范围判定(8 文件全部接收)与两轮增量复核(d3c8da98 删减为正确简化且文档同步;78bf3806 的 lastPush 逻辑已被本 head 删除,不再适用)。P1 经端到端实测、6 PR 复现与拆分查询验证后发布为 F2(行级评论,含修复草图)。结论:REQUEST_CHANGES(PRR_kwDOSBAwr88AAAABRpKjeg)。
深度审查 ✅ 已完成 未派发子任务:两轮增量均为单模块内改动加文档同步,触发/写入/匹配/中继路径未变;已用真实 API 对渲染与查询路径做端到端实测,前轮必要性审计(中继保留、匹配逻辑、模块拆分、订阅清单、测试删除)在本头复核成立。

审查发现

待处理
编号 严重性 问题状态规则来源
F2 High severity 审批人数行在有 write 用户审批时恒显示 0/1 🚧 未解决 —
已解决或已取代
编号 严重性 问题状态规则来源
F1 Low severity 考虑用 pull_request_review 直接触发欢迎刷新,移除单消费者 Review Signal 中继
精简建议(非阻塞)
➖ 已被后续变更取代 —
提交范围 · 接收 8 · 建议移出 0 · 待确认 0

接收 8 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。

文件结论仓库维护必要性依据替代去向或方案
.github/actions/pr-welcome/action.yml
.github/actions/pr-welcome/comment.md
.github/actions/pr-welcome/index.mjs
.github/actions/pr-welcome/merge-status.mjs
接收 欢迎评论自动化主体:workflow 触发入口、评论模板、PR 定位与写入防护、合入条件快照与渲染。本轮 head 将条件表收敛为审批人数、团队审批、CI 三行,删除最近推送审批/Review 对话等行、activities/compareCommits/reviewThreads 查询与不再使用的字段,并保留 GitHub 整体合入状态;方向与此前审计一致(渲染器不做合入资格判定)。端到端实测渲染正确。 PR 描述:welcome bot 展示实时合入条件;本轮提交说明要求表格仅保留三类并列明删除。 无更简替代:删减本身即是简化;reviewQuery 的数据获取范围仍满足三类行的最小需求(除与 mergeStateStatus 的组合缺陷,另报)。
.github/workflows/pr-welcome.yml
.github/workflows/review-signal.yml
接收 事件触发与中继:pull_request_target 触发、workflow_run 中继(fork 无 secrets 时借 WELCOME_BOT_TOKEN)、并发组与默认分支 checkout,前轮已复核,本轮未改动。 PR 描述需求的事件来源。 无:前轮必要性审计已确认中继为 fork 场景所必需。
.github/workflows/ci.yml
接收 净变更仅为 Pre-commit Checks job 增加 permissions: contents: read 权限加固。 CI 安全惯例;本 PR 早前的测试步骤已随 index.test.mjs 删除。 无:不声明则 job 继承更宽的默认令牌权限。
skills/relax-github-ci/references/maintenance.md
接收 维护文档同步收敛后的表格范围(三类行、不再做 push 历史/commit 比较/review 线程查询、其余条件由整体状态体现),与代码一致。 仓库惯例:skills/relax-github-ci 记录 CI 自动化运维语义。 可并入 workflow 注释,独立 reference 更利于维护者查阅。
精简审查与验证依据
审查范围进度结论
生产代码 ✅ 已完成 逐项检查了信号中继、匹配逻辑、模块拆分与订阅清单;中继的直触发建议在维护者指正(fork PR 无自定义 secrets)后撤回,全部保留。
测试 ✅ 已完成 本轮删除全部 8 个用例与 CI 接线,替换为部署后人工验证;对未变代码的防护用例一并删除属可挽回的覆盖损失,已作为非阻塞提示记录。

生产代码的必要性与替代方案

范围必须保留的契约更简单的方案结论依据与限制
.github/workflows/review-signal.yml 评审事件中继 审批 submitted/edited/dismissed 后刷新欢迎评论;消费者经 workflow_run 订阅。 在 pr-welcome.yml 直接声明 pull_request_review 触发,pullRequestNumbers 增加 pull_request_review 分支,删除中继 workflow。 保留 初判建议用 pull_request_review 直接触发以省去中继,经维护者指正撤回:PR 来自 fork 时,pull_request_review 触发的运行按 GitHub 文档拿不到 GITHUB_TOKEN 之外的 secrets(且 GITHUB_TOKEN 只读),欢迎评论写入需要 WELCOME_BOT_TOKEN;中继后的 workflow_run 运行在 base 仓库上下文、可以使用 secrets,fork PR 才能统一刷新。直接触发仅对同仓库 PR 可行,建议不成立。
pullRequestNumbers 的多重匹配(run.pull_requests、head sha、merge_commit_sha、分支+来源仓库) workflow_run 事件必须定位受影响的开放 PR,包括 fork run 缺少 PR 关联的场景。 仅保留 run.pull_requests 关联匹配。 保留 fork PR 的 workflow_run 载荷 pull_requests 常为空,pull_request 事件的 head_sha 语义存在歧义;代码同时覆盖两种解释与 fork 回退,测试覆盖 fork 定位与 push 事件过滤。收窄匹配会造成评论漏刷新。
merge-status.mjs 独立模块(快照读取与渲染拆分) index.mjs 渲染评论;merge-status.mjs 负责读取与状态渲染,测试直接导入 loadMergeStatus/renderMergeStatus/checkStatus。 合并回 index.mjs。 保留 读取与渲染职责分离且本轮重写后仍各自独立(GraphQL isRequired 读取与行渲染互不依赖);合并不减概念数量,仅增大单文件。
pr-welcome.yml 的 workflows 订阅清单 必需 CI 状态变化需反映到欢迎评论。 无从 API 由必需检查反查来源 workflow,动态订阅不存在。 保留 maintenance.md 已把“新增 CI workflow 时更新 pr-welcome.yml”记录为维护契约;漏配仅导致该 workflow 完成时不刷新评论,属已文档化限制。
merge-status.mjs 的逐项条件行与专用查询(78bf3806 引入、d3c8da98 删除) 条件表覆盖审批人数、团队审批、CI 三类;其余合入条件由 GitHub 整体合入状态体现,不做逐项判定。 保留最近推送审批、Review 对话、Code Owners 等逐项行与 activities/compareCommits/reviewThreads 专用查询(曾在 78bf380 实现并通过实测)。 删除 作者在实现完整判定并实测通过后于 d3c8da9 主动删减,转向最小表格;与本项目"渲染器不做合入资格判定"的既有结论一致,删减后整体状态仍承载其余条件,端到端渲染正确且查询面更小。逐项判定仅在确有维护需求时再恢复。

测试的必要性与替代方案

范围必须保留的契约更简单的方案结论依据与限制
.github/actions/pr-welcome/index.test.mjs(8 个行为用例与 CI 测试步骤一并删除) run() 写入防护(bot 身份不匹配拒绝写入、推送后重新定位评论、内容相同不写入)与 pullRequestNumbers 的 fork run 定位此前有确定性回归覆盖。 保留其中覆盖 index.mjs 未变代码的用例(身份校验、并发推送、无变化不写入、fork 匹配),仅删随重写失效的 merge-status 内部用例。 删除 删除为作者明确取舍:maintenance.md 改为部署默认分支后在草稿 PR 上人工验证。被删用例在上一 head(171573f)8/8 通过,其中覆盖 index.mjs 写入防护与 fork 匹配的部分针对本轮未改动的代码,本可保留;删除后这些路径与新的 ciStatus 逻辑仅剩人工验证,回归问题需部署后才暴露。显示层改动、自愈(下次事件重渲染)且不破坏已有评论,故记为非阻塞。
Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

@chatgpt-codex-connector

This comment was marked as spam.

@rai-studio-bot rai-studio-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.

审查结论:已完成,一条非阻塞精简建议

在 8501a1ad 上完成范围判定与常规审查:9 个文件全部接收(7 个自动化、1 个测试、1 个文档),无延期项。node --test .github/actions/pr-welcome/index.test.mjs 在 Node 24 实测 7/7 通过(与 Pre-commit Checks 中的 CI 接线一致);当前 CI 无失败。审批资格过滤、评论复用与无变化不写入、fork run 定位、bot 身份校验与并发推送防护均有测试覆盖;rulesets 与 classic branch protection 的读取边界处理一致,无法从 API 单独确认的条件均明确标注「GitHub 判定」。未发现阻塞缺陷,一条 P3 精简建议见行内评论;最终合入资格以 GitHub 为准。

看板:#427 (comment)

Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

Comment on lines +3 to +5
on:
pull_request_review:
types: [submitted, edited, dismissed]

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.

Low severity P3 · 考虑用 pull_request_review 直接触发,省去单消费者中继

非阻塞精简建议:目前 Review Signal 的唯一消费者是 Welcome Contributors。每个评审事件经中继会触发 3 个 workflow run(本信号 1 个 + 欢迎 in_progress/completed 各 1 个,共 5 个 job),其中 completed 那次通常重复加载同样的快照且不写入。若在 pr-welcome.yml 直接声明 pull_request_review: types: [submitted, edited, dismissed],同样的刷新行为只需 1 个 run(resolve + welcome 共 2 个 job);pullRequestNumbers 增加一个 pull_request_review 分支(直接取 context.payload.pull_request.number)即可,run.event 白名单里的 pull_request_review 与相应匹配路径也可移除。

若近期确有其他 workflow 计划订阅该信号(maintenance.md 已按信号总线记录该设计),保留现状也合理,以维护者取舍为准。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

笨啊,pull_request_review 能拿到 secrets 么?

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.

确实是我漏掉了这一点,该建议不成立,撤回。PR 来自 fork 时,pull_request_review 触发的运行按文档规则拿不到 GITHUB_TOKEN 之外的 secrets(且 GITHUB_TOKEN 只读):https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows。欢迎评论需要用 WELCOME_BOT_TOKEN 写入,而中继后的 workflow_run 运行在 base 仓库上下文、可以使用 secrets,从而让 fork PR 也能统一刷新。我的建议只对同仓库 PR 成立,无法覆盖外部贡献流程,是我错判了前提。

@SigureMo SigureMo changed the title feat(ci): show live PR merge requirements ci: show live PR merge requirements Oct 10, 2026
# 🐛 Bug Fix

- Fold merge requirements into one details block alongside the guide and CI commands
- Add summary emojis and render usernames as inline code without mentions
- Summarize required CI and omit disabled review options and duplicate merge constraints
- Keep unrecognized active rules visible and document the limits of API-based eligibility

# ✅ Tests

- Verify CI aggregation, unknown rules, disabled requirements and mention-free comments
- Pass eight Node.js 24 behavior tests and all pre-commit checks

Co-authored-by: Codex <[email protected]>

@rai-studio-bot rai-studio-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.

审查结论:通过

增量提交 38ba9859 在已接受范围内重构了合入条件展示:合并状态汇总为「GitHub」一行、必需 CI 汇总为单行状态、用户名改为行内代码避免 @ 通知、未知规则类型保持可见、重复的团队审批条目去重,测试同步更新并新增对应断言;写入路径(评论复用、无变化不写入、身份校验、并发推送防护)与本提交未改动。上一轮的 P3 建议 F1 已按维护者指正撤回(fork PR 的 pull_request_review 运行拿不到自定义 secrets,中继设计保留),review-signal.yml 在本提交中未改动,与该结论一致。Node 24 实测 node --test .github/actions/pr-welcome/index.test.mjs 8/8 通过,当前 CI 无失败,未发现新的阻塞或非阻塞代码问题。

非行级 PR 描述小提示:描述中「预计评论样式」示例仍为重构前的渲染输出(双语行、必检 CI 明细表),可随新渲染更新或注明基于旧快照,避免与实际评论样式不一致。

看板:#427 (comment)

Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

# 🐛 Bug Fix

- Show the contribution guide first, CI commands second and merge requirements last

Co-authored-by: Codex <[email protected]>

@rai-studio-bot rai-studio-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.

审查结论:增量重排已复核,维持通过

在 4331fbab 上完成第三轮增量审查:fix(ci): reorder welcome comment sections 仅将 .github/actions/pr-welcome/comment.md 的合入条件区块移到评论末尾(贡献指南、CI 指令在前),+2/-2,为纯展示层改动;{{mergeStatus}} 占位符与 Agents 注释位置正确,渲染与写入路径对区块顺序无结构依赖。9 个变更文件的范围判定不变(全部接收),无新增发现。

复核证据:Node 24 实测 node --test .github/actions/pr-welcome/index.test.mjs 8/8 通过;当前 CI 无失败;前两轮结论(F1 已按维护者指正撤回、无阻塞问题)在本头仍然成立。最终合入资格以 GitHub 为准。

看板:#427 (comment)

Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

SigureMo and others added 2 commits October 10, 2026 19:13
# 🐛 Bug Fix

- Restore the author mention in the greeting while keeping reviewer names in inline code
- State the minimum approval count and repository write-access requirement
- Remove merge-method guidance and footer links from the merge requirements block
- Document the limits of per-condition status evaluation

Co-authored-by: Codex <[email protected]>
# 🐛 Bug Fix

- Report latest-push approval as pending when no eligible approval exists
- Keep existing approvals unknown until GitHub confirms their push coverage and pusher relationship
- Validate the missing-approval state alongside existing eligibility checks

Co-authored-by: Codex <[email protected]>

@rai-studio-bot rai-studio-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.

审查结论:两个增量提交已复核,维持通过

在 171573f 上完成第四轮增量审查(覆盖被范围变更中断的 5546b53d 与本次 171573f):

  • 5546b53d:问候语改为 @{{author}} 提及作者(评论原位更新、首次创建仅通知一次;测试改为精确断言正文中唯一 mention 为 @author,合入条件内的用户名仍保持行内代码不 ping);审批行标签注明「至少 N 位有仓库 write 或更高权限的人 Approve」,与 authorCanPushToRepository 过滤语义一致;允许合入方式行与页脚链接连同其计算一并移除,无悬挂引用,maintenance.md 已同步该取舍。
  • 171573f:最新推送审批行改为两态——无合格审批时 ⏳ 等待推送者以外的人 Approve(此时必然未满足,状态准确),已有合格审批时保持 ❔ GitHub 判定(审批是否覆盖最近一次可审推送、审批者与推送者关系均无法从 API 单独确认,交由 GitHub 判定是诚实的处理);两种状态均有测试覆盖,maintenance.md 同步。

复核证据:9 个变更文件范围判定不变(全部接收);Node 24 实测 node --test .github/actions/pr-welcome/index.test.mjs 8/8 通过;当前 CI 无失败。前几轮结论(F1 已撤回、无阻塞问题)在本头仍然成立。

一条非阻塞提示:PR 描述与示例评论仍是 10:09 版本,未同步这两个提交的渲染变化(问候语提及、合入方式行与页脚链接已移除、最新推送审批行在无审批时显示 ⏳);仓库内 maintenance.md 已与新行为一致,仅描述文本滞后,不影响合入判断。最终合入资格以 GitHub 为准。

看板:#427 (comment)

Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

# ♻️ Refactor

- Read required CI contexts through GitHub GraphQL isRequired instead of manually matching check apps and commit status sources.
- Share GraphQL connection pagination and remove catch-all API fallbacks.
- Keep explicit handling for absent classic branch protection and inaccessible Team membership.

# 🔩 Chore

- Remove the welcome test file, its CI step and its documented invocation.

Co-authored-by: Codex <[email protected]>
DrRyanHuang
DrRyanHuang previously approved these changes Oct 10, 2026
# 🐛 Bug Fix

- Read the head branch activity actor and timestamp, and include review commit and submission time.
- Show satisfied latest-push approval for a qualified current-head review submitted after a linear code-changing push by a different actor.
- Keep merge-containing and force pushes for GitHub to determine.
- Document the supported approval check and its API evidence.

Co-authored-by: Codex <[email protected]>

@rai-studio-bot rai-studio-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.

审查结论:4522db42 重构复核通过,维持通过

第五轮增量审查覆盖 4522db42(refactor(ci): simplify welcome merge status):

  • 数据源重写:merge-status.mjs 改用 GraphQL statusCheckRollup.contexts + isRequired(pullRequestNumber)——必需检查直接由 GitHub 对该 PR 判定并过滤,替代旧的双 REST 调用与本地名称/app 匹配。实测该字段在真实 API 上存在且标志正确(必需检查为 true、bypass/信号类检查为 false);ciStatus 优先取 test merge commit 上的同名 context,缺失视为 pending,失败优先于通过。classic 分支保护经 classicRules 归一,本仓库无 classic 保护(404 → 空规则)已实测;Team 读取 403/404 显式降级为提示行;其余 API 错误改为刷新失败,属 maintenance.md 已记录的取舍。
  • 端到端实测:以与 action 相同权限档位的真实 token 走通 loadMergeStatus + renderMergeStatus 全链路,当前 PR 输出为 审批 ✅ 1/1(DrRyanHuang)、团队 relax-block-reviewers ⏳ 0/1(含可联系成员)、最近一次推送审批 ❔、CI ✅ 已通过、整体 ⏳ 合入条件未满足——与规则集要求(团队审批 1、dismiss stale reviews、last-push approval)及 mergeStateStatus=BLOCKED 一致,六种规则类型均在处理清单内,无多余 ❔ 行。
  • 周边:ci.yml 净变更为 Pre-commit job 增加 permissions: contents: read 权限加固;maintenance.md 与新语义一致;index.mjs、评论模板与 workflow 本轮未改动。

一条非阻塞提示:本轮删除了 index.test.mjs(8 个在上一 head 全部通过的用例)与对应 CI 步骤。其中覆盖 index.mjs 写入防护(bot 身份不匹配、并发推送后重新定位、内容相同不写入)与 fork 匹配的用例针对的是本轮未改动的代码,删除后这些路径与新的 ciStatus 逻辑不再有自动化回归保护,仅剩部署默认分支后的人工验证(显示层改动、下次事件重渲染自愈,故非阻塞)。如后续改动这些路径,建议恢复防护类用例——它们不依赖本次重写的内部实现。

CI 当前无失败(head 4522db42)。前几轮结论(F1 已被后续变更取代、无阻塞问题)在本头仍成立。最终合入资格以 GitHub 为准。

看板:#427 (comment)

Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

# ♻️ Refactor

- Limit the welcome requirement table to approval count, required Team approvals and CI.
- Put the minimum approval count and write-access requirement in the status column, and label Team approvals explicitly.
- Keep requests for changes in the approval-count row.
- Remove latest-push, review-thread and unused rule rendering logic together with their API queries and fields.
- Update CI maintenance documentation to match the displayed scope.

Validation: pre-commit, Node.js 24 syntax and actual API/GitHub Markdown rendering checks passed.

Co-authored-by: Codex <[email protected]>

@rai-studio-bot rai-studio-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.

需要修改

本轮(head d3c8da9)复核了条件表收敛为审批人数、团队审批、CI 三行的删减:方向正确,维护文档已同步,端到端渲染正常,CI 当前无失败。但存在一个阻塞缺陷:merge-status.mjs 的 reviewQuery 在同一 GraphQL 查询中同时请求 mergeStateStatus 与 latestOpinionatedReviews,在 GitHub 当前服务端行为下后者恒返回空节点,审批人数行会在任何有 write 及以上权限用户 Approve 时失真为 0/1——这恰好是收敛后表格的核心行。修复方案(拆分查询并行请求)已在本 PR 验证有效,详见行级评论。

看板:Nyanpasu 审查看板

Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

const reviewQuery = `query($owner: String!, $repo: String!, $number: Int!, $cursor: String) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
headRefOid baseRefName mergeable mergeStateStatus

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.

High severity P1 · 审批人数行在有 write 用户审批时恒显示 0/1

mergeStateStatus 与 latestOpinionatedReviews 同时出现在一个 GraphQL 查询中时,后者恒返回空节点(GitHub 当前服务端行为)。reviewQuery 同时请求两者,因此 latestOpinionatedReviews.nodes 恒为空,审批人数行在任何有 write 及以上权限用户 Approve 的 PR 上都会显示 ⏳ 0/1,且已审批人列表不会出现;团队审批与 CI 两行不受影响。

复现与证据(均为今日真实 API 实测):

  • 用本模块 reviewQuery 原样查询本 PR 返回 reviews: [];仅删去 mergeStateStatus 的同一查询返回 1 条 APPROVED(rai-studio-bot,authorCanPushToRepository: false)。
  • 同样复现于仓库其余 5 个 PR(426/425/423/407/404);今日 ~12:05 UTC 前同一查询仍正常,属 GitHub 行为变化而非本 PR 数据特例。

建议把状态字段与审批分页拆成两个查询并行请求(已在本 PR 验证可恢复正常输出):

const stateQuery = `query($owner: String!, $repo: String!, $number: Int!) {
  repository(owner: $owner, name: $repo) {
    pullRequest(number: $number) {
      headRefOid baseRefName mergeable mergeStateStatus
      potentialMergeCommit { oid }
    }
  }
}`
const reviewQuery = `query($owner: String!, $repo: String!, $number: Int!, $cursor: String) {
  repository(owner: $owner, name: $repo) {
    pullRequest(number: $number) {
      latestOpinionatedReviews(first: 100, after: $cursor) {
        nodes { author { login } authorCanPushToRepository state }
        pageInfo { hasNextPage endCursor }
      }
    }
  }
}`

const [stateResult, reviewResult] = await Promise.all([
  github.graphql(stateQuery, variables),
  readConnection(
    github,
    reviewQuery,
    variables,
    (data) => data.repository.pullRequest.latestOpinionatedReviews
  ),
])
const state = { ...stateResult.repository.pullRequest, ...reviewResult.data.repository.pullRequest }
const reviews = reviewResult.nodes

state.headRefOid/state.baseRefName 的过期校验(下方 PR changed while collecting reviews.)与 state.potentialMergeCommit 的使用不受拆分影响;mergeStateStatus 仅用于整体状态行文案,可一并迁入 stateQuery。

@SigureMo
SigureMo merged commit 7c4e537 into main Oct 10, 2026
15 checks passed
@SigureMo
SigureMo deleted the codex/pr-merge-status branch October 10, 2026 13:14
Mukayi added a commit to Mukayi/Relax that referenced this pull request Oct 12, 2026
…er-profiler

Brings in upstream/main 653c43c..dce533b (redai-studio#257, redai-studio#258, redai-studio#285, redai-studio#323, redai-studio#330,
redai-studio#335, redai-studio#408, redai-studio#409, redai-studio#412, redai-studio#414, redai-studio#416, redai-studio#417, redai-studio#419-redai-studio#421, redai-studio#424, redai-studio#426, redai-studio#427,
redai-studio#430, and 42 commits synced on 10-12 without PR numbers).

The only conflict is relax/utils/env.py: cc4b052 adds the DeepSeek-V4
MXFP4 QAT variables at the same spot where this branch adds the straggler
profiler variables. Resolved by keeping both blocks, straggler first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants