Skip to content

Commit cf4b06f

Browse files
docs(adr): ADR-0160 amended — related lists gain where / orderBy / limit (row 11 contract) (#37240)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBEaJzgBWzjWCNjBjkVoeRto)_ repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK Fixes #37202 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:现在用户无感(只改决定记录,不改代码);规则是给 AI 的记录资料包里,关联列表可以只带挑出来的行、按指定顺序排、限定条数(例如只带当前生效的那一版),筛选不增加任何权限,筛选或排序用到提问人不能据以查询的字段(看不到的、值被收起的、只显示掩码的)时整段省略并说明有资料不可见、不点名字段;要等后续实现卡 #37203(把这三个写法和读取它们的服务一起做出来)合并后才真正生效。 - 为什么做:属于「按记录向 AI 提问」这一大项,你 11 月 25 日已同意关联列表的筛选和排序,这里把它写成成文规则,后面的实现照着做。 - 出错会怎样:规则写错的话,后面的实现会照着错的做,碰到的是写资料包的人和用它提问的人;这次只有文档,撤回这次合并即可。 - 要你做什么:审后由你本人合并(合并即批准);你的原话只说了筛选和排序,其余十处是记录自己补全的决定,已在记录的「超出卡面原话的几点」一节逐条编号列出(第 13 到 22 点,下文英文部分也有一份),不同意哪条可以先划掉再合并。 ## What changes One file under `docs/adr/`: `0160-record-scoped-ai-inquiry.md`, 55 lines added and 13 removed against `main`. No schema, no code, no changeset. This is ADR-0160's second amendment. It records the maintainer's word of 2026-11-25, verbatim: 「related 的筛选和排序 同意」 (the thread of epic #36996, card #37202). The first amendment (PR #37196) had left filter and order on `related` as a separate protocol decision. - **Header.** A second `Amended:` bullet quotes the maintainer and lists what the amendment records. It says the maintainer's word names filter and order and no more, and it names each of the ten additions with its point number. The `Status:` line is byte-identical, so the generated `docs/adr/README.md` does not change and is not in the diff. - **D1.** A `related` entry gains `where`, `orderBy` and `limit`, on the child's own fields only. - `where` uses the platform's object filter form with ten operators (`$eq`, `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$null`, `$exists`), joined by `$and` / `$or`. A bare value is read as `$eq`. It follows no relation and takes no field-to-field comparand, no `$now` anchor, no formula and no whole `{token}` placeholder. Anything else is refused at parse. - `orderBy` is `{ field, order }[]`. - `limit` is a positive integer, at most the service's row cap for one related list. - The three keys leave "Later work". Placeholders resolved at call time join it. - The keys are declared here and land with their reader in row 11. Until then the schema on `main` refuses them. - **D3.** The filter and the order run inside the caller's one capped child query and grant nothing. A `related` entry whose `where` or `orderBy` names a field the caller cannot query on is dropped whole, with the statement that some material is not visible, and the field is never named. - **D4.** The read set is unchanged: the three keys add no object to it. - **Points that go past the card's words.** Points 5 and 11 are updated. Points 13–22 are new and list every place where the amendment goes past the maintainer's word and the card. - **Implementation split, Consequences.** The split gains row 11 (card #37203). Consequences counts a fourth protocol addition. ### Round 2, at `1cd00b0d` The contract review of the first head passed with three should-fix findings (comment 7154648352, adopted by the seat in 7154665327). This head answers them. - **S1.** D3 said "a field this caller cannot read". It now says "a field this caller cannot query on" and defines it as every field outside the security service's `getQueryableFields` answer. That takes in the field served masked and the field an agent's ceiling withholds, which the engine's guard also refuses. Both symbols are anchored. - **S2, by the seat's ruling for this text.** A bare value such as `{ is_current: true }` is admitted and read as `$eq`. A comparand that is one whole `{token}` placeholder is refused at parse in v1, beside the `$now` anchor, and placeholders resolved at call time are later work. - **S3.** The `Amended:` bullet no longer says that one sentence goes past the maintainer's word. The record's own section now carries points 13–22, and point 11 covers `where` and `orderBy`. - **Nits applied where they touch this text.** - The refusal that the rule avoids is named as the security plugin's engine middleware, not the data engine. - "The body" says an outline is cut by the body bound or by the entry cap. PR #37222 has merged, so the entry cap is now anchored on `main`. - A door whose own page cap is lower than a `limit` that parsed cuts the list there, and the cut is stated. - Row 11 may bound the size of a `where` at parse; this record sets no number. - **Not changed, by the review's own word.** The link-field sentence beside the new one still says "that caller's schema hides". The review asks for a follow-up card to carry it. The branch also merged `main` at `6211ddf4`, with no conflict. That brought the note PR #37209 added to D1 and the outline cap of PR #37222. ## Tests This PR changes a record only. No test is added or changed, and nothing is ablated. The readings the text rests on were re-taken on `main` at `6211ddf4`. The branch head is `1cd00b0d`, and every local gate below ran on that head. <details><summary>What the schema on main does with the three keys and with the sort direction</summary> A probe parsed a pack through `AiContextSchema` and a sort node through `SortNodeSchema`. It ran with `tsx` from the scratchpad and is not committed. ```text CONTROL (no new key) success = true related[].where: success = false | unrecognized_keys @ related.0: Unrecognized key(s) on a context pack `related` entry: `where`. related[].orderBy: success = false | unrecognized_keys @ related.0: Unrecognized key(s) on a context pack `related` entry: `orderBy`. related[].limit: success = false | unrecognized_keys @ related.0: Unrecognized key(s) on a context pack `related` entry: `limit`. SortNode { field, order }: success = true SortNode { field, direction }: success = false | unrecognized_keys: Unrecognized key(s) on this sort node: `direction`. Did you mean `direction` → `order`? ``` Each message is cut after its first sentence. The control row shows that the probe pack parses without the new keys, so each refusal is the key's own. </details> <details><summary>The anchors this round adds, resolved one by one</summary> `symbolResolutionClass` from `scripts/symbol-anchors.mjs`, asked for each new anchor and for one name that does not exist: ```text declaration packages/spec/src/contracts/security-service.ts#getQueryableFields declaration packages/plugins/plugin-security/src/security-plugin-object-inputs.ts#computeQueryGuardFieldPerms declaration packages/plugins/plugin-security/src/predicate-guard.ts#assertReadableQueryFields declaration packages/spec/src/data/context-tokens.zod.ts#FILTER_TOKEN_WRAPPED_RE declaration packages/core/src/utils/filter-tokens.ts#resolveFilterTokens declaration packages/services/service-record-context/src/body-outline.ts#RECORD_CONTEXT_OUTLINE_MAX_ENTRIES null packages/spec/src/contracts/security-service.ts#noSuchSymbolControl ``` </details> <details><summary>Local gates at 1cd00b0: 21 derived, 21 run, all exit 0</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived the same 21 commands as on the first head. Each exit code was captured before any pipe, and `--ran` reconciled the list: ```text ✓ 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). ``` The gates that read this file printed: ```text ✅ check-adr-links: 1222 relative link destination(s) under docs/adr/ resolve ✅ check-adr-symbol-anchors: 4199 anchors across 163 records resolve — 1416 symbol (1387 declaration, 29 literal), 2731 file-level, 52 cross-repo, 6 exempt, 96 continuation. adr-index --report: OK — docs/adr/README.md is current, every record parsed, self-test 60 assertions green. check-nul-bytes: OK (scanned 27783 text file(s) -- 27783 tracked, 0 untracked-not-ignored; skipped 101 binary; no raw ASCII control bytes). ``` The other 17 are `check-adr-links --self-test`, `check:adr-anchors`, `check:doc-authoring`, `check:pm-governed-merges`, `check:pm-prior-rulings`, `check:closed-ceremony-text`, `check-closing-keyword-parity` and its self-test, `check-comment-mask-corpus`, `check:cross-package-test-inputs`, `check:ci-filter-parity`, `check:driver-memory-census`, `check:gitlink-declared`, `check:refd-timer-probe`, `check:watch-hint-literal`, `plan-test-core-shards --self-test` and `check:doc-formula-expressions`. `check:doc-formula-expressions` reads the compiled output of `@objectstack/formula` and `@objectstack/lint`. Both were built first under the shared verify lock (`VERDICT command-exit 0`). `node scripts/adr-index.mjs` answered `unchanged docs/adr/README.md (250 lines)`. `node scripts/pm/overlap-check.mjs` answered `VERDICT clean exit 0` before each push. </details> Every family that CI runs is read from this PR's check-runs. None of them is re-run locally. ## Acceptance notes **Governed surface (Tier H).** `docs/adr/**` is governed. The maintainer's merge is the record. No seat readies, queues or arms this PR. **These decisions are listed for the maintainer.** The maintainer's word names filter and order on `related`. Everything below is the record's own settlement, accepted or struck by the merge. Each is a numbered point in the record's "Points that go past the card's words" section, and any one can be struck without touching the rest. | Point | Decision | Where it comes from | |:--|:--|:--| | 13 | `related` takes `limit` as well as filter and order. | The card names it; `get_record`'s `related` already takes one. | | 14 | A `limit` over the row cap is refused at parse. Row 11 declares one number that the schema and the service both read. | The pack's other bounds, and `get_record`'s own `related` limit. | | 15 | `where` admits ten operators, joined by `$and` / `$or`. `$not`, `$between`, `$empty`, the string-match operators, relation conditions, `{ $field }` and `$now` are refused. | The card says "a small operator set" and names none. | | 16 | A bare value is read as `$eq`. | The seat's ruling on review finding S2. | | 17 | A whole `{token}` comparand is refused at parse. Placeholders resolved at call time are later work. | The seat's ruling on review finding S2. | | 18 | `orderBy` is `{ field, order }[]`. | `SortNodeSchema` on `main` refuses `direction` by name. | | 19 | A `where` or `orderBy` field the caller cannot query on drops the section, stated and never named. | Review finding S1. The card says "hidden". | | 20 | A `where` or `orderBy` field the published definition lacks leaves the section out, and the answer states nothing. | The record's rule for author defects. | | 21 | A list cut at its own `limit` is a stated cut. | The record's rule that every cut is stated. | | 22 | D3, "The body", names the cap on an outline's entries. | Not about `related`: carried from the review of PR #37222, nit N5. | **Sections touched beyond the card's list, all in the one claimed file:** the author-defects paragraph and "Later work" in D1, "The body" in D3, the "Points" section, the intro and the two paragraphs under the Implementation split table, and one line of Consequences. **Seen and not changed here** (read on `main`, not exercised through a public door, so not filed): - Row 5's service still refuses the whole call when a `related` child is not served to this caller. The first amendment says that child is left out and the answer says so. - The link-field rule in D3 still says "that caller's schema hides". A link field that the schema shows and the caller cannot query on would reach the engine's guard, which refuses the whole call. The review asks for a follow-up card. - Card #37203's example spells the sort direction `direction`, and its item 3 says "hidden". Both now differ from the record. - The `ai_context` schema's guidance text for a stray `filter` key says a related list reads every child row the caller may read. Row 11 has to reword it. ## Verification Read first, by risk. All three are in `docs/adr/0160-record-scoped-ai-inquiry.md`: 1. **D3, "Field level", the bullet "The hidden field is one the pack uses structurally".** This is the disclosure rule: which callers lose the section, and what the answer may say. Round 2 rewrote its middle. 2. **D1, the `where` bullet under "Filter, order and limit on a related list".** This is the contract row 11 implements: the operator set, the bare value, and the comparands refused at parse. 3. **"Points that go past the card's words", points 13–22, and the header's second `Amended:` bullet.** They say which parts are the maintainer's word and which are the record's own. Two-minute check: run `pnpm check:adr-symbol-anchors`. It should exit 0 and print a line that starts `✅ check-adr-symbol-anchors:`. That line means every symbol the text cites is declared at the path the text names. At this head it counts 4199 anchors across 163 records. --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 660e7cd commit cf4b06f

1 file changed

Lines changed: 55 additions & 13 deletions

File tree

0 commit comments

Comments
 (0)