Skip to content

feat(ci): 按贡献者可信度给 PR 分级,识别 Bot 与低质提交 - #125

Open
ziozuxi wants to merge 1 commit into
Open-Source-Bazaar:mainfrom
ziozuxi:feat/pr-contributor-trust
Open

ziozuxi wants to merge 1 commit into
Open-Source-Bazaar:mainfrom
ziozuxi:feat/pr-contributor-trust

Conversation

@ziozuxi

@ziozuxi ziozuxi commented Nov 28, 2026

Copy link
Copy Markdown

Checklist(清单):

  • Labels
  • Assignees
  • Reviewers

Closes #89

做了什么

给 PR 加一层「贡献者可信度」分级:PR 打开或更新时,按一组信号打分,打上四档标签之一,并留一条可自动更新的说明评论。

标签 含义 建议
trusted-contributor 0 分,历史干净 正常流程,直接看 diff
first-time-contributor 1–3 分 正常审阅,留意描述是否对得上改动
needs-human-review ≥4 分 人工优先看,重点查 CI 与依赖变更
bot-pr 账号类型为 Bot / *[bot] 按需处理

评分信号:

信号 分值
账号类型为 Bot +5
账号 < 7 天 / < 30 天 +3 / +2
本仓库无已合并 PR 记录 +1
PR 描述 < 80 字符 +2
变更 > 800 行或 > 20 个文件 +2
修改 .github/ 下的配置 +2
修改依赖或锁文件 +1
24 小时内开 ≥ 4 个 PR +2

阈值集中在 contributor-trust.ts 的打分段落,调数字即可,不需要动结构。

为什么这样设计

1. 只分级,不自动关闭。
误杀一个真贡献者的代价,远高于多看一个低质 PR。社区真正的痛点是「维护者要在噪音里找人」,不是「bot 的 PR 必须消失」,所以这套只做分流,不做执法。

2. 评论幂等。
同一 PR 反复 push 只更新同一条评论(靠 HTML 注释标记定位),不会刷屏;concurrency 也按 PR 号分组,多次触发只跑最后一次。

3. 安全:pull_request_target 但不 checkout PR 代码。
只 checkout 默认分支,全程通过 GitHub API 读元数据,permissions 只给 contents: read + issues / pull-requests: write。这是这类工作流最容易出事的地方——一旦在 pull_request_target 下 checkout 了 head,等于把仓库 secrets 交给任意 PR。

4. 跟随仓库现有惯例。
脚本用 Deno + TypeScript 放在 .github/scripts/,action 锁到 commit SHA(与 claim-issue-reward.yml 一致),新增标签同时登记到 .github/settings.yml。

自测情况

本地已完成:deno check .github/scripts/contributor-trust.ts 通过;两个 YAML 均可正常解析。

没有在真实 PR 上跑过——我没有这个仓库的写权限。合并前建议先在自己的 fork 上用 workflow_dispatch 指定一个 PR 号跑一次,确认标签与评论符合预期,并验证重跑不会重复评论。

后续可以再做

  • isBotUser() 与 share-reward.ts 里的同名函数重复,可抽成 .github/scripts/bot.ts 共用(本次没有改动奖励链路,避免影响结算)
  • 目前不区分「agent 辅助但由人提交」和「纯 agent 刷量」,两者都落在 first-time-contributor。要区分只能读 commit 里的 Co-authored-by 或 PR 模板自述,属于另一个话题

- 新增 pr-contributor-trust 工作流与 .github/scripts/contributor-trust.ts
- 四档标签:trusted-contributor / first-time-contributor / needs-human-review / bot-pr
- 只分级不自动关闭;评论幂等;pull_request_target 下不 checkout PR 代码
- settings.yml 同步登记新增标签
@coderabbitai

coderabbitai Bot commented Nov 28, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized key: "code_generation" at "reviews"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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.

[Reward] Bot Killer

1 participant