Skip to content

feat(service-knowledge): under the markdown split, a section that fits is one passage - #38439

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-38351-markdown-fitting-section
Nov 29, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-38351-markdown-fitting-section

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread
Fixes #38351
Clause-②: no
Metadata-protocol: semantic
Skills-docs: follow-up #38442

维护者速读

  • 用户能看到什么变化:按标题切分的知识源里,一个放得下一段的小节(一条条文、一节说明、一张表格连同它的注释)现在整节一段,检索命中的是完整的一条,不再是半条;放不下的小节切法与以前完全一样。
  • 为什么做:知识切分专题第一阶段,按您对“放得下的小节整节一段做成默认”的裁决(选 A)实现,作者不用再手动调合并阈值。
  • 出错会怎样:只影响按标题切分的知识源,这些知识源本来就要因上一个“标题丢失”修复重建一次,这次改动搭同一次重建,不再多建;切分功能仍在预发布期,撤回只需回退本次改动并再重建一次。
  • 要你做的:无。

What changes

  • Splitter (packages/services/service-knowledge/src/split/splitter.ts, withPrefix): under split.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, whatever minChars is. Only a section that does not fit reaches splitRecursive, 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. recursive and whole are untouched.
  • Which "fits" (Zone 2 hypothesis 3). Fitting is judged on the passage as emitted, fits(lead + body.trim(), b), not on fits(body, left). estimateTokens rounds 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.
  • Version. SPLIT_ALGORITHM_VERSION_BY_STRATEGY.markdown stays 2. Read at base d751790c: .changeset/38350-markdown-bodyless-headings.md is still pending, and the published @objectstack/service-knowledge@next is 19.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_VERSION and its export are not touched.
  • Prose that restates the ruling (ruling 7247322956, A): the splitter file head and splitMarkdown docblocks; the KnowledgeSplitSchema docblock for markdown, the minChars docblock and .describe, and the knowledge source form's minChars help text in packages/spec; the regenerated content/docs/references/ai/knowledge-source.mdx; content/docs/protocol/knowledge.mdx section 3.5 and content/docs/ai/knowledge-rag.mdx. No key, value, default or export changes (check:api-surface and check:authorable-surface green).
  • Form translations (patch round 1, contract review record 7249205899 M1/S1): the en bundle leaf source.split.minChars.helpText in packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts regenerated by node scripts/check-i18n-bundles.mjs --write; the hand-translated zh-CN, ja-JP and es-ES leaves re-translated to the new rule. The other seven locales serve the new English through their source-hash fallback.
  • Changeset .changeset/38351-markdown-fitting-section.md: @objectstack/service-knowledge minor, @objectstack/platform-objects minor (the bundles above), and @objectstack/spec minor, because the spec's shipped prose changes (the .describe string ships in the JSON schemas and the reference, the help text ships in the form) and AGENTS.md asks at least minor of a semantic kind 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:

  • three 250-character paragraphs under one heading at the default minChars: one passage, prefix first;
  • the same with minChars: 0: still one passage;
  • a section that does not fit: cut exactly as before (pinned output), and minChars still merges its short pieces;
  • the prefix counts: exactly maxChars with the prefix is one passage, one character more is cut;
  • a path too long for the half-bounds rule falls back to the innermost heading, and that passage fits: one passage under the innermost prefix;
  • a table and its note inside a fitting section: one passage;
  • the token budget: under maxChars but over the budget is still cut, each piece within it;
  • "fits" reads the emitted passage (the rounding case above);
  • text before the first heading that fits: one passage, no path;
  • a parent's own text before its first child: one passage when it fits;
  • recursive unchanged 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.json is 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, maxChars 800. A unit "fits" when its passage under its full heading path is within maxChars and the token budget. Real estimateTokens, not stubbed.

