fix(service-analytics): 空 $and/$or 按布尔单位元归约,两个编译器对齐五后端,四条进一致性表 (#5322) - #5365
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ErbEDVAg1No9gdg1pgDAGB
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ErbEDVAg1No9gdg1pgDAGB
…ty-combinator-identity # Conflicts: # packages/services/service-analytics/src/strategies/filter-normalizer.ts # packages/services/service-analytics/src/strategies/native-sql-strategy.ts # packages/services/service-analytics/src/strategies/objectql-strategy.ts
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ErbEDVAg1No9gdg1pgDAGB
…ty-combinator-identity
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 109 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
pushed a commit
that referenced
this pull request
Aug 5, 2026
本 PR 的 spec 半边是契约文档,机械合并会把 base 时代的论断带上 main; 逐条对当前 origin/main 实测后校订: - FilterConditionSchema 的 NULL-safe $not 合规段:read-scope-sql 已由 #5326 对齐(#5297 关闭)、filter-normalizer 已由 #5335 对齐(#5325 关闭),七个面全部一致 —— 「尚未合规、指向 #5297」改写为已闭合的事实。 - 「Deliberately NOT declared here」:空组合子单位元由「两立场对峙、 上交 #5322」改为「#5322 已拍板取单位元,实施在 #5365(排在本 PR 之后 合入);main 上两个 analytics 编译器今天仍拒收,故本 PR 仍不在此声明, 声明随 #5365 翻正」;{ field: {} } 由「无后端设闸」改为「#5327 已闸 四家,driver-mongodb 是唯一还在作答的后端(#5376)」。 - filter-logic-conformance.ts 族 2/3 状态行同步重测:族 2 的后端阻塞 已清零,唯余 fixture 工作;族 3 的四家闸门已落,阻塞改为表形扩展 + mongodb(#5376)。族 1 段落一字未动 —— 由 #5365 在其同步轮删除, 已约定分工。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ErbEDVAg1No9gdg1pgDAGB
…ty-combinator-identity # Conflicts: # packages/services/service-analytics/src/strategies/filter-normalizer.ts
- filter.zod.ts:按 #5323 同步散文预留的交接("The declaration flips to stated contract with that PR"),空组合子单位元从「Deliberately NOT declared」段转为正式契约段;{field:{}} 半边保持未宣告(#5376 仍开)。 - filter-refusal-envelope.test.ts(#5366 新到):空数组两行从 REFUSALS 翻入 ACCEPTED(单位元树断言),同一守卫点的非数组拼写补位 REFUSALS,信封不变。 - filter-logic-conformance.ts:族 1 段落按分工删除(四行已进表),族 2/3 原样。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ErbEDVAg1No9gdg1pgDAGB
Contributor
Author
|
收官同步完成(#5323 合入 main 后的最后一轮,head
保持 draft,PM 侧接手 ready + queue。 Generated by Claude Code Generated by Claude Code |
os-zhuang
marked this pull request as ready for review
August 5, 2026 03:52
os-zhuang
enabled auto-merge
August 5, 2026 03:52
…补位 400 REST 层是 #5352 refusal pin 的第三份拷贝(service-analytics 两份已翻)。 harness 的 executeAggregate 从常量改为按引擎侧 filter 求值,四条单位元 断言(空 $or 零行、空 $and 全部行、{$not:{}} 零行、{} 析取项吸收) 因此承重 —— 200 之外还钉行数,与被丢弃的 filter 可区分。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ErbEDVAg1No9gdg1pgDAGB
This was referenced Aug 5, 2026
Merged
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 #5322
拍板依据
2026-08-04 维护者拍板(#5322 评论):采纳主案 取布尔单位元,service-analytics 两处对齐。publish/lint 编写期对字面量空组合子的响亮拒收另立 #5330,⛔ 不在本单范围。按 spec 车道链序,本 PR 排在 #5323(driver-mongodb 归约)之后合入。
前提复核 — 两轮实测矩阵(sql.js 逐行执行,非推断)
issue 正文矩阵是 @
175d789的,已过时。实测两轮:第一轮(base
f1cc3a316):read-scope-sql 的后两格已由 #5297/#5326 修复;normalizer 四格全错。第二轮(#5335 于 00:00Z 合入 main 后重测,base
c89d18c16)——#5335 把 normalizer 的后两格也修了:{$and:[]}{$or:[]}{$or:[{a:'x'},{}]}{$not:{}}read-scope-sqlfilter-normalizer结论:前提成立但范围收窄 —— 剩余工作是两个编译器的空数组单位元(第 1、2 格)+ 双侧 pin 翻向 + 四条进表。#5335 的三个重叠文件按「取 main 的
const节点体系」解决冲突,我此前自研的{kind:'false'}方案整体弃用,最终 delta 收敛为 9 文件。修后矩阵:两编译器 × 四格与期望列逐格一致(全部行/零行/全部行/零行)。
改动
read-scope-sql.tscompileNode:空数组从抛错改为单位元 —— 空$and不产出约束(TRUE),空$or产出FALSE_CLAUSE(1 = 0,零行)。非数组仍抛错(消息从 "requires a non-empty array" 改为 "requires an array")。与$not的语义在 driver-sql 与 driver-memory / formula 之间分叉:NULL 行的去留相反,$not: {}一个是 TRUE 一个是 FALSE #5146/fix(service-analytics): read scope 的{ $not: {} }不再整表放行,$not改为 NULL-safe (#5297) #5326 NULL-safe 重写的组合语义 = 先归约、后 NULL-safe:nullSafeNegationOperand对组合子数组逐元素映射(空数组原样通过、{}叶子无字段可守卫),归约出的常量不受重写影响,幸存叶子照常加守卫 —— 有专门测试钉住。filter-normalizer.tsbuildNode:同一单位元,落在 fix(service-analytics)!: 作者的where也 NULL-safe ——$not下推守卫、{$not:{}}为零行、{}析取项吸收$or(#5325) #5335 的const节点体系上(空$or→falseNode())。fix(service-analytics)!: 作者的where也 NULL-safe ——$not下推守卫、{$not:{}}为零行、{}析取项吸收$or(#5325) #5335 的形状拒收(非数组/非对象分支/非对象$not操作数)原样保留 —— 归约让「无约束」成为有意义裁决,把畸形分支静默读成 TRUE 会吸收$or放宽查询。read-scope-sql.test.ts:86、read-scope-not-null-safe.test.ts的 4 连抛错 pin、fix(service-analytics)!: 作者的where也 NULL-safe ——$not下推守卫、{$not:{}}为零行、{}析取项吸收$or(#5325) #5335 新增的filter-normalizer-not-null-safe.test.ts「空组合子在同仓有两个对立答案:五个后端归约成布尔单位元,service-analytics 的两个编译器 fail-closed 抛错 —— #5239 的一致性表四条因此进不了表 #5322 is its own ruling」pin 块,全部翻向单位元断言;原错误消息("An empty combinator has no defensible reading…")的历史交代与翻向理由写进各 docblock,引用 空组合子在同仓有两个对立答案:五个后端归约成布尔单位元,service-analytics 的两个编译器 fail-closed 抛错 —— #5239 的一致性表四条因此进不了表 #5322 拍板。FILTER_LOGIC_CASES补空$and/空$or/{}析取项吸收/{$not:{}}四行,自此两个 analytics conformance suite + 五后端被同一张表钉住这四格。read-scope-sql-conformance.test.ts的WHERE ${sql}拼接补上'' = TRUE的生产语义(与applyReadScope一致)。empty-combinator-identity.test.ts:树级归约 pin(const节点、吸收、notOf折叠)、引擎路径接缝(FALSE 以{$not:{}}真实到达executeAggregate,而非「什么都不发」)、非数组仍响亮的守卫 pin。service-analytics+spec均 patch,写明迁移含义(从抛错变为求值、{$or:[]}在 RLS 下 fail-closed)。验证(全部在 merged main 态,
flock串行)反向验证 —— 方向先预测、两轮如实记录
第一轮(pre-#5335 base):预测还原两侧源码后 23 红,实测 23 红/预测逐条命中;其中
read-scope-sql-conformance四条新行只红 2({}吸收与{$not:{}}在 main 已被 #5297/#5326 修复,保持绿)—— 与派发模板预设的「四条全红」不同,方向如实记录。第二轮(merged #5335 后重做):预测 19 红(native-sql conformance 从 4 红缩为 2 红,因 #5335 已覆盖后两格),实测 19 红/预测逐条命中,分布逐文件一致。
driver-mongodb:「预期红」在本容器不可观测,如实说明
派发词预告本地 driver-mongodb 四条会红(#5323 未合入)。实测本容器全绿,且这不是覆盖达成:translation 侧 suite 用进程内 matcher 把译文 document 桥接到行 id,而该 matcher 建模的是 MongoDB 的文档求值语义(
$and:[]→.every= true,$or:[]→.some= false)——真实服务端对空数组是整条查询拒绝(must be a nonempty array),只有需要真 mongod 的mongodb-filter-logic-conformance.test.ts半边能观测到,而本容器取不到 mongod 二进制(125 skipped)。因此:在能取到 mongod 的 CI 上,本 PR 的四条新行会在该 suite 红,解除条件 = #5323 合入(其归约让服务端半边转绿)。这正是 #5323 PR body 第 2 节记录的依赖方向,不在本单修复。合并次序与 #5323 的文件交叠
#5323 与本 PR 都动
packages/spec/src/data/filter-logic-conformance.ts:#5323 在头部 docblock 记「三族已裁定未进表」注记,本 PR 在 cases 数组加四行 —— 区域不同,git 可干净合并。#5323 先合后,本 PR 随车道 rebase 时需做两件小事(留给接力方或届时我方处理):$and/$or/$not归约成布尔单位元,非 filter 节点先响亮拒收 (#5239) #5323 在filter.zod.ts写的「Deliberately NOT declared here」段中空组合子一句,可改为正式声明(两端已 enforced,declared ≠ enforced 顾虑解除)—— 属可选跟进,不阻塞。范围外
$not有两处与 SQL 驱动分叉:非 NULL-safe(#5146 后的最后一个异类),且{ $not: {} }编译成空 → RLS 整表放行 #5297 在 normalizer 侧的 NULL-safe 已由 fix(service-analytics)!: 作者的where也 NULL-safe ——$not下推守卫、{$not:{}}为零行、{}析取项吸收$or(#5325) #5335 完成,本 PR 未触碰其语义,仅在其const体系上叠加空数组单位元。🤖 Generated with Claude Code
https://claude.ai/code/session_01ErbEDVAg1No9gdg1pgDAGB
Generated by Claude Code