@@ -57,6 +57,7 @@ import type { FlowFunctionEffect, FlowFunctionEntry } from '../automation/flow-f
5757import type { ServiceObject } from '../data/object.zod' ;
5858import type { Hook , HookContext } from '../data/hook.zod' ;
5959import type { BaseEngineOptions , EngineQueryOptions } from '../data/data-engine.zod' ;
60+ import type { FixedReadLeaf } from '../data/fixed-read-leaf' ;
6061
6162/**
6263 * The engine's schema-registry view — the members reached through the
@@ -278,6 +279,23 @@ export type EngineFilterJudgement =
278279 | { ok : true }
279280 | { ok : false ; code : string ; status : number ; message : string } ;
280281
282+ /**
283+ * The answer of {@link IObjectQLEngine.fixedReadLeafClassOf} (ADR-0155 D4):
284+ * which of the two classes a fixed-read leaf falls in on this engine, and what
285+ * names it. `@objectstack/objectql`'s `FixedReadLeafClass`, the seam's own
286+ * answer, stated here because spec does not depend on the engine package;
287+ * `ObjectQL implements IObjectQLEngine` holds the two equal on every build.
288+ */
289+ export type EngineFixedReadLeafClass =
290+ | {
291+ readonly class : 'other-datasource' ;
292+ readonly object : string ;
293+ readonly table : string ;
294+ readonly objectDatasource : string | undefined ;
295+ readonly tableDatasource : string | undefined ;
296+ }
297+ | { readonly class : 'registration-by-name' ; readonly table : string ; readonly registration : string } ;
298+
281299/**
282300 * The full ObjectQL engine, as the `objectql` slot's consumers use it.
283301 *
@@ -290,12 +308,13 @@ export type EngineFilterJudgement =
290308 * guarded call into a `possibly undefined` error and push code back toward the
291309 * `any` this contract exists to remove.
292310 *
293- * Four members are optional by ruling, not by this default: {@link judgeFilter}
311+ * Five members are optional by ruling, not by this default: {@link judgeFilter}
294312 * (#19995 ruling C), {@link getDisabledActions} (#27842 ruling letter B,
295313 * the `getFlowRegistration?` shape), {@link getCascadeDeleteObjects}
296- * (#28001, that shape again) and {@link deferSummaryRecompute} (#33795,
297- * ruling 6922040858). Their callers must work with an engine that lacks
298- * them, so the optional mark states that requirement in the type.
314+ * (#28001, that shape again), {@link deferSummaryRecompute} (#33795,
315+ * ruling 6922040858) and {@link fixedReadLeafClassOf} (#35946, ruling
316+ * 7051956587). Their callers must work with an engine that lacks them, so the
317+ * optional mark states that requirement in the type.
299318 */
300319export interface IObjectQLEngine extends IDataEngine , QueryEvaluationGate {
301320 // ── Schema access ────────────────────────────────────────────────────
@@ -510,6 +529,33 @@ export interface IObjectQLEngine extends IDataEngine, QueryEvaluationGate {
510529 * `typeof ql.hasObjectMiddleware === 'function'`.
511530 */
512531 hasObjectMiddleware ?( objectName : string ) : boolean ;
532+ /**
533+ * [ADR-0155 D4, plan step 5] Which of D4's two classes the fixed-read leaf
534+ * `leaf` (`SharedRecordIds`) falls in on this engine, or `undefined` when
535+ * neither applies: the engine seam's own recognition
536+ * (`fixedReadLeafClassOfEngine`), the one the executor boundary runs.
537+ *
538+ * - `'other-datasource'`: the object the leaf names is bound to another
539+ * datasource than the table its fixed inner read reads.
540+ * - `'registration-by-name'`: an object-scoped middleware, or a
541+ * `beforeFind` / `afterFind` hook, is registered for that table by name.
542+ *
543+ * Read-only: it reads the engine's datasource bindings, middlewares and
544+ * hooks, and calls no driver and logs nothing.
545+ *
546+ * The consumer is a read path that compiles the leaf itself instead of
547+ * handing it to the engine: the analytics native-SQL strategy (ADR-0155 Q2
548+ * as ruled) asks this before it compiles, compiles only on `undefined`, and
549+ * declines the query to the engine on a class, where the seam answers it.
550+ * It restates neither class (D4: recognised once, in the seam).
551+ *
552+ * OPTIONAL by ruling 7051956587: an engine without it cannot answer, and
553+ * that consumer reads the absence as "cannot say" and declines, so the
554+ * probe is `typeof ql.fixedReadLeafClassOf === 'function'`. ⛔ Never
555+ * `ql.fixedReadLeafClassOf?.(leaf) ?? null` alone: an absent member then
556+ * reads as "neither class" and the consumer compiles what it cannot see.
557+ */
558+ fixedReadLeafClassOf ?( leaf : FixedReadLeaf ) : EngineFixedReadLeafClass | undefined ;
513559 /** Bind declarative Hook metadata — AppPlugin's app-bundle path. */
514560 bindHooks (
515561 hooks : unknown [ ] | undefined ,
0 commit comments