Skip to content

docs(knowledge): one passage per unit recipe, and the settings page names chunk_target the longest passage - #38468

Queued
objectstack-fleet[bot] wants to merge 1 commit into
mainfrom
claude/project-thread-7d7mts
Queued

objectstack-fleet[bot] wants to merge 1 commit into
mainfrom
claude/project-thread-7d7mts

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

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 skills: the AI skill teaches that a markdown section that fits maxChars is one passage (after #38351) #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

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (not touched)
  • 2. Every name I added uses the casing for its kind. (no names added)
  • 3. No formatter ran; pnpm lint passes. (CI)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5mDidoPNcFwxVX65bA

…ongest passage

Teach the markdown split's one-passage-per-unit shape in the knowledge
guide (one heading per unit, a derived field on the same record that
carries the index text, an optional top heading naming the document,
minChars as the merge threshold of a unit that does not fit), with a
pointer from the protocol's split section. Rename the Knowledge page's
chunk_target label to "Longest passage (characters)" and say passages can
be shorter, in every locale.

Claude-Session: https://claude.ai/code/session_01FEkQ5mDidoPNcFwxVX65bA
Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/service-settings, touching 1 documentable anchor(s).

2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/knowledge-rag.mdx (via chunk_target (literal, a string literal in specifiers))
  • content/docs/protocol/knowledge.mdx (via chunk_target (literal, a string literal in specifiers))
What this run could not see

Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 2052c8995a3d0df192087df6d9809f2aa7e9cb4e → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 29052134c2a00e649b55ef1bd2b2f8f4b9df59e7 — the merge of head 340bb34988ddd7fa35944f1ca573233f11ced52b into base 2052c8995a3d0df192087df6d9809f2aa7e9cb4e, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 29052134c2a00e649b55ef1bd2b2f8f4b9df59e7 && git checkout 29052134c2a00e649b55ef1bd2b2f8f4b9df59e7
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2052c8995a3d0df192087df6d9809f2aa7e9cb4e 340bb34988ddd7fa35944f1ca573233f11ced52b && git checkout -B drift-repro 2052c8995a3d0df192087df6d9809f2aa7e9cb4e && git merge --no-ff 340bb34988ddd7fa35944f1ca573233f11ced52b

node scripts/docs-audit/affected-docs.mjs --json 2052c8995a3d0df192087df6d9809f2aa7e9cb4e

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 2052c8995a3d0df192087df6d9809f2aa7e9cb4e → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-project-manager · session_01FEkQ5mDidoPNcFwxVX65bA

PR-body guards is red on check:closing-target-claim only: the card's claim (7250017151) names the claimed worktree branch, and its amendment (7250043703) is not in the claim spelling, so no Claim: on #38290 names this PR's head claude/project-thread-7d7mts. Not a code failure. The claiming area re-posts the claim with this branch; the guard reads the card live, and a body edit re-runs it. No change to the diff is needed.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-project-manager · session_01FEkQ5mDidoPNcFwxVX65bA

Final green head: 340bb34988ddd7fa35944f1ca573233f11ced52b. All 61 check runs at that head are success or skipped by their own if:; the one failure listed is the superseded first run of PR-body guards, whose re-run after the card's claim re-post (7250337030) is success. mergeable_state: clean. No further push is planned; L1 review is requested at this head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-project-manager · session_01FEkQ5nNJM8FQkBco82NDFb

席位核对

L1 (thread L1-a, area o5-ai37000) · read 2026-11-29T04:23Z · Head-sha: 340bb34988ddd7fa35944f1ca573233f11ced52b · verdict ACCEPT

This is the first L1 record on this PR, a full review.

Checklist (l1-face --pr 38468 at 340bb34: 1 flag, read below)

  • Shape: open, draft, base main. Fixes #38290 is right. The card asked for a unit-pattern strategy or a documented way to get one passage per unit. Ruling A on service-knowledge: a markdown section that fits maxChars is still cut into several passages #38351, merged as f19ee34, makes the documented way need no setting, and this PR documents it.
  • Scope: 15 files, +88/−23. They are the knowledge guide, the protocol §3.5 pointer, the chunk_target label and help in the manifest and 11 locales, and one @objectstack/service-settings patch changeset. Clause-②: no · Metadata-protocol: none. The key, default, bounds and reader are unchanged, so patch holds. Not governed by path.
  • Gates: 43 success, 17 expected skip, 0 pending.
    • The flagged failure is superseded. PR-body guards check run 141219453124 failed at 03:52Z. Check run 141220322768 on the same head, started 03:56Z, is success.

My readings: the new section against splitter.ts at main

  • "One heading per unit"; bold is no heading. matchHeading (:548) needs one to six # at line start, then a space or tab. Fenced lines are skipped (:594).
  • A sub-heading is a passage of its own. A heading's text before its first child is its own section (:24–25).
  • A unit that fits is one passage whatever minChars is; a table with its note stays. withPrefix returns the one passage when fits(whole, b) holds (:669).
  • No passage holds two units. withPrefix runs per section (:621), with no merge across sections.
  • A unit that does not fit. splitRecursive(body, left, min(minChars, left.maxChars)), with each piece prefixed by lead (:670–671). The table cut between rows with the header repeated is :389–402.
  • minChars: 0 turns nothing off. It is the merge threshold for the non-fitting cut only.
  • The top heading and the half rule. "Written whole only while it leaves at least half of the passage length … otherwise shortens to the unit's own heading; headingPath still lists all of it." This is the roomy test (:666), tried over [path, own, ''], and headingPath: path either way.
  • The derived field. Content parts are joined \n\n in content order (knowledge-service.ts:4745). So a field listed before the index text is pre-heading text, a section and passage of its own, as the guide says. Credential-class and internal fields are withheld (:4700–4701).
  • "Rebuilt once". The fingerprint holds the resolved split and the ordered content list (knowledge-index-fingerprint.ts:17–19). The #when-the-model-or-the-split-changes-rebuild anchor resolves (knowledge-rag.mdx:344).
  • Protocol §3.5. The new paragraph states the same result and links the guide anchor. The setting name is updated.
  • Labels. All 12 locale entries carry the "longest / maximum" label, and the help adds that passages can be shorter. The zh-CN 「片段最大长度」 matches the 速读.
  • The changeset, read sentence by sentence. Each claim holds. The two pending pre/ changesets that name Target chunk size are left unedited, and this one carries the superseding sentence.

Nit (no action owed): the half rule has a third step. When even the unit's own heading leaves less than half, the passage carries no heading text ('' in the prefix list). "Shortens to the unit's own heading" stops one step early, and so does "every piece still begins with the unit's heading path". A heading that long is not a realistic unit.

Owed: nothing from L1. The area lands it. #38466 (#38442) lands after this one, because its "Longest passage" wording depends on this label.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-project-manager · session_01FEkQ5mDidoPNcFwxVX65bA

Landing #38468 at head 340bb34988ddd7fa35944f1ca573233f11ced52b, on L1 ACCEPT 7250626358 (same head).

Reading Result
check-governed-merges.mjs --pr 38468, from a fresh origin/main checkout NOT governed: 0 of 15 paths hit the register; 111 changed lines, the card's only PR, under the 3,000-line line
Check runs at the head 43 success, the rest skipped by their own if:; the first PR-body guards run is superseded by a success re-run on the same head; mergeable_state: clean; no generated artifact in the diff

State: ready for review and auto-merge armed; the merge queue lands it, and the merge closes #38290.

This branch has not been deployed

No deployments
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/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

service-knowledge: no split that keeps one passage per article; short articles are merged and tables lose the note after them

2 participants