Skip to content

fix(service-datasource): reject a pool block the memory arm cannot honour (#5931) - #6237

Merged
hotlong merged 1 commit into
mainfrom
claude/issue-5931-memory-pool-reject
Aug 7, 2026
Merged

fix(service-datasource): reject a pool block the memory arm cannot honour (#5931)#6237
hotlong merged 1 commit into
mainfrom
claude/issue-5931-memory-pool-reject

Conversation

@hotlong

@hotlong hotlong commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #5931

按 2026-08-07 维护者裁决实施:memory 并入 POOL_UNSUPPORTED_DRIVER_IDS,配 memory 专属消息,翻掉 #5954 特意留绿的钉。

前提复核(基于 origin/main 1549605)

单子的前提全部成立,逐条对上:

改了什么

memory 进入拒绝集合后,三扇门一起生效——它们本来就共用同一个 helper,不需要各改一处:Setup 向导 create/update、boot 期 auto-connect 预检、驱动工厂自身。

消息是 memory 专属的,不复用 sqlite 那句。 这一条裁决讲得很明确,而且不是文风问题:sqlite 被拒是因为第二个 :memory: 连接会打开另一个空库,按 max 分池等于把一个 datasource 的数据劈到几个库里;这套理由对 memory假的——它根本不开连接,存储就是本进程里的一个普通数据结构。照抄那句会告诉作者「驱动替你选了连接策略」,把人推去找一个不存在的旋钮。所以改成按驱动 id 取解释:

Datasource 'scratch' declares a `pool` block, but the 'memory' driver does not read it:
the in-memory driver has no pool to size, and no connection to pool — its store is a
plain data structure inside this process, reached by a direct call rather than over a
wire, so `min` / `max` and the timeouts have nothing to configure. The block is rejected
instead of dropped. Remove `pool` from this datasource declaration; it stays meaningful
on the pooled drivers (postgres / mysql / mongo).

顺带把「加臂必须写解释」做成结构约束:解释表 POOL_UNSUPPORTED_REASONSRecord< PoolUnsupportedDriverId, string > 键控,往集合里加 id 却不写解释是类型错误,而不是悄悄借用隔壁那句。下一个姊妹臂按 #6140 的默认并入时会被这条挡住。

sqlite / sqlite-wasm 两臂一个字没动。 不是靠 review 眼力保证的:新增一条整串 byte 级钉,字面量取自 origin/main 改动前的文本;另跑探针直接对比改前改后两个实现的输出——sqlite 518→518、sqlite-wasm 523→523、better-sqlite3 526→526,identical=true

那条钉是翻,不是删。 同一个事实换了裁决,所以保留它的位置和来历(注释说明它当初为什么被特意留绿),断言反过来,并把所有拼写(inmemory / in-memory / mingo / 大小写 / 两侧空格)一起钉住——它们 resolveDriverId 到同一个驱动。模块注释里指名本单的那段同步改写为「洞已闭」,并记下裁决顺带立的姊妹臂先例。

行为变化

driver: 'memory' + 非空 pool静默吞掉变成在到达的那扇门上抛错。删掉 pool 块即修好,且不损失任何东西——它此前配置的就是「无」。空 pool: {} 与不写 pool 的行为完全不变,memory 无 pool 照常构建(persistence: false#4083 形状原样保留)。

全仓 + examples/ 扫过:没有任何一处声明同时带 memorypool,兄弟仓(objectui / cloud)既不消费这个 helper 也没有这种声明。所以这是把一个可写、会被吞掉的 authoring 面关掉,不是打断谁今天在跑的东西。

验证

pnpm --filter @objectstack/service-datasource test      12 files / 244 tests passed
pnpm --filter @objectstack/service-datasource typecheck  tsc --noEmit 干净
pnpm --filter @objectstack/service-datasource build      成功
pnpm --filter @objectstack/runtime test                 105 files / 1506 tests passed
pnpm --filter @objectstack/cli test                      89 files /  902 tests passed
pnpm check:nul-bytes / check:engine-double-contract / check:empty-changeset   OK
eslint(改动文件)                                        0 problems

datasource-pool-support.test.ts 从 29 例增至 40 例。跨包扫的是规则的消费半径而不是被改的包:runtimecli 是真正会走 boot 预检那扇门的下游,所以整包跑了。

反向验证(先定方向再跑):集合成员被拒绝谓词读取,所以预期方向是——把 memory 从集合里撤回,11 条新钉全红,失败信息正是该有的样子(expected [ 'sqlite', 'sqlite-wasm' ] to deeply equal [ 'memory', 'sqlite', 'sqlite-wasm' ]promise resolved instead of rejecting 等);同时类型闸也从另一头响了——'memory' does not exist in type Readonly< Record< "sqlite" | "sqlite-wasm", string > >,证明解释表的键控约束双向都拦得住。撤回操作已还原,未进入本 PR。

范围

按派发红线执行:

changeset:@objectstack/service-datasource patch。取 patch 而非 #5954 的 minor,是因为本次没有新增任何导出——POOL_UNSUPPORTED_DRIVER_IDS / driverReadsDeclaredPool / unsupportedPoolIssue / unsupportedPoolMessage / assertDatasourcePoolSupported 签名一律照旧,只是集合多了一个成员、消息多了一个分支。#5954 当时是 minor,因为那一版新建了这批公开 API。


Generated by Claude Code

…honour (#5931)

#5714 made an unhonourable `pool` block a loud authoring error, but its ruling
was scoped to the two sqlite arms — the `memory` arm kept dropping it. It hands
`InMemoryDriver` nothing but `buildMemoryConfig(spec)`, which reads `spec.config`
and never `spec.pool`, so a sized pool reached nothing and said nothing.

`memory` now joins `POOL_UNSUPPORTED_DRIVER_IDS`, so all three doors that already
rejected sqlite reject it: the Setup wizard's create/update, the boot-time
auto-connect pre-pass, and the driver factory itself.

Its own explanation, not SQLite's, per the maintainer ruling of 2026-08-07:
SQLite is rejected because a second connection to `:memory:` opens a separate,
empty database, which would split one datasource across several stores. That
reasoning is false for `memory` — there is no connection at all — so reusing it
would send the author looking for a connection-strategy knob that does not
exist. Reasons are keyed by driver id, which makes an arm joining the set
without writing one a type error. The sqlite arms' text is byte-for-byte
unchanged (pinned whole).

The pin #5954 deliberately left green (`leaves 'memory' out of the rejected set
(#5931), deliberately`) is flipped rather than deleted — the same fact,
re-judged — and the module note that named this issue as a known, deliberately
drawn boundary now records the hole as closed.

Out of scope, by the dispatch's red line: the spec half of the ruling (the four
driver-qualified `pool` rows in `packages/spec/liveness/datasource.json`) goes to
the spec seat on its own issue.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015a5qkLzpGXhLL2F5gvJ7dD
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 7, 2026 11:30am

Request Review

@github-actions github-actions Bot added the size/m label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

No hand-written docs reference the 1 changed package(s). ✅

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling labels Aug 7, 2026
@hotlong
hotlong marked this pull request as ready for review August 7, 2026 11:41
@hotlong
hotlong added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit 01faeb1 Aug 7, 2026
24 checks passed
@hotlong
hotlong deleted the claude/issue-5931-memory-pool-reject branch August 7, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

datasource pool 声明在 memory 驱动臂同样被静默丢弃(#5714 的姊妹臂,裁决未覆盖)

2 participants