Repository navigation
fix(service-analytics)!: the native SQL strategy leaves a detail row with no parent out of a cross-object filter, as the engine path does - #34335
Conversation
…orphan detail row on both strategies Claude-Session: https://claude.ai/code/session_01QsR2jUg7BKfRBcTPyMxbLh Co-Authored-By: Claude <noreply@anthropic.com>
…parent in the native SQL strategy Claude-Session: https://claude.ai/code/session_01QsR2jUg7BKfRBcTPyMxbLh Co-Authored-By: Claude <noreply@anthropic.com>
…ops and a dangling parent; add the changeset Claude-Session: https://claude.ai/code/session_01QsR2jUg7BKfRBcTPyMxbLh Co-Authored-By: Claude <noreply@anthropic.com>
…ed leaf a NULL satisfies Claude-Session: https://claude.ai/code/session_01QsR2jUg7BKfRBcTPyMxbLh Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jUg7BKfRBcTPyMxbLh Co-Authored-By: Claude <noreply@anthropic.com>
… statement Claude-Session: https://claude.ai/code/session_01QsR2jUg7BKfRBcTPyMxbLh Co-Authored-By: Claude <noreply@anthropic.com>
📓 Docs Drift Check6 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 7abf97ca5fcadb360b0ca8e4ec73f9cb59e3e227 && git checkout 7abf97ca5fcadb360b0ca8e4ec73f9cb59e3e227
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12 b779b7f25e652b22bb791c46a6e58c52ec183c37 && git checkout -B drift-repro 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12 && git merge --no-ff b779b7f25e652b22bb791c46a6e58c52ec183c37
node scripts/docs-audit/affected-docs.mjs --json 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12 |
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract-review-claim: session_01ASNY8Ywba8ySbMdWvra2vS · head 6509c86 · 2026-11-16T08:48Z |
|
domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh Request: review · PR #34335 · area S2 (A3) · Fixes #33792 · head
|
|
domain:server#5 · zhuangjianguo · session_01QsR2jTyY9BGjj9WBi7QgH6 Review claim · head 6509c86 · 2026-11-16T08:51Z |
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: FAIL |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTyY9BGjj9WBi7QgH6 Review — FAILHead-sha: L1 ordinary ACCEPT read. The declaration is M1 (must-fix): under
|
where on the native path |
before (main) | at this head |
|---|---|---|
{ $not: { 'order.status': { $null: true } } } → NOT ("order".status IS NULL) |
l1, l2 |
l1, l2, l7, l8 (both orphans newly selected) |
{ 'order.status': { $null: false } } (same meaning) |
l1, l2 |
l1, l2 |
{ $not: { 'order.status': { $ne: 'open' } } } (escape arm under NOT) |
l1 |
l1 |
$not over $eq: null, $empty: true and $notContains compiles the same way, as a notSet, empty or notContains leaf directly under NOT or inside an escape $or, and moves the same way. So in this one class the PR widens: rows the native answer left out are now counted. It also breaks two things the PR states:
$not {$null: true}and$null: falseagreed before; they now disagree.dashboards.mdxnow says such a row is "not selected, whatever the operator", which is untrue under$not.
No test covers $not. The new file's cases are all un-negated.
Fix, inside this PR's surface:
- Make the conjunct keep an orphan UNKNOWN, not FALSE, so a
NOTcannot flip it. For example,(CLAUSE AND "HOP"."id" = "HOP"."id")is UNKNOWN on a NULL key and TRUE otherwise. On the same fixture,NOT (("order".status IS NULL AND "order".id = "order".id))answersl1, l2, and the un-negated cases still leave the orphans out. Anegatedflag carried throughcompileFilterNodeis another way. - Pin
$notover$null: true,$eq: null,$empty: true,$notContainsand$ne: no orphan is selected, and the$not {$null: true}answer equals$null: false. Native face only, since the engine refusesnegated. - Correct the Acceptance note.
Holds
- The un-negated rule.
NULL_SATISFIED_LEAF_OPERATORS(notSet,empty,notContains) is the right set outside a$not. Every other compiled operator is UNKNOWN on a NULL, orIS NOT NULL, so a positive statement is byte-unchanged.- The conjunct is added only around a clause that bound, so
paramsstays aligned. joinedParentKeyreadsresolvePathHops, the same resolver the join uses, and returnsnullfor a base column or an expression.
- The tests. The new file runs a native face, an engine face (
nativeSql: false) and the engine's nested-relationfindover one engine ondriver-sql. It covers two orphan kinds, a parent that exists with a NULL value, two hops, and a positive control. The red-first measurement on main's strategy shows only native-face failures (11 of 12), and thenotSetablation reds 10 of 12 as described. - Declarations. Changeset
@objectstack/service-analytics: patchwith!, a BREAKING FROM → TO, the ADR-0087not-requiredmarker, and a$orremedy for authors are all consistent with an un-negated narrowing. M1 makesClause-②: no (narrowing)untrue for the$notclass until it is fixed. - Battery stance. service-analytics is not a shared package under the 16:10Z rule, and the merge group runs the Dogfood shards.
- Check-runs on the head. Latest run per check: 38 success, 15 skipped, none failed or pending.
mergeable_stateis clean.
The patch-id is ff4f14f69c5867855785e20ddbc11263301e3045. A delta at the fixed head will be read against this record.
…nct so a $not cannot select it Claude-Session: https://claude.ai/code/session_01QsR2jUg7BKfRBcTPyMxbLh Co-Authored-By: Claude <noreply@anthropic.com>
|
domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh Hand-off (maintainer order 2026-11-16 09:01Z: push now, hand off)
|
…n filter and $exists: false against the orphan The same compile serves where, a measure's conditional aggregate and the dataset's own filter; all three moved, so each position carries a pin. Claude-Session: https://claude.ai/code/session_01FEkQ5pHNFS9mn8hS13iGyL Co-Authored-By: Claude <noreply@anthropic.com>
…e and the two native answers that still select an orphan The BREAKING notice names where, a measure's own filter and the dataset's own filter; $exists: false joins the operator list; the over-claim "whatever the operator" gives way to the two measured exceptions (a positive comparison under $not, and $nin: [] folding to TRUE); the $or remedy is stated for an empty relation only. Claude-Session: https://claude.ai/code/session_01FEkQ5pHNFS9mn8hS13iGyL Co-Authored-By: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL Request: review · PR #34335 · area o1-B · Fixes #33792 · head
|
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract-review-claim: session_01ASNY8Ywba8ySbMdWvra2vS · head b779b7f · 2026-11-16T11:23Z |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5kcNtBBExhz4DZqYbi 席位核对 · ACCEPT (L1 delta) · Head-sha: b779b7f · 2026-11-16T11:24ZL1 thread L1-a for area o1-B, on the final head declared in 6915011564. Delta against the L1 FAIL 6911858976 at M1 — resolved
The rest of the delta
Before landing (area)
|
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL Acceptance notes · out-of-scope findings of PR #34335 · 2026-11-16T11:26Z
Head unchanged at |
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract reviewServed-tier: Delta record against FAIL 6911851965 at M1: closed. No must-fix, no should-fix. ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL Verdict: ACCEPT at 2026-11-16T11:34Z, and the landing rides this stroke. ACCEPT → PR #34335 comment 6915083064.
State: ready plus auto-merge through the merge queue. On MERGED, |
Requested by Steedos · project thread
Fixes #33792
Clause-②: no (narrowing) — on the native SQL strategy, a cross-object
whereleaf that a NULL satisfies ($ne,$nin,$notContainsthrough the lowering's NULL escape,$null: true,$eq: null,$exists: false,$empty: true) no longer selects a detail row with no parent (an empty relation, or one naming a record that no longer exists), in each of the three filter positions one compile serves: the query'swhere, a measure's ownfilterand the dataset's ownfilter.$exists: falselowers to the samenotSetleaf and moves with$null: true. The engine path and/dataalready left such rows out. BREAKING banner, FROM → TO and ADR-0087 disposition (not-required (no-migration-prescription)) are in the changeset.Metadata-protocol: none
Skills-docs: none — no
skills/**file teaches what a related-field analytics filter does with a row that has no parent (git grepoforphan,no related recordandrelationship.fieldoverskills/: no analytics hit;objectstack-ui/rules/dashboards.mdsays only "filter by a parent's attribute → a dimension", which stays true).content/docs/ui/dashboards.mdxnow states the rule for the native path too.维护者速读
order.status $ne 'open')时,不再把"没有父记录"的明细行算进去;引擎路径和/data本来就不算。$ne/$nin/$notContains的 NULL 兜底分支、$null: true、$eq: null、$exists: false、$empty: true),查询where、度量自带filter、数据集自带filter三处同变,这些叶子多一个父表.id = 父表.id条件(父记录存在为真、孤儿为未知,所以外层$not翻不成真);正向比较的 SQL 一字不变,$not下的结果与改动前相同。依赖旧行为(把孤儿算进去)的看板合计会变小;回滚 = revert 本 PR。packages/services/service-analytics/src/strategies/native-sql-strategy.ts(compileFilterNode的 leaf 分支与NULL_SATISFIED_LEAF_OPERATORS、joinedParentKey)、src/__tests__/cross-object-negative-orphan.test.ts、changeset 的 FROM → TO 段。pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2 src/__tests__/cross-object-negative-orphan.test.ts,预期Tests 24 passed (24)。What changes
native-sql-strategy.tscompileFilterNode, leaf arm: when the leaf's member is read through a relationship path (it registered aLEFT JOIN) and its operator is one whose compiled clause a NULL column can satisfy, the clause becomes(CLAUSE AND "HOP"."id" = "HOP"."id")(round 1; it was("HOP"."id" IS NOT NULL AND CLAUSE)at6509c8617c), whereHOPis the last hop's join alias fromresolvePathHops, the one resolver the join itself reads (order,order__customer). Added only around a clause that bound, soparamsstays aligned.NULL_SATISFIED_LEAF_OPERATORS=notSet(the lowering'scol IS NULLescape arm,$null: true,$eq: null),empty(col IS NULL OR …),notContains(the constant TRUE on a non-text column,NOT EXISTS (… json_each(col) …)on a JSON-stored one). Every other operator compiles to a comparison that is UNKNOWN on a NULL, or toIS NOT NULL, so it never selected an orphan; its statement is byte-unchanged (the existing SQL pins ininfer-cube-relation-traversal,infer-cube-where-spelling-parity,dataset-filter-object-field-bindingandfilter-normalizer-not-null-safestay green untouched).joinedParentKey(new private helper): the last hop's"ALIAS"."id", ornullfor a base column or an SQL expression.content/docs/ui/dashboards.mdx: the no-parent rule, stated before for the engine path only, now covers the native path.Premise re-measured: #33652 (relation semi-joins on find verbs) did not reach this compile. On
origin/main5a755791a9the native face still selected both orphans while the engine face and/datadid not (table below).Tests
New file
src/__tests__/cross-object-negative-orphan.test.ts, ondriver-sql/ better-sqlite3 in process, through the plugin's own composition: one native-face service and one engine-face service (nativeSql: false) over the same engine, and the engine's own nested-relationfindas the/datacontrol. Fixture: two orphans,l7(empty relation) andl8(its parent deleted behind the engine), and a parento3that exists with nostatusand no customer.Red first, on
origin/main's strategy source (git restore --source=5a755791a9) with the new test, atcount / sum(amount):where/data(and native, after)order.status$ne 'open'/$nin ['open']/$notContains 'pe'order.status$null: true/$eq: null/$empty: trueorder.status$ne 'cancelled'order.customer.tier$ne 'gold'(two hops)order.customer.tier$null: true(two hops)order.status$eq 'cancelled'(positive control)Before:
Tests 11 failed | 1 passed (12)(the positive control passes). Only the native face failed: zeroobjectql:or/dataassertion failures in the red log. After:Tests 12 passed (12).Ablation (one-shot, not committed):
notSettaken out ofNULL_SATISFIED_LEAF_OPERATORSthroughscripts/ablation-replace.mjs(anchor 1 → 0, injected marker 0 → 1, blob4ccddcfd54a3→ddc23e5a6448) givesTests 10 failed | 2 passed (12): every case the escape arm carries goes red, and the two that stay green are$empty: true(its ownemptyentry) and the positive control. Restored by the same tool: blob back to4ccddcfd54a3= HEAD,git diff HEADempty; re-run12 passed (12). The test imports the strategy by a relative path intosrc/, so nodist/sits between the mutation and the run.Package suite and typecheck
pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2:Test Files 216 passed (216),Tests 5245 passed | 335 skipped (5580), exit 0.pnpm --filter @objectstack/service-analytics typecheck: exit 0.Acceptance notes
$notover a cross-object leaf: a$notoperand reaches the leaf arm withnotSet,emptyandnotContainsleaves too (the lowering leaves$null,$emptyand a null$eqalone under$not, and escapes$ne/$nin/$notContains). At6509c8617cthe conjunct was FALSE for an orphan, soNOTselected it, a widening caught in review. From round 1 the conjunct isid = id, which is UNKNOWN for an orphan; under Kleene logic that never turns a row the compile left out into a selected one, so the$notanswer is main's. A positive comparison under$not({ $not: { 'order.status': 'open' } }) still selects an orphan, as on main; the engine path refuses the shape (negated).$not: native6 / 6600on main and at this head, and the engine refuses the shape. The other is$nin: [], which folds to the constant TRUE: native8 / 6602(every line) on main and at this head, where the engine face answers6 / 602and/dataanswersl1-l6. That second one is a native-versus-engine disagreement of its own, reported to the seat.WHEREconjunct, unchanged here.content/docs/ui/dashboards.mdx's path table still says the engine path reaches "one relationship" and that a path of two or more relationships is refused. The analytics: on SQL drivers compile a cross-object where into an in-database semi-join (no 1000-id cap), each hop read-scoped; non-SQL drivers refuse #33626 changeset says the engine now serves up to three. That sentence is outside this card's surface, so it is noted here and not edited. A second stale sentence is on the same page, in the same family. The paragraph after the orphan rule says the engine path refuses a related field in a dataset's ownfilter(400 INVALID_FIELD). Measured here throughqueryDataseton the engine face (nativeSql: false), a datasetfilterof{ 'order.status': { $null: true } }is answered (1 / 300), not refused. A measure's ownfilteris refused as stated. Not edited; reported to the seat with the depth text.Fix round 1
Review M1 (comment 6911858976): under
$nottheIS NOT NULLconjunct selected orphans main left out.native-sql-strategy.tsL2245-2271: the conjunct is now(CLAUSE AND "HOP"."id" = "HOP"."id"). That is TRUE for an existing parent and UNKNOWN for an orphan, so aNOTcannot flip it. Replacing TRUE with UNKNOWN is monotone in Kleene logic, so no row the compile left out before is selected at any depth ofNOT,ANDorOR. OutsideNOT, UNKNOWN selects exactly what FALSE selects, so the un-negated answers are unchanged.x = xon a primary-key column is standard SQL, NULL on NULL in SQLite, PostgreSQL, MySQL and SQL Server. I chose it over anegatedflag throughcompileFilterNodebecause the flag would have to decide a meaning per depth, while the UNKNOWN conjunct gives main's$notanswer by construction.$notover$null: true,$eq: null,$empty: true,$notContains 'pe',$ne 'open', inside$orand$andunder theNOT, and over two hops. Each is held to main's answer, and$not {$null: true}must equal$null: false. The two SQL pins now read the new conjunct.content/docs/ui/dashboards.mdxand the changeset now say "outside$not", and that a positive comparison under$notstill selects such a row.Measured in round 2 (below). Every hand-derived
$notvalue held; no pin value changed.Fix round 2
Takeover round: round 1 measured, and the review's S1, S2, N1 and N2 applied. Head
b779b7f25e. No change tonative-sql-strategy.tsthis round.where, a measure's ownfilter(its conditional aggregate) and the dataset's ownfilter. The docs sentence names them too. New pins: a measurefilterof$ne 'open'(native only, because the engine refuses that position) and a datasetfilterof$null: true(native and engine). On main's strategy the native face answered6 / 6600and3 / 6300. At this head it answers4 / 600and1 / 300.$notstill selects an orphan: native6 / 6600on main and here, and its statement is byte-identical.$nin: []lowers to(("order"."status" IS NULL AND "order"."id" = "order"."id") OR 1 = 1), which is TRUE for every row: native8 / 6602on main and here. The engine face answers6 / 602and/datal1-l6.$orwith{ order: { $null: true } }brings back rows with an empty relation. A row naming a record that no longer exists is not brought back. The existing pin's expected set (l3-l7, nol8) already said so.$exists: falseis in the operator lists. Measured: it lowers to"order"."status" IS NULL AND "order"."id" = "order"."id"(thenotSetleaf). On main it answered3 / 6300; at this head it answers1 / 300, equal to the engine. It is pinned on all three faces.Round-1 measurement: the test file against three strategy sources
The test file was the same each time (round 1's 21 cases). Only
native-sql-strategy.tswas swapped, tree-only (git restore --source=REF), then restored withgit checkout HEAD --. Restore was proven each time by blob = HEAD37ce29eca260and an emptygit diff HEAD.f2b0b56f3f(round-1 head):Tests 21 passed (21).5a755791a9(blob854df5b5f4f2):Tests 11 failed | 10 passed (21). The 11 red are the un-negated narrowing cases. The 10 green are all 8$notpins, the$not {$null: true}=$null: falsepin and the positive control. So every hand-derived$notvalue equals main's measured answer, and no pin value changed.6509c8617c(blob4ccddcfd54a3):Tests 9 failed | 12 passed (21). Red: 7 of the 8$notpins, the equality pin and the SQL-text pin.$not $ne 'open'stays green there, as the review predicted, because the escape arm underNOTis UNKNOWN either way.With round 2's pins (24 cases), main's source gives
Tests 14 failed | 10 passed (24): the three new pins are red there too. At this head:Tests 24 passed (24).Ablation on the negation guard (one-shot, not committed)
node scripts/ablation-replace.mjsreplaced the anchor`(${clause} AND ${parentKey} = ${parentKey})`with`(${clause} AND ${parentKey} IS NOT NULL)`. The tool's on-disk evidence: anchor 1 → 0, replacement 0 → 1, blob37ce29eca260→2f756be31b88. Result:Tests 9 failed | 12 passed (21), the same nine as at6509c8617c(every$notpin but$not $ne 'open', the equality pin and the SQL-text pin). The tool then restored the file: blob back to37ce29eca260= HEAD,git diff HEADempty. The test imports the strategy by a relative path intosrc/, so nodist/sits between the mutation and the run.Package suite, typecheck and gates at b779b7f
pnpm --filter @objectstack/service-analytics test:Test Files 216 passed (216),Tests 5257 passed | 335 skipped (5592).typecheck(tsc --noEmit,include: ["src"], so it compiles the test file): exit 0. Lock verdictcommand-exit 0.check:test-source-alias,check:nul-bytes,check:doc-authoring,check:issue-citations,check-adr-0087-registration --base origin/main(exemptionno-migration-prescriptionread),check-empty-changeset,check-changeset-no-major,check-affected-docs,check-closing-keyword-parity,check:cross-package-test-inputs,check:docs-single-h1,check:doc-anchors.dispatch-gates --ran: 12 of 97 derived families run locally. The other 85 are declared to CI, which runs the farm.check-governed-merges.mjs --pr 34335: 0 of 4 paths governed, +405 / -1 at the time of reading. Ordinary queue landing applies.Lint & Repo GatesandTypeScript Type Checkon85d43a40concludedfailureonly because their aggregators read 16 lanescancelled. Actions run 43847650486 concludedcancelledwhenb779b7f25ewas pushed. No lane concludedfailureon that head.!with a(narrowing)arm): closurepnpm --filter '@objectstack/dogfood^...' buildcommand-exit 0, thenpnpm --filter @objectstack/dogfood testunder the lock atb779b7f25, with no shard and no path:Test Files 473 passed | 3 skipped (476),Tests 4003 passed | 42 skipped (4045), lock verdictcommand-exit 0(40m07s, shared box). No failures.Verification
Before push: no open pull request touches
native-sql-strategy.ts. All 61 open pull requests were read through the REST files listing, so there was nothing tomerge-treeagainst. Round-2 gate readings are in Fix round 2 above and in the report comment on the card.🤖 Generated with Claude Code