Skip to content

analytics: the ObjectQL strategy refuses a cross-object filter ("cb_order.status"), so a dashboard over detail rows cannot exclude rows of cancelled parents #33335

Closed

Description

@os-bob

Found while landing steedos-labs/os-project-blackcat-crm#116 (PR #118) on the published 18.4.0 packages. The ObjectQL lines below are unchanged on main at 87330e89.

Symptom

A dashboard over child rows cannot exclude rows by a status on their parent. The downstream app's Order Margin dashboard and Allocation by Plant tile read allocation plans and plan lines. Both must leave out plans of cancelled orders, which means filtering on the order's status.

The dataset query with that filter:

POST /api/v1/analytics/dataset/query
dataset: cb_plan_metrics
runtimeFilter: { plan_kind: 'recommended', 'cb_order.status': { $ne: 'cancelled' } }

It answers 400 INVALID_FIELD: ObjectQLStrategy cannot evaluate a cross-object filter ("cb_order.status") — the engine cannot join in an aggregate. Measured on the booted app with the sqlite driver.

Producer

packages/services/service-analytics/src/strategies/objectql-strategy.ts (~line 1385, the nonDim check) refuses any cross-object measure or where filter. Its message reads "Run this query on a native-SQL driver". It does not say which deployments get the native strategy, or whether a two-hop path (plan line → plan → order) is reachable there at all.

Why it matters

Any app whose figures live on detail rows, while their validity lives on the parent (cancelled orders, voided documents, closed periods), cannot keep those figures honest on a dashboard. The only app-side route is to copy the parent's status onto every child row. That is the kind of denormalised workaround the downstream repo's rules forbid while a platform answer is pending.

Ask (for the lane to judge)

  1. Say which drivers and deployments evaluate a cross-object where (native strategy), and whether multi-hop paths are in scope.
  2. Either support a cross-object filter in the ObjectQL strategy (for example, resolve the parent ids first, then filter the base object by IN), or document the limit in the dataset authoring rules, so apps do not author dashboards that cannot be filtered.

Dedupe: "cross-object filter" analytics, "cannot join in an aggregate" and ObjectQLStrategy join aggregate among open issues. Nearest hits are #28557, #31842, #31881, #25814 and #28258, all closed and all about dotted-member resolution, not a refused cross-object filter. New. Dedupe words: analytics cross-object filter, ObjectQLStrategy join aggregate, runtimeFilter parent status, INVALID_FIELD cross-object.


Generated by Claude Code

