Files
Agent-System/.doc/test-reports/2026-09-15-event-e0a-production-scope-contract-test-report.md
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

7.2 KiB
Raw Permalink Blame History

E0A 事件生产、契约与历史数据门 测试报告

一、 测试背景 (Background)

Phase 2 Track E 要求 notify / workflow advance / projection 达到「至少一次投递 + 恰好一个可见结果」。开工前生产入口仍临时构造 docflow.Commands,硬编码 Environment:"dev" / ProjectID:0,并把 "fav" 写进 delivery。dispatcher 必须保持 off,直到本报告的生产者/契约/历史数据门通过。

二、 测试目标 (Test Objectives)

  • 组合根持有唯一 *docflow.Commands;HTTP 适配器不得字面量构造。
  • document.agent_candidate_ready、document.downstream_impact_detected、document.approved 在领域提交同一 UoW 写 envelope + 目标 delivery。
  • 缺 environment/project fail closed 并回滚领域行。
  • FAV 生产链隔离:无 fav delivery、无 staging/artifact/publication。
  • 静态 allowlist 与 runtime registry 字节级子集;动态 FAV 注册失败。
  • 历史 inventory 只分类、不删行;repair 必须带 old/new digest。
  • 连续性模型书面结论:checkpoint + 首事件 bootstrap,禁止把 MemoryBus gap wait 搬到 PG。
  • dispatcher 保持 off。

三、 测试方案与环境 (Test Plan & Environment)

项 值
OS Linux 7.0.0-31-generic
Go go1.27.1 linux/amd64
分支 fix/event-production-scope-contract(从 Wave 0 后本地 dev@3d2a1de 检出)
Schema 39(00039_2026-09-15-event-inventory-and-principals.sql)
PostgreSQL 隔离库 agent_rel_e0a(admin 连 shuimu-system-pg-test:5434/postgres 自建);测完 DROP;禁止 agent_system_dev/test/main
历史流量 只读查询 shuimu-context-pg-dev:5433/agent_system_dev,不对该库跑测试、不写入
项目 143 只读
dispatcher off(本波未实现/未启动 cmd/events)
证据 .doc/test-reports/assets/2026-09-15-event-e0a-production-scope-contract/

四、 预期结果 (Expected Results)

链 判定
Approve 同一事务可见 document_records.current_state=approved + document.approved envelope + workflow_advance/notify delivery;无 fav
Materialize/Commit document.agent_candidate_ready 和/或 document.agent_version_committed;有 impact 时 document.downstream_impact_detected 使用独立 aggregate_type=document_impact
缺 env 领域行回滚到 approving,envelope/delivery 为 0
FAV staging/artifact/fav delivery = 0
Registry 未登记事件、动态 fav Register 失败
Unique (aggregate_type, aggregate_id, aggregate_version) 保留;同账本版本的多事件用不同 aggregate_type/id,不启用 event_seq

五、 实际测试结果与判定 (Actual Results & Evaluation)

5.1 单元 / archtest

  • 测试输入: unset TEST_DATABASE_URL; go test -short -count=1 ./internal/events ./internal/app/docflow ./internal/app ./internal/bizdev ./internal/archtest
  • 实际输出: 全部 PASS。TestAssertLiveConsumersRejectsFAV、TestRegistryParityWithYAML、TestEmitFailClosedMissingProject、TestFixtureInventoryThirtyPerType 绿。
  • 评价判定: PASS
  • 性能与耗时: 亚秒(archtest ~0.12s)

5.2 全仓 short

  • 测试输入: unset TEST_DATABASE_URL; go test -short -count=1 ./...;./scripts/arch-check.sh --mode block
  • 实际输出: 全包 PASS(internal/server 10.042s);arch-check block: production gate passed
  • 评价判定: PASS
  • 性能与耗时: 约 12s

5.3 隔离库 PG 三条链 + fail closed

  • 测试输入: TEST_DATABASE_URL=postgres://app:***@127.0.0.1:5434/agent_rel_e0a?sslmode=disable;go test -count=1 -v ./internal/app/docflow -run TestE0A_
  • 实际输出(摘录自 assets/.../pg-test.txt):
