Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d756745
feat(objectql): refuse a nested-relation where up front on a driver w…
claude Nov 16, 2026
8ed0b00
test(objectql): pin the up-front refusal on a driver without readable…
claude Nov 16, 2026
2894eca
test(spec): readableIdsLeaf is the sixth live driver capability bit; …
claude Nov 16, 2026
1d8bacb
test(service-analytics): a lookup dimension on a driver without reada…
claude Nov 16, 2026
957fd50
test(drivers): memory declares readableIdsLeaf, mongodb does not; cha…
claude Nov 16, 2026
642664a
docs: a driver without readableIdsLeaf refuses a nested-relation cond…
claude Nov 16, 2026
30c270d
chore(spec): record readableIdsLeaf in the authorable surface; change…
claude Nov 16, 2026
56d26a7
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 16, 2026
c286481
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
4c649ca
fix(objectql): type the relation group refusal's attribute read expli…
claude Nov 17, 2026
6528bd8
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
cc31d3f
fix(spec): restore the readableIdsLeaf schema entry after the lockRow…
claude Nov 17, 2026
d5f9113
docs(objectql): put the relation group join's refused section ahead o…
claude Nov 17, 2026
56eeb9b
docs(#33876): name the dimension refusal's ruling, and list the analy…
claude Nov 17, 2026
a29a6b9
fix(objectql): the filter judge answers the up-front driver refusal e…
claude Nov 17, 2026
13bdb52
docs(adr-0139): amend D3 for the readableIdsLeaf bit and its readers
claude Nov 17, 2026
e5c3fea
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
a5d3ac3
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 17, 2026
e7323bc
chore(spec): regenerate the driver capability artifacts after the mai…
claude Nov 17, 2026
779d1aa
docs(#33876): say every consumer, describe the judge's driver verdict…
claude Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .changeset/33876-readable-ids-leaf-refusal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
'@objectstack/spec': minor
'@objectstack/objectql': patch
'@objectstack/driver-sql': patch
'@objectstack/driver-memory': patch
'@objectstack/service-analytics': patch
---

feat(objectql): a nested-relation condition, and an analytics dimension through a lookup, are refused up front with a stable 400 on a driver that compiles no semi-join (MongoDB, OData), decided by the new `DriverCapabilities.readableIdsLeaf` bit

Clause-②: yes (narrowing) — narrowed: on a driver that does not declare `DriverCapabilities.readableIdsLeaf` (MongoDB, OData, a third-party driver), a nested-relation condition beneath a single-valued relation on `find`, `findOne`, `count` or `aggregate` is refused `INVALID_FILTER` / 400 before anything is read, where it read the related ids first and answered up to 1,000 related matches (past 1,000 it was already refused `INVALID_FILTER` / 400, never truncated); an analytics dimension through a lookup on such a driver is refused `INVALID_QUERY` / 400 before anything is read, where it was served by reading the related records for the grouped ids. Widened: a driver that declares the bit is served by the planned semi-join whatever its name.
Metadata-protocol: added
Skills-docs: follow-up #33875 — skills/objectstack-query/SKILL.md (its nested-relation row still promises the capped id read on every driver; MongoDB and OData now refuse it)

<!-- adr-0087: not-required (no-migration-prescription) No metadata key, accepted value or metadata type is removed, renamed or re-shaped: the one protocol change is the new optional `DriverCapabilities.readableIdsLeaf`, which a driver declares. What moves is a runtime answer on drivers that do not declare it, so there is nothing stored for a migration to rewrite and no tombstone. -->

**BREAKING** for a deployment whose data lives on MongoDB, OData or a third-party driver that does not declare `readableIdsLeaf`. The fix:

- FROM `find('opportunity', { where: { account: { region: 'NA' } } })` TO two reads: `find('account', { where: { region: 'NA' }, fields: ['id'] })`, then `find('opportunity', { where: { account: { $in: ids } } })`. The same for `findOne`, `count` and `aggregate`.
- FROM an analytics dimension `opportunity.stage` on a line cube TO a dimension on the lookup field itself (`opportunity`), then a read of `opportunity` for `stage` by those ids.
- FROM an analytics `where` naming a field through a lookup (`opportunity.stage`), or a dataset whose own `filter` does, TO a filter on the lookup field itself (`opportunity` `$in` the ids read from `opportunity` with that condition): the analytics service hands such a leaf to the engine as the same nested-relation condition, so on these drivers it is refused `INVALID_FILTER` / 400 the same way.
- FROM a row-level read scope that holds such a condition (a field through a single-valued relation) TO one on the relation field itself (`account` `$in` the ids it may read): on these drivers an analytics query under the former is refused before anything is read with the withheld `READ_SCOPE_COMPILE_FAILED` / 500, the answer a read scope the engine cannot run already gets.
- A third-party driver whose filter compiler composes the leaf declares `supports.readableIdsLeaf: true` and keeps serving both.

**`DriverCapabilities.readableIdsLeaf`** (`@objectstack/spec`) is a new optional capability bit: the driver's filter compiler compiles (or, in process, evaluates) a composed `ReadableIds` semi-join leaf. `driver-sql` declares it on every dialect (`SqliteWasmDriver` and `TursoDriver` inherit it), and so does `driver-memory`. MongoDB and OData do not. Absence means `false`.

**Where the engine reads it.** A nested-relation condition beneath a single-valued relation on a read verb (`{ account: { region: 'NA' } }` on `find`, `findOne`, `count` or `aggregate`) is planned as one in-database subquery on a driver that declares the bit, as before. On a driver that does not, the engine now refuses the condition before it plans or reads anything: `INVALID_FILTER` / 400, naming the driver and the two-step route (read the related object with that condition, then match the relation field against its ids with `$in`). Until now such a read fell back to reading the related ids first: up to 1,000 related matches were served, and past 1,000 the filter was refused `INVALID_FILTER` / 400. A multi-valued relation and the `where` of `update` / `delete` keep that capped id read on every driver. The engine's filter judge (`IObjectQLEngine.judgeFilter`) answers the same refusal from the driver's declared capabilities, without calling it, so a caller that asks the judge first (the analytics read-scope merge does) gets execution's verdict; an engine that routes the object to no driver does not judge it.

**The analytics dimension through a lookup** (`opportunity.stage` on a line cube, `@objectstack/service-analytics` on the ObjectQL face) is decided by the same bit. On a driver without it the query is refused before anything is read: `INVALID_QUERY` / 400, naming the driver and the route (group by the lookup field itself, then read the related object for its attribute by those ids). Until now it was served by reading the related ids. On a driver that declares the bit, the SQL drivers keep the one joined statement and `driver-memory` and Turso keep the id-expand, unchanged.

12 changes: 9 additions & 3 deletions content/docs/kernel/contracts/data-engine.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ where: {

A nested relation filter is a condition on a related record's own fields, written
beneath a relation field (`lookup`, `master_detail`, `user` or `tree`, single or
multiple). The engine serves it in `where`, the same on every driver: it reads the
multiple). The engine serves it in `where`, the same on every driver that serves it (below): it reads the
related object with the condition **as the caller** — that object's row scope and field
permissions apply, so a condition on a field the caller cannot read is refused
(`PERMISSION_DENIED` / 403), never answered with an empty list — and then matches the
Expand All @@ -213,15 +213,21 @@ single-valued relation on a read verb in each of these cases:

- a related object on another datasource;
- a federated related object;
- a driver that compiles no subquery (MongoDB, OData — the SQL drivers compile it, the
in-memory driver evaluates it in process);
- a related object whose reads an object-scoped middleware or an `afterFind` hook shapes;
- a related object read under different driver options than the outer object (its tenant
scope, most commonly) — decided before the related read is planned where the registry
answers it (the two objects' tenancy class under a walled posture), at the executor
boundary otherwise;
- a related read that a middleware answers itself (or adds rows to after the driver call).

A driver that compiles no subquery is not one of those cases. The SQL drivers compile it
and the in-memory driver evaluates it in process; each declares the
`DriverCapabilities.readableIdsLeaf` bit. On a driver without it (MongoDB, OData), a
single-valued relation condition on a read verb is refused before anything is planned or
read, `INVALID_FILTER` / 400, naming the driver and the two-step route below. A
multi-valued relation and `update` / `delete` keep the capped id read there. An analytics
dimension through a lookup is refused on such a driver the same way, `INVALID_QUERY` / 400.

A read rule that narrows a related object's rows after its driver call bounds a relation
condition on that object only when it is registered for that object — as an object-keyed
middleware or an `afterFind` hook; registered that way, the hop keeps the id read.
Expand Down
12 changes: 8 additions & 4 deletions content/docs/protocol/objectql/query-syntax.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -706,9 +706,14 @@ the caller and nested as a subquery; no dotted key; forward only: never a parent
only: an aggregation's `filter` and `having` refuse it, `INVALID_FILTER` / 400;
where ids are read, at most 1000 of them, refused past that,
`INVALID_FILTER` / 400, never truncated; the subquery form is taken only on
the related object's own datasource and on a driver that compiles it — the SQL
drivers (every `driver-sql` dialect, Turso) compile it and the in-memory driver
evaluates it in process; as the caller: the related object's row scope and field permissions
the related object's own datasource; on a read verb it needs a driver that
compiles it — the SQL drivers (every `driver-sql` dialect, Turso) compile it and
the in-memory driver evaluates it in process, each declaring the
`DriverCapabilities.readableIdsLeaf` bit, and on a driver without it (MongoDB,
OData) a single-valued relation condition on a read verb is refused before
anything is read, `INVALID_FILTER` / 400, naming the driver and the two-step
route (a multi-valued relation and `update` / `delete` keep the capped id read
there); as the caller: the related object's row scope and field permissions
apply, so a field the caller cannot read is refused, `PERMISSION_DENIED` / 403,
never an empty result.

Expand All @@ -717,7 +722,6 @@ of these cases:

- a related object on another datasource;
- a federated related object;
- a driver that compiles no subquery (MongoDB, OData);
- a related object whose reads an object-scoped middleware or an `afterFind` hook shapes;
- a related object read under different driver options than the outer object (its tenant
scope, most commonly) — decided before the related read is planned where the registry
Expand Down
1 change: 1 addition & 0 deletions content/docs/references/data/driver-nosql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const result = AggregationPipelineSchema.parse(data);
| **aggregationFilter** | `boolean` | optional | `aggregate()` evaluates a per-measure `aggregations[].filter` itself, with the engine's in-memory answer, except that text compares by the backend collation as in `where` (absence = false: the engine aggregates filtered measures in memory) |
| **lockRows** | `boolean` | optional | `find()` honours `DriverOptions.lockRows` inside a transaction: no other writer changes a returned row behind the transaction (it waits, or one side fails) (absence = false: the engine sends no lock request) |
| **zonedDateBucketing** | `boolean` | optional | `aggregate()` buckets a date groupBy on the calendar of the resolved IANA zone the engine sends (DriverAggregateQuery.timezone), DST-correct, equal to the in-memory buckets (absence = false: the engine buckets a non-UTC zone in memory) |
| **readableIdsLeaf** | `boolean` | optional | The filter compiler compiles (or, in process, evaluates) a composed `ReadableIds` semi-join leaf (absence = false: the engine refuses a nested-relation condition on a read verb up front, INVALID_FILTER / 400) |
| **create** | `never` | optional | [REMOVED] `DriverCapabilities.create` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `create`/`find`/`findOne`/`update`/`delete` are REQUIRED `IDataDriver` methods and the engine calls them unconditionally. Delete the key. |
| **read** | `never` | optional | [REMOVED] `DriverCapabilities.read` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: reads go through the REQUIRED `find`/`findOne`/`count` methods, called unconditionally. Delete the key. |
| **update** | `never` | optional | [REMOVED] `DriverCapabilities.update` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `update`/`upsert` are REQUIRED `IDataDriver` methods, called unconditionally. Delete the key. |
Expand Down
1 change: 1 addition & 0 deletions content/docs/references/data/driver-sql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const result = DataTypeMappingSchema.parse(data);
| **aggregationFilter** | `boolean` | optional | `aggregate()` evaluates a per-measure `aggregations[].filter` itself, with the engine's in-memory answer, except that text compares by the backend collation as in `where` (absence = false: the engine aggregates filtered measures in memory) |
| **lockRows** | `boolean` | optional | `find()` honours `DriverOptions.lockRows` inside a transaction: no other writer changes a returned row behind the transaction (it waits, or one side fails) (absence = false: the engine sends no lock request) |
| **zonedDateBucketing** | `boolean` | optional | `aggregate()` buckets a date groupBy on the calendar of the resolved IANA zone the engine sends (DriverAggregateQuery.timezone), DST-correct, equal to the in-memory buckets (absence = false: the engine buckets a non-UTC zone in memory) |
| **readableIdsLeaf** | `boolean` | optional | The filter compiler compiles (or, in process, evaluates) a composed `ReadableIds` semi-join leaf (absence = false: the engine refuses a nested-relation condition on a read verb up front, INVALID_FILTER / 400) |
| **create** | `never` | optional | [REMOVED] `DriverCapabilities.create` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `create`/`find`/`findOne`/`update`/`delete` are REQUIRED `IDataDriver` methods and the engine calls them unconditionally. Delete the key. |
| **read** | `never` | optional | [REMOVED] `DriverCapabilities.read` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: reads go through the REQUIRED `find`/`findOne`/`count` methods, called unconditionally. Delete the key. |
| **update** | `never` | optional | [REMOVED] `DriverCapabilities.update` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `update`/`upsert` are REQUIRED `IDataDriver` methods, called unconditionally. Delete the key. |
Expand Down
2 changes: 2 additions & 0 deletions content/docs/references/data/driver.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const result = DriverCapabilitiesSchema.parse(data);
| **aggregationFilter** | `boolean` | optional | `aggregate()` evaluates a per-measure `aggregations[].filter` itself, with the engine's in-memory answer, except that text compares by the backend collation as in `where` (absence = false: the engine aggregates filtered measures in memory) |
| **lockRows** | `boolean` | optional | `find()` honours `DriverOptions.lockRows` inside a transaction: no other writer changes a returned row behind the transaction (it waits, or one side fails) (absence = false: the engine sends no lock request) |
| **zonedDateBucketing** | `boolean` | optional | `aggregate()` buckets a date groupBy on the calendar of the resolved IANA zone the engine sends (DriverAggregateQuery.timezone), DST-correct, equal to the in-memory buckets (absence = false: the engine buckets a non-UTC zone in memory) |
| **readableIdsLeaf** | `boolean` | optional | The filter compiler compiles (or, in process, evaluates) a composed `ReadableIds` semi-join leaf (absence = false: the engine refuses a nested-relation condition on a read verb up front, INVALID_FILTER / 400) |
| **create** | `never` | optional | [REMOVED] `DriverCapabilities.create` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `create`/`find`/`findOne`/`update`/`delete` are REQUIRED `IDataDriver` methods and the engine calls them unconditionally. Delete the key. |
| **read** | `never` | optional | [REMOVED] `DriverCapabilities.read` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: reads go through the REQUIRED `find`/`findOne`/`count` methods, called unconditionally. Delete the key. |
| **update** | `never` | optional | [REMOVED] `DriverCapabilities.update` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `update`/`upsert` are REQUIRED `IDataDriver` methods, called unconditionally. Delete the key. |
Expand Down Expand Up @@ -93,6 +94,7 @@ const result = DriverCapabilitiesSchema.parse(data);
| **aggregationFilter** | `boolean` | optional | `aggregate()` evaluates a per-measure `aggregations[].filter` itself, with the engine's in-memory answer, except that text compares by the backend collation as in `where` (absence = false: the engine aggregates filtered measures in memory) |
| **lockRows** | `boolean` | optional | `find()` honours `DriverOptions.lockRows` inside a transaction: no other writer changes a returned row behind the transaction (it waits, or one side fails) (absence = false: the engine sends no lock request) |
| **zonedDateBucketing** | `boolean` | optional | `aggregate()` buckets a date groupBy on the calendar of the resolved IANA zone the engine sends (DriverAggregateQuery.timezone), DST-correct, equal to the in-memory buckets (absence = false: the engine buckets a non-UTC zone in memory) |
| **readableIdsLeaf** | `boolean` | optional | The filter compiler compiles (or, in process, evaluates) a composed `ReadableIds` semi-join leaf (absence = false: the engine refuses a nested-relation condition on a read verb up front, INVALID_FILTER / 400) |
| **create** | `never` | optional | [REMOVED] `DriverCapabilities.create` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `create`/`find`/`findOne`/`update`/`delete` are REQUIRED `IDataDriver` methods and the engine calls them unconditionally. Delete the key. |
| **read** | `never` | optional | [REMOVED] `DriverCapabilities.read` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: reads go through the REQUIRED `find`/`findOne`/`count` methods, called unconditionally. Delete the key. |
| **update** | `never` | optional | [REMOVED] `DriverCapabilities.update` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `update`/`upsert` are REQUIRED `IDataDriver` methods, called unconditionally. Delete the key. |
Expand Down
Loading
Loading