refactor(drivers)!: memory / mongodb 的 aggregate / distinct 收进 DriverQuery (#6212 批 C) - #6356
Merged
Merged
Conversation
…Query (#6212 批 C) #6210 的 changeset 结尾专门留了一句:aggregate / distinct 不在那次范围内, 因为它们不是 IDataDriver 收窄的那六个方法。#6212 记下了这笔账,本次结清 memory 与 mongodb 两个包的部分。 四处签名收窄(第一实参已经是对象名,query 里不再要求写第二遍): mongodb aggregate QueryAST -> DriverQuery(并删无用 import) memory distinct QueryInput -> DriverQuery memory aggregate [] | QueryAST -> [] | DriverQuery(保留联合) memory performAggregation Omit<QueryInput,'object'> -> DriverQuery memory.aggregate 的联合刻意保留:两支都有活体生产者 —— mongo 管线支由 memory-analytics.ts 喂,AST 支由 objectql 引擎与 @objectstack/verify 的日期 分桶探针喂。 证伪了 #6212 正文的一处归因:正文说 performAggregation 当初选 Omit<QueryInput,'object'> 是被 groupBy 的元素类型差异逼的。实测 QueryInput 与 QueryAST 在 groupBy 上逐字相同,差异只在 search/orderBy/expand;直接换 DriverQuery 零报错。契约优先取 DriverQuery,不再引入第二个查询类型家族。 零运行时改动:非测试改动 100% 是类型注解,无逻辑、无行为、无 emit 差异 (as 断言编译期即抹除)。这是 #5499 冻结面上被允许的处置口径,与 #6210 在同 一批驱动上走的是同一条。 两个门禁: - check:query-options-erasure 的测试面 267 -> 263(收窄让 4 处 as any 变多余, memory 2 + mongodb 2),已按门禁要求同 PR --update 提交 baseline; - check:type-check-debt 全仓 re-measure 通过。同时把 driver-mongodb 的 TEST_DEBT 从 43 ratchet 到实测 10:那 33 条 TS2345 是 PR #6210 消掉的(在 d367f03^ 实测仍是 43,组成与旧 note 逐字吻合),ledger 一直没跟着降。这不是 纯记账 —— mongodb 的 tsconfig 排除测试层,本次 aggregate 收窄的唯一消费者就 在那些被排除的测试里,把签名改回 QueryAST 实测是 12 条,43 的余量会把它整个 吞掉;降到 10 之后该反向验证才真的变红。 新增 memory-driver-query-narrowing.test.ts:pin 全部挂在对被收窄方法的真实调用 上,不挂 `const x: DriverQuery = …` 字面量 —— 后者在签名回退后依旧是绿的 (DriverQuery 本来就没有 object),正是 #5018/#4984 付过学费的死 pin 形状。 Part of #6212 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WyvqvKMG6asi9aXjKE6xtx
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 9 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
August 7, 2026 15:06
os-zhuang
enabled auto-merge
August 7, 2026 15:07
lemonhub-io
pushed a commit
to OpenFork-org/objectstack
that referenced
this pull request
Aug 8, 2026
…base cannot answer (objectstack-ai#6452) (objectstack-ai#6461) `resolveSurfaceBase()` fell back to origin/main's TIP whenever `merge-base HEAD origin/main` failed. Under a tip anchor "main added a key after this branch forked" and "this branch deleted a key" are the same fact, so the gate reported the first as the second (objectstack-ai#6359: PR objectstack-ai#6356 touched no packages/spec file and was told it had deleted ui/BulkActionDef:requiredPermissions). The anchor moves; the verdict does not. When merge-base cannot answer, the baseline rev now comes from an upstream anchor rev and its keys are read out of git at that commit — never out of authorable-surface.base.json itself. The rev is accepted only when something the PR does not control vouches for it: demonstrated reachability, or origin/main's own committed copy of the anchor naming the same commit; otherwise the rev origin/main records is used. With no upstream anchor at all the tip is kept and the run says so, naming `fetch-depth: 0`. Also folds verifyCommittedSurfaceBase's open-coded ancestry read onto the shared `probeAncestry` (objectstack-ai#5370/objectstack-ai#5847), so git DECLINING to answer is no longer read as a verdict of "not an ancestor". Claude-Session: https://claude.ai/code/session_01AZgRyPVwi1jLb1mNNuUQ9o Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
Part of #6212 (批 C,清单锚点单保持 open)
#6210 的 changeset 结尾专门留了一句:
aggregate/distinct不在那次范围内,因为它们不是IDataDriver收窄的那六个方法。#6212 记下了这笔账,本 PR 结清 memory 与 mongodb 两个包的部分。⛔ 未碰 A/B/D/E/F。四处签名收窄
MongoDBDriver.aggregatequery: QueryASTquery: DriverQuery(并删已无用的 import)InMemoryDriver.distinctquery?: QueryInputquery?: DriverQueryInMemoryDriver.aggregateRecord< string, any >[] | QueryASTRecord< string, any >[] | DriverQueryInMemoryDriver.performAggregation(私有)Omit< QueryInput, 'object' >DriverQueryQueryAST/QueryInput都把object声明成必填,所以一个手上只有where的调用方叫不出这个类型的名字,只能伸手拿as any—— 连where/orderBy/limit的检查一起关掉。这正是 #5181 记过账的代价。memory.aggregate的联合已保留两支都有活体生产者,退役任何一支都会打断一条链路:管线支由
memory-analytics.ts喂,AST 支由 objectql 引擎与@objectstack/verify的日期分桶探针喂。已在源码里把这条写进注释。证伪了 #6212 正文的一处归因
正文说
performAggregation当初选Omit< QueryInput, 'object' >是被groupBy的元素类型差异逼的。实测不成立:QueryInput与QueryAST在groupBy上逐字相同,差异只在search/orderBy/expand;直接换DriverQuery零报错。所以那不是被迫的选择 —— 契约优先取DriverQuery,不再引入第二个查询类型家族。(与测量棒评论的结论一致。)冻结面口径
纯类型注解、零运行时行为、零 emit 差异(
as断言编译期即抹除),不属 #5499 冻的「缺陷修复与语义补齐的开发投入」;#6210 已按同一口径在同一批驱动上做过一次并合并。硬约束遵守:只改了签名类型 + 无用 import + 测试里与第一实参逐字相等的冗余object键(仅一处),没有任何一处需要动逻辑。刻意未改的:
aggregate里'Aggregate operation (QueryAST)'这条 debug 日志文案 —— 它是运行期字符串,改它就不再是零行为变化了。反向验证(方向先判后跑)
distinct退回QueryInputTS2322元组槽变never、裸{ where }字面量TS2345、TS2578未使用的@ts-expect-errormemory.aggregate退回QueryASTmongodb.aggregate退回QueryAST第三行是刻意预判为绿并如实记录的:mongodb 的
tsconfig.json排除*.test.ts,而该方法的唯一消费者就是它自己的测试 —— per-packagetypecheck根本看不见这次收窄。这不是"没写好",是门禁盲区本身,见下。两个门禁
1.
check:query-options-erasure—— 棘轮向下收窄让 4 处
as any变成多余(memory 2 + mongodb 2),删除后测试面267 → 263,门禁按规矩红。已同 PR--update提交 baseline(diff 恰好一行)。⛔ 全程零新增as any。2.
check:type-check-debt—— 全仓 re-measure 通过,并把 mongodb 从 43 ratchet 到 10这一条不是纯记账,请重点看:
TS1309x7 +TS2550x3),而 ledger 记 43;d367f03d6^(PR refactor(drivers)!: 五个驱动的 query 参数跟进 DriverQuery,休眠的类型谎言没有藏身处 (#6075) #6210 前一刻)实测正好 43,组成TS2345x33 + 上述 10,与旧 note 逐字吻合 —— 那 33 条是 refactor(drivers)!: 五个驱动的 query 参数跟进 DriverQuery,休眠的类型谎言没有藏身处 (#6075) #6210 收窄六个契约方法时消掉的,与本 PR 无关(本分支与 pristine tree 在2bc187641上都报 10);aggregate签名改回QueryAST得 12 条 ——12 < 43,旧天花板会把它整个吞掉;降到 10 之后同一反转实测报records 10 … now reports 12 (+2),门禁真的红了。其余 5 条 ℹ(service-storage / objectql / runtime / rest / mcp 可下调)是既存漂移、非本 PR 所致,未动。
测试
新增
memory-driver-query-narrowing.test.ts(152 行)。所有 pin 都挂在对被收窄方法的真实调用上,不挂const x: DriverQuery = …字面量 —— 后者在签名回退后依旧是绿的(DriverQuery本来就没有object),正是 #5018 / #4984 付过学费的死 pin 形状。该包 tsconfig 不排除测试层、且无TEST_DEBT条目,所以这些@ts-expect-error是真检查而非幽灵。mongodb 侧刻意没有写同形 pin:那里的测试不在任何 tsc program 里,写了就是 AGENTS.md
PINS_CHECKED警告的幽灵检查;它的钉子是上面那条 ratchet。mongodb 的 137 条 skipped 需要真实 mongod(#5517 起 opt-in),因此那两处
as any的删除是类型层证据,不是运行期证据 —— 如实说明。Generated by Claude Code