Shape Setting Passages Mixed passages Fitting units split Fitted table + note together
Units are headings default, before 6,814 0% 261 / 6,018 (4.34%) 209 / 251 (83.3%)
Units are headings default, after 6,537 0% 0 / 6,018 (0%) 251 / 251 (100%)
Units are headings minChars = maxChars (before = after) 6,342 0% 0 251 / 251
Units are bold paragraphs under chapter headings default, before 4,245 59.22% 891 / 6,208 60 / 260
Units are bold paragraphs under chapter headings default, after 3,951 (-6.9%) 59.68% (+0.46 pt) 813 / 6,208 69 / 260
Units are bold paragraphs under chapter headings minChars = maxChars (before = after) 2,486 75.22% 262 / 6,208 218 / 260
  • Topic bar met on heading-shaped input: 0% of fitting units split (bar 0.5%), 0 mixed, every fitted table with its note.
  • Non-heading shape, the reading the ruling asked for: passages -6.9%, mixed share +0.46 points. The minChars = maxChars recipe on the same input gives -41% and +16 points.
  • With a 512-token embedder (budget 409), both shapes read identically before and after: under that budget the fitting sections were already one passage.
  • Byte-identity of sections that do not fit, measured: 20,000 random Markdown documents (headings, tables, lists, Chinese and English sentence marks) under random maxChars, minChars and 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.
  • Zone 2 hypothesis 5 (the card's 0.2% residual under the recipe): not reproduced. The synthetic corpus gives 0 there, as in the decision analysis; its headings are short, so the prefix fallback is never reached. Not explained here.
  • Not touched, by the order: 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 the maxChars/minChars keys), skills/** (the Skills-docs: follow-up), content/docs/releases/, and the markdown entry's comment in SPLIT_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.mdx section 3.5's markdown row 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:

  1. packages/services/service-knowledge/src/split/splitter.ts, withPrefix: the two early returns (the fits(whole, b) lines) and the comment above the prefix loop.
  2. packages/spec/src/ai/knowledge-source.zod.ts: the markdown bullet and the minChars docblock and .describe (contract-tier L2 face).
  3. content/docs/protocol/knowledge.mdx section 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 on 4723a4fe, no splitter or test change): pnpm check:i18n red at 4723a4fe (platform-objects DRIFTED (1)), exit 0 at c645c319 (all bundles in sync); check:i18n-stale-fill exit 0; pnpm --filter @objectstack/platform-objects exec vitest run src/apps/translations: 28 files, 625 tests passed; spec check: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 base d751790c.

  • 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 typecheck exit 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-surface green, authorable-surface.base.json untouched.
  • Red before the fix, on the unmodified splitter: 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; --ran reconciliation: 114 accounted, 110 exit 0, 4 NOT MEASURED (exit 3, prerequisite not met in this container: check-plugin-teardown-shape --self-test needs an unshallow clone; check:skill-examples, check:dual-build-cjs-loads and check:i18n need a full workspace build). CI runs all four.
  • node scripts/pm/overlap-check.mjs --branch=HEAD: VERDICT clean exit 0, merges cleanly with origin/main, 0 open PR heads overlapping.
  • Dogfood battery: not owed (no ! in the title, no (narrowing) arm).

Generated by Claude Code

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
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation protocol:ai tests 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

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/platform-objects, @objectstack/service-knowledge, @objectstack/spec, touching 5 documentable anchor(s).

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

  • content/docs/ai/knowledge-rag.mdx (via knowledge_source (symbol, a field of const object enMetadataForms; a field of const object esESMetadataForms; a field of const object jaJPMetadataForms; a field of const object zhCNMetadataForms), minChars (literal, a string literal in sections))
  • content/docs/getting-started/quick-reference.mdx (via knowledge_source (symbol, a field of const object enMetadataForms; a field of const object esESMetadataForms; a field of const object jaJPMetadataForms; a field of const object zhCNMetadataForms))
  • content/docs/permissions/system-context.mdx (via knowledge_source (symbol, a field of const object enMetadataForms; a field of const object esESMetadataForms; a field of const object jaJPMetadataForms; a field of const object zhCNMetadataForms))
  • content/docs/protocol/knowledge.mdx (via knowledge_source (symbol, a field of const object enMetadataForms; a field of const object esESMetadataForms; a field of const object jaJPMetadataForms; a field of const object zhCNMetadataForms), minChars (literal, a string literal in sections))
What this run could not see
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 253 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 125 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 181 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 da184dacd9d4f8ee66710453f235255e7fdee223 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 65fc776b299235f26545cbcf7721e9ade67f37bd — the merge of head c645c31925a58f83088e62b0e8e832eecc920145 into base da184dacd9d4f8ee66710453f235255e7fdee223, 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 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

⚠️ 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 da184dacd9d4f8ee66710453f235255e7fdee223 → 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_01FEkQ5mCvGQKiCEBneFwp1j

Contract-review-claim: session_01FEkQ5mCvGQKiCEBneFwp1j · head 4723a4f · 2026-11-29T01:50Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 4723a4fe1d269a904c7b7a9cfd3c70ea81544d29
Local-runs: none
Scope: packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/ai/knowledge-source.metadata-form.ts + packages/services/service-knowledge/src/split/splitter.ts
Security-touching: no
Rule-change-verified: none

Read: card #38351 (body and all five comments, ruling 7247322956 included), PR #38439 (body, eight files, the diff against main), and the check-runs on this head as of 2026-11-29T02:02Z: 30 success, 1 failure, 12 skipped, 30 still running (11 Test Core shards, 16 Test UI shards, Type Check · workspace, Type Check UI, Build & E2E UI). The failure decides this record; the running ones do not change it.

① Derived judgments

  • Accept set: unchanged. Right. KnowledgeSplitSchema keeps the same three keys, the same enum and the same number bounds; only a docblock and one .describe string move. Spec property liveness and Type Check · source gates are green on the head.
  • Exports: unchanged. Right. withPrefix is private, splitMarkdown keeps its signature, and no constant is added or moved.
  • Published prose: minChars description changes. Right. The regenerated content/docs/references/ai/knowledge-source.mdx carries the new sentence in both tables, and the spec artifact gates in Type Check · source gates are green.
  • Behaviour: markdown passages change for a section that fits but was cut. Right, and it is ruling A. Such a section becomes one passage, so the passage count and the documentId#index ids of that document shift. recursive and whole are untouched.
  • Index fingerprint: unchanged. Right under execution reading 3. markdown stays at 2. The condition that reading sets holds in the tree: .changeset/38350-markdown-bodyless-headings.md is still pending on live main (4437c50) and the package is still at 19.0.0-next.2.
  • Committed form translations: not regenerated. Wrong. The help text edited in knowledge-source.metadata-form.ts is the source of packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts, which the diff does not touch. This is M1 below.

② Semver level

  • Level matches the kind. The changeset gives minor to @objectstack/service-knowledge and @objectstack/spec. AGENTS.md Post-Task step 3 asks at least minor of a semantic kind on each package the diff moves, and these are the two it moves today.
  • Clause-②: no is correct. Nothing an author can write is added, removed or refused, and no export or route changes. The line is in both the PR body and the changeset.
  • Metadata-protocol: semantic is correct. The same written strategy: 'markdown' and minChars now mean something different, which is the ruling's own declaration (reading 4). Check Changeset is green.
  • The M1 fix will move a third package. Regenerating the bundle edits packages/platform-objects/src, so the changeset then owes @objectstack/platform-objects a line (.changeset/37309-knowledge-source-studio-form.md is the precedent for the same bundle). The delta review reads that line.

③ Boundary flags

  • open_questions: empty. Nothing to answer.
  • Dev flag, the markdown: 2 comment left as it is: answered as N1 below. Accepted for this PR; the carrier the dev names (review follow-ups of PR #38375 #38377) is "noted, not filed", so the seat has to put it on that card.
  • Dev flag, the card's 0.2% residual not reproduced: answered, no contract effect. The ruling's bar is 0.5% and the residual belongs to the minChars = maxChars recipe, which this change makes unnecessary.
  • Skills-docs: follow-up owed: accepted as declared; the ruling asks for the line. skills/objectstack-ai/SKILL.md:333-341 on main still teaches "Adjacent pieces shorter than minChars (default 200) are merged" with no fitting rule. No card number is named yet. The claim says the area files it before ACCEPT, and that is still owed.
  • ADR-0161 wording note (reading 4): escalated to the seat. The PR body defers it to "a separate card" without a number, and the card thread names none. docs/adr/0161-…md:274 is the sentence concerned ("it changes when the splitter gives different passages for the same text and settings"). Name the carrier before ACCEPT.
  • Acceptance numbers (reading 5): not verified here. The corpus table and the 20,000-document byte-identity run are the dev's local measurements on a synthetic corpus. No check-run carries them and this review is read-only. By reading the code I agree with the byte-identity claim: a section that fails the new check reaches the same splitRecursive call with the same arguments.
  • SQL push-down: none. The splitter is a pure function and the diff adds no query, id materialisation or join.
  • Security: no changed hunk teaches permission, sharing, credential or authentication behaviour.

④ Design judgment

packages/spec/src/ai/knowledge-source.metadata-form.ts — does not hold at its first consumer.

M1 (must-fix) — the new minChars help text reaches no Studio user on this head, and its gate is red.

  • The server localises this form from the platform-objects bundles (packages/platform-objects/src/metadata-translations/index.ts:56), and resolveMetadataFormLabels lets a bundle leaf replace the form's own string.
  • en.metadata-forms.generated.ts:3579 still holds the old sentence, ending "Recursive and Markdown only." So English shows the old text, and so do the seven locales that fall back to the en bundle.
  • Check-run Type Check · consumer gates is failure on this head. Its step "Check generated translation bundles are in sync with the schema" (pnpm check:i18n) prints platform-objects DRIFTED (1). It is the only red gate step in that lane.
  • The dev report lists check:i18n as NOT MEASURED locally, which is why it was missed.
  • Fix: node scripts/check-i18n-bundles.mjs --write after a workspace build, commit the regenerated bundle, and add the changeset line from ②.

S1 (should-fix) — three hand-translated locales keep the old rule after M1's regeneration.

  • zh-CN, ja-JP and es-ES hold real translations of the old sentence at source.split.minChars.helpText (line 3579 of each bundle).
  • They have no entry in their source-hashes tables, so they are served as they are. Merge mode keeps them, and no gate reports them.
  • A Chinese author would still read that short neighbours are merged up to this length under Markdown, with nothing about a fitting section. That is the misreading ruling A removes.
  • Fix: re-translate those three leaves in the same commit as M1.

packages/spec/src/ai/knowledge-source.zod.ts — holds against the ruling and the splitter.

  • The markdown bullet (lines 96-101), the minChars docblock (120-123) and the .describe (126) each agree with withPrefix as changed.
  • "Within the effective maxChars" covers the token budget, because the same docblock defines the effective maxChars as the smaller of the character value and what fits in 80% of the embedder's limit.
  • "Whatever minChars is" is true: the fitting check runs before minChars is read, so minChars: 0 does not opt out (reading 2).
  • "The text before the first heading, and a heading's text before its first sub-heading, are sections too" matches splitMarkdown, which flushes a section at every heading.

N2 (nit) — "its text with its heading path" is narrower than the code in one corner.

  • When the full path would take more than half the bounds, withPrefix falls back to the innermost heading, and fitting is judged under that shorter prefix.
  • A section whose text plus full path is over maxChars can therefore still be one passage. The splitter's own docblock says "the heading path it is given", which is exact.
  • The direction is harmless (fewer cuts) and the fallback predates this PR. Accepted as it stands; cheap to align while the head moves for M1.

packages/services/service-knowledge/src/split/splitter.ts — the code agrees with the contract.

  • One passage is exactly the section. whole is the selected prefix plus the trimmed body, the same bytes the old path produced whenever it returned one piece. No text is dropped or reordered.
  • No passage can exceed the bounds. The early return is guarded by fits(whole, b), which is the bound the file promises for every passage.
  • The "emitted passage" reading is sound. I checked the comment's claim against estimateTokens: the prefix ends in whitespace, so the raw sums add and the rounded estimate of the passage is at most the two rounded apart. The new check accepts everything the old per-part check accepted, plus the one-token rounding case.
  • Sections that do not fit are untouched. They reach splitRecursive(body, left, Math.min(minChars, left.maxChars)) as before.
  • The path-less branch and the body-less heading branch are correct. Text before the first heading takes the same rule; a heading with no text returns before the new lines.
  • I tried a path too long for the half-bounds rule, a prefix that is whitespace only, a token budget at or below the prefix, a table inside a fitting section, and minChars above maxChars. None breaks the bound or the contract.

N1 (nit) — the version table's own prose no longer describes version 2.

  • Its docblock (lines 75-83) says to bump an entry "in the change that makes that strategy give different passages", and the comment on markdown: 2 (94-96) names only the body-less heading change.
  • This diff changes markdown passages and rides 2, which reading 3 allows. Only the changeset records that 2 carries both changes.
  • No effect on the fingerprint or on correctness. Accepted deviation here; follow up on review follow-ups of PR #38375 #38377, which edits that block.

M1 is a must-fix, so this head fails. The delta review owes M1 and S1, plus the changeset line.

Implemented-by: claude/issue-38351-markdown-fitting-section
Reviewed-by: session_01FEkQ5mCvGQKiCEBneFwp1j

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
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract-review-claim: session_01FEkQ5mCvGQKiCEBneFwp1j · head c645c31 · 2026-11-29T02:16Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: c645c31925a58f83088e62b0e8e832eecc920145
Local-runs: none
Scope: packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/ai/knowledge-source.metadata-form.ts + packages/services/service-knowledge/src/split/splitter.ts, packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts, packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts, packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts, packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts
Security-touching: no
Rule-change-verified: none

Delta review from 4723a4fe1d269a904c7b7a9cfd3c70ea81544d29 (record 7249205899: must-fix M1, should-fix S1, nits N1 and N2) to this head.

Read: card #38351 (body and all six comments, ruling 7247322956 and both dev reports included), PR #38439 (body, twelve files, the diff against main and the two-commit delta, 8 files, +12/−10), and the check-runs on this head as of 2026-11-29T02:22Z: 31 success, 0 failure, 9 skipped, 29 still running (Build Core, 9 Test Core shards, 16 Test UI shards, Type Check · workspace, Type Check UI, Build & E2E UI). Nothing is red. The running ones do not decide this record; a red one among them would overturn it.

The delta leaves splitter.ts, knowledge-source.metadata-form.ts, the test file and the regenerated reference page byte-identical to round 1's head. main has not moved under any file of this diff since the merge base d751790c.

① Derived judgments

  • Accept set: unchanged. Right. KnowledgeSplitSchema keeps its three keys, enum and number bounds. The delta edits one docblock sentence in the zod file and no .describe string. Spec property liveness and Type Check · source gates are green on this head.
  • Exports: unchanged. Right. No export is added, moved or retyped in any of the three packages.
  • Published prose: the minChars description. Right. The reference page carries it in both tables and the delta did not need to regenerate it.
  • Committed form translations: now in step. Right. The en bundle leaf at en.metadata-forms.generated.ts:3579 is byte-equal to the form's help text. The key set of every bundle is unchanged; four leaf values move. This was the "Wrong" line of round 1.
  • Behaviour: markdown passages change for a section that fits but was cut. Right, and it is ruling A. Unchanged since round 1.
  • Index fingerprint: unchanged. Right under execution reading 3. markdown stays at 2. The condition still holds on live main (1afd9c1): .changeset/38350-markdown-bodyless-headings.md is pending, the three packages are at 19.0.0-next.2, and that changelog section does not carry the body-less heading fix.

② Semver level

  • Level matches the kind on all three packages. The changeset now gives minor to @objectstack/service-knowledge, @objectstack/spec and @objectstack/platform-objects. AGENTS.md Post-Task step 3 asks at least minor of a semantic kind on each package the diff moves, and the delta moves packages/platform-objects/src. The knowledge_source: a Studio form to create and edit a knowledge source (object, content fields, metadata fields, where, split) #37309 precedent was patch because its kind was none, so minor here is the right reading, not an over-bump. The three packages are in one fixed group, so the release version is the same either way.
  • Clause-②: no and Metadata-protocol: semantic are still correct, in both the PR body and the changeset. Check Changeset is green on this head.
  • The changeset's new sentence is true. It says the Setup bundles carry the new help text, regenerated for en and re-translated for zh-CN, ja-JP and es-ES. That is what the diff does.
  • One stale line in the changeset body, not blocking. It still reads Skills-docs: follow-up owed — skills/objectstack-ai/SKILL.md, while the PR body now names skills: the AI skill teaches that a markdown section that fits maxChars is one passage (after #38351) #38442. The rule owes that line to the PR body only, and the gate is green. Leave it: editing the changeset moves the head.

③ Boundary flags

  • open_questions: empty in both reports. Nothing to answer.
  • Dev flag, seven locales hold an older English copy of the minChars help text: answered, not a defect at the consumer. ar, de, fr, ko, pt-BR, ru and zh-Hant each record that leaf in their source-hashes.generated.ts table with the same digest (ar: line 81). MetadataFormsTranslations passes every translated locale through withSourceFallback, which serves the en string for a recorded copy whose source has moved. So those seven serve the new English sentence. I read this from the code and the green check:i18n step, which keeps the tables in sync; I did not run it.
  • Dev flag, minor against the patch precedent: answered in ②.
  • Dev flag, N1 left to review follow-ups of PR #38375 #38377: still accepted, and still not written on that card. Its thread has two comments (triage and the claim) and neither names the markdown: 2 comment. The seat owes that note before ACCEPT.
  • Skills-docs:: now follow-up #38442 in the PR body. The card exists, is open, is blocked by service-knowledge: a markdown section that fits maxChars is still cut into several passages #38351, and asks for the two SKILL.md sentences round 1 named. Answered.
  • ADR-0161 wording note (execution reading 4): escalated to the seat again. The PR body now says no ADR note is owed. A PR body cannot withdraw an item of the ruling's execution reading. My reading of the tree: docs/adr/0161-…md:274 says the version "changes when the splitter gives different passages for the same text and settings"; this change gives different passages and stays at 2, which only the topic's one-bump-per-train rule licenses. Before ACCEPT, the seat records on service-knowledge: a markdown section that fits maxChars is still cut into several passages #38351 either a carrier (review follow-ups of PR #38375 #38377 already carries a K7 revisions row for the same table) or the withdrawal of that item.
  • PR body describes round 1, the seat's to fix, no head change. Its changeset paragraph names two packages, its "What changes" list omits the four bundles, and its local-runs block is pinned to 4723a4fe. The dev report says so too.
  • Acceptance numbers (reading 5): not verified here, as in round 1. No splitter line changed in the delta, so they describe this head as well as they described the last.
  • SQL push-down: none. The delta adds no query, id materialisation or join.
  • Security: no changed hunk teaches permission, sharing, credential or authentication behaviour.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/ai/knowledge-source.metadata-form.ts and its four bundles — hold at the first consumer.

M1: closed.

  • Commit 9aeceaa regenerates one leaf, source.split.minChars.helpText in the en bundle, and it equals the form's string byte for byte.
  • No provenance table changed, which is what the generator's rule predicts: the en rewrite touches no translated leaf.
  • Check-run Type Check · consumer gates is success on this head. Its step "Check generated translation bundles are in sync with the schema" is green, and so are the three i18n steps after it.
  • The changeset line round 1 asked for is there (②).

S1: closed.

  • zh-CN, ja-JP and es-ES each keep the old sentence and add the fitting rule: under Markdown a section that fits is one passage, so only the pieces of a section that does not fit are merged. I read all three against the English; each says that and nothing more.
  • Their words match the neighbouring leaves (段落, パッセージ, pasaje for passage). zh-CN says 小节 where the strategy option says 章节; both read naturally.
  • None of the three has a provenance entry, before or after, so each is served as written. AGENTS.md allows hand edits to translated-locale values in these files.

packages/spec/src/ai/knowledge-source.zod.ts — holds against the ruling and the splitter.

N2: closed. The markdown bullet now reads "its text together with the heading path it is given (the whole path, or the innermost heading when the whole path is too long)". That matches the first two prefixes withPrefix tries, and content/docs/protocol/knowledge.mdx section 3.5 says the same. knowledge-rag.mdx takes the short form and links to that section. The rest of the docblock, the minChars docblock and the .describe are unchanged and still agree with the code.

N3 (nit) — the new parenthetical lists two of the three prefixes.

  • withPrefix tries the whole path, then the innermost heading, then no prefix at all. The last is taken when the innermost heading alone would leave less than half the bounds for text.
  • Fitting is then judged on the text alone, and the passage does not begin with a heading. The docblock (lines 98-99) and section 3.5 do not say so.
  • It needs a heading of about half maxChars (399 characters at the default, 49 at maxChars: 100). The direction is harmless (fewer cuts) and the fallback predates this PR.
  • Accepted as it stands. Fix it the next time this docblock is opened; a fix now moves the head.

N4 (nit) — line 101 of the docblock is 95 columns in a block wrapped at about 77. Cosmetic; left.

packages/services/service-knowledge/src/split/splitter.ts — the code agrees with the contract.

  • Unchanged since round 1, and I re-read splitMarkdown and withPrefix on this head.
  • The one passage is the selected prefix plus the trimmed text, guarded by fits(whole, b), so it can never exceed the bounds the file promises.
  • A section that does not fit reaches the same splitRecursive call with the same arguments as on main.
  • The path-less branch and the body-less heading branch are as round 1 found them.
  • I tried again a path over half the bounds, a heading over half the bounds, a token budget below the prefix, and minChars above maxChars. None breaks the bound.

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: claude/issue-38351-markdown-fitting-section
Reviewed-by: session_01FEkQ5mCvGQKiCEBneFwp1j

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Final green head declared for L1: c645c31925a58f83088e62b0e8e832eecc920145.

@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-29T02:47Z · Head-sha: c645c31925a58f83088e62b0e8e832eecc920145 · verdict ACCEPT

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

Checklist (l1-face --pr 38439 at c645c31: CLEAN, 13 items, exit 0)

  • Shape: open, draft, base main. Fixes #38351 is right. It delivers ruling A, recorded on the card: a markdown section that fits is one passage, minChars keeps its meaning for sections that do not fit, and it shares the strategy version move.
  • Scope: 12 files, +206/−27. They are the splitter and its test, the spec docblocks, the minChars describe and form help text, the four regenerated or re-translated Setup bundles, and three docs pages. The one changeset bumps service-knowledge, spec and platform-objects minor. Clause-②: no · Metadata-protocol: semantic, and AGENTS.md says a kind takes at least minor on each package the diff moves. Skills-docs: follow-up #38442 (open, the AI skill's markdown passage rule). The diff touches packages/spec/src/**, so the contract-tier L2 is owed: delta PASS 7249418590 on this head (M1 and S1 of round-1 record 7249205899 closed per that record; N3 and N4 left as nits).
  • Gates at c645c31: 65 success, 11 expected skip, 0 failed, 0 pending; mergeable_state clean. Not governed, so the area lands it.

My readings, at this head (detached worktree, restored, removed)

  • vitest run src/__tests__/split.test.ts: 41 passed.
  • Ablation: dropping the new fits(whole, b) return in withPrefix turns 7 cases red. Among them are the default-minChars case, minChars: 0 not being an opt-out, the exactly-maxChars boundary with the prefix counted, the innermost-heading fallback, and the table with its note. The source was restored.
  • Code: fitting is judged on the passage as emitted (prefix plus trimmed text, through fits), under the same prefix withPrefix selects. A section that does not fit still goes through splitRecursive with the same bounds and min(minChars, left.maxChars), so its passages are unchanged, as the changeset claims. The pre-heading text gets the same rule in the path.length === 0 branch.
  • No version bump, checked. splitter.ts:96 reads markdown: 2. The move from 1 to 2 is made by .changeset/38350-markdown-bodyless-headings.md, still pending on main: its line 16 says "The markdown split algorithm version moves from 1 to 2". The changeset file is not yet consumed, so no released version has shipped markdown: 2, and this change rides it. Every markdown source rebuilds once. If a Version Packages PR consumes 38350 before this merges, the reading changes, so it should be re-checked at landing.
  • Docs, read sentence by sentence (knowledge-rag.mdx, protocol/knowledge.mdx table, the minChars code comment and the effective-length paragraph, the two references/ai/knowledge-source.mdx rows). Each states the new rule: one passage when it fits, whatever minChars is; the prefix counts; a section that does not fit is cut as recursive cuts. Each agrees with the code and with the spec describe. The reference rows match the regenerated describe text byte for byte.
  • Changeset, sentence by sentence. Each claim holds against the diff: what changed, that a non-fitting section gives the same passages, the pre-heading and parent-heading text, that recursive/whole are unchanged, that no key or default changes, and the version reading above.

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 .changeset/38350-markdown-bodyless-headings.md is still unconsumed. Then the area lands it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Landing · head c645c31925a58f83088e62b0e8e832eecc920145

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

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 29, 2026 02:49
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit f19ee34 Nov 29, 2026
77 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-38351-markdown-fitting-section branch November 29, 2026 03:15
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 protocol:ai size/m tests 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: a markdown section that fits maxChars is still cut into several passages

2 participants