Skip to content

ai_context: related lists filter, order and limit (where / orderBy / limit) with the render-service reader #37203

Backlog

Description

@objectstack-fleet

repo:cloud#2 · os-bob · session_012dn2AecKpLaYkUtNRiqtby

Filing gate: ③ maintainer-directed (topic child). Source: topic #36996 (ADR-0160 Implementation split, row 11); maintainer 2026-11-25, verbatim: 「related 的筛选和排序 同意」.
Grading: area:ai · Feature · p2 (topic) · reach: every ai_context pack with a related list · evidence: read.

维护者速读

  • 做什么:情境包的关联列表(related)可以筛选、排序、限条数:where(只能用子对象自己的字段,少量运算符)、orderBy、limit。
  • 例子:BrightRule 的制度包只带现行版本的文档,正文在前、附件按序号排:where: { is_current: { $eq: true } },orderBy: [{ field: 'sort_no', order: 'asc' }]。CRM 的客户包只带未关闭的商机、按金额倒序。
  • 安全:筛选是作者写的,只是「选取」,不授予也不收回权限,提问人的行级规则照旧生效;筛选或排序用到的字段是提问人不能用来查询的字段时,整个关联段落省略并附一句「部分资料对你不可见」,不报错、不点名。
  • 需要你做的:无(规则已在 ADR-0160 修订中裁定,见 ADR-0160 amendment: related lists gain where / orderBy / limit (row 11 contract) #37202)。

What

  1. Spec (packages/spec/src/ai/ai-context.zod.ts, as landed by 记录 AI 问询 5:资料包类型 ai_context、渲染服务与 get_record_context 工具(MCP) #37140): related[] gains optional
    • where: the object-filter form (packages/spec/src/data/filter.zod.ts) restricted to the child's own fields, operators $eq $ne $in $nin $gt $gte $lt $lte $null $exists, joined by $and / $or. A bare value is read as $eq. Refused at parse: dotted paths, field-to-field comparands, a comparand that is one whole {token} (v1), $now anchors, formulas, any other operator.
    • orderBy: SortNodeSchema[] (packages/spec/src/data/query.zod.ts), that is { field, order }[], on the child's own fields. The direction is spelled order; SortNodeSchema refuses direction.
    • limit: positive integer, at most the service's per-list cap.
    • Liveness rows for the three keys with this card's reader; the KIND_COVERAGE example pack gains one filtered, ordered list; generated baselines refreshed.
  2. Render service (packages/services/service-record-context): the one capped child query joins the link filter and where with $and, applies orderBy and limit, as the caller. No second query.
  3. Field-level rule (ADR-0160 D3, amended): a where or orderBy field the caller cannot query on (every field outside getQueryableFields) drops the whole related section, with the single not-visible statement; the field is never named; never a refusal.
  4. Author surfaces (ADR-0160 D1): a where / orderBy field the child does not have is reported at save and by os validate; an operator outside the set is refused at parse.
  5. Read set (ADR-0160 D4): unchanged by these keys — the exported read-set function takes no new input from them.

Acceptance

  • Filter and order applied: a pack with where + orderBy + limit returns only matching child rows, in order, cut at limit; the cut is stated in the notes.
  • A row the caller's row rules hide stays absent even when it matches where (the filter grants nothing).
  • A where field and an orderBy field the caller cannot query on each drop the section with the not-visible statement, for an ordinary caller; the field name appears nowhere in the answer.
  • An unknown operator, a dotted path, a field-to-field comparand and a whole-{token} comparand are refused at parse; a bare value reads as $eq; an unknown field is reported by os validate.
  • The read-set function returns the same set with and without the three keys (pinned by test).
  • Same answer on MCP stdio and HTTP for one caller (the 记录 AI 问询 5:资料包类型 ai_context、渲染服务与 get_record_context 工具(MCP) #37140 parity harness).
  • Container run per AGENTS.md.

Out of scope

Blocked-by: #37140, #37202 (ADR-0160 amendment carrying this decision)
Parent: #36996. Reader: the server lane for service-record-context, with one spec file.
Dedupe: related where orderBy ai_context 0 · ai_context related filter 1 (the epic) · get_record_context related orderBy 1 (the seat post, no card).

Activity

  1. added
    priority:p2
    area:ai
    pm:blocked
    on Nov 25, 2026
  2. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    Triage: first touch 2026-11-25T03:35Z

  3. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    Row added 2026-11-25T06:12Z, at repo:objectstack#3's request (mailbox #36743, 7154521857). It is a conformance gap against ADR-0160 as amended by #37196 (merged at 03:47Z). This card builds the related-list read in get_record_context, so the gap rides here.

    • A related child the caller is not served refuses the whole call. packages/services/service-record-context/src/record-context-tools.ts:283 and :290 call refuseObject(entry.object, false) for a related child that the entry does not serve. The amended ADR says such a child is left out of the answer, and the answer says so. Done when the call returns the root and its served children, names the omitted child in the answer, and pins both an unserved child and a served control. The :296 arm, for exposure refusals, stays as the ADR says.

    Read on main (the lines are confirmed), not yet measured through the tool.

  4. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    2026-11-25T07:06Z Body aligned with the ADR-0160 second amendment (PR #37240, #37202), at seat 3's request (mailbox #36743, 7155462225; L1-w notes):

    1. The sort direction is spelled order (orderBy is { field, order }[]; SortNodeSchema refuses direction). The example in the quick read is fixed too.
    2. "served schema hides" now reads "cannot query on (every field outside getQueryableFields)", in What 3, the Acceptance and the quick read.
    3. Added: a bare value in where is read as ``.
    4. Added: a comparand that is one whole {token} is refused at parse in v1 (What 1 and the Acceptance).

    The body never had a "stays draft with pm:awaiting-merge" line, so nothing was dropped.

  5. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    2026-11-25T07:08Z Correction to the note above. Item 3 lost its operator to shell expansion. It reads: a bare value in where is read as $eq. The card body itself is correct.

  6. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    Unlocked 2026-11-25T08:38Z. PR #37240 merged and closed #37202, the ADR-0160 second amendment. #37140 was already closed. pm:blocked → pm:queue. Goes to seat 3 zone ai-A, as a non-cloud row of #36996 (row 11). The body was aligned with the amendment at 07:07Z, and it carries the unserved-related-child row.

  7. added
    pm:queue
    and removed
    pm:blocked
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:aipm:queuepriority:p2

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions