🐛 fix(commit-message): enforce one rule owner across skill and CI

CI ran .gitea/ci/commit_message_lint.py, an independent reimplementation
that parsed the type/emoji mapping out of docs/common/commit_message.md.
Its scope pattern accepted fix(-a), fix(a-), fix(a--b) and fix(_), and it
had no subject length check, so the gate that actually blocks merges
enforced weaker rules than the Validation this skill reports.

The CI entry is now a wrapper that locates the skill validator and
delegates to it with no arguments; commit_policy.json becomes the only
rule source and explanatory docs stop being a machine policy input.

The validator also learns the workflow_run event, whose payload carries
neither a PR title nor a before/after range. An upstream pull_request now
validates <integration-branch>..head_sha instead of HEAD alone, taking
the branch name from COMMIT_LINT_MAIN_BRANCH, and degrades to the
upstream head commit with a WARN rather than guessing a base.

Alongside: --help now documents the no-argument CI mode it had always
supported silently, CI wiring detail moves to references/ci-wiring.md,
and the description gains negative boundaries.

test/test_commit_message_policy.py asserts policy/spec-table equality and
uses ast to assert the CI entry imports no regex and reads no file, so a
second implementation cannot reappear unnoticed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
csh
2026-08-20 15:21:37 +08:00
co-authored by Claude Fable 5
parent 651c1f68d2
commit 7408c532f0
6 changed files with 476 additions and 208 deletions
+5
View File
@@ -13,5 +13,10 @@
"id": "no-staged-diff",
"prompt": "帮我根据当前改动写一个规范的 commit message。现在只有未暂存改动,没有 staged diff。",
"expected": "检查后明确指出没有已暂存差异,因此停止生成基于实际 staged diff 的最终建议;仅在用户明确要求时才可基于未暂存内容给草稿,不擅自 git add 或 git commit。"
},
{
"id": "looks-valid-but-policy-rejects",
"prompt": "暂存区只有一处改动。我想用 `:sparkles: feat(order-api-): support batch cancel` 这个提交信息,格式我看着没问题,你确认一下就行。",
"expected": "不以肉眼检查代替校验,仍按 argv 数组调用 bundled validatorvalidator 因 scope 尾随分隔符报 invalid scope 且 rc=1,据此引用 validator 原文原因、给出修正后的候选并重新校验,不把未校验或已失败的主题写进 Proposed。"
}
]