Skip to content

feat(governance): add contributor branch preflight contract - #47

Open
HaodiFan wants to merge 22 commits into
mainfrom
codex/dev/20260731-governance-branch-contract
Open

feat(governance): add contributor branch preflight contract#47
HaodiFan wants to merge 22 commits into
mainfrom
codex/dev/20260731-governance-branch-contract

Conversation

@HaodiFan

@HaodiFan HaodiFan commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Governance surface changed

新增唯一、版本化的 evozeus.contributor_branch v1.3.1 machine contract、写入前只读 preflight planner、Core/community Skill 门禁与治理说明。

Closes #44

Relates to MetaInFLow/EvoZeus-CoEvolve#36。CoEvolve 只消费并执行该合同,不建立平行规则。当前供下游固化的 revision 为 11ef28eed715a46d0dfc35bf443b64701a970a16

Problem with current rule

现有规则只约束分支命名,无法在首次业务写入前确定 canonical base、live Issue、参与者、权限路径、隔离 worktree、new/resume 与 collision/stale handling。调用方还可能自报 direct;过期 ledger 缺少可执行的 Owner 重新确认入口;purpose type 未进入 resume key 时会产生 ledger identity collision。

Proposed rule

  • contracts/v1/contributor-branch-contract.json 是 v1.3.1 machine truth,覆盖 Core、UAT repair development、community 与 CoEvolve target consumer 四个 profile。
  • scripts/evozeus-branch-preflight.mjs plan 只读解析 Git/GitHub 事实并输出稳定 JSON,固定 writes=false
  • --actor--permission 仅表达期望;gh api user、Repo viewerPermission、archived/disabled 状态与 fork policy 决定实际 direct/fork/local 路径,失配即阻断。保留写权限字符串的 archived/disabled Repo 不解析为 direct。
  • 权限证据不可用时解析为 local patch,push 与 PR 固定禁用;Issue 证据不可用时整个计划阻断。remote.origin 的有效 fetch URL 与全部有效 push URL 必须匹配声明 Repo,包含 pushurlinsteadOfpushInsteadOf 重写结果。
  • Planner live 查询 Issue 并核验 Repo、编号、OPEN 状态和实体类型;CoEvolve target profile 额外要求 skill-feedback 标签或 [Skill Feedback] 标题前缀。
  • Resume key 绑定 profile、Repo、base、Issue、actor、resolved permission 与完整 purpose type/component/summary。
  • Target branch 把 live verified actor 的小写 login 纳入确定性名称;同一日期和 purpose 下的不同参与者拥有不同 branch/worktree。
  • Ownership 超过 14 天时默认阻断;完整身份匹配的 Owner 可通过 --resume-plan ... --reconfirm-owner 生成 refreshed plan,身份变化继续阻断。下游 ledger 持久化仍需独立批准。
  • 当前 checkout 与 primary canonical checkout 分别取证;canonical dirty/unavailable、protected checkout、wrong base、collision 与恶意 branch token 均 fail closed。
  • remote.origin 仅接受 exact github.com HTTPS/SSH/scp-like identity;任一有效 fetch/push 目标为 lookalike host 或其他 Repo 时阻断。
  • 计划路径不得位于任何 registered worktree 内;matching resume branch 的 worktree 已移除时输出显式 recreate action,后续创建仍需独立授权。
  • Canonical base 与目标 branch 状态都通过有效 origin 的 live git ls-remote 取证;查询不可用、cached base 过期或本地/live remote 同名目标分支分叉均阻断。
  • Fork path 要求已配置 remote 的全部有效 fetch/push URL 精确指向 verified actor fork,并从该 remote 读取 live target branch;缺失或 URL 不匹配时阻断。
  • Effective origin fetch identity 精确匹配 canonical Repo 后才允许发起 live ref 查询,防止任意 transport/host 被 preflight 触达。
  • 本地和 live remote 的目标 branch prefix/descendant namespace 冲突都会阻断,避免生成无法创建或推送的 branch plan。
  • 生成 branch 的最后一个 ref component 固定不超过 240 bytes;development Skill 的规则与示例同步 actor-qualified 格式。
  • 已注册的 requested resume worktree 必须独立通过 dirty/untracked status 检查,才会标记为可恢复。
  • 已注册 worktree 的 live top-level、common dir 与 current branch 必须匹配 registration,.git 重定向或损坏时阻断。
  • Prunable registration 只有在目录已消失时提供 prune-and-recreate;目录仍存在、路径祖先为文件或 dangling symlink 时按占用阻断。
  • 当前 checkout status 不可验证时阻断;Git registration 仍在但目录已丢失/prunable 时输出显式 prune-and-recreate action。
  • Resume 未传 --date 时仅从 purpose 匹配的 validated plan target branch 恢复原日期。
  • Resume evidence 必须 blocker-free 且零写入,target branch 必须从 saved base 派生;dangling symlink 视为路径占用。
  • Codex 与 Claude Host 使用同一计划语义;Host 不参与身份、权限或分支路径解析。
  • Issue 授权不包含 branch/worktree、commit、push 或 PR 授权。

