Skip to content

feat(backbone): 三接口+双实现+生产skeleton+契约测试 (PR1b)#188

Open
raysonmeng wants to merge 1 commit into
feat/v3-pr1a-daemon-refactorfrom
feat/v3-pr1b-backbone-interfaces
Open

feat(backbone): 三接口+双实现+生产skeleton+契约测试 (PR1b)#188
raysonmeng wants to merge 1 commit into
feat/v3-pr1a-daemon-refactorfrom
feat/v3-pr1b-backbone-interfaces

Conversation

@raysonmeng

Copy link
Copy Markdown
Owner

Stacked on #187 (PR1a) — base 是 feat/v3-pr1a-daemon-refactor。PR1a 合并后会自动 retarget 到 master。

概要 / Summary

PR1b:按 spec §6 落地 v3 backbone 的三可替换接口 + 双实现并行 + 一套契约两实现都过(用户选 §6.4 字面全做)。core 只依赖接口,换 driver = 一行配置、core 零改。新增 src/backbone/零新增 npm 依赖(bun:sqlite / node:crypto / Bun 内置)。

三接口 × 三实现 / Interfaces × impls

接口 电池实现 第二实现(契约对照/测试 double) 生产 skeleton(§11.3,throw)
MessageTransport InProcTransport(进程内 pub/sub) InMemoryTransport(+published 内省) NatsTransport
Store(§12 十表面) SqliteStore(bun:sqlite + WAL) InMemoryStore PostgresStore
IdentityProvider PskIdentityProvider(node:crypto timingSafeEqual 常量时间比较) FakeIdentityProvider OidcIdentityProvider
  • 接口:envelope.ts(v3 信封 Appendix A,与旧 BridgeMessage 双轨并存)、identity.tstransport.tsstore.ts方法 async 前瞻生产 Postgres)。
  • 契约:runStoreContract / runIdentityProviderContract / runTransportContract——一套 suite,两实现各跑一遍 + skeleton 断言 throw(§6.4「两实现都过」的可执行证明)。

测试计划 / Test plan

  • 实现由 3 个并行 subagent 编写(Store/Identity/Transport 各一)
  • 新增 38 用例(Store 22 / Identity 5 / Transport 11)
  • bun run check exit 0 → 1704 pass / 0 fail、typecheck 干净、plugin bundle 同步(仅 build stamp)、版本对齐 0.1.24

Cross-review

  • 轮 1(thorough,5 维 + 逐条对抗式 verify):16 findings → 2 confirmed(同一 issue):getRecentEvents(limit<=0) 两实现语义分叉(InMemory slice(-0)=全表 / SQLite LIMIT 0=空,§6.4 违背)。→ 根因修复:两实现各加 if (limit<=0) return [] + 契约补 limit=0/-1 断言锁死。
  • 轮 2 / 轮 3(lean,2 broad reviewer + verify):连续两轮 0 真实 issue → 收敛。

Backlog(RECOMMEND,非阻塞,已对抗式驳倒)

  • InMemoryStore 返回活引用 vs SqliteStore JSON 快照——可加防御性拷贝。
  • InProcTransport throwing-subscriber 应 try-catch 隔离(broker PR 前补)。
  • 出契约域边界(小数 limit / close 后调用 / getMembers 顺序)两实现可进一步对齐。

🤖 Generated with Claude Code

按 spec §6 落地 v3 backbone 的三可替换接口(接口先行 + 双实现并行 + 一套契约两实现都过),
core 只依赖接口、换 driver 一行配置不动 core。新增 src/backbone/,零新增 npm 依赖
(bun:sqlite / node:crypto / Bun 原生全内置)。

- 接口:envelope.ts(v3 信封 Appendix A,与旧 BridgeMessage 双轨并存)、identity.ts、
  transport.ts、store.ts(§12 全表面,方法 async 前瞻生产 Postgres)。
- MessageTransport:InProcTransport(电池,进程内 pub/sub)+ InMemoryTransport(第二实现/测试 double,带 published 内省)+ NatsTransport(skeleton throw §11.3)。
- Store:SqliteStore(电池,bun:sqlite + WAL,§12 十表)+ InMemoryStore(第二实现/double)+ PostgresStore(skeleton)。
- IdentityProvider:PskIdentityProvider(电池,node:crypto timingSafeEqual 常量时间比较,产出 {id,displayName})+ FakeIdentityProvider(第二实现)+ OidcIdentityProvider(skeleton)。
- 契约:runStoreContract / runIdentityProviderContract / runTransportContract(一套 suite,两实现各跑一遍 + skeleton 断言 throw)。

实现由 3 个并行 subagent 编写。测试:新增 38 用例(Store 22 / Identity 5 / Transport 11),
全量 1704 pass / 0 fail,typecheck 干净,plugin bundle 同步(仅 build stamp 变化)、版本对齐。

Cross-review:轮1 thorough(5维+对抗式 verify) 抓出并根因修复 getRecentEvents 在 limit<=0 的
两实现语义分叉(§6.4)——两实现各加 limit<=0 守卫 + 契约补 limit=0/-1 断言锁死;轮2/轮3 lean
连续两轮 0 真实 issue 收敛。

Backlog (RECOMMEND, 非阻塞):InMemory 引用 vs JSON 快照别名可加防御拷贝;InProc throwing-subscriber
应 try-catch 隔离(broker PR 前补);小数 limit / close 后调用等出契约域边界两实现可进一步对齐。

---

feat(backbone): three replaceable interfaces + dual impls + production skeletons + contract tests (PR1b)

Land the v3 backbone's three replaceable interfaces per spec §6 (interface-first +
dual impls in parallel + one contract both impls pass); the core depends only on the
interfaces, swapping a driver is a one-line config change. New src/backbone/, zero new
npm deps (bun:sqlite / node:crypto / Bun built-ins). Store=Sqlite(WAL)+InMemory+Postgres-skeleton,
Identity=PSK+Fake+OIDC-skeleton, Transport=InProc+InMemory+NATS-skeleton. Adds 38 tests
(1704 total pass). Converged after 1 thorough + 2 lean adversarial cross-review rounds.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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