diff --git a/docs/adr/0160-record-scoped-ai-inquiry.md b/docs/adr/0160-record-scoped-ai-inquiry.md index ddbc3fe798d..045d36d9d15 100644 --- a/docs/adr/0160-record-scoped-ai-inquiry.md +++ b/docs/adr/0160-record-scoped-ai-inquiry.md @@ -9,6 +9,22 @@ - **Point 10** is accepted as written. - **Long text in a related list's cells** is allowed under one bound on the pack's carried text, and every cut is stated. See [D3](#d3), "The bound on carried text". - Nothing else changes. +- **Amended**: 2026-11-25, a second time, by the maintainer's word, verbatim: 「related 的筛选和排序 同意」, as the thread of epic [objectstack#36996](https://github.com/objectstack-ai/objectstack/issues/36996) records it (card [objectstack#37202](https://github.com/objectstack-ai/objectstack/issues/37202)). The review behind the first amendment had left filter and order on `related` to the maintainer, as a protocol addition that needs its own amendment; this is that amendment. Its readings of the tree were taken on `main` at `6211ddf4`. It records the following: + - **`related` gains `where`, `orderBy` and `limit`**, on the child's own fields only, and the three leave "Later work". See [D1](#d1), "Filter, order and limit on a related list". + - **The filter grants nothing.** It runs inside the caller's one capped child query. A `where` or `orderBy` field the caller cannot query on drops the section, with the statement that some material is not visible, and the field is never named. See [D3](#d3). + - **The read set is unchanged.** See [D4](#d4), "The seams". + - **Points 5 and 11** and one line of [Consequences](#consequences) are updated, and the [Implementation split](#implementation-split-after-acceptance) gains row 11. The keys are declared here and land with their reader there; until then the schema refuses them. + - **The maintainer's word names filter and order on `related`, and no more.** What the text adds to that word is this record's own settlement, accepted with the maintainer's merge of the PR that carries this amendment. [Points that go past the card's words](#points-that-go-past-the-cards-words) lists each addition, as points 13–22: + - `limit` itself (13), and a `limit` over the row cap refused at parse (14); + - the ten operators of `where`, joined by `$and` / `$or` (15); + - a bare value read as `$eq` (16); + - a whole `{token}` comparand refused at parse (17); + - `orderBy` spelled `{ field, order }` (18); + - the section dropped for a `where` or `orderBy` field the caller cannot query on (19); + - the section left out for a `where` or `orderBy` field the definition lacks (20); + - a list cut at its `limit` stated as a cut (21); + - the cap on an outline's entries, in [D3](#d3), "The body" (22). This one is not about `related`. It is carried from the seat's review of PR objectstack#37222 (card objectstack#37178), nit N5; that PR has since merged. + - Nothing else changes. - **Decided by**: the maintainer, 2026-11-24, verbatim and untranslated, as epic [objectstack#36996](https://github.com/objectstack-ai/objectstack/issues/36996) records them: 「先立专题 ① 记录范围 AI 问询 ;⑤ 应用技能进入应用内 AI ,M0 那几项知识服务缺陷 也立专题,目前开发的策略是按专题派」 and 「需要拍板的事项 都同意」. The six rulings the epic sets over every child are quoted in [Provenance](#provenance); ⛔ none of them is re-opened here. - **Card**: [objectstack#36997](https://github.com/objectstack-ai/objectstack/issues/36997). It lists ten items; D1–D9 decide items 1–9 in the card's order and [Not decided here](#not-decided-here) carries item 10. - **Builds on**: [ADR-0005](./0005-metadata-customization-overlay.md) (its ai row: a behavioural contract takes no environment overlay), [ADR-0011](./0011-actions-as-ai-tools.md) (an action reaches AI only through its `ai` exposure block), [ADR-0049](./0049-no-unenforced-security-properties.md) (enforce or remove), [ADR-0088](./0088-metadata-kind-admission-and-retirement.md) (the kind admission test), [ADR-0090](./0090-permission-model-v2-concept-convergence.md) D10 (the agent ceiling over reads), [ADR-0106](./0106-metadata-plane-fls-object-schema-masking.md) (the caller's served schema), [ADR-0112](./0112-error-code-vocabulary-and-ledger.md) (the error envelope and its catalogue), [ADR-0149](./0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md) D2 and M1 (one definition, one executor, every transport; guidance sentences belong to the executor), [ADR-0159](./0159-forms-are-their-own-metadata-type-public-forms-are-form-items-view-is-lists-only.md) (the latest kind admission; the form of D1). @@ -102,7 +118,7 @@ ADR-0088's three clauses: | `label` | Human name. | The pack's header in the tool answer, and the refusal that names candidate packs. | | `object` | The root object. Required. | Pack selection; the root read. | | `fields` | Ordered field names on the root object. | The field section of the pack. | -| `related` | Child lists: `{ object, field?, fields? }[]`. `object` is a child object with a reference field that points at the root; `field` names that field and is required when several do; `fields` are the columns of each row. One level, child lists only — the shape of `get_record`'s `related`. The link is resolved once, on the published definition, so no caller's pack follows a different link than the author declared. | The related section. | +| `related` | Child lists: `{ object, field?, fields?, where?, orderBy?, limit? }[]`. `object` is a child object with a reference field that points at the root; `field` names that field and is required when several do; `fields` are the columns of each row; `where`, `orderBy` and `limit` choose, order and cut the rows (second amendment, 2026-11-25, below). One level, child lists only — the shape of `get_record`'s `related`. The link is resolved once, on the published definition, so no caller's pack follows a different link than the author declared. | The related section. For `where`, `orderBy` and `limit`, the child query's filter, order and cut (row 11). | | `body` | `{ field }`: the one long-text field rendered as the record's body. | The body section and its outline ([D3](#d3)). | ```yaml @@ -119,9 +135,19 @@ body: field: content ``` +**Filter, order and limit on a related list (second amendment, 2026-11-25).** A `related` entry may carry three more keys. They choose which child rows the pack carries, and in what order; they never widen a read. `orderBy` and `limit` are keys that `get_record`'s `related` already takes (`packages/mcp/src/mcp-relation-reads.ts#RelatedListRequest`); `where` is the one key a pack adds to that shape. + +- `where`: a filter on the child's **own fields only**, in the platform's object filter form (`packages/spec/src/data/filter.zod.ts#FilterConditionSchema`). v1 admits `$eq`, `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$null` and `$exists` on a field, joined by `$and` / `$or`. Every other operator of that form is refused at parse (`#FILTER_OPERATORS`, `#LOGICAL_OPERATORS`). A bare value on a field is admitted and is read as `$eq`, as that form reads it: `{ is_current: true }` means `{ is_current: { $eq: true } }`. A comparand is a literal value of the kind that form takes for the operator, and so is each member of an `$in` or `$nin` list. It is never a reference to something else. `where` admits no relation traversal (neither a dotted key nor that form's nested condition on the record a lookup points at), no field-to-field comparand (`{ $field }`), no `$now` anchor and no formula. It admits no placeholder either. A string comparand or list member that is one whole `{…}` token, with or without a leading `$`, is refused at parse, whichever token it names: `{today}`, `{now}`, `{current_user_id}`, `{record_id}`, or one the platform does not know (`packages/spec/src/data/context-tokens.zod.ts#FILTER_TOKEN_WRAPPED_RE`). To a parser such a string is a literal, and the data engine resolves it at call time in every `where` it reads (`packages/core/src/utils/filter-tokens.ts#resolveFilterTokens`). There an unknown token, or `{record_id}`, fails the call for every caller, and a known one makes the pack's selection read the clock or the caller. v1 refuses them all at parse, and placeholders resolved at call time are later work. A string that only contains braces is a literal. Anything else is refused at parse. +- `orderBy`: `{ field, order }[]`, the shape of `packages/spec/src/data/query.zod.ts#SortNodeSchema`, on the child's own fields only. The direction is spelled `order`; that schema refuses `direction` by name. Without `orderBy` the read names no order, and the rows come in the data engine's order. +- `limit`: a positive integer, the most rows this list carries. It is at most the service's row cap for one related list (`packages/services/service-record-context/src/record-context-tools.ts#RECORD_CONTEXT_RELATED_MAX_ROWS`: 20 on `main` at `6211ddf4`, and this record still sets no number). Without `limit` the cap applies. Like the pack's other bounds (**v1 keys** above), a `limit` over the cap is refused at parse and is never lowered silently at call time; `get_record` refuses a `related` `limit` over its own cap the same way. A door whose own page cap is lower than a `limit` that parsed cuts the list at that cap, and the cut is stated like any other ([D3](#d3)). + +The link filter stays the service's: `where` is joined to it with `$and`, so no `where` can reach a child row of another root. An example, for an application whose current text lives on a child: `where: { is_current: { $eq: true } }`, `orderBy: [{ field: 'sort_no', order: 'asc' }]`. + +**Declared here, read in row 11.** The three keys land with their render-service reader in one PR ([Implementation split](#implementation-split-after-acceptance), row 11; ADR-0049). Until that PR merges, the schema that row 5 landed (`packages/spec/src/ai/ai-context.zod.ts#AiContextRelatedSchema`) is strict on `object`, `field` and `fields`, and refuses each of the three keys at parse. + **Registration (proposal, row 5 lands it).** One entry on each surface listed in Context. The registry row takes the `skill` row's flags, for the `skill` row's reason: a file loader (`**/*.ai-context.ts`, `**/*.ai-context.yml`), `supportsOverlay: true`, `allowRuntimeCreate: true`, `allowEnvironmentOverlay: false` (ADR-0005's ai row), `domain: 'ai'`; collection key `aiContexts`; a liveness row per key; a `KIND_COVERAGE` row with an example pack. -**Author defects are reported on author surfaces.** A pack that names an object or field that does not exist, a `related` entry with no reference field to the root, or a `body.field` that is not a long-text field is reported by metadata validation at save and by `os validate`. ADR-0149 D2 is the precedent: a dataset member no caller could be served is reported on an author surface, and the tool answer says nothing about it ([D3](#d3)). +**Author defects are reported on author surfaces.** A pack that names an object or field that does not exist, a `related` entry with no reference field to the root, a `where` or `orderBy` that names a field the child does not have, or a `body.field` that is not a long-text field is reported by metadata validation at save and by `os validate`. An operator outside `where`'s admitted set, or a comparand that is a whole `{…}` placeholder, is refused at parse, before any of this. ADR-0149 D2 is the precedent: a dataset member no caller could be served is reported on an author surface, and the tool answer says nothing about it ([D3](#d3)). **Advisory reports (amended 2026-11-25, point 1's third condition).** Two configurations are legal but leave a call to fail at run time. Validation reports each one as an advisory warning, never an error: @@ -130,7 +156,7 @@ body: The skill key and the action type that these reports read land in rows 8 and 6. Each report lands with its reader. -**Later work, not keys:** a fallback from `body` to knowledge search; filters, order and per-list limits on `related`; reads through a parent lookup or deeper than one level; a pack `description`; an override of a packaged pack ([ADR-0146](./0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md) D2's list is not joined). +**Later work, not keys:** a fallback from `body` to knowledge search; reads through a parent lookup or deeper than one level, a `where` that follows a relation among them; placeholders in a `where` that are resolved at call time, such as `{today}` or `{current_user_id}`; a pack `description`; an override of a packaged pack ([ADR-0146](./0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md) D2's list is not joined). ### D2 — The recipe is not on the object {#d2} @@ -152,7 +178,7 @@ The render service takes a pack, a record id and the caller, and returns the pac - the root record, as `get_record` reads it; - a lookup listed in `fields`, as `query_records`' `expand` reads it on the root; -- a `related` entry, as `get_record`'s `related` reads a list: one capped query on the child, filtered by the link field; +- a `related` entry, as `get_record`'s `related` reads a list: one capped query on the child, filtered by the link field joined with the entry's `where`, ordered by its `orderBy` and cut at its `limit` (second amendment, 2026-11-25). With a `where` it is the read `query_records` makes of the child, and still one query. The filter and the order run inside that one query, as the caller: a pack's `where` is written by the author and grants nothing, so the caller's row rules still decide which rows arrive; - a lookup listed in a `related` entry's `fields`, as `query_records`' `expand` reads it on the child. **The pack is projected before its reads are planned.** In the record tools the caller types the names, and a name the caller's schema does not show is answered `INVALID_FIELD`: the refusal names it and tells the caller to fix the request. In a pack the author typed the names and the caller sent none. The same answer would name a field the caller's schema hides, and would tell a model its request was malformed when it sent no field. So a pack may answer differently from a caller-typed read, and the order is fixed: @@ -179,14 +205,14 @@ The root object's gates are unchanged ([D4](#d4), "Order of judgement"). A root - **The caller's served schema shows the field and `getReadableFields` leaves it out** — an exempt caller, or schema masking switched off. The entry keeps its `name` and `label`, carries no value and is marked withheld. The notes name it, with the executor's sentence that such fields are not visible to the caller and are not empty. This is the #35137 rule, unchanged. - **The caller's served schema does not show the field** — the default for an ordinary caller. The pack names nothing: no entry, no name, no count. The notes carry one statement, the same whatever was removed: some of the material this pack covers is not visible to the caller, and the answer must not treat it as empty or absent. This is the `membersWithheld` precedent of ADR-0149 D2. The statement fires only for an entry the published definition has and the caller's served schema hides. A name the published definition lacks is an author defect ([D1](#d1)) and fires nothing. -- **The hidden field is one the pack uses structurally.** A hidden lookup in `fields` is a hidden field: it is dropped as above and never expanded. A `related` entry on a child the caller is served, whose link field that caller's schema hides, is a read the record tools refuse this caller, so the whole section is dropped, with the same statement. A hidden `body` field drops the body section, with the same statement. These are field-level rules, so they omit and state. Only an object-level refusal applies to the whole call. A child the caller is not served at all is settled at object level, in step 1: it is left out with the same statement, and it never reaches this rule. +- **The hidden field is one the pack uses structurally.** A hidden lookup in `fields` is a hidden field: it is dropped as above and never expanded. A `related` entry on a child the caller is served, whose link field that caller's schema hides, is a read the record tools refuse this caller, so the whole section is dropped, with the same statement. A `related` entry whose `where` or `orderBy` names a field this caller cannot query on is dropped whole too, with the same statement, and the field is never named (second amendment, 2026-11-25). The fields a caller can query on are the security service's answer for that caller (`packages/spec/src/contracts/security-service.ts#getQueryableFields`), and a field outside that answer is one the caller cannot query on. That is wider than a hidden field. It takes in a field the caller's schema hides, a field the schema shows while field-level security withholds it, a field this caller is served masked, a field that either party may not read when an agent asks on a person's behalf, and a computed field that reads any of these. Rows chosen or ordered by a value disclose it, a masked value included. So where the security plugin is installed, its engine middleware refuses a caller's filter or sort on each such field (`packages/plugins/plugin-security/src/predicate-guard.ts#assertReadableQueryFields`), judged on the one map that answer is computed from (`packages/plugins/plugin-security/src/security-plugin-object-inputs.ts#computeQueryGuardFieldPerms`). The service judges the entry before it reads, so that refusal is never reached and a field-level rule still never refuses a pack. Where there is no such answer, that contract says what a consumer does: every field that declares a masking rule counts as one the caller cannot query on. A masked field listed in `fields` is still carried as served; only filtering or ordering by it drops the section. A `where` or `orderBy` field the published definition lacks is an author defect and fires nothing, as above: the section is left out, and a filter is never read with one of its conditions removed. A hidden `body` field drops the body section, with the same statement. These are field-level rules, so they omit and state. Only an object-level refusal applies to the whole call. A child the caller is not served at all is settled at object level, in step 1: it is left out with the same statement, and it never reaches this rule. - A masked value is carried as served. The render adds no masking and removes none. This is how ruling 2's sentence — "A field hidden from the caller reads 'not visible to you'" — holds beside ADR-0106 D1, which removes such a field whole because a kept name "still leaks existence". The model is always told that something is not visible. It is told which field only when the caller's own schema already shows that field. **Labels.** A field entry carries `name`, `label` and the value as served, plus a display form where the stored value is not what a person reads: the option label for a select-family field, the display name for a lookup. Labels are the metadata service's at the caller's locale, as ADR-0149 D2 localizes a dataset. -**The body.** A body within the service's bound is carried whole. A longer body is carried as an outline: its headings in order, each with an `anchor`. One section is read by calling the tool again with that `anchor` ([D4](#d4)). A long body with no headings is carried up to the bound and marked truncated. Every cut is stated in the notes — a truncated body, a related list cut at its cap, or a cell cut under the bound below. The body bound and the row cap of a related list are constants of the service, fixed and pinned by test in row 5; this record sets no number. +**The body.** A body within the service's bound is carried whole. A longer body is carried as an outline: its headings in order, each with an `anchor`. One section is read by calling the tool again with that `anchor` ([D4](#d4)). A long body with no headings is carried up to the bound and marked truncated. An outline is bounded too. Its listing stays within the body bound, and the most headings one outline lists is a further constant of the service (`packages/services/service-record-context/src/body-outline.ts#RECORD_CONTEXT_OUTLINE_MAX_ENTRIES`). An outline cut by either bound says so (second amendment, 2026-11-25, carried from the review of objectstack#37178). Every cut is stated in the notes — a truncated body, a cut outline, a related list cut at its `limit`, at its cap or at the door's page cap, or a cell cut under the bound below. The body bound and the row cap of a related list are constants of the service, fixed and pinned by test in row 5; the outline's cap is one too, set and pinned by test in objectstack#37178; this record sets no number. **The bound on carried text (amended 2026-11-25).** A related list's columns may include long-text fields, and their values are carried as served, within one bound. Text the pack carries counts toward one total bound: the body, and every long-text value in the related lists' cells. @@ -236,7 +262,7 @@ The framing sentence covers the data member only, so it does not undo a note. Sp 1. **It is an ordinary tool call.** On MCP it passes through `packages/mcp/src/tool-call-interceptor.ts#routeToolCallsThrough` like every tool; in the product it is a registry tool call. Anything that reads a pack for a model does it as this tool call — the first-turn pre-read of row 9 included — and never by calling the render service directly. 2. **It is a read.** The executor writes nothing. -3. **Its read set is knowable from the call.** The read set is the root object, each `related[].object`, and the target object of each lookup the pack lists, in `fields` or in a `related` entry's `fields`. It is a function of the validated arguments and published metadata only, never of the caller or of record data. The D5 package exports the one function that returns it for a call's arguments, and the executor plans its reads from that same function. A caller's projected plan ([D3](#d3)) reads a subset of the set, never more; row 5 pins by test that the executor reads no object outside it. The set is the call's plan when it is computed, not a guarantee across a publish: a pack published between an interceptor's judgement and the executor's reads changes it. The data door still decides every read. +3. **Its read set is knowable from the call.** The read set is the root object, each `related[].object`, and the target object of each lookup the pack lists, in `fields` or in a `related` entry's `fields`. It is a function of the validated arguments and published metadata only, never of the caller or of record data. A `related` entry's `where`, `orderBy` and `limit` add no object to the set (second amendment, 2026-11-25): `where` and `orderBy` name only the child's own fields, and `where` admits no relation condition. So a filtered pack reads the same objects as an unfiltered one, and an interceptor that judges the set judges both alike. The D5 package exports the one function that returns it for a call's arguments, and the executor plans its reads from that same function. A caller's projected plan ([D3](#d3)) reads a subset of the set, never more; row 5 pins by test that the executor reads no object outside it. The set is the call's plan when it is computed, not a guarantee across a publish: a pack published between an interceptor's judgement and the executor's reads changes it. The data door still decides every read. ### D5 — The render service lives in a new service package {#d5} @@ -316,24 +342,37 @@ Shape only. No schema lands with this record or with row 5: the shape enters spe ## Points that go past the card's words -Each is this record's settlement, taken from the tree's precedent. Points 1, 2 and 10 change what a user sees and needed the maintainer's explicit acceptance. That acceptance was given on 2026-11-25 (「同意你的建议」): point 1 with three conditions, point 2 as amended, point 10 as written. The rest were the approver's, and were accepted with the merge. +Each is this record's settlement, taken from the tree's precedent. Points 1, 2 and 10 change what a user sees and needed the maintainer's explicit acceptance. That acceptance was given on 2026-11-25 (「同意你的建议」): point 1 with three conditions, point 2 as amended, point 10 as written. The rest of points 1–12 were the approver's, and were accepted with the merge. Points 13–22 are the second amendment's and have their own introduction, below point 12. 1. **Pack selection** (D4): with `context` omitted, exactly one pack on the object is used; none or several is a refusal. There is no default pack and no synthesized one. *Accepted 2026-11-25 with three conditions:* the several-packs refusal names each candidate with its label (D4); the in-app pre-read never runs a pack the runtime chose (D8); and validation gives two advisory reports (D1). 2. **Object level** (D3). *Amended 2026-11-25.* A related child the door serves to nobody refuses the call, following #35145. Some user may be able to read the root but not one related object the pack names. That user gets the pack without that section, and with the statement of point 10. The merged text refused the whole pack instead, and left the author to write one pack per audience. That was changed because a pack ships with an application, while object permissions are set per deployment. 3. **A lookup the caller cannot open carries no id** (D3) — neither the bare id nor the id the engine serves beside a `referenceNameVisible` name. This extends the ruling's "no dangling id" from related rows to references. A dangling id renders the same way. 4. **A section is read with `anchor` on the same tool** (D3, D4), not by a second tool. -5. **`related` is child lists, one level; `body` is an object with one key** (D1), so a later key can join each without a reshaping. The schema also bounds a pack's entry counts, so an oversized pack is refused at parse. +5. **`related` is child lists, one level; `body` is an object with one key** (D1), so a later key can join each without a reshaping. *Second amendment, 2026-11-25:* `where`, `orderBy` and `limit` join `related` that way, and no key is reshaped. The schema also bounds a pack's entry counts, so an oversized pack is refused at parse; a `limit` over the row cap is refused the same way. 6. **`ask_ai` takes no `target` and refuses `ai.exposed: true` at parse** (D7). 7. **The MCP prompt's record argument is optional, and the prompt names the tool call instead of carrying the pack** (D8). The call's arguments ride as a JSON object, and a skill with `context` must bind `get_record_context` in `tools`. 8. **The read-set function is exported** from the D5 package, and the pre-read is a tool call (D4). The set is the call's plan, not a guarantee across a publish. 9. **Registry flags, file suffix and collection key** follow the `skill` row (D1). 10. **A field the caller's schema hides is stated, not named** (D3). Ruling 2 says a hidden field reads "not visible to you". ADR-0106 D1 removes such a field whole from an ordinary caller's schema, so the #35137 naming reaches only exempt callers and deployments with masking off. The pack therefore names nothing for an ordinary caller and carries one statement that some of its material is not visible, on the `membersWithheld` precedent. Two alternatives are not taken: naming the field for every caller, which goes against ADR-0106 D1; and saying nothing, which falls short of ruling 2. -11. **A hidden field the pack uses structurally drops its part and does not refuse the pack** (D3). A hidden lookup is not expanded, and a `related` entry whose child the caller is served but whose link field is hidden is left out, each with the statement of point 10. A child the caller may not read at all is point 2's case: it is judged before projection and left out with the same statement. The alternative not taken is the record tools' answer to a caller-typed name, a whole-call `INVALID_FIELD`, which would name the field and blame a request that sent none. +11. **A hidden field the pack uses structurally drops its part and does not refuse the pack** (D3). A hidden lookup is not expanded, and a `related` entry whose child the caller is served but whose link field is hidden is left out, each with the statement of point 10. A child the caller may not read at all is point 2's case: it is judged before projection and left out with the same statement. The alternative not taken is the record tools' answer to a caller-typed name, a whole-call `INVALID_FIELD`, which would name the field and blame a request that sent none. *Second amendment, 2026-11-25:* a `related` entry whose `where` or `orderBy` names a field the caller cannot query on is left out the same way, with the same statement (point 19). 12. **Order and naming** (D3, D4). The root object's gates are judged before pack selection, and each `related` child's before projection. A `context` that names no pack and one rooted on another object get one answer. An object-level refusal names the refused object only when the caller's served schema shows it, and every such refusal carries one code. A child left out for this caller is never named (amended 2026-11-25). +**The second amendment's points (2026-11-25).** The maintainer's word for the second amendment is 「related 的筛选和排序 同意」: filter and order on `related`. Card objectstack#37202 adds to it a per-list `limit`, the child's own fields, "a small operator set", the caller's one capped query, the section dropped for a hidden `where` or `orderBy` field, and the unchanged read set. Points 13–22 are where the text goes past those words. Each is this record's settlement, taken from the tree's precedent or from a rule this record already had. None is the maintainer's own decision in the maintainer's words: they are accepted with the maintainer's merge of the PR that carries the amendment. Points 13–21 change what row 11 builds. + +13. **`related` takes `limit` as well as filter and order** (D1). The maintainer's word names filter and order. The card adds a per-list limit, and `get_record`'s `related` already takes one. Without it, an author who orders a list to carry its first rows cannot say how many. +14. **A `limit` over the row cap is refused at parse** (D1), like the pack's other bounds and like `get_record`'s own `related` `limit`. The card says only "at most the per-list cap". The alternative not taken is to accept the pack and cut at the cap at call time, which lowers an author's number without telling the author. The cost is that the schema and the service must read one declared number, and row 11 declares it. A door with a lower page cap of its own still cuts the list there, and the cut is stated. +15. **`where` admits ten operators, joined by `$and` / `$or`** (D1): `$eq`, `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$null` and `$exists`. The card says "a small operator set" and names none. Left out are `$not`, `$between`, `$empty`, the string-match operators, the nested condition on a lookup's target, the `{ $field }` comparand and the `$now` anchor. Each is refused at parse, and each can join later without reshaping a key. +16. **A bare value is read as `$eq`** (D1): `{ is_current: true }`. It is the filter form's first spelling and the one an author reaches for. The alternative not taken is to refuse it and require the operator spelling. +17. **A whole `{token}` comparand is refused at parse** (D1), beside the `$now` anchor: `{today}`, `{now}`, `{current_user_id}`, `{record_id}`, and any token the platform does not know. The data engine would resolve such a string at call time. The pack's selection would then read the clock or the caller, and an unknown token or `{record_id}` would fail every caller's call. The alternative not taken is a list of admitted tokens; placeholders resolved at call time are later work. +18. **`orderBy` is `{ field, order }[]`** (D1), the tree's sort node. The direction is spelled `order`, and that schema refuses `direction` by name. With no `orderBy` the read names no order, because the data engine adds none. +19. **A `where` or `orderBy` field the caller cannot query on drops the section** (D3), stated and never named. The card says "hidden". "Cannot query on" is every field outside the security service's `getQueryableFields` answer: besides the hidden field, it takes in the field the schema shows and field-level security withholds, the field served masked, and the others D3 lists. Under the narrower rule those callers would get a whole-call refusal from the engine's guard, where this record says a field-level rule omits and states. +20. **A `where` or `orderBy` field the published definition lacks leaves the section out** (D1, D3). It is an author defect, reported at save and by `os validate`, and the answer states nothing. The alternative not taken is to run the filter without that condition, which would carry rows the author excluded. +21. **A list cut at its own `limit` is a stated cut** (D3), like a list cut at the cap, so the model knows that more rows matched than it was given. +22. **The cap on an outline's entries is named** (D3, "The body"). This point is not about `related` and is not from the maintainer's word. The seat's review of PR objectstack#37222 (card objectstack#37178), nit N5, asked this record to name that cap as a further constant of the service and a further stated cut. The record sets no number. + ## Implementation split (after acceptance) -Rows 5–10 of the epic's table, with the epic's numbers. Listed, not filed: the owning seat files them when this record merges. Each PR makes its own `Metadata-protocol:` declaration; the column is the expected one. +Rows 5–10 of the epic's table, with the epic's numbers, and row 11, which the second amendment of 2026-11-25 adds. Listed, not filed: the owning seat files them when this record merges. Each PR makes its own `Metadata-protocol:` declaration; the column is the expected one. | Row | Card | Lane | `Metadata-protocol:` | Blocked by | Implements | |:--|:--|:--|:--|:--|:--| @@ -343,8 +382,11 @@ Rows 5–10 of the epic's table, with the epic's numbers. Listed, not filed: the | 8 | Skill key `context`; MCP skill prompts take a record argument | server | `added` | 5 | D8 | | 9 | cloud: the in-app chat persists the focus and pre-reads the pack as a tool call on the first turn | objectstack-ai/cloud | — | objectstack#36999, 5, 8 | D4 (registry registration), D6 and D8 (cloud readers) | | 10 | Answer citations that open the record at the cited place (split after this record merges) | — | `added` when the shape enters spec | this record | D9 | +| 11 | `related` filter, order and limit: the `where`, `orderBy` and `limit` keys and their render-service reader in one PR (second amendment, 2026-11-25) | spec + server | `added` | 5, the second amendment | D1, D3, D4 | + +Row 11 is the one row this record itself adds, by the second amendment of 2026-11-25 (card objectstack#37203). Row 5 has merged (PR objectstack#37173) with `related` strict on `object`, `field` and `fields`, so row 11 is a PR of its own that adds the three keys and their reader together. It also settles where the row cap's number is declared, so that the schema that bounds `limit` and the service that cuts the list read one number; today the number is the service's alone. This record sets no bound on the size of a `where` (its conditions, its nesting, the members of an `$in` list). Row 11 may set one in the schema, refused at parse like the pack's other bounds. -The lanes are the epic's, and three of them understate the work. This record adds no row; the seat decides how the cards carry it. +The lanes of rows 5–10 are the epic's, and three of them understate the work. For that this record adds no row; the seat decides how the cards carry it. - Row 7's form is a spec file, by the precedent of `packages/spec/src/ai/skill.form.ts`. - Row 8's key is a spec key, with its liveness row. @@ -357,7 +399,7 @@ The lanes are the epic's, and three of them understate the work. This record add - **One pack can serve roles with different object access** (amended 2026-11-25). A related object a role cannot read is left out for that role, and the answer says that some material is not visible. Only an object the door serves to nobody refuses the pack, and that is an author defect. A field-level rule never refuses a pack either: it shortens the pack and says so. - **An ordinary caller is told that something is hidden, never what.** The per-field "not visible to you" is seen only by a caller whose own schema shows the field (point 10). - **The seams need no new code for this tool.** `get_record_context` is a read whose objects are known from its arguments; cloud#4969 and cloud#4970 can cite D4. -- **Three protocol additions follow** — a kind, an `ActionType` member, a skill key — each in the PR that brings its reader. +- **Three protocol additions follow** — a kind, an `ActionType` member, a skill key — each in the PR that brings its reader. The second amendment of 2026-11-25 adds a fourth: the three `related` keys of row 11. - **A new package** joins `packages/services/`, if D5's proposal stands. ## Alternatives considered