Files
Agent-System/.doc/adr/2026-09-15-event-consumer-checkpoint.md
T
weichenandCursor 0f2f8d30e5 docs(test): record E0A producer-contract gate and checkpoint ADR
Archive isolated-PG evidence, 7-day read-only inventory, and the decision to bootstrap consumers from the first safe event instead of gap-waiting.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 08:52:59 +00:00

1.7 KiB

title, status, created, updated
title status created updated
事件连续性采用 consumer checkpoint + 首事件 bootstrap accepted 2026-09-15 2026-09-15

ADR:事件连续性采用 consumer checkpoint + 首事件 bootstrap

状态

接受(E0A)。在独立 FAV 审计或明确的无缺口 event sequence 迁移完成前不得改为 gap blocking。

背景

event_envelopes 已有 UNIQUE (aggregate_type, aggregate_id, aggregate_version)。受控文档的首次持久事件常常从较高 aggregate_version(账本 version_no)开始,中间版本从未发事件。若把领域版本号当成无缺口事件序号并在缺号时等待,会永久阻塞 delivery。MemoryBus 的 TestGapDoesNotSkipVersion 只是 characterization,不得搬到 PostgreSQL dispatcher。

决策

  1. Track E 选择 consumer checkpoint + 首事件 bootstrap。
  2. 每个 (consumer, aggregate_type, aggregate_id) 记录已成功处理的 event_id 与可选 aggregate_version。该 aggregate 上的第一件 safe 事件即为 bootstrap,不要求 version=1。
  3. 同一版本多个不同类型事件:当前唯一约束禁止。E0A 审计后保持该约束;需要同版本多事件时另立 additive 迁移,把序号改到独立 event_seq,不在本 ADR 启用。
  4. 禁止 在 dispatcher 启用 gap wait / ErrGapWait 阻塞,直到另有 ADR 选择独立无缺口 event sequence 且完成回填。
  5. 未知 schema、project 0、错误 environment、未知 consumer 的记录进入 inventory,不得 live claim。

后果

  • E0B checkpoint 表随 dispatcher migration 增加。
  • Projection 以 document_id + source_snapshot_id + digest no-replace,不依赖连续 version。
  • poison 事件 quarantine 后不静默跳号;其他 aggregate 继续。