feat(backbone): 三接口+双实现+生产skeleton+契约测试 (PR1b)#188
Open
raysonmeng wants to merge 1 commit into
Open
Conversation
按 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)
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要 / Summary
PR1b:按 spec §6 落地 v3 backbone 的三可替换接口 + 双实现并行 + 一套契约两实现都过(用户选 §6.4 字面全做)。core 只依赖接口,换 driver = 一行配置、core 零改。新增
src/backbone/,零新增 npm 依赖(bun:sqlite / node:crypto / Bun 内置)。三接口 × 三实现 / Interfaces × impls
MessageTransportInProcTransport(进程内 pub/sub)InMemoryTransport(+published内省)NatsTransportStore(§12 十表面)SqliteStore(bun:sqlite + WAL)InMemoryStorePostgresStoreIdentityProviderPskIdentityProvider(node:crypto timingSafeEqual 常量时间比较)FakeIdentityProviderOidcIdentityProviderenvelope.ts(v3 信封 Appendix A,与旧BridgeMessage双轨并存)、identity.ts、transport.ts、store.ts(方法 async 前瞻生产 Postgres)。runStoreContract/runIdentityProviderContract/runTransportContract——一套 suite,两实现各跑一遍 + skeleton 断言 throw(§6.4「两实现都过」的可执行证明)。测试计划 / Test plan
bun run checkexit 0 → 1704 pass / 0 fail、typecheck 干净、plugin bundle 同步(仅 build stamp)、版本对齐 0.1.24Cross-review
getRecentEvents(limit<=0)两实现语义分叉(InMemoryslice(-0)=全表 / SQLiteLIMIT 0=空,§6.4 违背)。→ 根因修复:两实现各加if (limit<=0) return []+ 契约补 limit=0/-1 断言锁死。Backlog(RECOMMEND,非阻塞,已对抗式驳倒)
InMemoryStore返回活引用 vsSqliteStoreJSON 快照——可加防御性拷贝。InProcTransportthrowing-subscriber 应 try-catch 隔离(broker PR 前补)。🤖 Generated with Claude Code