feat(runtime,datasource): default-datasource factory seam + adopt pre-built drivers via one connect path (#3826) - #3968
Merged
Conversation
…-built drivers via one connect path (#3826) DefaultDatasourcePlugin accepts an injected IDatasourceDriverFactory (default: the shared open-core factory, unchanged when omitted), and createPrebuiltDriverFactory wraps a host-built driver instance as a factory — the "adopt an existing driver" seam, landed as a factory so the connect + failure-verdict orchestration stays the single DatasourceConnectionService implementation. This is what the cloud compositions (turso, pooled control-plane/environment drivers) need to converge without forking the verdict. The @objectstack/verify dogfood harness now boots the declared default (sqlite-wasm definition) instead of a pre-built DriverPlugin, so the dogfood gate covers the converged path — the ADR-0062 §Risk mitigation. ADR-0062's header no longer understates D1 (open-core converged; the cloud repo is the last second site), and the degraded-boot parity guard's comment now describes what it actually guards. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GK5nd3gtehcAhrF6Zzp2on
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 3 package(s): 24 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
CI frozen-lockfile caught the miss: dropping @objectstack/driver-sqlite-wasm from @objectstack/verify's dependencies needs the lockfile regenerated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GK5nd3gtehcAhrF6Zzp2on
…he CLI uses" Stale since #3886: the CLI's primary boots as a declared default definition, not a pre-built DriverPlugin. Flagged by the docs drift check on this PR. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GK5nd3gtehcAhrF6Zzp2on
os-zhuang
marked this pull request as ready for review
July 30, 2026 00:31
This was referenced Jul 30, 2026
Closed
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.
#3826 收尾的 framework 侧:为 cloud 仓库的最后收敛铺接缝,并补上 #3869/#3886 留下的三处欠账。开源侧行为零变化(不注入 factory 时逐字节走原路径)。
为什么需要接缝
cloud 组装(
environment-kernel-factory的每环境主 driver、control-plane preset)有两个共享 factory 覆盖不了的性质:driver kind 在开源之外(turso),以及实例池化超出单个 kernel(control-plane driver 同时是每个环境 kernel 的 proxy 基座;每环境 driver 跨 kernel 重建缓存 —— 按定义重建会成倍开 pool)。没有接缝,cloud 只有两条路:留在旧DriverPlugin路径(判决在ObjectQLEngine.init(),恰是 #3826 要退役的第二实现),或者 fork 整套 connect 编排。两条都会重演 #3741 → #3758。改动
DefaultDatasourcePlugin接受注入的IDatasourceDriverFactory(缺省 = 共享开源 factory,不传时行为不变)。factory 只改变create()返回什么;policy-free init connect、bootCriticalfail-fast、OS_ALLOW_DRIVER_CONNECT_FAILURE、start() replay 进留存状态 —— 注入与否完全一致,新测试钉死了这一点(连不上的被收养实例吃到同一份判决)。createPrebuiltDriverFactory(driver, { driverId?, fallback? })(service-datasource):第一轮讨论里缺失的「adopt 现成 driver」入口,落成 factory 形态而不是第二个 connect 入口 ——create()每次返回同一实例,构造/池化/复用留给 host,只有判决收敛。TSDoc 明确写了它不是常规用法:能表达成{ driver, config }的就该用定义。sqlite-wasm定义经DefaultDatasourcePlugin),不再用预构建DriverPlugin—— dogfood gate 从此覆盖objectstack dev/serve 真实使用的收敛路径。ADR §Risk 承诺的 "behind the dogfood gate" 此前其实没兑现,这次兑现。顺带删掉 verify 对driver-sqlite-wasm的直接依赖(经 factory 懒加载)。defaultdatasource is a declaration, connected through the one datasource path (#3826) #3869/feat(cli): the serve storage fallback declares the default datasource instead of constructing a driver (#3826) #3886 起 header 里 "thedefaultdriver still has its own connect + failure path" 对开源侧已不成立(feat(datasource): a datasource that is down is visible, and says why when queried (#3827, #3828) #3836 批评它高估自己,合并后又变成低估)。现在:D1 对每条开源 boot 路径 implemented;cloud 组装是最后的第二实现。D1 正文补 fourth-pass 段落记录接缝设计,余项表述从cloud-stack.ts修正为真正的主 driver 组装点(environment-kernel-factory+ control-plane preset)。degraded-boot-parity.test.ts头注释重写:原文还在把default描述成driver.*kernel service + engine-init 连接(pass 2 之前的形态)。现在如实说明 engine 侧判决为什么仍是活代码(boot 再验证、DriverPlugin逃生舱、cloud 未收敛),以及守卫为何在 cloud 收敛后仍然保留(只要init()还能抛 connect 判决,它就必须与 service 的判决一致)。测试本体不动。验证
DatasourceConnectionService的收养 —— 身份而非等价、自然名保留、fail-fast 判决一致)pnpm turbo build受影响包全绿;根配置 ESLint 对本 diff 触及文件零告警(verify 包有 3 处@typescript-eslint/no-explicit-any规则解析报错,stash 对照确认是既有环境问题,不在本 diff 行内)后续
cloud 仓库用本接缝收敛
environment-kernel-factory+ control-plane preset(随后另开 PR);收敛后 #3826 才可关闭。Generated by Claude Code