Repository navigation
feat(service-knowledge)!: one splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key; KnowledgeChunk.metadata and knowledge.chunk_overlap retired - #37287
Conversation
… embedding descriptor, reindex failures Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…lden files and the budget property Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…e chunks; whole over the budget is removed and reported Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…ns, chunk_overlap retired, contract suite chunk cases and stubs Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
… read through the settings service Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…siness words, visibility pin moved Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…limit Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…e tenant-audit census can place its delete Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…eiver; the chunk-channel engine double holds the caller's bound Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…Strategy (ADR-0122) Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…em 5) — tombstone, retired-key and D3 semantic entries, step-18 rationale Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
… declarations, the ADR-0087 marker Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…unk key Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…owledge-splitter # Conflicts: # content/docs/protocol/knowledge.mdx # packages/plugins/knowledge-memory/src/__tests__/contract.test.ts # packages/plugins/knowledge-memory/src/index.ts # packages/services/service-knowledge/src/knowledge-service-plugin.ts # packages/services/service-knowledge/src/knowledge-service.ts # packages/services/service-knowledge/src/testing.ts # packages/spec/src/ai/knowledge-document.zod.ts
…ment reference from the merged tree Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
…d declare organizationIds, beside the merged organization cases Claude-Session: https://claude.ai/code/session_01QSeKYoHKp8EUQtketT9S29 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 5 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 178 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 a9947ebcda6f1ffccebcf1a22da3cc766dcab6e9 && git checkout a9947ebcda6f1ffccebcf1a22da3cc766dcab6e9
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 4ed453dc211f24114c36133cb016515f377d2d5c c84c242aa76ac788c77052c6a33335912f58ee17 && git checkout -B drift-repro 4ed453dc211f24114c36133cb016515f377d2d5c && git merge --no-ff c84c242aa76ac788c77052c6a33335912f58ee17
node scripts/docs-audit/affected-docs.mjs --json 4ed453dc211f24114c36133cb016515f377d2d5c
|
|
repo:objectstack#4 · os-justin · session_01QSeKYoHKp8EUQtketT9S29 {
"issue": 37098,
"status": "done",
"branch": "claude/issue-37098-knowledge-splitter",
"pr": "https://github.com/objectstack-ai/objectstack/pull/37287",
"session": "session_01QSeKYoHKp8EUQtketT9S29",
"premise_still_valid": true,
"summary": "Draft PR #37287 at head c84c242aa, under claim 7158315677 (Metadata-protocol: narrowed). It delivers the card's What 1–6: one service-layer splitter (whole / recursive / markdown, Chinese-aware sentence rule, tables and list items kept whole while they fit), the chunk channel and the capabilities.chunks flag (ADR-0161 K8 item 5), embedding.maxInputTokens on the adapter and IEmbedder.maxInputTokens? (K8 item 6; embedder-openai fills it), the split key (K8 item 10), whole-over-budget removed and reported (failed/failures; the event path logs at error; indexDocument throws), knowledge-memory taking the service's passages, chunk_target with a reader, and both docs pages. Per seat direction B (7158283273) and its ruling A, KnowledgeChunk.metadata is retired here with the kit under protocol major 18. knowledge.chunk_overlap is retired the Localization-format way. #37256 was merged in via os-regen-merge.sh, keeping both sides. docHash recipe unchanged.",
"tests": "On head c84c242aa: service-knowledge 253/253 (split.test.ts with 6 golden files and a 500-document seeded budget property; contract-stubs; chunk-channel; the merged organization cases); knowledge-memory 34/34 (contract suite with listDocuments, chunks and organizationIds); embedder-openai 30/30; service-settings 1523/1523 (pre-merge head; the merge did not touch it); spec 985 files / 29934 tests (pre-merge kit head 455310944, then check:generated green after the merge); step18-rationale-merge 9/9; packages/cli test/migrate-meta-engine-guidance.test.ts 3/3. Typecheck exit 0 for spec, service-knowledge, knowledge-memory, embedder-openai and service-settings, check:test-typecheck included, so the tsc-channel @ts-expect-error pin is live. No ablation: the behaviours are new, not changed.",
"gates": "Local, head c84c242aa: dispatch-gates --commands derived 122 families; all 122 ran, all exit 0; --ran: 122 derived, 122 run, 0 NOT-MEASURED, 0 UNRUN. The earlier four real findings stay fixed (tenant-audit census, logger receiver detach, objectql double limit, ADR-0122 parsed aliases). The two earlier NOT MEASURED (check:skill-examples, check:dual-build-cjs-loads) ran and passed once the closure was built. check-adr-0087-registration exit 0 (1 declared-breaking changeset, carrying its disposition); check-changeset-no-major exit 0; check-empty-changeset exit 0; spec check:generated: all 14 artifacts up to date. PR #37287 check-runs: 74/74 completed, none failed. Required contexts: Lint & Repo Gates success, TypeScript Type Check success, Test Core success, Build Core success, Governed Surface Queue Guard success, Type Check UI success, Test UI success, Build & E2E UI success, Live E2E UI success, Dogfood Regression Gate success, Lint UI skipped (no ui/ diff). Also success: Check Changeset, Spec property liveness, Check PR Size, PR-body guards.",
"dogfood_battery": "c84c242aa · os-verify-lock VERDICT command-exit 0 (48m43s) · Test Files 487 passed | 3 skipped (490) · Tests 4128 passed | 68 skipped (4196) · no failures",
"mcp_calls": "15 — mcp__github__issue_read x6, mcp__github__pull_request_read x2 (get_check_runs), mcp__claude-code-remote__send_message x7; no GitHub MCP write",
"api_writes": "5 — post-stamped report comments 7158152761, 7160020786, 7160082130 on #37098, the relay pr_create of #37287 (run 45610900972, read-back identical, assignee os-justin, no labels), and this comment",
"line_budget": "62 files; 2553 insertions + 233 deletions = 2786 changed lines against merge base f9fda2a4f, under 3000, so not Tier H by size",
"files_changed": "packages/services/service-knowledge (src/split/ new; knowledge-service.ts, knowledge-service-plugin.ts, testing.ts; tests split, contract-stubs, chunk-channel new; knowledge-service.test.ts; fixtures/split/*), packages/spec (ai/knowledge-document.zod.ts and its new test, ai/knowledge-source.zod.ts, contracts/knowledge-adapter.ts, embedder.ts, knowledge-service.ts with failed?/failures? only; migrations/entries/retired-keys/18.ai__KnowledgeChunk__metadata.ts, migrations/entries/semantic/18.knowledge-chunk-metadata-retired.ts, migrations/registry.ts.template with one STEP18_RATIONALE fragment; regenerated api-surface, export-origins, declaration-map, authorable-surface, references, strictness-ledger counts), packages/plugins/knowledge-memory, packages/plugins/embedder-openai, packages/services/service-settings (knowledge.manifest.ts and its test, 11 translations, settings-visibility-declaration.pin.test.ts), content/docs/protocol/knowledge.mdx, content/docs/ai/knowledge-rag.mdx, .changeset/37098-knowledge-splitter.md",
"deviations": [
"Earlier WIP pushes went out without overlap-check before each (noted by the PM); every push since has run it first.",
"No D2 MetadataConversion for KnowledgeChunk.metadata, although the relay asked for one. A chunk is a runtime contract shape, never stored in stack metadata, so a conversion has no source to walk. The kit routes such a key through the D3 semantic entry plus RETIRED_KEYS_BY_MAJOR only; precedent: ActionDescriptor.isAsync. retiredAfter is a conversion field (SemanticMigration has none), so it does not apply.",
"The retirement kit touches files outside the claim's literal file list, on the PM's order to follow the kit: the two migrations entries, registry.ts.template and packages/spec/src/ai/knowledge-document.test.ts. Two settings manifest pins (settings-visibility-declaration.pin.test.ts, knowledge.manifest.test.ts) moved with the ordered chunk_overlap retirement.",
"No minChars <= maxChars refinement: the published JSON Schema cannot carry it, and its baseline is outside the claim. A minChars above the effective maxChars reads as maxChars, documented on the key.",
"The worktree /home/user/objectstack-issue-37098 is kept rather than removed: #37265 still shares files, and its merge is the next expected round."
],
"open_questions": [],
"security_findings": "withheld",
"out_of_scope_findings": [
"carrier: skills/objectstack-ai/SKILL.md owner · noted, not filed — the skill does not name the new split key; skills/** is governed and outside this claim",
"carrier: #37100 · noted, not filed — docHash does not cover passages, so a changed split setting re-splits a document only when the document changes; the index fingerprint closes it, and the docs say so"
]
}Generated by Claude Code |
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ Contract reviewServed-tier: Face: schema ( ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: PASS |
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — REWORK · L1 · head
|
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — ACCEPT · L1 · head
|
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ Contract reviewServed-tier: Same-head delta over the contract review 7163151592. The head is unchanged: the live PR reads S1, closed
Carried, by referenceEverything else in 7163151592 stands as written and was not re-read: ① both deviations hold (D3 only for the runtime-only One observation, no finding: N6's second half (速读 line 4 says nothing is asked of the maintainer) still reads the same in the live body; it stays a nit, and the seat's hand-off carries the ask. Implemented-by: VERDICT: PASS No must-fix, no should-fix. |
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 维护者速读
席位意见:通过。两处移除都没有读者,移除按 ADR-0161 K8 第 5 项和席位 7158283273 的方向做,退役登记齐全(协议 18)。开发者没有写数据迁移,是对的:片段只在运行时存在,不存进任何元数据。切分器的样例和上限属性我在评审中重跑过,全部通过。技能文档的跟进已立卡 #37292。剩 7 处小瑕疵,比如 Markdown 切法下,末尾没有正文的标题可能丢失,不影响合并。 Hand-off · 2026-11-25T13:07Z · @os-zhuang — PR #37287 (card #37098, epic #37000) needs your approval. It declares |
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ
Fixes #37098
Clause-②: yes (narrowing) — widens the knowledge contract (the
splitkey,chunks,headingPath, the adapter'scapabilitiesandembedding,IEmbedder.maxInputTokens, the reindexfailed/failures) and narrows two accept sets:KnowledgeChunk.metadatais refused, andknowledge.chunk_overlapis no longer a key of theknowledgesettings namespaceMetadata-protocol: narrowed
Skills-docs: follow-up #37292 —
skills/objectstack-ai/SKILL.mddoes not yet teachsplitor name the two retired keys; that file is governed and outside this claim.content/docs/protocol/knowledge.mdx(new §3.5) andcontent/docs/ai/knowledge-rag.mdxdocument it here.维护者速读
What changes
packages/services/service-knowledge/src/split/):whole,recursive(blank line, line break, sentence end, semicolon, character; Chinese-aware sentence rule; tables and list items kept whole while they fit; short pieces merged up tominChars), andmarkdown(one section per heading, the heading path embedded at each passage's start and carried asheadingPath).KnowledgeDocument.chunks?,KnowledgeChunk.headingPath?, andIKnowledgeAdapter.capabilities?.chunks. An adapter that declares it gets every document with the service's passages; one that does not keeps receiving whole documents.indexDocumentrefuses caller-suppliedchunks, as it refusesdocHash.IKnowledgeAdapter.embedding?.maxInputTokensandIEmbedder.maxInputTokens?, read at use, never cached.embedder-openaireports its limit from the embedder-openai: an over-limit input is refused, not truncated (known-model input limits, one shared token estimate) #37093 table. A passage keepsmaxChars(split.maxChars, elseknowledge.chunk_target, else 800) and, when a limit is known,estimateTokenswithin 80% of it (the shared estimate, not forked).wholeover the budget is removed and reported, never truncated.reindexSourcegainsfailedandfailures(at most 20 named). The event sync logs aterrorwith source, record id, estimate and limit.indexDocumentthrows.splitkey, ADR-0161 K8 item 10:ObjectKnowledgeSource.split?: { strategy, maxChars?, minChars? }, read by the splitter.knowledge-memorydrops its own chunking. It declarescapabilities.chunksand indexes the service's passages as given.knowledge.chunk_targetgains its reader, through thesettingsservice at use, never at boot. It is now shown for the in-memory adapter too.knowledge.chunk_overlapis retired the way the Localization format keys were: removed from the manifest and its 11 translations,version1 to 2, a stored row kept, a write refused400 UNKNOWN_KEY.docHashkeeps its recipe: the passages are derived fromcontentand do not enter it.BREAKING
KnowledgeChunk.metadata: FROM an optional record, accepted and stripped, TO aretiredKey()tombstone (a parse refusal with the prescription;tsctypes itnever). Nothing wrote or read it. Fix: delete the key; filter on the document'smetadata. ADR-0161 K8 item 5, by seat direction 7158283273.knowledge.chunk_overlap: FROM a key of theknowledgesettings namespace TO no key (not shown or resolved; a write is refused400 UNKNOWN_KEY; a stored row is kept). Nothing read it. Fix: stop writing it.Retirement kit, per the
spec-property-retirementskill, under protocol major 18 (seat ruling A):retiredKey()tombstone;RETIRED_KEYS_BY_MAJOR[18]rowai/KnowledgeChunk:metadata;knowledge-chunk-metadata-retiredand itsSTEP18_RATIONALEfragment;[RETIRED]line inauthorable-surface/ai.json;packages/spec/src/ai/knowledge-document.test.ts;adr-0087: registeredmarker.No D2 conversion: a chunk is a runtime contract shape, never stored in stack metadata, so
os migrate metahas no source to rewrite — theActionDescriptor.isAsyncdisposition. The settings key follows the Localization format keys' retirement: specifier and 11 translations removed, manifestversion: 2, stored rows kept.Tests
split.test.ts: six golden files (Chinese regulation with 章/条, a Markdown table, a long unpunctuated run, mixed zh/en with quotes, 「3.2 条」 and 「400.50 元」, a Markdown heading tree), direct assertions of each rule, and a seeded property test. Over 500 random documents with random bounds, no passage's estimate exceeds the budget or the limit, no passage exceedsmaxChars, andrecursiveloses no text. Awholeproperty test runs 200 more.contract-stubs.test.ts: the contract suite against two stubs. One declares no capability and is pinned to receive whole documents, neverchunks. The other declareschunksand stores passages as given.testing.ts: the suite gains the chunk-channel cases. With chunks, the adapter receives exactlysplitDocument's passages and a hit is one of them by id and text;wholeover the budget is removed and reported; caller chunks are refused. Without chunks, whole documents arrive.knowledge-memoryruns it withchunks: true.chunk-channel.test.ts: the event path aterror;indexDocumentover the budget; the boundedfailures; themaxCharsprecedence; the descriptor read at use; and end to end,chunk_targetsaved after boot cuts the next write through the real settings service.openai-embedder.test.ts: the reported limit.knowledge.manifest.test.ts:version2 andchunk_overlapabsent.packages/spec/src/ai/knowledge-document.test.ts: the retiredKnowledgeChunk.metadatais refused at parse with the prescription (also insideKnowledgeDocument.chunks), a chunk without it parses clean, and authoring it is a@ts-expect-error.The local readings sit in the os-dev report comment on this PR.
Acceptance notes
KnowledgeChunk.metadatais retired here (seat direction 7158283273, option B; registered under protocol major 18 by the seat's ruling A). The claim was re-issued asMetadata-protocol: narrowed(7158315677).minChars≤maxChars. The published JSON Schema cannot carry it, and the baseline that declares a dropped refinement is outside this claim. AminCharsabove the effectivemaxCharsreads asmaxChars, documented on the key.docHashdoes not cover passages, so a changedsplit,chunk_targetor limit re-splits a document only when the document itself changes. The index fingerprint (ADR-0161 K7; knowledge-pgvector: an open vector store on PostgreSQL — tables, exact search, listing, chunks #37100) rebuilds a source on a split change. The docs say so.scripts/pm/os-regen-merge.sh, keeping both sides:organizationIdnext tochunks;implements: { listDocuments, chunks, organizationIds };resolveTenancyPosturenext toresolveChunkTarget.settings-visibility-declaration.pin.test.ts(90 to 87 predicates) andknowledge.manifest.test.ts.Verification
Read first:
packages/services/service-knowledge/src/split/splitter.ts(the sentence rule, the block-aware merge, the even character cut);knowledge-service.tsprepareDocuments/writeSyncedand the walk's failure branch;packages/spec/src/contracts/knowledge-adapter.ts.Two-minute check:
pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/split.test.ts. Expect 25 passed, then opensrc/__tests__/fixtures/split/regulation-zh.tight.golden.jsonand see each 章 title leading its own chapter.Generated by Claude Code