=== RUN   TestE0A_ThreeChainsSameTxAndFailClosed_PG
2026/09/15 08:49:02 goose: no migrations to run. current version: 39
--- PASS: TestE0A_ThreeChainsSameTxAndFailClosed_PG (0.03s)
=== RUN   TestE0A_InventoryClassifiesDirtyScope_PG
--- PASS: TestE0A_InventoryClassifiesDirtyScope_PG (0.00s)
PASS

goose 版本 39;FAV artifact_payload_staging / final_artifacts / fav delivery 计数在隔离库为 0。测完 DROP DATABASE agent_rel_e0a。

  • 评价判定: PASS
  • 性能与耗时: 含 goose 约 0.33s(首次)/ 0.04s(已迁)

5.4 历史 inventory(只读 + fixture)

  • 测试输入: 只读 agent_system_dev 近 7 天 event_envelopes;fixture 每 event type 30 条(TestFixtureInventoryThirtyPerType)。
  • 实际输出: 近 7 天有效流量仅 taskrun.completed=2;文档三类事件为 0,因此 shadow 样本 N 使用确定性 fixture(每类型 30)。现存 delivery:fav pending=2、projection pending=2(均挂在 taskrun.completed)。按契约 taskrun.completed 合法 consumer 仅为 notify,故 fav/projection 分类为 quarantine(未知/禁用 consumer),不得 live claim。dirty_scope=0。审批结论:quarantine 历史 fav/projection delivery;不删 envelope。
  • 评价判定: PASS(低流量走 fixture;历史脏 consumer 已分类)
  • 性能与耗时: 查询亚秒

六、 自动化测试套件汇总 (Test Suite Execution)

命令 结果
unset TEST_DATABASE_URL; go test -short -count=1 ./... PASS
./scripts/arch-check.sh --mode block PASS
隔离库 go test ./internal/app/docflow -run TestE0A_ PASS(schema 39)
dispatcher / cmd/events 未启动(E0A 退出门)

七、 测试结论与后续优化建议 (Conclusion & Next Steps)

E0A PASS,可以进入 E0B。dispatcher 仍 off。Goose 00039 已被 E0A inventory/principal 占用,E0B dispatcher 迁移使用 00040。

五个开放问题的书面结论

  1. Projection owner:最终文件投影属主仍是 docrevision(ProjectOutputMarkdown / workspace output.md)。no-replace 提交接口约定为未来表 document_projection_markers(document_id, source_snapshot_id, digest) + expected head;E1C 落地,本波不建表。
  2. 连续性模型:选择 consumer checkpoint + 首事件 bootstrap。ADR:.doc/adr/2026-09-15-event-consumer-checkpoint.md。禁止把 TestGapDoesNotSkipVersion 搬到 PG;gap blocking 关闭。
  3. 唯一约束:保留 UNIQUE (aggregate_type, aggregate_id, aggregate_version)。同账本版本的 approved / impact / report 使用不同 aggregate_type(document_approval / document_impact / document_report / document_candidate)。需要同类型同版本多事件时另立 event_seq,本波不启用。
  4. 7 天流量 / N / 连接预算:文档事件近 7 天为 0,shadow 样本用 fixture N=30/type。Worker 连接预算 E0A 为 0(无 dispatcher 进程);E0B 默认 batch 50 / lease 30s,独立 cmd/events 连接池有界。
  5. 错误 scope/schema/consumer:隔离库 fixture 将缺 env/project、未知事件、禁用 fav 标为 quarantine。dev 只读:2 条 taskrun.completed envelope 干净 scope;2 条 fav + 2 条 projection delivery quarantine,批准不重试、不删除。

后续

  • E0B:feature/events-dispatcher-pg,Goose 00040,原子 claim + attempt + fencing;默认 mode=off。
  • 不激活 FAV;不把 Track S/P 写成 E0A 完成。