test(verify): 删掉 checkDateBucketParity / checkReadCoercion 全部调用点的 as never (#6354) - #6396
Merged
Merged
Conversation
…dCoercion call site (#6354) `@objectstack/verify` declares `BucketableDriver` / `CoercibleDriver` as structural doubles for the driver under test. Every call site in the repo cast the driver to `never` first, so the one thing the doubles exist to express — "this driver really does have that set of methods" — was never checked anywhere. Removes all 10 casts (6 dogfood parity, 2 turso parity, 2 dogfood read-coercion). Zero runtime change, zero new escape hatches. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WyvqvKMG6asi9aXjKE6xtx
…e-bucket-parity-as-never
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckNo hand-written docs reference the 0 changed package(s). ✅ |
os-zhuang
marked this pull request as ready for review
August 7, 2026 16:49
os-zhuang
enabled auto-merge
August 7, 2026 16:49
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 #6354
观察类(p3),不是缺陷。 运行期行为此前就完全正确:
checkDateBucketParity照常跑,date-bucket 一致性照常被验证(dogfood 520 全绿,改动前后一致)。本 PR 恢复的只是编译期的一致性检查,零运行时改动。前提复核:论断成立,但立单时的计数偏低
立单表里列了 3 个调用点。实测全仓是 10 个 —— 立单人的表只覆盖了「传真实驱动」的那几处,漏掉了同一文件里 5 个传假驱动(负向控制)的调用点,以及
checkReadCoercion的 2 处。packages/qa/dogfood/test/date-bucket-parity-conformance.test.tspackages/drivers/driver-turso/src/date-bucket-parity.test.tspackages/qa/dogfood/test/read-coercion-conformance.test.ts(同族,见下)漏掉的 5 处不是无关紧要的:负向控制那几个假驱动恰恰是最需要被替身检查的对象 —— 它们是手写字面量,最容易与替身失配,而
as never把它们全部放行了。全部 10 处一并删除,一个不留。基线
按派工单要求,基线取已合入 #6355(批 A+E+F)之后的
origin/main。本分支已 merge 到466bd9285,合并后的BucketableDriver.aggregate已是收窄后的形状(不再是unknown),全套验证在该基线上重跑了一遍。(说明:#6355 合入前我已用它的
date-bucket-parity.ts在本地先行复核过一次,结论与合入后一致 —— 收窄不改变结果,原因见下。)三处(实为十处)各自独立复核
turso 两处没有沿用 dogfood 的结论:driver-turso 是独立的 tsc program,跑的是它自己的
typecheck。没有任何一处报错。 派工单说「若某处去掉后真的报错,那个报错就是本单最有价值的产出」—— 本单没有拿到这个产出:替身与三个真实驱动(
SqlDriver/SqliteWasmDriver/TursoDriver)以及 5 个手写假驱动的形状本来就一致。10 个 cast 全是死的。为什么 #6355 的收窄不改变结论,值得写下来:接口里以方法简写语法声明的成员,其参数按双变比较,所以把
aggregate的 query 参数从unknown收到更窄的类型,并不会让一个原本满足替身的驱动变得不满足。这也正是 #6355 自己在注释里已经说明的那件事。「确实读到了新 d.ts」的证据(AGENTS.md §9)
绿本身不算数 —— dogfood / driver-turso 读的是
@objectstack/verify的构建产物dist/*.d.ts,读到陈旧的一份也会绿。所以先按派工单要求做了反向验证。方向先预判:往替身里塞一个真实驱动不可能有的成员,10 个已去 cast 的调用点应当全部变红。 临时给两个替身各加一行
__freshnessProbe(): void;,重新 build@objectstack/verify,再 typecheck 两个消费方:8 + 2 = 10,与删掉的 cast 数一一对应。 这同时证明了两件事:消费方读到的确实是刚 build 出来的新 d.ts(不是假绿),且每一个调用点现在都真的在受检 —— 不是「没报错」,是「检查活着且会咬人」。探针已还原,
dist中__freshnessProbe命中数已回到 0。顺带一项:
checkReadCoercion已并入(派工单授权)派工单点名要实测
CoercibleDriver是否同形。实测:同形。它就是BucketableDriver去掉aggregate和supports,2 个调用点同样全是as never,同样全是死 cast(上面的探针实验里这 2 处也一并变红)。改动 2 行,判定「同形且改动微小」,按派工单授权并入本 PR。硬约束自查
零新增逃逸口。 全 diff 只删不加:
未碰
content/docs/releases/;未碰 driver-memory / driver-mongodb(#5499 冻结);未碰packages/spec。门禁
关于 erasure 棘轮,有一处要如实说明:派工单预判「本单删 cast,测试面可能下降而变红」。实测没有下降,计数 267 未动。 原因是该棘轮的词汇表只匹配 query/options 参数上的
as any(及as any as X洗白链),不包含as never,三个改动文件也都不在它的 baseline 里(各 grep 命中 0)。所以不需要--update,也不应把它说成本次改动的回归护栏 —— 事实是:目前没有任何门禁会阻止有人把as never加回去。测试
均在合并后的基线上重跑。运行期行为与改动前完全一致 —— 本来就应该一致,这是纯类型改动。
消费半径
@objectstack/verify的下游(前缀点...pkg)实测只有@objectstack/dogfood与@objectstack/driver-turso两个包引用这两个导出,两处都在本 PR 内。顺带发现(已另立单,不在本 PR 修)
as never—— 在driver.create的 options 门上,与 #6354 不同门 #6394:同一个 turso 文件第 68 行{ bypassTenantAudit: true } as never—— 也是死 cast(实测去掉后 driver-turso typecheck 依旧 exit=0),但它是driver.create的 options 门、不是本单的替身调用点,按 PD chore: version packages #10 另立单,不扩大本 PR 的 diff。🤖 Generated with Claude Code
https://claude.ai/code/session_01WyvqvKMG6asi9aXjKE6xtx
Generated by Claude Code