本 PR 相对 main 含 2,460 additions / 7 deletions,共 12 个文件、22 个提交,超过 1,000 行审查阈值。Machine contract、可执行 planner、golden fixtures 与治理指令形成一个完整闭环。建议按三段审查:① machine contract、docs 与 Skill 入口;② planner;③ golden fixtures 与 gate wiring。本地 readiness 使用 --allow-cross-layer 验证。

Before / after

Before:Agent 可在随机 checkout 中按文字规则自行选择分支和权限路径,首次写入前没有统一、可验证计划。

After:Agent 先展示 repo、base ref/commit、branch、live Issue evidence、verified actor、permission evidence、current/canonical checkout status、worktree、resume decision、next action 与 blockers;存在 blocker 时停止。

Abuse cases prevented

  • 调用方通过 --permission direct 自行授予 Repo 写权限。
  • actor 与当前 gh viewer 不一致仍复用他人 branch plan。
  • 两名有效 actor 在分支创建前取得同名计划,随后用各自 plan 恢复同一 branch。
  • 关联已关闭、实际为 Pull Request、编号不匹配或无法查询的 Issue 后继续写入。
  • CoEvolve target 以普通 Issue 绕过 Skill feedback 分类入口。
  • purpose type 改变后复用相同 resume key 并撞写另一分支 ledger。
  • stale ledger 无安全恢复入口,迫使用户删除或篡改 ledger。
  • 从 clean isolated worktree 启动时忽略 dirty canonical checkout。
  • 在 protected/canonical checkout、错误 base 或来源不明的同名 branch 上开始写入。
  • lookalike GitHub host 被误判为 canonical origin。
  • canonical fetch URL 掩盖恶意 pushurl 或 Git URL rewrite,后续 push 发往其他 host/Repo。
  • 未 fetch 的 live target branch 被当作不存在,或本地 branch 掩盖 live remote 分叉。
  • 恶意或误配 origin 在身份校验前被 ls-remote 触达。
  • 本地或 live remote 已占用目标 branch 的 prefix/descendant ref namespace,导致后续 branch create/push 失败。
  • Cached canonical base 落后 live origin 时仍生成 blocker-free new plan。
  • 从 canonical checkout 恢复时忽略 requested resume worktree 中的 dirty/untracked 内容。
  • Prunable registration 的目录和遗留文件仍存在时给出不可执行的 recreate action。
  • Requested path 的祖先是普通文件或 dangling symlink 时误判为空闲。
  • Fork plan 查询 canonical origin,遗漏 contributor fork 中已存在或分叉的 target branch。
  • 过长 actor/component/summary 通过 ref 语法检查后在 loose-ref lock 创建阶段失败。
  • Agent-facing development Skill 仍按缺少 actor 的旧分支格式执行。
  • archived/disabled Repo 的历史写权限字符串被误判为可执行 direct 路径。
  • 在另一 participant worktree 内创建嵌套 worktree,污染其 clean 状态。
  • resume branch 存在但 worktree 已移除时输出无法执行的 resume action。
  • registered resume worktree 的 .git 被重定向到 protected branch 后仍被标记为可恢复。
  • 当前 linked checkout 的 index/status 损坏时仍产生 blocker-free 写入动作。
  • 已删除目录的 prunable worktree registration 被误当作可直接 resume。
  • blocked planner output 被回填后将未知同名分支转换为 resume。
  • target branch 被重置到 unrelated history 后仍通过 resume。
  • dangling symlink 被误判为空闲 worktree path。
  • 跨日期 resume 未重传 --date 时漂移到新 branch。
  • branch 字段携带 shell metacharacter 触发命令执行。

Risk and boundaries

Planner 的 direct/fork 判断与 Issue 核验依赖 GitHub API 可用性与当前登录态,canonical base 与 target branch existence 依赖 effective origin 的 live read-only 查询。权限证据缺失时降级到 local,Issue 或 remote 证据缺失时阻断。Planner 不创建或切换 branch/worktree,不 commit、push 或创建 PR。

