You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c5281d0
Browse filesBrowse the repository at this point in the historyBrowse files
docs(knowledge): one passage per unit recipe, and the settings page names chunk_target the longest passage (#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#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 #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. #38351's ruling A
(record 7247322956, 「#38351 同意」, merged in PR #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 #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>
fix(service-settings): the Knowledge page names `chunk_target` for what it is, the longest passage
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
The Knowledge settings page labelled `knowledge.chunk_target`**Target chunk size**, while its help text, and the splitter that reads it, treat it as a maximum: no passage is longer, and many are shorter (under the `markdown` split, a section that fits is one passage of whatever length it has). The label now reads **Longest passage (characters)**, and the help text adds that passages can be shorter, in every locale the page ships (en, zh-CN, zh-Hant, ja-JP, ko, de, es-ES, fr, pt-BR, ru, ar). Earlier notes that name **Target chunk size** (the splitter, the knowledge skill) mean this same setting under its old label. The key, its default (800), its bounds and what reads it are unchanged.
11
+
12
+
What to do: nothing. A script or seed that writes `knowledge.chunk_target` keeps working.
Copy file name to clipboardExpand all lines: content/docs/ai/knowledge-rag.mdx
+46-1Lines changed: 46 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -258,7 +258,52 @@ source: {
258
258
-`markdown` cuts one section per heading; each passage begins with its heading path, which is embedded with it. A section that fits in one passage (its text together with the heading path it is given, within the length below) is one passage; only a section that does not fit is cut as `recursive` cuts, and `minChars` (default 200) merges the short pieces of that cut.
259
259
-`whole` keeps each document as one passage.
260
260
261
-
A passage is at most `split.maxChars` characters — else the **Knowledge → Target chunk size** setting, else 800 — and, when the adapter reports its embedder's input limit, within 80% of that limit by the shared token estimate below. A `whole` document over that budget is **removed from the index and reported** (`failed` and `failures` on the reindex result, an `error` log on the event sync), never truncated; because the estimate runs high, a `whole` document can use about 60% of the model's limit. The full rules are in [the protocol's split section](/docs/protocol/knowledge#35-the-split).
261
+
A passage is at most `split.maxChars` characters — else the **Knowledge → Longest passage** setting, else 800 — and, when the adapter reports its embedder's input limit, within 80% of that limit by the shared token estimate below. A `whole` document over that budget is **removed from the index and reported** (`failed` and `failures` on the reindex result, an `error` log on the event sync), never truncated; because the estimate runs high, a `whole` document can use about 60% of the model's limit. The full rules are in [the protocol's split section](/docs/protocol/knowledge#35-the-split).
262
+
263
+
### One passage per unit
264
+
265
+
Policies, regulations, contracts and manuals are made of units: an article, a numbered section, a question with its answer. A hit is most useful when it is one whole unit: not half of one, and not three of them. The `markdown` strategy gives exactly that once each unit is its own heading:
266
+
267
+
-**One heading per unit.** Write each unit as a Markdown heading at the start of its line (`## Article 12 Air travel`), with the unit's text under it. Bold text such as `**Article 12**` is not a heading, so every article under one real heading would share that one section. Keep a unit's sub-items as list items or plain lines, not headings: a sub-heading starts a section of its own, and with it a passage of its own.
268
+
-**A unit that fits is one passage.** When a unit's text together with its heading path fits within the passage length above, it is one passage, whatever `minChars` is. A table and the note right after it, written inside the same unit, stay in that passage.
269
+
-**A passage never holds two units.** Each section is split on its own, so short neighbouring units are never merged, and every passage begins with its unit's heading path (shortened when it is long, see below; the hit carries all of it as `headingPath`).
270
+
-**A unit that does not fit** is cut as `recursive` cuts, its pieces merged up to `minChars`, and every piece still begins with the unit's heading path. A table too long for one passage is cut between rows, each piece repeating the header row; a note after the table can then land in a different piece than the rows it explains.
271
+
-**`minChars` only merges the pieces of a unit that does not fit.** It is the merge threshold for that cut: pieces shorter than it are joined up to it. It is not a switch for one passage per unit, which needs no setting, and `minChars: 0` turns nothing off: a unit that fits is still one passage, and only the pieces of a unit that does not fit are left unmerged.
272
+
273
+
Most apps do not store their text in that shape: articles are bold paragraphs, or the text lives in rich text. Keep it as it is, and give the same record a second text field that holds the index text, the same content rewritten with one heading per unit, filled by the app each time the record is saved (in a record hook, for example). List only that field in `content`:
274
+
275
+
```ts
276
+
source: {
277
+
kind: 'object',
278
+
object: 'policy',
279
+
content: ['index_text'], // the derived field alone
280
+
metadataFields: ['department', 'status'],
281
+
split: { strategy: 'markdown', maxChars: 800 },
282
+
}
283
+
```
284
+
285
+
Keeping the index text on the same record, rather than in a second object with one row per unit, means a hit names the record people open, the search re-checks that record as the asking user, and `where` and `metadataFields` read the record's own fields. There is no second object to secure, keep in step with the first, or delete with it. The field is indexed like any other content field: its text is sent to the embedder, and a credential or internal field is never indexed.
286
+
287
+
**An optional top heading names the document.** The text the embedder sees is the passage: neither the record's title nor the department that owns it is in it unless the text says so. Starting the index text with one top-level heading that names them, with every unit one level below it, makes each passage's heading path begin with that heading:
288
+
289
+
```md
290
+
# Group travel policy · Finance department
291
+
292
+
## Article 1 Scope
293
+
Applies to every employee travelling on company business.
294
+
295
+
## Article 7 Hotel limits
296
+
| Region | Limit per night |
297
+
|---|---|
298
+
| Region 1 | 600 |
299
+
| Region 2 | 450 |
300
+
301
+
Region 1 means Beijing, Shanghai, Guangzhou and Shenzhen.
302
+
```
303
+
304
+
Article 7 is then one passage that begins `Group travel policy · Finance department > Article 7 Hotel limits`, the table and its note together, and a question that names the policy or the department matches it. Keep the top heading short: a heading path is written into the passage whole only while it leaves at least half of the passage length for text, and otherwise shortens to the unit's own heading (the hit's `headingPath` still lists all of it). A title that is already in the top heading needs no second `content` entry: a field listed before the index text would become a passage of its own, ahead of the first heading.
305
+
306
+
Moving an existing source to this shape changes its `content` and `split`, so its index is rebuilt once ([below](#when-the-model-or-the-split-changes-rebuild)), and the rebuild sends the whole source to the embedding provider again.
description: "Longest passage, in characters, when the knowledge service splits a document. A size set on a knowledge source itself wins; the embedding model's input limit can lower it."},
75
+
description: "The longest a passage can be, in characters, when the knowledge service splits a document; passages can be shorter. A size set on a knowledge source itself wins; the embedding model's input limit can lower it."},
help: 'أقصى طول للمقطع بالأحرف عند تقسيم خدمة المعرفة لمستند. تكون الأولوية للحجم المحدد في مصدر المعرفة نفسه، وقد يخفضه حد الإدخال الخاص بنموذج التضمين.',
689
+
label: 'أقصى طول للمقطع (أحرف)',
690
+
help: 'أقصى طول للمقطع بالأحرف عند تقسيم خدمة المعرفة لمستند، وقد تكون المقاطع أقصر. تكون الأولوية للحجم المحدد في مصدر المعرفة نفسه، وقد يخفضه حد الإدخال الخاص بنموذج التضمين.',
Copy file name to clipboardExpand all lines: packages/services/service-settings/src/translations/de.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -722,8 +722,8 @@ export const de: PlatformTranslationData = {
722
722
},
723
723
keys: {
724
724
chunk_target: {
725
-
label: 'Ziel-Chunkgröße (Zeichen)',
726
-
help: 'Längste Passage in Zeichen, wenn der Wissensdienst ein Dokument aufteilt. Eine an der Wissensquelle selbst gesetzte Größe hat Vorrang; das Eingabelimit des Embedding-Modells kann den Wert senken.',
725
+
label: 'Längste Passage (Zeichen)',
726
+
help: 'Längste Passage in Zeichen, wenn der Wissensdienst ein Dokument aufteilt; Passagen können kürzer sein. Eine an der Wissensquelle selbst gesetzte Größe hat Vorrang; das Eingabelimit des Embedding-Modells kann den Wert senken.',
help: 'Longest passage, in characters, when the knowledge service splits a document. A size set on a knowledge source itself wins; the embedding model\'s input limit can lower it.'},
help: 'The longest a passage can be, in characters, when the knowledge service splits a document; passages can be shorter. A size set on a knowledge source itself wins; the embedding model\'s input limit can lower it.'},
description: 'Un valor definido en la propia fuente de conocimiento prevalece sobre estos valores predeterminados.'},
589
589
},
590
590
keys: {
591
-
chunk_target: {label: 'Tamaño objetivo de fragmento (caracteres)',
592
-
help: 'Longitud máxima de un pasaje, en caracteres, cuando el servicio de conocimiento divide un documento. Un tamaño fijado en la propia fuente tiene prioridad; el límite de entrada del modelo de embeddings puede reducirlo.'},
591
+
chunk_target: {label: 'Pasaje más largo (caracteres)',
592
+
help: 'Longitud máxima de un pasaje, en caracteres, cuando el servicio de conocimiento divide un documento; los pasajes pueden ser más cortos. Un tamaño fijado en la propia fuente tiene prioridad; el límite de entrada del modelo de embeddings puede reducirlo.'},
help: 'Longueur maximale d’un passage, en caractères, lorsque le service de connaissances découpe un document. Une taille fixée sur la source elle-même l’emporte ; la limite d’entrée du modèle d’embedding peut l’abaisser.',
734
+
label: 'Passage le plus long (caractères)',
735
+
help: 'Longueur maximale d’un passage, en caractères, lorsque le service de connaissances découpe un document ; un passage peut être plus court. Une taille fixée sur la source elle-même l’emporte ; la limite d’entrée du modèle d’embedding peut l’abaisser.',
0 commit comments