Skip to content

feat(ai): a context pack's related list takes where / orderBy / limit (ADR-0160 row 11) - #37354

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-37203-related-where-orderby-limit
Nov 26, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-37203-related-where-orderby-limit

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #37203

Clause-②: yes
Metadata-protocol: added
Skills-docs: follow-up #37177

维护者速读

  • 用户能看到什么变化:AI 读取记录资料包时,关联列表可以按作者写的条件筛选、排序并限制条数;条件或排序用到提问人不能查询的字段时,这一段被省略并附一句「部分资料对你不可见」,不再整次报错。
  • 为什么做:记录范围 AI 问询专题的第 11 行(关联列表的筛选和排序),按维护者已同意的设计修订实现。
  • 出错会怎样:最坏是某个关联段落被省略或条数不对,AI 回答少了资料;不会多给提问人无权看的数据;撤回此 PR 即恢复原行为。
  • 要你做什么:无。

What changes

Spec (packages/spec/src/ai/ai-context.zod.ts). A related entry gains three optional keys, per ADR-0160 D1 (second amendment):

  • where: the object filter form on the child's own fields, held to AI_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 $now anchor, a formula/object comparand, and a comparand that is one whole brace placeholder (matched by FILTER_TOKEN_WRAPPED_RE). Built as FilterConditionSchema plus one refinement walk, so the base form's own comparand refusals still apply.
  • orderBy: SortNodeSchema[] ({ field, order }, direction refused by name), with the field held to a snake_case own-field name.
  • limit: positive integer up to AI_CONTEXT_MAX_RELATED_ROWS (20). This is the one number. RECORD_CONTEXT_RELATED_MAX_ROWS in the service now reads it (ADR-0160 row 11: "the schema that bounds limit and the service that cuts the list read one number").
  • aiContextWhereFields(where): lists the fields a where names. The service and the lint rule both use it.
  • Near-miss aliases: filter → where, sort / sortBy → orderBy. The schema-level guidance.filter now points at the entry's where.

