From c395a3706af9acae8bcf8acb13c061aebd637070 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Wed, 2 Dec 2026 21:28:16 +0900 Subject: [PATCH 1/2] feat(governance): maintainer domains, tiered merge gate, contributors wall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MAINTAINERS.yml as the single source: responsibility domains (duty/scope/intro, several clickable maintainers per cell joined by ·) with a merge tier per domain - rendered maintainer tables in both READMEs (tools/render_maintainers.py; --check on PRs, bot render PR from main) - merge-gate: /merge squash-merges Tier A (pkgs/tests) after 1 write-user approval + green checks/statuses; refuses every PR touching Tier B (workflows, index.toml, mcpp.toml, schema/governance docs) — those merge by human hands only - CODEOWNERS mirrors the same scopes for required code-owner review - weekly thanks-contributors wall (pinned 1a1fa1f) in PR mode, mirrored into README.zh-CN.md - docs/governance.md + zh: roles, quorum, AI-review-as-status rationale, branch-protection checklist, escalation - Contributing renamed to Maintenance & Contribution (维护与贡献) --- .github/CODEOWNERS | 24 +++ .github/MAINTAINERS.yml | 59 ++++++++ .github/workflows/maintainers.yml | 71 +++++++++ .github/workflows/merge-gate.yml | 46 ++++++ .github/workflows/thanks-contributors.yml | 58 +++++++ CHANGELOG.md | 2 + README.md | 31 +++- README.zh-CN.md | 28 +++- docs/README.md | 1 + docs/governance.md | 121 +++++++++++++++ docs/zh/README.md | 1 + docs/zh/governance.md | 104 +++++++++++++ tools/merge_gate.py | 176 ++++++++++++++++++++++ tools/render_contributors.py | 47 ++++++ tools/render_maintainers.py | 121 +++++++++++++++ 15 files changed, 888 insertions(+), 2 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/MAINTAINERS.yml create mode 100644 .github/workflows/maintainers.yml create mode 100644 .github/workflows/merge-gate.yml create mode 100644 .github/workflows/thanks-contributors.yml create mode 100644 docs/governance.md create mode 100644 docs/zh/governance.md create mode 100755 tools/merge_gate.py create mode 100755 tools/render_contributors.py create mode 100755 tools/render_maintainers.py diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..2f0ae5d3 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,24 @@ +# Required code-owner review — enforced by branch protection +# ("Require review from Code Owners"), not by this file alone. +# +# Scopes mirror .github/MAINTAINERS.yml: domains marked `merge: manual` there +# are the Tier-B paths tools/merge_gate.py refuses to auto-merge; everything +# else is Tier A and may be merged by the gate once its quorum is met. +# +# Bootstrap note: mcpplibs org teams do not exist yet, so every scope points +# at the current infra maintainer. As maintainers claim domains in +# MAINTAINERS.yml, replace these user references with teams +# (@mcppplibs/index-owners, per-domain teams) — four lines, no logic change. + +# Tier B — official infrastructure: manual merge only +/.github/workflows/ @Sunrisepeak +/.github/CODEOWNERS @Sunrisepeak +/.github/MAINTAINERS.yml @Sunrisepeak +/index.toml @Sunrisepeak +/mcpp.toml @Sunrisepeak +/docs/repository-and-schema.md @Sunrisepeak +/docs/governance.md @Sunrisepeak + +# Tier A — third-party packages and tests: auto-merge eligible after review +/pkgs/ @Sunrisepeak +/tests/ @Sunrisepeak diff --git a/.github/MAINTAINERS.yml b/.github/MAINTAINERS.yml new file mode 100644 index 00000000..f21784f7 --- /dev/null +++ b/.github/MAINTAINERS.yml @@ -0,0 +1,59 @@ +# Maintainers and responsibility domains — the single source of truth. +# +# What this file decides: +# - WHO maintains WHAT: each domain lists its maintainers (clickable GitHub +# logins, several per domain), its permission scope (path globs) and a +# one-line introduction. The README "Maintenance & Contribution" tables +# are rendered from here by tools/render_maintainers.py — CI fails a PR +# whose committed render is stale. +# - HOW changes merge: `merge: manual` domains are Tier B — their scope +# globs are the paths tools/merge_gate.py refuses to auto-merge; official +# infrastructure is always merged by a human. Every other domain is +# Tier A — mergeable by the gate once approvals + CI reach the quorum. +# - .github/CODEOWNERS mirrors the same scopes for GitHub's required +# code-owner review; keep the two aligned (branch protection enforces +# CODEOWNERS, this file is the human-readable policy). +# +# Claim a domain: open a PR that adds your login under `maintainers:` (and a +# one-line intro), approved by the domain's current maintainers — new domains +# are created by the infra domain. + +schema: 1 + +domains: + - id: infra + merge: manual + duty: + en: "Specification & CI: workflows, index.toml, mcpp.toml, schema and governance docs" + zh: "规范与 CI:工作流、index.toml、mcpp.toml、schema 与治理文档" + intro: + en: "The contract every client and package depends on. Changes are reviewed and merged by hand; see docs/governance.md for why bots never merge these." + zh: "所有客户端与包共同依赖的契约。变更经人工 review 后合并;bot 不合入这些路径的原因见 docs/zh/governance.md。" + scope: + - ".github/workflows/**" + - ".github/CODEOWNERS" + - ".github/MAINTAINERS.yml" + - "index.toml" + - "mcpp.toml" + - "docs/repository-and-schema.md" + - "docs/governance.md" + + maintainers: + - login: Sunrisepeak + intro: + en: "Initiator of the mcpp / d2learn ecosystem" + zh: "mcpp / d2learn 生态发起人" + + - id: packages + merge: auto + duty: + en: "Package descriptors and consumer tests (compat.*, mwrap, module packages)" + zh: "包描述符与消费测试(compat.*、mwrap、module 包)" + intro: + en: "Open for adoption — claim a package family or directory slice by PR; the gate merges a PR once one maintainer approval plus green CI are in." + zh: "开放认领——认领某个包家族或目录请发 PR;1 个 approve + CI 全绿后门禁即可合入。" + scope: + - "pkgs/**" + - "tests/**" + + maintainers: [] diff --git a/.github/workflows/maintainers.yml b/.github/workflows/maintainers.yml new file mode 100644 index 00000000..933c5d37 --- /dev/null +++ b/.github/workflows/maintainers.yml @@ -0,0 +1,71 @@ +name: maintainers + +# Renders the "Maintenance & Contribution" maintainer tables in both READMEs +# from .github/MAINTAINERS.yml. +# +# - pull_request: fail the PR if the committed render is stale. +# - push to main / manual: render and open a bot PR with the refreshed +# tables. Like every bot artifact, that PR never merges itself — it is a +# Tier B path (see MAINTAINERS.yml) and lands via human merge only. + +on: + pull_request: + paths: + - ".github/MAINTAINERS.yml" + - "README.md" + - "README.zh-CN.md" + - "tools/render_maintainers.py" + push: + branches: [main] + paths: + - ".github/MAINTAINERS.yml" + workflow_dispatch: + +permissions: + contents: write # bot PR branch + pull-requests: write # create the PR + +jobs: + check: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: pip install pyyaml + - run: python tools/render_maintainers.py --check + + render: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: pip install pyyaml + - run: python tools/render_maintainers.py + + - name: Open update PR if the render changed + env: + GH_TOKEN: ${{ github.token }} + run: | + if git diff --quiet; then + echo "render already up to date" + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + BR=maintainers/update + git checkout -B "$BR" + git add README.md README.zh-CN.md + git commit -m "docs: render maintainer tables from MAINTAINERS.yml" + git push -f origin "$BR" + OPEN=$(gh pr list --head "$BR" --state open --json number --jq 'length') + if [ "$OPEN" = "0" ]; then + gh pr create --head "$BR" \ + --title "docs: render maintainer tables from MAINTAINERS.yml" \ + --body $'Auto-generated from .github/MAINTAINERS.yml by the maintainers workflow.\n\n\n\n**Tier B(merge: manual):bot 不会合入,请人工 review 后在 GitHub 上主动合并。**' + fi diff --git a/.github/workflows/merge-gate.yml b/.github/workflows/merge-gate.yml new file mode 100644 index 00000000..1d7dee1b --- /dev/null +++ b/.github/workflows/merge-gate.yml @@ -0,0 +1,46 @@ +name: merge-gate + +# The `/merge` PR comment command: tiered, bot-assisted merging. +# +# Tier A (packages + tests): once one maintainer approval plus green CI are +# in, `/merge` has the gate squash-merge the PR. Tier B (workflows, +# index.toml, mcpp.toml, schema/governance docs — the `merge: manual` scopes +# in MAINTAINERS.yml): the gate refuses; official infrastructure is always +# merged by a human. The tier table lives in .github/MAINTAINERS.yml, the +# logic in tools/merge_gate.py. + +on: + issue_comment: + types: [created] + +permissions: + contents: write # merge via the API + issues: write # reply on the PR + pull-requests: write # read reviews, merge + +concurrency: + group: merge-gate-${{ github.event.issue.number }} + cancel-in-progress: false + +jobs: + gate: + if: >- + github.event.issue.pull_request != null && + github.event.comment.user.type != 'Bot' && + contains(github.event.comment.body, '/merge') + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ github.token }} + MERGE_PR_NUMBER: ${{ github.event.issue.number }} + MERGE_COMMENT_LOGIN: ${{ github.event.comment.user.login }} + MERGE_COMMENT_ID: ${{ github.event.comment.id }} + # Approvals from users with write access, excluding the PR author. + MIN_APPROVALS: '1' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: pip install pyyaml + - name: Evaluate /merge + run: python tools/merge_gate.py diff --git a/.github/workflows/thanks-contributors.yml b/.github/workflows/thanks-contributors.yml new file mode 100644 index 00000000..b5a216fa --- /dev/null +++ b/.github/workflows/thanks-contributors.yml @@ -0,0 +1,58 @@ +name: thanks-contributors + +# Weekly contributors wall for both READMEs. +# +# Sunrisepeak/thanks-contributors is pinned to the reviewed commit and runs in +# PR mode (auto_commit: false): it collects the wall, injects it into +# README.md between the thanks-contributors-flag markers, commits everything +# to the thanks-contributors/update branch and opens/updates its PR. Nothing +# ever lands on main directly. tools/render_contributors.py then mirrors the +# same table into README.zh-CN.md as one more commit on the same branch. + +on: + schedule: + - cron: "0 3 * * 1" # Mondays 03:00 UTC (upstream updater runs 02:17, validate Sundays 06:00) + workflow_dispatch: + +permissions: + contents: write # bot PR branch + pull-requests: write # create/update the PR + +jobs: + wall: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Collect contributors and update README.md + uses: Sunrisepeak/thanks-contributors@1a1fa1ffaeb42a670a13469754687d424a4382b3 + env: + GH_TOKEN: ${{ github.token }} + with: + targets: 'mcpplibs/mcpp-index' + auto_commit: 'false' # PR mode — never pushes main + pr_branch_name: 'thanks-contributors/update' + pr_title: 'chore: update contributors wall' + readme_path: 'README.md' + sort_pinned: 'Sunrisepeak' + exclude_logins: 'github-actions[bot]' + + - name: Mirror wall into README.zh-CN.md + run: python tools/render_contributors.py + + - name: Push the zh render to the same PR + env: + GH_TOKEN: ${{ github.token }} + run: | + if git diff --quiet -- README.zh-CN.md; then + echo "zh wall unchanged" + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add README.zh-CN.md + git commit -m "docs: render zh contributors wall" + git push origin thanks-contributors/update diff --git a/CHANGELOG.md b/CHANGELOG.md index 426775a4..e6a59a05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Added +- **「维护与贡献」章节与分级合入门禁(AI 时代开源自治的探索)。** 维护者表按职责域组织——一格内多名维护者、`·` 分隔、可点击,由 `.github/MAINTAINERS.yml` 单一来源渲染(`tools/render_maintainers.py`,PR CI 用 `--check` 校验新鲜度,main 上由 `maintainers.yml` 开 bot PR 回填);贡献者头像墙由 [thanks-contributors](https://github.com/Sunrisepeak/thanks-contributors)(固定到 reviewed commit `1a1fa1f`)每周以 PR 模式注入双 README(`thanks-contributors.yml` + `tools/render_contributors.py`)。合入分级:三方包与测试(`pkgs/**`、`tests/**`)1 个 approve + CI 全绿即可 auto-merge 或评论 `/merge` 由 `merge-gate.yml`/`tools/merge_gate.py` 合入;官方路径(workflows、`index.toml`、`mcpp.toml`、schema 与治理文档,即 `MAINTAINERS.yml` 中 `merge: manual` 的域)门禁拒绝任何 bot 合入,必须人工在 GitHub 上主动合并。`.github/CODEOWNERS` 把同样的路径映射到 GitHub code-owner review。角色、quorum、stall 升级与 branch protection 检查单见 [docs/governance.md](docs/governance.md)([中文](docs/zh/governance.md))。 - **compat.harfbuzz 14.3.0 的两个开关:`no-unused-api` 与 `no-aat-vertical`(修订 3)。** 与 `no-freetype` 同一种写法:mcpp 给本包的单元定义 `MCPP_FEATURE_NO_UNUSED_API`、`MCPP_FEATURE_NO_AAT_VERTICAL`,生成的 `config.h` 据此定义 HarfBuzz 自己的 `HB_NO_*`。`no-unused-api` 去掉只画字的程序不会调用的 API(缓冲区的序列化、校验与消息,MATH 与 meta 表,整形器不用的布局 API,字形名,样式查询),整形与绘制不变;`no-aat-vertical` 再去掉 Apple 的 AAT 整形(morx、kerx、trak)与竖排,给字体带 OpenType 布局、只横排的程序。默认都关,构建与以前相同。实测(emsdk 6.0.9,`-Oz`,只链接一个整形器调用的 57 个 `hb_*` 函数的程序):wasm 556,891 → 531,727 B(gzip 218,946 → 208,442),两个都开 461,992 B(gzip 187,747)。 - **mcpplibs.cmdline 0.0.6.** 命令补全内建:`app.completion()` 一次调用开启,程序以自己的命令树回答(`__complete`),bash、zsh、 fish、PowerShell 的适配脚本只向程序询问;选项与参数可陈述可选值、文件或目录提示与候选回调,命令可隐藏。测试成员移到 0.0.6, @@ -200,6 +201,7 @@ ### Changed +- **README 的 `Contributing` 章节改为 `Maintenance & Contribution`(中文「维护与贡献」)**,拆出维护者表(MAINTAINERS.yml 渲染)、贡献者头像墙与分级合入策略三块;原贡献指南内容与链接不变,移入 `Contribute`/`贡献` 小节。 - **工作区不再陈述索引,每个成员陈述自己测试所经的索引。** 根 `mcpp.toml` 的 `[indices] compat = { path = "." }` 由位置读取 (2026.10.10.1 弃用,2027.1 移除);149 个成员改为各自写 `compat = { path = "<到检出的相对路径>" }`,与已以其他名字指向检出的 79 个成员同形;57 个 mwrap 成员与 5 个 mtest 示例为避开根的重定向而写的空 `[indices]` 删去。改用 `[workspace.indices]` 不可行: diff --git a/README.md b/README.md index da76f448..bac33204 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,35 @@ mcpp build Use `mcpp self config --mirror CN` to select the CN mirror. The minimum supported mcpp version is recorded in [index.toml](index.toml). -## Contributing +## Maintenance & Contribution + +### Maintainers + + +| Responsibility | Scope | Maintainers | About | Merge tier | +|---|---|---|---|---| +| Specification & CI: workflows, index.toml, mcpp.toml, schema and governance docs | `.github/workflows/**` `.github/CODEOWNERS` `.github/MAINTAINERS.yml` `index.toml` `mcpp.toml` `docs/repository-and-schema.md` `docs/governance.md` | [Sunrisepeak](https://github.com/Sunrisepeak "Initiator of the mcpp / d2learn ecosystem") | The contract every client and package depends on. Changes are reviewed and merged by hand; see docs/governance.md for why bots never merge these. | manual — bots never merge | +| Package descriptors and consumer tests (compat.*, mwrap, module packages) | `pkgs/**` `tests/**` | *(open for adoption)* | Open for adoption — claim a package family or directory slice by PR; the gate merges a PR once one maintainer approval plus green CI are in. | `/merge` after 1 approval + green CI | + + +### Contributors + + + + +### Merge tiers + +- Packages and tests (`pkgs/**`, `tests/**`) — one maintainer approval plus + green CI is enough: enable auto-merge on the PR, or comment `/merge` and the + gate bot squash-merges it. +- Official infrastructure (workflows, `index.toml`, `mcpp.toml`, schema and + governance docs) — the gate bot refuses to merge these; an owner reviews and + merges by hand. + +Roles, responsibility domains and the claiming process live in the +[governance guide](docs/governance.md). + +### Contribute Follow the [package contribution guide](docs/README.md) or the [agent skill](.agents/skills/add-mcpp-index-package/SKILL.md). @@ -31,6 +59,7 @@ for review while preserving existing versions. - [CN mirrors](docs/cn-mirror.md) - [Repository, schema and CI](docs/repository-and-schema.md) - [openkal compatibility](docs/openkal-compat.md) +- [Governance](docs/governance.md) ## License diff --git a/README.zh-CN.md b/README.zh-CN.md index e1543e72..4776bb4f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -18,7 +18,32 @@ mcpp build 使用 `mcpp self config --mirror CN` 切换国内镜像。 最低 mcpp 版本见 [index.toml](index.toml)。 -## 贡献 +## 维护与贡献 + +### 维护者 + + +| 职责 | 权限范围 | 维护者 | 简介 | 合入策略 | +|---|---|---|---|---| +| 规范与 CI:工作流、index.toml、mcpp.toml、schema 与治理文档 | `.github/workflows/**` `.github/CODEOWNERS` `.github/MAINTAINERS.yml` `index.toml` `mcpp.toml` `docs/repository-and-schema.md` `docs/governance.md` | [Sunrisepeak](https://github.com/Sunrisepeak "mcpp / d2learn 生态发起人") | 所有客户端与包共同依赖的契约。变更经人工 review 后合并;bot 不合入这些路径的原因见 docs/zh/governance.md。 | 人工合并(任何 bot 不得合入) | +| 包描述符与消费测试(compat.*、mwrap、module 包) | `pkgs/**` `tests/**` | *(待认领)* | 开放认领——认领某个包家族或目录请发 PR;1 个 approve + CI 全绿后门禁即可合入。 | `/merge`:1 个 approve + CI 全绿后自动合入 | + + +### 贡献者 + + + + +### 合入策略(分级) + +- 三方包与测试(`pkgs/**`、`tests/**`)—— 1 个维护者 approve + CI 全绿即可: + 在 PR 上开启 auto-merge,或评论 `/merge` 由门禁 bot squash 合入。 +- 官方基础设施(workflows、`index.toml`、`mcpp.toml`、schema 与治理文档)—— + 门禁 bot 拒绝合入;由 owner 人工 review 后主动合并。 + +角色、职责域与认领流程见[治理文档](docs/zh/governance.md)。 + +### 贡献 参考[包贡献指南](docs/zh/README.md)或 [agent skill](.agents/skills/add-mcpp-index-package/SKILL.md)。 @@ -31,6 +56,7 @@ mcpp build - [国内镜像](docs/zh/cn-mirror.md) - [仓库、schema 与 CI](docs/zh/repository-and-schema.md) - [openkal 兼容性](docs/zh/openkal-compat.md) +- [治理](docs/zh/governance.md) ## License diff --git a/docs/README.md b/docs/README.md index c19d6dde..16ebd4e7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,6 +15,7 @@ behind each step. | [cn-mirror.md](cn-mirror.md) | The GitCode `mcpp-res` CN mirror loop (`gtc` tooling, closed-loop verification, caveats), including the fallback when you lack write access to `mcpp-res` (plain-string upstream url) | | [repository-and-schema.md](repository-and-schema.md) | Repository layout, descriptor schema cheat-sheet, `validate.yml` CI behavior, reproducing lint locally, case index | | [openkal-compat.md](openkal-compat.md) | What the `openkal` label means, how it is measured, and how a package that fails in an openkal graph is adapted | +| [governance.md](governance.md) | Maintainers and responsibility domains, the tiered merge policy (auto-merge vs human-only paths), branch-protection checklist | > The package field specification (the `mcpp = { … }` extension) is settled by `mcpp xpkg parse` — the very parser CI > uses; for semantics and constraints see [`docs/spec/`](https://github.com/mcpp-community/mcpp/tree/main/docs/spec) diff --git a/docs/governance.md b/docs/governance.md new file mode 100644 index 00000000..b16a0b9a --- /dev/null +++ b/docs/governance.md @@ -0,0 +1,121 @@ +# Governance + +**English** | [简体中文](zh/governance.md) + +How this index is maintained and how changes merge: policy lives in files +(humans and AI agents read the same documents), enforcement lives in branch +protection plus small bots, and the contract stays human-owned. This is a +deliberate experiment in self-governing maintenance for the AI era. + +## Single source of truth + +[`.github/MAINTAINERS.yml`](../.github/MAINTAINERS.yml) decides everything: + +| Field | Meaning | +|---|---| +| `duty` | what the domain is responsible for | +| `scope` | path globs the domain owns (also the Tier-B marker, see below) | +| `intro` | one-line description shown in the README | +| `maintainers` | clickable GitHub logins, several per domain | +| `merge` | `manual` (Tier B) or `auto` (Tier A) | + +It is rendered into the README "Maintainers" tables by +[`tools/render_maintainers.py`](../tools/render_maintainers.py) (PRs fail if +the committed render is stale; pushes to main open a bot PR with the refreshed +tables). `.github/CODEOWNERS` mirrors the same scopes for GitHub's required +code-owner review — branch protection enforces CODEOWNERS, MAINTAINERS.yml is +the human-readable policy behind it. + +**Claim a domain** by opening a PR that adds your login (and a one-line intro) +under `maintainers:`; the PR needs an approval from the domain's current +maintainers. New domains and any change to a `merge` tier are decided by the +infra domain. + +## Roles + +| Role | Who | Powers | +|---|---|---| +| Owner (infra domain) | listed in MAINTAINERS.yml | spec/CI/floor decisions; merges Tier B by hand; stall fallback | +| Domain maintainer | listed per domain | approves/rejects PRs inside the domain scope; claims slices | +| Contributor | anyone | opens PRs; passes the same gates | +| Update bot | `xpkgindex-update` | daily version PRs + aggregate CI status; never merges | +| Wall bot | `thanks-contributors` | weekly contributor-wall PR; never merges | +| Merge gate | `merge-gate.yml` | merges Tier A PRs on `/merge` when the quorum is met; refuses Tier B | + +## Merge tiers + +### Tier A — `merge: auto` (packages and tests) + +A PR whose changed files all live inside `auto` domains (`pkgs/**`, +`tests/**`) merges once its quorum is met: + +1. `MIN_APPROVALS` (currently 1) approvals from users with write access, + excluding the PR author; +2. every check run on the head SHA completed and successful; +3. every commit status successful (this is where the update bot's + `xpkgindex-update/ci` aggregate status enters the gate). + +Two paths, same quorum: + +- **Native auto-merge** — the author enables it; GitHub merges when branch + protection is satisfied. Good for ordinary PRs you watch converge. +- **`/merge`** — a user with write access comments `/merge`; the gate + re-checks approvals, check runs and statuses at run time, then squash-merges + and says who approved. Anything short of the quorum is reported back on the + PR, nothing is merged. + +### Tier B — `merge: manual` (official infrastructure) + +The scopes listed under `manual` domains — `.github/workflows/**`, +`.github/CODEOWNERS`, `.github/MAINTAINERS.yml`, `index.toml`, `mcpp.toml`, +`docs/repository-and-schema.md`, `docs/governance.md`. `/merge` refuses any +PR touching them, no matter how green it is: these files are merged by a +human, in the GitHub UI, on purpose. + +Why humans keep these: they decide what every client can resolve and who may +merge what next. `index.toml`'s floor only moves when a descriptor genuinely +stops being readable (an old client losing the whole index is the failure +mode); the engine pin couples caches and CI budgets — the cost notes in +`validate.yml` are the record. A bad package merge is bounded by the weekly +full regression; a bad policy merge is unbounded. That asymmetry is the whole +tiering. + +## Why AI review is a status, not an approval + +GitHub requires a human to be accountable for a PR approval, and machine +approvals do not count toward mergeability. A PR author can never approve +their own PR — which includes the update bot's daily PRs. So automated review +enters the gate the same way the update bot's CI does: as a **commit status +with veto power**. The planned AI reviewer posts `ai-review/approved` or +`ai-review/blocked` on the head SHA; `blocked` stops `/merge`, `approved` +never suffices alone — a human approval is always additionally required. It +reviews the diff and CI facts, not PR prose (prompt-injection surface). + +## Branch-protection checklist (one-time repo settings) + +- Require a pull request before merging: 1 approval; **require review from + Code Owners**; dismiss stale approvals; require approval of the most + recent push. +- Require status checks before merging: `validate`. +- Allow auto-merge; allow GitHub Actions to create and approve pull requests + (the bots' PRs need this); restrict merge methods to squash. + +Branch protection remains the hard floor: every `/merge` is re-validated +against it server-side, and the gate's checks are advisory on top. + +## Escalation + +- A PR stalls with no maintainer response for 72h: anyone may ping the domain + maintainers on the PR. +- Still stalled after 7 days: the infra owner may merge a Tier A PR by hand + with a note, or delegate the domain to a new maintainer (PR against + MAINTAINERS.yml). +- Disputes about policy, tiers or CI: infra domain, human, manual — by design. + +## Security notes + +`/merge` acts only for users with write access (checked per invocation, bots +excluded by the workflow guard). The gate never trusts the comment context +beyond identifying it: it re-reads the PR, its reviews, its checks and the +tier manifest at run time. Every automated merge is a squash commit whose +subject names the PR, so the audit trail is the history itself. diff --git a/docs/zh/README.md b/docs/zh/README.md index 2f2556b4..e7d1d7b1 100644 --- a/docs/zh/README.md +++ b/docs/zh/README.md @@ -12,6 +12,7 @@ | [automatic-updates.md](automatic-updates.md) | 适用条件、声明、每日 bot PR 与候选 CI | | [cn-mirror.md](cn-mirror.md) | GitCode `mcpp-res` CN 镜像闭环(`gtc` 工具、闭环校验、注意事项),含无 `mcpp-res` 写权限时的回退方案(plain-string 上游 url) | | [repository-and-schema.md](repository-and-schema.md) | 仓库布局、描述符 schema 速查、`validate.yml` CI 行为、本地 lint 复现、案例索引 | +| [governance.md](governance.md) | 维护者与职责域、分级合入策略(可自动合入 vs 仅限人工)、branch protection 检查单 | 英文版位于 [`docs/`](../)。 diff --git a/docs/zh/governance.md b/docs/zh/governance.md new file mode 100644 index 00000000..14ccb1f9 --- /dev/null +++ b/docs/zh/governance.md @@ -0,0 +1,104 @@ +# 治理 + +[English](../governance.md) | **简体中文** + +这个索引如何维护、变更如何合入:策略写在文件里(人和 AI agent 读同一份文档), +执行交给 branch protection 与几个小 bot,契约始终由人持有。这是对 AI 时代 +开源自治的一次刻意实验。 + +## 单一事实来源 + +[`.github/MAINTAINERS.yml`](../../.github/MAINTAINERS.yml) 决定一切: + +| 字段 | 含义 | +|---|---| +| `duty` | 该职责域负责什么 | +| `scope` | 域拥有的路径 glob(同时是 Tier B 的判定依据,见下) | +| `intro` | README 里展示的一句话简介 | +| `maintainers` | 可点击的 GitHub login,一格内可多人 | +| `merge` | `manual`(Tier B)或 `auto`(Tier A) | + +它由 [`tools/render_maintainers.py`](../../tools/render_maintainers.py) 渲染成 +README 的「维护者」表格(PR 里提交的渲染过期会让 CI 失败;push 到 main 由 +bot PR 回填表格)。`.github/CODEOWNERS` 把同样的路径映射到 GitHub 的 +code-owner review —— branch protection 强制的是 CODEOWNERS,MAINTAINERS.yml +是其背后人类可读的策略。 + +**认领职责域**:发 PR 在 `maintainers:` 下加你的 login(附一句话简介), +需要该域现有维护者的 approve。新职责域与任何 `merge` 档位的调整由 infra 域决定。 + +## 角色 + +| 角色 | 谁 | 权限 | +|---|---|---| +| Owner(infra 域) | 见 MAINTAINERS.yml | 规范/CI/下限决策;人工合并 Tier B;stall 兜底 | +| 职责域维护者 | 各域下所列 | 在本域范围内 approve/拒绝 PR;认领切片 | +| 贡献者 | 任何人 | 发 PR,通过同样的门禁 | +| 更新 bot | `xpkgindex-update` | 每日版本 PR + 聚合 CI status;永不合并 | +| 头像墙 bot | `thanks-contributors` | 每周贡献者墙 PR;永不合并 | +| 合入门禁 | `merge-gate.yml` | quorum 满足时按 `/merge` 合入 Tier A;拒绝 Tier B | + +## 合入分级 + +### Tier A —— `merge: auto`(包与测试) + +变更文件全部落在 `auto` 域(`pkgs/**`、`tests/**`)的 PR,quorum 满足即可合入: + +1. `MIN_APPROVALS`(当前 1)个来自有写权限用户的 approve,且不计 PR 作者; +2. head SHA 上所有 check run 完成且成功; +3. 所有 commit status 成功(更新 bot 的 `xpkgindex-update/ci` 聚合状态从这里进门)。 + +两条路径,同一 quorum: + +- **原生 auto-merge** —— 作者开启开关,branch protection 满足后 GitHub 自动合入。 + 适合自己盯着的普通 PR。 +- **`/merge`** —— 有写权限的用户在 PR 上评论 `/merge`;门禁在运行时重新核对 + approve、check run 与 status,然后 squash 合入并说明是谁批准的。quorum 不满足 + 时只在 PR 上说明缺什么,什么都不合并。 + +### Tier B —— `merge: manual`(官方基础设施) + +`manual` 域列出的 scope:`.github/workflows/**`、`.github/CODEOWNERS`、 +`.github/MAINTAINERS.yml`、`index.toml`、`mcpp.toml`、 +`docs/repository-and-schema.md`、`docs/governance.md`。`/merge` 对触及它们的 +PR 一律拒绝,无论多绿:这些文件由人工在 GitHub 界面上主动合并。 + +为什么这些留给人:它们决定每个客户端能解析什么、以及之后谁有权限合入什么。 +`index.toml` 的下限只在描述符真的读不动时才移动(旧客户端失去整个索引是必须 +避免的失败模式);引擎 pin 牵动缓存与 CI 预算——`validate.yml` 里的成本注释 +就是记录。一次糟糕的包合入,损害被每周全量回归兜住;一次糟糕的策略合入, +损害没有边界。**这个不对称就是分级的全部理由。** + +## 为什么 AI review 是 status 而不是 approve + +GitHub 要求 PR 的 approve 由人负责,机器账号的 approve 不计入可合并性;PR 作者 +永远不能 approve 自己的 PR——更新 bot 的每日 PR 也一样。所以自动 review 进入 +门禁的方式与更新 bot 的 CI 相同:**一张有否决权的 commit status**。计划中的 +AI reviewer 在 head SHA 上发布 `ai-review/approved` / `ai-review/blocked`; +`blocked` 让 `/merge` 停下,`approved` 单独永远不够——人工 approve 始终另需一票。 +它 review diff 与 CI 事实,不读 PR 描述(prompt injection 的入口面)。 + +## Branch protection 检查单(仓库设置,一次性) + +- Require a pull request before merging:1 个 approve;**Require review from + Code Owners**;dismiss stale approvals;要求对最近一次 push 的 approve。 +- Require status checks:`validate`。 +- 允许 auto-merge;允许 GitHub Actions 创建与 approve PR(bot PR 需要); + 合并方式限定 squash。 + +branch protection 始终是硬底线:每次 `/merge` 都被服务端按它重新校验, +门禁自己的检查是在这之上的建议层。 + +## 升级路径 + +- PR 72 小时无维护者响应:任何人都可在 PR 上 at 该域维护者。 +- 7 天后仍无响应:infra owner 可人工合入该 Tier A PR(附说明),或发 + MAINTAINERS.yml 的 PR 把域委托给新维护者。 +- 策略、档位或 CI 的争议:infra 域、人工、手动合并——这是有意的设计。 + +## 安全说明 + +`/merge` 只对有写权限的用户生效(每次调用都现查,workflow 层已排除 bot)。 +门禁只把评论上下文用于识别自己,不信任其余内容:PR、review、check 与档位 +清单都在运行时现读。每次自动合入都是一个标题带 PR 号的 squash commit, +审计轨迹就是历史本身。 diff --git a/tools/merge_gate.py b/tools/merge_gate.py new file mode 100755 index 00000000..83ea719c --- /dev/null +++ b/tools/merge_gate.py @@ -0,0 +1,176 @@ +#!/usr/bin/env python3 +"""Merge gate behind the `/merge` PR comment — the tiered merge policy. + +Reads .github/MAINTAINERS.yml for the merge tiers: + +- Domains with `merge: manual` list protected path globs. Any PR touching one + of them is refused with an explanatory comment: official infrastructure is + always reviewed and merged by a human, never by a bot. +- Every other PR is Tier A. It is squash-merged once its quorum is met: + MIN_APPROVALS approvals from users with write access (excluding the PR + author), every check run completed and successful, every commit status + (e.g. the xpkgindex-update aggregate) successful. Anything short of the + quorum is reported back on the PR and nothing is merged. + +Branch protection remains the hard floor: the merge call re-validates against +it server-side. Automated review enters the gate as a commit status with veto +power, never as an approval — see docs/governance.md. + +Env: GITHUB_TOKEN, GITHUB_REPOSITORY, MERGE_PR_NUMBER, MERGE_COMMENT_LOGIN, +MERGE_COMMENT_ID, MIN_APPROVALS (default 1). +""" + +from __future__ import annotations + +import fnmatch +import json +import os +import sys +import urllib.request +from pathlib import Path + +import yaml + +API = "https://api.github.com" +TOKEN = os.environ["GITHUB_TOKEN"] +REPO = os.environ["GITHUB_REPOSITORY"] +PR_NUMBER = int(os.environ["MERGE_PR_NUMBER"]) +LOGIN = os.environ["MERGE_COMMENT_LOGIN"] +COMMENT_ID = os.environ["MERGE_COMMENT_ID"] +MIN_APPROVALS = int(os.environ.get("MIN_APPROVALS", "1")) + +WRITE_PERMISSIONS = ("admin", "maintain", "write") +WRITE_ASSOCIATIONS = ("OWNER", "MEMBER", "COLLABORATOR") + + +def api(path: str, method: str = "GET", data: dict | None = None) -> tuple[dict | list, str]: + body = json.dumps(data).encode() if data is not None else None + req = urllib.request.Request( + API + path, + data=body, + method=method, + headers={ + "Authorization": f"Bearer {TOKEN}", + "Accept": "application/vnd.github+json", + "X-GitHub-Api-Version": "2022-11-28", + "User-Agent": "mcpp-index-merge-gate", + }, + ) + with urllib.request.urlopen(req) as response: + raw = response.read().decode() + return (json.loads(raw) if raw else {}), response.headers.get("Link", "") + + +def api_all(path: str) -> list: + items: list = [] + while path: + page, link = api(path) + items.extend(page) + path = "" + for part in link.split(","): + if 'rel="next"' in part: + url = part[part.index("<") + 1:part.index(">")] + path = url[len(API):] + return items + + +def say(body: str) -> None: + api(f"/repos/{REPO}/issues/{PR_NUMBER}/comments", "POST", {"body": body}) + + +def refuse(body: str) -> None: + say("❌ " + body) + + +def main() -> int: + comment, _ = api(f"/repos/{REPO}/issues/comments/{COMMENT_ID}") + if comment["body"].strip() != "/merge": + return 0 # the substring matched the workflow guard, not the exact command + + permission = api(f"/repos/{REPO}/collaborators/{LOGIN}/permission")[0]["permission"] + if permission not in WRITE_PERMISSIONS: + refuse(f"/merge 需要仓库写权限,你当前的权限是 `{permission}`。") + return 0 + + pr, _ = api(f"/repos/{REPO}/pulls/{PR_NUMBER}") + if pr["state"] != "open": + refuse("PR 已关闭,不再合并。") + return 0 + if pr["draft"]: + refuse("PR 处于草稿状态;先标记为 ready for review 再 `/merge`。") + return 0 + + manifest = yaml.safe_load(Path(".github/MAINTAINERS.yml").read_text(encoding="utf-8")) + manual_scopes = [ + scope + for domain in manifest["domains"] + if domain.get("merge") == "manual" + for scope in domain.get("scope") or [] + ] + files = api_all(f"/repos/{REPO}/pulls/{PR_NUMBER}/files?per_page=100") + protected = sorted({ + f["filename"] + for f in files + if any(fnmatch.fnmatch(f["filename"], pattern) for pattern in manual_scopes) + }) + if protected: + refuse( + "此 PR 触及官方管理路径(MAINTAINERS.yml 中 `merge: manual` 的域)。" + "按治理规则任何 bot 不得合入 —— 请 owner 人工 review 后在 GitHub 上主动合并。涉及:\n" + + "\n".join(f"- `{p}`" for p in protected) + ) + return 0 + + sha = pr["head"]["sha"] + runs = api_all(f"/repos/{REPO}/commits/{sha}/check-runs?per_page=100") + pending = [r["name"] for r in runs if r["status"] != "completed"] + failed = [ + r["name"] + for r in runs + if r["status"] == "completed" + and r["conclusion"] not in ("success", "skipped", "neutral") + ] + if pending or failed: + parts = [] + if pending: + parts.append("未完成的 check:" + "、".join(f"`{n}`" for n in pending)) + if failed: + parts.append("未通过的 check:" + "、".join(f"`{n}`" for n in failed)) + refuse("CI 尚未满足 quorum。" + ";".join(parts) + "。") + return 0 + + statuses, _ = api(f"/repos/{REPO}/commits/{sha}/status") + if statuses["total_count"] and statuses["state"] != "success": + refuse(f"commit status 未全部通过:当前 `{statuses['state']}`(含 xpkgindex-update/ci 聚合状态)。") + return 0 + + approvals: set[str] = set() + for review in api_all(f"/repos/{REPO}/pulls/{PR_NUMBER}/reviews?per_page=100"): + login = (review.get("user") or {}).get("login") + if not login or login == pr["user"]["login"]: + continue # the author can never count towards the quorum + if review["state"] == "APPROVED" and review.get("author_association") in WRITE_ASSOCIATIONS: + approvals.add(login) + elif review["state"] in ("CHANGES_REQUESTED", "DISMISSED"): + approvals.discard(login) + if len(approvals) < MIN_APPROVALS: + refuse( + f"approve 数不足:{len(approvals)}/{MIN_APPROVALS}" + f"(需有写权限的维护者 approve,且不计 PR 作者)。" + ) + return 0 + + api( + f"/repos/{REPO}/pulls/{PR_NUMBER}/merge", + "PUT", + {"merge_method": "squash", "commit_title": f"{pr['title']} (#{PR_NUMBER})"}, + ) + say( + f"✅ 已由 `/merge` 门禁合并(squash):approve 来自 " + f"{ '、'.join(sorted(approvals)) },check runs 与 commit status 全绿。" + ) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/render_contributors.py b/tools/render_contributors.py new file mode 100755 index 00000000..ec3680a2 --- /dev/null +++ b/tools/render_contributors.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +"""Mirror the thanks-contributors wall into README.zh-CN.md. + +The pinned Sunrisepeak/thanks-contributors action collects contributors and +injects the wall into README.md between the thanks-contributors-flag markers +(committing it to the bot PR branch in PR mode). This script renders the same + block into the Chinese README so both languages carry the wall, and +the workflow pushes it as one more commit on the same PR branch. +""" + +from __future__ import annotations + +import re +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +SOURCE = ROOT / ".thanks-contributors" / "contributors.md" +TARGET = ROOT / "README.zh-CN.md" +MARK_START = "" +MARK_END = "" + + +def main() -> int: + if not SOURCE.exists(): + print(f"{SOURCE} not found — nothing collected this run; leaving {TARGET.name} untouched") + return 0 + table = re.search(r"
.*
", SOURCE.read_text(encoding="utf-8"), re.S) + if not table: + print(f"{SOURCE}: no wall table found; leaving {TARGET.name} untouched") + return 0 + text = TARGET.read_text(encoding="utf-8") + start = text.find(MARK_START) + end = text.find(MARK_END) + if start == -1 or end == -1 or end < start: + raise SystemExit(f"{TARGET}: thanks-contributors markers missing or misplaced") + new = text[:start + len(MARK_START)] + "\n" + table.group(0) + "\n" + text[end:] + if new != text: + TARGET.write_text(new, encoding="utf-8") + print(f"updated {TARGET.name}") + else: + print(f"{TARGET.name} already current") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/render_maintainers.py b/tools/render_maintainers.py new file mode 100755 index 00000000..a562fbd6 --- /dev/null +++ b/tools/render_maintainers.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 +"""Render the maintainer tables in both READMEs from .github/MAINTAINERS.yml. + +MAINTAINERS.yml is the single source of truth: responsibility domains with +duty, scope globs, introduction, maintainers (clickable logins joined by +" · ") and the merge tier per domain. This script renders one table per +language into the markers below; the maintainers workflow runs it with +--check on PRs (stale render fails CI) and without it on main (opens a bot PR +with the refreshed tables). + + + ... + +""" + +from __future__ import annotations + +import sys +from pathlib import Path + +import yaml + +ROOT = Path(__file__).resolve().parent.parent +MANIFEST = ROOT / ".github" / "MAINTAINERS.yml" +MARK_START = "" +MARK_END = "" +SEPARATOR = " · " + +TEXT = { + "en": { + "readme": "README.md", + "columns": ["Responsibility", "Scope", "Maintainers", "About", "Merge tier"], + "adopt": "*(open for adoption)*", + "tier_manual": "manual — bots never merge", + "tier_auto": "`/merge` after 1 approval + green CI", + }, + "zh": { + "readme": "README.zh-CN.md", + "columns": ["职责", "权限范围", "维护者", "简介", "合入策略"], + "adopt": "*(待认领)*", + "tier_manual": "人工合并(任何 bot 不得合入)", + "tier_auto": "`/merge`:1 个 approve + CI 全绿后自动合入", + }, +} + + +def cell(text: str) -> str: + return text.replace("|", "\\|").replace("\n", " ") + + +def pick(value, lang: str) -> str: + if isinstance(value, dict): + return value.get(lang) or value.get("en") or "" + return value or "" + + +def maintainer_cell(maintainers, lang: str) -> str: + items = [] + for m in maintainers or []: + login = m["login"].strip() + intro = pick(m.get("intro"), lang).replace('"', "'") + url = f"https://github.com/{login}" + items.append(f'[{login}]({url} "{intro}")' if intro else f"[{login}]({url})") + return SEPARATOR.join(items) if items else TEXT[lang]["adopt"] + + +def scope_cell(scope) -> str: + return " ".join(f"`{s}`" for s in scope or []) + + +def table(manifest, lang: str) -> str: + t = TEXT[lang] + lines = [ + "| " + " | ".join(t["columns"]) + " |", + "|" + "---|" * len(t["columns"]), + ] + for domain in manifest["domains"]: + tier = t["tier_manual"] if domain.get("merge") == "manual" else t["tier_auto"] + row = [ + cell(pick(domain.get("duty"), lang)), + cell(scope_cell(domain.get("scope"))), + cell(maintainer_cell(domain.get("maintainers"), lang)), + cell(pick(domain.get("intro"), lang)), + cell(tier), + ] + lines.append("| " + " | ".join(row) + " |") + return "\n".join(lines) + + +def split_markers(path: Path) -> tuple[int, int, str]: + text = path.read_text(encoding="utf-8") + start = text.find(MARK_START) + end = text.find(MARK_END) + if start == -1 or end == -1 or end < start: + raise SystemExit(f"{path}: maintainers markers missing or misplaced") + return start, end, text + + +def main() -> int: + manifest = yaml.safe_load(MANIFEST.read_text(encoding="utf-8")) + check = "--check" in sys.argv[1:] + stale = False + for lang in ("en", "zh"): + t = TEXT[lang] + path = ROOT / t["readme"] + start, end, text = split_markers(path) + rendered = table(manifest, lang) + if text[start + len(MARK_START):end].strip() == rendered.strip(): + continue + if check: + print(f"{path}: committed render is stale (run: python tools/render_maintainers.py)") + stale = True + continue + new = text[:start + len(MARK_START)] + "\n" + rendered + "\n" + text[end:] + path.write_text(new, encoding="utf-8") + print(f"updated {path.name}") + return 1 if stale else 0 + + +if __name__ == "__main__": + sys.exit(main()) From 7f267a0d1194928b2a6173937b898e8d7044b6a2 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Wed, 2 Dec 2026 22:01:55 +0900 Subject: [PATCH 2/2] refactor(governance): maintainer table by GitHub role model (identity/permissions/intro/names) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MAINTAINERS.yml: `roles` (仓库负责人 admin / 核心维护者 maintain / 维护者 Committer write / 活跃贡献者 triage+moderate) replaces duty domains; `tiers.manual` is now a standalone path list - rendered table is 4 columns: identity | GitHub permission | one-line intro | maintainers (clickable, · separated) - merge_gate reads `tiers.manual`; gate behavior unchanged - governance docs: GitHub role mapping, Triage (sort & route) vs Moderate (edit & enforce, GA 2026-10-28) research result --- .github/CODEOWNERS | 8 +-- .github/MAINTAINERS.yml | 110 ++++++++++++++++++------------- .github/workflows/merge-gate.yml | 4 +- CHANGELOG.md | 2 +- README.md | 12 ++-- README.zh-CN.md | 12 ++-- docs/governance.md | 79 ++++++++++++---------- docs/zh/governance.md | 61 +++++++++-------- tools/merge_gate.py | 15 ++--- tools/render_maintainers.py | 40 +++++------ 10 files changed, 187 insertions(+), 156 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2f0ae5d3..1bf705f5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,14 +1,14 @@ # Required code-owner review — enforced by branch protection # ("Require review from Code Owners"), not by this file alone. # -# Scopes mirror .github/MAINTAINERS.yml: domains marked `merge: manual` there +# Scopes mirror the `tiers.manual` paths in .github/MAINTAINERS.yml: those # are the Tier-B paths tools/merge_gate.py refuses to auto-merge; everything # else is Tier A and may be merged by the gate once its quorum is met. # # Bootstrap note: mcpplibs org teams do not exist yet, so every scope points -# at the current infra maintainer. As maintainers claim domains in -# MAINTAINERS.yml, replace these user references with teams -# (@mcppplibs/index-owners, per-domain teams) — four lines, no logic change. +# at the current repository owner. As committers join (roles in +# MAINTAINERS.yml), replace these user references with teams +# (@mcppplibs/index-owners, per-module teams) — four lines, no logic change. # Tier B — official infrastructure: manual merge only /.github/workflows/ @Sunrisepeak diff --git a/.github/MAINTAINERS.yml b/.github/MAINTAINERS.yml index f21784f7..8719095e 100644 --- a/.github/MAINTAINERS.yml +++ b/.github/MAINTAINERS.yml @@ -1,59 +1,77 @@ -# Maintainers and responsibility domains — the single source of truth. +# Maintainers and repository roles — the single source of truth. # -# What this file decides: -# - WHO maintains WHAT: each domain lists its maintainers (clickable GitHub -# logins, several per domain), its permission scope (path globs) and a -# one-line introduction. The README "Maintenance & Contribution" tables -# are rendered from here by tools/render_maintainers.py — CI fails a PR -# whose committed render is stale. -# - HOW changes merge: `merge: manual` domains are Tier B — their scope -# globs are the paths tools/merge_gate.py refuses to auto-merge; official -# infrastructure is always merged by a human. Every other domain is -# Tier A — mergeable by the gate once approvals + CI reach the quorum. -# - .github/CODEOWNERS mirrors the same scopes for GitHub's required -# code-owner review; keep the two aligned (branch protection enforces -# CODEOWNERS, this file is the human-readable policy). +# The README "Maintenance & Contribution" table is rendered from `roles` +# by tools/render_maintainers.py; the maintainers workflow fails PRs whose +# committed render is stale and opens a bot PR from main. # -# Claim a domain: open a PR that adds your login under `maintainers:` (and a -# one-line intro), approved by the domain's current maintainers — new domains -# are created by the infra domain. - -schema: 1 +# `roles` maps our governance identities onto GitHub repository roles — +# the `github` field is what GitHub itself enforces (settings > collabs): +# +# 仓库负责人 admin full access; Tier B merged by hand +# 核心维护者 maintain repo management without sensitive actions +# 维护者 (Committer) write push, approve, /merge — the Tier A gate +# 活跃贡献者 triage, moderate issues/PRs without code access +# +# `tiers` is what tools/merge_gate.py reads: a PR touching any `manual` path +# is refused for automated merge — official infrastructure is merged by a +# human, in the GitHub UI, on purpose. +# +# Claim a seat: open a PR that adds your login under the role's +# `maintainers:` (with a one-line intro); promotion needs an approval from an +# existing member of that role or the repository owner. Role appointments and +# `tiers` changes are decided by the repository owner. -domains: - - id: infra - merge: manual - duty: - en: "Specification & CI: workflows, index.toml, mcpp.toml, schema and governance docs" - zh: "规范与 CI:工作流、index.toml、mcpp.toml、schema 与治理文档" +roles: + - id: owner + identity: + en: Repository owner + zh: 仓库负责人 + github: admin intro: - en: "The contract every client and package depends on. Changes are reviewed and merged by hand; see docs/governance.md for why bots never merge these." - zh: "所有客户端与包共同依赖的契约。变更经人工 review 后合并;bot 不合入这些路径的原因见 docs/zh/governance.md。" - scope: - - ".github/workflows/**" - - ".github/CODEOWNERS" - - ".github/MAINTAINERS.yml" - - "index.toml" - - "mcpp.toml" - - "docs/repository-and-schema.md" - - "docs/governance.md" - + en: "Holds the contract — spec, CI and version-floor decisions; merges official paths by hand" + zh: 契约持有者:规范、CI 与版本下限的最终决策;官方路径人工合并 maintainers: - login: Sunrisepeak intro: en: "Initiator of the mcpp / d2learn ecosystem" zh: "mcpp / d2learn 生态发起人" - - id: packages - merge: auto - duty: - en: "Package descriptors and consumer tests (compat.*, mwrap, module packages)" - zh: "包描述符与消费测试(compat.*、mwrap、module 包)" + - id: core + identity: + en: Core maintainer + zh: 核心维护者 + github: maintain intro: - en: "Open for adoption — claim a package family or directory slice by PR; the gate merges a PR once one maintainer approval plus green CI are in." - zh: "开放认领——认领某个包家族或目录请发 PR;1 个 approve + CI 全绿后门禁即可合入。" - scope: - - "pkgs/**" - - "tests/**" + en: "Day-to-day repo management and CI/release coordination — no sensitive or destructive actions" + zh: 仓库日常管理与 CI/发版协调,无敏感与破坏性操作 + maintainers: [] + - id: committer + identity: + en: Committer + zh: 维护者(Committer) + github: write + intro: + en: "Module owners — package review, approvals and /merge (Tier A)" + zh: 模块负责人:包准入 review、approve 与 `/merge`(Tier A) maintainers: [] + + - id: active + identity: + en: Active contributor + zh: 活跃贡献者 + github: [triage, moderate] + intro: + en: "Issue/PR triage and moderation — no code access" + zh: issue/PR 分流与议题规范化,无代码权限 + maintainers: [] + +tiers: + manual: + - ".github/workflows/**" + - ".github/CODEOWNERS" + - ".github/MAINTAINERS.yml" + - "index.toml" + - "mcpp.toml" + - "docs/repository-and-schema.md" + - "docs/governance.md" diff --git a/.github/workflows/merge-gate.yml b/.github/workflows/merge-gate.yml index 1d7dee1b..3f20527b 100644 --- a/.github/workflows/merge-gate.yml +++ b/.github/workflows/merge-gate.yml @@ -4,8 +4,8 @@ name: merge-gate # # Tier A (packages + tests): once one maintainer approval plus green CI are # in, `/merge` has the gate squash-merge the PR. Tier B (workflows, -# index.toml, mcpp.toml, schema/governance docs — the `merge: manual` scopes -# in MAINTAINERS.yml): the gate refuses; official infrastructure is always +# index.toml, mcpp.toml, schema/governance docs — the `tiers.manual` paths in +# MAINTAINERS.yml): the gate refuses; official infrastructure is always # merged by a human. The tier table lives in .github/MAINTAINERS.yml, the # logic in tools/merge_gate.py. diff --git a/CHANGELOG.md b/CHANGELOG.md index e6a59a05..003764d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ### Added -- **「维护与贡献」章节与分级合入门禁(AI 时代开源自治的探索)。** 维护者表按职责域组织——一格内多名维护者、`·` 分隔、可点击,由 `.github/MAINTAINERS.yml` 单一来源渲染(`tools/render_maintainers.py`,PR CI 用 `--check` 校验新鲜度,main 上由 `maintainers.yml` 开 bot PR 回填);贡献者头像墙由 [thanks-contributors](https://github.com/Sunrisepeak/thanks-contributors)(固定到 reviewed commit `1a1fa1f`)每周以 PR 模式注入双 README(`thanks-contributors.yml` + `tools/render_contributors.py`)。合入分级:三方包与测试(`pkgs/**`、`tests/**`)1 个 approve + CI 全绿即可 auto-merge 或评论 `/merge` 由 `merge-gate.yml`/`tools/merge_gate.py` 合入;官方路径(workflows、`index.toml`、`mcpp.toml`、schema 与治理文档,即 `MAINTAINERS.yml` 中 `merge: manual` 的域)门禁拒绝任何 bot 合入,必须人工在 GitHub 上主动合并。`.github/CODEOWNERS` 把同样的路径映射到 GitHub code-owner review。角色、quorum、stall 升级与 branch protection 检查单见 [docs/governance.md](docs/governance.md)([中文](docs/zh/governance.md))。 +- **「维护与贡献」章节与分级合入门禁(AI 时代开源自治的探索)。** 维护者表按身份与 GitHub 权限模型组织——仓库负责人 `admin` / 核心维护者 `maintain` / 维护者 Committer `write` / 活跃贡献者 `triage, moderate`——一格内多名维护者、`·` 分隔、可点击,由 `.github/MAINTAINERS.yml` 单一来源渲染(`tools/render_maintainers.py`,PR CI 用 `--check` 校验新鲜度,main 上由 `maintainers.yml` 开 bot PR 回填);贡献者头像墙由 [thanks-contributors](https://github.com/Sunrisepeak/thanks-contributors)(固定到 reviewed commit `1a1fa1f`)每周以 PR 模式注入双 README(`thanks-contributors.yml` + `tools/render_contributors.py`)。合入分级:三方包与测试(`pkgs/**`、`tests/**`)1 个 approve + CI 全绿即可 auto-merge 或评论 `/merge` 由 `merge-gate.yml`/`tools/merge_gate.py` 合入;官方路径(workflows、`index.toml`、`mcpp.toml`、schema 与治理文档,即 `MAINTAINERS.yml` 的 `tiers.manual`)门禁拒绝任何 bot 合入,必须人工在 GitHub 上主动合并。`.github/CODEOWNERS` 把同样的路径映射到 GitHub code-owner review。角色、quorum、stall 升级与 branch protection 检查单见 [docs/governance.md](docs/governance.md)([中文](docs/zh/governance.md))。 - **compat.harfbuzz 14.3.0 的两个开关:`no-unused-api` 与 `no-aat-vertical`(修订 3)。** 与 `no-freetype` 同一种写法:mcpp 给本包的单元定义 `MCPP_FEATURE_NO_UNUSED_API`、`MCPP_FEATURE_NO_AAT_VERTICAL`,生成的 `config.h` 据此定义 HarfBuzz 自己的 `HB_NO_*`。`no-unused-api` 去掉只画字的程序不会调用的 API(缓冲区的序列化、校验与消息,MATH 与 meta 表,整形器不用的布局 API,字形名,样式查询),整形与绘制不变;`no-aat-vertical` 再去掉 Apple 的 AAT 整形(morx、kerx、trak)与竖排,给字体带 OpenType 布局、只横排的程序。默认都关,构建与以前相同。实测(emsdk 6.0.9,`-Oz`,只链接一个整形器调用的 57 个 `hb_*` 函数的程序):wasm 556,891 → 531,727 B(gzip 218,946 → 208,442),两个都开 461,992 B(gzip 187,747)。 - **mcpplibs.cmdline 0.0.6.** 命令补全内建:`app.completion()` 一次调用开启,程序以自己的命令树回答(`__complete`),bash、zsh、 fish、PowerShell 的适配脚本只向程序询问;选项与参数可陈述可选值、文件或目录提示与候选回调,命令可隐藏。测试成员移到 0.0.6, diff --git a/README.md b/README.md index bac33204..07590604 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,12 @@ The minimum supported mcpp version is recorded in [index.toml](index.toml). ### Maintainers -| Responsibility | Scope | Maintainers | About | Merge tier | -|---|---|---|---|---| -| Specification & CI: workflows, index.toml, mcpp.toml, schema and governance docs | `.github/workflows/**` `.github/CODEOWNERS` `.github/MAINTAINERS.yml` `index.toml` `mcpp.toml` `docs/repository-and-schema.md` `docs/governance.md` | [Sunrisepeak](https://github.com/Sunrisepeak "Initiator of the mcpp / d2learn ecosystem") | The contract every client and package depends on. Changes are reviewed and merged by hand; see docs/governance.md for why bots never merge these. | manual — bots never merge | -| Package descriptors and consumer tests (compat.*, mwrap, module packages) | `pkgs/**` `tests/**` | *(open for adoption)* | Open for adoption — claim a package family or directory slice by PR; the gate merges a PR once one maintainer approval plus green CI are in. | `/merge` after 1 approval + green CI | +| Role | Permissions | About | Maintainers | +|---|---|---|---| +| Repository owner | `admin` | Holds the contract — spec, CI and version-floor decisions; merges official paths by hand | [Sunrisepeak](https://github.com/Sunrisepeak "Initiator of the mcpp / d2learn ecosystem") | +| Core maintainer | `maintain` | Day-to-day repo management and CI/release coordination — no sensitive or destructive actions | *(open for adoption)* | +| Committer | `write` | Module owners — package review, approvals and /merge (Tier A) | *(open for adoption)* | +| Active contributor | `triage`, `moderate` | Issue/PR triage and moderation — no code access | *(open for adoption)* | ### Contributors @@ -43,7 +45,7 @@ The minimum supported mcpp version is recorded in [index.toml](index.toml). governance docs) — the gate bot refuses to merge these; an owner reviews and merges by hand. -Roles, responsibility domains and the claiming process live in the +Roles, permissions and the claiming process live in the [governance guide](docs/governance.md). ### Contribute diff --git a/README.zh-CN.md b/README.zh-CN.md index 4776bb4f..fbf96785 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -23,10 +23,12 @@ mcpp build ### 维护者 -| 职责 | 权限范围 | 维护者 | 简介 | 合入策略 | -|---|---|---|---|---| -| 规范与 CI:工作流、index.toml、mcpp.toml、schema 与治理文档 | `.github/workflows/**` `.github/CODEOWNERS` `.github/MAINTAINERS.yml` `index.toml` `mcpp.toml` `docs/repository-and-schema.md` `docs/governance.md` | [Sunrisepeak](https://github.com/Sunrisepeak "mcpp / d2learn 生态发起人") | 所有客户端与包共同依赖的契约。变更经人工 review 后合并;bot 不合入这些路径的原因见 docs/zh/governance.md。 | 人工合并(任何 bot 不得合入) | -| 包描述符与消费测试(compat.*、mwrap、module 包) | `pkgs/**` `tests/**` | *(待认领)* | 开放认领——认领某个包家族或目录请发 PR;1 个 approve + CI 全绿后门禁即可合入。 | `/merge`:1 个 approve + CI 全绿后自动合入 | +| 身份 | 权限 | 简介 | 维护者 | +|---|---|---|---| +| 仓库负责人 | `admin` | 契约持有者:规范、CI 与版本下限的最终决策;官方路径人工合并 | [Sunrisepeak](https://github.com/Sunrisepeak "mcpp / d2learn 生态发起人") | +| 核心维护者 | `maintain` | 仓库日常管理与 CI/发版协调,无敏感与破坏性操作 | *(待认领)* | +| 维护者(Committer) | `write` | 模块负责人:包准入 review、approve 与 `/merge`(Tier A) | *(待认领)* | +| 活跃贡献者 | `triage`, `moderate` | issue/PR 分流与议题规范化,无代码权限 | *(待认领)* | ### 贡献者 @@ -41,7 +43,7 @@ mcpp build - 官方基础设施(workflows、`index.toml`、`mcpp.toml`、schema 与治理文档)—— 门禁 bot 拒绝合入;由 owner 人工 review 后主动合并。 -角色、职责域与认领流程见[治理文档](docs/zh/governance.md)。 +角色、权限与认领流程见[治理文档](docs/zh/governance.md)。 ### 贡献 diff --git a/docs/governance.md b/docs/governance.md index b16a0b9a..c626b89b 100644 --- a/docs/governance.md +++ b/docs/governance.md @@ -11,43 +11,54 @@ deliberate experiment in self-governing maintenance for the AI era. [`.github/MAINTAINERS.yml`](../.github/MAINTAINERS.yml) decides everything: -| Field | Meaning | +| Section | Meaning | |---|---| -| `duty` | what the domain is responsible for | -| `scope` | path globs the domain owns (also the Tier-B marker, see below) | -| `intro` | one-line description shown in the README | -| `maintainers` | clickable GitHub logins, several per domain | -| `merge` | `manual` (Tier B) or `auto` (Tier A) | +| `roles` | governance identities mapped onto GitHub repository roles, a one-line intro each, and the maintainers holding each seat | +| `tiers.manual` | path globs no bot may ever merge (Tier B) | -It is rendered into the README "Maintainers" tables by +It is rendered into the README "Maintainers" table by [`tools/render_maintainers.py`](../tools/render_maintainers.py) (PRs fail if the committed render is stale; pushes to main open a bot PR with the refreshed -tables). `.github/CODEOWNERS` mirrors the same scopes for GitHub's required -code-owner review — branch protection enforces CODEOWNERS, MAINTAINERS.yml is -the human-readable policy behind it. +table). `.github/CODEOWNERS` mirrors the `tiers.manual` paths for GitHub's +required code-owner review — branch protection enforces CODEOWNERS, +MAINTAINERS.yml is the human-readable policy behind it. -**Claim a domain** by opening a PR that adds your login (and a one-line intro) -under `maintainers:`; the PR needs an approval from the domain's current -maintainers. New domains and any change to a `merge` tier are decided by the -infra domain. +**Claim a seat** by opening a PR that adds your login under the role's +`maintainers:` (with a one-line intro); promotion needs an approval from an +existing member of that role or the repository owner. Role appointments and +`tiers` changes are decided by the repository owner. -## Roles +## Roles (the GitHub permission model) -| Role | Who | Powers | +Our identities are exact mirrors of [GitHub repository +roles](https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/managing-repository-roles/repository-roles-for-an-organization), +so every row of the README table is backed by a real, enforced permission — +not a promise: + +| Identity | GitHub role | Powers in this repo | |---|---|---| -| Owner (infra domain) | listed in MAINTAINERS.yml | spec/CI/floor decisions; merges Tier B by hand; stall fallback | -| Domain maintainer | listed per domain | approves/rejects PRs inside the domain scope; claims slices | -| Contributor | anyone | opens PRs; passes the same gates | -| Update bot | `xpkgindex-update` | daily version PRs + aggregate CI status; never merges | -| Wall bot | `thanks-contributors` | weekly contributor-wall PR; never merges | -| Merge gate | `merge-gate.yml` | merges Tier A PRs on `/merge` when the quorum is met; refuses Tier B | +| Repository owner | `admin` | full access incl. sensitive/destructive actions; holds the contract (spec, CI, version floor); merges Tier B by hand | +| Core maintainer | `maintain` | repo management without sensitive or destructive actions; CI/release coordination | +| Committer | `write` | push, approve/merge PRs, act as code owner; the `/merge` gate requires this level | +| Active contributor | `triage` + `moderate` | issues/PRs without code access — labels, assignment, close/reopen, plus editing any issue's title/body, locking issues, transferring issues, hiding comments | +| Contributor | `read` (default) | view, discuss, send PRs from forks | + +**Triage vs Moderate** (the two `active` roles): Triage *sorts and routes* +(labels, assignment, close/reopen, milestones, duplicates, review requests); +Moderate *adds editing and enforcement* — it can rewrite any issue's title +and body, edit any issue comment, lock issue conversations, transfer issues +and create/edit labels and milestones. Moderate is issue-centric and grants +nothing extra on PRs (locking a PR conversation already needs `write`); it +went GA on 2026-10-28. In this repo Moderate is the natural seat for +issue-normalization agents; Triage is the community seat. Neither can approve +or merge anything. ## Merge tiers -### Tier A — `merge: auto` (packages and tests) +### Tier A — packages and tests -A PR whose changed files all live inside `auto` domains (`pkgs/**`, -`tests/**`) merges once its quorum is met: +A PR whose changed files all live outside `tiers.manual` (`pkgs/**`, +`tests/**`, docs, …) merges once its quorum is met: 1. `MIN_APPROVALS` (currently 1) approvals from users with write access, excluding the PR author; @@ -64,10 +75,10 @@ Two paths, same quorum: and says who approved. Anything short of the quorum is reported back on the PR, nothing is merged. -### Tier B — `merge: manual` (official infrastructure) +### Tier B — official infrastructure -The scopes listed under `manual` domains — `.github/workflows/**`, -`.github/CODEOWNERS`, `.github/MAINTAINERS.yml`, `index.toml`, `mcpp.toml`, +The `tiers.manual` paths — `.github/workflows/**`, `.github/CODEOWNERS`, +`.github/MAINTAINERS.yml`, `index.toml`, `mcpp.toml`, `docs/repository-and-schema.md`, `docs/governance.md`. `/merge` refuses any PR touching them, no matter how green it is: these files are merged by a human, in the GitHub UI, on purpose. @@ -105,12 +116,12 @@ against it server-side, and the gate's checks are advisory on top. ## Escalation -- A PR stalls with no maintainer response for 72h: anyone may ping the domain - maintainers on the PR. -- Still stalled after 7 days: the infra owner may merge a Tier A PR by hand - with a note, or delegate the domain to a new maintainer (PR against - MAINTAINERS.yml). -- Disputes about policy, tiers or CI: infra domain, human, manual — by design. +- A PR stalls with no maintainer response for 72h: anyone may ping the + committers on the PR. +- Still stalled after 7 days: the repository owner may merge a Tier A PR by + hand with a note, or promote a new committer (PR against MAINTAINERS.yml). +- Disputes about roles, tiers or CI: repository owner, human, manual — by + design. ## Security notes diff --git a/docs/zh/governance.md b/docs/zh/governance.md index 14ccb1f9..46e5d9ae 100644 --- a/docs/zh/governance.md +++ b/docs/zh/governance.md @@ -10,39 +10,46 @@ [`.github/MAINTAINERS.yml`](../../.github/MAINTAINERS.yml) 决定一切: -| 字段 | 含义 | +| 段 | 含义 | |---|---| -| `duty` | 该职责域负责什么 | -| `scope` | 域拥有的路径 glob(同时是 Tier B 的判定依据,见下) | -| `intro` | README 里展示的一句话简介 | -| `maintainers` | 可点击的 GitHub login,一格内可多人 | -| `merge` | `manual`(Tier B)或 `auto`(Tier A) | +| `roles` | 治理身份到 GitHub 仓库角色的映射,每个身份一句话简介,以及该席位上的维护者名单 | +| `tiers.manual` | 任何 bot 永远不得合入的路径 glob(Tier B) | 它由 [`tools/render_maintainers.py`](../../tools/render_maintainers.py) 渲染成 README 的「维护者」表格(PR 里提交的渲染过期会让 CI 失败;push 到 main 由 -bot PR 回填表格)。`.github/CODEOWNERS` 把同样的路径映射到 GitHub 的 -code-owner review —— branch protection 强制的是 CODEOWNERS,MAINTAINERS.yml -是其背后人类可读的策略。 +bot PR 回填表格)。`.github/CODEOWNERS` 把 `tiers.manual` 的路径映射到 +GitHub 的 code-owner review —— branch protection 强制的是 CODEOWNERS, +MAINTAINERS.yml 是其背后人类可读的策略。 -**认领职责域**:发 PR 在 `maintainers:` 下加你的 login(附一句话简介), -需要该域现有维护者的 approve。新职责域与任何 `merge` 档位的调整由 infra 域决定。 +**认领席位**:发 PR 在对应角色的 `maintainers:` 下加你的 login(附一句话简介); +晋升需要该角色现有成员或仓库负责人的 approve。角色任命与 `tiers` 调整由仓库负责人决定。 -## 角色 +## 角色(GitHub 权限模型) -| 角色 | 谁 | 权限 | +我们的身份是 [GitHub 仓库角色](https://docs.github.com/zh/organizations/managing-user-access-to-your-organizations-repositories/managing-repository-roles/repository-roles-for-an-organization) +的精确映射——README 表格的每一行都对应一个真实被执行的权限,而不是口头承诺: + +| 身份 | GitHub 角色 | 在本仓的权力 | |---|---|---| -| Owner(infra 域) | 见 MAINTAINERS.yml | 规范/CI/下限决策;人工合并 Tier B;stall 兜底 | -| 职责域维护者 | 各域下所列 | 在本域范围内 approve/拒绝 PR;认领切片 | -| 贡献者 | 任何人 | 发 PR,通过同样的门禁 | -| 更新 bot | `xpkgindex-update` | 每日版本 PR + 聚合 CI status;永不合并 | -| 头像墙 bot | `thanks-contributors` | 每周贡献者墙 PR;永不合并 | -| 合入门禁 | `merge-gate.yml` | quorum 满足时按 `/merge` 合入 Tier A;拒绝 Tier B | +| 仓库负责人 | `admin` | 全部权限(含敏感/破坏性操作);持有契约(规范、CI、版本下限);人工合并 Tier B | +| 核心维护者 | `maintain` | 无敏感/破坏性操作的仓库管理;CI 与发版协调 | +| 维护者(Committer) | `write` | push、approve/merge PR、担任 code owner;`/merge` 门禁要求这一级 | +| 活跃贡献者 | `triage` + `moderate` | 无代码权限的 issue/PR 管理——标签、指派、关闭/重开,外加编辑任何 issue 标题/正文、锁定 issue、转移 issue、隐藏评论 | +| 贡献者 | `read`(默认) | 查看、讨论、从 fork 发 PR | + +**Triage 与 Moderate 的区别**(`活跃贡献者` 涵盖的两者):Triage 做**分类与路由** +(标签、指派、关闭/重开、里程碑、标重复、请求 review);Moderate 额外给**改写与执法** +——编辑任何人的 issue 标题与正文、编辑任何人的 issue 评论、锁定 issue 会话、 +转移 issue、创建/编辑标签与里程碑。Moderate 以 issue 为中心,对 PR 没有任何额外权力 +(锁 PR 会话本来就需 `write`);该角色 2026-10-28 才 GA。在本仓,Moderate 是 +议题规范化 agent 的天然席位,Triage 是社区成员的席位。两者都不能 approve 或 merge 任何东西。 ## 合入分级 -### Tier A —— `merge: auto`(包与测试) +### Tier A —— 包与测试 -变更文件全部落在 `auto` 域(`pkgs/**`、`tests/**`)的 PR,quorum 满足即可合入: +变更文件全部落在 `tiers.manual` 之外的 PR(`pkgs/**`、`tests/**`、docs 等), +quorum 满足即可合入: 1. `MIN_APPROVALS`(当前 1)个来自有写权限用户的 approve,且不计 PR 作者; 2. head SHA 上所有 check run 完成且成功; @@ -56,9 +63,9 @@ code-owner review —— branch protection 强制的是 CODEOWNERS,MAINTAINERS approve、check run 与 status,然后 squash 合入并说明是谁批准的。quorum 不满足 时只在 PR 上说明缺什么,什么都不合并。 -### Tier B —— `merge: manual`(官方基础设施) +### Tier B —— 官方基础设施 -`manual` 域列出的 scope:`.github/workflows/**`、`.github/CODEOWNERS`、 +`tiers.manual` 列出的路径:`.github/workflows/**`、`.github/CODEOWNERS`、 `.github/MAINTAINERS.yml`、`index.toml`、`mcpp.toml`、 `docs/repository-and-schema.md`、`docs/governance.md`。`/merge` 对触及它们的 PR 一律拒绝,无论多绿:这些文件由人工在 GitHub 界面上主动合并。 @@ -91,10 +98,10 @@ branch protection 始终是硬底线:每次 `/merge` 都被服务端按它重 ## 升级路径 -- PR 72 小时无维护者响应:任何人都可在 PR 上 at 该域维护者。 -- 7 天后仍无响应:infra owner 可人工合入该 Tier A PR(附说明),或发 - MAINTAINERS.yml 的 PR 把域委托给新维护者。 -- 策略、档位或 CI 的争议:infra 域、人工、手动合并——这是有意的设计。 +- PR 72 小时无维护者响应:任何人都可在 PR 上 at committer。 +- 7 天后仍无响应:仓库负责人可人工合入该 Tier A PR(附说明),或发 + MAINTAINERS.yml 的 PR 晋升新的 committer。 +- 角色、档位或 CI 的争议:仓库负责人、人工、手动合并——这是有意的设计。 ## 安全说明 diff --git a/tools/merge_gate.py b/tools/merge_gate.py index 83ea719c..d6eea30c 100755 --- a/tools/merge_gate.py +++ b/tools/merge_gate.py @@ -3,9 +3,9 @@ Reads .github/MAINTAINERS.yml for the merge tiers: -- Domains with `merge: manual` list protected path globs. Any PR touching one - of them is refused with an explanatory comment: official infrastructure is - always reviewed and merged by a human, never by a bot. +- `tiers.manual` lists protected path globs. Any PR touching one of them is + refused with an explanatory comment: official infrastructure is always + reviewed and merged by a human, never by a bot. - Every other PR is Tier A. It is squash-merged once its quorum is met: MIN_APPROVALS approvals from users with write access (excluding the PR author), every check run completed and successful, every commit status @@ -101,12 +101,7 @@ def main() -> int: return 0 manifest = yaml.safe_load(Path(".github/MAINTAINERS.yml").read_text(encoding="utf-8")) - manual_scopes = [ - scope - for domain in manifest["domains"] - if domain.get("merge") == "manual" - for scope in domain.get("scope") or [] - ] + manual_scopes = manifest["tiers"]["manual"] files = api_all(f"/repos/{REPO}/pulls/{PR_NUMBER}/files?per_page=100") protected = sorted({ f["filename"] @@ -115,7 +110,7 @@ def main() -> int: }) if protected: refuse( - "此 PR 触及官方管理路径(MAINTAINERS.yml 中 `merge: manual` 的域)。" + "此 PR 触及官方管理路径(MAINTAINERS.yml 的 `tiers.manual`)。" "按治理规则任何 bot 不得合入 —— 请 owner 人工 review 后在 GitHub 上主动合并。涉及:\n" + "\n".join(f"- `{p}`" for p in protected) ) diff --git a/tools/render_maintainers.py b/tools/render_maintainers.py index a562fbd6..ea618fac 100755 --- a/tools/render_maintainers.py +++ b/tools/render_maintainers.py @@ -1,10 +1,11 @@ #!/usr/bin/env python3 -"""Render the maintainer tables in both READMEs from .github/MAINTAINERS.yml. +"""Render the maintainer table in both READMEs from .github/MAINTAINERS.yml. -MAINTAINERS.yml is the single source of truth: responsibility domains with -duty, scope globs, introduction, maintainers (clickable logins joined by -" · ") and the merge tier per domain. This script renders one table per -language into the markers below; the maintainers workflow runs it with +MAINTAINERS.yml is the single source of truth: governance identities mapped +onto GitHub repository roles (`admin` / `maintain` / `write` / `triage, +moderate`), a one-line introduction per identity and the maintainers holding +that seat (clickable logins joined by " · "). This script renders one table +per language into the markers below; the maintainers workflow runs it with --check on PRs (stale render fails CI) and without it on main (opens a bot PR with the refreshed tables). @@ -29,17 +30,13 @@ TEXT = { "en": { "readme": "README.md", - "columns": ["Responsibility", "Scope", "Maintainers", "About", "Merge tier"], + "columns": ["Role", "Permissions", "About", "Maintainers"], "adopt": "*(open for adoption)*", - "tier_manual": "manual — bots never merge", - "tier_auto": "`/merge` after 1 approval + green CI", }, "zh": { "readme": "README.zh-CN.md", - "columns": ["职责", "权限范围", "维护者", "简介", "合入策略"], + "columns": ["身份", "权限", "简介", "维护者"], "adopt": "*(待认领)*", - "tier_manual": "人工合并(任何 bot 不得合入)", - "tier_auto": "`/merge`:1 个 approve + CI 全绿后自动合入", }, } @@ -54,6 +51,11 @@ def pick(value, lang: str) -> str: return value or "" +def github_cell(github) -> str: + perms = github if isinstance(github, list) else [github] + return ", ".join(f"`{p}`" for p in perms) + + def maintainer_cell(maintainers, lang: str) -> str: items = [] for m in maintainers or []: @@ -64,24 +66,18 @@ def maintainer_cell(maintainers, lang: str) -> str: return SEPARATOR.join(items) if items else TEXT[lang]["adopt"] -def scope_cell(scope) -> str: - return " ".join(f"`{s}`" for s in scope or []) - - def table(manifest, lang: str) -> str: t = TEXT[lang] lines = [ "| " + " | ".join(t["columns"]) + " |", "|" + "---|" * len(t["columns"]), ] - for domain in manifest["domains"]: - tier = t["tier_manual"] if domain.get("merge") == "manual" else t["tier_auto"] + for role in manifest["roles"]: row = [ - cell(pick(domain.get("duty"), lang)), - cell(scope_cell(domain.get("scope"))), - cell(maintainer_cell(domain.get("maintainers"), lang)), - cell(pick(domain.get("intro"), lang)), - cell(tier), + cell(pick(role.get("identity"), lang)), + cell(github_cell(role.get("github"))), + cell(pick(role.get("intro"), lang)), + cell(maintainer_cell(role.get("maintainers"), lang)), ] lines.append("| " + " | ".join(row) + " |") return "\n".join(lines)