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).
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