Render service (packages/services/service-record-context).

  • The one capped child query is where: { $and: [linkFilter, entry.where] }, with orderBy and limit: (entry.limit ?? cap) + 1. A cut at limit is marked truncated and stated (related_truncated). Still one query.
  • Before that query, each where / orderBy field 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 one not_visible statement, and the field is never named (D3, point 19). Neither case refuses the call.
  • "Cannot query on" is the door's new optional queryableFieldsOf (the security service's getQueryableFields). Without that answer, the contract's fallback applies (ISecurityService.getQueryableFields): the field must be served, must not be withheld (fieldVisibilityOf), and must declare no maskingRule. A probe that throws drops the section with the statement.
  • Triage row 7154563681 on the card (a related child that this caller is not served is left out, not refused) is not in this PR. It was implemented and then reverted in aa76b901b, because turning it on flips the real-kernel parity pin in packages/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]"), and packages/runtime is fenced here. Today's behaviour (the whole call is refused) is unchanged. It moves to a follow-up card.
  • The read set (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. A where or orderBy field the child does not define is reported as ai-context-field-unknown (warning) at save and by os validate, and the message says the list is left out.

Review delta S1/S2 (contract record 7177225249, on bb0107c).

  • S1: AI_CONTEXT_WHERE_MAX_DEPTH (32) bounds $and / $or nesting in where at parse, refused at the list that would carry a condition past it. aiContextWhereFields walks to that same constant, so every field of a where that 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.
  • S2: an orderBy field the child's sortability projection calls unsortable (resolveObjectSortability: a formula, or sortable: 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 with INVALID_SORT. validateAiContext reports it at save and by os validate as the new warning ai-context-sort-field-unsortable, with an os explain entry. HTTP door, read only (runtime is fenced): recordContextMembers → bridge.query → callData('query') → protocol.findData → assertSortFieldsExist refuses it with 400 INVALID_SORT too (formula by the unmaterialized-type verdict, sortable: false by assertSortFieldsAreOffered), so before this fix both transports refused the call. After it, neither door is asked.

Liveness, example, generated. liveness/ai_context.json gains related.where, related.orderBy.{field,order} and related.limit. The showcase KIND_COVERAGE pack showcase_project_brief now carries open tasks filtered by status $ne done, ordered by due_date, limit: 10. Regenerated: dropped-refinements.baseline.json (the where walk and the orderBy field 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 package pnpm --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.
  • Typecheck: @objectstack/spec, @objectstack/service-record-context and @objectstack/lint all exit 0.
  • pnpm --filter @objectstack/spec check:generated: all 14 artifacts up to date.

Ablations: five, each through scripts/ablation-replace.mjs with the blob restored to HEAD. Each suite imports src, so there is no dist step.

  1. Skip queryableAmong: 6 cases red (the four unqueryable cases, the masking fallback, the throwing probe).
  2. Drop the $and join: 4 cases red, including "no where reaches another root's rows".
  3. S2, skip the executor's sortability check: 2 cases red (sortable: false, formula), the door's INVALID_SORT reached.
  4. S1, drop the parse depth bound: 1 case red (the bound test).
  5. S2, skip the lint verdict: 2 cases red (the rule test and its save-door family). A first attempt was refused by the tool as a no-op (ambiguous replacement) and re-run with a unique one.

Acceptance notes

  • Parity on both transports with a where pack is not pinned here. The 记录 AI 问询 5:资料包类型 ai_context、渲染服务与 get_record_context 工具(MCP) #37140 harness is packages/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 in packages/runtime/** and packages/mcp/**. Both doors hand the one executor a door whose query passes the options through (recordContextMembers, the stdio bridge's query already takes orderBy), and the existing harness runs green against this build. The pin is a follow-up for the report.
  • Neither MCP door hands queryableFieldsOf yet, 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.
  • Studio's ContextPackRelatedEntries does 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 says related_truncated is "cut at the row cap". It now also fires at limit. This is spec prose outside the claim's one spec file and is left as is.
  • A door whose own page cap is below limit + 1 cuts silently. That is pre-existing for the cap too, and left as is.
  • where nesting is bounded (S1). No bound on the number of conditions or $in members 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 judges queried fields before relatedPlans.push, and the $and query; (2) ai-context.zod.ts, checkRelatedWhere.


Generated by Claude Code

@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation protocol:ai tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/lint, @objectstack/service-record-context, @objectstack/spec, touching 32 documentable anchor(s). ⚠️ 9 changed file(s) yielded no anchor (packages/lint/src/index.ts, packages/spec/api-surface/ai.json, packages/spec/authorable-surface/ai.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

29 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json d0088bbb8fec784e3a8e6d6b9e564ccb3e14f6eb.

⛔ 6 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 9 changed file(s) yielded no anchor (packages/lint/src/index.ts, packages/spec/api-surface/ai.json, packages/spec/authorable-surface/ai.json, …) — pages documenting those are invisible to this run
  • 6 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 176 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json d0088bbb8fec784e3a8e6d6b9e564ccb3e14f6eb → packageMentionDocs.

Which tree this was computed on

This run read content/docs from b1ce322417d949f19f2b9da92a85cbc268e02a0e — the merge of head bb0107ccadaab70025c410545408414395527a26 into base d0088bbb8fec784e3a8e6d6b9e564ccb3e14f6eb, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs d0088bbb8fec784e3a8e6d6b9e564ccb3e14f6eb → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…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>
@github-actions github-actions Bot added size/l and removed size/xl labels Nov 25, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: aa76b901be459a8271b412ad9fcb099024a7fb33
Local-runs: none
Scope: packages/spec/src/ai/ai-context.zod.ts + packages/services/service-record-context/src/record-context-tools.ts, packages/services/service-record-context/src/door.ts, packages/lint/src/validate-ai-context.ts

Inputs read: card #37203 (body and all 8 comments), PR #37354 body and file list (21 files), the net diff against main, the check-runs on this head (no failure; every required run success or skipped). Read to judge, not reviewed: docs/adr/0160-record-scoped-ai-inquiry.md (D1, D3, D4, points 13 to 21, row 11), packages/spec/src/data/filter.zod.ts, packages/spec/src/data/query.zod.ts, packages/spec/src/data/context-tokens.zod.ts, packages/spec/src/contracts/security-service.ts, packages/runtime/src/domains/mcp.ts#recordContextMembers, packages/mcp/src/stdio-data-bridge.ts.

① Derived judgments

  • related[] accept set widened by three optional keys (where, orderBy, limit); a pack without them parses and reads exactly as before. Right: ADR-0160 row 11, Metadata-protocol: added.
  • where is FilterConditionSchema plus one refinement walk, so it is a strict subset of the object filter form and the base form's comparand refusals still run. Read against ADR D1: the ten operators and $and / $or admitted; $not, every other $ key, a dotted key, a nested condition on a lookup's target, { $field }, $now, an object comparand, a whole {token} string (also as an $in / $nin member), a nested list and an empty operator map are each refused; a bare value is $eq; a string that only contains braces stays a literal. Right.
  • orderBy is SortNodeSchema[] with .min(1) and an own-field name check. orderBy: [] is refused, which the ADR's words do not state; an empty order means nothing, so right.
  • limit is an integer from 1 to AI_CONTEXT_MAX_RELATED_ROWS (20), and RECORD_CONTEXT_RELATED_MAX_ROWS now reads that constant. Right: point 14, one number. The service constant's type widens from the literal 20 to number; additive.
  • The aliases filter, sort, sortBy change a refusal's message only (the object was already strict). The schema-level guidance.filter text now points at the entry's where. Right.
  • New public exports of @objectstack/spec/ai: AI_CONTEXT_MAX_RELATED_ROWS, AI_CONTEXT_WHERE_OPERATORS, AI_CONTEXT_WHERE_COMBINATORS, aiContextWhereFields, AiContextRelatedWhereSchema and its two types. Additive; api-surface and export-origins moved with them and their gates are green.
  • RecordContextDoor.query takes an optional orderBy, and the door gains the optional queryableFieldsOf. Additive for a door implementer. Both in-tree doors pass query options through unchanged (read in recordContextMembers and the stdio bridge's query), so orderBy reaches the engine.
  • Lint: ai-context-field-unknown now also fires for a where / orderBy field the child lacks. No existing pack can carry those keys, so no existing pack gains a warning. Right.
  • The published JSON Schema for where and orderBy is wider than the Zod type; the new sites are in dropped-refinements.baseline.json and the gate is green. Right: new rules entering the ledger, no existing exemption widened.
  • The read set is unchanged: planObjectsOf takes nothing from the three keys (D4). Right.

② Semver level

minor on @objectstack/spec, @objectstack/service-record-context and @objectstack/lint. The diff adds authorable keys (Metadata-protocol: added, which takes at least minor on each package it moves) and removes or narrows nothing an author could write before. Check Changeset is success.
Clause-②: yes. The line stands in the PR body and in the changeset body, with no arm, and matches the diff.

③ Boundary flags

  • SQL push-down: holds. where, orderBy and limit all go into the one child query ($and with the link filter, limit + 1 probe). No new id materialisation and no in-app join, filter or sort. The added probes (queryableFieldsOf, fieldVisibilityOf) are metadata reads, at most one per related entry.
  • open_questions: none in the report.
  • Dev flag, parity acceptance PARTIAL: the card's line "same answer on MCP stdio and HTTP" has no where-pack case, because packages/mcp and packages/runtime were fenced. Accepted as carried, not as met. Escalated to the seat: the parity case needs a card before this PR closes ai_context: related lists filter, order and limit (where / orderBy / limit) with the render-service reader #37203.
  • Dev flag, neither real door supplies queryableFieldsOf: on real doors the fallback decides (served, not withheld, no maskingRule). That is the fallback the getQueryableFields contract and ADR D3 name, and it covers the card's "ordinary caller". A field the security answer excludes but the fallback admits (an agent acting for a person, a computed field reading a hidden one) still reaches the engine guard, which refuses the whole call: fail-closed, and against D3's "that refusal is never reached". Escalated to the seat: the door card (packages/runtime/src/domains/mcp.ts#recordContextMembers, packages/mcp/src/stdio-data-bridge.ts) has no carrier yet and needs one.
  • Dev flag, triage row 7154563681 (a related child this caller is not served is left out) implemented and reverted: answered, the tree at this head still refuses and the PR body says so. Escalated to the seat: the PR body says Fixes #37203, and the card's row is unchecked, so the row needs its own card before the merge closes this one.
  • Dev flag, Studio does not offer the three keys: answered, carried by 记录 AI 问询 7:在 Studio 里编辑资料包(ai_context 表单与作者界面) #37143 (note 7168171718).
  • Dev flag, RecordContextNoteKind prose says a cut "at the row cap": see N1.
  • Dev flag, a door page cap below limit + 1: see N2.
  • Dev flag, the baseline ledger grew: answered in ①.
  • Dev flag, stale PR body: answered, the body at this head names aa76b901b, 96 tests and the revert.
  • Dev flag, commit trailers: not a contract matter; the lane seat's.

④ Design judgment

packages/spec/src/ai/ai-context.zod.ts, against ADR-0160 D1 (second amendment) and its first consumer, executeGetRecordContext: the schema holds, with one hole.

S1 (should-fix) — aiContextWhereFields stops walking at depth 32, while checkRelatedWhere and FilterConditionSchema admit any nesting. A where nested deeper than 32 combinators parses, and the fields it names below that depth are in no list: the service does not judge them (neither "the child lacks it" nor "the caller cannot query on it"), the lint rule does not report them, and the query still runs with them. With the security plugin the engine guard then refuses the whole call for a caller who cannot query on such a field, which D3 says never happens; an unknown field reaches the engine. The two walks of one tree must agree: refuse nesting past a bound at parse (row 11 invites one, "refused at parse like the pack's other bounds"), or drop the cap. Pin the boundary by test.

packages/services/service-record-context/src/record-context-tools.ts and door.ts, sentence by sentence against D3: one capped query; the link filter joined with $and (a top-level $or in where cannot reach another root); orderBy passed; limit + 1 probe and the cut stated at plan.cap; a field the published definition lacks leaves the section out and states nothing; a field the caller cannot query on drops the section with the one statement and is never named; a throwing probe drops the section. The door answer path requires the field to be served as well as queryable. All agree with the contract. One case is not judged:

S2 (should-fix) — an orderBy on a field its author declared sortable: false is not judged anywhere. The stdio door's query refuses it before the engine (unofferedSortRefusal, INVALID_SORT, "Query parameter 'orderBy' sorts by ..."), and the executor does not catch it, so such a pack validates clean and then fails every call for every caller, with an error that blames a parameter the caller never sent. It is an author defect, and ADR D1 puts author defects on author surfaces while the answer states nothing. Report it in validate-ai-context.ts (and leave the section out in the executor, as for a field the child lacks), or have the seat rule it out of this card with a follow-up. Read on the stdio door only; the HTTP door's verdict was not read, so the parity line may also be at stake.

packages/lint/src/validate-ai-context.ts: extends the #37176 rule, reads the same aiContextWhereFields as the service, reports at related[i].where and related[i].orderBy[k].field, and its message matches what the service does (the list is left out). Agrees with D1, subject to S1 and S2.

Nits, none affecting correctness on the in-tree doors:

  • N1 (nit) — RecordContextNoteKind's doc line (packages/spec/src/ai/record-context-tools.zod.ts, outside the diff) still says related_truncated is a cut "at the row cap"; it now also fires at limit. Follow-up card.
  • N2 (nit) — ADR D1 and point 14 say a door whose own page cap is below a parsed limit cuts there "and the cut is stated". The executor cannot see such a cut (it compares against plan.cap), and door.ts does not say what a door owes. The stdio door passes limit through, so nothing in the tree reaches it as read; the HTTP bridge's cap was not read. Follow-up card.
  • N3 (nit) — AiContextRelatedWhere is typed as the whole FilterCondition, wider than the admitted subset, so the type admits $not and the others that parse refuses. Accepted deviation.
  • N4 (nit) — the limit describe reads "(at most 20, the default)"; the default is the row cap, which is the same number, but the sentence reads as if 20 were limit's default value. Accepted deviation.
  • N5 (nit) — no test pins an orderBy on a registry-injected field (created_at), the likely order for "the latest rows". Whether the lint field map and the published definition both carry it was not established by reading. Follow-up card.

Implemented-by: claude/issue-37203-related-where-orderby-limit
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: aa76b901be
REWORK — L1, seat repo:objectstack#5: the two should-fix findings of contract record 7177225249 are fixed in this PR before landing; the rest of L1 reads clean.

  1. Shape: open draft against main; Fixes #37203 stands: the reverted triage row (7154563681), the where parity case and the doors' missing queryableFieldsOf are carried by 37203 跟进:get_record_context 无权的关联子对象改为省略、真实通道交出可查询字段,并补筛选排序的双通道比对 #37361, nested under ai_context: related lists filter, order and limit (where / orderBy / limit) with the render-service reader #37203, so merging still delivers the card as now scoped. l1-face CLEAN.
  2. Owed in this PR: S1 (the aiContextWhereFields walk stops at depth 32 while parse admits any nesting — bound the nesting at parse or drop the cap, pinned by a test) and S2 (an orderBy on a sortable: false field is judged nowhere and the stdio door's INVALID_SORT refuses the whole call — report it at validate and leave the section out at call time, pinned by a test; read the HTTP door too). The same reviewer reads the delta.
  3. Gates: check-runs at aa76b901be: 62 success, 12 expected skip, 0 failed, 0 pending; Lint & Repo Gates and TypeScript Type Check success. Changeset and the generated ai-context.mdx rows read against the diff: true.
  4. Accepted deviations: contract nits N3 (AiContextRelatedWhere type wider than parse) and N4 (the limit describe wording).
  5. Out of scope and where it went: N1 (related_truncated doc line), N2 (a door-side page cap the executor cannot see) and N5 (orderBy on a registry-injected field) go to 37203 跟进:get_record_context 无权的关联子对象改为省略、真实通道交出可查询字段,并补筛选排序的双通道比对 #37361 or a sibling follow-up; Studio controls stay with 记录 AI 问询 7:在 Studio 里编辑资料包(ai_context 表单与作者界面) #37143.
  6. Landing terms: ungoverned, default tier; Clause-②: yes with a published schema, so a same-head at-tier PASS with S1 and S2 closed is owed before the area lands it.

…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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: bb0107ccadaab70025c410545408414395527a26
Local-runs: none
Scope: packages/spec/src/ai/ai-context.zod.ts + packages/services/service-record-context/src/record-context-tools.ts, packages/services/service-record-context/src/door.ts, packages/lint/src/validate-ai-context.ts, packages/lint/src/rule-explanations.ts, packages/lint/src/index.ts

Delta review of the round on aa76b901be459a8271b412ad9fcb099024a7fb33. Inputs read: card #37203 with its comments, the delta report among them (7179036175); the PR body at this head; the delta aa76b901b..bb0107cca (13 files); the check-runs on this head (no failure; every required run success or skipped). Read to judge, not reviewed: packages/spec/src/api/sortability.zod.ts#resolveObjectSortability, packages/metadata-protocol/src/protocol-query-validation.ts (assertSortFieldsExist, assertSortFieldsAreOffered, UNMATERIALIZED_SORT_TYPES), packages/mcp/src/stdio-data-bridge.ts#unofferedSortRefusal, packages/spec/src/data/search-fields.ts#SEARCH_VIRTUAL_TYPES. The sections below judge the whole PR at this head; what the earlier round settled and the delta did not touch is carried.

① Derived judgments

  • Carried from the earlier round, unchanged by the delta: related[] widened by the optional where, orderBy and limit; where a strict subset of the object filter form; limit bounded by the one number AI_CONTEXT_MAX_RELATED_ROWS; the aliases and guidance.filter text; the additive door members; the unchanged read set. All right.
  • New in the delta: where refuses $and / $or nested more than AI_CONTEXT_WHERE_MAX_DEPTH (32) lists deep. It narrows only what the earlier head of this same PR admitted, which was never published. Right: ADR-0160 row 11 invites the bound, "refused at parse like the pack's other bounds".
  • New public export AI_CONTEXT_WHERE_MAX_DEPTH in @objectstack/spec/ai; api-surface and export-origins moved with it. Additive.
  • New lint rule id ai-context-sort-field-unsortable (a warning) and its exported constant AI_CONTEXT_SORT_FIELD_UNSORTABLE. It can fire only on a pack that carries orderBy, which no pack on main can. Right.
  • The executor now leaves out, silently and for every caller, a related section whose orderBy names a field the child's sortability projection calls unsortable. Before the delta both doors refused that call whole. Right: an author defect, treated as the "field the definition lacks" arm is.
  • @objectstack/lint and @objectstack/service-record-context now import resolveObjectSortability from @objectstack/spec/api. Both already depend on the spec package; type checks are green.

② Semver level

minor on @objectstack/spec, @objectstack/service-record-context and @objectstack/lint, unchanged and still right: the delta adds one export and one rule id and removes nothing published. The changeset body now states the nesting bound and the unsortable-order rule. Check Changeset is success.
Clause-②: yes. The line stands in the PR body and in the changeset body, with no arm.

③ Boundary flags

  • SQL push-down: holds. The delta adds no read: the sortability verdict is computed from the published definition the executor already holds, and an unsortable order skips the query.
  • open_questions: none in the delta report.
  • Dev flag, S2 covers a formula as well as sortable: false: answered and accepted, see ④.
  • Dev flag, packages/lint/src/index.ts and rule-explanations.ts join the touched files: answered, they are the rule's wiring and are in Scope above.
  • Dev flag, N1, N2 and N5 not taken, carried by 37203 跟进:get_record_context 无权的关联子对象改为省略、真实通道交出可查询字段,并补筛选排序的双通道比对 #37361: accepted as carried.
  • Dev flag, PR refactor(spec)!: rename the Studio helper defineForm to defineMetadataForm and its modules to *.metadata-form.ts #37366 conflicts in the generated packages/spec/export-origins/ai.json: the lane seat's; whichever lands second regenerates the file.
  • Dev flags on push order (a push not gated on its overlap check; a push before the whole lint package ran) and commit trailers: not contract matters; the lane seat's. CI on this head is green.
  • Still escalated to the seat from the earlier round, and not answered by this delta: (1) the card's stdio/HTTP parity line has no where-pack case and needs a card; (2) neither real door supplies queryableFieldsOf, so a caller the security answer excludes but the fallback admits still gets a whole-call refusal from the engine guard, and that door card needs a carrier; (3) the PR body says Fixes #37203 while triage row 7154563681 is unchecked and not in this PR, so the row needs its own card before the merge closes this one.

④ Design judgment

S1: closed
S2: closed

packages/spec/src/ai/ai-context.zod.ts. checkRelatedWhere carries a depth that counts the $and / $or lists a condition sits beneath, and refuses a list that would put a condition at depth 33. aiContextWhereFields walks conditions down to depth 32 by the same constant and skips only members at depth 33, which parse has already refused. Read side by side, the two walks agree at the boundary: every field of a where that parsed is listed. The test pins 32 accepted, with the innermost field named, and 33 refused; the report's ablation of the bound went red.

packages/services/service-record-context/src/record-context-tools.ts. An orderBy field with sortable === false in resolveObjectSortability(published definition) leaves the section out before the query, after the "definition lacks it" check and before the caller-specific check, so the answer is the same for every caller and states nothing. A where on such a field still reads, which is right: the doors' verdict is on the sort axis only.

The formula widening, against both doors' actual predicate. resolveObjectSortability answers sortable: false for two reasons: virtual-type (isVirtualSearchField, SEARCH_VIRTUAL_TYPES, today formula alone) and author-declared (the literal sortable: false). The stdio door refuses by that same function (unofferedSortRefusal: projection[f]?.sortable === false), so it refuses both reasons. The HTTP door refuses sortable: false by that same function (assertSortFieldsAreOffered) and a formula by UNMATERIALIZED_SORT_TYPES, today formula alone. So the executor's predicate is exactly what each door refuses, and the widening holds; judging sortable: false alone would have left a formula order refusing the whole call on both doors. No must-fix, no should-fix.

packages/lint/src/validate-ai-context.ts, rule-explanations.ts, index.ts. The rule reads the same projection as the executor and the doors, reports at related[i].orderBy[k].field, reports an unknown field as ai-context-field-unknown first and never both, and its message matches what the executor does. Its wiring matches its sibling ai-context-body-not-long-text site for site: the constant in validate-ai-context.ts, the re-export in index.ts, the explanation and its RULE_EXPLANATIONS entry. The explanation's covers length pin is green on this head.

Tried and not broken: a pack with both an unknown and an unsortable order field (left out by the first check); an order on id (the projection answers sortable); a where-only entry (no sortability read); a lint run over array-shaped or map-shaped fields (the projection's reader takes both).

Nits, none affecting correctness on the in-tree doors:

Implemented-by: claude/issue-37203-related-where-orderby-limit
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: bb0107ccadaab70025c410545408414395527a26
ACCEPT — L1, seat repo:objectstack#5

  1. Shape: open draft against main, 23 files, +1092/−52. Fixes #37203 stands. The reverted triage row (7154563681), the stdio/HTTP where parity case and the doors' missing queryableFieldsOf are carried by 37203 跟进:get_record_context 无权的关联子对象改为省略、真实通道交出可查询字段,并补筛选排序的双通道比对 #37361, nested under ai_context: related lists filter, order and limit (where / orderBy / limit) with the render-service reader #37203, so merging still delivers the card as now scoped.
  2. Rework closed (contract record 7179109796):
    • S1: AI_CONTEXT_WHERE_MAX_DEPTH (32) bounds nesting at parse, and aiContextWhereFields walks the same constant. The two agree at the boundary, pinned at 32 and 33.
    • S2: an unsortable orderBy leaves the section out silently, before the query, by resolveObjectSortability. The new lint rule ai-context-sort-field-unsortable is wired site for site like ai-context-body-not-long-text.
    • The declared widening to formula/virtual fields holds on both doors. stdio refuses by the same projection. HTTP refuses sortable: false by the projection and formula by UNMATERIALIZED_SORT_TYPES.
    • Three ablations, each red.
  3. Gates: check-runs at bb0107ccad: 62 success, 12 expected skip, 0 failed, 0 pending.
  4. Accepted deviations: the formula/virtual widening (above), and contract nits N3, N4 and N8.
  5. Out of scope and where it went:
  6. Landing terms: ungoverned, default tier, Clause-②: yes. L2 at CONTRACT_REVIEW_TIER: PASS, comment 7179109796, same head, no must-fix, no should-fix. The area lands it.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 26, 2026 00:49
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit da50177 Nov 26, 2026
75 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-37203-related-where-orderby-limit branch November 26, 2026 01:19
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
… can never offer (objectstack-ai#37382)

<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg8ZBQe4UHadd2fGHGeWRW9V)_

repo:objectstack#5 · os-bill · session_01Utp6CbdHk3orAeensH6EzS

Fixes objectstack-ai#36714
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up objectstack-ai#35769 (row 7178935378:
skills/objectstack-data/rules/relationships.md, the three lint refusals)

## 维护者速读
-
用户能看到什么变化:应用作者在命令行校验、构建或检查应用时,若关联字段声明了「变更负责人时连带转移」而这种转移永远不会发生(父对象不提供变更负责人、经对象扩展加到不支持它的对象上、或子对象的接口不允许更新),现在会直接报错并写明怎么改;最终用户无感,运行时行为不变。
- 为什么做:数据模型专区「声明了就要生效」的收尾,替变更负责人连带转移功能补上作者期的提醒。
- 出错会怎样:若判断有误,作者的应用会在命令行校验时被误拦,改字段或对象即可通过;不影响已部署的应用和工作室保存,可直接撤回。
- 要你做什么:无。

## What changes

A `transferBehavior: 'cascade'` that the Change Owner endpoint can never
offer used to parse silently (ADR-0049, declared but not enforced). One
new `@objectstack/lint` rule, `validateTransferCascades`, refuses each
of the card's three cases at `error`, with the fix in the hint:

| Rule id | Case | Verdict from (spec, `@objectstack/spec/data`) |
|:---|:---|:---|
| `transfer-cascade-parent-without-change-owner` | 1: the reference
points at a parent in the stack that does not offer Change Owner |
`resolveUserActionTransfer` + `transferIneligibilityReason` (what the
endpoint's `changeOwnerOffReason` asks) |
| `transfer-cascade-extension-child-ineligible` | 2: an
`objectExtensions[].fields` field cascades onto an object that cannot
take a cascade | `transferCascadeIneligibilityReason` (what
`refuseIneligibleTransferCascades` and `transferCascadeRelations` ask) |
| `transfer-cascade-child-update-unexposed` | 3: the child's `enable`
block does not serve `update` | `apiExposureDenialReason`
(`canServeApiOperation` is its boolean face, the exposure filter in
`transferCascadeRelations`) |

- `packages/lint/src/validate-transfer-cascades.ts`: the walk only.
Objects are judged as served (`objectsAsServed`, every extension field
folded in), since `transferCascadeRelations` reads the registered,
merged definitions. An object the stack does not declare is skipped on
either side. Only single-value `lookup` / `master_detail` fields are
judged; off-type, multi-value and `sys_`-parent cascades stay the field
parse's refusals and are not reported twice.
- Registered in `authoring-rules.ts`: `gating`, all three commands,
`surfaces: CLI_ONLY` with a `surfaceReason` (see Acceptance notes).
Exported from the barrel (rule ids included), and the three ids have `os
explain` entries in `rule-explanations.ts` (inserted, not reordered).
-
`packages/spec/src/migrations/entries/semantic/18.transfer-cascade-never-offered-refused.ts`:
the ADR-0087 ledger entry `check:adr-0087-registration` requires for a
`Metadata-protocol: narrowed` changeset. It is a data file, not a schema
change.
- Docs: one sentence in `content/docs/api/data-api.mdx` beside the
existing multi-value refusal, and the CLI transcripts' author-time rule
count 79 → 80 (`check:docs-transcript-drift`).
- Changeset: `@objectstack/lint` minor, `@objectstack/spec` minor (the
kind is `narrowed`).

Mechanism assumptions measured at `origin/main` 98bda0a before code: A1
holds (the predicates are exported from `@objectstack/spec/data`; lint
imports them the way `validate-managed-api-methods.ts` does, no third
copy). A2: `error`, following `validateManagedApiMethods` (a declaration
decidable from the stack that the runtime silently drops) and the
parse's own refusal of the declaring object's half. A3 holds
(`child.enable` through the exposure predicate). A4: the two
`validate-predicate-path-refs.test.ts` pins count form predicates, not
registry entries; nothing moved.

Files to read first, by risk:
1. `packages/lint/src/validate-transfer-cascades.ts` —
`validateTransferCascades`, the served-object lookup and the `sys_` /
not-declared skips.
2. `packages/lint/src/authoring-rules.ts` — the new entry's tier and
`surfaceReason`.
3.
`packages/spec/src/migrations/entries/semantic/18.transfer-cascade-never-offered-refused.ts`.

## Tests

`packages/lint/src/validate-transfer-cascades-36714.test.ts`: every
fixture is a full `ObjectSchema` / `ObjectExtensionSchema` parse, so
each refusal is one the parse lets through. Each case is refused with
its rule, severity, `where`, `path` and the reason fragment its message
names; each eligible shape passes (an eligible parent, a parent outside
the stack, a `sys_` parent, an eligible extension target, a target
outside the stack, `update` served); the `packages[]` artifact shape is
read; and the `fieldPatches` arm is pinned as refused by the schema.

<details><summary>Local runs at 3e1fa4a (lint, spec,
ablation)</summary>

- `pnpm --filter @objectstack/lint test`: Test Files 236 passed (236),
Tests 9648 passed, 5 skipped (VERDICT command-exit 0).
- `pnpm --filter @objectstack/lint typecheck`: VERDICT command-exit 0.
- `pnpm --filter @objectstack/spec test`: Test Files 894 passed, 1
skipped (895), Tests 28417 passed (VERDICT command-exit 0).
- `pnpm --filter @objectstack/cli exec vitest run
test/migrate-meta-engine-guidance.test.ts`: 3 passed.
- Ablation (rule committed first): `scripts/ablation-replace.mjs`
replaced the walk's `for (const site of cascadeSites(stack))` with an
empty loop, x0 -> x1 on disk; the card's test file went 15 failed, 9
passed (24). Every refusal case red, every pass case green. Restored:
blob == HEAD, `git diff HEAD` empty.

</details>

## Acceptance notes

- The `Clause-②:` line carries the `(narrowing)` arm (body and
changeset, commit 8737482): Check Changeset reads `Metadata-protocol:
narrowed` beside a clause line without the arm as a contradiction. The
claim's `Clause-②: no` was copied first, at 3e1fa4a.
- Premise, partly narrower than written: case 2's `fieldPatches` arm
cannot occur. A field patch carries display properties only (`label`,
`description`, `inlineHelpText`, `placeholder`), and
`ObjectExtensionSchema` refuses `transferBehavior` there as an
unrecognized key, so the rule walks extension `fields` only; a test pins
the refusal.
- Not on the runtime publish gate yet (`surfaces: CLI_ONLY`): the door's
objects are served definitions carrying the injected `owner_id` as a
declared field, which the eligibility predicate reads (its `readonly`,
and on an external object whether it is declared). Crossing owes that
measurement or a read-back to the authored shape, as
`lintDuplicateFieldLabels` does. Until then a Studio or MCP save of
these shapes still passes. The runtime stays safe.
- Boundary: a cascade on a field an object declares itself, where only
an extension makes the served object ineligible, is not reported as case
2 (the card scopes case 2 to extension fields; the object's own half is
the parse's).
- File surface: the ADR-0087 ledger entry under
`packages/spec/src/migrations/entries/semantic/` is outside the claim's
listed surface. `check:adr-0087-registration` requires it for
`narrowed`; it changes no schema and no runtime.
- First-party exposure: zero. No example app, platform object, skill or
docs sample declares a cascade.
- Other open PRs that add an author-time rule (objectstack-ai#37354, objectstack-ai#37371) move the
same transcript count; whichever lands second gets a one-number docs
conflict or a `check:docs-transcript-drift` red.

## Verification

Two-minute check: `pnpm --filter @objectstack/lint exec vitest run
src/validate-transfer-cascades-36714.test.ts` prints 24 passed.

<details><summary>Gates: local derivation and reconciliation</summary>

`node scripts/pm/dispatch-gates.mjs --ran` at 3e1fa4a: 117 derived, 113
run, 4 NOT-MEASURED, 0 UNRUN. All 113 run exited 0. NOT-MEASURED, left
to CI:
- `check:type-check-debt`: the 300 s local timeout fired (repo-wide tsc
census).
- `check-plugin-teardown-shape.mjs --self-test`: shallow checkout.
- `spec check:skill-examples`: its client SDK surface reads
`packages/client-react` dist, not built locally.
- `check:dual-build-cjs-loads`: reads every workspace dist.

Outside the derivation, local-only: `check:dev-prereqs` exit 1, because
104 of 110 workspace packages are unbuilt in this container (machine
state, not this diff).

</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CbdHk3orAeensH6EzS -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…he record-context docs name both mounts (objectstack-ai#37409)

<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgXTK3Lp9k96oinCGTRnfrNo)_

Fixes objectstack-ai#37177

Clause-②: no
Metadata-protocol: none

## 维护者速读
- 用户能看到什么变化:替客户写应用的 AI
助手,现在能从随产品发布的技能文档里学会怎样写「资料包」,也就是挑出一条记录的哪些字段、关联列表和正文交给 AI;产品本身的行为没有变化。
- 为什么做:属于「在一条记录上问 AI」专题;资料包这个新的元数据类型此前在技能文档里只有一个名字,作者无从下笔。
- 出错会怎样:最坏是技能文档某句话教错,AI 写出的资料包被校验拒收或读到的内容比预期少;已有应用不受影响,撤回即可恢复。
- 要你做什么:批准这次技能文件改动(受管文件,需要你批准后才能合入)。

## What changes

**New reference `skills/objectstack-ai/references/context-packs.md`**
(111 lines, 1454 tokens). It teaches authoring an `ai_context` pack from
what `main` at `9ffe37153` enforces:
- the six pack keys and the six keys of a `related` entry, with their
bounds (30 fields, 3 related lists, 10 columns, `limit` 1 to 20), and
that an unknown key or a pack over a bound is refused at parse;
- a related list's `where` / `orderBy` / `limit` (objectstack-ai#37354): the admitted
operators, literal comparands only, `order` not `direction`;
- when to use fields, a related list or the body, and how the body is
carried (whole up to 8,000 characters, else an outline with anchors,
else cut and marked);
- serving and calling: `requires: ['record-context']` or a `plugins`
mount (objectstack-ai#37303), the call's four arguments, the answer's three parts;
- pack identity (objectstack-ai#37291): package and name, one pack per name in a
namespace (`422 NAMESPACE_CONFLICT`), `context` takes the face
`NAMESPACE-NAME`, a bare name two packages hold is refused `409
RESOURCE_CONFLICT`, and the `/meta/ai_context/NAME` read needs
`?package=` for such a name;
- what the caller is not shown, and the five `os validate` rules that
report an author's mistake the tool keeps silent about.

**Pointers in the two SKILL.md files, paid by deleting restatement in
the same file.** Neither SKILL.md ceiling row moves.
- `skills/objectstack-ai/SKILL.md`: a five-line "Context packs" section,
a `get_record_context` row in the MCP tools table, and the frontmatter
description and tags name the context pack.
- `skills/objectstack-platform/SKILL.md`: the `requires` token row says
what `record-context` serves and links the reference; the ADR-0150 list
of names "identified by package and name" gains context packs.

**N1 and N2 of scope note 7166997849 (prose only).**
- N1: the `aiContexts` `.describe()` and its TSDoc in
`packages/spec/src/stack.zod.ts` no longer read the token as the only
serving condition. They name both mounts: the CLI mounts the service
where `requires` includes `record-context`, and a host that composes its
own kernel lists `RecordContextServicePlugin` in `plugins`. Regenerated
mirror: `content/docs/references/api/package-api-assembled.mdx`.
- N2: `packages/services/service-record-context/README.md` and the
`RecordContextServicePlugin` docblock teach the token beside the
`plugins[]` mount.
- Patch changeset for `@objectstack/spec` and
`@objectstack/service-record-context`.

**Eval case 11** in
`skills/objectstack-ai/evals/skills-tools-knowledge.json`: the card's
prompt ("give the AI a customer's open opportunities and notes").

**One new ratchet row** in `scripts/check-skills-token-ratchet.mjs` for
the new reference, pinned at the measurement (5813 bytes, `ceil(5813 /
4) = 1454`, zero headroom). It is the seat's claim amendment 2 on the
card, comment 7179788843: "one new row in check-skills-token-ratchet.mjs
for the new references/context-packs.md, pinned at the measured size".

Container & model: `M`, `mode:thread`, `model: CONTRACT_REVIEW_TIER
(MANDATORY for skills/**, served at tier; claim amendment 7179771295)`,
`effort: high`

### Skills readings (base `9ffe37153`, head `e9b2056f`)

| File | Lines | Tokens (`ceil(bytes / 4)`, the ratchet's count) |
|:--|:--|:--|
| `skills/objectstack-ai/SKILL.md` | 485 to 487 | 6787 to 6798 (ceiling
6801, unchanged) |
| `skills/objectstack-platform/SKILL.md` | 422 to 422 | 6149 to 6149
(ceiling 6149, unchanged) |
| `skills/objectstack-ai/references/context-packs.md` | 0 to 111 | 0 to
1454 (new row 1454) |
| `skills/objectstack-ai/evals/skills-tools-knowledge.json` | 105 to 115
| 2668 to 2997 (eval fixture, not ratcheted) |
| All `SKILL.md` files together | 4959 to 4961 | |
| Whole `skills/` tree | 23130 to 23253 | ratcheted authored 198131 to
199596; bundle total 297515 to 299309 |

### What was deleted to pay for the pointers, and where each fact still
lives

The discipline is the standing ruling of record 6513306068, quoted
verbatim: 「A:先削重复,余额按实测提高」. Only its first half is used here:
restatement is cut, and no SKILL.md row is raised.

`skills/objectstack-ai/SKILL.md` (+11 tokens net, inside the 14 of
headroom it had):
1. The `Agent → Skill → Tool` diagram. Still taught: a skill's `tools`
row ("Tool names this skill grants"), "An agent's tool set is the union
of its surface-compatible skills' tools" (Platform agents), and the
three captions by the Skill Configuration table, the Actions dispatch
table and the Platform agents section.
2. "You usually don't author tool definitions by hand for action
invocation." Still taught by that section's own heading ("the default
path"), ladder rung 3, and "Default: declare no tool records" (Tool
metadata).
3. The Verify block's `# or: os build` comment line. Still taught in
`skills/objectstack-platform/references/operations.md` ("os build # the
same three gates, plus emits dist/objectstack.json"), which the section
points to. This home is in another file.
4. The Knowledge example's `// or 'memory' for dev/test` comment. Still
taught by the Wiring paragraph above it.

`skills/objectstack-platform/SKILL.md` (net 0):
1. "Embed any domain prefix directly in the name (e.g. `name:
'crm_account'`)". Still taught by the next two paragraphs
(`manifest.namespace`: every `object.name` must start with `crm_`;
"Which names carry the namespace").
2. "(one `task.object.ts` per object)". Still taught by the Naming
Conventions row (`{name}.{type}.ts`, `task.object.ts`).
3. "handed to the stack key of its name" on the barrel sentence. Still
taught by The Template's barrel bullet.

## Tests

<details><summary>Example validity (card What 3)</summary>

- The reference's `os:check` block parsed with the built
`AiContextSchema`: `parse success: true`. Seven controls on the same
pack were each refused: `limit: 21`, a `description` key, a `$contains`
operator, 4 related lists, 31 fields, 11 related columns, `direction` in
`orderBy`.
- `os validate` on a scratch stack (objects `account` and `opportunity`,
the block's pack, `requires: ['record-context']`): `Validation passed`,
exit 0, no `ai-context-*` warning. Control on the same stack with a
`where` field the child lacks and a `body.field` that is not long text:
`ai-context-field-unknown` at `aiContexts[0].related[0].where` and
`ai-context-body-not-long-text` at `aiContexts[0].body.field`. The
scratch stack was deleted.
- `pnpm --filter @objectstack/spec run check:skill-examples`: `352 prose
examples type-check across 3 surface(s)`, exit 0.
</details>

<details><summary>Eval case 11, graded with `gradeAnswer`
(packages/qa/scenarios/src/skill-evals/grade.ts)</summary>

- A reference answer (an `aiContexts` entry with the related
`opportunity` list filtered by `stage`, `body: { field: 'notes' }`,
`requires: ['record-context']`):
`{"pass":true,"missing":[],"forbidden":[]}`.
- Control, the wrong shape (an object-level `aiReadable`, a top-level
`filter:`, `direction:`):
`{"pass":false,"missing":["opportunity","related","where","body","notes","record-context"],"forbidden":["filter:","direction:","aiReadable"]}`.
</details>

<details open><summary>Eval case 11, run against a model (seat L1 item
S1, record 7181297604)</summary>

One round of the repository's runner on head `e9b2056f`: `pnpm --filter
@objectstack/scenarios skill-evals --skills objectstack-ai --concurrency
4` (the runner selects by bundle, not by case, so all 11 cases ran; 22
of 22 turns, each case once with the bundle installed and once without;
subscription login, no API key; the served model is in the round's run
records and is not written here, repository rule).

- **Case 11, with the skill: `pass`**, `missing: []`, `forbidden: []`.
The turn launched `objectstack-ai` and read
`objectstack-ai/references/context-packs.md`.
- **Case 11, without the skill: `fail`**, `missing:
["related","where","body"]`, `forbidden: ["filter:"]`. The no-skill
answer reached for a top-level `filter:`, which is the mistake the case
forbids.
- The pack in the with-skill answer, as the model wrote it:

```typescript
export const AccountBrief: AiContext = {
  name: 'account_brief',
  label: 'Customer brief: open opportunities and notes',
  object: 'account',
  fields: ['name'],
  related: [
    {
      object: 'opportunity',
      field: 'account',
      fields: ['name', 'stage'],
      where: { stage: { $nin: ['closed_won', 'closed_lost'] } },
      limit: 20,
    },
  ],
  body: { field: 'notes' },
};
```

- The same answer adds `requires: ['record-context']` on the stack and
says that without it nothing serves `get_record_context`.
- That literal through `AiContextSchema.safeParse` on this head: `model
answer pack parse success: true`. Not measured: `os validate` on it (the
answer names no object definitions to validate against).
- **The other ten cases, same round:** with the skill 9 of 11 pass,
without it 0 of 11. Cases 5 and 6 fail with the skill (missing
`aiExposed`; missing `signed-in session`). The same round on the base
text (`skills/objectstack-ai` as of `9ffe37153`, 10 cases, 20 of 20
turns): 8 of 10 with the skill, and the same two cases fail (5 missing
`skills`, `aiExposed`; 6 missing `signed-in session`, `refused`). Both
cases are red before this diff, on sentences this diff does not touch;
they are not fixed here.
- One repeat per arm, so each figure is one draw, not a rate.
</details>

<details><summary>Packages and gates (local, head `e9b2056f` unless a
line says otherwise)</summary>

- `pnpm --filter @objectstack/spec test`: `Test Files 896 passed (896)`,
`Tests 28442 passed | 1 todo`; the lock's line `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/service-record-context typecheck`, its
`test` (`Test Files 2 passed`, `Tests 99 passed`) and `pnpm --filter
@objectstack/spec typecheck`: one locked run, `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/spec check:generated`: 2 of 14 stale
(skill docs, `content/docs/references/**`); `--fix` regenerated those
two and both then checked clean.
- `node scripts/check-skills-token-ratchet.mjs`: exit 0, `61 authored
bundle file(s) within their ceilings`; its `--self-test`: `104 cases
pass`.
- Derived families (`node scripts/pm/dispatch-gates.mjs --commands`):
138. Reconciliation at `e9b2056f`: `138 derived, 137 run`, and the
138th, `pnpm check:pm-dispatch-gates`, was run on its own afterwards:
exit 0.
- 133 commands exited 0 on `f3cbf52a`. The last commit changed only
`skills/objectstack-platform/SKILL.md`, and the eleven gates that read
the skills were re-run on `e9b2056f`: all exit 0.
- `pnpm check:skill-top-level-keys` exited 1 on `f3cbf52a`: its
self-test pins the sentence "the top level refuses it and the stack
fails to load" in the platform skill, which I had cut as restatement.
`e9b2056f` restores the sentence and pays with a different cut. Exit 0
on `e9b2056f`.
- `pnpm --filter @objectstack/spec run check:skill-examples` exited 3
first (`PREREQUISITE NOT MET`, `packages/client-react/dist` not built),
and 0 after that package was built.
- NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs
--self-test`, reason: exit 3, the shallow clone cannot reach the commit
its fixture is pinned to. NOT MEASURED: `pnpm
check:dual-build-cjs-loads`, reason: exit 3, some packages have no
`dist/` here (only the CLI and client closures were built). CI runs
both.
- `test:repo` and the repo-wide lint were not run locally; they are CI's
(`Test Core`, `Lint & Repo Gates`).
</details>

No ablation: the diff changes documentation, one ratchet row and one
eval fixture, and no behaviour a test pins.

## Acceptance notes
- **Size.** The reference is 1454 tokens. My estimate to the seat before
writing was 600 to 800. The file holds a whole metadata kind (two key
tables, the body, serving, pack identity, the validate rules), and I did
not find a smaller form that keeps every item the card and its three
scope notes ask for.
- **N1 and the hosted kernel.** Scope note N1 says the hosted kernel
does not serve the tool yet. That lives in another repository, which I
cannot read from here, so no sentence states it. The new text says what
`main` does: a host without the service serves no such tool.
- **A related object the caller cannot read.** The reference teaches
what `main` does today: the whole call is refused `403
PERMISSION_DENIED` (`record-context-tools.ts`, step 4a). ADR-0160 D3 as
amended says such a child is left out and stated. The PR that lands the
amendment owes this reference one sentence.
- **Not taught, because `main` does not have it:** a skill's `context`
key (ADR-0160 D8; `SkillSchema` has no such key, though the pack `name`
description in `ai-context.zod.ts` already mentions it), and the total
bound on long-text cells of a related list (ADR-0160 D3, amended
2026-11-25; the service bounds only the body).
- **Possible defect, not fixed here.** `os validate` reported
`ai-context-field-unknown` for `owner_id` in a pack's `fields` on an
object that does not declare `owner_id` itself (the platform adds it).
Measured: the warning, on the scratch stack above. Not measured: whether
`get_record_context` carries the field at run time. The example avoids
the field. Reported to the seat in the dev report.
- `content/docs/ai/skills-reference.mdx` is regenerated from the changed
frontmatter (`gen:skill-docs`), not hand-edited.
- The model identifier is not written in this body (repository rule);
the tier is named by its word.

## Verification
Two-minute check: `node scripts/check-skills-token-ratchet.mjs`. Expect
`61 authored bundle file(s) within their ceilings`, with
`context-packs.md 1454 / 1454`, `objectstack-ai/SKILL.md 6798 / 6801`
and `objectstack-platform/SKILL.md 6149 / 6149`.

Read first: (1) `skills/objectstack-ai/references/context-packs.md`
against `packages/spec/src/ai/ai-context.zod.ts` and
`packages/services/service-record-context/src/record-context-tools.ts`;
the risky part is the section "What the caller is not shown". (2) The
deletions listed above, in the two SKILL.md diffs. (3)
`packages/spec/src/stack.zod.ts`, the `aiContexts` description.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CaWzgwG1QYaiBidBCK)_

<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CaWzgwG1QYaiBidBCK -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…outline in pages (outlineFrom / outlineNext) (objectstack-ai#37484)

Fixes objectstack-ai#37233

Clause-②: yes (widening)
Metadata-protocol: added

## 维护者速读

- 用户能看到什么变化:外接 AI
读一条正文很长的记录时,目录超过一页上限的部分可以分页继续列出,每个章节都能读到;此前如果几百个标题都在同一层,第 80 个之后的章节 AI
根本读不到。
- 为什么做:记录级 AI 问答专题(资料包读取工具)的后续收尾,补上目录截断后剩余章节无法到达的缺口,并改正一句会误导 AI 的截断提示。
- 出错会怎样:最坏是 AI 读长文时多翻一页或少列几个标题,读到的内容仍受原有长度上限和权限约束;可以直接撤回本次改动。
- 要你做的:无。

## What changes

ADR-0160 D3 "The body"; L1 ACCEPT 7153812992 on PR objectstack-ai#37222, nit N2 (this
card), N3, N4.

- **The outline comes in pages** (`boundedOutline(headings, from)`,
`body-outline.ts`). The pages run through every heading in ONE order —
shallowest level first, body order within a level — and a page takes
that order from `from` until the next heading would pass either existing
bound (80 entries, 8,000 serialized characters); each page lists its
headings in body order. Page 1 is today's outline, bar the N3 case
below. Every heading is on exactly one page, so following the
continuation from page 1 lists every heading with the anchor
`headingsOf` gives it. One mechanism serves both cuts: a flat body's
pages are runs of it in body order; a nested body's first page is its
top levels and later pages carry the deeper headings (which matters too:
a top section past the body bound is itself cut, so its sub-headings
past the cut were unreachable before as well).
- **Input `outlineFrom`, output `body.outlineNext`**
(`record-context-tools.zod.ts`). `outlineNext` is present only when a
heading remains that a later page lists; pass it as `outlineFrom`.
`outlineFrom` 0 is page 1. An `outlineFrom` past the last page, or on a
body that is no outline (carried whole, absent from the pack, withheld
from the caller), is ONE answer, `RESOURCE_NOT_FOUND` 404, as an
unresolved `anchor` is. `anchor` with `outlineFrom` is refused
`VALIDATION_ERROR` 400 at step 1, before any read.
- **The `outline_truncated` sentence, en and zh-Hans** (`sentences.ts`),
now says how many headings this page lists, how many it does not, that
pages run shallowest levels first then body order, and the `outlineFrom`
that lists the next page (or that no later page lists more). The clause
"A listed section's text includes the headings under it" is gone: in a
flat cut nothing left out sits under a listed section. The sentence
carries numbers only, never an anchor (an anchor is record text, and a
note never carries record text) — which is why the cursor is a position
and not an anchor.
- **N3, revisited because the paging made it cheap.** A heading whose
entry alone passes the character bound fits no page. Without a change it
would end the pages (the page that must start with it lists nothing), so
the pages now pass over it and the note counts it ("1 heading is too
long for any page to list, so its anchor is not given" / "K headings are
too long ..."). As a side effect one such heading no longer empties page
1. A body whose ONLY headings are such headings is still carried to the
bound and marked truncated, as before. Trade-off stated: such a heading
(about 3,950 characters or more of heading text) gets no anchor; in a
nested body its text is still inside its parent's section.
- **N4**: no change needed (the changeset it named has merged).
- Tool description: names `outlineNext` / `outlineFrom` beside `anchor`.
- **The `body_outline` note, en and zh-Hans, on every page** now says to
read a section with the same objectName, recordId and context, plus the
anchor and no `outlineFrom`. Before, it said "the same arguments", and
on a page reached through `outlineFrom` those arguments plus an anchor
are the pair this PR refuses (review S1).
- The MCP doors needed no code: both pass the input through whole, and
the `/mcp` door's registration validates against the spec's
`GetRecordContextInputSchema`, so the key is admitted there by the spec
change alone. The real-kernel parity cases below prove both doors carry
it.

### Design, and the alternative weighed

Continuation (chosen) vs listing every omitted heading's anchor
compactly: a compact list is still O(headings) in one answer, so for a
large enough body it passes the same bound and needs a cut of its own;
the continuation keeps every answer within the existing bounds however
big the body, with one mechanism for flat and nested cuts. Cursor: a
position in the page order, not an anchor, because the note that tells
the model where to continue may not carry record text, and an anchor is
derived from heading text.

### Declaration

`Metadata-protocol: added`, `@objectstack/spec` graded `minor` (PM
ruling, option A, on this PR's open question): the spec's
authorable-surface ledger records `GetRecordContextInput:outlineFrom`
and `RecordContextBody:outlineNext` as entered keys, and Check Changeset
reads that shard as a metadata-protocol addition (precedent: objectstack-ai#37140,
objectstack-ai#37354). `@objectstack/service-record-context` stays `patch`.

### ADR text this will need (governed, not edited here)

- D4 "Definition", the input line `{ objectName: string, recordId:
string, context?: string, anchor?: string }` gains `outlineFrom?:
integer` (the output's body gains `outlineNext`).
- D3 "The body", the sentence "A longer body is carried as an outline:
its headings in order, each with an `anchor`." needs: an outline past
its bounds comes in pages, continued by `outlineFrom`, every heading
listed on one page (bar a heading too long to list by itself, stated).
Carried by objectstack-ai#37490, which should also say that the cursor is a position
in the current body, so "exactly one page" holds for one state of the
body.

## Tests

See Verification for the commands and readings.

- `body-outline.test.ts`: a flat body of 300 headings pages as
80/80/80/60 and the pages together are exactly the body's headings in
order; a nested body's page 1 holds every top heading and later pages
only deeper ones, each page in body order, union = all headings, no
duplicates; the character bound before the entry cap; an over-long
shallowest heading is on no page, counted, and does not empty page 1.
- `record-context-tools.test.ts` (executor): **the acceptance pin** — a
body of 300 headings at one level, every page walked by the
`outlineNext` the tool gave, all 300 anchors issued once, every section
read by its issued anchor and equal to its text, every answer parsing
against `GetRecordContextOutputSchema` and within the bounds; the nested
cut whose top section is itself cut; the `outline_truncated` sentence
for a flat cut AND a nested cut in en AND zh-Hans (counts, `outlineFrom
N`, no record text, the old clause absent); the last page; `outlineFrom:
0`; the one 404 answer (past the end / body whole / no body / withheld
body); `anchor` + `outlineFrom` refused before any read; negative /
fractional / string refused at parse.
- `record-context-tools.zod.test.ts` (spec, new): admits and refuses
`outlineFrom` and `outlineNext`, asserting zod's issue code and path;
the JSON Schema projection carries `outlineFrom` as an integer of at
least 0.
- `mcp-record-context-tools-bridge.test.ts` (runtime, real kernel): page
2 over both doors, byte-equal, starts at `clause-(N+1)` (a door that
dropped the key would answer page 1), and its anchor reads its section;
`outlineFrom` on a body carried whole is the same coded 404 on both
doors.
- `mcp-record-context-tools.test.ts`: the registration's input property
list gains `outlineFrom`.

## Acceptance notes

- Acceptance bullet 1 (300 same-level headings, every section reached by
issued anchors, each answer bounded): pinned in
`record-context-tools.test.ts`, "a body of 300 headings at one level".
- Acceptance bullet 2 (the note sentence true for nested and flat cuts,
both pinned): "the cut note is true for a flat cut and for a nested cut,
in en and zh-Hans".
- Re-reading `outlineFrom` against a body edited between calls simply
answers the page at that position of the current body; anchors on it are
the current body's, so nothing stale is served.

## Verification

Read first (by risk):
`packages/services/service-record-context/src/body-outline.ts`
(`boundedOutline`: the skip of an unlistable heading and where `next` is
set), `src/record-context-tools.ts` (the body block: the one 404 for an
outline page that does not start where asked), `src/sentences.ts`
(`outlineTruncated`).

Two-minute check: `pnpm --filter @objectstack/service-record-context
exec vitest run --maxWorkers=2
src/__tests__/record-context-tools.test.ts -t "300 headings"` — one test
passes; it walks four pages and reads 300 sections.

All readings at head `5f6f72fd82540c66a716be2a3a874bbd89e58bbd`.

<details><summary>Suites of every touched package (under the verify
lock: VERDICT command-exit 0)</summary>

- Build of the three closures exit 0; `pnpm --filter @objectstack/spec
check:generated`: all 14 generated artifacts up to date.
- `@objectstack/service-record-context` test: Test Files 4 passed (4),
Tests 139 passed (139); typecheck exit 0.
- `@objectstack/mcp` test: Test Files 85 passed (85), Tests 1521 passed
(1521); typecheck exit 0.
- `@objectstack/runtime` test (`--project local`): Test Files 649 passed
(649), Tests 12061 passed, 25 skipped (12086); typecheck exit 0.
- `@objectstack/spec` test: Test Files 899 passed (899), Tests 28494
passed, 1 todo (28495); typecheck exit 0.

</details>

<details><summary>Derived gate families (dispatch-gates --commands,
111)</summary>

- 109 exit 0 (11 of them re-run after the build, having first refused
with no built output to read).
- NOT MEASURED, `check:skill-examples` and `check:dual-build-cjs-loads`:
PREREQUISITE NOT MET, they read built output of packages this diff does
not touch. CI's Lint and Repo Gates measures both.

</details>

<details><summary>Review S1 pin, and the ablation of the first
round</summary>

- S1: "a section listed on page 2 is read exactly as that page's
body_outline note says" reads page 2's first anchor with the record's
arguments, the anchor and no `outlineFrom` (en and zh-Hans), and gets
the section. The control, page 2's arguments plus the anchor, is refused
`VALIDATION_ERROR` 400.
- Ablation (first round, unchanged code path): `for (let at = from; ...`
replaced by `for (let at = 0; ...` in `boundedOutline` turned the
300-heading acceptance pin red (24080 anchors issued, not 300), along
with three other executor pins; restored blob equals HEAD.

</details>

---

_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc)_

<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CbeF2saT6wUBV4E9uc -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…rt door reads the sortability projection's computed-type predicate (objectstack-ai#37785)

<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DLCo5F2y7fgbM8tstGoyyUn)_

Fixes objectstack-ai#37386

Refs objectstack-ai#37486

Clause-②: no
Metadata-protocol: none

## 维护者速读

-
用户无感:这次做三件事,一是把架构记录里几处已经上线、文字却没跟上的细节补齐,二是让数据接口和列表的排序提示在「哪类字段没法排序」上读同一份判断,三是按你在另一张决策卡上选定的方案,把「确有资料被隐藏时才提示」这条约定先写进架构记录;今天每个请求的结果都和原来一样。
- 为什么做:属于「记录范围的 AI
问询」专题的收尾;记录停在旧说法,后面施工和审阅的人会按过时的约定做事,而两份各管各的判断,以后新增一种计算字段时就会对不上。
-
出错会怎样:最坏是某种字段的排序被数据接口错拒或错放,调用接口的开发者会看到排序报错;新写进记录的那条约定要等后续的修复合入才生效,知道资料包里列了哪些对象的人看到提示就能确定确有其物,这正是你选定的取舍;撤回这一次合并就恢复原状。
- 要你做什么:这是受管的架构记录修订,需要你审阅批准后才能合并。

## What changes

Four files, +170 / −48, in three parts: two under this card, and one
sentence for the card the `Refs` line names.

**1. ADR-0160, fifth amendment** —
`docs/adr/0160-record-scoped-ai-inquiry.md` (+12 / −6 of the file's +17
/ −7). The amendment writes down what `main` does in the places the card
lists, and says in words that it rests on no ruling of its own. Every
sentence was read against the tree on `main` at `7e638ba7`. The
behaviours marked *measured* were run through the executor and the input
schema in a throwaway probe that was deleted and never committed.

- **Status line and amendment log.** The status line names the third
amendment date. The `Amended` list gains a fifth entry that names this
card, PR objectstack-ai#37354 (which built row 11) and the review record of the fourth
amendment's PR (7194836142, nits N1–N3), then the four things recorded.
- **D1, "Author defects are reported on author surfaces" (card item 1,
N6).** One new sentence group: an `orderBy` that names a field the child
has and does not offer as a sort is an author defect. It names the
projection that answers the question (`resolveObjectSortability`), what
that is on `main` today (a `formula` field, or a field whose author
declared `sortable: false`), the rule id
`ai-context-sort-field-unsortable` with its symbol anchor, and why the
tool judges the field before the query: both MCP doors refuse an order
by such a field with `INVALID_SORT`, which would refuse the whole call.
- **Point 20** gains an in-place note, in the form the record already
uses for a settlement: where the judgement sits (after a field the
definition lacks, before the caller's own fields, so every caller gets
one answer), that PR objectstack-ai#37354 settled it, and the two alternatives not
taken.
- **D4 "Definition", the input row (card item 3 and N1).** "with the
record tools' aliases for the first two" is replaced by what the schema
holds: seven aliases (`object` and `table` for `objectName`; `id` and
`record_id` for `recordId`; `pack` and `contextName` for `context`;
`section` for `anchor`). The row now also says what an alias is: it is
**not accepted**. The input is strict, so a call that uses one is
refused at parse like any unknown key, and the refusal names the
declared key (*measured* for each of the seven). `outlineFrom` is stated
as an integer, 0 or more (*measured*: `-1` and `1.5` refused at parse,
`0` accepted).
- **D3 "Outline pages", "A page that does not exist" (N3).** The reasons
behind the one `RESOURCE_NOT_FOUND` gain: a pack whose `body` names a
field that is not a long-text field, or that the root does not have
(*measured*: both get the same 404 as a position past the end).
- **Point 24 (N2)** names its one exception: a heading whose entry alone
passes the body bound is listed on no page and issued no anchor, and the
cut statement counts it. A body whose headings are all that long has no
outline to cut (*measured*).

Nothing else in the record changes under the fifth amendment.

**2. The Data API's sort door reads the projection's predicate (card
item 2, N7)** —
`packages/metadata-protocol/src/protocol-query-validation.ts` (+21 /
−41), one new test file (+118), one changeset (+14).

- The third verdict of `assertSortFieldsExist` (a real field whose type
has no column to order by) judged the type by a module-local set,
`UNMATERIALIZED_SORT_TYPES`, `formula` alone. It now calls
`isVirtualSearchField` from `@objectstack/spec/data`: the predicate
`resolveObjectSortability` reads for `reason: 'virtual-type'`, and the
one this file's filter and search axes already read. The local set and
its docblock are removed; a comment at the call site says where the one
source is and why it is the storage fact and not the write contract
(`COMPUTED_VALUE_TYPES`).
- No file under `packages/spec/src/**` is edited. Nothing changes for a
caller today: both sets held `formula` and nothing else.
- What changes is the day a computed type is added: it is added in the
spec's `SEARCH_VIRTUAL_TYPES`, and the door, the projection, the list
header and the Sort picker follow together.
- `protocol.sort-door-projection-agreement-37386.test.ts` copies no
verdict table. For every member of the spec's `FieldType` it asks the
projection and holds the door to that answer (99 cases).
- Changeset `37386-sort-door-reads-projection-predicate.md`:
`@objectstack/metadata-protocol` patch.

**3. ADR-0160, sixth amendment** — the same file (+5 / −1, commit
`06b567e5`). It rests on the maintainer's ruling recorded in comment
7208943876 on the card the `Refs` line names (option B of decision
analysis 7207825366), and it comes before the code: the PR that builds
it stays a draft at `cb1a47e9` until this text is accepted.

- **D3 "Object level", the bullet "A `related` child that this caller is
not served is left out."** The sentence "Nothing of the child is read,
its definition included." is replaced by:

> Nothing of the child is read except its published definition, which is
asked once, for whether the stack defines the object at all (sixth
amendment, 2026-11-27): a name the published definitions lack is an
author defect ([D1](#d1)), left out with no statement for every caller.
The published definition is the same for every caller, so whether the
statement fires depends on this caller's served schema alone, and
nothing of the definition is carried. The statement therefore now means
that something the stack defines is hidden from this caller, so a caller
who knows the pack's names can infer that such an object exists. That is
the trade the field-level rule below already makes for fields, where the
statement fires only for an entry the published definition has.

The first two sentences are the draft in os-dev report 7207298690. The
last two name the signal in plain words, as execution item 1 of the
ruling asks.
- **Amendment log.** A sixth `Amended` entry quotes the ruled option
verbatim, names the building PR and its head, says that the text comes
before the code and what `main` does until then, and records the two
things above. It also says the record tools are not changed: a name the
caller typed is still answered alike whether the object is hidden or
does not exist.
- The fifth entry still says it rests on no ruling of its own; that
stays true of the fifth. Every other sentence of the record stands.

## Tests

Head `06b567e5`. Its one commit after `40e60883` edits the ADR alone, so
the package's source and tests are byte-identical to `40e60883`, where
the commands below ran. Every heavy command ran under the shared verify
lock; the result quoted is the lock's own `VERDICT command-exit` line.

- Dependency closure: `pnpm --workspace-concurrency=2 --filter
'@objectstack/metadata-protocol^...' build` → `VERDICT command-exit 0`.
- The new file, on `40e60883`: `pnpm --filter
@objectstack/metadata-protocol exec vitest run --maxWorkers=2
src/protocol.sort-door-projection-agreement-37386.test.ts` → `Test Files
1 passed (1)`, `Tests 99 passed (99)`, `VERDICT command-exit 0`.
- The package, on `40e60883`: `pnpm --filter
@objectstack/metadata-protocol test` → `Test Files 372 passed | 9
skipped (381)`, `Tests 23549 passed | 45 skipped (23594)`, `VERDICT
command-exit 0`.
- `pnpm --filter @objectstack/metadata-protocol typecheck`, on
`40e60883` → `VERDICT command-exit 0`. The package's `tsc --noEmit
--listFiles` lists the new test file, so the typecheck covers it.

**Ablation** (the fix committed first; `scripts/ablation-replace.mjs`;
each restore proved by blob equal to `HEAD` and an empty `git diff
HEAD`). Both were taken on the door at `70e73548`; the commits after it
leave the door byte-identical and add one side-effect import and no case
to the test file.

- **A, the door's set grows alone** (the filter replaced by a local set
holding `formula`, `summary` and a marker) → `Tests 2 failed | 97 passed
(99)`: both `summary` rows. The grid would offer that sort and the Data
API would refuse it.
- **B, the spec's set grows alone** (the filter replaced by a local set
that lacks `formula`) → `Tests 1 failed | 98 passed (99)`: the `formula`
row of the second table. The solo row stays green there, because the
door's fourth verdict still refuses the sort with the same code and
status; only the fields the refusal names tell the two verdicts apart.
That is why the second table sorts by the field under test and by a
companion that declares `sortable: false`.

## Acceptance notes

- **"D1 names the unsortable-orderBy defect and its rule id. The
amendment log cites this card."** D1's new sentences and the fifth
`Amended` entry.
- **"Exactly one source answers whether a field type is computed for
sorting. The door and the projection both read it, and a test pins that
they agree."** `isVirtualSearchField` is that source for the Data API
door and the projection; the test above pins it for every `FieldType`.
The card names `protocol-data-crud.ts` as the door's file; the claim
corrects that to `protocol-query-validation.ts`, which is where the set
was.
- **"D4's alias sentence matches the schema's aliases on `main`. N1–N3
of record 7194836142 are closed in the same ADR-0160 text."** The D4
row, the D3 list and point 24, as above.
- **Where the text says more than the card's words, on purpose.**
- The card says to state what the schema "admits". The schema does not
admit an alias: `strictObject`'s `aliases` are spellings it refuses by
name. The row says so, since "with the record tools' aliases" read as if
a caller could write them.
- N3 as written covers a `body` field with a non-body type. A `body`
naming a field the root does not have takes the same branch and gets the
same answer, so the clause names both.
- Point 24 also says what happens when every heading is too long, from
the remark under N2.
- The status line's date and the note on point 20 follow the record's
own convention for an amendment and a settlement.
- **The D3 "Object level" sentence: three commits.** `88fa54ae` added
the draft sentence the dispatch order first carried; the PM withdrew it
before this PR opened, because it waited for a maintainer ruling, and
`e2e6a626` reverts it. The ruling came (comment 7208943876, option B),
and `06b567e5` adds the sentence again, now with the two sentences that
name the signal and with a sixth amendment-log entry of its own. The
sentence describes behaviour that is not on `main` yet; the log entry
says so.
- **Not touched by the sixth amendment, on purpose.** D3 "Objects first"
still quotes the record tools' `judgeRelatedLists` docblock ("nothing
about a refused object is read, its definition included"): that is the
record tools' order, which the ruling leaves alone. Context, "What a
refusal names", is unchanged for the same reason.
- **One test-file commit after the first gate run.** `pnpm
check:test-source-alias` named the new test file: it reaches
`@objectstack/lint` through a dynamic import and did not load it at
module scope. `40e60883` adds the module-top side-effect import its
siblings in the package carry. No case changes.
- **Not changed, and why** (each `carrier: none`):
- The engine's own door, `assertOrderByIsMaterializable` in
`packages/objectql`, still spells the literal `formula`. The card names
the HTTP door and the projection; a third reader is outside the claimed
file surface.
- Six comments in four files outside this card's surface still mention
the retired name `UNMATERIALIZED_SORT_TYPES` (two in
`packages/drivers/driver-sql`, two in `packages/lint`, two in
`ui/packages/plugin-list` tests). The door's new comment keeps the
retired name so a search for it lands on the call site.
- The removed docblock said `fieldHasColumn` answers "has a column" for
a `multiple` formula. On `main` that helper reads `isMultiValueField`,
which is false for `formula`, so that paragraph was already stale and is
not carried over.
- One edge the predicate reads differently: a field whose `type` is not
a string but stringifies to `formula` was refused by the old
`String(...)` comparison and is not by `isVirtualSearchField`. No
schema-valid definition holds such a field.
- **Tier H by path.** `docs/adr/**` is governed, so the whole PR is Tier
H and stays a draft. The `Rule-change:` line is left out: the diff does
not touch `.claude/**`.

## Verification

**Read first** (by risk):

1. `docs/adr/0160-record-scoped-ai-inquiry.md`, D3 "Object level": the
replaced sentence moves a visibility boundary by a maintainer ruling,
and its last two sentences state what a caller can now infer.
2. The same file, the D4 input row: "An alias is not accepted" corrects
what the record said rather than adding to it.
3. `packages/metadata-protocol/src/protocol-query-validation.ts`, the
one-line filter in `assertSortFieldsExist`.

**Two-minute verification**: `pnpm --filter
@objectstack/metadata-protocol exec vitest run --maxWorkers=2
src/protocol.sort-door-projection-agreement-37386.test.ts` — expected
`Tests 99 passed (99)`.

**Gates, patch round (`06b567e5`).** The commit edits one file, so the
families rerun are the ones that read it: `node
scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack docs/adr/0160-record-scoped-ai-inquiry.md` →
21 commands, all exit 0 on `06b567e5`, each exit code captured before
any pipe. This is a declared narrowing: the other 52 families of the
full list read files that are byte-identical to `40e60883`, and CI runs
the whole farm on the new head.

- `--ran` reconciliation against that derivation: `✓ dispatch-gates
--ran: 21 derived famil(ies) accounted for — 21 run, 0 NOT-MEASURED (a
DERIVED zero — all 21 recorded an exit code and none of them is 3).`
- `pnpm check:issue-citations` (outside that derivation; the new entry
cites a card): exit 0.
- `dispatch-gates --tier`: changed lines 218 (+170 / −48) against the
human-merge threshold 3000: under.
- `overlap-check --branch=claude/area-o1B-37386` before the push:
`VERDICT clean exit 0` at `06b567e546` against `origin/main` at
`6e8f663710` and 0 PR heads. `origin/main` was not merged in: no
conflict.
- The derivation printed a STALE TREE warning: the branch is at least 17
commits behind `origin/main`, and 2 files the derivation reads changed
in that range.

<details><summary>Patch-round gates (21 commands on 06b567e, exit code
beside each)</summary>

```text
exit 0 · node scripts/check-adr-links.mjs
exit 0 · node scripts/check-adr-links.mjs --self-test
exit 0 · node scripts/check-closing-keyword-parity.mjs
exit 0 · node scripts/check-closing-keyword-parity.mjs --self-test
exit 0 · node scripts/check-comment-mask-corpus.mjs
exit 0 · node scripts/ci/plan-test-core-shards.mjs --self-test
exit 0 · pnpm --filter @objectstack/lint run check:doc-formula-expressions
exit 0 · pnpm check:adr-anchors
exit 0 · pnpm check:adr-index
exit 0 · pnpm check:adr-symbol-anchors
exit 0 · pnpm check:ci-filter-parity
exit 0 · pnpm check:closed-ceremony-text
exit 0 · pnpm check:cross-package-test-inputs
exit 0 · pnpm check:doc-authoring
exit 0 · pnpm check:driver-memory-census
exit 0 · pnpm check:gitlink-declared
exit 0 · pnpm check:nul-bytes
exit 0 · pnpm check:pm-governed-merges
exit 0 · pnpm check:pm-prior-rulings
exit 0 · pnpm check:refd-timer-probe
exit 0 · pnpm check:watch-hint-literal
```

</details>

**Gates, full union (`40e60883`).** The list is `node
scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on `40e60883` (no paths; the script takes
the change set from the merge base): 73 commands. Each ran on `40e60883`
with its exit code captured before any pipe.

- 72 exited 0. One exited 3: `node
scripts/check-plugin-teardown-shape.mjs --self-test`, PREREQUISITE NOT
MET, so NOT MEASURED. Its positive control is pinned to a commit a
shallow clone cannot read, and the remedy it names is to unshallow the
clone every worktree in this container shares, which was not done; CI
runs it on a full checkout.
- The same list on the earlier head `e2e6a626`: one red, `pnpm
check:test-source-alias`, naming the new test file (repaired by
`40e60883`, above); and two more exit-3 refusals for built output not on
disk (`check:dual-build-cjs-loads`, `check:lean-entry-closure`). Both
measured green on `40e60883`, after `check:type-check-debt` in the same
list had built the packages under the verify lock.
- `--ran` reconciliation on `40e60883`: `✓ dispatch-gates --ran: 73
derived famil(ies) accounted for — 72 run, 1 NOT-MEASURED (1 DERIVED
from a recorded exit 3).`
- `dispatch-gates --tier` at `40e60883`: `docs/adr/**` is the mandatory
contract tier; changed lines 212 (+165 / −47) against the human-merge
threshold 3000: under.
- `overlap-check --branch=claude/area-o1B-37386` before each push:
`VERDICT clean exit 0`, the last one at `40e60883` against `origin/main`
at `8b9b9d2355` and 0 PR heads.
- CI-owned families (type-check lanes, the repo-wide lint, `Test Core`,
the changeset check, the always-runs tail) are this PR's check-runs;
they had not reported when this body was written.

<details><summary>Not measured locally (1), each with its own refusal
text</summary>

```text
✗ check-plugin-teardown-shape self-test: cannot read the positive control at 621a487.
  The fixture is pinned to a commit rather than to an editable copy, so a checkout
  that cannot reach it cannot run this battery. Deepen the clone:
    git fetch --unshallow origin main

✗ check-plugin-teardown-shape self-test: selfTest() returned without reaching its verdict,
so no success line was printed. Exiting 0 here would report a self-test
that never finished as a self-test that passed.
```

</details>

<details><summary>Local gates (73 commands on 40e6088, exit code beside
each)</summary>

```text
exit 0 · node scripts/check-adr-0087-registration.mjs --base origin/main
exit 0 · node scripts/check-adr-0087-registration.mjs --self-test
exit 0 · node scripts/check-adr-links.mjs
exit 0 · node scripts/check-adr-links.mjs --self-test
exit 0 · node scripts/check-changeset-no-major.mjs --base origin/main
exit 0 · node scripts/check-closing-keyword-parity.mjs
exit 0 · node scripts/check-closing-keyword-parity.mjs --self-test
exit 0 · node scripts/check-comment-mask-adoption.mjs
exit 0 · node scripts/check-comment-mask-adoption.mjs --self-test
exit 0 · node scripts/check-comment-mask-corpus.mjs
exit 0 · node scripts/check-dts-emitted.mjs --self-test
exit 0 · node scripts/check-empty-changeset.mjs --base origin/main
exit 0 · node scripts/check-empty-changeset.mjs --self-test
exit 0 · node scripts/check-issue-citations.mjs
exit 0 · node scripts/check-plugin-teardown-shape.mjs
exit 3 · node scripts/check-plugin-teardown-shape.mjs --self-test
exit 0 · node scripts/ci/assert-turbo-remote-cache.mjs --self-test
exit 0 · node scripts/ci/plan-test-core-shards.mjs --self-test
exit 0 · node scripts/ci/prune-turbo-cache.mjs --self-test
exit 0 · node scripts/ci/snapshot-next.mjs --self-test
exit 0 · node scripts/docs-audit/check-affected-docs.mjs
exit 0 · node scripts/docs-audit/check-drift-comment.mjs
exit 0 · node scripts/pm/check-governed-queue-guard.mjs --self-test
exit 0 · node scripts/pm/release-rehearsal-clone.mjs --self-test
exit 0 · node scripts/release-pending-publish.mjs --self-test
exit 0 · pnpm --filter @objectstack/lint run check:doc-formula-expressions
exit 0 · pnpm --filter @objectstack/spec run check:duration-unit-keys
exit 0 · pnpm --filter @objectstack/spec run check:error-code-provenance
exit 0 · pnpm check:adr-anchors
exit 0 · pnpm check:adr-index
exit 0 · pnpm check:adr-symbol-anchors
exit 0 · pnpm check:changeset-gate-self-tests
exit 0 · pnpm check:ci-filter-parity
exit 0 · pnpm check:closed-ceremony-text
exit 0 · pnpm check:cross-package-test-inputs
exit 0 · pnpm check:dispatcher-error-vocabulary
exit 0 · pnpm check:doc-authoring
exit 0 · pnpm check:driver-memory-census
exit 0 · pnpm check:dts-closure
exit 0 · pnpm check:dual-build-cjs-loads
exit 0 · pnpm check:durability-log-level
exit 0 · pnpm check:engine-double-contract
exit 0 · pnpm check:error-status-conformance
exit 0 · pnpm check:gitlink-declared
exit 0 · pnpm check:issue-citations
exit 0 · pnpm check:keyed-text-bounds
exit 0 · pnpm check:lean-entry-closure
exit 0 · pnpm check:logger-receiver-detach
exit 0 · pnpm check:nul-bytes
exit 0 · pnpm check:object-def-param-keys
exit 0 · pnpm check:objectql-double-limit
exit 0 · pnpm check:optional-error-sink
exit 0 · pnpm check:org-identifier
exit 0 · pnpm check:page-declaration-shape
exit 0 · pnpm check:platform-object-tenancy-census
exit 0 · pnpm check:pm-governed-merges
exit 0 · pnpm check:pm-prior-rulings
exit 0 · pnpm check:published-files
exit 0 · pnpm check:query-options-erasure
exit 0 · pnpm check:refd-timer-probe
exit 0 · pnpm check:registry-log-declared
exit 0 · pnpm check:rest-log-spy-declared
exit 0 · pnpm check:slot-lookup
exit 0 · pnpm check:sourcemap-no-sources-content
exit 0 · pnpm check:system-context-census
exit 0 · pnpm check:test-source-alias
exit 0 · pnpm check:tier-file-adoption
exit 0 · pnpm check:type-check-coverage
exit 0 · pnpm check:type-check-debt
exit 0 · pnpm check:undeclared-dep-imports
exit 0 · pnpm check:vouch-for-reference-callers
exit 0 · pnpm check:watch-hint-literal
exit 0 · pnpm check:where-matcher
```

</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cxBECSPtHxQMZDHSie)_

<!-- signed: repo:objectstack#1 · os-elon-musk ·
session_016WV4cxBECSPtHxQMZDHSie -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ut of step with main (week of 2026-11-25) (objectstack-ai#38289)

<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDypKu7B9nwbu5WuV7AEio8)_

Fixes objectstack-ai#37245

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:用户无感;只在十份设计记录里补了带日期的说明,写明主线现在实际怎么做,原有的决定文字一个字没动。
- 为什么做:属于「每周设计记录修订」滚动清单(11 月 25
日这一周);清单每一行指出一处「记录写的和主线不一致」,这次一并补齐,免得照着记录干活的人被过时说法带偏。
- 出错会怎样:最坏是某条补充说明写得不准,读这些设计记录的人会碰到;纯文档、只增不删,可以直接撤回,不影响任何功能。
- 要你做什么:请审这些补充说明并亲手合并(设计记录须由你本人合)。

## What changes

Ten ADR files gain notes dated 2026-11-28. Every diff line is an
addition: 239 lines added, 0 removed. No original decision text is
rewritten, and no decision changes. Each note follows the note
convention its own record already uses.

Each row's "what is true now" was read against the code on `main` before
it was written. Where a row was wrong or had gone stale, the note says
what `main` does, and the table and the list under it say so.

| Row (comment id on the card) | ADR and section | Result |
|:---|:---|:---|
| Card body row (from objectstack-ai#37238) | ADR-0146, the 2026-11-24 amendment, "32
registered types" | **Landed. Row stale.** The row asks for 33; the
registry holds 35 entries on `main`. The note states no count and points
at the registry and at ADR-0084's table. |
| 7155511307, nit 1 | ADR-0160 D1, the door's page cap sentence |
**Landed. Row stale.** The row says the door has no page cap. PR objectstack-ai#37354
added one. The note says what `main` does: the list is cut one row under
the door's cap, not at it. |
| 7155511307, nit 2 | ADR-0160 D1, "only contains braces" | **Landed**
as the row asks. |
| 7155511307, nit 3 | ADR-0160 D3, the link-field sentence | **Landed as
a note that the sentence stands.** |
| 7161785832 | ADR-0158, Open items 9 and 12 | **Landed.** |
| 7178404228, anchor half | ADR-0066, line 146 | **No edit.** PR objectstack-ai#37621
already landed it (record 7198334624). |
| 7178404228, end-state half, with 7201928772 | ADR-0066 D2 ⑧ |
**Landed.** Its prerequisite, PR objectstack-ai#37371, is merged. The proposed text is
tightened in two places, listed below. |
| 7179515770 | ADR-0158 U3, U6, L4, Open item 10 | **Landed.** |
| 7184833647 | ADR-0159, Context, "One name already taken" (line 109) |
**Landed as a note. The anchor line is untouched.** This is not a
no-edit row: the anchor resolves, onto the opposite meaning. See below.
|
| 7187445064 | ADR-0158 L1, L2, Open items 6, 8, 10 and 11, and a new
Open item 13 | **Landed.** |
| 7195437501 | ADR-0010, the amendment note of 2026-11-24 | **Landed**,
with one arm `main` has gained since the row was written. See below. |
| 7212321297, first row | ADR-0067 D3 | **Landed. Row wording wrong.**
The note carries the revert rule that the `form` type brought. See
below. |
| 7212321297, second row | ADR-0160, implementation split, row 7's
bullet | **Landed.** The row places the stale path near line 425; it is
near line 491. |
| 7213085888 | ADR-0048 §3.5 | **Landed.** The row's ready text, dated
2026-11-28, with symbol anchors where it had line numbers. |
| 7215202653, corrected by 7215223685, with 7224476684 | ADR-0150 D3,
the note of 2026-11-26 | **Landed.** Item 2 of the first row said the
two doors were still open. The later row supersedes it: PR objectstack-ai#37948
merged, and both doors now refuse. |
| 7217585102 | ui ADR-0057, A2 and A3 | **Landed. Row stale on one
line.** The plan-marker line is written as `main` is today, after PR
objectstack-ai#37970, and not only as it was after PR objectstack-ai#37720. |

Comments that are not rows: 7186949648 (triage note), 7196224618 (a
one-row claim), 7196910014 (its report), 7198334624 (its landing record)
and 7237786310 (this claim).

**No row is held.** Every prerequisite is merged on `main`: PRs objectstack-ai#37219,
objectstack-ai#37240, objectstack-ai#37268, objectstack-ai#37354, objectstack-ai#37366 (which carried objectstack-ai#37422), objectstack-ai#37371, objectstack-ai#37389,
objectstack-ai#37423, objectstack-ai#37449, objectstack-ai#37640, objectstack-ai#37720, objectstack-ai#37818, objectstack-ai#37931, objectstack-ai#37948, objectstack-ai#37970, objectstack-ai#37065,
objectstack-ai#36138 and objectstack-ai#37021. The card has 19 comments as of this pull request; a
row added after comment 7237786310 is not in it.

### Where a note differs from its row

- **ADR-0146.** The row offers two forms, "give the count" or "point to
ADR-0084's table". The note takes the second. A count written today
would already be the third reading (32, then 33, now 35).
- **ADR-0160 D1, the page cap.** The row's premise was true when it was
written and is not now. `RecordContextDoor.pageCap` exists, and both
doors answer it. The note records the one-row difference between the
amendment's words and the code: a list whose cut plus its probe row
would pass the cap is cut one row under the cap.
- **ADR-0160 D3, the link field.** The note leaves the wording alone.
- **ADR-0066 D2 ⑧.** Two changes to the proposed text. The note says in
words that `viewAllFieldsReadVote` replaced `superuserFieldVote`, and
anchors only the function that exists. And it does not say that nothing
re-opens a lock across sets: another set's `viewAllFields` still makes a
hidden field readable, and another set's field row with `editable: true`
still grants the edit, because field grants union without deny.
- **ADR-0159, line 109.** PR objectstack-ai#37422 was merged into PR objectstack-ai#37366's branch,
so the anchor `view.zod.ts#defineForm` resolves and the gate is green on
it. It now resolves onto the `form` type's factory, while the paragraph
describes the Studio helper, which is `defineMetadataForm` today. The
paragraph is Context and describes the tree before the ruling was
carried out, so the note leaves it as written and states both names.
- **ADR-0010.** The row covers the three restore doors of PR objectstack-ai#37423. The
same rule has since gained a second refusal, from PR objectstack-ai#37640: a restore
that would write a version the platform registered into a package's row.
The note has one sentence on it. That sentence goes beyond the row; cut
it if the note should carry the row alone.
- **ADR-0067 D3.** The row asks for a note "naming `form` as a
translated metadata type". D3 is about undo granularity and has no such
notion. The contract reviews of PR objectstack-ai#37422 sent one fact to this record:
a `form` item is reverted only after every `view` row its commit edited
is put back, and it joins `failed[]` otherwise. The note records that.
- **ADR-0048.** The row's text was dated 2026-11-24. The note is dated
2026-11-28, the day it was written into the record.
- **ADR-0150.** Besides answering "Not judged yet", the note qualifies
one sentence of the 2026-11-26 note that said too much: the draft
discard is newly refused only over a stored package-less draft. Where it
was already refused, only its sentence moved.
- **ADR-0158.** Row 7179515770 points at a draft held by its seat, which
this session could not read. The notes are written from the two rows and
the code. Open item 13 is a new numbered item at the end of the list,
carried from the display card; it is marked not built and not settled.
- **ui ADR-0057.** The row asks for "what main does after objectstack-ai#37720".
`main` has moved once more: since PR objectstack-ai#37970 the entry's marker stands
for a write that waits for approval. The note says that, and that A5's
"Not recorded yet" bullet held until that pull request merged.

## Tests

Docs only. No package is touched, so no build closure and no package
test is owed for the change. No tested behaviour changed, so there is no
ablation.

What was checked by hand, on the committed text:

- Each phrase a note quotes from its ADR was compared with the base
file.
- Each verbatim maintainer quotation was compared, byte for byte, with
its record on GitHub.
- Each cited path and symbol exists on `main`. The one exception is
deliberate: the ADR-0160 note names `packages/spec/src/ai/skill.form.ts`
to say that no such file exists.
- Upstream moved ten commits while this was written (`e42520c67b` to
`e2a0e90025`). None touches an ADR file or a file a note cites.
`overlap-check` answers `VERDICT clean exit 0` against `origin/main` at
`e2a0e90025`, and no open pull request shares a file with this branch.

The local gate set is the `dispatch-gates --commands` derivation for
this change set, 27 commands, run on the final commit `c2c3345747`. Each
exit code was captured before any pipe. Reconciliation: `Run
reconciliation — 27 derived, 27 run, 0 NOT-MEASURED, 0 UNRUN`, all 27
with a recorded exit code.

<details><summary>ADR gates on c2c3345 (all exit 0)</summary>

| Command | Exit | Verdict line |
|:---|:---|:---|
| `pnpm check:adr-symbol-anchors` | 0 | `check-adr-symbol-anchors: 4525
anchors across 164 records resolve`, 0 line anchors survive. On the base
commit the same gate reads 4478. |
| `node scripts/check-adr-links.mjs` | 0 | `check-adr-links: 1268
relative link destination(s) under docs/adr/ resolve` |
| `node scripts/check-adr-links.mjs --self-test` | 0 | |
| `pnpm check:adr-anchors` | 0 | |
| `pnpm check:adr-index` | 0 | `adr-index --report: OK —
docs/adr/README.md is current, every record parsed` |
| `pnpm check:doc-authoring` | 0 | |
| `pnpm check:nul-bytes` | 0 | `check-nul-bytes: OK (scanned 28605 text
file(s)`, no raw control bytes |
| `pnpm check:closed-ceremony-text` | 0 | |
| `pnpm --filter @objectstack/lint run check:doc-formula-expressions` |
0 | run after building `@objectstack/formula` and `@objectstack/lint`
under the verify lock |
| `pnpm --dir ui run check:new-line-citations` | 0 | `VERDICT
new-cross-file-line-citations: 0 new citation(s)`. Not in the derived
list; run because a ui ADR changed. |

</details>

<details><summary>The other derived families on c2c3345 (all exit
0)</summary>

`node scripts/check-closing-keyword-parity.mjs` and its `--self-test`,
`node scripts/check-comment-mask-corpus.mjs`, `node
scripts/ci/plan-test-core-shards.mjs --self-test`, `pnpm
check:ci-filter-parity`, `pnpm check:cross-package-test-inputs`, `pnpm
check:driver-memory-census`, `pnpm check:gitlink-declared`, `pnpm
check:pm-governed-merges`, `pnpm check:pm-prior-rulings`, `pnpm
check:published-files`, `pnpm check:refd-timer-probe`, `pnpm
check:registry-log-declared`, `pnpm check:rest-log-spy-declared`, `pnpm
check:tier-file-adoption`, `pnpm check:undeclared-dep-imports`, `pnpm
check:watch-hint-literal`.

Before the push: `node scripts/check-commit-card-trailers.mjs --range
origin/main..HEAD` exit 0, one commit message, no card relation and no
model identifier in the trailer pair.

</details>

<details><summary>The ui scripts test family: one prerequisite failure,
then green</summary>

Derived command: `pnpm --dir ui exec vitest run scripts/`, run under the
verify lock with `--maxWorkers=2`.

- First run: `VERDICT command-exit 1`. `Test Files 1 failed | 171 passed
| 2 skipped (174)`, `Tests 1 failed | 5144 passed | 2 skipped (5147)`.
The one failure was
`scripts/__tests__/unit-registry-absence-collision.test.ts`, with
`Failed to resolve entry for package "@objectstack/client"`. The package
had no build output in the fresh worktree. That is a missing
prerequisite, not a verdict on this change.
- After building the `@objectstack/client` closure under the lock, the
same command on the same commit: `VERDICT command-exit 0`. `Test Files
172 passed | 2 skipped (174)`, `Tests 5145 passed | 2 skipped (5147)`.

</details>

Not run locally: the repository test project behind `test:repo`, which
CI runs on the pull request and on the merge group. Every other family
CI runs is read from this pull request's check runs, not re-run here.

## Acceptance notes

- **Changeset.** None, and the pull request carries `skip-changeset`.
`docs/adr/**` and `ui/docs/adr/**` ship in no package: the ui tree's
root is a private workspace root and `ui/docs` is under no package
directory.
- **Governed surface.** `docs/adr/**` lands by the maintainer's hand.
This pull request stays a draft; the seat hands it over.
- **The registry count.** The card row and the amendment both carry a
number. The repository rule for a volatile count is to remove it and not
to sync it, so the note adds none.
- **Seen and left alone.** These are outside the card and are not
changed here.
- ADR-0084, near line 226, says `form` is not a registered type. It is
about the working names of the 2026-07-01 table, and `form` is
registered now. It is a candidate row for next week's card of this name.
- One internal skill playbook and ui ADR-0056 still use the Studio form
helper's old name. The review of PR objectstack-ai#37366 already recorded both.
- Comments in the console's chat scope helper still describe the
`app:PKG:build` dock key and the Studio copilot.

## Verification

### Read first

1. `docs/adr/0066-unified-authorization-model.md`, the note of
2026-11-28 under D2 ⑧. It is the highest-risk hunk: one long paragraph
on authorization, and it supersedes parts of three earlier notes. Check
the sentences on what another set can still re-open, and the sentence
that stored sets are read with the new meaning and never rewritten.
2.
`docs/adr/0150-behavioural-metadata-addressed-by-package-objects-keep-the-literal-prefix.md`,
the amendment note of 2026-11-28. Check the four cells and their
remedies (enable, enable, name the package, name the package) against
the ruling it quotes.
3.
`docs/adr/0158-units-of-measure-standard-unit-table-org-units-quantity-unit-declaration-base-quantity.md`,
the notes under Open items 6 and 10 and the new Open item 13. Both notes
quote the maintainer, and item 10's records the shape of a new system
object.

### Two-minute check

Run `git diff --numstat origin/main...HEAD` on this branch. Expect ten
rows, nine under `docs/adr/` and one under `ui/docs/adr/`, each with `0`
in the removed column, and 239 added lines in total. Then run `pnpm
check:adr-symbol-anchors` and expect exit 0 with a line that contains
`check-adr-symbol-anchors: 4525 anchors across 164 records resolve`.

---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW)_

<!-- signed: repo:objectstack#1 · os-elon-musk ·
session_016WV4cxRDKprCtjpEdtiPFW -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:ai size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants