From d756745c3b59b249f016ebe102f95084e93be8fe Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:21:40 +0000 Subject: [PATCH 01/15] feat(objectql): refuse a nested-relation where up front on a driver without the readableIdsLeaf capability Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- .../driver-memory/src/memory-driver.ts | 7 +- packages/drivers/driver-sql/src/sql-driver.ts | 6 ++ .../src/engine-delete-and-aggregate.ts | 12 +++- .../objectql/src/engine-query-lowering.ts | 39 ++++++++++- packages/objectql/src/engine.ts | 1 + .../objectql/src/relation-filter-lowering.ts | 18 +++++ packages/objectql/src/relation-group-join.ts | 70 +++++++++++++++++-- packages/objectql/src/relation-semi-join.ts | 58 +++++++++------ .../services/service-analytics/src/plugin.ts | 7 +- .../src/strategies/objectql-strategy.ts | 10 ++- .../service-analytics/src/strategies/types.ts | 16 +++-- packages/spec/src/data/driver.zod.ts | 34 +++++++++ 12 files changed, 240 insertions(+), 38 deletions(-) diff --git a/packages/drivers/driver-memory/src/memory-driver.ts b/packages/drivers/driver-memory/src/memory-driver.ts index 161820eb595..1be6b46ce50 100644 --- a/packages/drivers/driver-memory/src/memory-driver.ts +++ b/packages/drivers/driver-memory/src/memory-driver.ts @@ -596,8 +596,13 @@ export class InMemoryDriver implements IDataDriver { * expressed by the methods this class implements; the bits were read by * nothing and two of them were WRONG for years (`streaming: true` over a * full-table read — see #4484/#4634). + * + * [#33876] `readableIdsLeaf`: this driver evaluates a composed + * `ReadableIds` leaf in process (ADR-0139 D3: read the related object under + * the composed scope, then member-test), so the engine plans a + * nested-relation condition on a read verb as that leaf here. */ - readonly supports = {}; + readonly supports = { readableIdsLeaf: true }; /** * The "Database": A map of TableName -> Array of Records diff --git a/packages/drivers/driver-sql/src/sql-driver.ts b/packages/drivers/driver-sql/src/sql-driver.ts index 806e2c46c22..62557b995e6 100644 --- a/packages/drivers/driver-sql/src/sql-driver.ts +++ b/packages/drivers/driver-sql/src/sql-driver.ts @@ -393,6 +393,12 @@ export class SqlDriver implements IDataDriver { // collation's, as for this datasource's `where` (the latitude the bit's // TSDoc in `data/driver.zod.ts` states, measured dialects named there). aggregationFilter: true, + // [#33876] The filter compiler compiles a composed `ReadableIds` leaf + // to one nested subquery (ADR-0139 D3, `applyFilterCondition`), so the + // engine plans a nested-relation condition on a read verb as that leaf + // here. Every dialect; `SqliteWasmDriver` and `TursoDriver` inherit it + // (Turso's remote transport compiles the leaf with its own compiler). + readableIdsLeaf: true, }; } diff --git a/packages/objectql/src/engine-delete-and-aggregate.ts b/packages/objectql/src/engine-delete-and-aggregate.ts index 7c7aad63c3f..8d4cd4070db 100644 --- a/packages/objectql/src/engine-delete-and-aggregate.ts +++ b/packages/objectql/src/engine-delete-and-aggregate.ts @@ -83,7 +83,7 @@ import { RELATION_SCOPE_PLAN, type RelationScopePlan } from './relation-semi-joi import { assertRelationGroupRequestShape, assertRelationGroupRowsJoined, declineRelationGroup, planRelationGroups, RELATION_GROUP_JOINS, relationFieldsJudgedAsGroupKeys, relationGroupByRequestOf, relationGroupJoinsAtBoundary, - relationGroupRegistryDecline, withoutJudgedRelationFields, type PlannedRelationGroup, + relationGroupDriverRefusal, relationGroupRegistryDecline, withoutJudgedRelationFields, type PlannedRelationGroup, } from './relation-group-join.js'; import { ObjectQLStatics as ObjectQL } from './engine.js'; import type { ObjectQL as ObjectQLClass } from './engine.js'; @@ -931,6 +931,16 @@ export class DeleteAndAggregateFacet { // is read, so the caller's own path runs the doors below itself. const relationGroup = relationGroupByRequestOf(options); if (relationGroup !== undefined) { + // [#33876] A driver that compiles no `ReadableIds` leaf refuses the + // dimension outright, before the decline: the caller throws the + // error rather than serve its FK-expand. + const refusal = relationGroupDriverRefusal( + object, relationGroup, this.getDriver(object) as { readonly name?: unknown; readonly supports?: unknown } | undefined, + ); + if (refusal !== undefined) { + relationGroup.outcome = { kind: 'refused', error: refusal }; + return []; + } const reason = relationGroupRegistryDecline.call({ getObjectSchema: (name: string) => this._registry.getObject(name), getDriver: (name: string) => this.getDriver(name) as { readonly name?: unknown; readonly aggregate?: unknown } | undefined, diff --git a/packages/objectql/src/engine-query-lowering.ts b/packages/objectql/src/engine-query-lowering.ts index 75728f1443e..d0fa050d4cd 100644 --- a/packages/objectql/src/engine-query-lowering.ts +++ b/packages/objectql/src/engine-query-lowering.ts @@ -69,9 +69,16 @@ import { lowerRelationSite, RELATION_FILTER_ID_CAP, relationFilterCapError, + relationSemiJoinDriverRefusal, type RelationReplacement, } from './relation-filter-lowering.js'; -import { planRelationSemiJoinLeaf, RELATION_SCOPE_PLAN, type RelationScopePlan } from './relation-semi-join.js'; +import { + driverCompilesReadableIdsLeaf, + driverNameOf, + planRelationSemiJoinLeaf, + RELATION_SCOPE_PLAN, + type RelationScopePlan, +} from './relation-semi-join.js'; import type { EngineReadOptions } from './engine-top-level.js'; import { aggregatedRowColumnClasses } from './having-filter.js'; import { relationSitesOf, resolveThenLowerWhere, SECURITY_SERVICE_SOURCE_SLOT } from './engine.js'; @@ -94,6 +101,11 @@ export interface QueryLoweringHost { find: ObjectQL['find']; /** `relation-semi-join.ts`'s `relationSemiJoinServes`, bound to the engine. */ relationSemiJoinServes: (object: string, target: string) => boolean; + /** + * [#33876] The driver a read of `object` reaches — the engine's own + * `getDriver` — read for its `readableIdsLeaf` bit and its name. + */ + relationReadDriver: (object: string) => { readonly name?: unknown; readonly supports?: unknown } | undefined; } /** @@ -189,6 +201,17 @@ export async function resolveWhereTokens( * (`INVALID_FILTER` / 400, the two-step route in the words), never run over * a cut-off list. * + * **Refused up front on a driver that compiles no semi-join.** [#33876, the + * maintainer's ruling A on #33626's Q2] A single-valued relation condition on + * a read verb whose driver lacks the `DriverCapabilities.readableIdsLeaf` bit + * (MongoDB, OData) is refused before ANY related read is planned or run — + * every site is judged first — `INVALID_FILTER` / 400, naming the driver and + * the two-step route (`relationSemiJoinDriverRefusal`). It is not served by + * the id read: SQL first, and a driver that cannot run the subquery refuses + * with a stable code rather than keep a slower path built for parity + * (AGENTS.md Prime Directive #5). A multi-valued relation and a write verb's + * `where` keep the id read on every driver, as below. + * * Returns `where` by reference when it holds no condition — the common path * reads nothing and allocates nothing beyond one walk. */ @@ -201,7 +224,7 @@ export async function resolveWhereTokens( const SEMI_JOIN_READ_VERBS: ReadonlySet = new Set(['find', 'findOne', 'count', 'aggregate']); export async function lowerRelationConditions( - this: Pick, + this: Pick, object: string, operation: string, where: W, @@ -212,6 +235,18 @@ export async function lowerRelationConditions( const sites = relationSitesOf(object, operation, where, schema, this.relatedSchemaOf); if (sites.length === 0) return where; const context = `${operation}('${object}')`; + // [#33876] Judged for every site before any related read is planned or + // run: on a read verb, a single-valued relation condition needs a driver + // that compiles the `ReadableIds` leaf, or it is refused here. + if (SEMI_JOIN_READ_VERBS.has(operation)) { + const refused = sites.find((site) => !site.multiple); + if (refused !== undefined) { + const driver = this.relationReadDriver(object); + if (!driverCompilesReadableIdsLeaf(driver)) { + throw relationSemiJoinDriverRefusal(refused, context, driverNameOf(driver)); + } + } + } const replacements: RelationReplacement[] = []; // The id read the engine has always run for a relation condition: the // related object read as the caller, `id` only, one id past the cap. diff --git a/packages/objectql/src/engine.ts b/packages/objectql/src/engine.ts index 8d789a8785f..3f19b7c1714 100644 --- a/packages/objectql/src/engine.ts +++ b/packages/objectql/src/engine.ts @@ -4299,6 +4299,7 @@ export class ObjectQL implements IObjectQLEngine { get relatedSchemaOf() { return readRelatedSchemaOf(); }, find: (...a) => this.find(...a), relationSemiJoinServes: (...a) => this.relationSemiJoinServes(...a), + relationReadDriver: (name) => this.getDriver(name), }; return (lowerRelationConditions).call(host, object, operation, where, execCtx); } diff --git a/packages/objectql/src/relation-filter-lowering.ts b/packages/objectql/src/relation-filter-lowering.ts index 417badb8672..1b8c6ed5fa8 100644 --- a/packages/objectql/src/relation-filter-lowering.ts +++ b/packages/objectql/src/relation-filter-lowering.ts @@ -328,6 +328,24 @@ export function relationConditionError(refusal: RelationConditionRefusal, contex return invalidFilterError(relationConditionRefusalMessage(refusal, context)); } +/** + * [#33876] The words of the up-front refusal of a nested-relation condition + * on a read verb whose driver compiles no `ReadableIds` leaf (the + * `DriverCapabilities.readableIdsLeaf` bit is absent: MongoDB, OData). + * Thrown before any related read is planned or run. The short reason and + * the two-step route come first — the REST door bounds a 4xx message at 500 + * characters by truncation — then "NOT applied" and which drivers run it. + */ +export function relationSemiJoinDriverRefusal(site: RelationFilterSite, context: string, driverName: string): Error { + return invalidFilterError( + `${context}: the nested-relation condition at ${site.path} cannot run on this read's driver ` + + `'${driverName}', which compiles no semi-join of '${site.target}'. Read '${site.target}' with that ` + + `condition yourself, then match '${site.field}' against its ids: ${idsRoute(site.field, site.multiple)}. ` + + 'The filter was NOT applied and nothing was read. A driver that declares the readableIdsLeaf ' + + 'capability (the SQL drivers, the in-memory driver) runs it as one statement.', + ); +} + /** * The cap refusal: the condition matched more related records than * {@link RELATION_FILTER_ID_CAP}, so the filter is refused — `INVALID_FILTER` / diff --git a/packages/objectql/src/relation-group-join.ts b/packages/objectql/src/relation-group-join.ts index eb0ce9bb2f9..e0fc952dde4 100644 --- a/packages/objectql/src/relation-group-join.ts +++ b/packages/objectql/src/relation-group-join.ts @@ -69,12 +69,20 @@ * * ## Declined, never half-served * - * Every case this module cannot prove is the same read as the FK-expand's is - * DECLINED: the engine runs nothing more and writes the reason to the + * ## Refused, on a driver that compiles no semi-join + * + * [#33876] A read whose driver lacks the `DriverCapabilities.readableIdsLeaf` + * bit (MongoDB, OData) is REFUSED before anything else is judged or read + * ({@link relationGroupDriverRefusal}): the outcome is `refused`, carrying + * an `INVALID_QUERY` / 400 the caller throws instead of serving its + * FK-expand. The same bit decides a nested-relation `where` on that driver. + * + * Every other case this module cannot prove is the same read as the + * FK-expand's is DECLINED: the engine runs nothing more and writes the reason to the * request's `outcome`, and the caller serves the dimension the way it always * has. Declined before anything is read when the registry already answers — - * a driver outside {@link RELATION_GROUP_JOIN_COMPILING_DRIVERS} (memory keeps - * its in-process FK-expand; MongoDB and OData keep theirs), a federated + * a driver outside {@link RELATION_GROUP_JOIN_COMPILING_DRIVERS} that does + * declare the bit (memory and Turso keep their FK-expand), a federated * object, a field that is not a single-valued relation to the named object, * or a related object `relationSemiJoinServes` keeps the id read for; and * after planning, when the related read was not provably one planned @@ -94,7 +102,10 @@ import { } from '@objectstack/spec/data'; import { readableIdsRefusalError } from './filter-comparand-shape.js'; import { isFederatedObject } from './federated-object.js'; +import { StandardErrorCode } from '@objectstack/spec/api'; import { + driverCompilesReadableIdsLeaf, + driverNameOf, planRelationSemiJoinLeaf, plannedRelationLeafVerdict, RELATION_SCOPE_PLAN, @@ -139,10 +150,16 @@ export interface RelationGroupBy { readonly resolvedAlias: string; } -/** What the engine did with a {@link RelationGroupByRequest}. */ +/** + * What the engine did with a {@link RelationGroupByRequest}. `refused` + * ([#33876]): the read's driver compiles no `ReadableIds` leaf, so the + * dimension is not served on ANY path — the caller throws `error` rather + * than fall back to its FK-expand ({@link relationGroupDriverRefusal}). + */ export type RelationGroupOutcome = | { readonly kind: 'joined' } - | { readonly kind: 'declined'; readonly reason: string }; + | { readonly kind: 'declined'; readonly reason: string } + | { readonly kind: 'refused'; readonly error: Error }; /** * The request: the relations to group by, and the slot the engine writes its @@ -279,6 +296,47 @@ export function withoutJudgedRelationFields( return { ...ast, groupBy: kept.length === 0 && !Array.isArray(ownGroupBy) ? undefined : kept }; } +/** + * [#33876] The up-front refusal of a relation group request on a driver that + * compiles no `ReadableIds` leaf (its `DriverCapabilities.readableIdsLeaf` + * bit is absent: MongoDB, OData) — the analytics dimension through a lookup, + * decided by the same bit as a nested-relation `where` + * (`relationSemiJoinDriverRefusal`), the maintainer's ruling A on #33626's + * Q2. `undefined` when the driver declares the bit: `driver-memory` does, and + * keeps its in-process FK-expand through the ordinary decline. Nothing is + * read; the caller serves nothing and throws the error, `INVALID_QUERY` / + * 400, naming the driver and the two-step route. + */ +export function relationGroupDriverRefusal( + object: string, + request: RelationGroupByRequest, + driver: { readonly name?: unknown; readonly supports?: unknown } | undefined, +): Error | undefined { + if (driverCompilesReadableIdsLeaf(driver)) return undefined; + const relation = Array.isArray(request.relations) ? request.relations[0] : undefined; + const field = typeof relation?.field === 'string' ? relation.field : 'the relation field'; + const target = typeof relation?.object === 'string' ? relation.object : 'the related object'; + const attrs = Array.isArray(relation?.attrs) + ? relation.attrs.map((a) => a?.attr).filter((a): a is string => typeof a === 'string') + : []; + const what = attrs.length > 0 ? attrs.map((a) => `'${a}'`).join(', ') : 'its attributes'; + const err = new Error( + `aggregate('${object}'): grouping by ${what} of '${target}' through '${object}.${field}' cannot run on ` + + `this read's driver '${driverNameOf(driver)}', which compiles no semi-join of '${target}'. Group by ` + + `'${field}' itself, then read '${target}' for ${what} by those ids. The query was NOT run and nothing ` + + 'was read. A driver that declares the readableIdsLeaf capability (the SQL drivers, the in-memory ' + + 'driver) serves it.', + ) as Error & { code?: string; status?: number; httpStatus?: number; object?: string; param?: string }; + err.code = StandardErrorCode.enum.INVALID_QUERY; + err.status = 400; + // …and `httpStatus`, the same number under ADR-0112 D5's spelling — what a + // consumer holding the THROWN error reads; `status` stays for the HTTP doors. + err.httpStatus = 400; + err.object = object; + err.param = 'groupBy'; + return err; +} + /** What {@link relationGroupRegistryDecline} reads off the engine. */ export interface RelationGroupRegistryHost { getObjectSchema(object: string): unknown; diff --git a/packages/objectql/src/relation-semi-join.ts b/packages/objectql/src/relation-semi-join.ts index 20c004e45f9..be10387d9d6 100644 --- a/packages/objectql/src/relation-semi-join.ts +++ b/packages/objectql/src/relation-semi-join.ts @@ -39,13 +39,13 @@ * the executor boundary's comparison): * * - **Before planning** — the registry already answers: the related object - * has a restriction no planned `where` can carry, or the read's driver - * compiles no subquery: an object-scoped middleware or an `afterFind` hook - * on the related object (both act after its driver call), another - * datasource than the read's object, a federated related object, a related - * object of another tenancy class than the read's object under a walled - * posture (its driver options differ), or a driver outside - * {@link SEMI_JOIN_COMPILING_DRIVERS}. The related read is dispatched once. + * has a restriction no planned `where` can carry: an object-scoped + * middleware or an `afterFind` hook on the related object (both act after + * its driver call), another datasource than the read's object, a federated + * related object, a related object of another tenancy class than the + * read's object under a walled posture (its driver options differ). The + * related read is dispatched once. (A read whose driver compiles no + * subquery is not a fallback: it is refused before this point.) * - **After planning** — the related read did not reach exactly one driver * call, or came back with rows the driver never returned (a middleware * answered without the driver, or added rows after it). @@ -75,10 +75,12 @@ * * The composed leaf is ADR-0139's: `driver-sql` (every dialect, Turso and * the WASM SQLite face included) compiles it into a nested subquery; - * `driver-memory` evaluates it in process. Every other driver keeps the id - * read: no capability bit says which drivers compile the leaf yet, so the - * engine names the ones it knows do, and an unnamed driver is never handed - * one by this lowering. + * `driver-memory` evaluates it in process. Each says so with the + * `DriverCapabilities.readableIdsLeaf` bit ({@link driverCompilesReadableIdsLeaf}). + * A driver without the bit (MongoDB, OData) is never handed one by this + * lowering: the condition is refused before anything is planned or read + * (`relation-filter-lowering.ts`#`relationSemiJoinDriverRefusal`), `INVALID_FILTER` / 400, rather + * than reaching the driver and failing there as a composition fault. * * ## Forgery * @@ -112,19 +114,30 @@ export interface RelationScopePlan { readonly rows: unknown[]; } -/** The driver names whose drivers compile (or, in process, evaluate) a composed `ReadableIds` leaf. */ -export const SEMI_JOIN_COMPILING_DRIVERS: ReadonlySet = new Set([ - 'com.objectstack.driver.sql', - 'com.objectstack.driver.turso', - 'com.objectstack.driver.sqlite-wasm', - 'com.objectstack.driver.memory', -]); +/** + * Whether `driver` compiles (or, in process, evaluates) a composed + * `ReadableIds` leaf: its `DriverCapabilities.readableIdsLeaf` bit, `true` + * exactly. Absence is `false` — a driver that declares nothing is never + * handed a leaf by the relation lowering. The one reader of the bit: the + * nested-relation `where` refusal (`relation-filter-lowering.ts`#`relationSemiJoinDriverRefusal`), + * the semi-join plan ({@link relationSemiJoinServes}) and the analytics + * relation-group refusal (`relation-group-join.ts`) all ask it here. + */ +export function driverCompilesReadableIdsLeaf(driver: { readonly supports?: unknown } | undefined): boolean { + const supports = driver?.supports; + return supports !== null && typeof supports === 'object' && (supports as { readableIdsLeaf?: unknown }).readableIdsLeaf === true; +} + +/** The driver's name as an author reads it in a refusal: its `name`, or `unnamed`. */ +export function driverNameOf(driver: { readonly name?: unknown } | undefined): string { + return typeof driver?.name === 'string' && driver.name !== '' ? driver.name : 'unnamed'; +} /** What {@link relationSemiJoinServes} reads off the engine. */ export interface RelationSemiJoinServesHost { uncomposableReadableIdsParent(object: string, parent: string): unknown; hasHooksFor(event: string, object: string): boolean; - getDriver(object: string): { readonly name?: unknown } | undefined; + getDriver(object: string): { readonly name?: unknown; readonly supports?: unknown } | undefined; /** The registered schema of `object` (`undefined` when none is registered). */ getObjectSchema(object: string): unknown; /** The tenancy posture in force, as the engine's driver options read it. */ @@ -149,7 +162,9 @@ export interface RelationSemiJoinServesHost { * options carry a tenant scope the other's do not, and the executor * boundary would fall back after the related read was already planned — * dispatching it a second time. Deciding it here dispatches it once. - * - `object`'s driver compiles the composed leaf ({@link SEMI_JOIN_COMPILING_DRIVERS}). + * - `object`'s driver compiles the composed leaf ({@link driverCompilesReadableIdsLeaf}); + * a read on one that does not never gets here on a read verb — it is + * refused first (`relation-filter-lowering.ts`#`relationSemiJoinDriverRefusal`). */ export function relationSemiJoinServes(this: RelationSemiJoinServesHost, object: string, target: string): boolean { if (this.uncomposableReadableIdsParent(object, target) !== undefined) return false; @@ -160,8 +175,7 @@ export function relationSemiJoinServes(this: RelationSemiJoinServesHost, object: postureEnforcesWall(this.resolveEnginePosture()) && isDriverTenantScopedSchema(this.getObjectSchema(object)) !== isDriverTenantScopedSchema(targetSchema) ) return false; - const name = this.getDriver(object)?.name; - return typeof name === 'string' && SEMI_JOIN_COMPILING_DRIVERS.has(name); + return driverCompilesReadableIdsLeaf(this.getDriver(object)); } /** What a planned related read answered for one leaf. */ diff --git a/packages/services/service-analytics/src/plugin.ts b/packages/services/service-analytics/src/plugin.ts index dfb07badb09..e35eb49ac72 100644 --- a/packages/services/service-analytics/src/plugin.ts +++ b/packages/services/service-analytics/src/plugin.ts @@ -499,7 +499,7 @@ export class AnalyticsServicePlugin implements Plugin { // serves the dimension by its FK-expand. Same engine as the executor // above, by construction. executeRelationGroupAggregate = async (objectName, input, relations) => { - const request: { relations: typeof relations; outcome?: { kind: string; reason?: string } } = { relations }; + const request: { relations: typeof relations; outcome?: { kind: string; reason?: string; error?: unknown } } = { relations }; const engine = requireDataEngine(); const aggregate = engine.aggregate as unknown as ( object: string, query: unknown, options: Record, @@ -508,6 +508,11 @@ export class AnalyticsServicePlugin implements Plugin { [RELATION_GROUP_BY]: request, }); if (request.outcome?.kind === 'joined') return { joined: true, rows: rows as Record[] }; + // [#33876] The read's driver compiles no semi-join: the engine's + // refusal travels back for the strategy to throw — no FK-expand. + if (request.outcome?.kind === 'refused' && request.outcome.error instanceof Error) { + return { joined: false, reason: request.outcome.error.message, refusal: request.outcome.error }; + } return { joined: false, reason: request.outcome?.reason ?? 'the "data" engine does not serve a relation group join', diff --git a/packages/services/service-analytics/src/strategies/objectql-strategy.ts b/packages/services/service-analytics/src/strategies/objectql-strategy.ts index 132270287f5..86b78240bc3 100644 --- a/packages/services/service-analytics/src/strategies/objectql-strategy.ts +++ b/packages/services/service-analytics/src/strategies/objectql-strategy.ts @@ -1783,8 +1783,12 @@ export class ObjectQLStrategy implements AnalyticsStrategy { * did not return — the rows go through the same {@link rebucketCrossObject}, * keyed per row, so the buckets and their measures are the FK-expand's. * + * Throws the engine's refusal (`INVALID_QUERY` / 400) when the read's + * driver compiles no semi-join (MongoDB, OData, [#33876]): the dimension is + * served on no path there. + * * `null` — serve by the FK-expand — when the host wired no such hook or the - * engine declined (a driver that compiles no join: memory, MongoDB, OData; + * engine declined (a driver that compiles no join: memory, Turso; * a read it cannot prove is one statement), and when anything on the way * refused with a 4xx: the FK-expand re-derives that refusal, so its order * and its envelope stay today's. @@ -1864,6 +1868,10 @@ export class ObjectQLStrategy implements AnalyticsStrategy { if (isClientRefusal(error)) return null; throw error; } + // [#33876] The read's driver compiles no semi-join (MongoDB, OData): the + // engine refused the dimension before reading anything, and no path + // serves it — thrown here, never answered by the FK-expand. + if (!answer.joined && answer.refusal !== undefined) throw answer.refusal; if (!answer.joined) return null; // Each row is one group of the joined statement. Its key for a relation diff --git a/packages/services/service-analytics/src/strategies/types.ts b/packages/services/service-analytics/src/strategies/types.ts index c8c1711a5d4..80dd2dd46ce 100644 --- a/packages/services/service-analytics/src/strategies/types.ts +++ b/packages/services/service-analytics/src/strategies/types.ts @@ -273,8 +273,10 @@ export interface DatasetScopedStrategyContext extends StrategyContext { * by its FK-expand (`resolveFkAttr`, an `id IN (…)` read of the related * object) only when this is absent or answers `joined: false`: the engine * declines every read it cannot prove is the FK-expand's own read as one - * statement (a driver that compiles no join — memory, MongoDB, OData — - * among them), before it reads anything the strategy's path reads again. + * statement (a driver that compiles no join — memory, Turso — among + * them), before it reads anything the strategy's path reads again. On a + * driver that compiles no semi-join at all (MongoDB, OData) it answers a + * `refusal` the strategy throws: no path serves the dimension there. * * `AnalyticsServicePlugin` wires it only when it bridges `executeAggregate` * itself, to the same engine. Declared HERE rather than on the spec's @@ -302,7 +304,13 @@ export interface RelationGroupAggregateRelation { readonly resolvedAlias: string; } -/** The engine's answer: the grouped rows, or why it declined (the rows path then serves). */ +/** + * The engine's answer: the grouped rows, or why it declined (the rows path + * then serves). [#33876] `refusal`: the read's driver compiles no semi-join + * (no `DriverCapabilities.readableIdsLeaf` bit: MongoDB, OData), so the + * dimension is served on NO path — the strategy throws it, `INVALID_QUERY` / + * 400, instead of falling back to its FK-expand. + */ export type RelationGroupAggregateAnswer = | { readonly joined: true; readonly rows: Record[] } - | { readonly joined: false; readonly reason: string }; + | { readonly joined: false; readonly reason: string; readonly refusal?: Error }; diff --git a/packages/spec/src/data/driver.zod.ts b/packages/spec/src/data/driver.zod.ts index 7c7871df30a..13d6234ce0e 100644 --- a/packages/spec/src/data/driver.zod.ts +++ b/packages/spec/src/data/driver.zod.ts @@ -160,6 +160,10 @@ const capRemoved = (key: string, mechanism: string) => * `aggregate()`: the engine ANDs it with method presence, because a driver * can carry `aggregate()` without compiling that key (and a subclass can * inherit a compiler its own transport refuses). + * - `readableIdsLeaf` — opt-IN for a nested-relation condition on a read + * verb: the engine plans it as a composed `ReadableIds` leaf (ADR-0139) on + * a driver that declares it, and refuses it up front (`INVALID_FILTER` / + * 400) on one that does not, before any related read runs. * * Everything else IS the method: aggregate pushdown gates on * `typeof driver.aggregate === 'function'`, schema sync on @@ -338,6 +342,36 @@ export const DriverCapabilitiesSchema = lazySchema(() => z.object({ */ aggregationFilter: z.boolean().optional().describe('`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)'), + /** + * This driver compiles (or, in process, evaluates) a composed `ReadableIds` + * leaf (ADR-0139 D1/D3): `field IN (SELECT id FROM WHERE + * AND )` as one statement on the SQL family, a read of the + * related rows then a member test in `driver-memory`. + * + * What the engine does with it: a nested-relation condition on a read verb + * (`{ account: { region: 'NA' } }` on `find`, `findOne`, `count`, + * `aggregate`) beneath a single-valued relation is planned as that leaf + * when this bit is `true`; when it is absent the engine REFUSES the + * condition before planning or reading anything, `INVALID_FILTER` / 400, + * naming the driver and the two-step route (read the related object, then + * match the relation field against its ids). An analytics dimension + * through a lookup is refused on such a driver the same way, before any + * read (`INVALID_QUERY` / 400). The same bit decides both. + * + * Why a bit and not method presence: no driver method says whether the + * filter compiler understands the leaf — every driver has `find()`. A + * driver that cannot compile it (MongoDB, OData) used to be reached with + * it and refused from inside the driver as a composition fault + * (`INTERNAL_ERROR` / 500), which an author cannot act on. + * + * ⛔ Not a way to say "this condition, today". It describes the driver's + * filter compiler, is read at dispatch time, and a driver whose transport + * compiles the leaf only sometimes should not declare it. + * + * Optional; absence means `false`, like `batchSchemaSync`. + */ + readableIdsLeaf: z.boolean().optional().describe('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)'), + // ============================================================================ // Retired capability bits (#4634, ADR-0049 enforce-or-remove) — 17.0.0 // ============================================================================ From 8ed0b000b5d7b28a3437773c59e91ec31cd918ef Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:34:05 +0000 Subject: [PATCH 02/15] test(objectql): pin the up-front refusal on a driver without readableIdsLeaf; doubles declare the bit Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- .../src/credential-evaluation-guard.test.ts | 4 +- .../engine-nested-relation-lowering.test.ts | 71 +++++++++++++++---- ...ne-readable-ids-nested-composition.test.ts | 11 +-- .../src/query-expression-conformance.test.ts | 5 +- .../objectql/src/relation-group-join.test.ts | 34 +++++++-- packages/spec/authorable-surface/data.json | 1 + 6 files changed, 98 insertions(+), 28 deletions(-) diff --git a/packages/objectql/src/credential-evaluation-guard.test.ts b/packages/objectql/src/credential-evaluation-guard.test.ts index 24ee9d2ae90..f8b0fdc499d 100644 --- a/packages/objectql/src/credential-evaluation-guard.test.ts +++ b/packages/objectql/src/credential-evaluation-guard.test.ts @@ -26,7 +26,9 @@ function makeRecordingDriver() { return true; }; const driver: any = { - name: 'memory', version: '0.0.0', supports: {}, + // [#33876] Declares the `readableIdsLeaf` bit: a nested-relation + // condition on a read verb is refused up front on a driver without it. + name: 'memory', version: '0.0.0', supports: { readableIdsLeaf: true }, async connect() {}, async disconnect() {}, async checkHealth() { return true; }, async execute() { return null; }, async find(object: string, ast: any) { diff --git a/packages/objectql/src/engine-nested-relation-lowering.test.ts b/packages/objectql/src/engine-nested-relation-lowering.test.ts index c0faff56c92..e542ba3a315 100644 --- a/packages/objectql/src/engine-nested-relation-lowering.test.ts +++ b/packages/objectql/src/engine-nested-relation-lowering.test.ts @@ -72,17 +72,19 @@ interface SeenRead { object: string; ast: any } /** * A recording driver. A read of the object named in `answers` returns those * rows (the related read's matches); every other read returns none. Writes - * are recorded, never applied. It answers to `name` — by default the SQL - * driver's, one of the drivers the engine plans a semi-join for - * (`SEMI_JOIN_COMPILING_DRIVERS`); any other name keeps the id read. + * are recorded, never applied. It answers to `name` (by default the SQL + * driver's) and declares `supports` — by default the + * `DriverCapabilities.readableIdsLeaf` bit the engine plans a semi-join on + * ([#33876]); a driver without it is refused a single-valued relation + * condition on a read verb up front. */ -function makeRecordingDriver(name = 'com.objectstack.driver.sql') { +function makeRecordingDriver(name = 'com.objectstack.driver.sql', supports: Record = { readableIdsLeaf: true }) { const reads: SeenRead[] = []; const writes: SeenRead[] = []; const answers = new Map>>(); const rowsOf = (o: string) => answers.get(o) ?? []; const driver: any = { - name, version: '0.0.0', supports: {}, + name, version: '0.0.0', supports, async connect() {}, async disconnect() {}, async checkHealth() { return true; }, async execute() { return null; }, async find(o: string, ast: any) { reads.push({ object: o, ast }); return rowsOf(o); }, async findOne(o: string, ast: any) { reads.push({ object: o, ast }); return rowsOf(o)[0] ?? null; }, @@ -453,8 +455,8 @@ describe('[#20802] the nested-relation form is lowered at the engine\'s where se describe('[#33626] the semi-join falls back to the id read wherever it is not provably that read', () => { const OUTER_REF = { owner: { $in: ['u1'] } }; - async function makeEngine(driverName?: string) { - const rec = makeRecordingDriver(driverName); + async function makeEngine(driverName?: string, supports?: Record) { + const rec = makeRecordingDriver(driverName, supports); const engine = new ObjectQL(); engine.registerDriver(rec.driver, true); await engine.init(); @@ -479,17 +481,56 @@ describe('[#33626] the semi-join falls back to the id read wherever it is not pr expect(normalized(r.outerWhere), name).toEqual({ owner: { $in: ids } }); } - it('a driver that compiles no subquery (MongoDB, OData, any unnamed driver) keeps the capped id read', async () => { - for (const name of ['com.objectstack.driver.mongodb', 'com.objectstack.driver.odata', 'recording']) { - const { engine, rec } = await makeEngine(name); - rec.answers.set(OWNER, idRows('u1')); - expectIdRead(await readsOf(engine, rec), ['u1'], name); - // …and past the cap it is refused as it always was, never run over a cut-off list. - rec.answers.set(OWNER, Array.from({ length: RELATION_FILTER_ID_CAP + 1 }, (_, i) => ({ id: `u${i}` }))); - expect(envelopeOf(await refusalOf(engine.find(OBJECT, { where: { owner: { region: 'NA' } } }))), name).toEqual(INVALID_FILTER); + // [#33876, the maintainer's ruling A on #33626's Q2] The bit decides, not + // the name: a driver without `readableIdsLeaf` (MongoDB, OData, any driver + // that declares nothing) is REFUSED the condition before any related read is + // planned or run — no id read, no driver call — and the refusal names the + // driver. Every read verb; a multi-valued relation and a write verb keep the + // capped id read there. + it('[#33876] a driver without the readableIdsLeaf bit (MongoDB, OData, an undeclared driver) is refused up front: INVALID_FILTER / 400, nothing read', async () => { + for (const name of ['com.objectstack.driver.mongodb', 'com.objectstack.driver.odata', 'recording', 'com.objectstack.driver.sql']) { + for (const supports of [{}, { readableIdsLeaf: false }, { readableIdsLeaf: 'true' }]) { + const label = `${name} ${JSON.stringify(supports)}`; + const { engine, rec } = await makeEngine(name, supports); + rec.answers.set(OWNER, idRows('u1')); + const where = { owner: { region: 'NA' } }; + const verbs: Array<[string, () => Promise]> = [ + ['find', () => engine.find(OBJECT, { where })], + ['findOne', () => engine.findOne(OBJECT, { where })], + ['count', () => engine.count(OBJECT, { where })], + ['aggregate', () => engine.aggregate(OBJECT, { where, aggregations: [{ function: 'count', alias: 'n' }] } as EngineAggregateOptions)], + ]; + for (const [verb, run] of verbs) { + rec.reads.length = 0; + const err = await refusalOf(run()); + expect(envelopeOf(err), `${label} ${verb}`).toEqual(INVALID_FILTER); + expect(err?.message, `${label} ${verb}`).toContain(`'${name}'`); + expect(rec.reads, `${label} ${verb}: nothing read`).toEqual([]); + } + // Inside $or / $not alike — every site is judged before anything is read. + rec.reads.length = 0; + expect(envelopeOf(await refusalOf(engine.find(OBJECT, { where: { $or: [{ title: 'a' }, { $not: where }] } }))), label).toEqual(INVALID_FILTER); + expect(rec.reads, label).toEqual([]); + // A multi-valued relation keeps the capped id read on that driver… + rec.reads.length = 0; + await engine.find(OBJECT, { where: { owners: { region: 'NA' } } }); + expect(rec.reads.filter((r) => r.object === OWNER), label).toHaveLength(1); + // …and so does a write verb's `where`. + rec.writes.length = 0; + await engine.update(OBJECT, { title: 'b' }, { where, multi: true }); + expect(normalized(rec.writes[rec.writes.length - 1]?.ast?.where), label).toEqual({ owner: { $in: ['u1'] } }); + } } }); + it('[#33876] CONTROL the bit decides, not the name: a driver named MongoDB that declares readableIdsLeaf plans the semi-join', async () => { + const { engine, rec } = await makeEngine('com.objectstack.driver.mongodb', { readableIdsLeaf: true }); + rec.answers.set(OWNER, idRows('u1')); + const r = await readsOf(engine, rec); + expect(r.related).toHaveLength(0); + expect(normalized(r.outerWhere)).toEqual({ owner: { $in: { SEMI_JOIN: OWNER, scope: { region: 'NA' } } } }); + }); + it('CONTROL a compiling driver plans the read: no id read, one composed leaf', async () => { const { engine, rec } = await makeEngine(); rec.answers.set(OWNER, idRows('u1')); diff --git a/packages/objectql/src/engine-readable-ids-nested-composition.test.ts b/packages/objectql/src/engine-readable-ids-nested-composition.test.ts index 4926dfe131f..eaa9a42b96d 100644 --- a/packages/objectql/src/engine-readable-ids-nested-composition.test.ts +++ b/packages/objectql/src/engine-readable-ids-nested-composition.test.ts @@ -49,10 +49,10 @@ function wire(engine: ObjectQL, source: unknown): void { (engine as unknown as Record)[SECURITY_SERVICE_SOURCE_SLOT] = source; } -function makeRecordingDriver(name = 'recording') { +function makeRecordingDriver(name = 'recording', supports: Record = {}) { const calls: SeenCall[] = []; const driver: any = { - name, version: '0.0.0', supports: {}, + name, version: '0.0.0', supports, async connect() {}, async disconnect() {}, async checkHealth() { return true; }, async execute() { return null; }, async find(object: string, ast: any) { calls.push({ verb: 'find', object, ast }); return []; }, async findOne(object: string, ast: any) { calls.push({ verb: 'findOne', object, ast }); return null; }, @@ -533,9 +533,10 @@ describe('[#33696 ruling 6893666857] the required master\'s leaf over an unrestr }); it('a condition the caller writes on the required master, in the same read, is never dropped with the master\'s own leaf', async () => { - // A driver the nested-relation lowering plans a subquery for: the - // caller's `{ opp: { name: 'x' } }` becomes a leaf over the same master. - const rec = makeRecordingDriver('com.objectstack.driver.sql'); + // A driver the nested-relation lowering plans a subquery for (it declares + // the `readableIdsLeaf` bit, [#33876]): the caller's `{ opp: { name: 'x' } }` + // becomes a leaf over the same master. + const rec = makeRecordingDriver('com.objectstack.driver.sql', { readableIdsLeaf: true }); const planned = new ObjectQL(); planned.registerDriver(rec.driver, true); await planned.init(); diff --git a/packages/objectql/src/query-expression-conformance.test.ts b/packages/objectql/src/query-expression-conformance.test.ts index 9fc6b77c609..f62704efab5 100644 --- a/packages/objectql/src/query-expression-conformance.test.ts +++ b/packages/objectql/src/query-expression-conformance.test.ts @@ -214,7 +214,10 @@ function makeStubDriver() { const driver: any = { name: 'memory', version: '0.0.0', - supports: {} as any, + // [#33876] It evaluates a composed `ReadableIds` leaf (above), and says + // so: a nested-relation condition on a read verb is refused up front + // on a driver without the bit. + supports: { readableIdsLeaf: true } as any, async connect() {}, async disconnect() {}, async checkHealth() { return true; }, diff --git a/packages/objectql/src/relation-group-join.test.ts b/packages/objectql/src/relation-group-join.test.ts index eb222cfc666..ea588ca7eca 100644 --- a/packages/objectql/src/relation-group-join.test.ts +++ b/packages/objectql/src/relation-group-join.test.ts @@ -48,11 +48,16 @@ const LINE_OBJECT = { interface SeenCall { verb: string; object: string; ast: any } -function makeRecordingDriver(name: string) { +/** + * `supports` defaults to the `DriverCapabilities.readableIdsLeaf` bit every + * SQL face and `driver-memory` declare ([#33876]); MongoDB and OData declare + * nothing. + */ +function makeRecordingDriver(name: string, supports: Record = { readableIdsLeaf: true }) { const calls: SeenCall[] = []; let answer: Array> = []; const driver: any = { - name, version: '0.0.0', supports: {}, + name, version: '0.0.0', supports, async connect() {}, async disconnect() {}, async checkHealth() { return true; }, async execute() { return null; }, async find(o: string, ast: any) { calls.push({ verb: 'find', object: o, ast }); return []; }, async findOne(o: string, ast: any) { calls.push({ verb: 'findOne', object: o, ast }); return null; }, @@ -82,8 +87,8 @@ const request = (over: Partial = {} const BASE_QUERY = { groupBy: ['region'], aggregations: [{ function: 'sum' as const, field: 'amount', alias: 'total' }] }; -async function makeEngine(driverName: string) { - const rec = makeRecordingDriver(driverName); +async function makeEngine(driverName: string, supports?: Record) { + const rec = makeRecordingDriver(driverName, supports); const engine = new ObjectQL(); engine.registerDriver(rec.driver, true); await engine.init(); @@ -200,8 +205,8 @@ describe('relation group join — served as one driver statement whose related h }); describe('relation group join — DECLINED, with nothing read, wherever it is not provably the FK-expand\'s read', () => { - for (const name of ['com.objectstack.driver.memory', 'com.objectstack.driver.mongodb', 'com.objectstack.driver.odata', 'com.objectstack.driver.turso']) { - it(`a driver that compiles no join (${name}): declined, no driver call — the caller's own path serves it`, async () => { + for (const name of ['com.objectstack.driver.memory', 'com.objectstack.driver.turso']) { + it(`a driver that compiles no join but declares readableIdsLeaf (${name}): declined, no driver call — the caller's own path serves it`, async () => { const { engine, rec } = await makeEngine(name); const req = request(); const rows = await engine.aggregate(LINE, BASE_QUERY, { [RELATION_GROUP_BY]: req } as never); @@ -211,6 +216,23 @@ describe('relation group join — DECLINED, with nothing read, wherever it is no }); } + // [#33876] The dimension half of the maintainer's ruling A on #33626's Q2: + // a driver without the bit is REFUSED, not declined — the outcome carries + // the error the caller throws instead of serving its FK-expand. + for (const name of ['com.objectstack.driver.mongodb', 'com.objectstack.driver.odata', 'com.objectstack.driver.sql']) { + it(`[#33876] a driver without readableIdsLeaf (${name}): refused, INVALID_QUERY / 400 on the outcome, no driver call`, async () => { + const { engine, rec } = await makeEngine(name, {}); + const req = request(); + const rows = await engine.aggregate(LINE, BASE_QUERY, { [RELATION_GROUP_BY]: req } as never); + expect(rows).toEqual([]); + expect(req.outcome?.kind).toBe('refused'); + const err = (req.outcome as { error?: Error & { code?: string; status?: number } }).error; + expect({ code: err?.code, status: err?.status }).toEqual({ code: 'INVALID_QUERY', status: 400 }); + expect(err?.message).toContain(`'${name}'`); + expect(rec.calls).toEqual([]); + }); + } + it('a multi-valued relation: declined', async () => { const { engine, rec } = await makeEngine('com.objectstack.driver.sql'); const req = request({ field: 'opportunities' }); diff --git a/packages/spec/authorable-surface/data.json b/packages/spec/authorable-surface/data.json index f99d4facb2d..e914fe817a5 100644 --- a/packages/spec/authorable-surface/data.json +++ b/packages/spec/authorable-surface/data.json @@ -212,6 +212,7 @@ "data/DriverCapabilities:querySubqueries [RETIRED]", "data/DriverCapabilities:queryWindowFunctions [RETIRED]", "data/DriverCapabilities:read [RETIRED]", + "data/DriverCapabilities:readableIdsLeaf", "data/DriverCapabilities:savepoints [RETIRED]", "data/DriverCapabilities:schemaSync [RETIRED]", "data/DriverCapabilities:streaming [RETIRED]", From 2894eca782040905e540c044eebd434f2dfeeeb8 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:37:10 +0000 Subject: [PATCH 03/15] test(spec): readableIdsLeaf is the sixth live driver capability bit; regenerate the driver reference pages Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- content/docs/references/data/driver-nosql.mdx | 1 + content/docs/references/data/driver-sql.mdx | 1 + content/docs/references/data/driver.mdx | 2 ++ packages/spec/src/data/driver.test.ts | 16 +++++++++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/content/docs/references/data/driver-nosql.mdx b/content/docs/references/data/driver-nosql.mdx index 81eb356ce1f..0d019f1140d 100644 --- a/content/docs/references/data/driver-nosql.mdx +++ b/content/docs/references/data/driver-nosql.mdx @@ -166,6 +166,7 @@ const result = AggregationPipelineSchema.parse(data); | **batchSchemaSync** | `boolean` | optional | Supports batched schema sync to reduce schema DDL round-trips (absence = false) | | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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) | +| **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. | diff --git a/content/docs/references/data/driver-sql.mdx b/content/docs/references/data/driver-sql.mdx index 0e33d1f5635..f86b0306de1 100644 --- a/content/docs/references/data/driver-sql.mdx +++ b/content/docs/references/data/driver-sql.mdx @@ -79,6 +79,7 @@ const result = DataTypeMappingSchema.parse(data); | **batchSchemaSync** | `boolean` | optional | Supports batched schema sync to reduce schema DDL round-trips (absence = false) | | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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) | +| **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. | diff --git a/content/docs/references/data/driver.mdx b/content/docs/references/data/driver.mdx index 707842e7435..bf77f5e97e2 100644 --- a/content/docs/references/data/driver.mdx +++ b/content/docs/references/data/driver.mdx @@ -33,6 +33,7 @@ const result = DriverCapabilitiesSchema.parse(data); | **batchSchemaSync** | `boolean` | optional | Supports batched schema sync to reduce schema DDL round-trips (absence = false) | | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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) | +| **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. | @@ -89,6 +90,7 @@ const result = DriverCapabilitiesSchema.parse(data); | **batchSchemaSync** | `boolean` | optional | Supports batched schema sync to reduce schema DDL round-trips (absence = false) | | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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) | +| **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. | diff --git a/packages/spec/src/data/driver.test.ts b/packages/spec/src/data/driver.test.ts index fe9a8032e73..cb3f51e9876 100644 --- a/packages/spec/src/data/driver.test.ts +++ b/packages/spec/src/data/driver.test.ts @@ -61,6 +61,11 @@ const RETIRED_BITS = [ * * `aggregationFilter` is the fifth, under the same rule: `engine.aggregate` * reads it (with method presence) to send a per-measure filter to the driver. + * + * [#33876] `readableIdsLeaf` is the sixth, under the same rule: no method + * says whether a driver's filter compiler understands a composed `ReadableIds` + * leaf (every driver has `find()`), and the engine's nested-relation lowering + * reads it to plan the semi-join or refuse the condition up front. */ const LIVE_BITS = [ 'queryDateGranularity', @@ -68,6 +73,7 @@ const LIVE_BITS = [ 'batchSchemaSync', 'transactionsUnsupported', 'aggregationFilter', + 'readableIdsLeaf', ] as const; describe('DriverCapabilitiesSchema', () => { @@ -78,6 +84,7 @@ describe('DriverCapabilitiesSchema', () => { batchSchemaSync: true, transactionsUnsupported: true, aggregationFilter: true, + readableIdsLeaf: true, }; expect(() => DriverCapabilitiesSchema.parse(capabilities)).not.toThrow(); @@ -95,13 +102,20 @@ describe('DriverCapabilitiesSchema', () => { expect(parsed).not.toHaveProperty('transactionsUnsupported'); // Absent = the engine aggregates a filtered measure in memory, as before the bit. expect(parsed).not.toHaveProperty('aggregationFilter'); + // [#33876] Absent = no semi-join leaf: the engine refuses a nested-relation + // condition on a read verb up front. + expect(parsed).not.toHaveProperty('readableIdsLeaf'); }); it('refuses a non-boolean aggregationFilter', () => { expect(DriverCapabilitiesSchema.safeParse({ aggregationFilter: 'yes' }).success).toBe(false); }); - it('declares exactly the audited shape: 5 live bits + 31 tombstones', () => { + it('refuses a non-boolean readableIdsLeaf', () => { + expect(DriverCapabilitiesSchema.safeParse({ readableIdsLeaf: 'yes' }).success).toBe(false); + }); + + it('declares exactly the audited shape: 6 live bits + 31 tombstones', () => { const shape = (DriverCapabilitiesSchema as unknown as { shape: Record }).shape; const keys = Object.keys(shape).sort(); expect(keys).toEqual([...RETIRED_BITS, ...LIVE_BITS].slice().sort()); From 1d8bacbb66f29bdee040db8dd2393df2c7dccd40 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:40:08 +0000 Subject: [PATCH 04/15] test(service-analytics): a lookup dimension on a driver without readableIdsLeaf is refused up front, no FK-expand Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- .../cross-object-relation-group-join.test.ts | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/packages/services/service-analytics/src/__tests__/cross-object-relation-group-join.test.ts b/packages/services/service-analytics/src/__tests__/cross-object-relation-group-join.test.ts index 6a24abe3d36..fd60e3f859c 100644 --- a/packages/services/service-analytics/src/__tests__/cross-object-relation-group-join.test.ts +++ b/packages/services/service-analytics/src/__tests__/cross-object-relation-group-join.test.ts @@ -463,3 +463,65 @@ describe('[#22661] the related object\'s API exposure: the joined path answers i }); } }); + +describe('[#33876] a driver that compiles no semi-join (no readableIdsLeaf bit: MongoDB, OData) refuses the dimension up front', () => { + /** The driver's own capability record, re-declared on this instance only. */ + const redeclare = (driver: SqliteWasmDriver, over: { name?: string; supports: Record }) => { + Object.defineProperty(driver, 'supports', { value: over.supports, configurable: true }); + if (over.name !== undefined) Object.defineProperty(driver, 'name', { value: over.name, configurable: true }); + }; + /** Every driver read, by verb and object. */ + const recordReads = (driver: SqliteWasmDriver): string[] => { + const seen: string[] = []; + for (const verb of ['find', 'findOne', 'count', 'aggregate'] as const) { + const own = (driver as unknown as Record unknown>)[verb]!.bind(driver); + Object.defineProperty(driver, verb, { + value: (object: string, ...rest: unknown[]) => { seen.push(`${verb}:${object}`); return own(object, ...rest); }, + configurable: true, + }); + } + return seen; + }; + const QUERY = { cube: dataset.name, dimensions: ['stage'], measures: ['line_count'] } as AnalyticsQuery; + + it('without the bit: INVALID_QUERY / 400 naming the driver, the outcome is refused, and the driver is never asked — no FK-expand', async () => { + process.env.OS_TENANCY_POSTURE = 'isolated'; + const { engine, driver } = await seeded(); + try { + const { readableIdsLeaf: _dropped, ...rest } = driver.supports as Record; + redeclare(driver, { name: 'com.objectstack.driver.mongodb', supports: rest }); + const reads = recordReads(driver); + const outcomes: unknown[] = []; + const service = await pluginService(engine, true, outcomes); + const err = await service.query(QUERY, ADMIN_A).then(() => null, (e: Error & { code?: string; status?: number }) => e); + expect(envelopeOf(err)).toEqual({ code: 'INVALID_QUERY', status: 400 }); + expect(err?.message).toContain("'com.objectstack.driver.mongodb'"); + expect(outcomes).toHaveLength(1); + expect((outcomes[0] as { kind?: unknown }).kind).toBe('refused'); + expect(reads, 'nothing was read: not the base aggregate, not the related object').toEqual([]); + } finally { + await driver.disconnect?.(); + if (OLD_POSTURE === undefined) delete process.env.OS_TENANCY_POSTURE; + else process.env.OS_TENANCY_POSTURE = OLD_POSTURE; + } + }); + + it('CONTROL a driver that declares the bit but compiles no join (the Turso and in-memory shape) is declined, and the FK-expand serves the dimension', async () => { + process.env.OS_TENANCY_POSTURE = 'isolated'; + const { engine, driver } = await seeded(); + try { + redeclare(driver, { name: 'com.objectstack.driver.turso', supports: { ...(driver.supports as Record), readableIdsLeaf: true } }); + const outcomes: unknown[] = []; + const service = await pluginService(engine, true, outcomes); + const { rows } = await service.query(QUERY, ADMIN_A); + expect((outcomes[0] as { kind?: unknown }).kind).toBe('declined'); + const reference = await (await pluginService(engine, false)).query(QUERY, ADMIN_A); + expect(sorted(rows)).toEqual(sorted(reference.rows)); + expect(rows.length).toBeGreaterThan(0); + } finally { + await driver.disconnect?.(); + if (OLD_POSTURE === undefined) delete process.env.OS_TENANCY_POSTURE; + else process.env.OS_TENANCY_POSTURE = OLD_POSTURE; + } + }); +}); From 957fd50adbb4c214060fe83aad6c21c8cbf8b3d2 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:44:09 +0000 Subject: [PATCH 05/15] test(drivers): memory declares readableIdsLeaf, mongodb does not; changeset Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- .changeset/33876-readable-ids-leaf-refusal.md | 20 +++++++++++++++++++ .../driver-memory/src/memory-driver.test.ts | 7 +++++-- .../mongodb-readable-ids-conformance.test.ts | 13 ++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .changeset/33876-readable-ids-leaf-refusal.md diff --git a/.changeset/33876-readable-ids-leaf-refusal.md b/.changeset/33876-readable-ids-leaf-refusal.md new file mode 100644 index 00000000000..ef9fff8a93a --- /dev/null +++ b/.changeset/33876-readable-ids-leaf-refusal.md @@ -0,0 +1,20 @@ +--- +'@objectstack/spec': patch +'@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 +Metadata-protocol: none + +**`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, capped at 1,000 matches. A multi-valued relation and the `where` of `update` / `delete` keep that capped id read on every driver. + +**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. + +**Who sees a change.** Only a deployment whose data lives on MongoDB or OData, or on a third-party driver that does not declare the bit. A third-party driver whose filter compiler composes the leaf declares `supports.readableIdsLeaf: true` to keep serving these conditions. diff --git a/packages/drivers/driver-memory/src/memory-driver.test.ts b/packages/drivers/driver-memory/src/memory-driver.test.ts index e189a1e0000..7db102c6c2c 100644 --- a/packages/drivers/driver-memory/src/memory-driver.test.ts +++ b/packages/drivers/driver-memory/src/memory-driver.test.ts @@ -260,11 +260,14 @@ describe('InMemoryDriver', () => { expect(results[0].name).toBe('Alice'); }); - it('advertises no capability bits — transactions are expressed by the methods (#4634)', () => { + it('advertises only readableIdsLeaf — transactions are expressed by the methods (#4634)', () => { // `supports.transactions` was one of the 31 inert bits retired in #4634: // the engine gates transaction use on `driver.beginTransaction` presence // (proven by the rollback test above), never on a boolean. - expect(driver.supports).toEqual({}); + // [#33876] The one bit it declares: it evaluates a composed + // `ReadableIds` leaf in process, so the engine plans a nested-relation + // condition on a read verb as that leaf here instead of refusing it. + expect(driver.supports).toEqual({ readableIdsLeaf: true }); }); }); diff --git a/packages/drivers/driver-mongodb/src/mongodb-readable-ids-conformance.test.ts b/packages/drivers/driver-mongodb/src/mongodb-readable-ids-conformance.test.ts index c0b9b50a36b..f06bd26e378 100644 --- a/packages/drivers/driver-mongodb/src/mongodb-readable-ids-conformance.test.ts +++ b/packages/drivers/driver-mongodb/src/mongodb-readable-ids-conformance.test.ts @@ -23,6 +23,7 @@ import { lowerFilterCondition, } from '@objectstack/spec/data'; import { translateFilter } from './mongodb-filter.js'; +import { MongoDBDriver } from './mongodb-driver.js'; import { buildAggregationPipeline } from './mongodb-aggregation.js'; const seamed = (where: unknown): any => lowerFilterCondition(where, { isDatetimeColumn: () => false }); @@ -90,3 +91,15 @@ describe('[ADR-0139 D3] driver-mongodb — ReadableIds conformance (refusing dri } }); }); + +describe('[#33876] driver-mongodb does not declare the readableIdsLeaf capability', () => { + // The engine reads this bit to plan a nested-relation condition as a + // composed leaf; without it the condition is refused up front, + // INVALID_FILTER / 400, before any related read. Declaring it while the + // filter translation above refuses the leaf would turn that 400 back into + // this driver's 500. + it('its supports record carries no readableIdsLeaf', () => { + const driver = new MongoDBDriver({ url: 'mongodb://127.0.0.1:1/never-connected', database: 'never_connected' }); + expect(driver.supports).not.toHaveProperty('readableIdsLeaf'); + }); +}); From 642664abcda37b27ec3593bceb6e9617662ddf48 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:45:00 +0000 Subject: [PATCH 06/15] docs: a driver without readableIdsLeaf refuses a nested-relation condition up front, no longer a fallback case Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- content/docs/kernel/contracts/data-engine.mdx | 12 +++++++++--- content/docs/protocol/objectql/query-syntax.mdx | 12 ++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/content/docs/kernel/contracts/data-engine.mdx b/content/docs/kernel/contracts/data-engine.mdx index fdfd6b1389c..19d28b2f27b 100644 --- a/content/docs/kernel/contracts/data-engine.mdx +++ b/content/docs/kernel/contracts/data-engine.mdx @@ -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 @@ -213,8 +213,6 @@ 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 @@ -222,6 +220,14 @@ single-valued relation on a read verb in each of these cases: 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. diff --git a/content/docs/protocol/objectql/query-syntax.mdx b/content/docs/protocol/objectql/query-syntax.mdx index 795d7297bbf..e4a299ba10b 100644 --- a/content/docs/protocol/objectql/query-syntax.mdx +++ b/content/docs/protocol/objectql/query-syntax.mdx @@ -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. @@ -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 From 30c270d2771cd8e5ea91a4fe0423e9de5edfd6e6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 23:05:07 +0000 Subject: [PATCH 07/15] chore(spec): record readableIdsLeaf in the authorable surface; changeset declares the added key Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- .changeset/33876-readable-ids-leaf-refusal.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.changeset/33876-readable-ids-leaf-refusal.md b/.changeset/33876-readable-ids-leaf-refusal.md index ef9fff8a93a..4f5f01b8bbf 100644 --- a/.changeset/33876-readable-ids-leaf-refusal.md +++ b/.changeset/33876-readable-ids-leaf-refusal.md @@ -1,5 +1,5 @@ --- -'@objectstack/spec': patch +'@objectstack/spec': minor '@objectstack/objectql': patch '@objectstack/driver-sql': patch '@objectstack/driver-memory': patch @@ -9,7 +9,8 @@ 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 -Metadata-protocol: none +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) **`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`. From 4c649ca0a1a8dcb3894c1fb5a0d0692031a9dd0c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 01:08:50 +0000 Subject: [PATCH 08/15] fix(objectql): type the relation group refusal's attribute read explicitly The readonly relations array narrowed to any[] under Array.isArray, so the attribute callbacks were implicitly any and objectql's typecheck failed. Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- packages/objectql/src/relation-group-join.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/objectql/src/relation-group-join.ts b/packages/objectql/src/relation-group-join.ts index e0fc952dde4..46c00084474 100644 --- a/packages/objectql/src/relation-group-join.ts +++ b/packages/objectql/src/relation-group-join.ts @@ -313,12 +313,14 @@ export function relationGroupDriverRefusal( driver: { readonly name?: unknown; readonly supports?: unknown } | undefined, ): Error | undefined { if (driverCompilesReadableIdsLeaf(driver)) return undefined; - const relation = Array.isArray(request.relations) ? request.relations[0] : undefined; + const relations: readonly RelationGroupBy[] = Array.isArray(request.relations) ? request.relations : []; + const relation: RelationGroupBy | undefined = relations[0]; const field = typeof relation?.field === 'string' ? relation.field : 'the relation field'; const target = typeof relation?.object === 'string' ? relation.object : 'the related object'; - const attrs = Array.isArray(relation?.attrs) - ? relation.attrs.map((a) => a?.attr).filter((a): a is string => typeof a === 'string') - : []; + const declared: readonly RelationGroupAttribute[] = Array.isArray(relation?.attrs) ? relation.attrs : []; + const attrs = declared + .map((entry: RelationGroupAttribute | undefined) => entry?.attr) + .filter((attr: unknown): attr is string => typeof attr === 'string'); const what = attrs.length > 0 ? attrs.map((a) => `'${a}'`).join(', ') : 'its attributes'; const err = new Error( `aggregate('${object}'): grouping by ${what} of '${target}' through '${object}.${field}' cannot run on ` From cc31d3f7b6c50ed7c720d61bbea6f9f5c9840b29 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 02:26:57 +0000 Subject: [PATCH 09/15] fix(spec): restore the readableIdsLeaf schema entry after the lockRows merge and declare the narrowing Regenerates the authorable surface and driver reference pages from the merged tree. The DriverCapabilities TSDoc now states what a driver without the bit got before (a capped id read: up to 1,000 related matches served, refused past them) and the live-bit list names the analytics dimension reader. The changeset declares the narrowing arm, with the BREAKING migration and its ADR-0087 disposition. Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- .changeset/33876-readable-ids-leaf-refusal.md | 13 ++++++++++--- content/docs/references/data/driver-nosql.mdx | 1 + content/docs/references/data/driver-sql.mdx | 1 + content/docs/references/data/driver.mdx | 3 +++ packages/spec/authorable-surface/data.json | 2 ++ packages/spec/src/data/driver.zod.ts | 2 ++ 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.changeset/33876-readable-ids-leaf-refusal.md b/.changeset/33876-readable-ids-leaf-refusal.md index 4f5f01b8bbf..09985d349fd 100644 --- a/.changeset/33876-readable-ids-leaf-refusal.md +++ b/.changeset/33876-readable-ids-leaf-refusal.md @@ -8,14 +8,21 @@ 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 +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) + + +**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. +- 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, capped at 1,000 matches. A multi-valued relation and the `where` of `update` / `delete` keep that capped id read on every driver. +**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 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. -**Who sees a change.** Only a deployment whose data lives on MongoDB or OData, or on a third-party driver that does not declare the bit. A third-party driver whose filter compiler composes the leaf declares `supports.readableIdsLeaf: true` to keep serving these conditions. diff --git a/content/docs/references/data/driver-nosql.mdx b/content/docs/references/data/driver-nosql.mdx index 0d019f1140d..ebf018a85b7 100644 --- a/content/docs/references/data/driver-nosql.mdx +++ b/content/docs/references/data/driver-nosql.mdx @@ -166,6 +166,7 @@ const result = AggregationPipelineSchema.parse(data); | **batchSchemaSync** | `boolean` | optional | Supports batched schema sync to reduce schema DDL round-trips (absence = false) | | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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) | | **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. | diff --git a/content/docs/references/data/driver-sql.mdx b/content/docs/references/data/driver-sql.mdx index f86b0306de1..71994d98916 100644 --- a/content/docs/references/data/driver-sql.mdx +++ b/content/docs/references/data/driver-sql.mdx @@ -79,6 +79,7 @@ const result = DataTypeMappingSchema.parse(data); | **batchSchemaSync** | `boolean` | optional | Supports batched schema sync to reduce schema DDL round-trips (absence = false) | | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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) | | **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. | diff --git a/content/docs/references/data/driver.mdx b/content/docs/references/data/driver.mdx index bf77f5e97e2..2cd3228bec2 100644 --- a/content/docs/references/data/driver.mdx +++ b/content/docs/references/data/driver.mdx @@ -33,6 +33,7 @@ const result = DriverCapabilitiesSchema.parse(data); | **batchSchemaSync** | `boolean` | optional | Supports batched schema sync to reduce schema DDL round-trips (absence = false) | | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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) | | **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. | @@ -90,6 +91,7 @@ const result = DriverCapabilitiesSchema.parse(data); | **batchSchemaSync** | `boolean` | optional | Supports batched schema sync to reduce schema DDL round-trips (absence = false) | | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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) | | **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. | @@ -151,6 +153,7 @@ const result = DriverCapabilitiesSchema.parse(data); | **timezone** | `string` | optional | Business reference timezone (IANA) for date-dependent generation, e.g. autonumber date tokens | | **preserveAudit** | `boolean` | optional | Historical import: keep a supplied updated_at instead of force-stamping now (from ExecutionContext.preserveAudit) | | **bypassTenantAudit** | `boolean` | optional | Suppress the driver tenant-audit warning for a deliberately global write on a tenant-scoped object (diagnostics only — never changes what the write touches) | +| **lockRows** | `boolean` | optional | find() inside a transaction: lock the returned rows against concurrent writers until the transaction ends (SELECT … FOR UPDATE); honoured only by a driver declaring supports.lockRows | --- diff --git a/packages/spec/authorable-surface/data.json b/packages/spec/authorable-surface/data.json index e914fe817a5..baf080a6083 100644 --- a/packages/spec/authorable-surface/data.json +++ b/packages/spec/authorable-surface/data.json @@ -200,6 +200,7 @@ "data/DriverCapabilities:joins [RETIRED]", "data/DriverCapabilities:jsonFields [RETIRED]", "data/DriverCapabilities:jsonQuery [RETIRED]", + "data/DriverCapabilities:lockRows", "data/DriverCapabilities:migrations [RETIRED]", "data/DriverCapabilities:preparedStatements [RETIRED]", "data/DriverCapabilities:queryAggregations [RETIRED]", @@ -231,6 +232,7 @@ "data/DriverDefinition:id", "data/DriverDefinition:label", "data/DriverOptions:bypassTenantAudit", + "data/DriverOptions:lockRows", "data/DriverOptions:preserveAudit", "data/DriverOptions:skipCache", "data/DriverOptions:tenantId", diff --git a/packages/spec/src/data/driver.zod.ts b/packages/spec/src/data/driver.zod.ts index 24519159d2b..588968831b5 100644 --- a/packages/spec/src/data/driver.zod.ts +++ b/packages/spec/src/data/driver.zod.ts @@ -404,6 +404,8 @@ export const DriverCapabilitiesSchema = lazySchema(() => z.object({ * Optional; absence means `false`, like `batchSchemaSync`. */ lockRows: z.boolean().optional().describe('`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)'), + + /** * This driver compiles (or, in process, evaluates) a composed `ReadableIds` * leaf (ADR-0139 D1/D3): `field IN (SELECT id FROM WHERE * AND )` as one statement on the SQL family, a read of the From d5f91136c1eecfc7ede018e63b7b6124adb3692e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 03:54:54 +0000 Subject: [PATCH 10/15] docs(objectql): put the relation group join's refused section ahead of its declined heading Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n Co-authored-by: Claude --- packages/objectql/src/relation-group-join.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/objectql/src/relation-group-join.ts b/packages/objectql/src/relation-group-join.ts index 46c00084474..d1e8c0aec04 100644 --- a/packages/objectql/src/relation-group-join.ts +++ b/packages/objectql/src/relation-group-join.ts @@ -67,8 +67,6 @@ * group is `NULL`; the caller tells it from a real `NULL` attribute by the * resolved column, and so keeps its "restricted" bucket exactly. * - * ## Declined, never half-served - * * ## Refused, on a driver that compiles no semi-join * * [#33876] A read whose driver lacks the `DriverCapabilities.readableIdsLeaf` @@ -77,6 +75,8 @@ * an `INVALID_QUERY` / 400 the caller throws instead of serving its * FK-expand. The same bit decides a nested-relation `where` on that driver. * + * ## Declined, never half-served + * * Every other case this module cannot prove is the same read as the * FK-expand's is DECLINED: the engine runs nothing more and writes the reason to the * request's `outcome`, and the caller serves the dimension the way it always From 56eeb9bbb9fb37302fd7d1da2a0ba2c94df07306 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 04:24:00 +0000 Subject: [PATCH 11/15] docs(#33876): name the dimension refusal's ruling, and list the analytics where leaf in BREAKING The dimension refusal follows the scope note on #33876 under Prime Directive 5, not ruling A. The changeset's BREAKING section now also names an analytics where leaf through a lookup, and a dataset's own filter, which reach the same nested-relation gate on these drivers. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n --- .changeset/33876-readable-ids-leaf-refusal.md | 1 + packages/objectql/src/relation-group-join.test.ts | 4 ++-- packages/objectql/src/relation-group-join.ts | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.changeset/33876-readable-ids-leaf-refusal.md b/.changeset/33876-readable-ids-leaf-refusal.md index 09985d349fd..f5b6e777815 100644 --- a/.changeset/33876-readable-ids-leaf-refusal.md +++ b/.changeset/33876-readable-ids-leaf-refusal.md @@ -18,6 +18,7 @@ Skills-docs: follow-up #33875 — skills/objectstack-query/SKILL.md (its nested- - 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. - 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`. diff --git a/packages/objectql/src/relation-group-join.test.ts b/packages/objectql/src/relation-group-join.test.ts index ea588ca7eca..cc0910bb5e8 100644 --- a/packages/objectql/src/relation-group-join.test.ts +++ b/packages/objectql/src/relation-group-join.test.ts @@ -216,8 +216,8 @@ describe('relation group join — DECLINED, with nothing read, wherever it is no }); } - // [#33876] The dimension half of the maintainer's ruling A on #33626's Q2: - // a driver without the bit is REFUSED, not declined — the outcome carries + // [#33876] The dimension half (the scope note on #33876, 6917475155, under + // Prime Directive 5): a driver without the bit is REFUSED, not declined — the outcome carries // the error the caller throws instead of serving its FK-expand. for (const name of ['com.objectstack.driver.mongodb', 'com.objectstack.driver.odata', 'com.objectstack.driver.sql']) { it(`[#33876] a driver without readableIdsLeaf (${name}): refused, INVALID_QUERY / 400 on the outcome, no driver call`, async () => { diff --git a/packages/objectql/src/relation-group-join.ts b/packages/objectql/src/relation-group-join.ts index d1e8c0aec04..d90e77b359a 100644 --- a/packages/objectql/src/relation-group-join.ts +++ b/packages/objectql/src/relation-group-join.ts @@ -301,8 +301,9 @@ export function withoutJudgedRelationFields( * compiles no `ReadableIds` leaf (its `DriverCapabilities.readableIdsLeaf` * bit is absent: MongoDB, OData) — the analytics dimension through a lookup, * decided by the same bit as a nested-relation `where` - * (`relationSemiJoinDriverRefusal`), the maintainer's ruling A on #33626's - * Q2. `undefined` when the driver declares the bit: `driver-memory` does, and + * (`relationSemiJoinDriverRefusal`): the scope note on #33876 (6917475155) + * under Prime Directive 5 (memory and mongo refuse what they cannot run with + * a stable code). `undefined` when the driver declares the bit: `driver-memory` does, and * keeps its in-process FK-expand through the ordinary decline. Nothing is * read; the caller serves nothing and throws the error, `INVALID_QUERY` / * 400, naming the driver and the two-step route. From a29a6b9f7039edd429ca30faa2ce9ff5cdb76090 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 04:24:00 +0000 Subject: [PATCH 12/15] fix(objectql): the filter judge answers the up-front driver refusal execution raises A nested-relation condition on a read verb is refused up front on a driver that does not declare DriverCapabilities.readableIdsLeaf. The engine's filter judge now gives the same verdict, from the driver's declared capabilities and without calling it, so every caller that asks the judge first refuses what execution would refuse. One function serves both. An engine that routes the object to no driver (the authoring-time judge) does not judge it. The analytics read-scope merge asks that judge, so a read scope the object's driver cannot run is refused there in its usual withheld envelope. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n --- .../engine-nested-relation-lowering.test.ts | 32 +++++++ .../objectql/src/engine-query-lowering.ts | 27 ++---- .../src/engine-secrets-and-routing.ts | 14 +++- packages/objectql/src/engine-top-level.ts | 29 +++++-- packages/objectql/src/engine.ts | 8 +- .../objectql/src/relation-filter-lowering.ts | 36 ++++++++ ...jectql-read-scope-engine-admission.test.ts | 83 +++++++++++++++++++ .../service-analytics/src/read-scope-sql.ts | 4 +- .../spec/src/contracts/objectql-engine.ts | 11 ++- 9 files changed, 211 insertions(+), 33 deletions(-) diff --git a/packages/objectql/src/engine-nested-relation-lowering.test.ts b/packages/objectql/src/engine-nested-relation-lowering.test.ts index e542ba3a315..c61fc26972c 100644 --- a/packages/objectql/src/engine-nested-relation-lowering.test.ts +++ b/packages/objectql/src/engine-nested-relation-lowering.test.ts @@ -531,6 +531,38 @@ describe('[#33626] the semi-join falls back to the id read wherever it is not pr expect(normalized(r.outerWhere)).toEqual({ owner: { $in: { SEMI_JOIN: OWNER, scope: { region: 'NA' } } } }); }); + it('[#33876] the filter judge answers the same up-front refusal as execution, from the declared bit, and reads nothing', async () => { + const where = { owner: { region: 'NA' } }; + for (const name of ['com.objectstack.driver.mongodb', 'com.objectstack.driver.odata']) { + const { engine, rec } = await makeEngine(name, {}); + rec.answers.set(OWNER, idRows('u1')); + for (const verb of ['find', 'findOne', 'count', 'aggregate'] as const) { + const run = verb === 'aggregate' + ? () => engine.aggregate(OBJECT, { where, aggregations: [{ function: 'count', alias: 'n' }] } as EngineAggregateOptions) + : () => engine[verb](OBJECT, { where }); + const err = await refusalOf(run()); + rec.reads.length = 0; + expect(engine.judgeFilter(OBJECT, where, { operation: verb }), `${name} ${verb}`).toEqual({ ok: false, ...INVALID_FILTER, message: err!.message }); + // …under $or / $not too, at the depth execution judges it. + const nested = { $or: [{ title: 'a' }, { $not: where }] }; + const nestedErr = await refusalOf(engine.find(OBJECT, { where: nested })); + expect(engine.judgeFilter(OBJECT, nested), `${name} nested`).toEqual({ ok: false, ...INVALID_FILTER, message: nestedErr!.message }); + expect(rec.reads, `${name} ${verb}: the judge reads nothing`).toEqual([]); + } + // What execution serves on that driver, the judge admits: a multi-valued relation and a write verb's `where`. + expect(engine.judgeFilter(OBJECT, { owners: { region: 'NA' } }), name).toEqual({ ok: true }); + expect(engine.judgeFilter(OBJECT, where, { operation: 'update' }), name).toEqual({ ok: true }); + } + // CONTROL: a driver that declares the bit is admitted. + const { engine } = await makeEngine('com.objectstack.driver.mongodb', { readableIdsLeaf: true }); + expect(engine.judgeFilter(OBJECT, where, { operation: 'aggregate' })).toEqual({ ok: true }); + // CONTROL: an engine that routes the object to no driver (the authoring-time judge) does not judge it. + const authoring = new ObjectQL(); + authoring.registry.registerObject(OWNER_OBJECT as any, 'test'); + authoring.registry.registerObject(LEDGER as any, 'test'); + expect(authoring.judgeFilter(OBJECT, where)).toEqual({ ok: true }); + }); + it('CONTROL a compiling driver plans the read: no id read, one composed leaf', async () => { const { engine, rec } = await makeEngine(); rec.answers.set(OWNER, idRows('u1')); diff --git a/packages/objectql/src/engine-query-lowering.ts b/packages/objectql/src/engine-query-lowering.ts index d0fa050d4cd..82c2382b7a7 100644 --- a/packages/objectql/src/engine-query-lowering.ts +++ b/packages/objectql/src/engine-query-lowering.ts @@ -69,12 +69,11 @@ import { lowerRelationSite, RELATION_FILTER_ID_CAP, relationFilterCapError, - relationSemiJoinDriverRefusal, + relationReadDriverRefusal, + SEMI_JOIN_READ_VERBS, type RelationReplacement, } from './relation-filter-lowering.js'; import { - driverCompilesReadableIdsLeaf, - driverNameOf, planRelationSemiJoinLeaf, RELATION_SCOPE_PLAN, type RelationScopePlan, @@ -215,14 +214,6 @@ export async function resolveWhereTokens( * Returns `where` by reference when it holds no condition — the common path * reads nothing and allocates nothing beyond one walk. */ -/** - * The verbs whose `where` reaches the engine's executor boundary, where a - * `ReadableIds` leaf is composed (ADR-0139 D2): a single-valued relation - * condition is served as a semi-join there. A write verb's `where` - * (`update`, `delete`) keeps the id read, under the cap. - */ -const SEMI_JOIN_READ_VERBS: ReadonlySet = new Set(['find', 'findOne', 'count', 'aggregate']); - export async function lowerRelationConditions( this: Pick, object: string, @@ -237,16 +228,10 @@ export async function lowerRelationConditions( const context = `${operation}('${object}')`; // [#33876] Judged for every site before any related read is planned or // run: on a read verb, a single-valued relation condition needs a driver - // that compiles the `ReadableIds` leaf, or it is refused here. - if (SEMI_JOIN_READ_VERBS.has(operation)) { - const refused = sites.find((site) => !site.multiple); - if (refused !== undefined) { - const driver = this.relationReadDriver(object); - if (!driverCompilesReadableIdsLeaf(driver)) { - throw relationSemiJoinDriverRefusal(refused, context, driverNameOf(driver)); - } - } - } + // that compiles the `ReadableIds` leaf, or it is refused here. The + // admission judge asks the same function (`judgeWhereAdmission`). + const driverRefusal = relationReadDriverRefusal(object, operation, sites, () => this.relationReadDriver(object)); + if (driverRefusal !== undefined) throw driverRefusal; const replacements: RelationReplacement[] = []; // The id read the engine has always run for a relation condition: the // related object read as the caller, `id` only, one id past the cap. diff --git a/packages/objectql/src/engine-secrets-and-routing.ts b/packages/objectql/src/engine-secrets-and-routing.ts index 7fc2ee546cc..1f5490e7c36 100644 --- a/packages/objectql/src/engine-secrets-and-routing.ts +++ b/packages/objectql/src/engine-secrets-and-routing.ts @@ -59,6 +59,7 @@ export interface SecretsAndRoutingHost { datasourceMapping: ObjectQL['datasourceMapping']; readonly defaultDriver: ObjectQL['defaultDriver']; readonly drivers: ObjectQL['drivers']; + getDriver: ObjectQL['getDriver']; readonly logger: ObjectQL['logger']; readonly manifests: ObjectQL['manifests']; readonly relatedSchemaOf: ObjectQL['relatedSchemaOf']; @@ -140,7 +141,7 @@ export class SecretsAndRoutingFacet { } /** The body of `ObjectQL#judgeFilter`; the method's docblock there is its contract. */ - static judgeFilter(this: Pick, objectName: string, where: EngineQueryOptions['where'], options?: EngineFilterJudgementOptions): EngineFilterJudgement { + static judgeFilter(this: Pick, objectName: string, where: EngineQueryOptions['where'], options?: EngineFilterJudgementOptions): EngineFilterJudgement { const object = this._registry.getObject(objectName) ? this.resolveObjectName(objectName) : objectName; return judgeWhereAdmission( object, @@ -149,6 +150,17 @@ export class SecretsAndRoutingFacet { this._registry.getObject(object), options?.context, this.relatedSchemaOf, + // [#33876] The object's driver, for its DECLARED capabilities only + // (`judgeWhereAdmission`). A name this engine routes to no driver + // answers `null`: that verdict is not judged here, and execution + // raises its own routing error. + (name) => { + try { + return this.getDriver(name); + } catch { + return null; + } + }, ); } diff --git a/packages/objectql/src/engine-top-level.ts b/packages/objectql/src/engine-top-level.ts index 1638ab8d1b2..dac2d18b839 100644 --- a/packages/objectql/src/engine-top-level.ts +++ b/packages/objectql/src/engine-top-level.ts @@ -19,7 +19,7 @@ import { assertResolvedTemporalTokensInRange, assertTemporalComparandsInterpreta import type { ResolvedTokenJudge } from './temporal-comparand-door.js'; import { assertTextOperatorTargetsAreStringCapable } from './text-operator-declared-type-door.js'; import { mapRelationConditions, narrowNumberComparands } from './number-comparand-declared-type-door.js'; -import { lowerRelationSite } from './relation-filter-lowering.js'; +import { lowerRelationSite, relationReadDriverRefusal } from './relation-filter-lowering.js'; import type { RelationFilterSite } from './relation-filter-lowering.js'; import { SystemFieldName } from '@objectstack/spec/system'; import { judgeCollectionItemOwnerStamp } from '@objectstack/spec/kernel'; @@ -1236,6 +1236,16 @@ function admissionRefusalOf( * stops there: which ids the read finds, the cap and the caller's permissions * on the related object need data and a caller, and are execution's alone. * + * [#33876] One driver verdict IS the engine's own admission, so the judge + * answers it too: on a read verb, a single-valued nested-relation condition + * is refused before any related read when the object's driver does not + * declare `DriverCapabilities.readableIdsLeaf` (`relationReadDriverRefusal`, + * the one function execution calls). The judge reads the driver's DECLARED + * capabilities through `driverOf` and calls nothing on it. A host that + * resolves no driver for the object (`driverOf` absent or answering `null`: + * the authoring-time judge, whose engine holds no datasource) does not judge + * this verdict; execution, which must resolve a driver, still raises it. + * * What differs by verb sits BETWEEN or AROUND those stages and judges * something other than `where`: option-key folding and refusal, the driver * lookup (`getDriver`, before stage 1 on the writes and between the stages on @@ -1247,9 +1257,10 @@ function admissionRefusalOf( * ## What it reads * * The `where` value, the object's declared field map (`schema`, the - * registry's), and the execution context (for stage 2). No driver, no data, - * no hook, no middleware. Execution's own stages read nothing more, measured - * door by door on #20157. + * registry's), the execution context (for stage 2), and [#33876] the + * declared capabilities of the object's driver (above). No driver call, no + * data, no hook, no middleware. Execution's own stages read nothing more, + * measured door by door on #20157. * * A thrown door diagnostic becomes the returned refusal, with the same `code`, * `status` and `message` execution raises. Anything else is re-thrown @@ -1262,6 +1273,7 @@ function judgeWhereAdmission( schema: unknown, context: Parameters[0], schemaOf?: (name: string) => unknown, + driverOf?: (name: string) => { readonly name?: unknown; readonly supports?: unknown } | null, ): EngineFilterJudgement { try { const admitted = lowerWhereFilterArray(object, operation, { where }, schema, schemaOf); @@ -1277,8 +1289,15 @@ function judgeWhereAdmission( // of the filter is lowered with each condition standing for the empty id // set, which the shared lowering treats as it treats any `$in` / `$or`. const sites = relationSitesOf(object, operation, resolved, schema, schemaOf); + // [#33876] Execution's up-front driver verdict, at the point execution + // raises it: after admission, before any related read. + const driver = sites.length === 0 || driverOf === undefined ? null : driverOf(object); + if (driver !== null) { + const driverRefusal = relationReadDriverRefusal(object, operation, sites, () => driver); + if (driverRefusal !== undefined) throw driverRefusal; + } for (const site of sites) { - const inner = judgeWhereAdmission(site.target, 'find', site.condition, schemaOf?.(site.target), context, schemaOf); + const inner = judgeWhereAdmission(site.target, 'find', site.condition, schemaOf?.(site.target), context, schemaOf, driverOf); if (!inner.ok) return inner; } const related = sites.length === 0 diff --git a/packages/objectql/src/engine.ts b/packages/objectql/src/engine.ts index 58f4fd30347..46e72924393 100644 --- a/packages/objectql/src/engine.ts +++ b/packages/objectql/src/engine.ts @@ -3352,8 +3352,11 @@ export class ObjectQL implements IObjectQLEngine { * * A registered name resolves exactly as the verbs resolve it, and the field * map is the one they read, so the verdict (and the object name inside its - * message) is the one execution would give. It stops before `getDriver`: - * nothing is resolved from or sent to a datasource. + * message) is the one execution would give. It calls no driver and sends + * nothing to a datasource; [#33876] it reads the object's driver's DECLARED + * capabilities for the one admission verdict that depends on them (a + * nested-relation condition on a driver without `readableIdsLeaf`), and + * skips that verdict when this engine routes the object to no driver. * * It judges the FILTER, not the object's existence. For a name the registry * does not resolve, the verbs refuse the object itself (`OBJECT_NOT_FOUND`, @@ -6099,6 +6102,7 @@ export class ObjectQL implements IObjectQLEngine { set datasourceMapping(v) { engine.datasourceMapping = v; }, get defaultDriver() { return engine.defaultDriver; }, get drivers() { return engine.drivers; }, + getDriver: (...a) => engine.getDriver(...a), get logger() { return engine.logger; }, get manifests() { return engine.manifests; }, get relatedSchemaOf() { return engine.relatedSchemaOf; }, diff --git a/packages/objectql/src/relation-filter-lowering.ts b/packages/objectql/src/relation-filter-lowering.ts index 1b8c6ed5fa8..3014fd463a0 100644 --- a/packages/objectql/src/relation-filter-lowering.ts +++ b/packages/objectql/src/relation-filter-lowering.ts @@ -79,6 +79,7 @@ import { type FilterCondition, } from '@objectstack/spec/data'; import { invalidFilterError } from './filter-comparand-shape.js'; +import { driverCompilesReadableIdsLeaf, driverNameOf } from './relation-semi-join.js'; import { isNoOperatorObject, provisionedNoOperatorObjectColumn } from './no-operator-object-door.js'; /** @@ -346,6 +347,41 @@ export function relationSemiJoinDriverRefusal(site: RelationFilterSite, context: ); } +/** + * The verbs whose `where` reaches the engine's executor boundary, where a + * `ReadableIds` leaf is composed (ADR-0139 D2): a single-valued relation + * condition is served as a semi-join there. A write verb's `where` + * (`update`, `delete`) keeps the id read, under the cap. + */ +export const SEMI_JOIN_READ_VERBS: ReadonlySet = new Set(['find', 'findOne', 'count', 'aggregate']); + +/** + * [#33876] The up-front driver verdict on a `where`'s nested-relation + * conditions: on a read verb, the first single-valued site is refused + * ({@link relationSemiJoinDriverRefusal}) when the read's driver does not + * declare `DriverCapabilities.readableIdsLeaf`; `undefined` otherwise. The + * driver is read through `driverOf`, and only when a site could be refused. + * + * ONE function, called by execution (`lowerRelationConditions`, before any + * related read) and by the admission judge (`judgeWhereAdmission`, the body of + * `IObjectQLEngine.judgeFilter`), so the judge answers exactly what execution + * raises for the same filter on the same object. + */ +export function relationReadDriverRefusal( + object: string, + operation: string, + sites: readonly RelationFilterSite[], + driverOf: () => { readonly name?: unknown; readonly supports?: unknown } | undefined, +): Error | undefined { + if (!SEMI_JOIN_READ_VERBS.has(operation)) return undefined; + const refused = sites.find((site) => !site.multiple); + if (refused === undefined) return undefined; + // Asked only when a site could be refused: the common path resolves no driver here. + const driver = driverOf(); + if (driverCompilesReadableIdsLeaf(driver)) return undefined; + return relationSemiJoinDriverRefusal(refused, `${operation}('${object}')`, driverNameOf(driver)); +} + /** * The cap refusal: the condition matched more related records than * {@link RELATION_FILTER_ID_CAP}, so the filter is refused — `INVALID_FILTER` / diff --git a/packages/services/service-analytics/src/__tests__/objectql-read-scope-engine-admission.test.ts b/packages/services/service-analytics/src/__tests__/objectql-read-scope-engine-admission.test.ts index e459cb830eb..e1dcb690d9c 100644 --- a/packages/services/service-analytics/src/__tests__/objectql-read-scope-engine-admission.test.ts +++ b/packages/services/service-analytics/src/__tests__/objectql-read-scope-engine-admission.test.ts @@ -329,6 +329,89 @@ describe('[#19995, ruling C] a read scope the engine refuses is refused by the a }); }); + describe('[#33876] a nested-relation condition on a driver that does not declare it can run one', () => { + // A second engine whose driver declares no `DriverCapabilities.readableIdsLeaf`. + // Execution refuses a single-valued nested-relation condition on such a + // driver up front, and the engine's filter judge answers that same refusal + // from the declared bit, so the merge refuses the scope before any read. + let bitlessDriver: SqliteWasmDriver; + let bitless: AnalyticsService; + let reads: ReturnType void>>; + /** A single-valued relation (`account`, a lookup) with a condition on the related object. */ + const NESTED = { account: { rank: { $lte: 1 } } }; + + beforeAll(async () => { + bitlessDriver = new SqliteWasmDriver({ filename: ':memory:' }); + (bitlessDriver as unknown as { logger: unknown }).logger = quiet; + await bitlessDriver.initObjects([ + { name: BASE, fields: BASE_FIELDS }, + { name: REF, fields: REF_FIELDS }, + ] as never); + for (const row of BASE_ROWS) await bitlessDriver.create(BASE, { ...row }); + for (const row of REF_ROWS) await bitlessDriver.create(REF, { ...row }); + // The same SQL storage under a driver that declares everything but the bit. + const declared = { ...(bitlessDriver.supports as Record), readableIdsLeaf: false }; + Object.defineProperty(bitlessDriver, 'supports', { get: () => declared }); + Object.defineProperty(bitlessDriver, 'name', { value: 'test.driver.declares-no-readable-ids-leaf' }); + reads = vi.fn<(verb: string, object: unknown) => void>(); + for (const verb of ['find', 'findOne', 'count', 'aggregate'] as const) { + const own = (bitlessDriver as unknown as Record unknown>)[verb].bind(bitlessDriver); + (bitlessDriver as unknown as Record)[verb] = (...a: unknown[]) => { + reads(verb, a[0]); + return own(...a); + }; + } + + const bitlessEngine = new ObjectQL({ logger: quiet }); + bitlessEngine.registerDriver(bitlessDriver as never, true); + await bitlessEngine.init(); + bitlessEngine.registerObject({ name: BASE, label: 'Deal', fields: BASE_FIELDS } as never); + bitlessEngine.registerObject({ name: REF, label: 'Account', fields: REF_FIELDS } as never); + bitless = (await pluginService(bitlessEngine)).service; + }); + + afterAll(async () => { + await bitlessDriver?.disconnect?.(); + }); + + it('a BASE scope with such a condition → READ_SCOPE_COMPILE_FAILED / 500, prose withheld, nothing read', async () => { + reads.mockClear(); + const { refusal, rows } = await outcome(() => bitless.query(DIRECT, MEMBER), { [BASE]: NESTED }); + expect(rows, 'a scope the driver cannot run must not be served').toBeUndefined(); + assertWithheldServerFault(refusal, 'account'); + expect(reads, 'refused before any read').not.toHaveBeenCalled(); + }); + + it('the same scope on the cross-object path → withheld 500', async () => { + // The dimension through the lookup is itself refused on this driver + // (INVALID_QUERY / 400, the caller's own query); the scope is judged at + // the merge before that, so its verdict is the one raised. + const { refusal, rows } = await outcome(() => bitless.query(CROSS, MEMBER), { [BASE]: NESTED }); + expect(rows).toBeUndefined(); + assertWithheldServerFault(refusal, 'account'); + }); + + it('CONTROL: the driver that declares the bit serves the same scope with exactly its rows', async () => { + const { refusal, rows } = await outcome(() => wired.query(DIRECT, MEMBER), { [BASE]: NESTED }); + expect(refusal).toBeUndefined(); + expect(counts(rows, 'region')).toEqual({ emea: 1, amer: 1 }); + }); + + it('CONTROL: a well-formed scope with no such condition is served on the driver without the bit', async () => { + const { refusal, rows } = await outcome(() => bitless.query(DIRECT, MEMBER), { [BASE]: { region: { $in: ['emea', 'apac'] } } }); + expect(refusal).toBeUndefined(); + expect(counts(rows, 'region')).toEqual({ emea: 1, apac: 1 }); + }); + + it("the caller's own `where` with such a condition keeps the engine's INVALID_FILTER / 400", async () => { + const { refusal } = await outcome( + () => bitless.query({ ...DIRECT, where: NESTED } as AnalyticsQuery, MEMBER), + { [BASE]: ALL_REGIONS }, + ); + assertCallersOwn(refusal, 'INVALID_FILTER', 'account'); + }); + }); + describe('a host that cannot answer keeps today’s behaviour and says so once', () => { it('AnalyticsService given no judgeFilter: the engine’s 400 as before, one warn across queries', async () => { const warn = vi.fn(); diff --git a/packages/services/service-analytics/src/read-scope-sql.ts b/packages/services/service-analytics/src/read-scope-sql.ts index b011efeefba..bdd73e304da 100644 --- a/packages/services/service-analytics/src/read-scope-sql.ts +++ b/packages/services/service-analytics/src/read-scope-sql.ts @@ -587,7 +587,9 @@ import { * Ruling C gave the engine a judge-only admission member, * `IObjectQLEngine.judgeFilter` (#20157). It runs the engine's own `where` * admission, the same stage functions in the same order every verb runs, and - * stops before any driver. {@link assertReadScopeAdmittedByEngine} asks it about + * calls no driver (the one verdict that depends on the object's driver, a + * nested-relation condition it does not declare it can run, is taken from its + * declared capabilities, #33876). {@link assertReadScopeAdmittedByEngine} asks it about * the scope ALONE, at every engine-bound merge: `ObjectQLStrategy.withReadScope` * and `resolveFkAttr`, and the plugin's record-label fetch (the #14329 door). * A refusal is raised in this module's one envelope. The engine's sentence diff --git a/packages/spec/src/contracts/objectql-engine.ts b/packages/spec/src/contracts/objectql-engine.ts index c535b75e380..02f273b2240 100644 --- a/packages/spec/src/contracts/objectql-engine.ts +++ b/packages/spec/src/contracts/objectql-engine.ts @@ -345,16 +345,21 @@ export interface IObjectQLEngine extends IDataEngine, QueryEvaluationGate { * * The engine answers the way execution would answer. The engine's own * `where` admission runs: every door the verbs run, in their order, through - * the same functions. It stops before any driver is resolved or called. + * the same functions. It calls no driver. The one admission verdict that + * depends on the object's driver (a nested-relation condition on a read + * verb, refused up front on a driver that does not declare + * `DriverCapabilities.readableIdsLeaf`) is judged from that driver's + * DECLARED capabilities; an engine that routes the object to no driver + * (the authoring-time judge) does not judge it. * `{ ok: true }` means execution would admit the filter at the same point. * `{ ok: false, … }` carries the `code`, `status` and `message` execution * would have raised. * - * - **Nothing executes.** No driver, no hook, no middleware, no read. The + * - **Nothing executes.** No driver call, no hook, no middleware, no read. The * member is synchronous, so a door that needs I/O cannot join it * without a contract change. * - **What it judges is the engine's own admission.** Refusals that sit - * below it are not judged: driver refusals, hooks, and the predicates + * below it are not judged: a driver's own refusals, hooks, and the predicates * middleware composes after admission (RLS, sharing, tenant scope). * The judge sees the object's declared field map from the registry. For * an object the registry does not know, the field-map doors answer From 13bdb52606258aa63a87e1747fe25f43b89a29d9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 04:24:58 +0000 Subject: [PATCH 13/15] docs(adr-0139): amend D3 for the readableIdsLeaf bit and its readers D3's "no DriverCapabilities bit returns" is lifted for one bit and the engine's own readers of it: a nested-relation condition on a read verb (INVALID_FILTER / 400, and the filter judge answers the same) and an analytics dimension through a lookup (INVALID_QUERY / 400), refused up front on a driver that does not declare it. The six consumers' refusal envelope is unchanged. The changeset names the judge's verdict. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n --- .changeset/33876-readable-ids-leaf-refusal.md | 2 +- ...rnal-semi-join-leaf-readable-parent-ids.md | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.changeset/33876-readable-ids-leaf-refusal.md b/.changeset/33876-readable-ids-leaf-refusal.md index f5b6e777815..e9f42397fc7 100644 --- a/.changeset/33876-readable-ids-leaf-refusal.md +++ b/.changeset/33876-readable-ids-leaf-refusal.md @@ -23,7 +23,7 @@ Skills-docs: follow-up #33875 — skills/objectstack-query/SKILL.md (its nested- **`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. +**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. diff --git a/docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md b/docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md index 2ed60476c61..f40695ea408 100644 --- a/docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md +++ b/docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md @@ -28,6 +28,19 @@ the chain unchanged, and D6's other ⛔ (an interim with two spellings of one sc [#33696](https://github.com/objectstack-ai/objectstack/issues/33696)). D6 carries the ruling's binding bullets verbatim, and ADR-0055 is noted in step, as the ruling orders. This amendment declares; #33696's change lands only after it merges. +**Amended** (2026-11-17): D3's "⛔ No `DriverCapabilities` bit returns" is lifted for one bit and the engine's own +readers of it, and nothing else. A driver declares `DriverCapabilities.readableIdsLeaf` when its filter compiler compiles +(or, in process, evaluates) a composed `ReadableIds` leaf: `driver-sql` (every dialect; the WASM SQLite face and Turso +by inheritance) and `driver-memory` declare it, MongoDB and OData do not. The engine reads it for author-written +conditions only. A nested-relation condition beneath a single-valued relation on a read verb is refused up front on a +driver without it, `INVALID_FILTER` / 400, and the engine's filter judge answers that same refusal (the maintainer's +ruling A on [#33626](https://github.com/objectstack-ai/objectstack/issues/33626)'s Q2, record +[`6889543194`](https://github.com/objectstack-ai/objectstack/issues/33626#issuecomment-6889543194); Q1, record +[`6889549817`](https://github.com/objectstack-ai/objectstack/issues/33626#issuecomment-6889549817), keeps `driver-memory` serving in process). An +analytics dimension through a lookup is refused `INVALID_QUERY` / 400 (the scope note on +[#33876](https://github.com/objectstack-ai/objectstack/issues/33876), [`6917475155`](https://github.com/objectstack-ai/objectstack/issues/33876#issuecomment-6917475155), under Prime +Directive 5). Each refusal names the driver and the two-step route, before any related read. D3's refusal envelope +(`INTERNAL_ERROR` / 500) for a leaf one of the six consumers composes is unchanged. **Decided by**: the maintainer, 「同意」 to the director seat's batch #312 item 2 (ruling [`6097072172`](https://github.com/objectstack-ai/objectstack/issues/22590#issuecomment-6097072172), 2026-10-10T11:34Z): **A is the end state, its first deliverable an ADR**; B (an unbounded `$in`) and a raised cap are ⛔ not taken. The @@ -200,6 +213,17 @@ restriction". > refusal is excluded, because it would fail every `sys_user` read on a driver that does not compile it. So the > engine consults a driver declaration to choose between the compiled leaf and the exact-array floor before the call. > A declaration the engine consults is not the inert bit the 17.0.0 rationale removed. + + > **Amendment note (2026-11-17, #33876).** For the six consumers this bullet stands as written: their leaf still + > reaches a refusing driver and is refused there in this envelope. It no longer holds for two author-written + > conditions, where a 500 from inside the driver is the wrong answer because the author can rewrite them: a + > nested-relation condition beneath a single-valued relation on a read verb + > (`packages/objectql/src/relation-filter-lowering.ts#relationReadDriverRefusal`, which the nested-relation lowering + > and the engine's filter judge both call) and an analytics dimension through a lookup + > (`packages/objectql/src/relation-group-join.ts#relationGroupDriverRefusal`). For those the engine reads + > `DriverCapabilities.readableIdsLeaf` (`packages/objectql/src/relation-semi-join.ts#driverCompilesReadableIdsLeaf`) + > and refuses with a 400 before any read on a driver that does not declare it. The bit has readers in the same + > change, so it is not the inert bit the 17.0.0 rationale removed. - The leaf joins the per-driver conformance case-sets, so a driver that compiles it is measured and one that refuses is recorded as refusing. @@ -344,6 +368,9 @@ change is #33696's, and by the ruling it lands only after this amendment merges. roughly 3–5k lines over 6–10 PRs across three lanes, by the ruling's own estimate, with no precedent in the tree. - **A deployment on a refusing driver** (`driver-mongodb`, until O3) reads the six objects as a loud 500, not a short list — the ruling's "refuse loudly"; a silent re-entry into the probe is the shape this record exists to remove. + On such a deployment, and on OData, a nested-relation `where` beneath a single-valued relation on a read verb and an + analytics dimension through a lookup answer a stable 400 before any read (amended 2026-11-17, #33876). Before, the + condition took the capped id read and the dimension read the related records by id. - **The bound-parameter ceiling moves, it does not vanish.** `getReadFilter`'s scope may itself carry pre-resolved id lists (ADR-0055's `rlsMembership`, record shares); they now bind inside the subquery. ADR-0055's known limit is unchanged, and O1 names the ceilings as unmeasured. From e7323bc858842852bc307a78eb2c24f2b54eb502 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 05:34:37 +0000 Subject: [PATCH 14/15] chore(spec): regenerate the driver capability artifacts after the main merge The merge brought zonedDateBucketing beside readableIdsLeaf and lockRows; the authorable-surface shard and the driver reference pages now list all three live bits. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n --- content/docs/references/data/driver-nosql.mdx | 1 + content/docs/references/data/driver-sql.mdx | 1 + content/docs/references/data/driver.mdx | 2 ++ packages/spec/authorable-surface/data.json | 1 + 4 files changed, 5 insertions(+) diff --git a/content/docs/references/data/driver-nosql.mdx b/content/docs/references/data/driver-nosql.mdx index ebf018a85b7..dc0459eac77 100644 --- a/content/docs/references/data/driver-nosql.mdx +++ b/content/docs/references/data/driver-nosql.mdx @@ -167,6 +167,7 @@ const result = AggregationPipelineSchema.parse(data); | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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. | diff --git a/content/docs/references/data/driver-sql.mdx b/content/docs/references/data/driver-sql.mdx index 71994d98916..d8b8bcfb1cd 100644 --- a/content/docs/references/data/driver-sql.mdx +++ b/content/docs/references/data/driver-sql.mdx @@ -80,6 +80,7 @@ const result = DataTypeMappingSchema.parse(data); | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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. | diff --git a/content/docs/references/data/driver.mdx b/content/docs/references/data/driver.mdx index 2cd3228bec2..a5d64e49983 100644 --- a/content/docs/references/data/driver.mdx +++ b/content/docs/references/data/driver.mdx @@ -34,6 +34,7 @@ const result = DriverCapabilitiesSchema.parse(data); | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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. | @@ -92,6 +93,7 @@ const result = DriverCapabilitiesSchema.parse(data); | **transactionsUnsupported** | `boolean` | optional | Transport cannot honour transactions even though `beginTransaction` is inherited (absence = false) | | **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. | diff --git a/packages/spec/authorable-surface/data.json b/packages/spec/authorable-surface/data.json index baf080a6083..5c405fe41f2 100644 --- a/packages/spec/authorable-surface/data.json +++ b/packages/spec/authorable-surface/data.json @@ -221,6 +221,7 @@ "data/DriverCapabilities:transactionsUnsupported", "data/DriverCapabilities:update [RETIRED]", "data/DriverCapabilities:vectorSearch [RETIRED]", + "data/DriverCapabilities:zonedDateBucketing", "data/DriverConfig:capabilities", "data/DriverConfig:connectionString", "data/DriverConfig:name", From 779d1aa3303cc1b0a70179d5aada3b860641ac01 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 07:14:24 +0000 Subject: [PATCH 15/15] docs(#33876): say every consumer, describe the judge's driver verdict in cli and lint, list the read scope in BREAKING ADR-0139's amendment keeps the 500 envelope for a leaf any consumer composes. The authoring filter judge's two comments now say the engine's judge calls no driver and leaves its one driver-dependent verdict unjudged when no driver is routed. The changeset's BREAKING list names a row-level read scope holding such a condition: on these drivers an analytics query under it answers the withheld 500. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01ADHkmQh7Hd2qHJy17QJq6n --- .changeset/33876-readable-ids-leaf-refusal.md | 1 + ...-engine-internal-semi-join-leaf-readable-parent-ids.md | 4 ++-- packages/cli/src/utils/authoring-filter-judge.ts | 8 ++++++-- .../lint/src/validate-rls-predicate-enforceability.ts | 7 +++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.changeset/33876-readable-ids-leaf-refusal.md b/.changeset/33876-readable-ids-leaf-refusal.md index e9f42397fc7..01ce043dba2 100644 --- a/.changeset/33876-readable-ids-leaf-refusal.md +++ b/.changeset/33876-readable-ids-leaf-refusal.md @@ -19,6 +19,7 @@ Skills-docs: follow-up #33875 — skills/objectstack-query/SKILL.md (its nested- - 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`. diff --git a/docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md b/docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md index f40695ea408..13b448252ea 100644 --- a/docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md +++ b/docs/adr/0139-engine-internal-semi-join-leaf-readable-parent-ids.md @@ -40,7 +40,7 @@ ruling A on [#33626](https://github.com/objectstack-ai/objectstack/issues/33626) analytics dimension through a lookup is refused `INVALID_QUERY` / 400 (the scope note on [#33876](https://github.com/objectstack-ai/objectstack/issues/33876), [`6917475155`](https://github.com/objectstack-ai/objectstack/issues/33876#issuecomment-6917475155), under Prime Directive 5). Each refusal names the driver and the two-step route, before any related read. D3's refusal envelope -(`INTERNAL_ERROR` / 500) for a leaf one of the six consumers composes is unchanged. +(`INTERNAL_ERROR` / 500) for a leaf any consumer composes is unchanged. **Decided by**: the maintainer, 「同意」 to the director seat's batch #312 item 2 (ruling [`6097072172`](https://github.com/objectstack-ai/objectstack/issues/22590#issuecomment-6097072172), 2026-10-10T11:34Z): **A is the end state, its first deliverable an ADR**; B (an unbounded `$in`) and a raised cap are ⛔ not taken. The @@ -214,7 +214,7 @@ restriction". > engine consults a driver declaration to choose between the compiled leaf and the exact-array floor before the call. > A declaration the engine consults is not the inert bit the 17.0.0 rationale removed. - > **Amendment note (2026-11-17, #33876).** For the six consumers this bullet stands as written: their leaf still + > **Amendment note (2026-11-17, #33876).** For every consumer this bullet stands as written: its leaf still > reaches a refusing driver and is refused there in this envelope. It no longer holds for two author-written > conditions, where a 500 from inside the driver is the wrong answer because the author can rewrite them: a > nested-relation condition beneath a single-valued relation on a read verb diff --git a/packages/cli/src/utils/authoring-filter-judge.ts b/packages/cli/src/utils/authoring-filter-judge.ts index 3779d69985d..89dd57420c1 100644 --- a/packages/cli/src/utils/authoring-filter-judge.ts +++ b/packages/cli/src/utils/authoring-filter-judge.ts @@ -15,8 +15,12 @@ * * It can, because the admission reads nothing a driver or a kernel supplies: * `judgeFilter` runs the engine's `where` admission against the `where`, the - * registry's field map and the context, and stops before any driver is - * resolved. Measured on #20158: an `ObjectQL` constructed with no driver and no + * registry's field map and the context, and calls no driver. The one verdict + * that depends on the object's driver (a nested-relation condition on a read + * verb, refused up front on a driver that does not declare + * `DriverCapabilities.readableIdsLeaf`, #33876) is taken from that driver's + * declared capabilities, and an engine that routes the object to no driver, as + * this one does, leaves it unjudged. Measured on #20158: an `ObjectQL` constructed with no driver and no * kernel, the stack's objects registered through its own registry, answered * every class the runtime engine answers — including the registry-injected * system columns (`created_at` compared against an unreadable value is refused diff --git a/packages/lint/src/validate-rls-predicate-enforceability.ts b/packages/lint/src/validate-rls-predicate-enforceability.ts index 4041413368d..3d8849d429b 100644 --- a/packages/lint/src/validate-rls-predicate-enforceability.ts +++ b/packages/lint/src/validate-rls-predicate-enforceability.ts @@ -1401,8 +1401,11 @@ function engineJudgeProbe(probe: UserProbe): { probe: UserProbe; rebound: boolea * it admits it or the predicate has no lowering to judge. * * Asked of the ENGINE, through the method the caller handed in — the same - * function the engine runs before any driver is resolved (`judgeFilter`). No - * context is passed: at authoring time there is no caller. + * admission the engine runs before any driver call (`judgeFilter`). Its one + * driver-dependent verdict (a nested-relation condition on a driver that does + * not declare `DriverCapabilities.readableIdsLeaf`, #33876) is left unjudged + * by an engine with no driver, as at authoring time. No context is passed: at + * authoring time there is no caller. */ function engineRefusal( judge: FilterJudge,