Repository navigation
feat(ai): a context pack's related list takes where / orderBy / limit (ADR-0160 row 11) - #37354
Conversation
…R-0160 row 11) Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
…ows, showcase pack, changeset Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
…ill orderBy liveness Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 29 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 6 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 176 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b1ce322417d949f19f2b9da92a85cbc268e02a0e && git checkout b1ce322417d949f19f2b9da92a85cbc268e02a0e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin d0088bbb8fec784e3a8e6d6b9e564ccb3e14f6eb bb0107ccadaab70025c410545408414395527a26 && git checkout -B drift-repro d0088bbb8fec784e3a8e6d6b9e564ccb3e14f6eb && git merge --no-ff bb0107ccadaab70025c410545408414395527a26
node scripts/docs-audit/affected-docs.mjs --json d0088bbb8fec784e3a8e6d6b9e564ccb3e14f6eb
|
…78 schemas, 1210 sites) Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
…le-call refusal out of this PR The amended left-out behaviour flips a pin in packages/runtime (the real-kernel parity harness), which is outside this PR's file surface; it goes to its own change with that pin. Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head aa76b90 · 2026-11-25T23:05Z The seat runs the at-tier contract review of this head through an isolated sub-agent; L1 is the seat's own. |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: Inputs read: card #37203 (body and all 8 comments), PR #37354 body and file list (21 files), the net diff against ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
S1 (should-fix) —
S2 (should-fix) — an
Nits, none affecting correctness on the in-tree doors:
Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
…st ordered by a field not offered as a sort S1: AI_CONTEXT_WHERE_MAX_DEPTH (32) bounds $and / $or nesting in a related list's where at parse, and aiContextWhereFields walks to exactly that depth, so every field of a where that parsed is judged by the render service and the author surfaces. S2: an orderBy field the child's sortability projection calls unsortable (a formula, or sortable: false) is an author defect: get_record_context leaves the section out and states nothing, instead of the doors' INVALID_SORT refusing the whole call, and validateAiContext reports it as the new warning ai-context-sort-field-unsortable. Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
…vers line within the one-line bound Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head bb0107c · 2026-11-26T00:44Z The seat runs the at-tier contract review of this head through an isolated sub-agent; L1 is the seat's own. |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: Delta review of the round on ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentS1: closed
The formula widening, against both doors' actual predicate.
Tried and not broken: a pack with both an unknown and an unsortable order field (left out by the first check); an order on Nits, none affecting correctness on the in-tree doors:
Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
Fixes #37203
Clause-②: yes
Metadata-protocol: added
Skills-docs: follow-up #37177
维护者速读
What changes
Spec (
packages/spec/src/ai/ai-context.zod.ts). Arelatedentry gains three optional keys, per ADR-0160 D1 (second amendment):where: the object filter form on the child's own fields, held toAI_CONTEXT_WHERE_OPERATORS($eq $ne $in $nin $gt $gte $lt $lte $null $exists) joined by$and/$or. A bare value is$eq. Refused at parse: any other operator, a dotted path, a condition on a lookup's target,{ $field }, a$nowanchor, a formula/object comparand, and a comparand that is one whole brace placeholder (matched byFILTER_TOKEN_WRAPPED_RE). Built asFilterConditionSchemaplus one refinement walk, so the base form's own comparand refusals still apply.orderBy:SortNodeSchema[]({ field, order },directionrefused by name), with the field held to a snake_case own-field name.limit: positive integer up toAI_CONTEXT_MAX_RELATED_ROWS(20). This is the one number.RECORD_CONTEXT_RELATED_MAX_ROWSin the service now reads it (ADR-0160 row 11: "the schema that boundslimitand the service that cuts the list read one number").aiContextWhereFields(where): lists the fields awherenames. The service and the lint rule both use it.filter→where,sort/sortBy→orderBy. The schema-levelguidance.filternow points at the entry'swhere.Render service (
packages/services/service-record-context).where: { $and: [linkFilter, entry.where] }, withorderByandlimit: (entry.limit ?? cap) + 1. A cut atlimitis markedtruncatedand stated (related_truncated). Still one query.where/orderByfield is judged. A field the child's published definition lacks leaves the section out with nothing stated (ADR point 20). A field the caller cannot query on drops the section with the onenot_visiblestatement, and the field is never named (D3, point 19). Neither case refuses the call.queryableFieldsOf(the security service'sgetQueryableFields). Without that answer, the contract's fallback applies (ISecurityService.getQueryableFields): the field must be served, must not be withheld (fieldVisibilityOf), and must declare nomaskingRule. A probe that throws drops the section with the statement.aa76b901b, because turning it on flips the real-kernel parity pin inpackages/runtime(landed in test(runtime): get_record_context answers one caller with the same bytes on the /mcp and stdio doors over a real kernel #37350, case titled "[today; ADR-0160 as amended says left out and stated]"), andpackages/runtimeis fenced here. Today's behaviour (the whole call is refused) is unchanged. It moves to a follow-up card.recordContextReadSet/planObjectsOf) does not change (D4), and a test pins it with and without the keys.Author surfaces (
packages/lint/src/validate-ai-context.ts). This extends the #37176 rule rather than adding a validator. AwhereororderByfield the child does not define is reported asai-context-field-unknown(warning) at save and byos validate, and the message says the list is left out.Review delta S1/S2 (contract record 7177225249, on bb0107c).
AI_CONTEXT_WHERE_MAX_DEPTH(32) bounds$and/$ornesting inwhereat parse, refused at the list that would carry a condition past it.aiContextWhereFieldswalks to that same constant, so every field of awherethat parsed is judged by the service and the lint rule. A test pins the bound: 32 parses and names the innermost field, 33 is refused once.orderByfield the child's sortability projection calls unsortable (resolveObjectSortability: a formula, orsortable: false) is an author defect. The executor leaves the section out and states nothing, matching the "field the definition lacks" arm and ADR D1, instead of letting the door refuse the whole call withINVALID_SORT.validateAiContextreports it at save and byos validateas the new warningai-context-sort-field-unsortable, with anos explainentry. HTTP door, read only (runtime is fenced):recordContextMembers→bridge.query→callData('query')→protocol.findData→assertSortFieldsExistrefuses it with400 INVALID_SORTtoo (formula by the unmaterialized-type verdict,sortable: falsebyassertSortFieldsAreOffered), so before this fix both transports refused the call. After it, neither door is asked.Liveness, example, generated.
liveness/ai_context.jsongainsrelated.where,related.orderBy.{field,order}andrelated.limit. The showcaseKIND_COVERAGEpackshowcase_project_briefnow carries open tasks filtered bystatus $ne done, ordered bydue_date,limit: 10. Regenerated:dropped-refinements.baseline.json(thewherewalk and theorderByfield check are refinements JSON Schema cannot carry; the build printed these rows), authorable-surface, api-surface, export-origins, declaration-map, reference docs, state-counts.Tests
Local runs (final head bb0107c; the derived gate sweep re-run on bb0107c)
pnpm --filter @objectstack/service-record-context test: 2 files, 99 tests passed. The new describe block "a related list's where, orderBy and limit" has 18 cases.pnpm --filter @objectstack/spec exec vitest run src/ai/ai-context.zod.test.ts: 23 passed (parse admits and refuses every bullet of What 1, and the nesting bound).pnpm --filter @objectstack/lint exec vitest run src/validate-ai-context.test.ts: 18 passed. Whole packagepnpm --filter @objectstack/lint test: 235 files, 9633 tests passed.pnpm --filter @objectstack/mcp exec vitest run src/mcp-record-context-tools.test.ts(read-only run of the 记录 AI 问询 5:资料包类型 ai_context、渲染服务与 get_record_context 工具(MCP) #37140 parity harness against the rebuilt service, at 16b86ef): 14 passed. CI Test Core at bb0107c runs it and the runtime real-kernel harness: green.@objectstack/spec,@objectstack/service-record-contextand@objectstack/lintall exit 0.pnpm --filter @objectstack/spec check:generated: all 14 artifacts up to date.Ablations: five, each through
scripts/ablation-replace.mjswith the blob restored to HEAD. Each suite importssrc, so there is no dist step.queryableAmong: 6 cases red (the four unqueryable cases, the masking fallback, the throwing probe).$andjoin: 4 cases red, including "no where reaches another root's rows".sortable: false, formula), the door'sINVALID_SORTreached.Acceptance notes
wherepack is not pinned here. The 记录 AI 问询 5:资料包类型 ai_context、渲染服务与 get_record_context 工具(MCP) #37140 harness ispackages/mcp/src/mcp-record-context-tools.test.ts, which was fenced for this PR while sibling 37140 跟进:get_record_context 在运行时 HTTP 通道上用真执行器测一遍(含拒绝) #37175 was in flight inpackages/runtime/**andpackages/mcp/**. Both doors hand the one executor a door whosequerypasses the options through (recordContextMembers, the stdio bridge'squeryalready takesorderBy), and the existing harness runs green against this build. The pin is a follow-up for the report.queryableFieldsOfyet, so on real doors the contract fallback decides (masking-declared, hidden and withheld fields count as not queryable). A field that the security service's answer would exclude but the fallback admits (an agent acting on someone's behalf, or a computed field reading a hidden one) still reaches the engine guard, and the guard refuses the call. This is reported as a finding for the door lane.ContextPackRelatedEntriesdoes not offer the three keys yet; it preserves them on edit (note 7168171718). That goes to 记录 AI 问询 7:在 Studio 里编辑资料包(ai_context 表单与作者界面) #37143.RecordContextNoteKind's doc line still saysrelated_truncatedis "cut at the row cap". It now also fires atlimit. This is spec prose outside the claim's one spec file and is left as is.limit + 1cuts silently. That is pre-existing for the cap too, and left as is.wherenesting is bounded (S1). No bound on the number of conditions or$inmembers was set; ADR row 11 allows one, but none was needed.Verification
Two-minute check:
pnpm --filter @objectstack/service-record-context exec vitest run src/__tests__/record-context-tools.test.ts. Expect it green, with the "a related list's where, orderBy and limit" block green.Read first: (1)
record-context-tools.ts, the 4b block that judgesqueriedfields beforerelatedPlans.push, and the$andquery; (2)ai-context.zod.ts,checkRelatedWhere.Generated by Claude Code