feat: trusted candidate webhook adapter and lost-notification reconciliation #17

Merged
cflmy merged 1 commits from feature/issue3-webhook-adapter into main 2026-11-27 09:42:55 +08:00
Owner

范围(#3 可信候选通知与漏通知对账)

scripts/webhook-adapter.py(无长驻服务、无合并/推送权):

  • HMAC-SHA256 校验 Gitea webhook 原始 body;只接受 push(非删除)与 pull_request(opened/synchronized/reopened)。
  • 仓库身份来自 accepted 根图远端允许列表;组件 base 使用 accepted 当前固定 SHA(payload base 仅 hint);CI 严格聚合(≥1 个状态且全 success、允许主机 https)。
  • 通过后交给既有 candidate-notify.py 做可达性/去重/重放/基线重验 + impact.py 影响;输出计划 auto_promote=false/auto_merge=false。
  • --reconcile 扫描允许列表仓库开放 PR + head statuses,恢复丢失的快速通知;幂等状态、transient 退避重试、401/403 立即失败、错误不冒充成功。

验证(真实临时 Git 仓库,无网络 fixture)

python3 -m unittest tests.integration.test_webhook_adapter:8 tests OK;完整 tests/integration:79 tests OK。证据 docs/evidence/2026-11-27-candidate-webhook-reconcile.md。

未验证(不隐藏)

真实 Gitea webhook endpoint/secret、Woodpecker 触发、bot 最小权限、cron 工作流与平台并发/限流部署属 #10 M0 实测;本 PR 不声称平台已部署。

Refs cflmy/marqdo#3, cflmy/marqdo#10

## 范围(#3 可信候选通知与漏通知对账) `scripts/webhook-adapter.py`(无长驻服务、无合并/推送权): - HMAC-SHA256 校验 Gitea webhook 原始 body;只接受 `push`(非删除)与 `pull_request`(opened/synchronized/reopened)。 - 仓库身份来自 accepted 根图远端允许列表;组件 base 使用 accepted 当前固定 SHA(payload base 仅 hint);CI 严格聚合(≥1 个状态且全 success、允许主机 https)。 - 通过后交给既有 `candidate-notify.py` 做可达性/去重/重放/基线重验 + `impact.py` 影响;输出计划 `auto_promote=false`/`auto_merge=false`。 - `--reconcile` 扫描允许列表仓库开放 PR + head statuses,恢复丢失的快速通知;幂等状态、transient 退避重试、401/403 立即失败、错误不冒充成功。 ## 验证(真实临时 Git 仓库,无网络 fixture) `python3 -m unittest tests.integration.test_webhook_adapter`:8 tests OK;完整 `tests/integration`:79 tests OK。证据 `docs/evidence/2026-11-27-candidate-webhook-reconcile.md`。 ## 未验证(不隐藏) 真实 Gitea webhook endpoint/secret、Woodpecker 触发、bot 最小权限、cron 工作流与平台并发/限流部署属 #10 M0 实测;本 PR 不声称平台已部署。 Refs cflmy/marqdo#3, cflmy/marqdo#10
cflmy added 1 commit 2026-11-27 09:30:49 +08:00
- scripts/webhook-adapter.py authenticates the raw Gitea body with the repo
  webhook secret (HMAC-SHA256), whitelists push/pull_request candidate actions,
  resolves the repository from the accepted root graph, uses the accepted pin as
  base (payload base is only a hint), aggregates CI strictly, and delegates to
  the existing candidate-notify verifier for reachability, dedupe/replay,
  baseline revalidation and impact.
- --reconcile scans open PRs in allowlisted repositories, recovers candidates
  whose fast notification was lost with the same idempotent state, retries
  transient API errors with bounded backoff, fails closed on 401/403, and
  reports errors without claiming a downstream success.
- 8 focused adapter tests plus the full 79-test integration suite pass on real
  temporary Git fixtures. Docs/evidence record the trust rules and that the
  platform webhook/cron deployment itself is still external (#10 M0).

Refs cflmy/marqdo#3, cflmy/marqdo#10
cflmy merged commit 4a92201708 into main 2026-11-27 09:42: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#17