test(plugin-auth): where-operator 覆盖测试迁到 sqlite :memory: 见证;contains pin 实测不可迁,留证上报 (#5830) - #5880
Merged
Merged
Conversation
…te `:memory:` witness (#5830) #5704 的收口尾单的一半。#5812/#5844 在 #5704 survey 之后给 plugin-auth 带进了 两个新的 driver-memory 测试消费者;本 PR 迁走其中可以迁的那一个,并把另一个的 留存原因实测出来、写进注释,交维护者裁处置。 - auth-where-operator-coverage.test.ts:行为面后端由 InMemoryDriver 换成 @objectstack/driver-sql + better-sqlite3 `:memory:`,建表走 driver 自己的 initObjects()。#5813 的缺陷是「谓词被丢掉、filter 编译成 {}」,任何真正执行 过滤的后端都见证得到,已双向反验。 - plugin-auth 新增 @objectstack/driver-sql devDep;driver-memory devDep 暂留 (auth-contains-filter.test.ts 仍在用)。 - driver-split 的 Q2-B 注释按迁移后的真实事实修订(仅注释,零行为改动)。 tests-only,发布不可见,skip-changeset。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JwwiU9bjhwy2SWj13ho8uv
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 10 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This was referenced Aug 6, 2026
baozhoutao
marked this pull request as ready for review
August 6, 2026 11:05
This was referenced Aug 6, 2026
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.
Fixes #5830
背景
#5704 的程序是「driver-memory 在项目内的测试消费者迁到 sqlite 内存模式」,Q2-B 只留
undeclared-field-write-driver-split一处参照臂。#5812/#5844 在 #5704 survey(基线a58c0b5)之后给 plugin-auth 带进了两个新消费者。本 PR 迁走其中能迁的那一个,并把另一个留下的实测理由写进注释。验收证据:grep 前后
排除 driver-memory 包自身,
git grep -l "from '@objectstack/driver-memory'" -- 'packages/**/*.test.ts':BEFORE(
origin/main@e2bfa6ce3)—— 3 处AFTER(本分支)—— 2 处
派单预期是「只剩 driver-split 一处」。差的那一处不是漏做,是下面这条测量的结论。
前提验证:为什么
auth-contains-filter.test.ts不能迁packages/drivers/driver-sql/src/sql-driver.ts的算子编译里,$regex是$contains的 fallthrough 别名 —— 两者走同一个applyContainsLike:也就是说,SQL 后端分不出 #5710 的缺陷和它的修复。实测(两个后端、同一份 fixture、同样的 4 个比较数):
$containssqlite$regexsqlite$containsmemory$regexmemorya.b["a.b"]["a.b"]["a.b"]["a.b","axb"]^a[][][]["a.b","axb"](["x(y"]["x(y"]["x(y"]xb["axb"]["axb"]["axb"]["axb"]sqlite 两列逐格相同,memory 两列在前三格格格不同,而那三格正好就是该文件行为面的三条 pin。
再把派单第 4 条要求的反向验证按原样跑一遍 —— 把
objectql-adapter.ts的contains支临时改回裸$regex(即 #5710 的缺陷):4 failed | 3 passed—— 契约面 1 条 + 行为面 3 条全红。Tests 4 passed (4)—— 全绿,缺陷仍在适配器里。所以迁移会把三条承重 pin 变成「因为分辨不出任何东西所以恒绿」的断言 —— 正是 fixture 三分法里「整条替换」那一类的反面教材。派单第 1 条的停手条件成立,故保留现状 + 把理由钉进注释,不硬做也不悄悄放着。
它什么时候能迁:等 #5702 落地。#5710 摘掉了
$regex的最后一个 live producer,上面那个case '$regex':别名已是死产者代码;一旦 driver 侧改成按名拒收$regex,SQL 臂就能以「算子不在 allowlist」的方式见证同一个缺陷,该文件即可迁移。本 PR 实际改了什么
1.
auth-where-operator-coverage.test.ts迁到 sqlite:memory:行为面(face 3)后端换成
@objectstack/driver-sql+ better-sqlite3:memory:,抄 PR #5806 batch 3 的现成写法,没有自创 harness;建表走 driver 自己的initObjects(),不是 store 首写时凭空长出来的。这个文件迁得动,同样是测出来的,不是假设:#5813 的缺陷是谓词被丢掉(filter 编译成
{},查询答成整表),凡是真正执行过滤的后端都见证得到;$nin/$startsWith/$endsWith都是FILTER_OPERATORS成员,driver-sql 都真编译(whereNotIn,以及带显式ESCAPE的applyLike)。pin 实质零缩水,双向反验:
not_in支改回静默丢弃(plugin-auth:convertWhere()对not_in/starts_with/ends_with没有分支,谓词被整条丢弃 —— 认证路径上的过滤放大 #5813 的原始形状)→4 failed | 23 passed,行为面报的正是整表:starts_with错译成$contains(拼得像、求值错)→6 failed | 21 passed,锚定语义和 count 都抓到了:Test Files 36 passed (36) / Tests 820 passed (820)。两处顺带的收敛,都是「靠声明解决,不是靠放松」(#5806 的做法):
emailVerified/createdAt/updatedAt三个驼峰键,没有任何断言读它们,也只有 schemaless store 才会收(sys_user拼的是email_verified/created_at/updated_at)。现在 fixture 收敛到它真正断言的两列。LIKE默认 ASCII 大小写不敏感,而$startsWith/$endsWith契约层敏感(spec:$regex按 ADR-0049 退役 +$icontains入算子词表与 FILTER_LOGIC_CASES(#4706 裁决 B 案 · 契约半边,先行) #5701 Q2=A)—— 和 driver-memory 的 mingo 走iflag 是同一笔账,归 drivers:$regex响亮拒收 +$icontains各后端实现(#4706 裁决 B 案 · 驱动半边) #5702 预算。没有新增任何依赖大小写收敛方向的断言,规避策略与原文件一致。delete双件仍以assertEngineDeleteDispatch(options)开场,原样保留(check:engine-double-contract绿:38 pinned)。2.
plugin-auth/package.json新增
@objectstack/driver-sqldevDep。@objectstack/driver-memorydevDep 暂留 ——auth-contains-filter.test.ts还在用它;它随该文件的裁决一并摘除。3. driver-split 的 Q2-B 注释(仅注释,零行为改动)
原句 "the ONLY place in the repository that still consumes it from a test" 改为按迁移后的真实事实叙述:它是唯一的长期消费点,并补记 #5812/#5844 带进来的两个临时消费者各自的去向与理由。
必答项:是否影响 #5702 的预算或前提?
不影响预算,并且给它的前提补了一条实测。
$regex响亮拒收 +$icontains各后端实现(#4706 裁决 B 案 · 驱动半边) #5702 的两件事 —— driver 侧$regex按名拒收、$contains/$startsWith/$endsWith大小写对齐 —— 一行都没提前做,也没绕过。$regex响亮拒收 +$icontains各后端实现(#4706 裁决 B 案 · 驱动半边) #5702 怎么裁都不会撞上本 PR 的断言。sqliteLIKE的 ASCII 不敏感与 memory mingo 的iflag 是同一笔账的两个面,drivers:$regex响亮拒收 +$icontains各后端实现(#4706 裁决 B 案 · 驱动半边) #5702 的口径应当把 SQL 族一并覆盖。$regex拒收那半:本 PR 测出sql-driver.ts里case '$regex':落到$contains的别名,在 plugin-auth: better-auth 的contains被译成裸$regex,用户输入当正则求值 —— 且是$regex退役唯一挡路的生产者 #5710 摘掉最后一个 live producer 之后已是死产者代码。建议 drivers:$regex响亮拒收 +$icontains各后端实现(#4706 裁决 B 案 · 驱动半边) #5702 的清理范围把它一并纳入 —— 那不只是清理,它还是auth-contains-filter.test.ts能迁移的前置条件([finding] #5704 收口后仓内新增一个 driver-memory 测试消费者:plugin-auth/auth-contains-filter.test.ts(#5710 pin 测试,与 #5704 程序不变量的张力,请分诊裁处置) #5830 的开放一半因此Blocked-by: #5702)。测试
tests-only + 注释 + devDep,发布不可见 —— tests-only, skip-changeset requested,未提交空 changeset,
skip-changeset标签以并集方式自行写入并读回确认。Generated by Claude Code