Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(tooling): 支持人类与智能体共同作者署名

longmeidaob07cd98ec479
diff --git a/.claude/skills/peach-worktree/SKILL.md b/.claude/skills/peach-worktree/SKILL.md
index 324fbd0c4..5df628427 100644
--- a/.claude/skills/peach-worktree/SKILL.md
+++ b/.claude/skills/peach-worktree/SKILL.md
@@ -5,7 +5,7 @@ description: 在用户说并行、工作树、暂存、提交、ready、集成
# 并行 worktree 与提交边界
-最后复核:2026-10-13
+最后复核:2026-10-18
证据来源:`docs/HANDOFF.md`「并行智能体与 Git 工作树」、`README.md`、ADR-0015、ADR-0017、本机工作树与沙箱工具记录。
## 是否委派与何时使用
@@ -66,7 +66,7 @@ description: 在用户说并行、工作树、暂存、提交、ready、集成
代码差别比换工具本身还大。工具与地址的名单在 `scripts/co_author.py` 的 `VENDORS`,
`ready` / `integrate` 逐个提交判,拒收缺失、形态不对、工具未登记和地址与工具不配四种;
合进来的 merge 与已在 `origin/master` 上的提交(网页上直接改的那种,签不了名)不算。
- 一个提交由两个智能体接力写成时,两条并列署名都写上。
+ 智能体接力写成时并列署名;人类共同作者使用「姓名 <邮箱>」,与智能体署名同块保留。
- 禁止 `git add .`、`git add -A`、目录路径或 glob。只暂存任务明确拥有的文件。
- 提交前用 `git diff --cached --name-status` 与任务边界逐条对照。干净的 `git status`
diff --git a/docs/REUSE.md b/docs/REUSE.md
index 83df79383..131d7cb55 100644
--- a/docs/REUSE.md
+++ b/docs/REUSE.md
@@ -286,7 +286,7 @@ MGS 专属发行先查自营商品目录,Prestige 番号复用 `metadata_route
定向调试复用标准库 unittest 的按名字加载与现有浏览器夹具,记录复用沿用文件清单、影响域和 FileLock,不新增测试框架或缓存服务。局部成功记录保留未受影响域的原验证时间,失败域不能从历史基线恢复;浏览器失败即停。回归覆盖过期、环境差异、未知与共享文件、失败后再次验证、路径越界及不签调试证明,详见 [测试](TESTING.md#定向调试与局部记录)。
-提交消息复用 Git 的 [`interpret-trailers --parse`](https://git-scm.com/docs/git-interpret-trailers),署名与 README 声明判据由 `co_author.py`、`check_readme_impact.py` 共用;`check_commit_message.py` 接到仓库 `commit-msg` 钩子。Git 自身处理注释与多行 trailer,Peach 只检查字段形态和分段。Windows Git 2.55.0.windows.3 的临时仓库回归覆盖拒绝提交、保留暂存、多署名、amend 和合并消息;不新增解析依赖。具体触发范围见 [README 维护](README_MAINTENANCE.md)。
+提交消息复用 Git 的 [`interpret-trailers --parse`](https://git-scm.com/docs/git-interpret-trailers),署名与 README 声明判据由 `co_author.py`、`check_readme_impact.py` 共用;`check_commit_message.py` 接到仓库 `commit-msg` 钩子。Git 自身处理注释与多行 trailer,Peach 只检查字段形态和分段。Windows Git 2.55.0.windows.3 的临时仓库回归覆盖拒绝提交、保留暂存、人类与智能体共同署名、amend 和合并消息;不新增解析依赖。具体触发范围见 [README 维护](README_MAINTENANCE.md)。
### 播放、采集、发布与打包
diff --git a/scripts/co_author.py b/scripts/co_author.py
index b87bb38eb..bb3188783 100644
--- a/scripts/co_author.py
+++ b/scripts/co_author.py
@@ -17,6 +17,7 @@ VENDORS = {
#: 署名形态:`工具 (模型 版本) <厂商 noreply>`。括号里那一段是重点——同一个工具换代
#: 模型,写出来的代码差别比换工具本身还大,事后翻这一行是要知道哪个模型写的。
FORM = re.compile(r"(?P<tool>[^()<>]+) \((?P<model>[^()]+)\) <(?P<mail>[^<>\s]+)>")
+HUMAN_FORM = re.compile(r"(?P<name>[^()<>\r\n]+) <(?P<mail>[^<>\s@]+@[^<>\s@]+)>")
EXAMPLE = "Co-Authored-By: Claude Code (Opus 5) <[email protected]>"
@@ -38,8 +39,14 @@ def problems(label: str, found: list[str]) -> list[str]:
if not found:
return [f"提交「{label}」须有 Co-Authored-By 写明工具与模型,如 {EXAMPLE}"]
problems = []
+ has_agent = False
for value in found:
parsed = FORM.fullmatch(value)
+ human = HUMAN_FORM.fullmatch(value)
+ if (parsed is None and human is not None and human["name"].strip()
+ and human["name"].strip().casefold() not in {tool.casefold() for tool in VENDORS}
+ and human["mail"].casefold() not in VENDORS.values()):
+ continue
if parsed is None:
problems.append(f"提交「{label}」的署名「{value}」形态不对,须为 工具 (模型 版本) "
f"<厂商 noreply>,如 {EXAMPLE}")
@@ -49,6 +56,10 @@ def problems(label: str, found: list[str]) -> list[str]:
elif parsed["mail"] != VENDORS[parsed["tool"]]:
problems.append(f"提交「{label}」里 {parsed['tool']} 的署名地址须是 "
f"{VENDORS[parsed['tool']]},不是 {parsed['mail']}")
+ else:
+ has_agent = True
+ if not problems and not has_agent:
+ problems.append(f"提交「{label}」须有 Co-Authored-By 写明工具与模型,如 {EXAMPLE}")
return problems
@@ -56,8 +67,8 @@ def check(repo: Path, base: str, head: str = "HEAD") -> list[str]:
"""分支上每个非 merge 提交都要有署名,且每一条都合规。
署名是事后追责唯一的入手处:出问题的那一行是哪个工具的哪个模型写的,只能从这里看。
- 所以缺了、形态不对、工具没登记、地址与工具不配,四种都拒收。多条并列是允许的,
- 一个提交确实可能由两个智能体接力写成。
+ 每个提交须有合规的智能体署名。人类共同作者使用「姓名 <邮箱>」,可以与智能体并列;
+ 智能体的模型、工具登记和厂商地址仍逐条检查。
判据落在每个提交上,不是落在分支尖端:一次交付常常是好几个提交,只看最后一个
等于只要收尾那次签对了,前面写代码的几次签成谁都放行——而要追的恰恰是写出那
diff --git a/tests/test_agent_worktree.py b/tests/test_agent_worktree.py
index ef1fbd6a9..ee54b4132 100644
--- a/tests/test_agent_worktree.py
+++ b/tests/test_agent_worktree.py
@@ -216,6 +216,13 @@ class CommitMessageGuardTests(_WorktreeCase):
self.assertEqual(amended.returncode, 0, amended.stderr)
self.assertEqual(_git(self.worker, "show", "-s", "--format=%B").stdout.strip(), message.strip())
+ def test_human_and_agent_trailers_are_preserved_in_the_commit(self):
+ message = ("test: 共同作者署名\n\n" + AUTHOR
+ + "\nCo-Authored-By: Contributor <[email protected]>\n")
+ result = self.attempt(message)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(_git(self.worker, "show", "-s", "--format=%B").stdout.strip(), message.strip())
+
def test_intermediate_commit_can_leave_readme_scope_for_delivery_check(self):
result = self.attempt("test: intermediate\n\n" + AUTHOR)
self.assertEqual(result.returncode, 0, result.stderr)
@@ -682,6 +689,29 @@ class CoAuthorTests(unittest.TestCase):
self.signed("Co-Authored-By: Claude Code (Opus 5) <[email protected]>",
"Co-Authored-By: Codex (GPT-5.5) <[email protected]>"), [])
+ def test_human_and_agent_coauthors_share_one_commit(self):
+ human = "Co-Authored-By: Contributor <[email protected]>"
+ agent = "Co-Authored-By: Codex (GPT-6) <[email protected]>"
+ for signatures in ((human, agent), (agent, human)):
+ with self.subTest(signatures=signatures):
+ self.assertEqual(self.signed(*signatures), [])
+
+ def test_human_coauthor_requires_an_agent_signature(self):
+ self.assertTrue(self.signed("Co-Authored-By: Contributor <[email protected]>"))
+
+ def test_human_coauthor_requires_a_name_and_email(self):
+ agent = "Co-Authored-By: Codex (GPT-6) <[email protected]>"
+ for human in ("Contributor", "Contributor <invalid>", "<[email protected]>"):
+ with self.subTest(human=human):
+ self.assertTrue(co_author.problems("测试", [agent, human]))
+
+ def test_registered_agent_and_vendor_addresses_require_model_metadata(self):
+ agent = "Codex (GPT-6) <[email protected]>"
+ for signature in ("Codex <[email protected]>",
+ "Contributor <[email protected]>"):
+ with self.subTest(signature=signature):
+ self.assertTrue(co_author.problems("测试", [agent, signature]))
+
def test_every_commit_on_the_branch_is_checked_not_only_head(self):
"""一次交付常常是好几个提交。只判尖端等于只判收尾那一次签得对不对,
而要追的恰恰是写出某一行的那个提交,所以问题里要报出它的短 hash 和主题。