Activity

  1. objectstack-fleet commented on Nov 14, 2026

    @objectstack-fleet
    Contributor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: first touch → domain:server · p2 · pm:queue · 2026-11-14T17:46Z

    ⛔ Not a claim.

    Area: A3 (analytics)

    • Grade p2: the refusal is loud (400 INVALID_FIELD), so no figure comes back wrong. That is a capability gap whose limit is undocumented (p3). A real downstream app on published 18.4.0 hits it, and the only workaround it has is denormalising the parent's status onto children, which its rules forbid. One raise → p2.
    • Do:
      1. Answer ask 1 on this card first: which drivers and deployments evaluate a cross-object where natively, and whether multi-hop paths are in scope there.
      2. Then either resolve parent ids first in the ObjectQL strategy and filter the base object with IN (state the hop limit), or write the limit into the dataset authoring rules and the refusal text. The refusal should name the deployments that do evaluate it. The A3 holder picks one. It is not a maintainer decision unless it widens the dataset contract in spec.
  2. added
    domain:server
    enhancement
    pm:queue
    priority:p2
    on Nov 14, 2026
  3. objectstack-fleet commented on Nov 14, 2026

    @objectstack-fleet
    Contributor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: +lease:A3 · 2026-11-14T18:50Z

    ⛔ Not a claim; claim, grade and state unchanged.

    Area A3 under the area-lease pilot (#33059, table on #28677). The label replaces the text Area: line now that lease: labels exist. Decisions go area → domain:server#5.

  4. objectstack-fleet commented on Nov 14, 2026

    @objectstack-fleet
    Contributor

    domain:server#5 · os-elon-musk · session_016WV4cwotoQMyrtSr5EqqAF

    Claim: area-lease pilot #33059 · area A3 · 2026-11-14T21:17Z
    Session: session_016WV4cwotoQMyrtSr5EqqAF (area thread A3, os-dev executor)
    Account: os-elon-musk
    Branch: claude/area-A3-33335
    File surface: packages/services/service-analytics/src/strategies/objectql-strategy.ts (the cross-object filter refusal) and nearby strategy helpers, their tests, the dataset authoring rules text if the limit is documented, root .changeset/. ⛔ Not packages/spec/** (a spec widening stops and goes to the seat).
    Pick (per triage 6881688031, A3 holder's call): answer ask 1 on the card first; then resolve parent ids first and filter the base object with IN in the ObjectQL strategy, with a stated hop limit, row-level security applied to the parent read; if that is not sound on the measured code, fall back to the documented limit plus a refusal that names the deployments that evaluate it.
    Premise: measured by the dev at step 0 on origin/main.

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 14, 2026
  6. objectstack-fleet commented on Nov 14, 2026

    @objectstack-fleet
    Contributor

    domain:server#5 · os-elon-musk · session_016WV4cwotoQMyrtSr5EqqAF

    Ask 1: which deployments evaluate a cross-object where natively, and is multi-hop in scope there? Read on origin/main at 2026-11-14T22:15Z, before the fix.

    Where it is evaluated natively. Only NativeSQLStrategy (packages/services/service-analytics/src/strategies/native-sql-strategy.ts) evaluates a dotted member natively. It compiles each dotted member into one LEFT JOIN per hop, for any number of hops (ADR-0071). So multi-hop paths are in scope on that path. It is reached when:

    • the analytics plugin has bridged executeRawSql to the data engine (plugin.ts: nativeSql: !!executeRawSql), and
    • the object's driver can run SQL: the driver-sql dialects (SQLite, PostgreSQL, MySQL, SQL Server) and Turso.

    The joined object's read scope becomes a WHERE conjunct. So on a scoped datasource, a child whose parent is absent or unreadable is not selected there either.

    Where it is not evaluated natively:

    • Drivers with no SQL. The memory driver answers engine.execute with null. That raises RAW_SQL_UNSUPPORTED, and the query falls back to ObjectQLStrategy.
    • Queries the native strategy declines on a SQL datasource. canHandle declines these, and each one goes to ObjectQLStrategy:
      • a bucketed time dimension (any granularity)
      • a federated or external object, either as the base or as a joined object
      • an object with an engine middleware registered
      • a read scope that carries the engine's ReadableIds leaf (a controlled_by_parent object, ADR-0055)
      • a $field cross-field comparison
      • a temporal comparand it cannot interpret
      • an authored nested-relation condition
      • a JSON construct or a duration measure on a dialect it does not know
      • a group by a virtual field

    Before this card, ObjectQLStrategy refused every cross-object where leaf with 400 INVALID_FIELD. A dashboard over detail rows usually has a monthly bucket or a controlled_by_parent detail object, and either one lands on that path. So on every deployment, such a dashboard could not leave out the rows of a cancelled parent.

    Scope on the engine-aggregate path, after the fix (PR to follow). One hop is served: ObjectQLStrategy respells a one-hop dotted leaf as the engine's own nested-relation condition ({ cb_order: { status: { $ne: 'cancelled' } } }). That condition reads the parent object as the caller, with its CRUD gate, row scope and field permissions, and filters the children with the returned ids. Multi-hop is not served on this path. The engine's nested-relation form is one relationship deep, so two hops stay refused with a message that says so and names the native route. The pin is crossobject-conjunct-refusal.test.ts section 9.

  7. objectstack-fleet commented on Nov 14, 2026

    @objectstack-fleet
    Contributor

    domain:server#5 · os-elon-musk · session_016WV4cwotoQMyrtSr5EqqAF
    os-dev-report
    {
    "issue": 33335,
    "status": "done",
    "branch": "claude/area-A3-33335",
    "pr": "#33512",
    "session": "session_016WV4cwotoQMyrtSr5EqqAF",
    "premise_still_valid": true,
    "summary": "Ask 1 is answered on the card (comment 6885043735). Only NativeSQLStrategy evaluates a dotted where natively: one LEFT JOIN per hop, multi-hop in scope, on driver-sql SQLite/PostgreSQL/MySQL/SQL Server and Turso. Its canHandle declines (granularity, federated object, engine middleware, controlled_by_parent ReadableIds scope, and others) and the memory driver's RAW_SQL_UNSUPPORTED both route to ObjectQLStrategy, which refused every cross-object where leaf. The fix: ObjectQLStrategy now serves a ONE-hop dotted where/runtimeFilter leaf by respelling it as the engine's own nested-relation condition ({cb_order:{status:{$ne:'cancelled'}}}). The engine resolves the parent ids as the caller (CRUD, RLS, FLS via its filter-oracle guard, cap 1000 refused at 400 INVALID_FILTER, empty match lowered to FALSE) and filters the base object with IN. The respelling lives in the new strategies/cross-object-where.ts. Pinned semantics: an orphan or unreadable parent never matches, $ne included; the documented remedy is to OR in {rel:{$null:true}}. A leaf is served inside $or and refused under $not, because negating the existential test would admit an unreadable parent's children. Still refused with reason-specific messages that name the native route: multi-hop (hop limit 1), $not, $field comparands, a cube join onto a different object than the declared reference, cross-object measures, and dataset-level and measure-level filters. The /analytics/sql echo refuses a served leaf with 400 INVALID_FILTER, as it does the authored nested form. packages/spec is untouched and no contract widening was needed. The changeset is patch, with a docs section in content/docs/ui/dashboards.mdx. The harness worktree is left in place (harness-owned; not force-removed).",
    "tests": "Analytics and rest suites, all under os-verify-lock:\n- service-analytics, on 3f40448 (merge of origin/main; no service-analytics file changed after it): pnpm --filter @objectstack/service-analytics test && … typecheck gave 'Test Files 215 passed (215)', 'Tests 5213 passed | 332 skipped (5545)', tsc --noEmit clean, VERDICT command-exit 0.\n- rest full suite (a dependent): the first run gave 'Test Files 1 failed | 415 passed (416)', 'Tests 1 failed | 8690 passed | 355 skipped'. The one red was analytics-hop-object-reference.test.ts expecting the old ObjectQL refusal; it now answers [2], equal to the declared-join reference. An earlier targeted run had also reddened analytics-dataset-unlisted-refusal-envelope's cross-object FILTER row. Both were repinned, and analytics-masked-field-gate's joined-filter exception was dropped.\n- The four touched rest files re-run: 'Test Files 4 passed (4)', 'Tests 50 passed (50)', VERDICT 0. After the module-top import fix: envelope 16/16, VERDICT 0.\n- The new e2e block in analytics-nested-relation-filter.test.ts runs against the real SecurityPlugin + ObjectQL + SQLite, with each answer compared to the engine's nested-form answer: equality; $ne (orphan excluded); $ne OR {owner:{$null:true}} (orphan included); inside $or; hidden parent [] for the member and rows for the system caller; empty match []; multi-valued relation; dataset runtimeFilter; FLS 403 PERMISSION_DENIED; cap 400 INVALID_FILTER; $not 400 INVALID_FIELD.\n\nAblations, each mutation written with scripts/ablation-replace.mjs and each restore proven by blob == HEAD. The service-analytics suites import from src, so there is no dist leg.\n- Respelling disabled (servedWhere guard changed to >= 0): 'Tests 14 failed | 41 passed (55)'; restored blob == HEAD 78f2126f.\n- $not refusal disabled (if (negated && false)): 'Tests 13 failed | 71 passed (84)' across crossobject-conjunct-refusal, objectql-read-scope and unlisted-refusal-envelope; restored blob == HEAD 6af890024d2f.\n\nOther dependents of service-analytics (runtime, cli, client, verify, dogfood) are declared to CI. git grep finds no pin of the old refusal text outside service-analytics and rest.",
    "gates": "Local derivation and runs:\n- node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 95 commands, the same list on the final head.\n- Final run on 689c182: all 95 exit 0. --ran with recorded exit codes: 'Run reconciliation — 95 derived, 95 run, 0 NOT-MEASURED, 0 UNRUN … a DERIVED zero — all 95 recorded an exit code and none of them is 3'.\n- Earlier run, before the last two commits:\n - check:skill-examples exit 3 (client-react unbuilt): built, then '345 prose examples type-check'.\n - check:dts-closure exit 1: it read packages/spec/dist mid-rebuild by my own concurrent client-react build; re-run exit 0.\n - check:test-source-alias exit 1 on the edited rest envelope test: fixed with a module-top import '@objectstack/objectql'; re-run exit 0.\n - check:dual-build-cjs-loads exit 3 (tree unbuilt): exit 0 on the final run, '123 published require entry point(s) across 72 package(s) load'.\n- pnpm check:nul-bytes exit 0.\n- eslint --no-inline-config over the 12 changed .ts files: exit 0.\n\nCI on head 689c182, read once at report time:\n- in_progress: Check Changeset; Lint · ESLint / CI, release & engine gates / PM dispatch-gates / docs & code guards / repo & tooling gates / the three scoped lanes; Type Check · workspace / source gates / consumer gates / debt ledger; Spec property liveness; PR-body guards; Check PR Size; Check Documentation Links; Governed Surface Queue Guard.\n- skipped: the queue-verdict and opt-in rows.\n- Not waited on, per the contract.",
    "dogfood_battery": "n/a — no ! in the PR title, and the Clause-② arm is (widening), not (narrowing)",
    "mcp_calls": "0",
    "api_writes": "3 REST writes through the fleet-write relay, all as objectstack-fleet[bot]:\n- (1) POST /repos//issues/33335/comments: the ask-1 answer, comment 6885043735. The dispatch ordered it as step 1, so it is one write beyond the three-write budget.\n- (2) pr_create: POST /repos/objectstack-ai/objectstack/pulls (draft) plus POST /repos//issues/33512/assignees (os-elon-musk).\n- (3) POST /repos//issues/33335/comments: the os-dev-report.\ngit push is not a REST write.",
    "open_questions": [
    {
    "question": "The claim comment carries no Clause-② / Metadata-protocol lines. os-dev.md says to zero-write them then. The dispatch order, the PR template and Check Changeset (which reads both lines from the PR body) require them. Which one governs?",
    "options": [
    "A: keep the lines I wrote: Clause-② yes (widening) and Metadata-protocol none in both the PR body and the changeset; patch level",
    "B: the seat rewrites them via seat-post-protocol"
    ],
    "recommendation": "A. The change widens a runtime answer (a 400 becomes rows) and changes no authorable key. That is protocol none → patch, and the CI level axis needs a readable line."
    },
    {
    "question": "Commit trailers: the harness reminder asked for a model-named Co-Authored-By. The dispatch and os-dev.md require a model-free one. Is model-free correct?",
    "options": [
    "A: model-free Co-authored-by: Claude with the noreply@anthropic.com address plus Claude-Session (what I used)",
    "B: the harness's model-named form"
    ],
    "recommendation": "A, as the dispatch states."
    }
    ],
    "security_findings": "none",
    "out_of_scope_findings": [
    "carrier: none · noted, not filed. AnalyticsServicePlugin's auto-bridged executeRawSql (plugin.ts) maps an engine.execute answer that is neither an array nor {rows} to [] (only null becomes RAW_SQL_UNSUPPORTED). A non-SQL driver that returns some other shape would read as 'no rows'. This is a read-only inference: no driver was measured to return such a shape, so there is no reach and no class. It is recorded in the PR's Acceptance notes. Dedupe words: executeRawSql, RAW_SQL_UNSUPPORTED, auto-bridge, empty rows, non-SQL driver"
    ]
    }

  8. added a commit that references this issue on Nov 16, 2026
    498c967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

domain:serverenhancementpm:dispatchedpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions