Skip to content

Commit 8032d95

Browse files
docs(adr): ADR-0161 dated note — the document hash covers the organization of a document that has one (K8 items 2 and 9) (#37263)
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ Part of #37097 repo:objectstack#4 · os-justin · session_01QSeKYkXwZ3ECV8yacsjMJM Clause-②: yes Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:用户无感;只在「知识检索平台边界」这份决定记录里加一条带日期的说明,写明文档指纹在文档带有所属组织时把组织也算进去,不带组织的文档指纹与以前逐字节相同。 - 为什么做:属于「知识检索平台化」专题第二阶段;实现改动 #37256(让索引文档记下所属组织、检索时先按组织过滤)改了指纹的算法,按这份记录自己的规矩,这种改动要先以带日期的说明写进记录、由你批准。 - 出错会怎样:说明写错的话,后面写存储适配器的人会照着错的做,最坏是换了组织的文档在重建索引时被跳过、在按组织过滤的检索里排不上;这次只有文档,撤回这次合并即可。 - 要你做什么:审后由你本人合并(合并即批准),并且要排在实现改动 #37256(上面那个让文档记下所属组织的改动)之前合并。 ## 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`, 9 lines added and none removed against `main`. No schema, no code, no changeset. **This PR must merge before PR #37256.** That PR changes the hash recipe of K8 item 2, and K8 rule 3 gives the form of such a change: "the change is a dated note on this record". Contract review `7157191417` on PR #37256 (its finding M1) and the seat's L1 `7157210840` hold that PR until this note has merged. `docs/adr/**` is Tier H: the maintainer merges this PR; no seat approves, merges or enqueues it. `Part of #37097`, not a closing line: the card's implementation is PR #37256 and stays there. This PR carries the record's note and nothing else. Two additions, both in the form sibling records already use (ADR-0090 and ADR-0151, notes of 2026-11-24): 1. **A dated note under K8's table**, as a blockquote that opens `Note (2026-11-25, card, built by PR)`. The table is left as written. 2. **One `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 and is not in the diff. The note, as it stands at the head: > **Note (2026-11-25, [#37097](#37097), built by [#37256](#37256)) — items 2 and 9: the hash covers the organization of a document that has one.** Item 2's hash covers the document as the service assembles it. The parenthesis "content, title, metadata" was everything assembly set on a document, its identity aside, when item 2 was accepted. Item 9 adds `organizationId` to the assembled document when the document has one, and the hash covers it then. A document without one hashes byte for byte as it did before, so the version prefix is not bumped. > > - **Why.** A document that gains an organization, loses it or moves to another one gets a new hash, so a complete reindex never leaves a stale organization on a stored document. The other answer kept the parenthesis and bumped the version. It leaves a later change of organization to the events alone, and missed events are the hole reconcile exists to close (K1). > - **A later optional member that assembly sets** enters the hash the same way, left out when it is absent, or the version is bumped. > - **What an adapter stores.** An adapter that stores `docHash` stores `organizationId` from the same version on; otherwise, once it starts reading this field, a complete reindex skips its documents and a walled search never ranks them. > > Item 9's first reader, #37097, is built by PR #37256, and this change to item 2 lands with it. The reasoning is contract review [`7157191417`](#37256 (comment)) on that PR (its M1 and S2). The table is left as written; read items 2 and 9 with this note. The header bullet: > - **Amended** (2026-11-25, [#37097](#37097)): a dated note under the table of [K8](#k8--the-contract-additions-decided-item-by-item) records that the document hash of item 2 covers `organizationId` when the document has one (item 9), with no version bump. The status line above is left as it is. What each sentence of the note rests on: | Sentence | Read where | |:--|:--| | the hash covered content, title and metadata | `packages/services/service-knowledge/src/knowledge-service.ts#computeDocHash` on `origin/main` at `d62f9e9c` | | assembly also sets the document's identity, which the hash never covered | `recordToDocument` in the same file at `d62f9e9c`: `id`, `sourceId`, `sourceRecordId` beside `content`, `title`, `metadata` | | the organization enters the hashed body only when the document has one; the version stays `v1` | `computeDocHash` and `DOC_HASH_VERSION` on PR #37256's branch at `e8b0688f` (and unchanged from `3df745d2`, the head the review read) | | events keep an index fresh, reconcile keeps it correct | K1 of this record, the "Sync and reconcile" row | | the adapter sentence | finding S2 of review `7157191417`; character for character the spec TSDoc on `KnowledgeDocument.organizationId` on PR #37256 at `6e978db3` | ## Tests No test changes: the diff is one Markdown file. The derived gate families were run at `dd1756af`. The final head `aec56080` changes only the adapter sentence's wording, and CI at `aec56080` is 25 success, 19 skipped, 0 failed. <details><summary>Local gates at dd1756a: 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 `d62f9e9c`). Each was run with its output redirected to a file and its exit code read before any pipe. | 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, at `dd1756af`: ```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). ``` Verdict lines from that run: ```text ✅ check-adr-links: 1222 relative link destination(s) under docs/adr/ resolve adr-index --report: OK — docs/adr/README.md is current, every record parsed, self-test 60 assertions green. … ✅ check-adr-symbol-anchors: 4199 anchors across 163 records resolve … check-nul-bytes: OK (scanned 27788 text file(s) -- 27788 tracked, 0 untracked-not-ignored; skipped 101 binary; no raw ASCII control bytes). ``` One family was not measured on its first run. At the first commit `15616e2f`, `check:doc-formula-expressions` exited 3, PREREQUISITE NOT MET: it imports the compiled output of `@objectstack/formula` and `@objectstack/lint`, and neither was built in a fresh worktree. After `pnpm exec turbo run build --concurrency=2 --filter=@objectstack/formula --filter=@objectstack/lint` under the verify lock (`VERDICT command-exit 0`), it exited 0 at `15616e2f` and again at `dd1756af`. `node scripts/pm/overlap-check.mjs --branch=claude/issue-37097-adr-0161-dochash-note` before each of the three pushes: `VERDICT clean exit 0` (at `dd1756af`: 1 changed file, against `origin/main` `d62f9e9c` and 0 PR heads). </details> ## Acceptance notes - **Where the note's words differ from the dispatch order's summary**, each for precision: - The order's summary says the item 9 reader "landed" in PR #37256. This note merges first, so it says the reader "is built by PR #37256, and this change to item 2 lands with it", which is true before and after that merge. - "The whole assembled document" became "everything assembly set on a document, its identity aside": assembly also sets `id`, `sourceId` and `sourceRecordId`, and the hash never covered those. - The rule for a later optional member is scoped to a member "that assembly sets", so it does not read as a rule about every optional key of `KnowledgeDocument` (the chunk channel of item 5 is set by the splitter and belongs to K7's fingerprint). - The adapter sentence is the spec TSDoc's sentence on PR #37256, word for word (commit `aec56080`), so the record and the contract say the same thing. - **The header bullet** was not in the order's list. It follows ADR-0151, whose header has the same shape and gains one `Amended` bullet per dated note. - **The note cites the review record** `7157191417`, so that the approver finds the reasoning from the record itself. - **No `scripts/adr-anchors` entry.** `pnpm check:adr-anchors` exits 0 without one, so the gate does not require it for the note. The review's N4 (an anchor for K8 item 9 in code) stays a follow-up outside this file surface. - **No changeset.** `docs/adr/**` publishes nothing and no derived gate asked for one; the PR carries `skip-changeset`. - **PR #37256 moved while this was written**, from `3df745d2` (the head the review read) to `6e978db3`. What changed there is a test file and the spec TSDoc; the hash recipe is the same at every head. ## Verification Read first: 1. The note under K8's table in the one changed file. The sentence to weigh is the adapter rule, "An adapter that stores `docHash` stores `organizationId` from the same version on": K8 rule 2 keeps every member optional, and this sentence says two of them are taken up together. 2. The "Why" bullet of the same note: it records which answer was not taken (keep the parenthesis, bump the version) and why. 3. `computeDocHash` on PR #37256's branch, `packages/services/service-knowledge/src/knowledge-service.ts`, to hold the note against the recipe it describes. Two-minute check: open this PR's Files tab. It shows one file under `docs/adr/`, +9 −0: one `Amended` bullet at the end of the header list, and one blockquote between K8's table and the paragraph that starts "What "capabilities" became." Body rewritten to head `aec56080` by seat repo:objectstack#4 (session_01QSeKYpEsWWE9Y5YtSsDgqZ) from the dev's round-2 report 7158272523. --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYkXwZ3ECV8yacsjMJM)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 376377c commit 8032d95

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- **Builds on**: [ADR-0005](./0005-metadata-customization-overlay.md) (one Zod source per type), [ADR-0049](./0049-no-unenforced-security-properties.md) and [ADR-0078](./0078-no-silently-inert-metadata.md) (a declared key is enforced or it is not declared; a key lands with its reader), [ADR-0087](./0087-metadata-protocol-upgrade-contract.md) (conversions, tombstones and the migration chain), [ADR-0088](./0088-metadata-kind-admission-and-retirement.md) (the kind admission test), [ADR-0090](./0090-permission-model-v2-concept-convergence.md) D10 (an agent reads as the principal it acts for), [ADR-0112](./0112-error-code-vocabulary-and-ledger.md) (coded refusals), [ADR-0149](./0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md) D2 (one tool definition, one executor, every transport), [ADR-0159](./0159-forms-are-their-own-metadata-type-public-forms-are-form-items-view-is-lists-only.md) (the latest kind admission, followed for the form of K4), and [`ADR-0057-system-data-lifecycle-and-retention`](./0057-system-data-lifecycle-and-retention.md) (the reap guard the knowledge plugin registers).
1717
- **Leaves unchanged**: permission-aware retrieval (every object-source hit is re-read as the caller, and a source is searched for a caller only after the exposure and field-level admission of PR #36850); the reap guard of #4672 as landed; the signature and return type of `IKnowledgeService.search`; the settings shape of #33933 (knowledge settings only where the service is mounted), which #37102 keeps: without the capability token there is no knowledge service and no knowledge settings page; the open AI door, which stays MCP-only (cloud ADR-0119 D4).
1818
- **Inputs**: every code and docs text quoted below was read on `objectstack-ai/objectstack` `main` at `254e396a29`, the commit this record's branch starts from. Positions are in [Readings](#readings-taken-at-254e396a29). PR #36823 and PR #36850 are merged and are in that tree; PR #37075 is open and edits §6 of `content/docs/protocol/knowledge.mdx`, so the §6 quotations may move when it lands.
19+
- **Amended** (2026-11-25, [#37097](https://github.com/objectstack-ai/objectstack/issues/37097)): a dated note under the table of [K8](#k8--the-contract-additions-decided-item-by-item) records that the document hash of item 2 covers `organizationId` when the document has one (item 9), with no version bump. The status line above is left as it is.
1920

2021
---
2122

@@ -317,6 +318,14 @@ The epic holds the contract shut until this record merges ("No new adapter-contr
317318
| 16 | `knowledge-turso` | Accepted as a rule | No member beyond items 1, 5, 7, 8 and 9. Its generation table and lock row stay inside the adapter (K7, rule 2). | #37107 |
318319
| 17 | (not in the input) A typed scope filter | Deferred | A typed form for what is an opaque `filter` record on `AdapterSearchOptions` today, built by the service from `scope: [{ object, ids }]`. | row 11 |
319320

321+
> **Note (2026-11-25, [#37097](https://github.com/objectstack-ai/objectstack/issues/37097), built by [#37256](https://github.com/objectstack-ai/objectstack/pull/37256)) — items 2 and 9: the hash covers the organization of a document that has one.** Item 2's hash covers the document as the service assembles it. The parenthesis "content, title, metadata" was everything assembly set on a document, its identity aside, when item 2 was accepted. Item 9 adds `organizationId` to the assembled document when the document has one, and the hash covers it then. A document without one hashes byte for byte as it did before, so the version prefix is not bumped.
322+
>
323+
> - **Why.** A document that gains an organization, loses it or moves to another one gets a new hash, so a complete reindex never leaves a stale organization on a stored document. The other answer kept the parenthesis and bumped the version. It leaves a later change of organization to the events alone, and missed events are the hole reconcile exists to close (K1).
324+
> - **A later optional member that assembly sets** enters the hash the same way, left out when it is absent, or the version is bumped.
325+
> - **What an adapter stores.** An adapter that stores `docHash` stores `organizationId` from the same version on; otherwise, once it starts reading this field, a complete reindex skips its documents and a walled search never ranks them.
326+
>
327+
> Item 9's first reader, #37097, is built by PR #37256, and this change to item 2 lands with it. The reasoning is contract review [`7157191417`](https://github.com/objectstack-ai/objectstack/pull/37256#issuecomment-7157191417) on that PR (its M1 and S2). The table is left as written; read items 2 and 9 with this note.
328+
320329
**What "capabilities" became.** #36990's rule named "capabilities" among the members that waited for this record. Two things answer it. A method that is absent is the capability signal for listing, dropping, status, and the start and end of a build: the service asks whether the method is there. One flag covers what a method cannot say, `capabilities.chunks` (item 5). No wider descriptor is added.
321330

322331
**What counts as a member** (for rule 5 below, and for the epic's "no new adapter-contract member"). A member is anything an adapter author must read to be correct:

0 commit comments

Comments
 (0)