Skip to content

[自动合并 P1-2] 拆除 review-thread-resolved 死锁 + 实测 App enable auto-merge #83

Description

@randypanding

目标

拆除 main-protection ruleset 中 required_review_thread_resolution: true 造成的无人值守死锁,并实测 AG-1(App cloudbrid-agent, id 4632704)的 token 能够成功 enable auto-merge。

背景(源自 #81 §2.1 / §2.2)

"所有 review thread 必须 resolved" 在有人的团队是好规则,在无人值守下是永久 pending 的定时炸弹:CodeQL、任何 review bot、随手一条 comment 只要 unresolved,auto-merge 永远不触发,也没有人去点 resolve。#81 给出三选一,本卡采用推荐项:从 required 条件里去掉(组织本来没有第二个 reviewer),同时在规范层禁止 bot 使用 review comment 通道(机器意见只走 check run annotation / PR comment,不产生 review thread)。

另外,App token 能否 enable auto-merge 历史上有权限坑,contents+PRs:write 通常够,但必须实测而不是假设。

涉及文件

  • governance/rulesets/main-protection.jsonpull_request rule 的 required_review_thread_resolution
  • governance/drift-check.sh(ruleset 对账会自动跟随,无需改)
  • standards/(新增或修订一条:bot 禁止使用 review comment 通道的约定)
  • scripts/gh-app-token.sh(测试用取 token)

执行步骤

  1. main-protection.jsonrequired_review_thread_resolution 改为 false
  2. apply.sh 将 ruleset 应用到 org,确认生效。
  3. 在 standards 中写明:任何自动化(bot/agent)不得创建 review comment / review thread,机器反馈只走 check run annotation 或普通 PR comment。
  4. 实测:用 scripts/gh-app-token.sh 取 AG-1 单仓 token,在测试仓 PR 上执行 gh pr merge --auto --squash

验收标准

  • org ruleset 实际生效值 required_review_thread_resolution == falsegh api orgs/Cloudbird-Software/rulesets 读取对账,drift-check 不红)。
  • 存在 unresolved review thread 的 PR,gate 绿后仍能被 auto-merge 合并。
  • AG-1 App token enable auto-merge 实测成功。

测试方法(预先指定)

T1 死锁复现与消除(核心,端到端)

  1. 在测试仓 Use-up-Plan 用 AG-1 身份开一个 PR(改动随意,如 README 加一行)。
  2. 用人类账号在该 PR 上留一条 review comment(gh api repos/.../pulls/N/comments 或 UI),保持 unresolved。
  3. 等 gate 变绿后执行 gh pr merge --auto --squash
  4. 断言:PR 在无人再触碰的情况下被合并(改 ruleset 前该用例应卡住不合并——可作为对照先跑一次确认死锁真实存在,再改 ruleset 后跑同一用例断言合并成功)。
  5. 合并后清理:删除测试分支。

T2 App token 权限实测(不可省略,#81 明确要求实测而非假设)

  1. source scripts/gh-app-token.sh(按其用法取单仓 token,scope 到测试仓)。
  2. GH_TOKEN=<app-token> gh pr merge --auto --squash <PR号> --repo Cloudbird-Software/Use-up-Plan
  3. 断言:退出码 0,且 gh api repos/Cloudbird-Software/Use-up-Plan/pulls/<N> --jq '.auto_merge != null' 返回 true
  4. 若失败:记录完整错误(权限缺哪项),回报到本 issue 再决定是调 App 权限还是换路径——不允许绕过去假设成功。

T3 对账回归

  • 触发 governance-drift workflow,断言 ruleset 对账段不红(expected ruleset 文本与实际生效一致)。

依赖

  • P1-1(auto-merge 开关已开并对账,否则 T1 无从谈起)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentAgent 运行时相关auto-merge自动合并计划(#81)工作卡rulesetRuleset 配置相关

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions