Skip to content

docs(adr): ADR-0161 — the knowledge platform boundary; knowledge_source becomes a governed metadata type - #37119

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-37001-knowledge-platform-adr
Nov 24, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-37001-knowledge-platform-adr

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Fixes #37001
Clause-②: no
Metadata-protocol: none

This PR is one decision record and its index row. It changes no file outside docs/adr/, and no schema, contract member or behaviour.

Sequencing: draft PR #37115 holds record number 0160 and also regenerates docs/adr/README.md, so the two pull requests conflict on that one generated file and on nothing else. Whichever of the two lands second merges main and re-runs pnpm adr:index. This record takes 0161.

维护者速读

  • 用户能看到什么变化:用户无感。这是一份决定记录:平台自己负责把记录组成文档、保持索引与数据一致、按结构切分、按记录返回结果;向量化调用、混合检索、重排、文件解析仍交给外接的检索后端;「知识源」变成随应用发布、可在界面里配置的受管配置。
  • 为什么做:属于「知识检索平台化」专题的第一阶段,给后面每一项开发定下边界和接口形状,也让制度问询这类应用不必再自己写向量代码。
  • 出错会怎样:只是一份文档,合并后不改任何行为;写错的地方会带偏后续的开发任务,可以再改这份记录,也可以直接撤回这次合并。
  • 要你做什么:对下面 3 个问题逐个表态(认可草稿的写法,或划掉),再批准并手工合并;合并即认可文中另外两处由记录自己定下的写法(知识源可不写检索后端;接口清单第 8 项多定的 indexStatus / beginBuild / completeBuild / recipe hash)。契约审核 PASS:记录 7145632759,Head-sha 4fa0cdc5710d645580d23a914f4d55e67ed3a5a4。

What changes

  • New record docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md, Status Proposed, with a ## Provenance section naming objectstack-ai/cloud#4960 and the cloud record it produced.
  • It answers the card's seven items in order (K1 to K9 in the record): the boundary and the texts it revises; what it supersedes, by name; the admission of knowledge_source under ADR-0088 with its v1 keys; the ADR-0087 dispositions for two renames and three removals; the index fingerprint and generations; the contract additions; one search_knowledge definition for every transport.
  • K8 answers the sixteen items of the contract input (comment 7142505760 on the card) one by one: accepted, deferred or refused, each with its final shape and the phase-2 card that first reads it, and says which keys count as contract members. The execution table follows the epic's current layout.
  • docs/adr/README.md is regenerated by pnpm adr:index (one row, three counts).
  • No adapter-contract member is added, no key is added or removed, and none of the revised docs or code notes is edited: each is rewritten by the child whose code makes the new sentence true.

Second round, after the contract review on this PR at head 7e71f545 (verdict FAIL): K8 and Execution are rewritten against the contract input; K7 names whose embedder is hashed, hashes the applied split, adds the recipe hash as the trigger for repair inside a generation, and refuses a mismatched search; K1 says what the push door becomes; K4 gains the one-name rule across the two doors, the authoring permission and source admission at save, and makes adapter optional from row 3 on the input's item 11.

Third round, after the delta review at head ccaf28f1 (verdict PASS, one should-fix and three nits): a build is opened by beginBuild, a call beside completeBuild; the states that start a rebuild gain the index with no recipe hash and the adapter with no indexStatus; item 8 lands whole in the first of #37099 and #37100 to merge; a search over several sources answers from the ones it can search and names the refused ones; the record says where a run-time change of an egress declaration is picked up and how the deployment's adapter is known.

Read first, by risk:

  1. K8: the sixteen-item table, and what counts as a member.
  2. K7: the fingerprint's sources, the three states that start a rebuild, and rules 3 and 4.
  3. K4: the v1 key table, point 1 with its cost, the optional adapter, and the two guards on authoring.

Questions for the maintainer

The card's seven items, the maintainer's words, the contract input and the cloud record do not settle these three. The record marks each ▲ where it stands. They are the maintainer's to rule on in review; merging the record as written accepts what it writes.

Question 1. Record point 1: the fate of the runtime-registration file and http source shapes, and of the push door (indexDocument, deleteDocument). The card asks for the fate and names the rule (one strict contract) but not the fate.

  • A (written in the record, marked ▲): both arms retire with the type's admission, with an ADR-0087 disposition, and the two push methods leave the service contract with them; all of it returns later as one designed arm with a parsing adapter
  • B: keep one key-less arm for a corpus an external engine ingests, with the push door as its write door
  • C: keep the two shapes as code-only registrations beside the governed type