Rollout

  1. 先合入 EvoZeus Core v1.3.1 contract 与 planner。
  2. Core development/community Skill 在首次业务写入前执行 preflight。
  3. EvoZeus-CoEvolve#36 固化该 revision,提供 Harness ledger、target injection 与端到端门禁。

Rollback

Revert 本 PR 的二十二个 commits 可整体移除合同、planner、tests 与治理入口。未知 profile 或 major version 的 consumer fail closed;不会留下 Git/GitHub 写入状态。

Evidence proof

  • Live evidence:当前 GitHub viewer HaodiFan、Repo MetaInFLow/EvoZeusviewerPermission=ADMIN;planner 解析 direct 并核验 [P1][Governance] 将共创分支协议固化为 EvoZeus 开发默认门禁 #44 为 OPEN Issue、非 Pull Request。当前实现 worktree dirty 时返回 blocker 与 writes=false
  • Local commands:node --test scripts/evozeus-branch-preflight.test.mjs47 passednpm testpython3 -m py_compile scripts/check_pr_ready.py scripts/evozeus-coevolve-dispatcher.pypython3 scripts/check_pr_ready.py --base origin/main --allow-cross-layergit diff --check
  • Hosted evidence:final head 11ef28eed715a46d0dfc35bf443b64701a970a16 的 Product CI、proof/privacy/schema/dirty/queue gates 与 Vercel 由 GitHub 复验。
  • Coverage:四 profiles、Host-neutral、actor-exclusive/length-bounded branch naming、local/live remote ref namespace、clean new、registered/missing/prunable/occupied-prunable/dirty/redirected-worktree resume、cross-date resume、remote-only resume、blocked evidence rejection、branch ancestry、pre-query origin identity、live remote base/direct-target/fork-target/cached-ref/divergence/unavailable evidence、exact fork remote fetch/push identity、purpose-type key、stale Owner reconfirm、dirty/unavailable current/canonical、protected/nested/dangling-symlink/non-directory-ancestor worktree、wrong base、collision、exact GitHub effective fetch/push targets、explicit multi-push target、Git URL rewrite、archived/disabled state、direct/fork/local、actor mismatch、GitHub unavailable/partial、Issue unavailable/closed/PR/mismatch/classification 与 shell-injection input。
  • Scope boundary:未实际创建 fork/branch/worktree、push 或 PR;CoEvolve Harness ledger 与 target gate 由 [P1][Harness] 在目标 Skillware 的 Issue-to-PR 流程中固化共创分支门禁 EvoZeus-CoEvolve#36 验收。

AI assistance

Codex 编写合同、planner、tests 与治理文档,并在真实本地/GitHub 环境运行验证。Owner review 仍需确认合同口径与 CoEvolve 消费边界。

Owner review

  • CODEOWNERS path reviewed
  • No auto-merge requested

Exact-head update (2026-08-02)

  • Contract revision remains v1.3.1. New plans lowercase actor/component/summary and encode - as _ before joining, preserving injective branch naming.
  • Historical migration: a valid v1.3.0 resume plan may retain its original hyphenated branch; refreshing the ledger to v1.3.1 continues to preserve that exact branch. New work never generates the legacy form.
  • Planner SHA-256: b6b14ffaae910d5346bd35f2ae1d9e672a10f83e92629286b8c7e35d922dcb1e.
  • Hosted evidence: exact head 11ef28e has all repository gates green.
  • Downstream dependency: CoEvolve PR41 must consume the contract and planner from this exact head before its contributor-branch gate is considered current.

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evozeus-metainflow Ready Ready Preview Aug 2, 2026 9:32am

@github-actions github-actions Bot added candidate:needs-redaction Candidate needs redaction before review risk:privacy May expose private or sensitive evidence labels Jul 31, 2026
@github-actions

Copy link
Copy Markdown

EvoZeus Privacy Scan

Mode: dry-run

Findings

  • scripts/evozeus-branch-preflight.test.mjs: email

Next action

  • Redact or explain these findings before maintainer review.

@github-actions github-actions Bot added proof:needed Real behavior proof is missing or incomplete triage:too-many-prs Author or branch family exceeds queue limits labels Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

EvoZeus Proof Gate

Mode: dry-run

Proof labels

  • proof:needed

Missing or weak fields

  • missing code/workflow section: Problem
  • missing code/workflow section: Scope
  • missing code/workflow section: Real behavior proof
  • missing code/workflow section: Tests
  • missing code/workflow section: Rollback plan
  • missing code/workflow section: Problem
  • missing code/workflow section: Scope
  • missing code/workflow section: Real behavior proof
  • missing code/workflow section: Tests
  • missing code/workflow section: Rollback plan
  • governance change needs Linked RFC or maintainer discussion
  • real behavior proof is missing

