From 3253eff946744e7200b7d922713a02a5662ee8cf Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 15:51:43 +0000 Subject: [PATCH 1/2] docs(spec): FilterCondition form 4 states the engine's three-relationship hop limit The nested-relation docblocks said the engine serves one level; the engine admits a condition up to RELATION_CONDITION_MAX_HOPS (3, ADR-0071's hop limit) relationships deep and refuses one past it with INVALID_FILTER / 400. Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude --- packages/spec/src/data/filter.zod.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/spec/src/data/filter.zod.ts b/packages/spec/src/data/filter.zod.ts index 0c554a479dd..2166834dad9 100644 --- a/packages/spec/src/data/filter.zod.ts +++ b/packages/spec/src/data/filter.zod.ts @@ -2219,9 +2219,12 @@ function checkFilterConditionComparands( * field permissions apply, so a condition on a field the caller cannot read * is refused, never answered empty — and matches the relation field against * the ids it returns (`$in` on a single-valued relation; any member, an - * `$or` of `$contains` per id, on a multi-valued one). One level: every key - * must be a field the related object declares, and a relation condition - * beneath it, or a dotted key, is refused. A condition matching more related + * `$or` of `$contains` per id, on a multi-valued one). Up to three + * relationships deep (ADR-0071's 3-hop limit, `RELATION_CONDITION_MAX_HOPS` + * in `packages/objectql/src/relation-filter-lowering.ts`): every key must be + * a field the related object declares, a relation key may hold a condition + * of its own, and a condition past the third relationship, or a dotted key, + * is refused (`INVALID_FILTER` / 400). A condition matching more related * records than the engine's cap is refused rather than truncated; filter the * related object yourself then, and match its ids the same way. An * aggregation's own `filter` and `having` do not serve the form. The same @@ -2232,7 +2235,7 @@ export type FilterCondition = { [key: string]: | any // Implicit equality: key: value | z.infer // Explicit operators: key: { $op: value } - | FilterCondition; // Nested relation: key: { nested: ... } — served by the engine in `where`, one level (form 4 above) + | FilterCondition; // Nested relation: key: { nested: ... } — served by the engine in `where`, up to three relationships deep (form 4 above) } & { /** Logical AND - combines all conditions that must be true */ $and?: FilterCondition[]; @@ -2370,7 +2373,7 @@ export const FilterConditionSchema: z.ZodType * { email: { $contains: "@company.com" } } * ], * account: { // Nested relation (form 4): a field - * industry: "tech" // of the related record, one level + * industry: "tech" // of the related record (up to 3 hops) * } * } * } @@ -2461,7 +2464,7 @@ export type Filter = { $null?: boolean; $exists?: boolean; } - | (T[K] extends object ? Filter : never); // Nested relation — typed at any depth here; the engine serves one level, in `where` (see FilterCondition) + | (T[K] extends object ? Filter : never); // Nested relation — typed at any depth here; the engine serves up to three relationships, in `where` (see FilterCondition) } & { $and?: Filter[]; $or?: Filter[]; From ce513cad517d8abb7e23f0b800e39980f4fff06a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 16:52:24 +0000 Subject: [PATCH 2/2] docs(spec): patch changeset for the FilterCondition hop-limit docblock; name the provisioned keys Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude --- .changeset/35494-nested-relation-hop-docblock.md | 10 ++++++++++ packages/spec/src/data/filter.zod.ts | 9 +++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .changeset/35494-nested-relation-hop-docblock.md diff --git a/.changeset/35494-nested-relation-hop-docblock.md b/.changeset/35494-nested-relation-hop-docblock.md new file mode 100644 index 00000000000..1ac9519e540 --- /dev/null +++ b/.changeset/35494-nested-relation-hop-docblock.md @@ -0,0 +1,10 @@ +--- +'@objectstack/spec': patch +--- + +docs(spec): the `FilterCondition` nested-relation docblock states the engine's three-relationship limit + +Clause-②: no — comment-only edits in packages/spec; no schema, export or accept set moves +Metadata-protocol: none — no metadata key is touched + +`@objectstack/spec`: comments only, in `src/data/filter.zod.ts`, which the package ships as source. The nested-relation form (`{ relation: { field: value } }`, form 4 on `FilterCondition`) and its three one-line mentions said the engine serves it one level deep; they now say up to three relationships deep (ADR-0071's 3-hop limit, `RELATION_CONDITION_MAX_HOPS` in objectql), with a condition past the third relationship refused as `INVALID_FILTER` / 400, and name the platform-provisioned `id`, `created_at` and `updated_at` beside the related object's declared fields as admitted keys. diff --git a/packages/spec/src/data/filter.zod.ts b/packages/spec/src/data/filter.zod.ts index 2166834dad9..53409e39a8d 100644 --- a/packages/spec/src/data/filter.zod.ts +++ b/packages/spec/src/data/filter.zod.ts @@ -2222,10 +2222,11 @@ function checkFilterConditionComparands( * `$or` of `$contains` per id, on a multi-valued one). Up to three * relationships deep (ADR-0071's 3-hop limit, `RELATION_CONDITION_MAX_HOPS` * in `packages/objectql/src/relation-filter-lowering.ts`): every key must be - * a field the related object declares, a relation key may hold a condition - * of its own, and a condition past the third relationship, or a dotted key, - * is refused (`INVALID_FILTER` / 400). A condition matching more related - * records than the engine's cap is refused rather than truncated; filter the + * a field the related object declares (or `id`, `created_at`, `updated_at`), + * a relation key may hold a condition of its own, and a condition past the + * third relationship, or a dotted key, is refused (`INVALID_FILTER` / 400). + * A condition matching more related records than the engine's cap is + * refused rather than truncated; filter the * related object yourself then, and match its ids the same way. An * aggregation's own `filter` and `having` do not serve the form. The same * object beneath a JSON-valued field (a whole-value match) and beneath a