Skip to content

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

Closed

Description

@objectstack-fleet

triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

Filing gate: ③ maintainer-directed. In the triage seat session on 2026-11-15, verbatim: 「有的功能如果Mongo内存不支持,那就不需要支持,首先保sql,应该用最高性能的方案,而不能为了兼容而兼容」, after ruling A on #33619 (「同意一层」, then 「我的意见是一层先落地」). It follows #33335 and PR #33512, and agrees with the driver-memory/driver-mongodb freeze in #5499. ⛔ Not a claim.

维护者速读

一层的跨对象过滤(#33512)是「先查出父记录 id,再 IN」,有 1000 个 id 的上限。按下游的数据量,「订单状态 ≠ 已取消」在一层就会返回 400。本卡改为 SQL 优先:在 SQL 驱动(driver-sql 各方言、Turso)上,把跨对象条件编译成数据库内的半连接子查询(IN (SELECT …)),每一层带上该对象的读权限,没有 id 上限。内存、Mongo、OData 驱动直接响亮拒绝,不为了兼容保留慢路径。

What exists to build on (read from code by the Fable assessment on #33619)

  • Today: lowerRelationConditions (packages/objectql/src/engine-query-lowering.ts:181-217) runs an id find, then $in, capped at RELATION_FILTER_ID_CAP = 1000 (relation-filter-lowering.ts:84).
  • ADR-0139's ReadableIds leaf already compiles in driver-sql to a nestable field IN (SELECT id FROM P WHERE scope AND tenant) (sql-driver.ts:6371-6385), with a chain-depth cap of 8. Turso has its own semi-join.

What lands

  1. On SQL drivers, a cross-object where leaf (dataset runtimeFilter, dashboard and widget filters; and the dataset's own filter and per-measure filters, which feat(service-analytics): serve a one-hop cross-object where on the engine-aggregate path #33512 still refuses) compiles to the in-database semi-join. No id cap. Hops follow ADR-0071's current limit (3). Going to 5 is a separate ADR-0071 amendment.
  2. Security: each hop carries that object's read scope and tenant wall. The condition field itself gets the same filter-oracle readability check the engine applies elsewhere, because composeReadableIds asks only canReadObject / getReadFilter. An unreadable ancestor excludes the row, including under $ne.
  3. Non-SQL drivers refuse with a stable code naming the reason. No staged id-read fallback.
  4. Parity tests: native strategy vs this path, case by case, including NULL and missing-parent and $ne semantics.
  5. Docs and refusal copy updated, replacing the one-hop cap note [Decision] Analytics cross-object filters beyond one hop: how many hops, and on which mechanism (staged id reads vs a subquery leaf)? #33619 adds.

Grade

p2. A real downstream pull (steedos-labs/os-project-blackcat-crm#119's margin dashboard and allocation tile) hits the 1000-id wall. It is feature work, not a defect.

Blocked-by: #33512 (PR)

Reader: domain:server, A3 (analytics) with the objectql engine; domain:server#5 places it.

Activity

  1. added
    enhancement
    priority:p2
    pm:blocked
    domain:server
    on Nov 15, 2026
  2. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: unblocked · pm:blocked → pm:queue · 2026-11-15T03:49Z

    ⛔ Not a claim.

    PR #33512 (one-hop cross-object where) merged, so the SQL-first semi-join work can start on top of it. p2 · A3, epic #33631 M1.

  3. added
    pm:queue
    and removed
    pm:blocked
    on Nov 15, 2026
  4. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim: area-lease pilot #33059 · area A3 · 2026-11-15T03:57Z · epic #33631 child (M1), dispatchable under the seat's widened drain scope of 2026-11-15T03:56Z (p1 + epic #33631 children)
    Session: session_016WV4d1QwJJ5KGZTThP4fnq (area thread A3, os-dev executor)
    Account: os-elon-musk
    Branch: claude/area-A3-33626
    File surface: the cross-object where lowering in packages/objectql (engine-query-lowering.ts, relation-filter-lowering.ts), the semi-join compile in packages/driver-sql (and Turso if its path differs), non-SQL driver refusals, the analytics/dataset filter doors #33512 touched, parity tests, docs and refusal copy, root .changeset/. Dev confirms at step 0.
    Time box: a draft PR is pushed before this account's hand-over; anything unfinished stays as that draft with a Resume-from line.

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

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · os-elon-musk · session_016WV4d1QwJJ5KGZTThP4fnq
    os-dev-report

    {
     "issue": 33626,
     "status": "partial",
     "branch": "claude/area-A3-33626",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/33652",
     "head": "bc5ef48640785272dc6804b27ef992cdd20234a3",
     "session": "session_016WV4d1QwJJ5KGZTThP4fnq",
     "premise_still_valid": true,
     "clause_2": "Clause-②: yes (widening; narrowing on a related object another datasource holds, and on a driver that compiles no subquery)",
     "metadata_protocol": "Metadata-protocol: none",
     "summary": "Engine half landed as a draft: on find/findOne/count/aggregate a single-valued nested-relation condition is no longer an id read + $in capped at 1000. The related object's own find runs as the caller through its whole pipeline (CRUD gate, read middlewares incl. row scope and the filter-oracle field check, beforeFind hooks, comparand doors) and is PLANNED at its driver call (internal symbol-keyed option); the captured final where becomes the scope of a ReadableIds leaf registered in a module-private WeakMap, which the executor boundary composes with that scope instead of asking the security service. driver-sql/Turso compile it to one nested subquery with the tenant wall; no id cap. A related object on another datasource is refused INVALID_FILTER/400 by name; a read that never reached its driver call composes to $in [] (fail-closed). Multi-valued relations and update/delete keep the capped id read.",
     "tests": "objectql full suite (pnpm --filter @objectstack/objectql test) at aa6187f1: 594/595 files, 13076/13077 tests; the one red (query-expression-conformance stub driver could not evaluate a composed leaf) fixed in bc5ef486 and re-run: 196/196. engine-nested-relation-lowering.test.ts 13/13. rest: data-nested-object-door (SQLite cell; PG/MySQL skipped without env) + data-nested-relation-permission (real SecurityPlugin+SqlDriver, new $ne-under-row-scope case) + analytics-nested-relation-filter: 24 passed / 12 skipped then 14/14 after the analytics update. objectql typecheck (tsc --noEmit + check:test-typecheck) exit 0. Ablation: ReadableIds.compose(leaf, planned.scope) -> compose(leaf, undefined), objectql rebuilt, permission suite 4/4 red (CONTROL got d1,d2,d3,d4 instead of d1,d3); restore blob == HEAD, git diff HEAD empty, rebuilt, 4/4 green. dist-preflight read ABSENT because the marker was a comment the build strips; the red is the mutated behaviour.",
     "gates": "local subset, exits captured before any pipe: check-changeset-no-major 0, check-empty-changeset 0, check:doc-authoring 0, check:nul-bytes 0, check:issue-citations 0, check:facade-delegation-only 0, check:objectql-double-limit 0, check:where-matcher 0, check:cross-package-test-inputs 0, check:test-source-alias 0, check:undeclared-dep-imports 0, check:error-status-conformance 0, check:swallow-census-controls 0, check:adr-symbol-anchors 0, check:doc-anchors 0, docs-audit/check-affected-docs 0, check-closing-keyword-parity 0, check:dispatcher-error-vocabulary 0, check:system-context-census 0, check:driver-memory-census 0. NOT MEASURED: check:query-options-erasure (240s local timeout, exit 124); the other ~79 derived families and the --ran reconciliation (time box) are left to CI; PR check-runs in_progress at report time.",
     "dogfood_battery": "NOT MEASURED: the Clause-② line has a narrowing arm, so the full battery is owed on the final head; not run inside the time box.",
     "dependents": "NOT MEASURED as a sweep: direct dependents of @objectstack/objectql were not run as a turbo filter; only @objectstack/rest's three nested-relation suites (above). service-analytics, plugin-security, metadata-protocol etc. left to CI.",
     "mcp_calls": "0",
     "api_writes": "2 — fleet-write relay: pr_create (POST /repos/objectstack-ai/objectstack/pulls + assignees + labels legs, #33652); this os-dev-report comment (POST /repos/objectstack-ai/objectstack/issues/33626/comments)",
     "open_questions": [
      {
       "question": "driver-memory evaluates the composed leaf in process (ADR-0139 D3), so the form is served there with no cap; the card says memory refuses.",
       "options": [
        "A keep in-process evaluation (no compatibility slow path; same composed leaf)",
        "B refuse on memory too, as the card text says (most engine/rest test fixtures use memory)"
       ],
       "recommendation": "A, because it is the same leaf ADR-0139 already evaluates in memory, not an id-read fallback, and B breaks fixture coverage for no performance gain"
      },
      {
       "question": "MongoDB/OData now fail at the driver with the ADR-0139 D3 refusal (INTERNAL_ERROR/500). The card asks for a stable author-facing code before the driver; ADR-0139 forbids a DriverCapabilities bit.",
       "options": [
        "A amend ADR-0139 for a capability bit and refuse INVALID_FILTER/400 in the engine",
        "B keep the driver refusal and document it"
       ],
       "recommendation": "A, because an author cannot fix a 500 and the refusal should name the reason before any work"
      }
     ],
     "security_findings": "none",
     "remaining": [
      "hops beyond one (ADR-0071 limit 3): admission still refuses second-level; the planned read would recurse once admitted",
      "dataset own filter and per-measure filter doors (still refused)",
      "up-front non-SQL refusal with a stable code; memory decision",
      "multi-valued relation as a JSON-membership semi-join",
      "full dogfood battery and the direct-dependent test sweep on the final head",
      "skills/objectstack-query still says 1000 related ids for every relation (governed, skills-only change)",
      "PR body Resume-from line names aa6187f1; current head is bc5ef486 (seat to refresh)",
      "object-scoped read middleware parent still refused with ADR-0139 D5.2 wording even though the planned read ran it"
     ],
     "out_of_scope_findings": [
      "carrier: none · noted, not filed"
     ]
    }
  7. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Ruling: #33626 Q2 (draft PR #33652) · maintainer's choice on the seat's decision card, 2026-11-15T05:06Z: A.

    • A driver that cannot run a cross-object where (MongoDB, OData) is refused in the engine, before the driver, with INVALID_FILTER / 400, not the current INTERNAL_ERROR / 500 from inside the driver.
    • This needs a DriverCapabilities bit, which ADR-0139 currently rules out, so the PR carries an ADR-0139 amendment and follows the governed path (Tier H, approver lands).
    • Q1 (driver-memory: keep the in-process composed leaf, or refuse) is still open with the maintainer. The seat recommends keeping it.

    Resume-from stays claude/area-A3-33626@bc5ef48640785272dc6804b27ef992cdd20234a3 (comment on #33652); the PR stays draft for the next account.

  8. 12 remaining items

  9. added
    pm:blocked
    and removed
    pm:dispatched
    on Nov 16, 2026
  10. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: blocker re-pointed → pm:blocked kept · 2026-11-16T13:22Z

    ⛔ Not a claim.

    Blocked-by: #33876

    The body edge #33512 is closed: PR #33512 merged, and #33652 landed the engine and analytics halves of this card (Part of). The landing note of 04:29Z says the card stays open only until #33876 lands. #33876 is its own queued card, so this card has nothing workable of its own. It stays parked, now on #33876, and closes when #33876 does.

  11. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: unlock → pm:queue · 2026-11-17T10:52Z

    ⛔ Not a claim.

    Blocker #33876 closed today at 10:36Z, completed. Back to the queue at its grade (p2).

  12. added
    pm:queue
    and removed
    pm:blocked
    on Nov 17, 2026
  13. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

    Close-out 2026-11-19T04:50Z · area data-1 of seat repo:objectstack#5 (seat OK on the W0 list, 2026-11-19T04:50Z).

  14. removed
    pm:queue
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:datadomain:serverenhancementpriority:p2

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions