Skip to content
Merged
17 changes: 17 additions & 0 deletions .changeset/35786-fixed-read-leaf-seam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@objectstack/spec': minor
'@objectstack/core': patch
'@objectstack/objectql': patch
---

feat: the engine's seam for the fixed-read leaf, and the driver declaration for it (ADR-0155, step 2 of 6)

Clause-②: yes
Metadata-protocol: added

No visible change on its own: nothing on main writes a fixed-read leaf yet (the sharing plugin starts writing `SharedRecordIds` at ADR-0155's last step), and no driver declares one (the SQL drivers and the memory driver declare it on the steps that compile it).

- **The driver declaration** (`@objectstack/spec`). `DriverCapabilities.fixedReadLeaves` lists the fixed-read leaves a driver's filter compiler evaluates exactly, by name, e.g. `['SharedRecordIds']`; absence means none. The names are `FIXED_READ_LEAF_NAMES`, and `fixedReadLeafNameOf(leaf)` maps a leaf to its name. It stays separate from `readableIdsLeaf`: a `ReadableIds` leaf is not a fixed-read leaf, and a driver that evaluates both declares both. Both descriptions now say so.
- **The seam** (`@objectstack/objectql`). The engine's comparand door admits a branded `SharedRecordIds` leaf as a `$in` comparand, and the engine hands it to the driver by reference only when it sits on `id` of the object it names (directly, or inside a composed `ReadableIds` scope over that object), on a read verb in its read form or in a predicate update's `where` in its write form, for the context's user or its delegator (a system context is exempt), outside both classes ADR-0155 D4 recognises (the object on another datasource than `sys_record_share`; a middleware or a `beforeFind` / `afterFind` hook registered for `sys_record_share` by name), and to a driver whose `fixedReadLeaves` names it. Anything else is refused before any driver is asked, `INTERNAL_ERROR` / 500, logged at `error` once per evaluator. An unbranded copy is still refused at the door as a non-list comparand, `INVALID_FILTER` / 400.
- **The refusal** (`@objectstack/core`). `fixedReadLeafRefusal`, `refuseFixedReadLeafOnce` and `describeFixedReadLeaf` are the one envelope every evaluator answers a fixed-read leaf it will not run with; `logRefusalOnce` is the once-per-instance log it shares with the `ReadableIds` refusal.
- **Filter tokens** (`@objectstack/core`). `resolveFilterTokens` returns a fixed-read leaf by reference, as it does a `ReadableIds` leaf, so a read scope that carries a placeholder beside the leaf keeps the leaf's brand.
2 changes: 2 additions & 0 deletions content/docs/permissions/system-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ bugs — it is the protection or the side effect that silently does not happen.
| 18c | **Credential-column filter / sort refusal not applied** — a `where`, `orderBy`, per-aggregation `filter` or `expand` entry naming a `password` / `secret` column is evaluated | objectql | Get: the server's own match on a stored credential value, a lookup that never returns it. Every other caller, administrators included, is refused `400 INVALID_FIELD` for anything but a has-a-value check (ADR-0100). Lose: nothing a wire caller reaches — `isSystem` is never set on an inbound request | `rejectCredentialEvaluation` |
| 18d | **Stored-metadata type read gate not applied** — a read of `sys_metadata` / `sys_metadata_history` is not narrowed by the capability its row's type requires | objectql | Get: every row of the family on `find` / `findOne` / `count` / `aggregate` — the metadata loader, the `/meta` doors' own store reads, boot (a read with no execution context is not narrowed either). Lose: the narrowing that serves a stored row of a capability-gated type (`datasource`, `external_catalog`) only to holders of the capability the `/meta` type gate names for it | `storedMetadataTypeReadFilter` |
| 18e | **`internal: true` evaluate refusal not applied on the engine's read path** — a filter, sort, group key, aggregation operand, per-aggregation `filter`, nested-relation condition or `expand` entry naming a field declared `internal: true` is evaluated | objectql | Get: the server's own match on a flagged column (the API-key, share-link, SCIM-credential and approval-token lookups, the better-auth adapter), which still never returns the value. Every other caller of `find` / `findOne` / `count` / `aggregate`, administrators included, is refused `400 INVALID_FIELD`; the data door asks the same judgement for every caller, a system context included. Lose: nothing a wire caller reaches — `isSystem` is never set on an inbound request | `rejectInternalFieldEvaluation` |
| 18f | **Fixed-read leaf recipient check not applied** — a `SharedRecordIds` leaf (ADR-0155) that names another principal is handed on to the driver | objectql | Get: server code may hand the engine a share-table read for any recipient. Nothing on main writes the leaf yet; the sharing plugin starts at ADR-0155's last step. Every other caller's leaf must name its own user or its delegator, or the operation is refused `500 INTERNAL_ERROR` before any driver is asked (ADR-0155 D4). The position, verb, class and driver-declaration checks apply to every caller, a system context included. Lose: nothing a wire caller reaches — no request can spell the leaf, and `isSystem` is never set on an inbound request | `passFixedReadLeaves` |

### 2. Write pipeline and data integrity

Expand Down Expand Up @@ -561,6 +562,7 @@ and CI refuses one that differs from what the tree produces.
| `packages/objectql/src/engine-update.ts#update` | 4 | 19, 20 |
| `packages/objectql/src/engine-validate.ts#validate` | 1 | 21b |
| `packages/objectql/src/engine.ts#isSystem` | 1 | 64 |
| `packages/objectql/src/fixed-read-leaf-seam.ts#passFixedReadLeaves` | 1 | 18f |
| `packages/objectql/src/internal-field-evaluation-guard.ts#rejectInternalFieldEvaluation` | 1 | 18e |
| `packages/objectql/src/recycle-bin/list.ts#assertCallerManagesRecycleBin` | 1 | 29f |
| `packages/objectql/src/recycle-bin/purge.ts#recycleBinWallDenies` | 1 | 29d |
Expand Down
3 changes: 2 additions & 1 deletion content/docs/references/data/driver-nosql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ const result = AggregationPipelineSchema.parse(data);
| **aggregationFilter** | `boolean` | optional | `aggregate()` evaluates a per-measure `aggregations[].filter` itself, with the engine's in-memory answer, except that text compares by the backend collation as in `where` (absence = false: the engine aggregates filtered measures in memory) |
| **lockRows** | `boolean` | optional | `find()` honours `DriverOptions.lockRows` inside a transaction: no other writer changes a returned row behind the transaction (it waits, or one side fails) (absence = false: the engine sends no lock request) |
| **zonedDateBucketing** | `boolean` | optional | `aggregate()` buckets a date groupBy on the calendar of the resolved IANA zone the engine sends (DriverAggregateQuery.timezone), DST-correct, equal to the in-memory buckets (absence = false: the engine buckets a non-UTC zone in memory) |
| **readableIdsLeaf** | `boolean` | optional | The filter compiler compiles (or, in process, evaluates) a composed `ReadableIds` semi-join leaf (absence = false: the engine refuses a nested-relation condition on a read verb up front, INVALID_FILTER / 400) |
| **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). A `ReadableIds` leaf is not a fixed-read leaf, so `fixedReadLeaves` neither implies nor is implied by this bit |
| **fixedReadLeaves** | `Enum<'SharedRecordIds'>[]` | optional | The fixed-read leaves (ADR-0155 D4) the filter compiler evaluates exactly, by name, e.g. ["SharedRecordIds"] (absence = none: the engine refuses an operation carrying such a leaf before calling the driver, INTERNAL_ERROR / 500). Separate from `readableIdsLeaf`: a `ReadableIds` leaf is not a fixed-read leaf |
| **create** | `never` | optional | [REMOVED] `DriverCapabilities.create` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `create`/`find`/`findOne`/`update`/`delete` are REQUIRED `IDataDriver` methods and the engine calls them unconditionally. Delete the key. |
| **read** | `never` | optional | [REMOVED] `DriverCapabilities.read` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: reads go through the REQUIRED `find`/`findOne`/`count` methods, called unconditionally. Delete the key. |
| **update** | `never` | optional | [REMOVED] `DriverCapabilities.update` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `update`/`upsert` are REQUIRED `IDataDriver` methods, called unconditionally. Delete the key. |
Expand Down
3 changes: 2 additions & 1 deletion content/docs/references/data/driver-sql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ const result = DataTypeMappingSchema.parse(data);
| **aggregationFilter** | `boolean` | optional | `aggregate()` evaluates a per-measure `aggregations[].filter` itself, with the engine's in-memory answer, except that text compares by the backend collation as in `where` (absence = false: the engine aggregates filtered measures in memory) |
| **lockRows** | `boolean` | optional | `find()` honours `DriverOptions.lockRows` inside a transaction: no other writer changes a returned row behind the transaction (it waits, or one side fails) (absence = false: the engine sends no lock request) |
| **zonedDateBucketing** | `boolean` | optional | `aggregate()` buckets a date groupBy on the calendar of the resolved IANA zone the engine sends (DriverAggregateQuery.timezone), DST-correct, equal to the in-memory buckets (absence = false: the engine buckets a non-UTC zone in memory) |
| **readableIdsLeaf** | `boolean` | optional | The filter compiler compiles (or, in process, evaluates) a composed `ReadableIds` semi-join leaf (absence = false: the engine refuses a nested-relation condition on a read verb up front, INVALID_FILTER / 400) |
| **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). A `ReadableIds` leaf is not a fixed-read leaf, so `fixedReadLeaves` neither implies nor is implied by this bit |
| **fixedReadLeaves** | `Enum<'SharedRecordIds'>[]` | optional | The fixed-read leaves (ADR-0155 D4) the filter compiler evaluates exactly, by name, e.g. ["SharedRecordIds"] (absence = none: the engine refuses an operation carrying such a leaf before calling the driver, INTERNAL_ERROR / 500). Separate from `readableIdsLeaf`: a `ReadableIds` leaf is not a fixed-read leaf |
| **create** | `never` | optional | [REMOVED] `DriverCapabilities.create` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `create`/`find`/`findOne`/`update`/`delete` are REQUIRED `IDataDriver` methods and the engine calls them unconditionally. Delete the key. |
| **read** | `never` | optional | [REMOVED] `DriverCapabilities.read` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: reads go through the REQUIRED `find`/`findOne`/`count` methods, called unconditionally. Delete the key. |
| **update** | `never` | optional | [REMOVED] `DriverCapabilities.update` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `update`/`upsert` are REQUIRED `IDataDriver` methods, called unconditionally. Delete the key. |
Expand Down
6 changes: 4 additions & 2 deletions content/docs/references/data/driver.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const result = DriverCapabilitiesSchema.parse(data);
| **aggregationFilter** | `boolean` | optional | `aggregate()` evaluates a per-measure `aggregations[].filter` itself, with the engine's in-memory answer, except that text compares by the backend collation as in `where` (absence = false: the engine aggregates filtered measures in memory) |
| **lockRows** | `boolean` | optional | `find()` honours `DriverOptions.lockRows` inside a transaction: no other writer changes a returned row behind the transaction (it waits, or one side fails) (absence = false: the engine sends no lock request) |
| **zonedDateBucketing** | `boolean` | optional | `aggregate()` buckets a date groupBy on the calendar of the resolved IANA zone the engine sends (DriverAggregateQuery.timezone), DST-correct, equal to the in-memory buckets (absence = false: the engine buckets a non-UTC zone in memory) |
| **readableIdsLeaf** | `boolean` | optional | The filter compiler compiles (or, in process, evaluates) a composed `ReadableIds` semi-join leaf (absence = false: the engine refuses a nested-relation condition on a read verb up front, INVALID_FILTER / 400) |
| **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). A `ReadableIds` leaf is not a fixed-read leaf, so `fixedReadLeaves` neither implies nor is implied by this bit |
| **fixedReadLeaves** | `Enum<'SharedRecordIds'>[]` | optional | The fixed-read leaves (ADR-0155 D4) the filter compiler evaluates exactly, by name, e.g. ["SharedRecordIds"] (absence = none: the engine refuses an operation carrying such a leaf before calling the driver, INTERNAL_ERROR / 500). Separate from `readableIdsLeaf`: a `ReadableIds` leaf is not a fixed-read leaf |
| **create** | `never` | optional | [REMOVED] `DriverCapabilities.create` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `create`/`find`/`findOne`/`update`/`delete` are REQUIRED `IDataDriver` methods and the engine calls them unconditionally. Delete the key. |
| **read** | `never` | optional | [REMOVED] `DriverCapabilities.read` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: reads go through the REQUIRED `find`/`findOne`/`count` methods, called unconditionally. Delete the key. |
| **update** | `never` | optional | [REMOVED] `DriverCapabilities.update` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `update`/`upsert` are REQUIRED `IDataDriver` methods, called unconditionally. Delete the key. |
Expand Down Expand Up @@ -94,7 +95,8 @@ const result = DriverCapabilitiesSchema.parse(data);
| **aggregationFilter** | `boolean` | optional | `aggregate()` evaluates a per-measure `aggregations[].filter` itself, with the engine's in-memory answer, except that text compares by the backend collation as in `where` (absence = false: the engine aggregates filtered measures in memory) |
| **lockRows** | `boolean` | optional | `find()` honours `DriverOptions.lockRows` inside a transaction: no other writer changes a returned row behind the transaction (it waits, or one side fails) (absence = false: the engine sends no lock request) |
| **zonedDateBucketing** | `boolean` | optional | `aggregate()` buckets a date groupBy on the calendar of the resolved IANA zone the engine sends (DriverAggregateQuery.timezone), DST-correct, equal to the in-memory buckets (absence = false: the engine buckets a non-UTC zone in memory) |
| **readableIdsLeaf** | `boolean` | optional | The filter compiler compiles (or, in process, evaluates) a composed `ReadableIds` semi-join leaf (absence = false: the engine refuses a nested-relation condition on a read verb up front, INVALID_FILTER / 400) |
| **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). A `ReadableIds` leaf is not a fixed-read leaf, so `fixedReadLeaves` neither implies nor is implied by this bit |
| **fixedReadLeaves** | `Enum<'SharedRecordIds'>[]` | optional | The fixed-read leaves (ADR-0155 D4) the filter compiler evaluates exactly, by name, e.g. ["SharedRecordIds"] (absence = none: the engine refuses an operation carrying such a leaf before calling the driver, INTERNAL_ERROR / 500). Separate from `readableIdsLeaf`: a `ReadableIds` leaf is not a fixed-read leaf |
| **create** | `never` | optional | [REMOVED] `DriverCapabilities.create` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `create`/`find`/`findOne`/`update`/`delete` are REQUIRED `IDataDriver` methods and the engine calls them unconditionally. Delete the key. |
| **read** | `never` | optional | [REMOVED] `DriverCapabilities.read` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: reads go through the REQUIRED `find`/`findOne`/`count` methods, called unconditionally. Delete the key. |
| **update** | `never` | optional | [REMOVED] `DriverCapabilities.update` was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: `update`/`upsert` are REQUIRED `IDataDriver` methods, called unconditionally. Delete the key. |
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ export * from './utils/blank-storage-form.js';
// above gives.
export * from './utils/json-column-operator-refusal.js';
export * from './utils/readable-ids-driver-refusal.js';
// [ADR-0155 D4] …and the fixed-read leaves' refusal, on the same floor for the
// same reason: the engine's seam answers it now, each evaluator on its own card.
export * from './utils/fixed-read-leaf-refusal.js';

// [#12350 / ADR-0126 §4] THE activation-ledger row contract, parameterized by
// `metadata_type`. Same reason as the two entries above: its consumers —
Expand Down
Loading
Loading