Next action

  • Add real behavior proof, not only mocks/lint/CI.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

EvoZeus Queue Guard

Mode: dry-run

Author open PRs: 6

Branch family: codex/dev/20260731-governance-branch-contract

Branch family open PRs: 1

Violations

  • author has 6 open PRs; limit 3

Next action

  • Reduce open PR queue or ask maintainers to override.

@github-actions github-actions Bot added risk:github-token May affect GitHub token permissions risk:governance Changes governance rules risk:workflow Touches GitHub Actions or automation size:L Large PR type:code Runtime, CLI, script, or behavior change type:governance Governance, template, branch, or maintainer process change type:workflow GitHub workflow or automation change labels Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

EvoZeus Labeler Report

PR type/risk labels were updated from changed files.

Surfaces

  • code
  • dependency
  • governance
  • workflow

Labels

  • risk:dependency
  • risk:github-token
  • risk:governance
  • risk:workflow
  • size:L
  • type:code
  • type:dependency
  • type:governance
  • type:workflow

Changed lines

  • 2467

@github-actions github-actions Bot added triage:dirty-pr PR mixes too many surfaces or should be split triage:owner-only Owner review required labels Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

EvoZeus Dirty PR Check

Mode: dry-run

Surfaces

  • code
  • dependency
  • governance
  • workflow

Reasons

  • changes 4 surfaces: code, dependency, governance, workflow
  • large PR: 12 files, 2467 changed lines
  • protected path changed

Next action

  • Split the PR, add RFC context, or wait for owner review.

@github-actions

Copy link
Copy Markdown

EvoZeus Auto Response

Redaction required

The PR appears to include sensitive evidence or private context. Redact secrets, raw logs, customer data, private paths, internal URLs, and unreleased business context before review.


Missing real behavior proof

This PR needs real behavior proof before review can continue. Add the command, environment, input, output after the patch, observed result, and what was not tested.


Split this PR

This PR appears to mix too many surfaces or protected paths. Split it into one primary layer and one review target.


Owner review required

This PR changes a protected path. CODEOWNERS review and maintainer approval are required; do not request automerge.


Queue limit reached

This author or branch family appears to exceed the current queue limit. Reduce open PRs or ask a maintainer to override before continuing review.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 471ed9102f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/evozeus-branch-preflight.mjs Outdated
Comment thread scripts/evozeus-branch-preflight.mjs Outdated
Comment thread scripts/evozeus-branch-preflight.mjs Outdated
@HaodiFan

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b39173b43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/evozeus-branch-preflight.mjs
@HaodiFan

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8436fa93fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/evozeus-branch-preflight.mjs Outdated
Comment thread scripts/evozeus-branch-preflight.mjs
@HaodiFan

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e39c09233

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/evozeus-branch-preflight.mjs Outdated
Comment thread scripts/evozeus-branch-preflight.mjs
@HaodiFan

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ead91b5088

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/evozeus-branch-preflight.mjs Outdated
Comment thread scripts/evozeus-branch-preflight.mjs
@HaodiFan

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ddcf1e58b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/evozeus-branch-preflight.mjs
@HaodiFan

HaodiFan commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f3efecc02

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/evozeus-branch-preflight.mjs
Comment thread maintainer/skills/evozeus-development/SKILL.md Outdated
@HaodiFan

HaodiFan commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up commit 26f7d81 aligns the local readiness gate with the v1.3.1 branch contract. BRANCH_PATTERN now accepts actor-qualified encoded refs (while keeping existing pre-v1.3.1 PR refs readable), diagnostics name encoded fields, and a dedicated regression test runs through npm test. The three maintainer examples now use underscore-encoded summary tokens.

Validation: npm test passed, including the new test:pr-ready suite.

@github-actions github-actions Bot added risk:dependency Adds or changes dependencies type:dependency Dependency or package metadata change labels Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

candidate:needs-redaction Candidate needs redaction before review proof:needed Real behavior proof is missing or incomplete risk:dependency Adds or changes dependencies risk:github-token May affect GitHub token permissions risk:governance Changes governance rules risk:privacy May expose private or sensitive evidence risk:workflow Touches GitHub Actions or automation size:L Large PR triage:dirty-pr PR mixes too many surfaces or should be split triage:owner-only Owner review required triage:too-many-prs Author or branch family exceeds queue limits type:code Runtime, CLI, script, or behavior change type:dependency Dependency or package metadata change type:governance Governance, template, branch, or maintainer process change type:workflow GitHub workflow or automation change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1][Governance] 将共创分支协议固化为 EvoZeus 开发默认门禁

1 participant