Repository navigation
feat(service-knowledge): under the markdown split, a section that fits is one passage - #38439
Conversation
Under split strategy markdown, a section whose passage under the heading-path prefix withPrefix selects fits maxChars and the token budget is now one passage, whatever minChars is; minChars keeps merging the pieces of sections that do not fit. Text before the first heading follows the same rule. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mCvGQKiCEBneFwp1j
…merges only sections that do not fit Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mCvGQKiCEBneFwp1j
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mCvGQKiCEBneFwp1j
📓 Docs Drift CheckThis PR changes 3 package(s): 4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 181 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 65fc776b299235f26545cbcf7721e9ade67f37bd && git checkout 65fc776b299235f26545cbcf7721e9ade67f37bd
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin da184dacd9d4f8ee66710453f235255e7fdee223 c645c31925a58f83088e62b0e8e832eecc920145 && git checkout -B drift-repro da184dacd9d4f8ee66710453f235255e7fdee223 && git merge --no-ff c645c31925a58f83088e62b0e8e832eecc920145
node scripts/docs-audit/affected-docs.mjs --json da184dacd9d4f8ee66710453f235255e7fdee223
|
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5mCvGQKiCEBneFwp1j Contract-review-claim: session_01FEkQ5mCvGQKiCEBneFwp1j · head 4723a4f · 2026-11-29T01:50Z |
… bundle Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mCvGQKiCEBneFwp1j
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5mCvGQKiCEBneFwp1j Contract reviewServed-tier: Read: card #38351 (body and all five comments, ruling 7247322956 included), PR #38439 (body, eight files, the diff against ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
M1 (must-fix) — the new
S1 (should-fix) — three hand-translated locales keep the old rule after M1's regeneration.
N2 (nit) — "its text with its heading path" is narrower than the code in one corner.
N1 (nit) — the version table's own prose no longer describes version 2.
M1 is a must-fix, so this head fails. The delta review owes M1 and S1, plus the changeset line. Implemented-by: VERDICT: FAIL |
…jects in the changeset, exact heading-path wording Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mCvGQKiCEBneFwp1j
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5mCvGQKiCEBneFwp1j Contract-review-claim: session_01FEkQ5mCvGQKiCEBneFwp1j · head c645c31 · 2026-11-29T02:16Z |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5mCvGQKiCEBneFwp1j Contract reviewServed-tier: Delta review from Read: card #38351 (body and all six comments, ruling 7247322956 and both dev reports included), PR #38439 (body, twelve files, the diff against The delta leaves ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix, no should-fix.
M1: closed.
S1: closed.
N2: closed. The N3 (nit) — the new parenthetical lists two of the three prefixes.
N4 (nit) — line 101 of the docblock is 95 columns in a block wrapped at about 77. Cosmetic; left.
N1 stays as round 1 left it: an accepted deviation, to be carried on #38377 (③). Open for the seat before ACCEPT, none of them a change to this head: the N1 note on #38377, the ADR-0161 item on #38351, and the PR body. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5mCvGQKiCEBneFwp1j Final green head declared for L1:
|
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5nNJM8FQkBco82NDFb 席位核对L1 (thread L1-a, area o5-ai37000) · read 2026-11-29T02:47Z · Head-sha: This is the first L1 record on this PR, a full review. Checklist (l1-face
My readings, at this head (detached worktree, restored, removed)
Accepted (no action): the contract record's N3 (the parenthetical names two of the three prefixes) and N4 (one 95-column docblock line) are nits it left. The ADR-0161 note is not owed, because the area measured no ADR text that contradicts the change (body line 60). Owed: nothing from L1. Before landing, re-confirm |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5mCvGQKiCEBneFwp1j Landing · head
|
| Probe | Reading |
|---|---|
check-governed-merges.mjs --pr 38439 |
NOT governed (0 of 12 paths on the register); 233 changed lines, under 3000 |
pr-state.mjs --pr 38439 |
65 success · 11 expected skip (check-expected-skips OK) · 0 failed · 0 pending · mergeable_state clean |
landing-k.mjs --pr 38439 |
K = 2, no locale or shared-book leg |
overlap-check.mjs |
merges cleanly with origin/main 1afd9c1 and with #38452, #38421 |
| Version reading | .changeset/38350-markdown-bodyless-headings.md still unconsumed on origin/main 1afd9c1, so markdown: 2 is unreleased and this PR rides it |
| Records on this head | L1 ACCEPT 7249654609 · contract review PASS 7249418590 |
State change: ready + auto-merge now (area lands, not governed). On merge, Fixes #38351 closes the card; the area clears pm:dispatched. Follow-ups: #38442 (skills docs, blocked by this card), N1 on #38377 (7249429872).
…tack-ai#38452) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XPpqjfjwZCAyAm71ZUE2yhz)_ Fixes objectstack-ai#38377 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no published skill, doc page or example names the retired constant (git grep over `skills`, `content/docs`, `docs`, `examples`, `apps`, `ui`, `.claude` at 4fa2f8e: 0 hits); the ADR text is item 2, carried by the lander ## 维护者速读 - 用户能看到什么变化:用户无感;只有直接引用知识服务包里那个旧常量的宿主代码,升级后编译会提示删掉这行引用。 - 为什么做:知识平台「切分版本按策略计」之后的收尾,撤掉一个已经没有任何运行代码读取的公开常量,免得作者和 AI 以为改它有效。 - 出错会怎样:最坏是某个宿主仍引用它而编译失败,删掉那行引用即可;可直接撤回本改动,不会触发任何索引重建。 - 要你做的:无。 ## What changes `SPLIT_ALGORITHM_VERSION` leaves `@objectstack/service-knowledge` at once, with no alias (the card's stage posture). Since the per-strategy split version landed, the index fingerprint (ADR-0161 K7) reads `SPLIT_ALGORITHM_VERSION_BY_STRATEGY` for the source's resolved strategy, and the global constant was read by no runtime code. - `src/split/splitter.ts`: the constant and its docblock are deleted. The per-strategy table's docblock linked to it ("Every entry started at" the constant); it now says every entry started at 1, the one split version the fingerprint read before the table, which names no retired symbol and stays true. - `src/split/index.ts`, `src/index.ts`: both re-exports are deleted. - `src/__tests__/index-fingerprint.test.ts`: the version pin keeps the two remaining constants (`INDEX_FINGERPRINT_VERSION`, `ASSEMBLY_RULE_VERSION`), and a new case pins the retirement: neither the split barrel nor the package entry has the property, with a positive control on the entry. - Area-ordered additions (the sibling split card's L2 nit, comment text only, no assertion, value or snapshot changed): two comments now name both changes `markdown` version 2 carries, the body-less heading as its own passage and a fitting section as one passage whatever `minChars` is. One is the `markdown: 2` entry comment in `SPLIT_ALGORITHM_VERSION_BY_STRATEGY` (`splitter.ts`); the other is the `PINNED` docblock in `index-fingerprint.test.ts`. The second clause is true only once PR objectstack-ai#38439 merges; the seat lands this PR after it. The table's docblock does not tie version 2 to one change, so it needed no edit. - `.changeset/38377-retire-split-algorithm-version.md`: `patch` (kind `none`), BREAKING banner, FROM/TO table, a sentence saying this retirement replaces the still-pending 38349 changeset's note that the constant keeps its name and value (that changeset is not edited), ADR-0087 disposition `not-required (runtime-export-retired @objectstack/service-knowledge#SPLIT_ALGORITHM_VERSION)`. Item 2 of the card (the ADR-0161 K7 revisions row) is not in this PR: no `docs/adr/**` edit. The landing seat appends it to the weekly ADR revisions card (`carrier:` PR objectstack-ai#38375). `Fixes` stays because that row is landing bookkeeping. Landing: a narrowing of a published surface. It owes one contract-review-tier L2 on its final head before the queue. Read first: (1) `src/split/splitter.ts` — the reworded docblock is the only prose a reader of the table keeps; (2) the changeset — it ships as the CHANGELOG line an upgrader greps; (3) the new test case. Two-minute check: `pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/index-fingerprint.test.ts` — expect 9 tests passing, including "publishes no global split version beside the per-strategy table". ## Tests Package suite at `f76ba9c9`. At `987b09ca`, the last commit that touched code or tests, `index-fingerprint.test.ts` alone under the verify lock: Test Files 1 passed (1), Tests 9 passed (9), VERDICT command-exit 0. <details><summary>service-knowledge test + typecheck (lock VERDICT command-exit 0)</summary> ``` pnpm --filter @objectstack/service-knowledge test Test Files 21 passed (21) Tests 727 passed (727) pnpm --filter @objectstack/service-knowledge typecheck check:test-typecheck: OK, the test layer compiles under tsconfig.test.json; 0 file(s) / 0 error(s) held in test-typecheck-debt.json ``` </details> <details><summary>Ablation of the new retirement pin</summary> With `export const SPLIT_ALGORITHM_VERSION = 1;` appended to `src/index.ts` on disk, `index-fingerprint.test.ts` went red: `publishes no global split version beside the per-strategy table` failed with `expected ... to not have property "SPLIT_ALGORITHM_VERSION"` (1 failed, 8 passed). Restored with `git checkout HEAD`, tree clean. </details> <details><summary>Full dogfood (the narrowing arm), at `4fa2f8ee`</summary> `pnpm turbo run build --filter='@objectstack/dogfood^...'` then `pnpm --filter @objectstack/dogfood test` under the verify lock: VERDICT command-exit 0, Test Files 495 passed, 3 skipped (498), Tests 4183 passed, 68 skipped (4251). `987b09ca` differs from `4fa2f8ee` by comments only (`git diff --stat 4fa2f8e..HEAD`: 2 files changed, 4 insertions, 1 deletion; one hunk in `splitter.ts`, one in `index-fingerprint.test.ts`, both comment lines). The final head `42214359` adds one changeset sentence. So the battery was not re-run. </details> ## Acceptance notes - Whole-tree search before deleting, at `d751790c`: `git grep -n 'SPLIT_ALGORITHM_VERSION\b'` gave 13 lines. 5 were the declaration, the two re-exports and the pin's import and assertion (all removed here); 1 was the per-strategy docblock link (reworded); the other 7 are history: `.changeset/38349-split-version-per-strategy.md`, `.changeset/pre/37100-knowledge-pgvector.md` and five generated `CHANGELOG.md` files. They are left alone: existing changesets are never edited, and CHANGELOGs are release-owned. No `skills`, `content/docs`, `docs`, `examples`, `apps`, `ui` or `.claude` hit. - The package has no API-surface baseline, so no generator was owed. ## Verification <details><summary>Local gates (derived with dispatch-gates --commands, reconciled with --ran: 63 derived, 63 run)</summary> - 60 of 63 exited 0 on the first pass. - `node scripts/check-adr-0087-registration.mjs --base origin/main` exit 1 on `0c4609e7` (the FROM column spelled an import statement, not the operand); after the fix, exit 0 on `4fa2f8ee`: `not-required (runtime-export-retired) -- verified: @objectstack/service-knowledge#SPLIT_ALGORITHM_VERSION`. - `node scripts/check-plugin-teardown-shape.mjs --self-test` exit 3 (shallow clone could not reach its pinned fixture commit); after fetching that commit, exit 0, 48 cases pass. - `pnpm check:dual-build-cjs-loads` exit 3, PREREQUISITE NOT MET (needs every package built). NOT MEASURED locally, CI runs it. - Re-run at `4fa2f8ee` after the changeset fix: check-changeset-no-major, check-empty-changeset, check:changeset-gate-self-tests, check:nul-bytes, check:doc-authoring, check:issue-citations: all exit 0. check:nul-bytes exit 0 again at `f76ba9c9` and at `987b09ca`. At `42214359` (changeset sentence only), check-adr-0087-registration, check-changeset-no-major, check-empty-changeset and check:nul-bytes: all exit 0. - `node scripts/check-platform-checklist.mjs --changed-from origin/main` exit 0: 0 anchored files in the change set. - `node scripts/pm/overlap-check.mjs` before each push: clean; at `f76ba9c9`, `987b09ca` and `42214359` it also merges cleanly with PR objectstack-ai#38439. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5omA3kZCsWzBMMqF11 <!-- signed: repo:objectstack#5 · os-project-manager · session_01FEkQ5omA3kZCsWzBMMqF11 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…ames chunk_target the longest passage (objectstack-ai#38468) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XDXvJPPtrTGfdDYhWWpihq5)_ Fixes objectstack-ai#38290 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:写知识源的应用作者在知识检索指南里能读到“一条一段”的做法(每条写成一个标题、在同一条记录上派生一个专供检索的文本字段、可选的顶层标题写明文档和所属部门);管理员在知识设置页看到的“目标片段大小”改名为“片段最大长度”,各语言一致。 - 为什么做:知识切分专题第一阶段的文档项,回答外部作者提出的“怎样让每一条恰好一段”的问题;放得下的小节整节一段已按您的裁决合入,这里只把做法写清楚。 - 出错会怎样:只改文档和设置页的文字,键名、默认值、切分行为都不变;写错只会误导读者,直接撤回即可。 - 要你做的:无。 ## What changes - **Knowledge guide** (`content/docs/ai/knowledge-rag.mdx`): a new `### One passage per unit` section under "Splitting documents into passages". It teaches, as the landed `markdown` splitter behaves at f19ee34: - one heading per unit (a heading at the start of its line; bold text is not a heading; a unit's sub-items as list items, since a sub-heading is a section and a passage of its own); - a unit whose text with its heading path fits is one passage whatever `minChars` is, and a table with the note after it inside that unit stay together; - no passage holds two units (each section is split on its own), and every passage begins with its unit's heading path; - a unit that does not fit is cut as `recursive` cuts, its pieces merged up to `minChars`; the note after a cut table can land in another piece; - `minChars` is the merge threshold of a unit that does not fit, not a switch, and `minChars: 0` turns nothing off; - a derived field on the same record carries the index text, listed alone in `content` (why the same record and not a second object: the hit names the record people open, the search re-checks that record as the asker, `where` and `metadataFields` read its own fields); - an optional top heading names the document (and the department that owns it), so every passage's heading path begins with it; keep it short, because a path that leaves less than half of the passage length shortens to the unit's own heading; a title already in that heading needs no second `content` entry; - moving a source to this shape changes `content` and `split`, so it rebuilds once and re-sends the source to the embedder. - **Protocol page** (`content/docs/protocol/knowledge.mdx` §3.5): one paragraph that states the result and points to the guide; the setting's name updated. - **Settings page** (`packages/services/service-settings`): `knowledge.chunk_target` was labelled **Target chunk size (chars)** while its help text and the splitter treat it as a maximum. The label is now **Longest passage (characters)** and the help adds that passages can be shorter, in the manifest and in all 11 locales (en, zh-CN, zh-Hant, ja-JP, ko, de, es-ES, fr, pt-BR, ru, ar). Key, default, bounds and reader unchanged. - **Changeset**: a patch on `@objectstack/service-settings`, which also says that earlier notes naming **Target chunk size** mean the same setting (the pending changesets that name it are not edited). ## Answer to objectstack-ai#38290 The card asked for either a split strategy that cuts at a unit pattern, or a documented way to get one passage per unit. objectstack-ai#38351's ruling A (record 7247322956, 「objectstack-ai#38351 同意」, merged in PR objectstack-ai#38439) made a fitting `markdown` section one passage by default, so the documented way needs no setting: write each unit as a heading. `minChars: 0` is not that switch and is not an opt-out (ruling item 2): `minChars` only merges the pieces of a section that does not fit. A table and its trailing note inside one fitting unit are one passage. The app's workaround (a second object with one row per article) can become a derived field on the policy record itself. The 84% → 94% figure is not cited here: the topic's adoption comment notes it changed several variables at once. ## Acceptance notes - `skills/objectstack-ai/SKILL.md` still names "the **Target chunk size** setting". Skills are objectstack-ai#38442's surface; its dev was told to write "the **Longest passage** setting" and to land after this PR. - The card's claim names this PR's head in claim 7250337030 (the area's re-post of 7250017151 with the platform branch). - The pending changesets that name **Target chunk size** (`.changeset/pre/37098-knowledge-splitter.md`, `.changeset/pre/37292-skill-knowledge-split.md`) are not edited; this PR's changeset carries the superseding sentence. ## Verification All at head `340bb349`, tree `objectstack-ai/objectstack`, base `origin/main` f459c86. - `pnpm --filter @objectstack/service-settings test`: Test Files 79 passed (79), Tests 1545 passed (1545); exit 0. - `pnpm --filter @objectstack/service-settings typecheck`: exit 0 (dependency closure built first, exit 0). - `node scripts/pm/overlap-check.mjs --branch=HEAD`: `VERDICT clean exit 0` (merges cleanly with origin/main; no open PR head on these files). - Derived gate families (`dispatch-gates --commands`): 89 derived, 86 run with exit 0, 3 NOT MEASURED (exit 3, prerequisite not met, nothing measured; CI runs them): - `node scripts/check-plugin-teardown-shape.mjs --self-test`: its positive control is pinned to a commit the shallow clone cannot reach. - `pnpm --filter @objectstack/spec run check:skill-examples`: needs a `@objectstack/client-react` build this diff does not touch. - `pnpm check:dual-build-cjs-loads`: needs every package's `dist/`, which this container did not build. - `dispatch-gates --ran`: 89 derived families accounted for, 86 run, 3 NOT MEASURED (derived from the recorded exit 3). - Every other family CI runs on this PR is read from its check runs, not re-run here. Two-minute check: open `content/docs/ai/knowledge-rag.mdx` at "One passage per unit" and compare each bullet with `withPrefix` and `splitMarkdown` in `packages/services/service-knowledge/src/split/splitter.ts`. Read first: the new section of `content/docs/ai/knowledge-rag.mdx` (the claims a reader acts on), then the `zh-CN.ts` / `ja-JP.ts` label wording. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. (no names added) - [x] 3. No formatter ran; `pnpm lint` passes. (CI) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5mDidoPNcFwxVX65bA <!-- signed: repo:objectstack#5 · os-project-manager · session_01FEkQ5mDidoPNcFwxVX65bA --> Co-authored-by: Claude <noreply@anthropic.com>
…s its sources without an embedder or its deployment store (objectstack-ai#38470) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X6jdZukAJaWgnbQHnPWHxMw)_ Refs objectstack-ai#38369 Clause-②: no (narrowing) Metadata-protocol: narrowed Skills-docs: follow-up objectstack-ai#38475 ## 维护者速读 - 自托管部署如果没配嵌入模型(或部署的知识存储没挂上),知识源现在只列出、不构建、不同步、不检索,智能体工具里也不再出现 `search_knowledge`;启动日志说一次缺了哪一半、怎么补。以前这种部署照样启动构建和同步,工具也列出来,但每次构建和检索都报错。 - 属于知识库检索这条线,执行您对 objectstack-ai#38368 的裁决(四点全按推荐 1A 2A 3A 4A)和 ADR-0161 K8 的日期注记"挂载不等于启用"。这是三单中的第一单:先把"不服务"做实;保存时拒绝(第 2 单)和状态/命令行文字(第 3 单)随后各开一单。 - 只影响运行时自动挂载知识服务、且缺嵌入模型或知识存储的部署;配齐两半的部署、以及宿主自己挂载知识服务的部署行为不变;从不阻止启动;出问题可整单撤回。 - 要你做的:批准这次收窄(按审批流程)。 ## What changes The authority is the ADR-0161 K8 dated note on item 12 (PR objectstack-ai#38401, 0c1b2ff), with ruling 7248214179 (amendment 7248231750, points 1–4) and build notes 7248592159 (points 1–4). This PR is part 1 of the three serial PRs the card names: items 1–2, ruling points 2–3, build notes 1, 2 and 4. Part 2 (the save refusal: item 3, points 1 and 4, build note 3) and part 3 (items 4–5) follow from `main` after this merges. - **Enabled by configuration, read once at boot** (`packages/services/service-knowledge/src/knowledge-service-plugin.ts`). The capability composition (`packages/core/src/capability-composition.ts`) now passes `runtimeComposed: { declared }` beside `deploymentAdapter`; `declared` is true only when the stack lists `knowledge` in `requires`. With `runtimeComposed` set, the plugin reads at `kernel:bootstrapped`, after every store's `start()` registered its adapter: an embedder is available (another plugin registered one, or the saved `ai.embedder_*` settings build one) and the deployment's store is mounted (an adapter of `deploymentAdapter`'s id is registered). Both ⇒ the boot goes on as today. Either missing ⇒ held. A plugin a host mounts (no `runtimeComposed`) is untouched: it serves from the start, as before. - **Held** (`packages/services/service-knowledge/src/knowledge-service.ts`, `KnowledgeService.settleEnablement`). Every source, whichever store it names (point 2: an application-registered store too), is loaded and listed, and never built, synced, reconciled or searched: the boot build, the reload build, the reconcile pass and its job, the record sync (enqueue, upsert, delete and the queued worker), the predicate-write note and the unmounted-adapter report all return. A dropped source keeps its index (a warn line says no store is called). `search`, `rebuildSource` and `reindexSource` throw `heldSourcesError`: status `503`, code `SERVICE_UNAVAILABLE`, and a message naming the missing half and the fix (build note 2). - **No reap guard and no store call while not enabled** (point 3, build note 1). The lifecycle reap guard used to register at `kernel:ready`, before the reading; the lifecycle service has no unregister. A runtime-composed plugin now registers it only once the reading says enabled. Held, a retention sweep deletes on time and calls no store. - **One boot line**, never a boot refusal (ADR-0078 §4). `info` when only a shipped `knowledge_source` mounted the service and nothing was saved; `warn` when the stack declares `requires: ['knowledge']`, when a saved embedder provider builds nothing (a provider saved without its key), or when the store is not mounted. The embedder's own boot line is not also said when held. - **No tool definition while pending or held** (`KnowledgeService.knowledgeTools()` answers `definitions: []`). HTTP MCP reads the definitions per request, so it lists `search_knowledge` only once enabled. - **stdio** (`packages/mcp/src/plugin.ts`, build note 4). The stdio bridge reads the tool in its own `start()`, before the reading, so a runtime-composed service hands out nothing there. `MCPServerPlugin` now registers `search_knowledge` at `kernel:listening` (after every `kernel:bootstrapped` handler) only when the service then hands out its definition. Fail-closed: an unknown state reads as absent, never listed and then withdrawn. The MCP SDK takes a tool after the transport attached and sends `notifications/tools/list_changed`; skill prompts read the served tools at each listing. A host-mounted service's tool still registers in `start()`, once. - **ADR-0087**: `packages/spec/src/migrations/entries/semantic/19.knowledge-service-held-without-embedder-or-store.ts` (notice only, no D2 conversion: the fix is the deployment's configuration, never the item). The changeset carries `registered` with that id. ### Boot window Between `kernel:ready` and `kernel:bootstrapped` the reading is pending. In that window no tool definition is handed out (fail-closed); a record write's sync behaves as today (it embeds through the stand-in embedder, which refuses). Gating starts when the reading settles. No reap guard registers in that window on a runtime-composed plugin. ### Point 2 measurement None of `@objectstack/verify`'s `harness.required-providers` cases reads as held: every one registers an embedder. The file is unchanged and its 16 cases pass. ### Docs `content/docs/ai/knowledge-rag.mdx`: a "Mounted is not enabled" bullet under *Turning it on* (held state, the boot line and its level, the remedy, host-mounted not held), a clause on the "Nothing is configured" embedder bullet, and one sentence under *The `search_knowledge` tool* (not listed while held; on stdio registered after the reading, with `notifications/tools/list_changed`). `content/docs/protocol/knowledge.mdx`: a "Mounted is not enabled" paragraph after *What mounts the service*, and the reap-guard section says a runtime-composed service registers no guard until it is read as enabled. Added after sibling objectstack-ai#38439 (objectstack-ai#38351) merged (f19ee34), with `main` merged in first. `skills/objectstack-ai/SKILL.md` is out of scope: follow-up objectstack-ai#38475 rewrites its knowledge wording once, from `main`, after part 3. ## Tests - `packages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.ts`, new describe "a runtime-composed knowledge service is enabled by configuration", booted on `LiteKernel` with a store plugin that counts every call (10 cases): held with no embedder saved (one `info` line, zero store calls after writes and a delete); no `search_knowledge` definition, search answers `503 SERVICE_UNAVAILABLE` naming the missing half, rebuild refused; `requires: ['knowledge']` ⇒ `warn`; a provider saved without its key ⇒ `warn` (build note 3's state, read here; its save refusal is part 2); store not mounted ⇒ `warn`; both halves missing named together; point 2 (an application-registered store is held too); controls: enabled through a host-registered embedder and through saved settings (built, definition handed out); a host-mounted plugin builds as before. - `packages/services/service-knowledge/src/__tests__/reap-guard.test.ts` (point 3, build note 1): held ⇒ `registerReapGuard` never called and the retention sweep deletes `k1`, `k2` on time with no store call; control: enabled ⇒ the guard registers for `['task']` after the reading and de-indexes before the delete. - `packages/mcp/src/mcp-knowledge-tools.test.ts` (build note 4): HTTP lists the tool only once enabled (pending, held: absent; host-mounted: listed from the start); stdio through `MCPServerPlugin` with the boot hooks fired by hand: held is never listed and no `list_changed` is sent; enabled registers at `kernel:listening` with `notifications/tools/list_changed` and the same description; host-mounted registers once in `start()`. - `packages/runtime/src/mcp-knowledge-tools-bridge.test.ts`: the runtime bridge reads the definitions per listing (pending and held `[]`, enabled `['search_knowledge']`). - `packages/core/src/capability-composition.test.ts`: `runtimeComposed: { declared }` is passed, `declared` only when the stack lists the token. - `scripts/engine-double-contract.pinned.json` learns the stdio double's `findOne` pin (the double routes through `assertEngineFindOnePredicate`). ## Verification **Final head `4659f2a369`** (`main` merged twice since `72a9cbfb6a`, for objectstack-ai#38439 and objectstack-ai#38436; plus the docs commit). At that head, under the lock: closure build exit 0; `@objectstack/service-knowledge` `pnpm test` 751 passed; `@objectstack/mcp` `pnpm test` 1655 passed; core 26, runtime 7, verify 16 passed; typecheck exit 0 for service-knowledge, core, mcp and runtime; `check:engine-double-contract`, `check:slot-lookup`, `check-adr-0087-registration` (entry at or above PROTOCOL_MAJOR 19), spec `check:docs`, `check:doc-authoring`, `check-affected-docs`, `check:adr-anchors` exit 0. **Dogfood battery at `4659f2a369`: VERDICT command-exit 0 · Test Files 495 passed, 3 skipped (498) · Tests 4183 passed, 68 skipped (4251) · 0 failed.** CI at `4659f2a369`: 62 check-runs success, 10 skipped, none failed. The readings below were taken at `72a9cbfb6a` and stand where noted. Shared container; every build and test ran through `scripts/pm/os-verify-lock.sh`. <details><summary>Tests and typecheck at 72a9cbf</summary> - Closure build (`pnpm --filter '@objectstack/dogfood^...' --filter '@objectstack/cli...' --filter '@objectstack/lint...' build`): VERDICT command-exit 0. - `@objectstack/service-knowledge` `pnpm test`: Test Files 21 passed, Tests 738 passed; `typecheck` exit 0. - `@objectstack/mcp` `pnpm test`: Test Files 88 passed, Tests 1655 passed; `typecheck` exit 0. - `@objectstack/core` `capability-composition.test.ts`: Tests 26 passed; `typecheck` exit 0. - `@objectstack/runtime` `mcp-knowledge-tools-bridge.test.ts`: Tests 7 passed; `typecheck` exit 0. - `@objectstack/verify` `harness.required-providers.test.ts`: Tests 16 passed (point 2 measurement above; file unchanged). - `@objectstack/cli` `plan.artifact-item-capabilities.test.ts`, `boot-preparation-parity.test.ts`, `migrate-meta-engine-guidance.test.ts`: Tests 44 passed. - `@objectstack/spec` `typecheck` exit 0 (migration registry regenerated with the new entry). - ESLint over every changed `.ts` file: exit 0. </details> <details><summary>Ablation</summary> At `2d6c3dfd` (plugin unchanged since): `scripts/ablation-replace.mjs` replaced `const held = this.settleEnablement(ctx, this.service, embedder);` with `const held = false; void this.settleEnablement;`. The runtime-composed describe went 9 failed / 1 passed (the host-mounted control stayed green). Restored; blob back to HEAD, `git diff HEAD` empty. </details> <details><summary>Dogfood battery at 72a9cbf</summary> `pnpm --filter @objectstack/dogfood test` under the lock: VERDICT command-exit 0 · Test Files 495 passed, 3 skipped (498) · Tests 4183 passed, 68 skipped (4251) · 0 failed. </details> <details><summary>Live positive control (os dev, showcase app)</summary> The showcase mounts `KnowledgeServicePlugin` itself (host-mounted, unchanged by this PR), so for the control its two knowledge plugins and the source's `adapter: 'memory'` were commented out in the worktree only (never committed; restored with `git checkout`), which lets the runtime compose the service with the Turso store. `objectstack dev --seed-admin --log-level info` on a file database, signed in as the seeded admin: - **No embedder saved.** One boot line, `INFO KnowledgeServicePlugin: the knowledge service is not enabled on this deployment: no embedder is configured (no embedder provider is saved — …). Its sources are held: none is built, synced or searched. To enable it, save an embedder provider, then restart. 1 source(s) held: showcase-showcase_task_notes.` (hidden at the default log level, as `info` should be). No build line. `index_status` lists the source with `build: null`. The Knowledge page's rebuild action answers "was not started: [knowledge] the knowledge service is not enabled on this deployment: …". MCP over HTTP: `tools/list` 20 tools, `search_knowledge` absent. - **Embedder saved, restarted.** `PUT /api/settings/ai` saved a `custom` provider pointing at a local OpenAI-compatible stub. The boot registered the embedder, registered the reap guard for `[showcase_task]` after the reading, and built the source: "8 row(s) read, 8 written". MCP `tools/list` 21 tools with `search_knowledge`; a `search_knowledge` call answered hits from `showcase-showcase_task_notes`; the stub logged one call of 8 inputs (build) and one of 1 (search). - The boot also logs `ERROR [knowledge] the start of the build … was not recorded (Duplicate record refused on 'Knowledge Sync State' …)` whenever a build starts, host-mounted or not. That is objectstack-ai#38418 (open, seat 1), not this change. - `index_status` still reads the adapter while held (here: `state: unreadable` with the embedder's reason). Saying "not enabled" there, and in `os knowledge status` / `rebuild`, is card item 4, part 3. </details> <details><summary>Gates at 72a9cbf</summary> `dispatch-gates --ran`: 106 derived families accounted for, 105 run with exit 0, 1 NOT MEASURED: `check:dual-build-cjs-loads` exits 3 (no `dist/` for `@objectstack/studio`, `client-react`, `scenarios`, outside this closure); CI runs it. Among them: `check-adr-0087-registration` (1 declared-breaking changeset, `registered knowledge-service-held-without-embedder-or-store`), `check-changeset-no-major`, `check-empty-changeset`, spec `check:upgrade-guide`, `check:spec-changes`, `check:api-surface`, `check:liveness`, `check:engine-double-contract` (after the stdio double's fix), `check:slot-lookup` (after typing the store plugin), `check:error-status-conformance`, `check:type-check-debt`, `check:nul-bytes`. `check-plugin-teardown-shape --self-test` exit 0 after fetching its pinned fixture commit. `overlap-check` before the push: clean against `main` and against objectstack-ai#38439, objectstack-ai#38435 and objectstack-ai#38268 (objectstack-ai#38418 has no PR yet). </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5m2rYCwPR3qqhnZDfW <!-- signed: repo:objectstack#5 · os-project-manager · session_01FEkQ5m2rYCwPR3qqhnZDfW --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Leehom · project thread
Fixes #38351
Clause-②: no
Metadata-protocol: semantic
Skills-docs: follow-up #38442
维护者速读
What changes
packages/services/service-knowledge/src/split/splitter.ts,withPrefix): undersplit.strategy: 'markdown', after the heading-path prefix is selected exactly as before (full path, else the innermost heading, else none, by the existing half-the-bounds rule), a section whose emitted passage (prefix plus trimmed text) fits the bounds is returned as that one passage, whateverminCharsis. Only a section that does not fit reachessplitRecursive, unchanged, so its passages are byte-identical to before. The path-less branch (text before the first heading) takes the same rule. Body-less headings and the carry logic are untouched.recursiveandwholeare untouched.fits(lead + body.trim(), b), not onfits(body, left).estimateTokensrounds up per text and the prefix ends in whitespace, so the two raw sums add and the estimate of the passage is at most the prefix's estimate plus the body's: the emitted check accepts everything the split check accepts, plus the sections that are over the budget left after the prefix only by one rounding token. Characters agree, except for a heading that starts with whitespace other than a space or tab, where the emitted check is again the looser one. The emitted check is the bound the file promises for every passage, so a fitting passage can never exceed it. Pinned by a test.SPLIT_ALGORITHM_VERSION_BY_STRATEGY.markdownstays 2. Read at based751790c:.changeset/38350-markdown-bodyless-headings.mdis still pending, and the published@objectstack/service-knowledge@nextis19.0.0-next.2, whose changelog does not carry it. So this rides the 1 to 2 move already in this train (topic rule: one bump per train).SPLIT_ALGORITHM_VERSIONand its export are not touched.splitMarkdowndocblocks; theKnowledgeSplitSchemadocblock formarkdown, theminCharsdocblock and.describe, and the knowledge source form'sminCharshelp text inpackages/spec; the regeneratedcontent/docs/references/ai/knowledge-source.mdx;content/docs/protocol/knowledge.mdxsection 3.5 andcontent/docs/ai/knowledge-rag.mdx. No key, value, default or export changes (check:api-surfaceandcheck:authorable-surfacegreen).enbundle leafsource.split.minChars.helpTextinpackages/platform-objects/src/apps/translations/en.metadata-forms.generated.tsregenerated bynode scripts/check-i18n-bundles.mjs --write; the hand-translatedzh-CN,ja-JPandes-ESleaves re-translated to the new rule. The other seven locales serve the new English through their source-hash fallback..changeset/38351-markdown-fitting-section.md:@objectstack/service-knowledgeminor,@objectstack/platform-objectsminor (the bundles above), and@objectstack/specminor, because the spec's shipped prose changes (the.describestring ships in the JSON schemas and the reference, the help text ships in the form) and AGENTS.md asks at leastminorof asemantickind on every package the diff moves.Tests
packages/services/service-knowledge/src/__tests__/split.test.ts, new top-level describe "splitter — markdown: a section that fits is one passage", 11 cases:minChars: one passage, prefix first;minChars: 0: still one passage;minCharsstill merges its short pieces;maxCharswith the prefix is one passage, one character more is cut;maxCharsbut over the budget is still cut, each piece within it;recursiveunchanged on the same paragraphs.Before the fix, against the unmodified splitter, 8 of these were red (the 3 that pin unchanged behaviour were green, as they must be). The existing "every heading and line is kept" and "no passage over the budget" properties and the golden files pass unchanged (
headings.markdown.golden.jsonis byte-identical).Acceptance notes
Seeded synthetic corpus (the private corpus is not available; the script stays out of the PR). 400 documents per shape, article length lognormal with median 96 (about 78% under 200), 1 to 6 chapters and 1 to 8 articles each, paragraphs of 120 to 320 characters, 5% of articles carrying a table and its note at a random position,
maxChars800. A unit "fits" when its passage under its full heading path is withinmaxCharsand the token budget. RealestimateTokens, not stubbed.minChars = maxChars(before = after)minChars = maxChars(before = after)minChars = maxCharsrecipe on the same input gives -41% and +16 points.maxChars,minCharsand token limits, compared section by section between the base splitter and this one: 162,790 sections identical, 7,735 sections that were cut now one passage, 0 other differences.docs/adr/**(no ADR note owed: no ADR text contradicts the change; ADR-0161 hands the split rules to the splitter's card and only names themaxChars/minCharskeys),skills/**(theSkills-docs:follow-up),content/docs/releases/, and themarkdownentry's comment inSPLIT_ALGORITHM_VERSION_BY_STRATEGY, which names only the body-less heading change. It sits next to the constant sibling review follow-ups of PR #38375 #38377 retires, so it is left to avoid a conflict, and the changeset records that version 2 carries both changes.content/docs/protocol/knowledge.mdxsection 3.5'smarkdownrow said "A heading with no text of its own joins the next passage". That has not been true since the body-less heading fix, so the rewritten row states the landed behaviour.Verification
Read first, by risk:
packages/services/service-knowledge/src/split/splitter.ts,withPrefix: the two early returns (thefits(whole, b)lines) and the comment above the prefix loop.packages/spec/src/ai/knowledge-source.zod.ts: themarkdownbullet and theminCharsdocblock and.describe(contract-tier L2 face).content/docs/protocol/knowledge.mdxsection 3.5.Two-minute check:
pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/split.test.ts -t "fits is one passage"shows 11 passing tests.Local runs (heads 4723a4f and c645c31)
Patch round 1, head
c645c319(two commits on4723a4fe, no splitter or test change):pnpm check:i18nred at4723a4fe(platform-objects DRIFTED (1)), exit 0 atc645c319(all bundles in sync);check:i18n-stale-fillexit 0;pnpm --filter @objectstack/platform-objects exec vitest run src/apps/translations: 28 files, 625 tests passed; speccheck:generated: all 14 up to date;dispatch-gates --ran: 118 accounted, 115 run, 3 NOT MEASURED (prerequisite not met in this container; CI runs them);overlap-check.mjs --branch=HEAD: clean.Round 0, all on head
4723a4fe, worktree based751790c.pnpm --filter @objectstack/service-knowledge test: Test Files 21 passed (21), Tests 737 passed (737); lock VERDICT command-exit 0.pnpm --filter @objectstack/service-knowledge typecheck: tsc clean;check:test-typecheck: OK, 0 errors.pnpm --filter @objectstack/spec exec vitest run src/ai/knowledge-source.metadata-form.test.ts src/ai/knowledge-source.test.ts: 2 files, 42 tests passed;pnpm --filter @objectstack/spec typecheckexit 0. The rest of the spec suite is CI's (prose-only change in spec).pnpm --filter @objectstack/spec build && check:generated: 1 of 14 stale (check:docs), regenerated with--fix(the reference page above);check:authorable-surface,check:api-surfacegreen,authorable-surface.base.jsonuntouched.vitest run src/__tests__/split.test.ts -t 'fits is one passage', Tests 8 failed / 3 passed (the 3 pin unchanged behaviour), each failure a fitting section returned as 2 to 4 passages.node scripts/pm/dispatch-gates.mjs --commands(derived from the merge base, 8 paths): 114 commands, run locally;--ranreconciliation: 114 accounted, 110 exit 0, 4 NOT MEASURED (exit 3, prerequisite not met in this container:check-plugin-teardown-shape --self-testneeds an unshallow clone;check:skill-examples,check:dual-build-cjs-loadsandcheck:i18nneed a full workspace build). CI runs all four.node scripts/pm/overlap-check.mjs --branch=HEAD:VERDICT clean exit 0, merges cleanly withorigin/main, 0 open PR heads overlapping.!in the title, no(narrowing)arm).Generated by Claude Code