Recommendation of the session that wrote the record: A. Ruling D2 (a type referencing objects), the v1-key rule (prefix, mimeTypes, urls, userAgent have 0 readers) and Prime Directive 12 leave no other consistent answer; C is a second contract. What A costs, in full: a corpus ingested outside the platform has no v1 form; indexDocument and deleteDocument leave IKnowledgeService (0 callers in this tree, tests aside); and the clauses that two phase-2 cards build for the two arms (#37103 item 3, #37097 item 1) are removed by row 3. Whatever the answer, the two push methods are refused on an object source.

Question 2. Record point 2: what does "content recipe" cover in the index fingerprint? The card names the component without defining it.

  • A (written, marked ▲): the object, the ordered content list and the assembly rule's version. where and metadataFields go to a second hash, the recipe hash, whose change starts one complete rebuild inside the same generation
  • B: also metadataFields in the fingerprint
  • C: also where in the fingerprint

Recommendation of the session that wrote the record: A. The fingerprint answers whether stored vectors can be ranked against new ones, and neither where nor metadataFields changes a vector. B or C needs no recipe hash for those keys, at the price of re-embedding the whole source on every such change.

Question 3. Record point 3: after the type lands, does registration in code (the plugin's sources option and registerSource) stay?

  • A (written, marked ▲): it stays as a second door for the one schema and parses with it; one name is one source, so a registration from one door never replaces a source that arrived through the other (a coded refusal)
  • B: it is closed once every source can be metadata

Recommendation of the session that wrote the record: A. The epic's phase 2 registers sources in code, and tests and code plugins need the door; one strict contract is one shape, not one door. The record leaves the later closing open, so B needs no rewrite.

The earlier question on whether a source must name its adapter is no longer a question: the contract input (item 11) leaves it to the record, and the record decides it (optional from row 3; an omitted adapter means the deployment's adapter).

◆ These are decided here, on the contract input (comment 7142505760: "the ADR decides the final shapes"). They are listed so that the approver sees each choice in one place.

The input's item What this record decides
5 the chunk's final keys, with the service setting its id; the flag is capabilities.chunks
6 one embedding descriptor on the adapter (model, dimensions, maxInputTokens, variant), read at use
8 three parts: the expected fingerprint and recipe hash on every call; indexStatus; beginBuild and completeBuild, the first of which is what opens a generation. All of it lands in one PR, the first of #37099 and #37100. Parts (b) and (c) and the recipe hash go past the input's words
10 split lives on the object arm, as source.split
11 adapter becomes optional in row 3; an omitted one means the deployment's adapter
13 no grouping member now
15 no query-prefix member; an adapter option
(the review's finding on the push door) indexDocument and deleteDocument are refused on an object source
(the review's finding on a search over several sources) the searchable sources answer and each refused source is named; refused whole only when none can be searched (K7, rule 5)

Tests

No code changes, so no test changes and no ablation. A docs-only record.

Acceptance notes

  • The cloud repository was not readable from the writing session. Every statement about the cloud record is taken from two comments on this tracker, both cited in the record's Provenance.
  • The dispatch asked for a file and line on every quoted text. docs/adr/** refuses line anchors (check:adr-symbol-anchors), so the decision text cites files and symbols, and the positions are in the record's Readings table in words, repeated below.
  • The first readings were taken at 254e396a29, the rows added for the contract section at b49a264a10; no file in the table differs between the two commits.
  • K8's item 8 goes past the contract input's words in three members (indexStatus, beginBuild, completeBuild) and in the recipe hash; the record says so in the table and in its list of decisions. With the status member, service-knowledge: a source that was never built gets built, and an operator can start a rebuild #37099 waits for this record, which its Blocked-by line does not say today.
  • No entry under scripts/adr-anchors/ is added: the gate asks for none on a new record, and anchors belong to the implementing cards.
  • The cloud record owes a one-line pointer back to this number; that is the cloud lane's, after this merges.
  • Observed, not filed: once embedding and vectorStore leave the source, EmbeddingModelSchema and VectorStoreSchema have no composer in the spec. The record names it as the type-admission card's finding.

Verification

Two-minute check: pnpm check:adr-symbol-anchors && pnpm check:adr-anchors && node scripts/check-adr-links.mjs && pnpm check:adr-index. Expected: four green verdict lines.

Local gate readings at 4fa0cdc
Readings, taken at 254e396 and b49a264

Each text this record quotes was read on objectstack-ai/objectstack main at 254e396a29. The rows added for the contract section (the last eight) were read at b49a264a10, the main this record's branch has merged; no file in this table differs between the two commits. The numbers are a dated reading for the card, not anchors; the decision text cites symbols and files.

File What was read Position at 254e396a29
content/docs/protocol/knowledge.mdx the opening, "ObjectStack does not ship its own RAG engine." lines 7 to 10
same §1, "We have nothing distinctive to add to those layers." line 45
same §1, "The protocol scopes the framework's responsibility to (1)–(4)" lines 60 to 61
same §3.1, "It is stored as metadata (versioned, environment-scoped)" lines 111 to 113
same §3.2, "The framework does not chunk; adapters do." lines 162 to 163
same §3.4, "The adapter surface is deliberately minimal" lines 217 to 220
same §5, a '*' member "meaning every field the object declares except id" lines 310 to 311
same §5, sensitive fields go in a separate source lines 322 to 324
same §6, "that surface stays unbuilt until a real object source calls for it" lines 397 to 399
same §7, the knowledge-pgvector row; §8, KnowledgeSource.embedding line 430; lines 449 to 452
content/docs/ai/knowledge-rag.mdx "File / HTTP hits pass through (ACL is the adapter's problem)"; "Why we did not build a vector DB" line 78; line 82
packages/spec/src/ai/knowledge-source.zod.ts the class note, "the shape of a runtime registration, ⛔ not a governed metadata type" lines 104 to 123, the sentence at 105 to 106
same contentFields and its * note; the file arm; the http arm lines 63 to 67; 80 to 87; 89 to 96
same the cron note, "this slot is parsed and reaches no engine"; id; embedding; vectorStore; aiExposed lines 36 to 37; 125 to 126; 140 to 144; 145 to 149; 159 to 160
packages/spec/src/ai/embedding.zod.ts the file note, "NOT in scope" and "These were removed in v1" lines 15 to 23
packages/spec/src/contracts/knowledge-adapter.ts "The surface is deliberately minimal"; the interface lines 18 to 20; 56 to 74
packages/spec/src/ai/knowledge-document.zod.ts the file note; the chunk note; permissions lines 10 to 13; 53 to 57; 45 to 50
packages/spec/src/contracts/embedder.ts IEmbedder lines 26 to 39
packages/spec/authorable-surface/ai.json the five keys of K6 lines 239, 245, 246, 250 and 322
packages/spec/src/data/ai-read-exposure.ts "Any other object is refused" lines 32 to 37
packages/services/service-knowledge/src/knowledge-service.ts the class note, "Non-responsibilities (the parts plugins own)" lines 88 to 89
same registerSource, no parse; reindexSource, with its file and http answer, its one find and its one upsert lines 123 to 131; 161 to 219, with 168 to 178, 192 to 196 and 210 to 212
same search; handleRecordUpsert; objectSourcesFor; documentIdFor lines 235 to 280; 290 to 304; 550 to 557; 560 to 562
same recordToDocument, with the '*' branch and the title lines 578 to 615, with 591 to 595 and 612
packages/services/service-knowledge/src/knowledge-service-plugin.ts the three deferral comments of K3 lines 250 to 260; 296 to 299; 312 to 321
packages/services/service-knowledge/src/knowledge-tools.ts the aiExposed note; the definition; the executor lines 22 to 33; 148 to 160; 246 to 284
packages/services/service-knowledge/src/knowledge-source-admission.ts admitSourceFields from line 228
packages/plugins/knowledge-memory/src/index.ts the paragraph split with a soft 800-character cap lines 17 to 18, and 104
packages/plugins/knowledge-ragflow/src/index.ts extractRagflowOptions; one chunk per document lines 67 to 85; 113 to 139
packages/mcp/src/mcp-http-tools.ts registerKnowledgeTools and its call lines 3514 and 3182
packages/runtime/src/domains/mcp.ts the knowledge seam under data:read lines 262 to 271
packages/spec/src/contracts/knowledge-service.ts indexDocument and deleteDocument on IKnowledgeService lines 93 and 95
packages/services/service-knowledge/src/knowledge-service.ts indexDocument and deleteDocument hand the caller's document to the adapter lines 147 to 157
same in search, an adapter failure is logged and the search goes on lines 270 to 274
same isNonObjectSourceHit, and the two places that pass such a hit without a re-read lines 526 to 529; 480 and 515
packages/spec/src/contracts/knowledge-adapter.ts AdapterContext; AdapterSearchOptions with its opaque filter lines 31 to 38; 41 to 50, filter at 47
packages/spec/src/ai/knowledge-document.zod.ts the keys of KnowledgeChunkSchema: id, documentId, index, content, metadata lines 58 to 69
packages/plugins/knowledge-ragflow/src/index.ts the four adapterConfig keys the adapter reads lines 50 to 58 and 67 to 85
packages/spec/src/kernel/platform-capabilities.ts; packages/services/service-settings/src/manifests/knowledge.manifest.ts; examples/app-showcase/src/coverage.ts PLATFORM_CAPABILITY_TOKENS; the chunk_target and chunk_overlap settings; KIND_COVERAGE from line 31; lines 105 to 112; line 52

Readings that are counts: no file under packages/services/service-knowledge/src, packages/plugins/knowledge-memory/src or packages/plugins/knowledge-ragflow/src, tests aside, reads prefix, mimeTypes, urls, userAgent, a source's embedding or vectorStore, refresh.cron, or a document's permissions (0 matches each; the controls adapterConfig and contentFields match 3 and 6 times in the same three directories). indexDocument and deleteDocument have no caller outside their declaration and their implementation, tests aside (0 matches), and KnowledgeChunkSchema has no reader (its one other mention is a type-alias pin). Nothing under examples/ registers a knowledge source: 0 matches for KnowledgeServicePlugin, against 38 files that match the control defineStack; examples/app-todo lists the two knowledge packages as dependencies and imports neither.

Readings from the tracker: the contract input is comment 7142505760 on #37001, and the cards it names (#37096 to #37103 and #37107) were read in full, with the epic's body as it stands after its phase-2 rewrite. The retirement of knowledge-ragflow is card #37004 and ruling 7134290286 on #36839. #4606 has no comment, and its judgements are in its body. The ruling on #4672 is comment 5194621834; it was relayed by the services lane's PM and names the maintainer. The 2026-11-15 words are in the body of #33933 and are restated in comment 7134104071.


Generated by Claude Code

…ource admission

Proposed record. The platform owns document assembly, sync and reconcile,
structural split and record-level return; adapters own embedding calls,
hybrid retrieval, rerank and file parsing. knowledge_source is admitted as
a governed metadata type under ADR-0088. The index row is regenerated by
adr:index. No file outside docs/adr/ changes.

Claude-Session: https://claude.ai/code/session_01QSeKYpRrYuqSLCvbSk9zrL
Co-authored-by: Claude <noreply@anthropic.com>
…d controls

Bare symbol spans become path-qualified anchors or plain names, two
paraphrases that stood in quotation marks are unquoted, the zero-reader
counts name their controls, and the execution table says which open
points wait on a ruling.

Claude-Session: https://claude.ai/code/session_01QSeKYpRrYuqSLCvbSk9zrL
Co-authored-by: Claude <noreply@anthropic.com>
An open pull request holds 0160 for another record, so this record moves
to the next free number: the file is renamed, the title line follows, and
the index is regenerated by adr:index. The record's text is unchanged.

Claude-Session: https://claude.ai/code/session_01QSeKYpRrYuqSLCvbSk9zrL
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 24, 2026
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation labels Nov 24, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL

Final head for L1 (2026-11-24T20:34Z): 7e71f5451ceea55679accb5c3a60dce977b43f67 — check-runs on it: 26 success, 23 skipped, 0 failure, 0 pending; mergeable state clean. Area: a4-K.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 7e71f5451ceea55679accb5c3a60dce977b43f67
Local-runs: none
Scope: docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md, docs/adr/README.md + none
Security-touching: yes

Read: card #37001 body and all 8 comments (incl. the cloud confirmation 7136374724 and the maintainer's contract input 7142505760), epic #37000 body, its 4 comments and its 20 children's bodies, PR #37119 body, its one comment, its 2-file net diff against main, and the 49 check-runs on this head (26 success, 23 skipped, 0 failure, 0 pending). The cited code was read in the tree at this head, never reviewed. Not read (outside the brief's inputs, so the quotations stand unverified by this record): #4606, #4672, #33933, #34830 comment 7136912027, #37004, the cloud repository.

① Derived judgments

The diff changes no accept-set and no published surface today; it commits the platform to the following, each judged against the rulings and the live tree.

  • K1 boundary (platform: assembly, sync and reconcile, structural split, record-level return; adapter: embedding calls, hybrid retrieval, rerank, file parsing) — RIGHT. It is ruling D1 word for word, and the "today" readings hold (recordToDocument assembles, knowledge-memory splits at a soft 800, knowledge-ragflow posts one chunk, IKnowledgeAdapter is upsert / search / delete / healthCheck).
  • K4 knowledge_source admitted as a metadata type on the one schema KnowledgeSourceSchema — RIGHT (ruling D2; ADR-0088's three clauses, see ④).
  • K4 v1 key set, unknown key refused — RIGHT in rule (ADR-0049 / ADR-0078). The enforcer column was spot-checked: embedding, vectorStore, refresh.cron, prefix, mimeTypes, urls, userAgent have no reader; registerSource stores without a parse. One imprecision: extractRagflowOptions reads four adapterConfig keys (datasetId, rerankModel, similarityThreshold, vectorSimilarityWeight), not datasetId alone (N1).
  • K5 content is a non-empty list, '*' refused at parse — RIGHT (ruling D5); this narrows today's accept-set and K6 carries it.
  • K6 renames id to name, contentFields to content; removes embedding, vectorStore, refresh.cron — RIGHT. All five are on packages/spec/authorable-surface/ai.json; id already carries the snake_case regex, so the rename is value-lossless as claimed and no document id moves.
  • K6 file / http arms retired (point 1) — a narrowing the rulings do not order; the maintainer's (③ Q1). The loss statement is incomplete (S1).
  • K7 one fingerprint of five components, a changed fingerprint is a new generation — RIGHT as a rule, INCOMPLETE as specified (S2).
  • K8 the closed list of adapter-contract additions with first readers, plus rule 5 and K10 rule 2 ("after it, only K8's list") — WRONG as written: the list disagrees with the maintainer's input on the card and with the phase-2 cards that are its first consumers (M1).
  • K9 one search_knowledge definition, aiExposed at the tool layer, every knowledge tool through the registry and the MCP seams, removed-hit count never returned — RIGHT (ADR-0149 D2, cloud ADR-0119 requirement 1, the epic's rulings).
  • K2 / K3 texts revised and positions superseded, each rewritten by the child whose code makes it true — RIGHT in form; this PR edits none of them.
  • docs/adr/README.md — RIGHT: one row, 160 to 161 records, 155 to 156 numbers, Proposed 8 to 9; generated, and the index gate is green on this head.

② Semver level

Clause-②: no — correct. The diff is two files under docs/adr/; nothing under packages/ or any published artifact moves, so there is no semver level and no changeset is owed. skip-changeset is the right label and Check Changeset concluded success on this head. Metadata-protocol: none is right for this PR; K6's statement that row 3's PR carries Metadata-protocol: narrowed, the (narrowing) arm and a registered ADR-0087 entry is the correct forward declaration.

③ Boundary flags

Dev flags.

  • Symbols and files in the decision text, positions in a Readings table in words, against the dispatch's "file:line on every quote" — ANSWERED: correct; docs/adr/** refuses line anchors and the anchor gates are green.
  • Overlap with draft PR docs(adr): ADR-0160 — record-scoped AI inquiry: the ai_context type, get_record_context, conversation focus, ask_ai, skill context, citation shape #37115 on docs/adr/README.md, record number 0161 while 0160 is unlanded — ANSWERED: acceptable; the body's Sequencing line states the rule (second to land merges main and re-runs pnpm adr:index). No finding.
  • Cloud facts taken from two tracker comments only — ANSWERED: stated in Provenance; the requirements quoted from 7136374724 match that comment.
  • The PR comment 7143757968 says "the record is written to the recommendation" at each point. That is not true of point 2: the record writes A (decide nothing) and the body recommends B. The body itself is accurate; the maintainer should read the body, not that comment (N2).

The four "Questions for the maintainer" — ESCALATED, all four are the maintainer's. This record's view of each recommendation and of whether the text takes either answer:

  • Q1 file / http shapes, recommendation A (retire with the type) — SOUND in direction: zero readers of the four keys, hits of such sources skip the permission re-read (isNonObjectSourceHit), and a code-only second shape is a second contract. Not sound as argued: the record says the only loss is a corpus ingested outside the platform, and misses IKnowledgeService.indexDocument / deleteDocument, the on-platform push door those arms are the registration for (S1). Either answer applies locally: A is K4 point 1 plus one K6 family; B or C strikes that paragraph and that K6 sentence, nothing else moves. If A stands, service-knowledge: search returns records, not chunks — granularity and groupBy #37103's file / http grouping clauses and service-knowledge: documents carry their organization, and search hands the caller's organizations to the adapter #37097's "absent for file / http" clause build for arms row 3 removes.
  • Q2 must a source name its adapter, recommendation B (optional, deployment default), record writes A (undecided, rule before row 3) — SOUND, and less optional than the record says: the epic's "Done when" (one metadata source on os dev, hosted and PostgreSQL) cannot hold while Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL #37102 mounts pgvector or turso by database and adapter is required. B is additive and touches no other decision. C is not free: it needs a K6 removal row and a home for per-source adapterConfig (knowledge-ragflow needs datasetId per source). The record should say so beside point 2.
  • Q3 "content recipe" in the fingerprint, recommendation A (object, ordered content, assembly rule version; not where, not metadataFields) — SOUND for the question the fingerprint answers (vector comparability), but only with a named trigger for the in-generation repair, which the record does not give (S2c). B or C is a one-row edit of K7; nothing else moves.
  • Q4 registration in code stays, recommendation A — SOUND: the epic's phase 2 registers sources in code, and "one strict contract" is one shape. The record already leaves the later closing open, so B needs no rewrite. Missing: what happens when one name arrives through both doors (S3).

SQL push-down check (Prime Directive 5): the record prescribes an enumerate-then-diff purge (K8 item 1) and a per-hit re-read as the caller. Not a finding: the index is adapter-owned behind a contract and may sit in another store, so the anti-join cannot be pushed down in general. The record does not state that reason; row 2 and row 15 should (N3).

④ Design judgment

The seven card items. All seven are present: 1 boundary and revised texts (K1, K2); 2 supersessions by name (K3); 3 ADR-0088 admission, v1 keys, file / http fate (K4); 4 ADR-0087 dispositions (K6); 5 fingerprint and generation (K7); 6 contract additions with first readers (K8); 7 one search_knowledge definition, aiExposed at the tool layer (K9). Status Proposed, ## Provenance names objectstack-ai/cloud#4960. Item 6 lands in form and fails in content (M1).

Against the other records. No contradiction found with ADR-0087 (K6 uses conversion entry, retiredKey() tombstone, registry row, one D3 entry per family, and the amended refusal of not-required (no-migration-prescription) on a declared narrowing), with ADR-0149 D2 (one definition, one executor, every transport), with cloud ADR-0119 as quoted in 7136374724 (tool seams: K9 rule 4; field egress: K5; both stores open; MCP-only open door), or with Prime Directives 7, 10, 12, 13. The epic's six "Rulings that bound every child" are all carried in K10.

ADR-0088 admission. Sound. Clause 1: a source has its own name, its own index and generations, and binds by source.object; this is not the validation case of ADR-0088's 2026-08 addendum, which failed because the engine read only the object-embedded shape and the item had no binding key (the record should say so in one sentence, N4). Clause 2: file loader plus allowRuntimeCreate, overlay left at the registry default. Clause 3: the knowledge service, landing with the type in row 3's one PR; BrightRule is the waiting application. Two gaps for row 3, neither against admission: S4 (the authoring guard) and N5 (the example the registry-driven showcase coverage will demand).

M1 (must-fix) — K8's list does not match the maintainer's input on the card nor the phase-2 cards that read it, and K8 rule 5 with K10 rule 2 make that mismatch binding. Comment 7142505760 on #37001 is headed "Input for this ADR's contract section" and says "the ADR decides the final shapes"; the record cites it nowhere and none of listDocuments, docHash, headingPath, maxInputTokens, queryPrefix or a phase-2 card number appears in it. On acceptance as written:

S1 (should-fix) — the direct-push door is not in the design. IKnowledgeService.indexDocument(sourceId, doc) and deleteDocument hand a caller-built KnowledgeDocument straight to the adapter. K1 ("One function decides. No adapter builds a document from a record") and K5 ("a field the field-egress declaration withholds never enters a document") are not true of an object source while that door takes it, and with the file / http arms gone an object source is the only target left. #37098 already plans for "a document indexed directly". The record must say what the door becomes (refused on object sources, removed, or kept for a designed non-object arm) and Q1 must name it as part of what A costs.

S2 (should-fix) — the fingerprint rule is not complete.

S3 (should-fix) — two doors, one name. registerSource overwrites an existing id with a warning. Once a governed item and a code registration can carry the same name, that is a silent override of governed metadata. Point 4 should require a refusal and leave the wording to row 3.

S4 (should-fix) — authoring a source is an egress and cost decision with no stated guard. K4 clause 2 opens runtime authoring through Studio and MCP; K5 says the listed fields leave the row store and #37099 says a first build sends the whole source to the provider. The record should bind row 3 to state which permission admits authoring and that PR #36850's source admission is evaluated for a newly authored item, not only at search.

Nits. N1 adapterConfig reading (above). N2 the PR comment's "written to the recommendation" (above). N3 the push-down reason. N4 one sentence on the validation precedent. N5 row 3's carry list omits the example / showcase kind coverage ADR-0088's Consequences describe. N6 ADR-0087 D7 (a TS-only surface is compiler-carried) is the alternative reading for K6's code-door half; K6 item 3 leaves it to row 3, which is acceptable, but it should be named.

Implemented-by: claude/issue-37001-knowledge-platform-adr
Reviewed-by: fresh subagent of session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: FAIL

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — REWORK · L1 · head 7e71f5451ceea55679accb5c3a60dce977b43f67 · 2026-11-24T20:41Z

Requested by zone a4-K (7143757968) for card #37001. Beside the contract review at this head (CONTRACT_REVIEW_TIER): FAIL, M1 must-fix, S1–S4 should-fix — every finding in that record is part of this REWORK.

Form holds: Status Proposed, Provenance names objectstack-ai/cloud#4960 and cloud ADR-0119 by path, the index row and counts are right, in-page anchors resolve; all seven card items are present as K1–K9; no contradiction with ADR-0087, ADR-0088 (admission sound on all three clauses), ADR-0149 D2, cloud ADR-0119's requirements (7136374724) or the one-strict-contract rule; skip-changeset and Clause-②: no are right. Check-runs: 26 success, 23 expected skip, 0 failed.

The REWORK, in the record's ids:

The four maintainer questions stay in the PR body for the hand-off; the record judges each recommendation (Q1 sound once S1 lands; Q2 sound; Q3 sound once S2's repair trigger is named; Q4 sound). Delta contract review and delta L1 on the new head, then the hand-off.

The contract section answers the maintainer session's sixteen contract
items in order, each accepted, deferred or refused, with its final shape
and the card that first reads it, and says what counts as a member. The
execution table follows the epic's current layout. The fingerprint rule
gains the adapter-reported embedder, the applied split, a recipe hash as
the trigger for repair inside a generation, and a refusal on the search
side. The record states what the push door becomes, the one-name rule
across the two doors, and the two guards on authoring a source.

Claude-Session: https://claude.ai/code/session_01QSeKYpRrYuqSLCvbSk9zrL
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l and removed size/m labels Nov 24, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL

Final head for delta review (2026-11-24T21:15Z): ccaf28f1847aa1b881ef7dc08defeaf96a151b78 — check-runs on it: 26 success, 22 skipped, 0 failure, 0 pending; mergeable state clean; draft, no auto-merge. Area: a4-K.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ccaf28f1847aa1b881ef7dc08defeaf96a151b78
Local-runs: none
Scope: docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md, docs/adr/README.md + none
Security-touching: yes

Delta review of the record at head 7e71f5451ceea55679accb5c3a60dce977b43f67 (comment 7143922684, FAIL: M1, S1 to S4, N1 to N6). Read: the delta 7e71f5451ce..ccaf28f1847 (one commit, one file, +181 / -100; docs/adr/README.md unchanged), with K1, K4 to K10, Execution, the Points section, Consequences and the TL;DR read whole at the new head; the PR body and its 4 comments (incl. the zone's announcement 7144701539); card #37001's body and 9 comments (incl. the contract input 7142505760 and the dev's map 7144476497); the epic #37000's body; the bodies of #37096, #37097, #37098, #37099, #37100, #37101, #37102, #37103 and #37107; the 48 check-runs on this head (26 success, 22 skipped, 0 failure, 0 pending). The cited code was read in the tree at this head, never reviewed. Not read: #37093 to #37095, #37104, #37004, #36993, #4606, #4672, #33933, the cloud repository; what the record says of them stands unverified here.

① Derived judgments

The diff still changes no accept-set and no published surface. What moved since the prior head, each judged against the contract input, the phase-2 cards and the tree:

② Semver level

Unchanged and still correct. Clause-②: no; two files under docs/adr/; no semver level; no changeset owed; skip-changeset is right. On this head both Check Changeset runs concluded skipped (on the prior head one concluded success); neither failed, and no check on this head failed or is pending. Metadata-protocol: none is right for this PR; K6's forward declaration for row 3 (narrowed, the (narrowing) arm, registered ADR-0087 entries) stands.

③ Boundary flags

The zone's two points (comment 7144701539), ruled:

Dev flags (comment 7144476497):

The three "Questions for the maintainer" — ESCALATED, all three are the maintainer's, each with options and a recommendation, and the record takes either answer locally:

  • Q1 file / http and the push door, recommendation A — SOUND, and the cost is now stated in full (the off-platform corpus, the two push methods, the two card clauses).
  • Q2 what "content recipe" covers, recommendation A — SOUND now that the recipe hash names the trigger; B or C drops the recipe hash for those keys.
  • Q3 registration in code stays, recommendation A — SOUND, with the one-name refusal.

SQL push-down check (Prime Directive 5): the reason is now in K1 (the index may sit in another store; the adapter-side form returns as item 13 with its reader). No finding.

The dev's two claims about other cards, verified. Outside the graded findings; both are the epic owner's card edits.

④ Design judgment

The prior findings, by id.

  • M1: closed. K8 answers 7142505760 item by item and cites it by id. (a) dropSource is accepted and deferred to row 3, and service-knowledge: adapters list their documents; a complete reindex skips unchanged documents and purges the ones its source no longer has; one contract test suite #37096's row carries items 1 and 2 only. (b) KnowledgeDocument.docHash, KnowledgeHit.docHash, KnowledgeHit.headingPath, the adapter's embedding descriptor with maxInputTokens, IEmbedder.model, IEmbedder.maxInputTokens and the knowledge token are in the table with the cards as readers; rule 4 now reads "what an adapter reports, never how it is configured". (c) The organization members read first by service-knowledge: documents carry their organization, and search hands the caller's organizations to the adapter #37097 with knowledge-memory; listing is signalled by method absence with purged: null; the one flag is capabilities.chunks in service-knowledge: one service-layer splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key #37098. (d) Items 10 and 15 are decided and marked. (e) The adapter owns its generations (K7 rule 2). (f) Execution follows the epic's current tables, and knowledge-ragflow is out of the suite. "What counts as a member" settles rule 5's reach, so no phase-2 card the epic accepted needs a dated note to land what its text already names.
  • S1: closed. K1 "The push door", K4 point 1's cost list, K5, K6, and the PR body's question 1.
  • S2: closed. (a) "Whose embedder" and the descriptor's variant. (b) The resolved maxChars and minChars are hashed. (c) The recipe hash and the three-state table, read at boot and on a source reload. (d) K7 rule 4. What the fix added is judged as S5.
  • S3: closed. K4 point 3: one name is one source; the second arrival through the other door is refused with a coded refusal; a metadata item reloading itself is not a second arrival.
  • S4: closed. K4 "Authoring a source is an egress decision and a cost decision": a named permission, the same at every door, and source admission at save as the authoring principal, each pinned by row 3.
  • Nits: N1, N3, N4, N5, N6 closed in the text. N2 closed by the correction in 7144701539 and by point 1 above.

New in the delta.

S5 (should-fix) — the build lifecycle that item 8 adds is not complete. It is new contract text past the input's words, and K8 rule 5 closes the list, so a gap found by #37099, #37101 or #37107 costs a dated Tier H note.

Nits. N7 K7 rule 4 does not say what a search over several sources answers when one source is refused (the whole call refused, or the rest answered with the refusal reported); name the owner (#37100 or the service). N8 the recipe hash covers "withheld by the field-egress declaration" but is re-read only at boot and on a source reload, so a declaration changed at run time is not seen until then; the egress record should carry that trigger. N9 row 3 says how the service knows the deployment's adapter when several are mounted.

M1: closed. S1: closed. S2: closed. S3: closed. S4: closed. S5: open (should-fix, new in this delta). No must-fix.

Implemented-by: claude/issue-37001-knowledge-platform-adr
Reviewed-by: fresh subagent of session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — REWORK · L1 · head ccaf28f1847aa1b881ef7dc08defeaf96a151b78 · 2026-11-24T21:23Z

Delta L1 for card #37001, beside the delta contract review at this head (CONTRACT_REVIEW_TIER): PASS, M1 and S1–S4 closed, N1–N6 closed, one new should-fix S5.

A build is opened by a call beside the one that ends it, never guessed
from a write. The states that start a rebuild gain the index that holds
no recipe hash and the adapter that reports no status. The index stamp,
the status and the two build calls land in one change. A search over
several sources answers from the ones it can search and names the rest.
The record says where a run-time change of an egress declaration is
picked up and how the deployment's adapter is known.

Claude-Session: https://claude.ai/code/session_01QSeKYpRrYuqSLCvbSk9zrL
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpRrYuqSLCvbSk9zrL

Final head for delta review (2026-11-24T21:49Z): 4fa0cdc5710d645580d23a914f4d55e67ed3a5a4 — check-runs on it: 26 success, 22 skipped, 0 failure, 0 pending; draft, no auto-merge. Area: a4-K.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 4fa0cdc5710d645580d23a914f4d55e67ed3a5a4
Local-runs: none
Scope: docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md, docs/adr/README.md + none
Security-touching: yes

Second delta review, of the record at head ccaf28f1847aa1b881ef7dc08defeaf96a151b78 (comment 7144861870, PASS: S5 open, N7 to N9). Read: the delta ccaf28f1847..4fa0cdc5710 (one commit, one file, +26 / -19; docs/adr/README.md unchanged), with K7, K8 item 8 and its rules, "What counts as a member", the Execution table and the paragraph under it read whole at the new head; the PR body and its 7 comments (incl. the zone's announcement 7145452376); the dev's map 7145136589 on #37001; the bodies and all comments of #37099 (5) and #37100 (3), incl. 7145167146 and 7144903681; the body of #37098; the 48 check-runs on this head (26 success, 22 skipped, 0 failure, 0 pending). Not re-read: everything the prior two records read and this delta does not touch; the cloud repository.

① Derived judgments

The diff still changes no accept-set and no published surface. What moved since the prior head:

  • K7 rule 3 (new) and K8 item 8 (c): a build is opened by a call, beginBuild?(ctx), beside completeBuild?(ctx) — RIGHT. It is one of the three forms S5 (a) offered, it sits inside item 8 (so the input's item 16, "no member beyond items 1, 5, 7, 8 and 9", still holds), and it is marked ◆ in K7, in the Points table and in the PR body.
  • K7 rule 4 (was 3): a mismatched write goes to the generation that only beginBuild opens, and is refused when there is none — RIGHT; the first write of a rebuild is no longer refused by the rule's own words.
  • K7 "What starts a rebuild": five states (two added) — RIGHT, and neither added state can loop or hide a change silently.
  • K7 rule 5 (was 4), a search over several sources: the searchable ones answer, each refused source is named with its code, the call is refused whole only when none can be searched — RIGHT. Fail-closed for the refused source, and the model is told, so the "nothing matched" misreading is closed.
  • Execution, "Item 8 lands whole, once", with the rows of service-knowledge: a source that was never built gets built, and an operator can start a rebuild #37099, knowledge-pgvector: an open vector store on PostgreSQL — tables, exact search, listing, chunks #37100 and knowledge-pgvector: a changed fingerprint builds a new generation and switches to it #37101 and the reader cells of items 6 and 8 — RIGHT, and coherent with the cards as they stand (④, S5 c).
  • K4 (how the deployment's adapter is known) and K5 / K7 (the run-time egress trigger) — RIGHT; each names its owner.
  • The renumbering of K7's rules 3 to 7 into 4 to 8: every reference inside the record was moved with it (Execution rows, the Points table, Consequences, the References line). One reference outside the record was not (N10).

② Semver level

Unchanged and correct. Clause-②: no; two files under docs/adr/; no semver level; no changeset owed; skip-changeset is right. Both Check Changeset runs are skipped on this head; no check failed or is pending. Metadata-protocol: none is right for this PR.

③ Boundary flags

Dev flags (comment 7145136589):

The three "Questions for the maintainer" — ESCALATED, unchanged in text and in options; the prior record's reading of each recommendation (all three sound) stands. The body's ◆ table gained item 8's new wording and the row for a search over several sources.

SQL push-down check (Prime Directive 5): the delta adds no id materialisation and no in-app join. No finding.

④ Design judgment

S5, by part.

S5: closed.

N7 to N9. N7 closed (K7 rule 5; owner #37100, or a card split from it for the service's lane). N8 closed (seen at the next boot or source reload, and not before; the run-time trigger is asked of the field-egress record). N9 closed (the runtime that mounts a store for the knowledge capability marks it as the deployment's; a code registration never is by that act alone).

No decided shape changed. Checked hunk by hunk: AdapterContext.index, AdapterSearchOptions.index, indexStatus and its three keys, completeBuild's meaning, the embedding descriptor's four keys, the recipe hash's inputs, the K4 key table, K6's dispositions and the three ▲ points are word for word or equivalent. What moved is who lands a member (items 6 and 8), never its shape. One member is added (beginBuild), inside an item that was already ◆.

No new defect at must-fix or should-fix. Nits, none of which affects correctness of the contract:

Card-side, outside the graded findings; the zone's or triage's.

M1: closed. S1: closed. S2: closed. S3: closed. S4: closed. S5: closed. N1 to N9: closed. No must-fix, no should-fix.

Implemented-by: claude/issue-37001-knowledge-platform-adr
Reviewed-by: fresh subagent of session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — ACCEPT · L1 · head 4fa0cdc5710d645580d23a914f4d55e67ed3a5a4 · 2026-11-24T21:55Z

Card #37001. Over the delta L1 REWORK at ccaf28f184 (7144881422), beside the second delta contract review at this head (7145549687, CONTRACT_REVIEW_TIER): PASS, S5 closed, N7–N9 closed, no must-fix, no should-fix.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 4fa0cdc5710d645580d23a914f4d55e67ed3a5a4
Local-runs: none
Scope: docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md, docs/adr/README.md + none
Security-touching: yes

Second delta review, of the record at head ccaf28f1847aa1b881ef7dc08defeaf96a151b78 (comment 7144861870, PASS: S5 open, N7 to N9). Read: the delta ccaf28f1847..4fa0cdc5710 (one commit, one file, +26 / -19; docs/adr/README.md unchanged), with K7, K8 item 8 and its rules, "What counts as a member", the Execution table and the paragraph under it read whole at the new head; the PR body and its 7 comments (incl. the zone's announcement 7145452376); the dev's map 7145136589 on #37001; the bodies and all comments of #37099 (5) and #37100 (3), incl. 7145167146 and 7144903681; the body of #37098; the 48 check-runs on this head (26 success, 22 skipped, 0 failure, 0 pending). Not re-read: everything the prior two records read and this delta does not touch; the cloud repository.

① Derived judgments

The diff still changes no accept-set and no published surface. What moved since the prior head:

  • K7 rule 3 (new) and K8 item 8 (c): a build is opened by a call, beginBuild?(ctx), beside completeBuild?(ctx) — RIGHT. It is one of the three forms S5 (a) offered, it sits inside item 8 (so the input's item 16, "no member beyond items 1, 5, 7, 8 and 9", still holds), and it is marked ◆ in K7, in the Points table and in the PR body.
  • K7 rule 4 (was 3): a mismatched write goes to the generation that only beginBuild opens, and is refused when there is none — RIGHT; the first write of a rebuild is no longer refused by the rule's own words.
  • K7 "What starts a rebuild": five states (two added) — RIGHT, and neither added state can loop or hide a change silently.
  • K7 rule 5 (was 4), a search over several sources: the searchable ones answer, each refused source is named with its code, the call is refused whole only when none can be searched — RIGHT. Fail-closed for the refused source, and the model is told, so the "nothing matched" misreading is closed.
  • Execution, "Item 8 lands whole, once", with the rows of service-knowledge: a source that was never built gets built, and an operator can start a rebuild #37099, knowledge-pgvector: an open vector store on PostgreSQL — tables, exact search, listing, chunks #37100 and knowledge-pgvector: a changed fingerprint builds a new generation and switches to it #37101 and the reader cells of items 6 and 8 — RIGHT, and coherent with the cards as they stand (④, S5 c).
  • K4 (how the deployment's adapter is known) and K5 / K7 (the run-time egress trigger) — RIGHT; each names its owner.
  • The renumbering of K7's rules 3 to 7 into 4 to 8: every reference inside the record was moved with it (Execution rows, the Points table, Consequences, the References line). One reference outside the record was not (N10).

② Semver level

Unchanged and correct. Clause-②: no; two files under docs/adr/; no semver level; no changeset owed; skip-changeset is right. Both Check Changeset runs are skipped on this head; no check failed or is pending. Metadata-protocol: none is right for this PR.

③ Boundary flags

Dev flags (comment 7145136589):

The three "Questions for the maintainer" — ESCALATED, unchanged in text and in options; the prior record's reading of each recommendation (all three sound) stands. The body's ◆ table gained item 8's new wording and the row for a search over several sources.

SQL push-down check (Prime Directive 5): the delta adds no id materialisation and no in-app join. No finding.

④ Design judgment

S5, by part.

S5: closed.

N7 to N9. N7 closed (K7 rule 5; owner #37100, or a card split from it for the service's lane). N8 closed (seen at the next boot or source reload, and not before; the run-time trigger is asked of the field-egress record). N9 closed (the runtime that mounts a store for the knowledge capability marks it as the deployment's; a code registration never is by that act alone).

No decided shape changed. Checked hunk by hunk: AdapterContext.index, AdapterSearchOptions.index, indexStatus and its three keys, completeBuild's meaning, the embedding descriptor's four keys, the recipe hash's inputs, the K4 key table, K6's dispositions and the three ▲ points are word for word or equivalent. What moved is who lands a member (items 6 and 8), never its shape. One member is added (beginBuild), inside an item that was already ◆.

No new finding above nit. Nits, none of which affects correctness of the contract:

Card-side, outside the graded findings; the zone's or triage's.

M1: closed. S1: closed. S2: closed. S3: closed. S4: closed. S5: closed. N1 to N9: closed. No must-fix, no should-fix.

Implemented-by: claude/issue-37001-knowledge-platform-adr
Reviewed-by: fresh subagent of session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

维护者速读

  • 定了什么:平台自己负责把业务记录组成文档、保持索引和数据一致、按结构切分、按记录返回结果;向量化、混合检索、重排、文件解析交给外接的检索后端;「知识源」成为随应用发布、可在界面里配置的受管配置。
  • 为什么:这是「知识检索平台化」专题的第一步,后面每张开发卡的边界和接口形状都以这份记录为准,应用(如制度问询)不必再自己写向量代码。
  • 写错会怎样:这次合并只进一份文档,不改任何行为;写错的地方会带偏第二阶段的开发卡,改法是在这份记录上补一条带日期的说明,或撤回这次合并。
  • 要你做什么:先对下面 3 个问题逐个表态(认可草稿的写法,或划掉),再批准并手工合并;合并即认可文中另外两处由记录自己定下的写法。

需要你裁决的三个问题(业务语言)

  1. 文件和网页这两种知识源、以及应用自己把文档直接推进索引的入口,要不要先下线?
    草稿建议:都下线(选项 A),以后带着完整设计和文件解析后端一起加回来。代价:平台外灌入的资料库在第一版没有对应写法;两个推送接口从服务里拿掉(目前没有调用方);第二阶段两张卡里为这两种知识源写的条款届时删除。无论选哪个,「对象类」知识源都不再允许直接推送文档。
  2. 哪些改动算「索引要整套重建」(重新向量化)?
    草稿建议:只有对象、正文字段列表和拼装规则变了才整套重建(选项 A);筛选条件和附带字段变了不重新向量化,系统在启动或配置重载时自动走一遍、在原索引里修补。另两个选项把附带字段、或连筛选条件也算进去:不需要修补机制,但每改一次就全量重新向量化,有费用。
  3. 知识源做成可配置项以后,还能不能在代码里注册?
    草稿建议:保留(选项 A),用同一套格式;同一个名字只能是一个知识源,从另一个入口再来一个同名的会被拒绝,不会悄悄覆盖。以后要不要关掉代码入口,留到那时再定。

由这份记录直接定下的两点(合并即认可,不认可请先划掉)

  • 知识源可以不写用哪个检索后端:不写就用部署里装的那个(从知识源做成可配置项那一步起生效,第二阶段仍必须写)。依据是你那条接口清单的第 11 项「留给这份记录和第 3 行」。哪个算「部署里装的」,由运行时在装载时标记。
  • 接口清单第 8 项比你列的多定了几样:检索后端报告自己索引的状态(indexStatus);平台通知「开始全量重建」和「全量建完了」(beginBuild / completeBuild);以及用来触发「原索引内修补」的第二个校验值(recipe hash)。评审认为这属于记录该定的接口形状,生命周期现已写全;其中第二个校验值与问题 2 绑定,问题 2 若不选 A,它对相应字段就不需要了。

Hand-off · 2026-11-24T22:00Z · @os-zhuang — PR #37119 (card #37001, ADR-0161, knowledge platform boundary) is ready for your rulings and approval. Docs only. Seat ACCEPT above at this head; contract review PASS 7145632759, Head-sha 4fa0cdc5710d645580d23a914f4d55e67ed3a5a4. After your approval the seat lands it.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 24, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Landing · 2026-11-24T22:10Z · authorized approval in place: os-zhuang APPROVED at head 4fa0cdc5710d645580d23a914f4d55e67ed3a5a4, the head the seat ACCEPT (7145588367) and the contract review PASS (7145632759) name. The maintainer, in seat repo:objectstack#4's session: 「37119 没收到维护者合并的标签,但是我刚点了同意。」

The hand-off's brief said approval accepts the record as drafted unless a question is struck; none was struck, so the three questions stand at the draft's recommendation (A each), together with the two points the record decides itself. Check-runs at this head: 28 success, 33 expected skip, 0 failed. Ready and queued by the seat; pm:awaiting-merge cleared.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 24, 2026 22:10
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 24, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

pm:awaiting-merge cleared · 2026-11-24T22:11Z · the approval it waited for is in (os-zhuang, head 4fa0cdc571); the PR is ready and armed for the queue.

@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 24, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Ruling recorded · 2026-11-24T22:12Z · the three maintainer questions in this PR's body. The maintainer in seat repo:objectstack#4's session, verbatim: 「37119 三个建议我都同意」

  1. A — the file / http source shapes and the direct-push door retire with the type's admission (ADR-0087 dispositions as the record states); an object source never takes a pushed document.
  2. A — only the object, the ordered content list and the assembly-rule version force a full rebuild; where and metadataFields changes are repaired in place in the same generation (the recipe hash is the trigger).
  3. A — code registration stays as a second door onto the same schema; a name arriving through both doors is refused, never overwritten.

This confirms the reading recorded at landing (7145908305).

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 24, 2026
Resolve the docs/adr/README.md conflict with ADR-0160 (#37115) by
regenerating the index with `pnpm adr:index`; no hand merge.

Claude-Session: https://claude.ai/code/session_01QSeKYpRrYuqSLCvbSk9zrL
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Re-landing · 2026-11-24T23:03Z · the merge queue removed this PR at 22:48Z on a docs/adr/README.md conflict after #37115 (ADR-0160) merged. New head c2bab6781b3fb6e78a29f8a395fb8d4eddffe0d0 merges main (2af9729579) into the approved 4fa0cdc571. Read by the seat:

  • The record file is byte-identical to the approved head (git diff 4fa0cdc571 c2bab6781b -- docs/adr/0161-…md is empty).
  • The only resolved file is the generated index docs/adr/README.md, regenerated by scripts/adr-index.mjs: the ADR-0161 row, the record count 161 → 162 and Proposed 9 → 10; ADR-0160 and ADR-0161 both listed. The PR's net diff against main is still these two files.

A merge-only head move keeps the approval (os-zhuang at 4fa0cdc571), the seat ACCEPT and the contract review PASS. Check-runs at this head: 25 success, 19 expected skip, 0 failed. Ready and armed again by the seat.

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 6f3a8da Nov 24, 2026
44 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-37001-knowledge-platform-adr branch November 24, 2026 23:23
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ne walk per source at a time (objectstack-ai#37129)

Fixes objectstack-ai#36992

Clause-②: no
Metadata-protocol: none

## 维护者速读
- 用户能看到什么变化:挂了知识检索的应用,管理员手动重建某个知识源时,系统改为每次读 100 条、写 100
条,大表不再一次全读进内存;同一知识源的两次重建会排队依次执行;文档和告警不再声称重建能清掉已删除记录的检索内容。
- 为什么做:知识检索平台化专题第一阶段的「数据多了也不能崩」——原来重建一次把整张表读进内存再一次性交给索引服务,数据量大时会撑爆内存或超时。
-
出错会怎样:只影响挂了知识检索服务的应用的手动重建;某一页失败时重建停在那一页并在结果里说明是哪一页,之前写入的不回退;已删除记录的旧内容仍要等「索引清理」那张卡落地才会被清掉;改动可直接撤回。
- 要你做的:无。

## What changes

`KnowledgeService.reindexSource`
(`packages/services/service-knowledge/src/knowledge-service.ts`) for an
`object` source, per card items 1-5:

- **Keyset paging by id (item 1).** The walk reads at most
`REINDEX_PAGE_SIZE` = 100 rows per `find(object, { where, orderBy: [{
field: 'id', order: 'asc' }], limit }, { context: system })`. Page 1
sends the source's `where` alone. Every later page sends `{ $and:
[where, { id: { $gt: cursor } }] }` (or just the cursor condition when
the source has no `where`), where the cursor is the previous page's last
id, kept in its own type. Each page is upserted in its own
`adapter.upsert(docs, { source, reason: 'reindex' })` before the next
read. Every `find` carries a `limit`, and no `upsert` holds more than
one page. Each row goes through the same `recordToDocument(source,
objSource, row, this.schemaFor(object))` gate the event sync uses; no
second builder was added. The system context now travels in the trailing
options argument (the `IDataEngine` contract's position) and no longer
inside the query behind an `as never` cast.
- **Only an empty page ends the walk.** A page that comes back short of
its `limit` is followed by the next read: `find` does not promise
`min(limit, remaining)` rows, because an `afterFind` hook may drop rows
from a page (`packages/objectql/src/engine-find.ts`). So a 101-row
object takes three reads, the last one empty.
- **Failure ends the run with `ok: false` and names the page (item 1).**
A read, a document build or an upsert that throws returns `{ ok: false,
object, discovered, indexed, message }`. The message reads `reindex of
source 'S' stopped at page N (after id 'X'): ...` with the cause (an
`Error`'s message, any other thrown value via `String(...)`), and the
counts cover the pages done before it. Those pages stay in the index.
Two further stops prevent an endless walk: a page whose last row has no
id, and a last id that did not move past the cursor (an engine that
ignored the id condition). Each returns `ok: false` and names its page.
Before this change, a failure threw out of `reindexSource`.
- **What is serialized, and what is not (item 1).** The record sync's
per-document promise chain from objectstack-ai#37075 is now one module-level helper,
`chainAfter(tails, key, task)`, which returns the task's own outcome
while the chain itself never rejects. `serializeRecordSync` delegates to
it unchanged in meaning, and `reindexSource` chains on a separate
`reindexTails` map keyed by source id. So a second reindex of the same
source waits for the first and their pages never interleave; different
sources still run concurrently. Record events do NOT wait for a walk. A
row updated or deleted between a page's read and that page's upsert is
written back from the older read, and a deleted row's document then
stays as a ghost until the index purge (objectstack-ai#37096). That race predates this
PR, and paging narrows its window from the whole object to one page. The
jsdoc and the changeset say exactly this.
- **`limit` / `dryRun` (item 2).** `opts.limit` keeps its total-cap
meaning: each read asks for `min(100, limit - discovered)`, and the walk
stops at the cap without an extra read. A fractional `limit` is floored.
A negative or non-finite one (`-1`, `NaN`, `Infinity`) is refused with
`ok: false` and nothing is read; before this change such a value went
straight to `find`. `dryRun` calls `count(object, { where }, { context
})`, reads no rows, and reports `min(count, limit)`.
- **Page size (item 3), my reading.** Item 3 said to match the
embedder's per-request cap until the `embedder-openai` sibling landed,
then follow it. That sibling (objectstack-ai#36995) landed as objectstack-ai#37037, and
`OpenAIEmbedder` now splits a larger input set into requests of its own
cap. So the page size is no longer an embedder-correctness bound; it
bounds memory and the size of one adapter call. I kept 100 as a module
constant and did not add an option: `KnowledgeReindexOptions` is a spec
contract, and `KnowledgeServiceOptions` is not forwarded from any config
a host writes. `REINDEX_PAGE_SIZE` is exported from the module for the
tests only and is not re-exported from `index.ts`, so the published
`dist/index.d.ts` export list is unchanged.
- **Result shape (item 4).** `{ indexed, discovered, object?, ok,
message? }` is unchanged. No fields were added, so no published type
widens.
- **No purge (item 5).** A reindex still removes no documents, and no
adapter-contract member was added. The knowledge-platform ADR (objectstack-ai#37001 /
objectstack-ai#37119) is not merged.
- **No surface claims a reindex removes documents any more.** These
sites are reworded; behaviour is unchanged. Each now says a reindex
refreshes the rows that still exist and match, and that the documents of
deleted (or no-longer-matching) rows wait for the index purge (objectstack-ai#37096):
- `content/docs/protocol/knowledge.mdx`: the predicate-write callout
("Repair such an index with an explicit `reindexSource`") and the
rolled-back-write passage (a document built from an insert that rolled
back has no row left to repair it from).
  - The same rolled-back-write passage in `handleRecordUpsert`'s jsdoc.
- The bulk-write warning in `knowledge-service-plugin.ts`. As a runtime
string it names the purge in words, with no tracker number. Its existing
pins in `event-sync-data-events.test.ts` still hold.

## Tests

`src/__tests__/knowledge-service.test.ts` adds a new top-level
`describe('KnowledgeService — the reindex walk pages by id')` (25 cases)
in the existing harness file. Its engine double throws on any `find`
without a positive `limit`, without `orderBy` id asc, or without the
system context, and on any operator it does not implement. It orders
numbers numerically and everything else by string. Rows are inserted in
shuffled order, so the walk sees only the engine's ordering.

- Boundaries:
  - 0 rows: one read, no upsert.
- Exactly 100 rows: one upsert of 100, then a page-2 read of `{ id: {
$gt: 'r099' } }` that comes back empty.
- 101 rows: upserts of 100 then 1, each row exactly once, in id order,
then a third, empty read of `{ id: { $gt: 'r100' } }`. Every read is
limited to 100, every upsert holds at most 100, and the reason is
`reindex`.
- A short page is not the end: the first full page comes back with 99 of
its 100 rows (the drop an `afterFind` hook can make), and every later
row is still upserted (pages 99/100/50, 249 rows, 4 reads).
- Numeric ids 1..150: the cursor keeps the number (`{ id: { $gt: 100 }
}`, then `{ id: { $gt: 150 } }`), and the pages follow numeric order.
- The source's `where` is ANDed with the cursor (the exact page-2
`where` is asserted).
- `limit`:
  - 150 / 100 / 30 / 0 read `[100,50]` / `[100]` / `[30]` / nothing.
  - A `limit` above the row count reads to the end.
  - 150.7 is floored to 150.
- -1, NaN and Infinity are refused with `ok: false` (plain and
`dryRun`), with no `find`, no `count` and no upsert.
- `dryRun` uses `count` under the `where`, capped by `limit`, with zero
`find` calls.
- Failures, each `ok: false` with the counts of the pages done before
it:
- A failed read on page 2 and a failed upsert on page 2: the message
names `page 2` and `after id 'r099'`, the counts are 100/100, and the
next walk after a failure runs (the lock is released).
  - A document build that throws on page 2.
  - A thrown non-`Error` is reported by its text, never as `undefined`.
- An engine that ignores the cursor ends the walk at page 2 instead of
looping. A last row with no id ends the walk after page 1.
- A concurrent second reindex of the same source makes no read while the
first one's read is held, and the upsert order is `r000+100, r100+50,
r000+100, r100+50`. Walks of different sources do not wait for each
other.

The two older reindex tests were updated for the new call shape. The
context is read from the trailing argument. `dryRun` asserts that
`count` is called and `find` is not. Their doubles now answer an empty
next page, as a cursor-honouring engine does: they used to return the
same rows for every read, which this walk now correctly reports as a
cursor that did not advance.

## Acceptance notes

- **Cursor order on a SQL driver, checked once.** The zone confirmed
that a single check is enough. `service-knowledge` cannot reach a SQL
driver: its dependencies are `core`, `objectql`, `platform-objects`,
`service-settings` and `spec`. A committed test would need
`@objectstack/driver-sql` as a devDependency plus a `pnpm-lock.yaml`
importer entry, and the lockfile is outside this PR's file surface. So
the check is a scratch measurement against this branch's source, re-run
on the current head (readings under Verification).
- `KnowledgeReindexResult.ok`'s jsdoc in `packages/spec` ("an adapter /
source check prevented the run") now also covers a failed page and a
refused `limit`. That is outside this PR's file surface, and the wording
is still broadly true.
- `dryRun`'s `count` is not wrapped: a failing count still rejects, as
the old `dryRun` read did. The card's `ok: false` rule is about pages.

## Verification

Read first (risk order):
1. `knowledge-service.ts` `walkObjectSource`: the loop's exits (empty
page, cap, and the two non-advance stops) and the cursor `where`
composition.
2. `knowledge-service.ts` `chainAfter` and `serializeRecordSync`: the
event-sync chain now goes through the shared helper.
3. `knowledge-service.test.ts` `pagedEngine`: the double's refusals are
what make "every find has a limit" fail loudly.

Two-minute check: run `pnpm --filter @objectstack/service-knowledge exec
vitest run src/__tests__/knowledge-service.test.ts`. Expect 53 passing
tests, 25 of them under `the reindex walk pages by id`.

Every reading below was taken at head `9e24b96c`, the final commit.

<details><summary>Package tests and typecheck</summary>

```
pnpm --filter @objectstack/service-knowledge test
 Test Files  8 passed (8)
      Tests  142 passed (142)
pnpm --filter @objectstack/service-knowledge typecheck
check:test-typecheck: OK — 0 file(s) / 0 error(s) / 0 pinned signature(s)
```
</details>

<details><summary>Ablations (source-resolved subject: the test imports
../knowledge-service.js, so no dist is on the path; each mutation made
by scripts/ablation-replace.mjs; each restore proven by blob == HEAD and
an empty git diff HEAD)</summary>

```
A4 (9e24b96) restore `if (rows.length < want) break;` after the page upsert
   -> 3 failed (one page + 1, the short-page pin, numeric ids), 50 passed
   (a first attempt was refused by the tool before any test ran: its replacement contained the anchor, so the anchor count could not drop)
A1-A3 (99518e6, before this round; the code they mutate is unchanged)
A1 delete `limit: want,` from the page read   -> 12 failed (the double refuses an unbounded find)
A2 bypass chainAfter on reindexTails          -> 1 failed  (the never-interleave pin)
A3 drop the `id > cursor` condition           -> 7 failed; the walk still terminated (the non-advance stop held)
```
</details>

<details><summary>SQL driver: one scratch run of ObjectQL + SqlDriver
(better-sqlite3, :memory:) against this branch's source at
9e24b96</summary>

The run used 250 rows of a `kb_note` object, inserted in shuffled order:
16 explicit ids chosen to stress ordering (`a A b B r9 r10 r100 Z z 0 9
10 _x -y r_1 r-1`) plus 234 engine-generated ids. 191 rows have `status
= 'open'`. The fourth read is the empty one that ends the walk.

```
rows 250 result {"ok":true,"object":"kb_note","discovered":250,"indexed":250}
pages 100,100,50 finds 4 maxPage 100 pageSize 100
each row once true
walk order == engine id order true
every find limited true
page2 query {"where":{"id":{"$gt":"MutQpGXcbru5V4DJ"}},"orderBy":[{"field":"id","order":"asc"}],"limit":100}
open: rows 191 result {"ok":true,"object":"kb_note","discovered":191,"indexed":191} once true page2 query {"where":{"$and":[{"status":"open"},{"id":{"$gt":"XhVtf05MZ_zLLW3V"}}]},"orderBy":[{"field":"id","order":"asc"}],"limit":100}
limit 150 {"ok":true,"object":"kb_note","discovered":150,"indexed":150} reads 100,50
dryRun {"ok":true,"object":"kb_note","discovered":191,"indexed":0,"message":"dryRun=true; no documents pushed."}
```
</details>

<details><summary>Local gate subset (dispatch-gates --commands, derived
from merge base eec6fb3, 5 paths): 100 derived, 98 exit 0, 2 NOT
MEASURED</summary>

```
dispatch-gates --ran: 100 derived famil(ies) accounted for — 98 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)
NOT MEASURED: pnpm check:dual-build-cjs-loads, reason: PREREQUISITE NOT MET (64 packages have no dist/; reads the whole monorepo's built output)
NOT MEASURED: pnpm --filter @objectstack/spec run check:skill-examples, reason: PREREQUISITE NOT MET (client / client-react have no dist/; selected by the docs page)
doc authoring guard: 23493 customer-facing string(s) ... clean — no internal issue-id references
check-nul-bytes: OK (no raw ASCII control bytes)
eslint --no-inline-config on the three changed source files: exit 0
```
CI runs both NOT MEASURED families on a full build.
</details>

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

<!-- signed: repo:objectstack#4 · os-justin ·
session_01QSeKYpRrYuqSLCvbSk9zrL -->

---------

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 size/l skip-changeset PR has no user-facing published change; bypasses the changeset gate

Projects

None yet

3 participants