Skip to content

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

Merged
os-zhuang merged 18 commits into
mainfrom
claude/issue-37098-knowledge-splitter
Nov 25, 2026
Merged

os-zhuang merged 18 commits into
mainfrom
claude/issue-37098-knowledge-splitter

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ
Fixes #37098

Clause-②: yes (narrowing) — widens the knowledge contract (the split key, chunks, headingPath, the adapter's capabilities and embedding, IEmbedder.maxInputTokens, the reindex failed / failures) and narrows two accept sets: KnowledgeChunk.metadata is refused, and knowledge.chunk_overlap is no longer a key of the knowledge settings namespace
Metadata-protocol: narrowed
Skills-docs: follow-up #37292 — skills/objectstack-ai/SKILL.md does not yet teach split or name the two retired keys; that file is governed and outside this claim. content/docs/protocol/knowledge.mdx (new §3.5) and content/docs/ai/knowledge-rag.mdx document it here.

维护者速读

  • 用户能看到什么变化:知识检索在建索引时由平台统一把文档切成片段,长制度按章、条切开,中文按句号问号断句,不会切在「3.2 条」「400.50 元」中间,也不切开表格。
  • 为什么做:属于「知识检索平台化」专题第二阶段,让每种存储拿到的片段完全一致。
  • 出错会怎样:整篇切法下超过模型上限的文档会从检索中移除并报失败,不会被截断;设置页的「片段重叠」一项被移除(它从未生效),片段上一个从未被使用的字段也被移除,写了它的代码会收到带修复说明的报错。
  • 要你做什么:无。

What changes

  • One splitter in the service (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 to minChars), and markdown (one section per heading, the heading path embedded at each passage's start and carried as headingPath).
  • The chunk channel, as ADR-0161 K8 item 5 settled it. KnowledgeDocument.chunks?, KnowledgeChunk.headingPath?, and IKnowledgeAdapter.capabilities?.chunks. An adapter that declares it gets every document with the service's passages; one that does not keeps receiving whole documents. indexDocument refuses caller-supplied chunks, as it refuses docHash.
  • The limit, per ADR-0161 K8 item 6. IKnowledgeAdapter.embedding?.maxInputTokens and IEmbedder.maxInputTokens?, read at use, never cached. embedder-openai reports 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 keeps maxChars (split.maxChars, else knowledge.chunk_target, else 800) and, when a limit is known, estimateTokens within 80% of it (the shared estimate, not forked).
  • whole over the budget is removed and reported, never truncated. reindexSource gains failed and failures (at most 20 named). The event sync logs at error with source, record id, estimate and limit. indexDocument throws.
  • The split key, ADR-0161 K8 item 10: ObjectKnowledgeSource.split?: { strategy, maxChars?, minChars? }, read by the splitter.
  • knowledge-memory drops its own chunking. It declares capabilities.chunks and indexes the service's passages as given.
  • Settings. knowledge.chunk_target gains its reader, through the settings service at use, never at boot. It is now shown for the in-memory adapter too. knowledge.chunk_overlap is retired the way the Localization format keys were: removed from the manifest and its 11 translations, version 1 to 2, a stored row kept, a write refused 400 UNKNOWN_KEY.
  • docHash keeps its recipe: the passages are derived from content and do not enter it.

BREAKING

  • KnowledgeChunk.metadata: FROM an optional record, accepted and stripped, TO a retiredKey() tombstone (a parse refusal with the prescription; tsc types it never). Nothing wrote or read it. Fix: delete the key; filter on the document's metadata. ADR-0161 K8 item 5, by seat direction 7158283273.
  • knowledge.chunk_overlap: FROM a key of the knowledge settings namespace TO no key (not shown or resolved; a write is refused 400 UNKNOWN_KEY; a stored row is kept). Nothing read it. Fix: stop writing it.

Retirement kit, per the spec-property-retirement skill, under protocol major 18 (seat ruling A):

  • the retiredKey() tombstone;
  • RETIRED_KEYS_BY_MAJOR[18] row ai/KnowledgeChunk:metadata;
  • D3 knowledge-chunk-metadata-retired and its STEP18_RATIONALE fragment;
  • the [RETIRED] line in authorable-surface/ai.json;
  • the regenerated reference;
  • the pin packages/spec/src/ai/knowledge-document.test.ts;
  • the changeset's adr-0087: registered marker.

No D2 conversion: a chunk is a runtime contract shape, never stored in stack metadata, so os migrate meta has no source to rewrite — the ActionDescriptor.isAsync disposition. The settings key follows the Localization format keys' retirement: specifier and 11 translations removed, manifest version: 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 exceeds maxChars, and recursive loses no text. A whole property 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, never chunks. The other declares chunks and stores passages as given.
  • testing.ts: the suite gains the chunk-channel cases. With chunks, the adapter receives exactly splitDocument's passages and a hit is one of them by id and text; whole over the budget is removed and reported; caller chunks are refused. Without chunks, whole documents arrive. knowledge-memory runs it with chunks: true.
  • chunk-channel.test.ts: the event path at error; indexDocument over the budget; the bounded failures; the maxChars precedence; the descriptor read at use; and end to end, chunk_target saved after boot cuts the next write through the real settings service.
  • openai-embedder.test.ts: the reported limit. knowledge.manifest.test.ts: version 2 and chunk_overlap absent.
  • packages/spec/src/ai/knowledge-document.test.ts: the retired KnowledgeChunk.metadata is refused at parse with the prescription (also inside KnowledgeDocument.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.metadata is retired here (seat direction 7158283273, option B; registered under protocol major 18 by the seat's ruling A). The claim was re-issued as Metadata-protocol: narrowed (7158315677).
  • No refinement for minChars ≤ maxChars. The published JSON Schema cannot carry it, and the baseline that declares a dropped refinement is outside this claim. A minChars above the effective maxChars reads as maxChars, documented on the key.
  • A table that does not fit is cut between rows, each piece repeating the header. A list item that does not fit is cut as a paragraph. The budget is the hard bound.
  • Re-splitting. docHash does not cover passages, so a changed split, chunk_target or 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.
  • Merged with feat(service-knowledge): documents carry their organization, and search hands the adapter the caller's organizations #37256 (the organization filter) through scripts/pm/os-regen-merge.sh, keeping both sides:
    • organizationId next to chunks;
    • the organization filter before ranking, over the service's passages;
    • implements: { listDocuments, chunks, organizationIds };
    • resolveTenancyPosture next to resolveChunkTarget.
  • feat(service-knowledge): register EMBEDDER_SERVICE from the ai.embedder_* settings when the knowledge service is mounted #37265 still shares files, a declared serial constraint: whichever lands second merges main.
  • Two test pins outside the claim's literal file list moved with the ordered retirement, both deliberate tripwires on the manifest: settings-visibility-declaration.pin.test.ts (90 to 87 predicates) and knowledge.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.ts prepareDocuments / writeSynced and 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 open src/__tests__/fixtures/split/regulation-zh.tight.golden.json and see each 章 title leading its own chapter.


Generated by Claude Code

… 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>
…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>
…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>
@github-actions github-actions Bot added size/xl 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 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 5 package(s): @objectstack/embedder-openai, @objectstack/knowledge-memory, @objectstack/service-knowledge, @objectstack/service-settings, @objectstack/spec, touching 85 documentable anchor(s). ⚠️ 9 changed file(s) yielded no anchor (packages/spec/api-surface/ai.json, packages/spec/api-surface/contracts.json, packages/spec/authorable-surface/ai.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

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

  • content/docs/ai/agents.mdx (via maxTokens (symbol, a field of interface Bounds; a field of interface ResolvedSplit))
  • content/docs/ai/knowledge-rag.mdx (via IEmbedder (symbol, a top-level interface), KnowledgeService (symbol, a top-level class), KnowledgeServicePlugin (symbol, a top-level class), OpenAIEmbedder (symbol, a top-level class), maxChars (symbol, a field of interface Bounds; a field of interface ResolvedSplit), maxInputTokens (symbol, a field of class OpenAIEmbedder; a field of interface AdapterEmbeddingDescriptor; a field of interface IEmbedder; a field of interface ResolveSplitInput; a field of interface ServiceSetup), sourceId (symbol, a const object of class KnowledgeMemoryAdapter))
  • content/docs/api/data-api.mdx (via sourceId (symbol, a const object of class KnowledgeMemoryAdapter))
  • content/docs/automation/flows.mdx (via sourceId (symbol, a const object of class KnowledgeMemoryAdapter))
  • content/docs/getting-started/common-patterns.mdx (via maxTokens (symbol, a field of interface Bounds; a field of interface ResolvedSplit))
  • content/docs/kernel/runtime-services/sharing-service.mdx (via sourceId (symbol, a const object of class KnowledgeMemoryAdapter))
  • content/docs/protocol/knowledge.mdx (via IEmbedder (symbol, a top-level interface), IKnowledgeAdapter (symbol, a top-level interface), KnowledgeDocumentSchema (symbol, a top-level const), KnowledgeReindexResult (symbol, a top-level interface), KnowledgeService (symbol, a top-level class), KnowledgeServicePlugin (symbol, a top-level class), docHash (symbol, a field of interface ChunkRecord; a field of interface StoredDocument), indexDocument (symbol, a method of class KnowledgeService), listDocuments (symbol, a method of class KnowledgeMemoryAdapter), maxChars (symbol, a field of interface Bounds; a field of interface ResolvedSplit), maxInputTokens (symbol, a field of class OpenAIEmbedder; a field of interface AdapterEmbeddingDescriptor; a field of interface IEmbedder; a field of interface ResolveSplitInput; a field of interface ServiceSetup), minChars (symbol, a field of interface ResolvedSplit), reindexSource (symbol, a method of class KnowledgeService), runKnowledgeAdapterContract (symbol, a top-level function), sourceId (symbol, a const object of class KnowledgeMemoryAdapter), chunk_target (literal, a string literal in KnowledgeServicePlugin))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v18/18-0.mdx (via sourceId (symbol, a const object of class KnowledgeMemoryAdapter))
  • content/docs/releases/v18/18-4.mdx (via sourceId (symbol, a const object of class KnowledgeMemoryAdapter))
  • content/docs/releases/v18/18-6.mdx (via sourceId (symbol, a const object of class KnowledgeMemoryAdapter))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 9 changed file(s) yielded no anchor (packages/spec/api-surface/ai.json, packages/spec/api-surface/contracts.json, packages/spec/authorable-surface/ai.json, …) — pages documenting those are invisible to this run
  • 26 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 124 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 — 178 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 4ed453dc211f24114c36133cb016515f377d2d5c → packageMentionDocs.

Which tree this was computed on

This run read content/docs from a9947ebcda6f1ffccebcf1a22da3cc766dcab6e9 — the merge of head c84c242aa76ac788c77052c6a33335912f58ee17 into base 4ed453dc211f24114c36133cb016515f377d2d5c, 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 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

⚠️ 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 4ed453dc211f24114c36133cb016515f377d2d5c → 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#4 · os-justin · session_01QSeKYoHKp8EUQtketT9S29
os-dev-report

{
  "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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: c84c242aa76ac788c77052c6a33335912f58ee17
Local-runs: probe — three runs in a throwaway worktree at the head, each for a check the brief asked to be reproduced rather than read: (1) build-migration-registry.ts, to read the generated RETIRED_KEYS_BY_MAJOR[18]; (2) the pin's three parse assertions against knowledge-document.zod.ts, at head and with the retiredKey() line deleted; (3) splitter.ts against its six golden files, hand-made edge cases and a 4,000-document property run. No vitest, no build, no dogfood. Worktree removed.
Scope: packages/spec/src/ai/knowledge-document.zod.ts, packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/contracts/embedder.ts, packages/spec/src/contracts/knowledge-adapter.ts, packages/spec/src/contracts/knowledge-service.ts, packages/spec/src/migrations/entries/retired-keys/18.ai__KnowledgeChunk__metadata.ts, packages/spec/src/migrations/entries/semantic/18.knowledge-chunk-metadata-retired.ts, packages/spec/src/migrations/registry.ts.template + packages/spec/src/ai/knowledge-document.test.ts, packages/spec/authorable-surface/ai.json, packages/services/service-knowledge/src/split/splitter.ts, packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-service-plugin.ts, packages/services/service-knowledge/src/testing.ts, packages/plugins/knowledge-memory/src/index.ts, packages/plugins/embedder-openai/src/index.ts, packages/services/service-settings/src/manifests/knowledge.manifest.ts, .changeset/37098-knowledge-splitter.md

Face: schema (record-recognisers --template --paths on the 62 changed paths returns the eight packages/spec/src files above as hits). Read outside the diff, not reviewed: .claude/skills/spec-property-retirement/SKILL.md, the ActionDescriptor.isAsync kit (protocol 17), packages/spec/src/conversions/types.ts, packages/spec/src/shared/token-estimate.ts, ADR-0161 K6 and K8, skills/objectstack-ai/SKILL.md.

① Derived judgments

  • Deviation 1 holds: no D2 conversion and no retiredAfter is owed. A conversion rewrites stored stack metadata, and KnowledgeChunk is in none:
    • stack.zod.ts, packages/spec/src/conversions/** and packages/spec/src/kernel/** name neither KnowledgeDocument nor KnowledgeChunk.
    • At the merge base no file under packages/services, packages/plugins, apps, examples or ui/packages names KnowledgeChunk or reads a document's chunks. The only chunks there is RAGFlow's own API response.
    • No adapter stores a chunk-level metadata: knowledge-memory stores the document's metadata beside each passage, and knowledge-ragflow sends whole documents.
    • ADR-0161 K6 reads the same way for the source: "No stored row carries any of them".
    • retiredAfter is declared only on MetadataConversion (conversions/types.ts), so with no conversion there is nowhere to write it. The seat's later wording ("retiredAfter the latest stable") assumed a conversion; the skill's §3 last item is the governing text: a key with no source to rewrite takes the D3 semantic entry alone.
    • The 17.action-descriptor-is-async-retired kit is the same shape: a tombstone, a retired-key row, one D3 semantic entry, no conversion.
  • Deviation 2 holds: the major-18 registration is complete.
    • Tombstone: metadata: retiredKey(...) on KnowledgeChunkSchema. The message follows the house form (the full key in backticks, "was removed in @objectstack/spec 18", why it was inert, "Delete the key.", the live mechanism). It carries no os migrate meta sentence, which is right with no conversion and matches the isAsync message.
    • Retired-key row: the entry file retired-keys/18.ai__KnowledgeChunk__metadata.ts exports 'ai/KnowledgeChunk:metadata'. registry.ts is git-ignored and generated; run at the head, the generator writes that string inside the 18: [ block of RETIRED_KEYS_BY_MAJOR (311 retired-key entries in all). Nothing is hand-typed.
    • D3: semantic/18.knowledge-chunk-metadata-retired.ts has non-empty reason and acceptanceCriteria, and the generator places it in step18. The STEP18_RATIONALE fragment has the same id, sits in id order before list-view-filterable-fields-retired, and takes order: 125, which no other fragment uses.
    • Authorable surface: "ai/KnowledgeChunk:metadata [RETIRED]" replaces the live line.
    • Pin: with the retiredKey() line deleted, both parse refusals in knowledge-document.test.ts fail ("did not throw") and the clean-parse case still passes; at head all three pass. The file was restored to blob 4fca15827da. The @ts-expect-error case and build gate (b2) go red on the same deletion by reading; neither was run.
  • Additive members. IEmbedder.maxInputTokens?, IKnowledgeAdapter.capabilities? and embedding?, AdapterCapabilities.chunks?, KnowledgeReindexResult.failed? and failures?, KnowledgeDocument.chunks?, KnowledgeChunk.headingPath? and ObjectKnowledgeSource.split? are all optional. An implementation written before this change still type-checks. The generated baselines add names and remove none.
  • knowledge.chunk_overlap has no reader left. A case-insensitive search of the head for chunk_overlap and chunkOverlap finds the changeset, the root CHANGELOG.md, ADR-0161's readings table, and three comments or assertions in service-settings. The specifier is out of the manifest, all 11 translation packs carry zero mentions, and the manifest is at version: 2.
  • The splitter, as run.
    • All six golden files reproduce byte for byte.
    • 4,000 seeded documents with bounds wider than the dev's (limits from 4 tokens, maxChars from 2, CRLF, tabs, emoji, the ideographic space, both strategies): no passage over maxChars or over the token budget, none empty, and recursive loses no text.
    • whole over the budget answers a failure with the estimate and the budget; it returns no passage. whole with no limit known checks nothing.
    • 「依照第3.2 条报销400.50 元。」 at maxChars: 14 cuts into 「依照第3.2 条报销」 and 「400.50 元。」: neither decimal is cut.
  • The service splits once. prepareDocuments is the only place splitDocument is called, and all three adapter.upsert sites (indexDocument, the reindex walk, writeSynced) go through it. An adapter without capabilities.chunks gets the documents untouched. The suite compares what the adapter received with splitDocument's output by toEqual, and a hit with a passage by id and text.
  • knowledge-memory no longer splits. chunkAndEmbed and CHUNK_TARGET are gone; embedPassages maps doc.chunks one to one. The organization filter from feat(service-knowledge): documents carry their organization, and search hands the adapter the caller's organizations #37256 still runs before the metadata filter and the ranking.
  • Check-runs on the head: 60 success, 10 skipped, 0 failed. Check Changeset, Spec property liveness, Type Check · source gates, Type Check · consumer gates, Governed Surface Queue Guard and Test Core 1 to 10 are among the successes. The dogfood shards are among the skipped, as on every PR.
  • K = 8 against main dfdebfadd58, merge base f9fda2a4f84 (the feat(service-knowledge): documents carry their organization, and search hands the adapter the caller's organizations #37256 merge). git merge-tree --write-tree is clean (tree a50f7e33ba1), and none of main's eight commits touches a path of this diff.

② Semver level

  • @objectstack/spec: minor is right for Metadata-protocol: narrowed; the skill forbids major and the BREAKING banner carries the break. Check Changeset passes.
  • patch on the four other packages matches how feat(service-knowledge): documents carry their organization, and search hands the adapter the caller's organizations #37256 shipped the same kind of change.
  • Metadata-protocol: narrowed is right: the diff adds split and narrows KnowledgeChunk.metadata, and narrowed wins.
  • The BREAKING section names both removals, each with FROM, TO and a one-line fix. The adr-0087: registered knowledge-chunk-metadata-retired marker names an entry that exists. knowledge.chunk_overlap is a settings key with no spec registry, so the BREAKING entry is its whole disposition, as the seat ruled.

③ Boundary flags

  • Dev flag, no D2 conversion and no retiredAfter: answered in ①, holds.
  • Dev flag, two test pins outside the claim's file list (settings-visibility-declaration.pin.test.ts 90 to 87, knowledge.manifest.test.ts): both are tripwires on the manifest this card edits, and the new count follows from the diff (one specifier with a predicate removed, two predicates dropped).
  • Dev flag, no minChars ≤ maxChars refinement: resolveSplit clamps minChars to maxChars, a test pins it, and the key's description says it.
  • Dev flag, docHash does not cover the passages: true in the code (chunks is set after computeDocHash), and both doc pages and the changeset say so.
  • Open question "which major": settled as major 18 by the seat; built that way.
  • SQL push-down: no new id materialisation or in-app join. The reindex deletes the failed documents of one page by id through the adapter, which is the adapter contract's own door.
  • S1 (should-fix) — the Skills-docs: line reads none in this change, and its own reason says skills/objectstack-ai/SKILL.md does not yet teach split. By the claim template that is follow-up owed, and the owed card exists: skills/objectstack-ai: teach the knowledge source split key (strategy, maxChars, minChars) that #37098 adds #37292. The line should read Skills-docs: follow-up #37292. This is the seat's rewrite of the PR body, not a dev fix, and it moves no head. skills/objectstack-ai: teach the knowledge source split key (strategy, maxChars, minChars) that #37098 adds #37292 should also cover SKILL.md lines 281 to 284, which say chunking is "NOT platform metadata": that sentence becomes false when this lands.

④ Design judgment

  • The narrowing takes away nothing an author had. KnowledgeChunk.metadata had no producer and no reader on main, so a value written there was dropped. ADR-0161 K8 item 5 says service-knowledge: one service-layer splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key #37098 "gives it one or removes it", and the seat chose removal. The schema now refuses what it used to drop in silence.
  • K8 item 5 is built as written: chunks? on the document, the reshaped KnowledgeChunk with headingPath?, capabilities?: { chunks?: boolean }, and whole documents for an adapter that declares nothing.
  • K8 item 6 is built in part, as the ADR assigns it: embedding?: { maxInputTokens? } only. model, dimensions and variant wait for item 8's PR. The service reads the descriptor in prepareDocuments on every batch and keeps no copy.
  • K8 item 10: split sits on the object arm with strategy, maxChars? and minChars?, and the splitter reads all three.
  • Changeset and 维护者速读: each sentence checked against the code is true, apart from N6.
  • N1 — markdown can drop a heading that has no text under it. # A then # B with nothing else gives one passage, B. ## B then ## C at the end of a document gives A > C and loses B. A bodiless heading longer than half the bound is dropped whole. The no-loss property covers recursive only.
  • N2 — The character-level cut does not look at punctuation: 「他说:“不行。”然后走了。」 at maxChars: 12 is cut between 。 and ”. The sentence rule itself holds, and this is the last level the card allows.
  • N3 — KnowledgeChunkSchema.parse has no caller in the platform outside its test. The service builds chunks as typed objects, and indexDocument refuses any chunks before a parse could run. tsc is the channel that reaches an author; the parse refusal reaches only a consumer who parses.
  • N4 — KnowledgeSplitSchema is a plain z.object (the strictness ledger's ai/ count goes 112 to 113), and registerSource parses nothing. From untyped code a misspelt key is ignored and an unknown strategy string cuts as recursive, in silence. The source loader of ADR-0161 row 3 is where that closes.
  • N5 — runKnowledgeAdapterContract's implements.chunks is a new required option on a published subpath (@objectstack/service-knowledge/testing). The changeset gives the fix under "What to do" and not under BREAKING, as feat(service-knowledge): documents carry their organization, and search hands the adapter the caller's organizations #37256 did for organizationIds.
  • N6 — 速读 line 1 says tables are not cut; a table over the bound is cut between rows with the header repeated. Line 4 says nothing is asked of the maintainer, while a declared narrowing needs the maintainer's approval; the seat's hand-off carries that ask.
  • N7 — The Localization precedent pinned the REST behaviour of its retired keys (RETIRED_FORMAT_ROWS in settings-routes.test.ts). This PR adds no such pin for knowledge.chunk_overlap; the behaviour claimed is the generic undeclared-key path those pins already cover.

Implemented-by: claude/issue-37098-knowledge-splitter
Reviewed-by: session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — REWORK · L1 · head c84c242aa76ac788c77052c6a33335912f58ee17 · 2026-11-25T13:00Z

  • M1 (must-fix) — the full dogfood battery reading is missing. The PR declares a (narrowing) arm, so one full run of pnpm --filter @objectstack/dogfood test pinned to this head is owed before queueing.
    • The PR body says "the local readings sit in the os-dev report comment on this PR". The PR has one comment, the docs-drift bot's.
    • The last dev report on the card (7160082130) says the battery "will be owed on the final head". No later report is on the card or the PR.
    • CI does not cover it: the dogfood shards are skipped on a PR and run only in the merge queue.
    • Fix: the dev posts the os-dev report with dogfood_battery for head c84c242aa76: the lock's VERDICT line, Test Files N/N, Tests M/M, every failure named. No code change is asked. A head that moves only by a merge of main keeps the rest of this review.
  • S1 (should-fix) — the Skills-docs: line reads none in this change, while its own reason says skills/objectstack-ai/SKILL.md does not teach split. The template's value is follow-up owed, and the card is filed: skills/objectstack-ai: teach the knowledge source split key (strategy, maxChars, minChars) that #37098 adds #37292. I rewrite the PR-body line to Skills-docs: follow-up #37292; this is not a dev fix. skills/objectstack-ai: teach the knowledge source split key (strategy, maxChars, minChars) that #37098 adds #37292 should also cover SKILL.md lines 281 to 284 ("chunking … NOT platform metadata"), which this PR makes false.
  • Card service-knowledge: one service-layer splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key #37098 (ADR-0161 K8 items 5, 6 and 10): one splitter in service-knowledge (whole, recursive, markdown), the chunk channel, the split key, and two retirements. 62 files, +2553/−233 (2,786 lines, under 3,000).
  • Declarations read true: Clause-②: yes (narrowing), Metadata-protocol: narrowed, @objectstack/spec: minor. The changeset's BREAKING section names both removals with FROM, TO and a one-line fix, and carries adr-0087: registered knowledge-chunk-metadata-retired.
  • Deviation 1, no D2 conversion and no retiredAfter: holds. KnowledgeChunk is in no stored artifact: the stack schema and the conversion walkers do not name it, no code outside packages/spec named it at the merge base, and no adapter stores a chunk-level metadata. retiredAfter exists only on a conversion. The skill's §3 gives a key with no source to rewrite the D3 semantic entry alone, and the ActionDescriptor.isAsync kit (protocol 17) is the same shape. My earlier wording about retiredAfter assumed a conversion; it does not apply.
  • Deviation 2, the major-18 registration: complete.
    • The retiredKey() tombstone is on KnowledgeChunkSchema.metadata, with the house-form message.
    • RETIRED_KEYS_BY_MAJOR[18] holds 'ai/KnowledgeChunk:metadata'. It comes from the entry file; I ran the generator at the head and read the row in the 18: block.
    • The D3 entry knowledge-chunk-metadata-retired is in step18, and its STEP18_RATIONALE fragment sits in id order with a free order: 125.
    • authorable-surface/ai.json has the [RETIRED] row.
    • The pin goes red without the tombstone: with the retiredKey() line deleted, both parse refusals in knowledge-document.test.ts fail; at head they pass.
  • knowledge.chunk_overlap: no reader remains anywhere in the tree. The specifier and all 11 translations are gone, the manifest is version: 2, and the steps match the Localization format keys' retirement.
  • Splitter, re-run outside vitest: the six golden files reproduce byte for byte. Over 4,000 seeded documents with wider bounds than the dev's, no passage exceeds maxChars or the token budget and recursive loses no text. 「3.2 条」 and 「400.50 元」 stay whole. whole over the budget answers a failure and no passage.
  • Service: prepareDocuments is the one place that splits, and all three upsert paths use it. An adapter with capabilities.chunks receives exactly splitDocument's passages (the suite compares by toEqual); one without receives whole documents. A whole document over the budget is deleted and reported on all three paths: failed and failures on a reindex, an error log on the event sync, a throw from indexDocument.
  • knowledge-memory drops chunkAndEmbed and indexes doc.chunks one to one.
  • Contract: IEmbedder.maxInputTokens?, capabilities?, embedding?, chunks?, headingPath?, split?, failed? and failures? are all optional. The baselines only add names.
  • Overlap with feat(service-knowledge): documents carry their organization, and search hands the adapter the caller's organizations #37256 (merged, and the merge base of this head): the organization filter still runs before the metadata filter and the ranking in knowledge-memory, and organizationId sits beside chunks.
  • Overlap with feat(service-knowledge): register EMBEDDER_SERVICE from the ai.embedder_* settings when the knowledge service is mounted #37265 (open, draft, head fa818f4d407): 15 shared files. A trial merge conflicts in content/docs/ai/knowledge-rag.mdx only; the rest merge by themselves. Whichever lands second merges main and keeps:
  • Check-runs on the head: 60 success, 10 skipped, 0 failed. K = 8 against main dfdebfadd58; git merge-tree is clean and main's eight commits touch none of the 62 paths.
  • N1 — markdown can drop a heading with no text under it: # A then # B alone gives only B, and a bodiless heading at the end of a document can be lost. The no-loss property covers recursive only.
  • N2 — The character-level cut ignores punctuation: 「他说:“不行。”然后走了。」 at maxChars: 12 is cut between 。 and ”. The sentence rule itself holds.
  • N3 — KnowledgeChunkSchema.parse has no caller in the platform outside its test, so tsc is the channel that reaches an author.
  • N4 — KnowledgeSplitSchema is not strict and registerSource parses nothing: from untyped code a misspelt key or an unknown strategy reads as recursive in silence, until the row-3 loader.
  • N5 — implements.chunks is a new required option of @objectstack/service-knowledge/testing; the changeset gives its fix under "What to do", not under BREAKING (as feat(service-knowledge): documents carry their organization, and search hands the adapter the caller's organizations #37256 did for organizationIds).
  • N6 — 速读 line 1 says tables are not cut, but a table over the bound is cut between rows. Line 4 says nothing is asked of the maintainer, while the narrowing needs approval; the hand-off carries the ask.
  • N7 — No REST pin for the retired knowledge.chunk_overlap like the Localization keys' RETIRED_FORMAT_ROWS; the generic undeclared-key path those pins cover is what answers.
  • The PR is still a draft; the zone marks it ready before landing.
  • Contract review at the same head is in the ## Contract review record: PASS. Nothing in the contract is sent back; M1 is the only item between this PR and the maintainer's narrowing gate.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — ACCEPT · L1 · head c84c242aa76ac788c77052c6a33335912f58ee17 · 2026-11-25T13:04Z

  • Same-head delta over the L1 REWORK 7163174425. The head is unchanged.
  • M1, closed. The dogfood battery reading for this head is on the PR in the dev's os-dev report 7163120953, posted 2026-11-25T12:58:49Z. That is before the L1 was posted, but the L1's read had missed it. The reading: c84c242aa · os-verify-lock VERDICT command-exit 0 (48m43s) · Test Files 487 passed | 3 skipped (490) · Tests 4128 passed | 68 skipped (4196) · no failures.
  • S1, closed. The PR body's Skills-docs line now reads follow-up #37292. skills/objectstack-ai: teach the knowledge source split key (strategy, maxChars, minChars) that #37098 adds #37292 also carries skills/objectstack-ai/SKILL.md lines 281–284 (comment 7163188624).
  • Carried, still holding: contract review PASS 7163151592 at CONTRACT_REVIEW_TIER. Both deviations hold: D3-only for the runtime-only KnowledgeChunk, and the major-18 kit is complete. Check-runs are 60 success, 10 skipped, 0 failed. Merge-tree is clean. Nits as listed in 7163174425.
  • Against feat(service-knowledge): register EMBEDDER_SERVICE from the ai.embedder_* settings when the knowledge service is mounted #37265: only content/docs/ai/knowledge-rag.mdx conflicts. The second lander keeps both sections.
  • Landing. Clause-②: yes (narrowing) puts this through the maintainer gate: hand-off first. After approval the seat re-queues it. If K ≥ 15 at that point, it merges main first, and a merge-only head move keeps this ACCEPT.

No must-fix, no should-fix.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: c84c242aa76ac788c77052c6a33335912f58ee17
Local-runs: none
Scope: delta — the PR body's Skills-docs: line only. No file of the diff was re-read.

Same-head delta over the contract review 7163151592. The head is unchanged: the live PR reads c84c242aa76ac788c77052c6a33335912f58ee17, 18 commits, the same as that record. Three reads, all through the API: the PR body (last updated 2026-11-25T13:05:12Z), issue #37292, and its comment 7163188624.

S1, closed

Carried, by reference

Everything else in 7163151592 stands as written and was not re-read: ① both deviations hold (D3 only for the runtime-only KnowledgeChunk; the major-18 kit is complete), ② the semver level, ③ the other boundary flags, ④ the design judgment, and the nits N1 to N7. Nothing else is reopened.

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: claude/issue-37098-knowledge-splitter
Reviewed-by: session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: PASS

No must-fix, no should-fix.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

维护者速读

  • 用户能看到什么变化:建知识索引时,平台统一把文档切成片段。长制度按章、条切开,中文按句号、问号断句,不会切在「3.2 条」「400.50 元」中间;放得下的表格保持完整。设置页的「片段重叠」一项被移除,它从未生效。
  • 为什么做:「知识检索平台化」(专题:知识检索平台化(应用写一份知识源配置就有可用的检索:开源、托管、企业版都能用) #37000)第二阶段的一项(service-knowledge: one service-layer splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key #37098),让每种存储拿到的片段完全一致。
  • 出错会怎样:选了「整篇」切法且超过模型上限的文档,会从检索中移除并报失败,不会被截断。片段上一个从没人用过的字段 metadata 被移除,写了它的代码会收到带修复说明的报错。脚本若还在写「片段重叠」,会被拒绝(400);已存的值保留。发布说明里两处都写了破坏性改动说明和改法。
  • 要你做什么:审核并合并。它移除了一个已发布的字段和一个设置项,属于声明了收窄的改动,按 2026-11-19 的裁定要你批准。契约审核 PASS:7163320948,Head-sha c84c242aa76ac788c77052c6a33335912f58ee17。席位核对 ACCEPT:7163270475。0 个失败检查。

席位意见:通过。两处移除都没有读者,移除按 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 Clause-②: yes (narrowing) and Metadata-protocol: narrowed: KnowledgeChunk.metadata becomes a retiredKey() tombstone and knowledge.chunk_overlap leaves the knowledge settings namespace; neither had a reader. The 2026-11-19 narrowing ruling requires your approval before it enters the merge queue; it has not been queued. Seat ACCEPT 7163270475 and contract review PASS 7163320948 (CONTRACT_REVIEW_TIER, schema face), Head-sha c84c242aa76ac788c77052c6a33335912f58ee17; 0 failed check-runs. After your approval the seat queues it.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 25, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 25, 2026 13:43
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 25, 2026
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 91138ec Nov 25, 2026
80 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-37098-knowledge-splitter branch November 25, 2026 17:07
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
… hit's title is the object's display field (objectstack-ai#37301)

<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8HtXJcvyDnGVcP1BL7DwnBY)_

Fixes objectstack-ai#36993
Fixes objectstack-ai#36994

Clause-②: no
Metadata-protocol: none

## 维护者速读
- 用户能看到什么变化:在挂了知识库的应用里,一个人能看的记录很少时,AI
检索不再返回空或只剩一两条,而是继续往后找,补满到要的条数;命中结果的标题改为取对象的名称字段(比如客户的「名称」、发票的编号),不再只认名为
title 的字段。
- 为什么做:知识检索平台化专题的第一、四阶段两张卡,同一个文件一起修;「按记录返回」那张卡要在这次的补齐逻辑上继续做。
-
出错会怎样:最坏是检索多读一轮、稍慢,或某条命中没有标题。权限检查只多不少:名称字段对某人不可查时,这个知识源对他不检索;旧索引里的标题还取自名为
title 的字段,所以在索引重建之前,title 字段对某人不可查时同样不检索。可以直接撤回。
- 要你做的:无。

## What changes

**Search refills after the permission filter (objectstack-ai#36993).**
`KnowledgeService.search` re-checks every object-source hit as the
caller *after* ranking, so a caller who may read few of the matching
rows was answered from what was left of `topK` ranked hits. Now:

- When the re-check can remove hits (a caller who is not the system
identity, with a data engine bound), each `object` source is asked for
`topK × SEARCH_FIRST_ROUND_FACTOR` (5).
- When the survivors name fewer than `topK` records (several passages of
one record count once: an object hit is its source and record id, any
other hit its document), every `object` source that answered as many
hits as it was asked (the only ones that may hold more) is asked once
more, for `topK × SEARCH_REFILL_FACTOR` (20, the cap). That round's
answer replaces the source's first-round hits; a source whose refill
throws keeps its first-round survivors. At most two rounds; an adapter
that caps `topK` answers fewer than asked and is never asked again.
- A `file` / `http` source is asked for `topK` once (the re-check never
removes its hits). The system identity gets one round of `topK`, no
refill. No context: object sources stay unsearched, as before (fail
closed).
- The answer is still at most `topK` chunk-level hits, sorted by score;
`search`'s return type is unchanged (`expectTypeOf` pin). The count the
re-check removed is logged at `debug` only, never returned.
- The adapter loop moved into a private `searchRound`, unchanged in
behaviour (foreign-source hits dropped and warned, a throwing adapter
logged and skipped).

**A hit's title is the object's display field (objectstack-ai#36994).**
`recordToDocument` read `record.title`. Per ADR-0161 K5 ("the title is
the object's display field"), it now reads the field
`documentTitleField(schema)` names: `resolveDisplayField` (ADR-0079:
`nameField`, its deprecated alias, else the derivation), and with no
object definition a field named `title`, as before. A withheld field
(credential-class or `internal`), an empty value, a value that is not
text or a finite number, a definition that resolves no display field, or
a `nameField` the definition does not declare gives no title.
`resolveRecordDisplayName` is not used: its `Record #id` floor is a UI
label.

The source admission's field gate (`servedFieldsOf`) asks about the same
field through the same `documentTitleField`. So a source whose object's
display field the caller may not query is not searched for that caller
at all. It also keeps asking about a declared field named `title`, as
before: documents indexed under the earlier rule carry that field's
value as their title and stay in the index until a complete reindex
writes them again, and nothing reindexes at boot. That arm is retired
once the index is proven rebuilt under the display-field rule (the
recipe hash that names the title rule, ADR-0161 K7, and the rebuild of a
stale source, objectstack-ai#37099); the code comment says so.

Docs: `content/docs/protocol/knowledge.mdx` states the refill and its
cap, and the display-field title (three places that said "the record
`title`"); `content/docs/ai/knowledge-rag.mdx` says the same in two
sentences. `content/docs/permissions/system-context.mdx` row 46 keys
`search` too (it now reads `isSystem`: the system identity skips the
over-fetch and the refill), and its generated register is regenerated
(`check:system-context-census --write`).

## Tests

`packages/services/service-knowledge`: `pnpm test` 8 files / 219 tests
passed at 4621738; `pnpm typecheck` exit 0 (incl.
`check:test-typecheck`). New pins in `knowledge-service.test.ts` (two
top-level describes) and `knowledge-source-admission.test.ts` (one):

- 100 hits, the caller may read 5 spread across them → those 5, best
first; asked `[s1, 25]` then `[s1, 100]`.
- A readable row beyond the cap → fewer than `topK`, never a third
round. Enough survivors → no refill. An adapter capping at 10 → asked
once. Several sources → only the saturated one refilled. The refill
decision counts records: topK 3, one source answers two passages of one
readable record, another holds a readable record past its first round
that outranks both → it is refilled and answers `[s1-c0, s1-c15, s2-a]`.
A failed refill keeps round one. System identity → one round of `topK`,
no re-check. No context → only the file source, asked `topK`. A file
source beside an object source → asked `topK` once.
- Removed count only in the `debug` log; answer and return type
unchanged.
- Title: explicit `nameField`; derived `name` over `title`; formula
(text) and autonumber name fields (a number value → its text); withheld
internal / secret name fields; empty, non-text, unresolvable and
undeclared-`nameField` cases; no definition → `title`; the event sync
and the reindex walk read the definition off the engine.
- Field gate: hiding the display field refuses the source even with
`title` visible; hiding a declared `title` that is not the display field
refuses it too (the adapter returns a stored hit carrying an old-rule
title, and the answer is empty); a caller who may query both gets the
hit.

<details><summary>Ablations: each committed first, mutated through
scripts/ablation-replace.mjs, restored to HEAD with git diff HEAD
empty</summary>

- Refill disabled (`if (false && filtered && kept.length < topK)`): 6
refill tests red, 5 green (the ones that pin "no refill").
- Title back to `record.title`: 5 title tests red.
- Field gate back to `title` only: both display-field gate tests red.
- Refill decision back to counting hits (`kept.length`): the
record-counting test red, 150 green.
- The declared-`title` arm deleted from the gate: its refusal pin red,
24 green.

</details>

## Acceptance notes

- **objectstack-ai#36993 point 2 is applied to the refill decision only.** The answer
stays at most `topK` chunk-level hits (`KnowledgeSearchOptions.topK` is
"Max number of hits to return"; `search_knowledge` returns "at most
`topK`" passages; the card: "what is returned stays chunk-level hits").
Counting records decides whether to refill, and with several sources
that changes the answer: another source's refill can outrank a second
passage of a record already counted (pinned above).
- **The declared `title` arm of the field gate is temporary.** Retire it
when the index is proven rebuilt under the display-field rule (ADR-0161
K7 recipe hash, objectstack-ai#37099).
- **Title egress** (the question raised on objectstack-ai#36994): ADR-0161 K5 declares
the title as the object's display field, so it is sent whether or not
the source lists that field among its content fields. It is withheld
when the field is credential-class or `internal`. The field-egress
declaration of cloud ADR-0119 does not exist yet; when it does,
`documentTitleField` is the one place assembly and the gate both read.
- The title enters `docHash`, so the first complete reindex after this
lands rewrites the documents whose title changed.
- Seat 4's objectstack-ai#37287 edits the same file; `scripts/pm/overlap-check.mjs`
merges this branch with its head cleanly (the search factors sit beside
`LIST_DOCUMENTS_PAGE_SIZE` to stay clear of its new constant).

## Verification

Files to read first:
`packages/services/service-knowledge/src/knowledge-service.ts`
(`search`, `searchRound`, `documentTitle`),
`knowledge-source-admission.ts` (`documentTitleField`,
`servedFieldsOf`).

Two-minute check: `pnpm --filter @objectstack/service-knowledge exec
vitest run src/__tests__/knowledge-service.test.ts -t refills` — 11
tests pass; the first shows a caller reading 5 of 100 hits getting all
5.

<details><summary>Local gate families: the derived list
(scripts/pm/dispatch-gates.mjs --commands, 98 commands, derived at
ecb0842), run in order; CI runs the full farm</summary>

- Rework round (4621738): package test 8 files / 219, typecheck 0,
eslint on the four changed source and test files 0, check:doc-anchors 0,
check:system-context-census 0, overlap-check clean against origin/main,
objectstack-ai#37287 and objectstack-ai#37265.


- 79 of 98 run: 76 exit 0; 3 PREREQUISITE NOT MET (not verdicts, NOT
MEASURED locally, CI builds them): check-plugin-teardown-shape
--self-test (shallow clone cannot reach its pinned fixture commit), spec
check:skill-examples (client-react dist not built),
check:dual-build-cjs-loads (hono / account dist not built).
- The remaining 19 (the repo-wide eslint-backed ratchets onward) were
still running when this was written: NOT MEASURED locally; their CI
check-runs are the reading.
- Also run: package typecheck (exit 0, incl. check:test-typecheck),
eslint on the four changed source and test files (exit 0),
check:doc-anchors (exit 0), check:system-context-census (exit 0 after
row 46 below), scripts/pm/overlap-check.mjs (clean against origin/main,
objectstack-ai#37287 and objectstack-ai#37265).

</details>

## Human Minimum

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1

---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1)_

<!-- signed: repo:cloud#1 · os-warren · session_01JQwxbWqwmAwx7eD4Xf3dv1
-->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ped bucket beside skill and ai_context (objectstack-ai#37330)

<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8ThLXnc2MYoAdJHGZxSsdaA)_

repo:cloud#1 · os-warren · session_01JQwxbZjKjZ947xtTvgJuHX

Fixes objectstack-ai#37325

Clause-②: no
Metadata-protocol: none

## 维护者速读

-
用户能看到什么变化:用户无感(只改决定记录,不改代码);把你今天定的「按应用+名字区分,都保留」写进记录:两个应用各带的同名知识源都保留、各建各的索引,AI
用「应用前缀-名字」指明是哪一个。
- 为什么做:属于「知识检索平台化」专题;哪些类型按应用区分要先写进记录,后面的实现卡
objectstack-ai#37304(让知识源成为应用包里的一份配置)才能照着做。
- 出错会怎样:记录写偏的话,后面的实现会照着偏的做;这次只有文档,撤回这次合并即可。
- 要你做什么:合并这个
PR,合并就是这条裁定的记录;其中一处超出你的原话、只能由你定:同一个应用前缀下不允许两个应用包带同名知识源(前缀不同的同名知识源照样都保留),不同意就先划掉这一条再合并。

## What changes

Two files under `docs/adr/`: 58 lines added, 1 line changed. No schema,
no code, no changeset.

**ADR-0150** (Accepted) gains a dated addendum. No ruled sentence is
rewritten.

- The status line gains one **Amended** clause, dated 2026-11-25, after
the `ai_context` one. This is the one changed line: the clause is
appended, and nothing before it is edited.
- The D1 table gains one row, marked with the date, after the
`ai_context` row and before bucket 4.
- A new section after the `ai_context` addendum and before D2, "Addendum
(2026-11-25): `knowledge_source` joins bucket 3". It writes the
maintainer's ruling of that day into the record: the knowledge source
type of ADR-0161 K4 is identified by `(package, name)`, in bucket 3
beside `skill` and `ai_context`.

The ruling is quoted with its record id in the status clause, at the
head of the addendum and in the ADR-0161 note: seat record `7168239918`
on the code card, decision card tapped **B 「按应用+名字区分,都保留」** at
2026-11-25T16:34:09Z, against the card's recommendation.

The addendum says, in this order:

1. **The type**, and what D2, D3, D4, D5, D6 and D8 mean for it. A
package's source is spelled `NS-NAME` where its name crosses the AI
face, which is inside `search_knowledge`: the `sources` list of an
answer and the `sourceIds` argument.
2. **The principle, read for this type.** The recommendation read a
source's name under D1's storage half. The ruling did not, so the keys
of a source's index are derived from its identity, as its face is. Three
things that reading does not hide are listed.
3. **The tree today**, measured on `main` at `fbb62e1c`. The type is not
registered and is in none of the four lists. A source reaches the
service through code only. The keys of an index are the bare `id`.
4. **What changes with the bucket**: the service's copy, overlays, owner
stamps, uninstall and the keys of an index.
5. **The readers that move.** It names five and moves none.
6. **The follow-up**, the code card objectstack-ai#37304, after this merge.
7. **Past the ruling's words**: seven points, none decided here. One is
the maintainer's, two follow from text already ruled, and four are left
open for the code card.

**ADR-0161** gains one cross-reference note after point 3 of K4 and
before K5. No sentence of it is changed.

**Not in this PR**, by the card's contract: none of the four lists is
edited, no reader is moved and no store is re-keyed. That is the code
card's work, after this merge.

## Tests

No package is touched, so no package build or test is owed. The checks
that read these two files are the docs gates under Verification.

## Acceptance notes

- **The chain.** This PR is the ruling's record and step 1 of its
execution. The code card objectstack-ai#37304 comes after it and stays open: it takes
the four lists, the readers and the store keying in memory, pgvector and
turso.
- **One decision is the maintainer's alone** (point 1 of "Past the
ruling's words"). The ruling record counts "the `domain:server` four
lists and readers (precedent PR objectstack-ai#37291)" and names none of them. In that
PR the fourth list is `NAMESPACE_UNIQUE_TYPES`: one package holder of a
name inside one namespace, refused at install and in `os validate`. So
"Two packages shipping one source name both work" holds for two
namespaces, and inside one namespace the second is refused. The list's
header reserves a further type to the maintainer. The merge accepts this
point. Struck, two co-owners of a namespace may ship one name, and the
one face they derive is refused at the call.
- **Two points follow from text already ruled** and are no new decision.
A source name takes the name grammar of buckets 2 and 3, which refuses a
`_`-led name that today's `id` pattern admits. And a `409` names only
the sources the tool may search (ADR-0161 K9).
- **Four points are left open for the code card.** Each is stated in the
addendum and decided nowhere in it: what each shape carries (a hit's
`sourceId` and `documentId`, a stored document's `sourceId`, the by-name
members of the service contract); which coordinate a key carries, the
package id or the namespace, and what removes an index left under the
old key; which holder a source registered in code is; and an environment
source under a name a package later ships.
- **The acceptance line of the card**, "The addendum quotes the ruling
comment id and the maintainer's words; earlier text of the record
unchanged". The id and the words are in all three places named above.
ADR-0150's diff has one changed line, the status line, and its old text
is a strict prefix of the new text. Every other old line of both files
survives, in order.
- **The tree moved once during the work.** `main` gained the knowledge
splitter (PR objectstack-ai#37287) under six of the files the addendum anchors. `main`
is merged into the branch (a merge commit, no rebase and no force-push).
Every "today" sentence and every anchor was read again at `fbb62e1c`,
and all hold. The two dated readings name that commit.
- **Overlap.** PR objectstack-ai#37329 adds a dated note under K8 of the same ADR-0161
file. `node scripts/pm/overlap-check.mjs
--branch=claude/project-thread-4uapwf` answered `VERDICT clean exit 0`
at this head, against `origin/main` and that PR's head. Whichever of the
two lands second merges `main`.
- **Line budget.** 58 added and 1 changed; the precedent PR objectstack-ai#37209 was
44 and 1. The difference is the "principle" paragraph, which the
precedent did not need because its ruling followed the recommendation,
and the seven-point list.
- **Citation form.** `check:adr-symbol-anchors` refuses a line anchor
under `docs/adr/`, so the record cites `path#Symbol`, and the line
numbers are in the table under Verification.
- **No changeset.** `docs/adr/` ships in no package, so this PR carries
`skip-changeset`.
- **Tier H.** This PR stays draft. The merge is the maintainer's, and it
is the ruling's record.
- **Shallow checkout.** No claim here is read from history dates.
- **Attribution lines.** The dispatch asked for a commit trailer that
names a model and for the harness's two-line block at the end of this
body. The repository's rules ask for the model-free trailer pair and for
one footer line under a rule, and those are what the commits and this
body carry.
- **Noted, not filed.** ADR-0161's status keyword still reads Proposed
on `main`, and its own status line says the record is in force from the
merge of the PR that carried it. This PR adds one note to that record
and does not touch its status line.

## Verification

**Read first**, by risk:

1. `docs/adr/0150-…-literal-prefix.md`, "Past the ruling's words" at the
end of the addendum (lines 191 to 199). Point 1 is the one decision that
is the maintainer's.
2. The same file, "The principle, read for this type" (line 160): how
D1's storage half reads for a type the ruling placed against the
recommendation.
3. The same file, the D1 table hunk (line 95) and the status line (line
3): one row inserted into a ruled table and one appended clause. Check
that both read as additions and change no ruled text.

**Two-minute check**: run `node scripts/check-adr-symbol-anchors.mjs`.
Expect `4220 anchors across 163 records resolve` and exit 0. Twenty-one
of them are this diff's `path#Symbol` anchors.

<details>
<summary>Measured anchors on main at fbb62e1 (file:line)</summary>

| What the addendum says | Where it is read |
|---|---|
| The type is in no row of the registry; `skill` and `ai_context` open
no environment overlay |
`packages/spec/src/kernel/metadata-plugin.zod.ts:798`
(`DEFAULT_METADATA_TYPE_REGISTRY`), `:1384`, `:1388` |
| The service keeps one slot per (package, name) for listed types |
`packages/spec/src/api/protocol.zod.ts:2753`
(`PACKAGE_SLOTTED_METADATA_TYPES`; `skill` at `:2754`) |
| Any other type is keyed by name alone |
`packages/metadata/src/package-slotted-store.ts:797` (`storeWriteKey`),
`:820` |
| The one rule resolves only its listed types, and throws for a type
outside the list | `packages/core/src/package-scoped-resolution.ts:245`
(`PACKAGE_SCOPED_TYPES`; `skill` at `:270`), `:740`;
`packages/objectql/src/package-scoped-resolver.ts:149` |
| A by-name read consults (package, name) for listed types |
`packages/objectql/src/package-scoped-read.ts:88`
(`PACKAGE_SCOPED_READ_TYPES`; `skill` at `:96`) |
| One package holder of a name inside a namespace; the list is reserved
to the maintainer |
`packages/objectql/src/namespace-co-owner-names.ts:96`
(`NAMESPACE_UNIQUE_TYPES`), `:27` |
| A source reaches the service through code only |
`packages/services/service-knowledge/src/knowledge-service-plugin.ts:91`
(`KnowledgeServicePlugin`), `:44`, `:220` |
| One map by `id`; a second registration replaces the first with a
warning |
`packages/services/service-knowledge/src/knowledge-service.ts:121`
(`KnowledgeService`), `:123`, `:166`, `:168` |
| A document id is the source's `id`, a `:` and the record id |
`packages/services/service-knowledge/src/knowledge-service.ts:1570`
(`documentIdFor`), `:1571` |
| An adapter is handed the whole source |
`packages/spec/src/contracts/knowledge-adapter.ts:33`
(`AdapterContext`), `:35` |
| The one in-tree store keyed by the bare `id` |
`packages/plugins/knowledge-memory/src/index.ts:44`
(`KnowledgeMemoryAdapter`), `:48`, `:55` |
| The push door that takes a document id from a caller |
`packages/spec/src/contracts/knowledge-service.ts:107`
(`IKnowledgeService`), `:127` |
| The tool lists each source by its `id`; a hit shows `sourceId` and
`documentId` |
`packages/services/service-knowledge/src/knowledge-tools.ts:61`
(`SearchKnowledgeSourceSummary`), `:70`, `:72`, `:222` |
| An unknown `sourceIds` entry is refused `NOT_FOUND` |
`packages/services/service-knowledge/src/knowledge-tools.ts:246`
(`createKnowledgeTools`), `:257`, `:260` |
| Today's `id` pattern admits a `_`-led name; the bucket's pattern does
not | `packages/spec/src/ai/knowledge-source.zod.ts:174`
(`KnowledgeSourceSchema`), `:176`;
`packages/spec/src/kernel/address-grammar.ts:68`
(`ROUTER_ADDRESSABLE_NAME_PATTERN`) |
| The one face derivation | `packages/spec/src/ai/face-name.ts:86`
(`deriveAiFaceName`) |
| A skill prompt's name: a face, else a bare name by the one rule |
`packages/mcp/src/skill-prompts.ts:373` (`lookupSkillPrompt`) |
| The owner stamp's judge, and the collections it judges |
`packages/spec/src/kernel/collection-item-owner-stamp.ts:129`
(`judgeCollectionItemOwnerStamp`), `:100` |
| The type's row is not among the served overrides |
`packages/metadata-protocol/src/protocol-package-bindings.ts:388`
(`SEALED_ROW_SERVED_OVERRIDE_TYPES`) |
| Uninstall, the registry's half |
`packages/objectql/src/registry.ts:5328` (`uninstallPackage`) |
| Uninstall, the service's half |
`packages/metadata/src/metadata-manager.ts:2880` (`unregisterPackage`) |

Absence readings at the same commit, each with a positive control:

- `knowledge_source` in the four list files, in
`packages/metadata/src/package-slotted-store.ts` and in the registry's
rows: 0 lines each. Control: `skill` is in the first three lists and in
the registry, at the lines the table gives.
- A stack collection: `knowledgeSources` in
`packages/spec/src/stack.zod.ts`, 0 lines. Control: `aiContexts`, 3
lines.
- `knowledge_source` under `packages/`, `examples/`, `ui/`, `skills/`
and `content/`: 0 files. Control: `ai_context`, 60 files.
- `KnowledgeServicePlugin` or `registerSource` under `examples/`: 0
files. Control: 25 files under `packages/`.
- Tracked paths under `knowledge-pgvector` or `knowledge-turso`: 0.
Control: `packages/plugins/knowledge-memory`, 10 files.
- Before this diff, ADR-0161 named ADR-0150 on 0 lines (control:
ADR-0088, 7 lines), and ADR-0150 held the word "knowledge" on 0 lines
(control: `ai_context`, 6 lines).

</details>

<details>
<summary>Local gates at head 05f35b6: 21 derived, 21 run, all exit
0</summary>

Derived with `node scripts/pm/dispatch-gates.mjs --repo
objectstack-ai/objectstack --commands`, and reconciled with `--ran`:

```
Run reconciliation — 21 derived, 21 run, 0 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 21 derived famil(ies) accounted for — 21 run, 0 NOT-MEASURED (a DERIVED zero — all 21 recorded an exit code and none of them is 3).
```

Each exit code was captured before any pipe:

```
0  node scripts/check-adr-links.mjs                      1225 relative link destination(s) under docs/adr/ resolve
0  node scripts/check-adr-links.mjs --self-test
0  node scripts/check-closing-keyword-parity.mjs         3 parsers agree on all 9 keywords
0  node scripts/check-closing-keyword-parity.mjs --self-test
0  node scripts/check-comment-mask-corpus.mjs            23929 files, 0 disagree, 0 unparseable
0  node scripts/ci/plan-test-core-shards.mjs --self-test
0  pnpm --filter @objectstack/lint run check:doc-formula-expressions
0  pnpm check:adr-anchors                                132 anchored file(s), every governing ADR still referenced
0  pnpm check:adr-index                                  docs/adr/README.md is current, every record parsed
0  pnpm check:adr-symbol-anchors                         4220 anchors across 163 records resolve
0  pnpm check:ci-filter-parity
0  pnpm check:closed-ceremony-text
0  pnpm check:cross-package-test-inputs
0  pnpm check:doc-authoring
0  pnpm check:driver-memory-census
0  pnpm check:gitlink-declared
0  pnpm check:nul-bytes                                  no raw ASCII control bytes
0  pnpm check:pm-governed-merges
0  pnpm check:pm-prior-rulings
0  pnpm check:refd-timer-probe
0  pnpm check:watch-hint-literal
```

`check:doc-formula-expressions` reads the compiled output of
`@objectstack/formula` and `@objectstack/lint`. Those two and their
dependencies were built first on the merged tree, under the shared
verify lock (`VERDICT command-exit 0`).

`docs/adr/README.md` is generated from each record's status keyword.
ADR-0150's keyword stays Accepted and ADR-0161's stays Proposed, so the
index does not change and is not in this diff.

Also at this head: `node scripts/check-commit-card-trailers.mjs --range
origin/main..HEAD` exits 0 over the 3 commits of the branch.

Not measured locally, and CI's to run: the type-check lanes, the `Plan
Test Core shards` job and the governed-merges audit, which take values
only a CI run has.

</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbZjKjZ947xtTvgJuHX)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…nd names the keys retired beside it (objectstack-ai#37334)

<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8JhskFY4nvqZftyd6QBC3Sa)_

Fixes objectstack-ai#37292

Clause-②: no
Metadata-protocol: none
Skills-docs: this PR is the skills-docs half (`skills/objectstack-ai`);
PR objectstack-ai#37287 shipped the `split` key and named this card

## 维护者速读

- 用户能看到什么变化:用 AI 搭建知识源时,AI
读到的技能说明现在会教「切片设置」怎么写:普通文字按段落和句子切,带标题的手册按章节切,短记录整篇一段;并说明「切片重叠」设置和单段附加信息已经下线、写了会被拒。只有文字变化。
- 为什么做:属于知识检索平台化专题,补上切片功能合并后欠下的技能说明,后面重写知识源一节的卡要在它之后做。
- 出错会怎样:最坏是说明写得不准,AI 写出的设置仍会被校验拦住;撤回即恢复旧文字。
- 要你做什么:受治理的技能文件,需要你批准后合并。

## What changes

`skills/objectstack-ai/SKILL.md`, *Knowledge Sources (RAG)*:

- The `object` row of the source table gains `split?`, and a new passage
replaces the closing note that said chunking is not platform metadata
(PR objectstack-ai#37287 made that false). It teaches `split: { strategy, maxChars?,
minChars? }` on object sources only: `recursive` (default) for prose,
`markdown` for documents with headings (each passage embedded with its
heading path), `whole` for short records only, because a document over
the embedder's input budget is removed from the index and reported,
never truncated. `maxChars` overrides the **Target chunk size** setting
(`knowledge.chunk_target`, else 800), the embedder's input limit can
lower it, and `whole` ignores it; `minChars` defaults to 200. Changing
`split` re-splits a document only when it next changes.
- The key applies to an adapter that declares `capabilities.chunks`
(`memory`); `ragflow` does not, receives whole documents, and `split`
has no effect on it.
- Names the two keys retired beside it, both refused when written: the
`knowledge.chunk_overlap` setting (`400 UNKNOWN_KEY`; passages never
overlap) and `KnowledgeChunk.metadata` (parse error; a passage takes its
document's `metadata`).
- Top-K, score thresholds and rerankers: not source metadata; they
belong to the adapter or application code.

Paid for by deleting restatement in the same file; the token ceiling is
unchanged (6801, the file measures 6800). Deleted: the pitfall "Indexing
everything" (the `object` row's Hygiene column says it); the "Skills are
your entry point" paragraph (the frontmatter, the `tools` row and
*Platform agents* say it); the incident sentence after
`ai-skill-tool-unresolved`; the sentence on what `os validate` confirms;
the *App AI Blueprint* registration-row clause repeating three facts
stated in their own sections; four clauses repeating the sentence beside
them (*Tool metadata*, *Platform agents*, *Wiring*, *Actions as AI
Tools*).

`evals/skills-tools-knowledge.json`:

- New case 9: a Markdown handbook source on the in-memory adapter, split
by section at 600 characters, with a request for overlapping passages.
Expected: `split: { strategy: 'markdown', maxChars: 600 }` and the
overlap declined. Assertions: must contain `split`, `strategy`,
`markdown`, `maxChars`; must not contain `chunkSize`, `chunkOverlap`,
`overlap: 100`.
- Case 3 (RAGFlow): `expected_output` no longer says chunking is adapter
config; it writes no `split`, since that adapter receives whole
documents.

Changeset `.changeset/37292-skill-knowledge-split.md`:
`@objectstack/skills` patch.

Out of scope, left for their cards: the `contentFields` / `id` / `'*'` /
`embedding` / `vectorStore` / `file` / `http` / `adapterConfig` teaching
and the example block (objectstack-ai#37310, row 5b, after objectstack-ai#37306), and the `ragflow`
mentions (objectstack-ai#37004).

## Why

PR objectstack-ai#37287 (objectstack-ai#37098) added the source's `split` key and retired
`KnowledgeChunk.metadata` and `knowledge.chunk_overlap`. The skill an AI
reads to author a knowledge source did not mention any of them and still
said chunking is not platform metadata, so an agent would never set
`split` and could still write the overlap setting.

## Verification

Every claim in the new passage rests on:
`packages/spec/src/ai/knowledge-source.zod.ts` (`KnowledgeSplitSchema`,
`ObjectKnowledgeSourceSchema.split`),
`packages/spec/src/ai/knowledge-document.zod.ts` (the
`KnowledgeChunk.metadata` tombstone),
`content/docs/protocol/knowledge.mdx` §3.5 and the adapter-contract
paragraph above it, `.changeset/37098-knowledge-splitter.md` (the
`chunk_overlap` refusal),
`packages/plugins/knowledge-memory/src/index.ts:46` (`capabilities = {
chunks: true }`; `knowledge-ragflow` declares none).

Skills size readings (`node scripts/check-skills-token-ratchet.mjs`,
tokens = ceil(utf8 bytes / 4)):

| | main | this PR |
|---|---|---|
| `skills/objectstack-ai/SKILL.md` lines | 467 | 474 |
| `skills/objectstack-ai/SKILL.md` tokens (ceiling 6801) | 6801 | 6800 |
| All `skills/*/SKILL.md` lines | 4941 | 4948 |
| Bundle total tokens (whole shipped tree) | 297002 | 297305 |

The bundle grows by 303 tokens, all in the unratcheted eval fixture
(2140 to 2444); ratcheted authored text drops by 1.

<details><summary>Local gates at 6fb18c1</summary>

`node scripts/pm/dispatch-gates.mjs --commands` derived 49 commands. 41
ran locally, all exit 0, including `check-skills-token-ratchet` (gate
and `--self-test`), `@objectstack/spec check:skill-docs`,
`check:skill-links`, `check:skill-identifier-liveness`,
`check:skill-compatibility`, `check:skill-frame-sync`,
`check:doc-authoring`, `check:nul-bytes`, `check-empty-changeset`,
`check-changeset-no-major`, `check-adr-0087-registration`,
`check:pm-governed-merges`.

NOT MEASURED locally, left to CI: `@objectstack/lint
check:doc-formula-expressions` (exit 3, prerequisite: needs
`@objectstack/formula` and `@objectstack/lint` built; nothing measured),
and seven families that read built `dist/` output (`check:dts-closure`,
`check:dual-build-cjs-loads`, `check:lean-entry-closure`,
`check:published-files`, `check:sourcemap-no-sources-content`,
`check:driver-memory-census`, `check:corpus-claim-drift`). The diff
touches no package source.
</details>

No ablation: the change is docs and an eval fixture; no tested behaviour
moved.

Two-minute check: read *Knowledge Sources (RAG)* in
`skills/objectstack-ai/SKILL.md` and compare the *Splitting* passage
with `content/docs/protocol/knowledge.mdx` §3.5.

## Acceptance notes

- Authored by a Fable subagent from a first draft in this session, per
the claim's tier; the seat's L1 and the contract review read the final
diff.
- None filed.

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (repo-wide lint is CI's
run; the diff touches only Markdown and JSON)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01JQwxbYY43RED8SphBLGpAy

---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbYY43RED8SphBLGpAy)_

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…dshake reads '^19' (objectstack-ai#37314)

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ
Fixes objectstack-ai#37229
Clause-②: yes (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up objectstack-ai#37298

## 维护者速读

- 协议版本从 18 升到 19:仓库里每个示例应用、连接器应用和文档示例都改为声明 19,新建项目模板在出预发布版时自动改成 19;只有装
19 预发布版的人会碰到。
- 属于「19.0.0 大版本」路线(你选的方案「A」第 2 项);它解开 19.0.0-next 的版本
PR:出版本的流水线不接受顺手改协议版本,所以由这一单先改好。
- 装了 19 预发布版、但应用仍声明 18 的人,启动时会被拒绝并提示改成
19(单一配置文件的应用有一条命令可自动改;多包组合的应用要逐个包手改);18.x 正式版用户不受影响;撤回即还原本单。
- 按你对冲突的裁决「A」,本单还改了一道检查:预发布模式下且 spec 已排定大版本时,下架提示写「19.0.0」不再被拦;五条下架提示因此写
19.0.0。
- 要你做的:「进入预发布模式」那一单已合并;本单是大版本变更,请你亲自把关合并。「Check
Changeset」是有意的红:本单改了别人已合并的两条变更说明(各改一处事实)。另一单 objectstack-ai#37298 改三个技能文件,在本单合入之后合并。

## What changes

On the shape of the v18 move (objectstack-ai#22215, commit `4e9fe9f`), minus
`skills/**`.

- **`packages/spec/src/kernel/protocol-version.ts`:** `PROTOCOL_VERSION
= '19.0.0'`. The docblock names protocol 19 as the pre-mode lockstep
exception (ruling records 6049734955 and 7153441862), and says the blank
template follows at the version pass and the published skills' examples
in a change of their own.
- **Handshakes:** 85 sites in 67 files move `engines.protocol` from
`'^18'` to `'^19'`. Each is a manifest that stands for "an app on the
current protocol", and none of them asserts on the range.

| Directory | Files | Sites |
|---|---|---|
| `examples/` (crm, showcase, todo, starter, multi-package ×2) | 6 | 6 |
| `packages/apps/connector-{docusign,github,stripe}` | 3 | 3 |
| `packages/cli` (tests) | 40 | 56 |
| `packages/qa` (7 dogfood tests, the sql-perf bench app, the scenarios
exporter test) | 9 | 9 |
| `packages/lint`, `packages/spec`, `packages/metadata` (tests) | 4 | 5
|
| `packages/mcp/README.md` | 1 | 2 |
| `content/docs` (cli, your-first-project, upgrading) | 3 | 3 |
| `docs/qa/scenarios/builds/travel_expense.json` | 1 | 1 |

`examples/app-starter` arrived from `main` (objectstack-ai#37399) declaring `'^18'`
and moves with the merge. Its boot test, which installs the starter
through `MarketplaceInstallLocalPlugin`, passes 5/5 at `'^19'`. At
`'^18'` it reads 3 failed | 2 passed, refused
`OS_PROTOCOL_INCOMPATIBLE`.

- **`docs/qa/platform-checklist/areas/cli.json`:** one prose fact, "the
stock showcase declares `'^18'`", now reads `'^19'`.
- **`docs/qa/scenarios/builds/travel_expense.provenance.json`:**
`sha256` is the build's hash as it now stands, and a second `amended`
entry names the one edit (`engines.protocol` `'^18'` → `'^19'`) and the
hash it replaced. `cardSha256` is unchanged.
- **The protocol 19 migration step (ADR-0087).**
`packages/spec/src/migrations/registry.ts.template` opens `step19`, with
no conversions yet. Its first semantic entry,
`entries/semantic/19.protocol-18-range-refused.ts`, is the refusal this
PR causes, with the prescription: `--write` rewrites the range of a root
`defineStack` manifest; for a manifest `composeStacks` composes, it
writes nothing and lists the range for a hand edit in each package
manifest. Its acceptance text claims only what the hop does: it edits or
refuses the range. A key retired in this release that the metadata still
carries is refused at parse by its own message, which names its own
remedy. The text no longer says that `validate` passes or that every
package installs. The upgrade guide now generates three hop sections
(17, 18, 19). See "Why a step-19 entry" below.
- **Removal prescriptions stamped after 18.6.0 name `@objectstack/spec
19.0.0`.** `retired-key-removal-version.pin.test.ts` derives the
removing release's major from `PROTOCOL_MAJOR`, so at 19 the retirements
not in the published 18.6.0 name 19.0.0, not 18.7.0, a release the v19
line never cuts: `object-grid` `singleClickEdit` (`component.zod.ts`),
the boolean `field.inlineEdit` (`field.zod.ts`), `listView.columnState`
and `view.columnState` (`view.zod.ts`), and `seed.mode` `'insert'` /
`'replace'` (`seed.zod.ts`). Their text pins, the regenerated
`content/docs/references/ui/{component,view}.mdx`,
`content/docs/data-modeling/seed-data.mdx` and the metadata-protocol
seed pin follow.
- **`scripts/check-future-spec-major.mjs` reads the pre-mode window
(ruling record 7176929521, option A).** On a stable `@objectstack/spec`
label, with `.changeset/pre.json` at `"mode": "pre"` and a pending
changeset declaring `"@objectstack/spec": major`, the next publish is
label + 1, so the gate judges citations against 19 here. That is why the
prescriptions above can name `@objectstack/spec 19.0.0`. The window is
read through `check-changeset-no-major.mjs`'s
`readProtocolLockstepInputs`, the reader the protocol lockstep already
uses; there is no second parser. That file's docblock now names its
three importers (`check-docs-image-tag.mjs`,
`check-future-spec-major.mjs`, `pm/l1-face.mjs`); the change is a
comment. Label + 2, pre mode without a pending spec major, a pending
spec major outside pre mode and a prerelease label each open nothing;
five new self-test rows pin those five cases (34 → 39 cases). An
unreadable `.changeset/` opens nothing either, by the code; no row pins
it. The stable-label condition is the same one `judgeProtocolLockstep`
applies: on a `19.0.0-next.N` label the label's own major is already the
carrier. Reverse verification: with the window condition ablated, the
gate reads 14 problems, the 14 sites.
- **Two fixtures pay a dynamic load at module top**
(`validate-flow-region-shape.test.ts`,
`plugin-artifact-packages-attribution.test.ts`).
`check:test-source-alias` judges every test file a diff edits, and both
edits here are the range literal. The gate prescribes exactly these
imports.
- **`.changeset/37229-protocol-19.md`:** `"@objectstack/spec": minor`
and `"@objectstack/mcp": patch` (its shipped `README.md` changes), the
two declaration lines, a BREAKING note with the FROM → TO and the
command, and `registered protocol-18-range-refused`.
- **DELIBERATE CORRECTION of two existing changesets.** `Check
Changeset` stays red on both by design: each note is on the merge base,
and each changes only the facts this PR makes false.
- `.changeset/37223-v19-line-opens.md` (carried N1 of objectstack-ai#37230's L1, and
N3 of this PR's L1), two sentences. "The first is `@object-ui/i18n`'s
retirement …" now reads "The first change graded `major` is
`@object-ui/i18n`'s retirement …", because this PR's protocol move is a
breaking change graded `minor`. "`PROTOCOL_VERSION` follows
`@objectstack/spec`'s major at version time." now reads
"`PROTOCOL_VERSION` moves to 19 ahead of the version pass, in its own
changeset."
- `.changeset/37042-skills-inline-edit-boolean.md`, one clause: "The
spec parse refuses `true` and `false` on a relationship field's
`inlineEdit` since 18.7.0" now reads "… since 19.0.0", the release the
retirement ships in.
- **Carried from objectstack-ai#37230's L1, N3 —
`ui/packages/i18n/scripts/released-keys-removed.mjs`** refuses an
argument it does not know (exit 2, naming it), and prints the tag's
commit: `^{commit}` peels the annotated tag. Measured: the tag
`@object-ui/i18n@18.6.0` is a tag object `0dbef86ce3`, and the script
now prints its commit `958ee03594`. The script is not in the package's
`files[]`, so it publishes nothing and needs no changeset.

## Judgments: every `'^18'` left in place, with its reason

| Site | Reason |
|---|---|
| `skills/**` (3 files) | Governed Tier H; the sibling PR objectstack-ai#37298. |
|
`packages/create-objectstack/src/templates/blank/objectstack.config.ts:38`
| The version pass stamps it with the template's `@objectstack/*`
versions, and `template-consistency.test.ts` holds it equal to the
scaffolder major (create-objectstack is 18.6.0). Measured: moved to
`'^19'` now, that test goes red; the version-pass rehearsal below stamps
it `'^19'`. Same judgment as objectstack-ai#22215. |
| `packages/cli/src/utils/protocol-version-gap.test.ts:82` | Paired with
an explicit installed `'17.2.0'`: "a newer major is silent". The subject
is the pairing, not the current protocol. |
| `packages/metadata-core/src/artifact-forward-conversion*.test.ts`,
`protocol-handshake.test.ts` | The subject is the artifact's floor
against an injected runtime label (the v18 prerelease major-step
window), or a range/major pair. No handshake against `PROTOCOL_VERSION`
runs. |
|
`packages/metadata/src/plugin-artifact-forward-conversion-{major-step,package-body}.test.ts`
| The same age subject at the metadata door, which runs no handshake. |
| `docs/qa/platform-checklist/areas/platform-core.json`, item
`platform-core.protocol-18-handshake-and-stored-replay` | Revised in
place to protocol 19 (revision 6, with its history entry). The id keeps
its protocol-18 slug because ids are immutable. Its `'^18'` now stands
for the refused case: `'^18'` → 422 `OS_PROTOCOL_INCOMPATIBLE` naming
`os migrate meta --from 18`, `'^19'` admitted, and the artifact step
edits the copy's range to `'>=18.0.0'`, as the option-B fixture does. |
| `content/docs/releases/**`, `docs/adr/**`, `**/CHANGELOG.md`,
`.github/workflows/release.yml` (comment), script comments |
Release-owned, governed or historical prose. |
| `ui/**` tests,
`packages/runtime/src/domains/packages-ensure-customization.test.ts`,
`scripts/docs-audit/affected-docs.mjs` | Not a protocol handshake
(`requiredRange` of a later refusal, a package-dependency range, a React
peer range). |

Moved to `'>=18.0.0'` (5 sites, commit `e05fdf6f`):
`packages/runtime/src/standalone-stack-option-b-forward-conversion.test.ts`.
It boots through the load seam, which refuses `'^18'` at protocol 19.
Measured: `ProtocolIncompatibleError: package 'com.test.ob.core' targets
protocol ^18 … Run: objectstack migrate meta --from 18`, 3 cases. Its
subject is the conversion window, which opens on the floor. `'>=18.0.0'`
keeps the floor (18.0.0, as `parseRangeFloor` reads `^18`) and admits
19. This is the same move as objectstack-ai#22215's two runtime fixtures (`>=17.1.0`).
The fixture's docblock now says why, so a later sweep to `'^19'` does
not close the window.

## Why a step-19 entry (the ADR-0087 disposition)

`Metadata-protocol:` is judged from content. A 19 runtime refuses an
authored value, `engines.protocol: '^18'`, that 18 admitted. That is
`narrowed`, and the `Clause-②` arm is `narrowing`, as in objectstack-ai#22215. On a
declared `narrowed`, `check:adr-0087-registration` refuses `not-required
(no-migration-prescription)` outright and asks for a registered entry.
Measured: "`not-required (no-migration-prescription)` is refused on a
changeset that declares `Metadata-protocol: narrowed` … fix: register an
entry under packages/spec/src/migrations/entries/semantic/". No entry at
the merge base covers the refusal, so this PR opens step 19 with one
entry, and the upgrade guide carries the prescription.

## Acceptance notes

- **Docs versus npm `latest`.** The three docs pages show `'^19'`, as in
objectstack-ai#22215. npm `latest` stays 18.6.0 until 19.0 GA, and an 18.x runtime
refuses `'^19'`. The changeset says to move the range together with the
`@objectstack/*` versions.
- **Size.** 92 files, +440 / −161 against `main` (GitHub at
`3811cd10f5a`), under the 3,000-line threshold.
- **Out of this PR, found by the version-pass rehearsal.** On the
post-version tree, `check:release-notes` is red: `@objectstack/spec`
ships 19.x and there is no curated `content/docs/releases/v19` page. It
is red on the control leg too (main + objectstack-ai#37230, without this PR), so
objectstack-ai#37230's `major` causes it, not this PR. Release pages are
release-owned, so this PR does not write one. Until one exists, the
version-PR lane still refuses the 19.0.0-next refresh, on that gate
alone.
- **objectstack-ai#37287 and step 19.** objectstack-ai#37287 registered its retirement,
`KnowledgeChunk.metadata`, under step 18; it reached this branch through
the merge of `main`, and its refusal says "removed in @objectstack/spec
18" (`packages/spec/src/ai/knowledge-document.zod.ts:61`). Once protocol
19 is on `main`, `os migrate meta --from 18` replays only step 19, so a
retirement that ships on the v19 line and is filed under step 18 is not
listed to an 18 → 19 upgrader. objectstack-ai#37287 is one member of the family
"step-18 entries registered on `main` after the 18.6.0 tag" (31 step-18
semantic entry files at this head that the 18.6.0 tag does not carry,
and 34 on `main` at `5d21d431ec`, after objectstack-ai#37382, objectstack-ai#37392 and objectstack-ai#37395). That
card is follow-up owed (seat).
- **The dev's open questions, as built (seat reading at L1):**
- The declaration is `yes (narrowing)` + `narrowed` with a step-19
entry, rather than `semantic`.
  - The blank template stays `'^18'`, and the version pass stamps it.
- The metadata and metadata-core floor-subject sites are kept. The
option-B runtime file moves to `'>=18.0.0'`.
- The gate conflict between `check-future-spec-major` and the
removal-version pin is resolved by ruling record 7176929521, option A
(above).

## Verification

Two-minute check: `node scripts/check-future-spec-major.mjs` prints `✓
check-future-spec-major: no @objectstack/spec citation names a major
above 19` and `pre-mode window: label major 18, pre mode next, pending
major for @objectstack/spec in .changeset/37223-v19-line-opens.md — the
next publish carries 19`, and exits 0. `node
scripts/check-changeset-no-major.mjs --base origin/main` prints `✓
Protocol lockstep: PROTOCOL_VERSION major 19, @objectstack/spec@18.6.0 —
the one exception, evidenced: pre mode (tag next) and a pending major
for @objectstack/spec (.changeset/37223-v19-line-opens.md).` and exits
0.

Read first:
1. `.changeset/37229-protocol-19.md` and
`packages/spec/src/migrations/entries/semantic/19.protocol-18-range-refused.ts`:
what an upgrading author is told.
2. `packages/spec/src/migrations/registry.ts.template`, the new
`step19`: the ledger's protocol 19 step opens here.
3. `scripts/check-future-spec-major.mjs`, `judgedMajor` and the five new
self-test rows: the one gate this PR changes.
4. The Judgments table: every `'^18'` left in place.

<details><summary>Readings at <code>3811cd10f5a</code> (the dev's,
through the verify lock, and the seat's L1)</summary>

- **CI at `3811cd10f5a`:** 70 check-runs, 60 success, 9 skipped, 1
failure. The failure is `Check Changeset`, by design: its two file
annotations name the two DELIBERATE CORRECTION notes, and its ADR-0087
and no-major steps are green. All eleven required contexts are success,
`Test Core` 10/10 included, and so is `Type Check · source gates`.
- **Tests:**
- dogfood full battery (os-dev-report 7183121949 on objectstack-ai#37229): Test Files
487 passed | 3 skipped (490), Tests 4129 passed | 68 skipped (4197),
VERDICT command-exit 0.
- whole spec suite: Test Files 896 passed (896), Tests 28442 passed | 1
todo (28443).
- `examples/app-starter` boot test: 5/5 (re-run by the seat). With the
range put back to `'^18'` through `ablation-replace`, it reads 3 failed
| 2 passed, refused `OS_PROTOCOL_INCOMPATIBLE`; the restore was proven
with `git diff HEAD` empty.
- `retired-key-removal-version.pin.test.ts` and
`protocol-version.test.ts`: 2 files, 68/68 (re-run by the seat).
- **Guards:**
- `check-future-spec-major` exits 0, and `--self-test` reads `39 cases
pass` (re-run by the seat). The gate file is byte-identical to
`9ed0f5e41f6`, where the seat ablated `stable`, the pending-major
condition, the pre-mode condition and `+ 1` in turn: one self-test row
went red each time, and with the window off the scan read the 14 sites.
Each ablation was restored with `git diff HEAD` empty.
  - `check-changeset-no-major --base origin/main` exits 0.
- `check:adr-0087-registration` exits 0 with `registered
protocol-18-range-refused`.
- `dispatch-gates --commands` derives 150 families on this diff. Two are
red: `check-empty-changeset` by design (the two DELIBERATE CORRECTION
notes), and `check:platform-checklist` on `areas/automation.json: ABSENT
SYMBOL … FlowItemMoreMenu.tsx#FlowItemMoreMenu`, which `main` itself
carries (reproduced on `origin/main` `ecbe854bda`; this diff touches
neither path). The other 148 exit 0.
- **Against current `main` (`5d21d431ec`, 9 commits past the merge
base):** `git merge-tree --write-tree` is clean, and the merged tree
carries the same `'^18'` lines as this head. `main` added no other
handshake at `'^18'`.

</details>

<details><summary>Earlier readings (the dev's, on 9da4c1d plus the
fixture fix, and at 8852bcb for the <code>--write</code>
reach)</summary>

Not re-run at `3811cd10f5a`. Of the code these read, this PR changed
only the step-19 entry's text and the `examples/app-starter` range after
them. The merges of `main` brought other changes in, and CI at the head
is green.

- **Handshake**, from the built `@objectstack/metadata-core` on protocol
19: `'^18'` → `incompatible OS_PROTOCOL_INCOMPATIBLE … Run: objectstack
migrate meta --from 18`; `'^19'` → `ok`.
- **Prescription**, with the built CLI. On a `'^18'` copy of
`examples/app-todo`, `os migrate meta --from 18` lists the step-19
entry, and `--write` rewrites `objectstack.config.ts:48` to `'^19'`. On
`examples/app-multi-package` with both package manifests at `'^18'`,
`--write` writes nothing and prints the range for a hand edit (`manifest
is composed by composeStacks(…)`).
- **Template control leg:** moving the blank template to `'^19'` now
turns `template-consistency.test.ts` red (`expected 19 to be 18`).
- **`release.yml` version-pass rehearsal.** The `version-pr` Render and
Validate blocks were extracted verbatim and run in a throwaway clone:
- Results: `PROTOCOL_VERSION already 19.0.0`; the template is stamped
`'^19'`; unvalidated surfaces 0; 14 of 15 content gates green;
`check:release-notes` red.
- Control (main + objectstack-ai#37230 without this PR): `protocol-version.ts` is
unvalidated, with the same release-notes red.
- **Tests:** cli 677 files, 8441 tests passed; runtime 647 files, 11978
passed | 25 skipped (the option-B file fails 3 cases at 9da4c1d and
passes 6/6 at e05fdf6); metadata, metadata-core, lint, mcp,
create-objectstack, scenarios and the example tests all green;
`validate` exits 0 for 4 examples and 3 connector apps.

</details>

## Provenance

Opened by seat repo:objectstack#4 on the maintainer's authorization in
the seat session (「objectstack-ai#37229 的两个 PR 开 PR 时被拦了:放行」). The dev session
(`session_01QSeKYnLptCbfzwtkTrDG3j`, zone a4-S) had three writes refused
by its permission check, and none was retried: its relay `pr_create`,
the hand-off of the payload to the seat, and the push of the runtime
fixture fix. The seat read the prepared body from that session's final
message. The fixture fix was then re-applied and pushed as `e05fdf6f`
(fast-forward, five sites in one test file) by a seat-dispatched dev, on
the maintainer's authorization 「objectstack-ai#37229 夹具修复推送放行」. Rework round 1 (seat
L1 7170046632) pushed `3fdf3490b9` to `43133e8ce5`. After ruling record
7176929521, `c871272e47` merged `origin/main` `db77cc493a`, `e5a7e35bff`
regenerated the two ui reference pages from the merged tree, and
`9ed0f5e41f` changed the gate. Rework round 2 (seat L1 7181615974, L2
7181629335): `d47c169db75` merged `origin/main` `da7c559990`, and
`3811cd10f5a` moved `examples/app-starter` to `'^19'`, narrowed the
step-19 entry's acceptance text, and corrected a comment in
`check-changeset-no-major.mjs`. Branch
`claude/issue-37229-protocol-version-19` @ `3811cd10f5a`.

---
🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ

---------

Co-authored-by: Claude <noreply@anthropic.com>
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 pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue protocol:ai size/xl 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: one service-layer splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key

3 participants