Repository navigation
Commit 8032d95
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
320 | 329 | | |
321 | 330 | | |
322 | 331 | | |
| |||
0 commit comments