Repository navigation
Commit 13ffe1c
docs(adr): ADR-0161 dated note — item 17, the typed scope a search hands its adapter: record ids, or a parent object through a listed lookup (#37329)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8GWXHtfAHuZXmmZpkARr4Wi)_
Fixes #37324
Clause-②: yes
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:用户无感;只在「知识检索平台边界」这份决定记录里加一条带日期的说明,定下「限定范围检索」的接口形状:可以只在指定的几条记录里搜,也可以借知识源列出的查找字段,只在一份上级记录(比如一份制度)下的条款里搜。
-
为什么做:属于「知识检索平台化」专题第三阶段,记下您刚裁的「也能指定上级对象(制度)」;记录规定适配器契约的新成员要先以带日期的说明写进记录,随后的按范围检索代码卡才能动工。
-
出错会怎样:说明写错,后面写检索服务和存储适配器的人会照错的做,最坏是限定范围后漏掉结果(权限仍逐条按提问人重读,不会越权);有两处是记录替您定的细节请过目:一类条款若有两个字段都指向同一类制度,按制度限定时这类条款不参与检索并记日志;人员字段不算「上级」;本次只有文档,撤回合并即可。
- 要你做什么:审后由你本人合并(受治理面,合并即批准),且要排在随后的按范围检索代码改动之前。
## What changes
One file under `docs/adr/`:
`0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md`,
17 lines added and none removed against `main` (`829a45e9`). No schema,
no code, no changeset.
K8 item 17 of ADR-0161 ("A typed scope filter") reads "Deferred" with no
final shape, and K8 rule 3 says a shape that cannot be built as written
changes by "a dated note on this record". This PR is that note. It
records the maintainer's ruling on Q3, record
[`7168192820`](#37308 (comment))
on #37308: 「也能指定上级对象(制度)」. #37308 builds the member after this note
merges; #37311 (row 12) adds the `search_knowledge` arguments.
`docs/adr/**` is Tier H: the maintainer merges this PR; no seat
approves, merges or enqueues it.
Two additions, in the form PR #37263 used for the #37097 note:
1. **A second dated note under K8's table**, after the #37097 note and
before "What "capabilities" became.". The table is left as written.
2. **A second `Amended` bullet** at the end of the header list, pointing
at the note. The `Status:` line is byte-identical, so the generated
`docs/adr/README.md` does not change.
What the note decides. Each ◆ is a shape the note decides past the
ruling's words, for the approver to accept with the record or strike:
- ◆ **The member** is `AdapterSearchOptions.scope?`, a list of terms: `{
kind: 'record', ids }` (the document's `sourceRecordId` in `ids`) or `{
kind: 'metadata', field, ids }` (the document's `metadata[field]` in
`ids`, or a list with an element in `ids`). The adapter gets resolved
terms, never `{ object, ids }`: turning an object into a field needs the
object's registered definition, which is the platform's (K1).
- ◆ **Absent, present, empty**, read as item 9's `organizationIds`:
absent ranks every document as before; present filters BEFORE ranking so
`topK` is filled from in-scope documents; an empty list ranks nothing
and is never "no filter". `organizationIds`, `scope` and the opaque
`filter` all apply.
- **How the service builds it** from `KnowledgeSearchOptions.scope`
(entries of `object` and `ids`), per source: the source's own object
gives a `record` term; another object gives a `metadata` term for the
`metadataFields` member that points at it; no such member, and the entry
does not reach the source. A source no entry reaches is not searched; a
`file` or `http` source answers nothing under a scope.
- ◆ **Four readings the ruling leaves open**: (1) several entries
reaching one source combine as a union; (2) an own-object entry is the
`record` term only; (3) only `lookup` and `master_detail` are parent
links, target read through `referenceTargetOf`; a `user` field is not
one; a withheld field is not one; (4) a source that lists two or more
lookups to the entry's object is not reached by it, logged once per
source naming the fields.
- **What a scope does not reach**: a parent two hops away. An entry that
reaches no searched source answers the same empty answer a withheld
source gives, so the answer never tells which it was.
- ◆ **The service's guarantee**: after the adapter answers, the service
drops every hit no term holds for, judging `KnowledgeHit.sourceRecordId`
and `KnowledgeHit.metadata[field]`, fail closed. No capability flag is
added (K8 rule 5); the service logs once per adapter the first time its
check drops a hit.
- ◆ **Judged on the index copy**, never an access decision: the
permission re-read of the live row stays the access decision. Source
admission already requires every `metadataFields` member an index
carries to be queryable by the caller, so "that field in ids" is a
filter the caller could run on the object's own rows; the parent row is
never read.
- ◆ **The opaque `filter` stays as it is**, handed through and checked
by nothing in the service; whether it retires is its own card.
- **The suite cases** the member lands with in
`runKnowledgeAdapterContract`, per term kind, and one through a real
`KnowledgeService` over an adapter that ignores the member.
- **Not here**: the bounds on `KnowledgeSearchOptions.scope` (#37308,
coded refusal, ADR-0112), the tool argument (#37311), record-level
return (#37103).
**One shape differs from #37324's body words.** That body says the
member on `AdapterSearchOptions` is `scope: [{ object, ids }]`. The note
keeps `[{ object, ids }]` on the service option only and hands the
adapter resolved terms, as #37308's item 1 and K8 item 17 itself say
("built by the service from"). The member name is `scope` on both
interfaces, with distinct types.
## Tests
No test changes: the diff is one Markdown file. The derived gate
families were run at `8a64f99f`, the head.
<details><summary>Local gates at 8a64f99: 21 derived, 21 run, all exit
0</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 21 commands from the branch's change
set (1 path against merge base `829a45e9`). Each was run with its output
redirected to a file and its exit code read before any pipe.
`check:doc-formula-expressions` needs `@objectstack/formula` and
`@objectstack/lint` built: built first under the verify lock, `VERDICT
command-exit 0`.
| Command | Exit |
|:--|:--|
| `node scripts/check-adr-links.mjs` | 0 |
| `node scripts/check-adr-links.mjs --self-test` | 0 |
| `node scripts/check-closing-keyword-parity.mjs` | 0 |
| `node scripts/check-closing-keyword-parity.mjs --self-test` | 0 |
| `node scripts/check-comment-mask-corpus.mjs` | 0 |
| `node scripts/ci/plan-test-core-shards.mjs --self-test` | 0 |
| `pnpm --filter @objectstack/lint run check:doc-formula-expressions` |
0 |
| `pnpm check:adr-anchors` | 0 |
| `pnpm check:adr-index` | 0 |
| `pnpm check:adr-symbol-anchors` | 0 |
| `pnpm check:ci-filter-parity` | 0 |
| `pnpm check:closed-ceremony-text` | 0 |
| `pnpm check:cross-package-test-inputs` | 0 |
| `pnpm check:doc-authoring` | 0 |
| `pnpm check:driver-memory-census` | 0 |
| `pnpm check:gitlink-declared` | 0 |
| `pnpm check:nul-bytes` | 0 |
| `pnpm check:pm-governed-merges` | 0 |
| `pnpm check:pm-prior-rulings` | 0 |
| `pnpm check:refd-timer-probe` | 0 |
| `pnpm check:watch-hint-literal` | 0 |
Reconciliation, `node scripts/pm/dispatch-gates.mjs --repo
objectstack-ai/objectstack --ran` with the exit codes recorded:
```text
Run reconciliation — 21 derived, 21 run, 0 NOT-MEASURED, 0 UNRUN.
✓ 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).
```
`check:adr-symbol-anchors` resolves the note's four `path#symbol`
citations. Outside the derived set and not run locally: the
governed-merges audit with workflow-only variables, CI's test-core shard
planning steps, and the type-check lanes (the diff touches no
TypeScript). CI carries them.
</details>
## Acceptance notes
- **Two ◆ readings worth the approver's eye**, each written as the
note's recommendation:
- Reading (4), two lookups to the same parent: the entry does not reach
the source, logged once. The other answers were a union of the fields
(answers "inside this policy" with clauses that only cite it through the
other field), the first field listed (gives list order a meaning no
author wrote), a key on the entry naming the field (no consumer yet), or
a refusal (would differ from the withheld-source answer). No source in
this tree lists a reference field in `metadataFields` today, so no
measured consumer decides it; empty-now can open later without removing
anyone's hits.
- Reading (3), the `user` field: excluded as a parent link. The visible
cost: `Field.lookup('sys_user')` is a link while `Field.user()` is not.
Nothing scopes by user today; it returns by a dated note with its
reader.
- **The opaque `filter`** has no producer in this tree (the one non-test
caller of `IKnowledgeService.search`, `createKnowledgeTools`, passes
none) and gets no service guarantee. The note leaves it unchanged;
whether to retire it is a question for its own card. Noted, not filed:
carrier none.
- **Left to #37308's code PR**, not decided here: whether the refill
after the permission filter also counts hits the scope check removed;
whether an empty `KnowledgeSearchOptions.scope` or an entry with no ids
is answered empty or refused (the note fixes only that it never reads as
"no scope"); the bound numbers; log levels.
- **No changeset.** `docs/adr/**` publishes nothing; the PR carries
`skip-changeset`.
- **No `scripts/adr-anchors` entry.** `pnpm check:adr-anchors` exits 0
without one; the code PR anchors the member it lands.
## Verification
Read first:
1. The "Four readings the ruling's words leave open" bullet of the new
note, readings (3) and (4): the two places the note goes furthest past
the ruling.
2. The "The service's guarantee, whatever the adapter does" bullet: fail
closed on a hit without the document's metadata, and no capability flag.
3. The "The opaque `filter` stays as it is" bullet.
Two-minute check: open this PR's Files tab. It shows one file under
`docs/adr/`, +17 −0: one `Amended` bullet at the end of the header list,
and one blockquote between the #37097 note and the paragraph that starts
"What "capabilities" became.".
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbZmjM1KubX3ZAoJPPm)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8979953 commit 13ffe1c
1 file changed
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
328 | 329 | | |
329 | 330 | | |
330 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
331 | 348 | | |
332 | 349 | | |
333 | 350 | | |
| |||
0 commit comments