feat(candidate): authorize, verify and dedupe candidate notifications #15

Merged
cflmy merged 1 commits from release/candidate-notify into main 2026-11-27 02:24:55 +08:00
Owner

范围(issue #3 候选通知授权、去重与影响范围)

实现根 scripts/candidate-notify.py,作为(未来)机器人动作前的授权校验器;不开发自动 Agent 管理平台、不自动合并:

  • 只接受规范化通知(仓库、kind、head/base SHA、CI status/URL),不信任原始远端 payload。
  • 仓库允许列表来自 accepted 根图的 .gitmodules 远端;未知仓库拒绝。
  • 提交必须在本地对象库可达;组件候选的 base_sha 必须等于 accepted 根图当前固定的 SHA(拒绝 stale/retarget)。
  • CI 必须是允许主机上的 https URL 且 success。
  • 按 (repository, head SHA) 去重拒绝重放;accepted 基线变化时允许但标记 revalidate,要求重跑全部门禁。
  • 影响范围复用 scripts/impact.py(root 用新旧并集 diff,组件用反向 requires 闭包 + checks_with);无法确定时全量。
  • 计划固定 auto_promote=false、auto_merge=false、requires_human_review=true,仅允许创建候选分支/PR。
  • 同时修正 impact 的 .gitmodules Git config 三段式键解析。

验证(候选 d4ccb77)

  • python3 -m unittest tests.integration.test_candidate_notify:10/10 PASS。
  • python3 -m unittest discover -s tests/integration:71 tests OK(含 impact 5 + notify 10)。
  • 覆盖:合法组件/根候选、未知仓库、CI 失败、非允许 CI 主机、不可达提交、stale base、重放拒绝、新基线 revalidate、dry-run 不写状态。

未完成(不隐藏)

真实 webhook 传输适配器与 CI 自动触发未接入(本仓不新增长期运行的服务);本 PR 只提供可测试的授权/去重/影响校验逻辑,机器人仍只允许创建候选分支/PR。

Refs cflmy/marqdo#3

## 范围(issue #3 候选通知授权、去重与影响范围) 实现根 `scripts/candidate-notify.py`,作为(未来)机器人动作前的授权校验器;不开发自动 Agent 管理平台、不自动合并: - 只接受规范化通知(仓库、kind、head/base SHA、CI status/URL),不信任原始远端 payload。 - 仓库允许列表来自 accepted 根图的 `.gitmodules` 远端;未知仓库拒绝。 - 提交必须在本地对象库可达;组件候选的 `base_sha` 必须等于 accepted 根图当前固定的 SHA(拒绝 stale/retarget)。 - CI 必须是允许主机上的 `https` URL 且 `success`。 - 按 `(repository, head SHA)` 去重拒绝重放;accepted 基线变化时允许但标记 `revalidate`,要求重跑全部门禁。 - 影响范围复用 `scripts/impact.py`(root 用新旧并集 diff,组件用反向 requires 闭包 + checks_with);无法确定时全量。 - 计划固定 `auto_promote=false`、`auto_merge=false`、`requires_human_review=true`,仅允许创建候选分支/PR。 - 同时修正 impact 的 `.gitmodules` Git config 三段式键解析。 ## 验证(候选 `d4ccb77`) - `python3 -m unittest tests.integration.test_candidate_notify`:10/10 PASS。 - `python3 -m unittest discover -s tests/integration`:71 tests OK(含 impact 5 + notify 10)。 - 覆盖:合法组件/根候选、未知仓库、CI 失败、非允许 CI 主机、不可达提交、stale base、重放拒绝、新基线 revalidate、dry-run 不写状态。 ## 未完成(不隐藏) 真实 webhook 传输适配器与 CI 自动触发未接入(本仓不新增长期运行的服务);本 PR 只提供可测试的授权/去重/影响校验逻辑,机器人仍只允许创建候选分支/PR。 Refs cflmy/marqdo#3
cflmy added 1 commit 2026-11-27 02:19:17 +08:00
Implement the authorization verifier for candidate notifications (issue #3):
normalized schema, repository allowlist from the accepted root graph remotes,
reachable commit check, exact accepted base SHA for component candidates,
allowlisted https CI success URL, replay-safe (repository, head SHA) state with
new-baseline revalidation, and union-graph impact reuse (full fallback on
undetermined scope). The plan never auto-promotes or auto-merges; a human still
reviews the candidate branch/PR.

Tests build real temporary Git repositories and cover verified component and
root candidates, unknown repository, failed/non-allowlisted CI, unreachable
commit, stale base, replay + revalidation, dry-run state.

Also the impact analyzer's .gitmodules parser now handles the 3-segment Git
config keys correctly.

Refs cflmy/marqdo#3
cflmy merged commit d4ccb77003 into main 2026-11-27 02:24:55 +08:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cflmy/marqdo#15