Skip to content

feat(core): batch durable publish + listener fan-out contract + fork single transaction - #179

Merged
LeXwDeX merged 1 commit into
devfrom
feat/event-batch-publish
Aug 7, 2026
Merged

feat(core): batch durable publish + listener fan-out contract + fork single transaction#179
LeXwDeX merged 1 commit into
devfrom
feat/event-batch-publish

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented Aug 7, 2026

Copy link
Copy Markdown
Owner

内容

publishMany(批 durable 发布)

  • 一批 durable 事件单事务提交:聚合内 seq 连续、投影按入口序执行、提交后单次 durable wake
  • BatchEvent 接口 + 聚合一致性 / string-aggregate 校验(early-return 拍平,无 else)
  • commitDurableEventInner 提取为事务作用域单事件提交,publish 与 publishMany 共用;wakeDurable 提取

listener fan-out 契约(随批入库——与 publishMany 经 notify 签名耦合,无法拆分)

  • listener 在 layer scope 绑定的 fiber 上 fork 执行:单事件内按注册序;失败/慢 listener 不阻塞 publish(observe 包裹)
  • 跨事件顺序不保证(契约注释明示);event.test.ts 断言对齐为顺序无关(filter/sort),保留 NOT-guaranteed disclaimer

session fork 单事务

  • fork 收敛为一个 db.transaction(publish 各自 savepoint 子事务),大 session fork 一次 commit

测试与验证

  • event-batch.test.ts(批提交 / seq 连续 / 聚合校验 / 投影序 / 单次 wake)+ fork-batch.test.ts(单事务收敛)
  • 提交时 pre-commit 全量 typecheck + lint 通过;此前工作流内 core/opencode/llm typecheck 与测试全绿(core 1161 pass,2 个已知环境失败;opencode 1009 pass;llm 287 pass)

chore

  • oxlint ratchet 4831 → 4842:新测试沿用既有 as-never 测试惯例产生的 no-unsafe-type-assertion 计数(全树实测 4842)

备注

  • 本 PR 原计划将 fan-out 拆为独立后续 PR;实施时发现 publishMany 调用单参 notify,与 fan-out 功能耦合,经确认合并入库

…single transaction

- publishMany:一批 durable 事件单事务提交,聚合内 seq 连续、投影按序、提交后单次 wake(BatchEvent 接口 + 聚合一致性校验拍平为 early-return,无 else)
- notify fan-out 契约:listener 在 layer scope 绑定 fiber 上 fork 执行——单事件内按注册序、失败/慢 listener 不阻塞 publish;跨事件顺序不保证(契约注释 + event.test.ts 断言对齐为顺序无关)
- commitDurableEventInner 提取为事务作用域单事件提交(seq 分配/owner 校验/投影/UPSERT+INSERT),publish 与 publishMany 共用;wakeDurable 提取
- session fork 收敛为单事务(publish 各自开 savepoint 子事务),大 session fork 一次 commit
- 测试:event-batch(批提交/seq 连续/聚合校验/投影序/wake 一次)+ fork-batch(单事务收敛、@ts-ignore 镜像 sqlite driver 既有模式并有债务注释)
- chore: oxlint ratchet 4831 → 4842(新测试沿用 as-never 测试惯例的 no-unsafe-type-assertion 计数;全树实测)
@LeXwDeX
LeXwDeX merged commit f56f2fb into dev Aug 7, 2026
4 of 5 checks passed
@LeXwDeX
LeXwDeX deleted the feat/event-batch-publish branch August 7, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant