Skip to content

Commit 98bda0a

Browse files
docs(skills): objectstack-ai teaches the knowledge source split key and names the keys retired beside it (#37334)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8JhskFY4nvqZftyd6QBC3Sa)_ Fixes #37292 Clause-②: no Metadata-protocol: none Skills-docs: this PR is the skills-docs half (`skills/objectstack-ai`); PR #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 #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 (#37310, row 5b, after #37306), and the `ragflow` mentions (#37004). ## Why PR #37287 (#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>
1 parent 8fe4eaf commit 98bda0a

3 files changed

Lines changed: 69 additions & 27 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): `objectstack-ai` teaches the knowledge source `split` key and names the two keys retired beside it
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`skills/objectstack-ai/SKILL.md`, *Knowledge Sources (RAG)*:
11+
12+
- The object source's fields gain `split?`, and a passage teaches `split: { strategy, maxChars?, minChars? }`, an object-source key: `recursive` (the default) for prose, `markdown` for documents with headings, `whole` for short records only, since 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 the document next changes. The key applies to an adapter that declares `capabilities.chunks` (`memory`); one that does not (`ragflow`) receives whole documents, and `split` has no effect on it.
13+
- It names the two keys retired with the splitter, and that each is refused when written: the `knowledge.chunk_overlap` setting (`400 UNKNOWN_KEY`; passages never overlap) and `KnowledgeChunk.metadata` (a parse error; a passage takes its document's `metadata`).
14+
- The closing note that said chunking is not platform metadata is replaced: the service splits; top-K, score thresholds and rerankers are not source metadata and belong to the adapter or application code.
15+
16+
Paid for by deleting restatement in the same file, with the token ceiling unchanged (6801; the file now measures 6800):
17+
18+
- the pitfall "Indexing everything" (the `object` row's hygiene column says the same);
19+
- the "Skills are your entry point" paragraph under the diagram (the frontmatter description, the `tools` row and *Platform agents* say the same);
20+
- the incident sentence after `ai-skill-tool-unresolved`;
21+
- the sentence saying what `os validate` confirms;
22+
- the clause of the *App AI Blueprint* registration row repeating three facts stated in their own sections;
23+
- four clauses that repeated the sentence beside them: "A skill names a platform tool or an `action_<name>`" (*Tool metadata*), "the user never picks from a roster…" (*Platform agents*), "without one the id is unresolvable" (*Wiring*), and "exposure is never automatic" (*Actions as AI Tools*).
24+
25+
`evals/skills-tools-knowledge.json`: a new case 9 asks for a Markdown handbook source on the in-memory adapter, split by section at 600 characters with overlapping passages; the expected answer writes `split: { strategy: 'markdown', maxChars: 600 }` and declines the overlap. Case 3 (RAGFlow) no longer says chunking is adapter config: its expected answer writes no `split`, because that adapter receives whole documents.

‎skills/objectstack-ai/SKILL.md‎

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ Agent → Skill → Tool
3636
└─ Autonomous actor with role, instructions, and guardrails
3737
```
3838

39-
**Skills are your entry point** — agents are platform-internal (reference
40-
section at the bottom), so you extend the platform by authoring skills, and a
41-
skill reaches tools by naming them.
42-
4339
---
4440

4541
## Skill Configuration
@@ -85,9 +81,7 @@ A `skill.tools[]` entry resolves against the union of four sources
8581
own hint: no in-product turn registers it.
8682

8783
A name none of them resolves raises **`ai-skill-tool-unresolved`** (warning,
88-
ADR-0078 advisory-first). The rule exists because one audited app shipped 10
89-
fictional tools across 6 skills through `validate` / `lint` clean, and became a
90-
copilot claiming abilities it did not have.
84+
ADR-0078 advisory-first).
9185

9286
### Skill Example
9387

@@ -149,7 +143,7 @@ You usually **don't author tool definitions by hand** for action invocation. An
149143
tool named `action_<actionName>` **only when it opts in** — `ai.exposed: true`
150144
(default `false`) plus an `ai.description` of ≥ 40 chars, refused by the parse
151145
without it (ADR-0011). `registerActionsAsTools()` walks the opted-in ones;
152-
exposure is never automatic, and there is no opt-out key.
146+
there is no opt-out key.
153147

154148
Three action types dispatch headlessly:
155149

@@ -243,8 +237,7 @@ collection for them — they are registered at runtime, and the ☁️
243237
`@objectstack/service-knowledge` registers `IKnowledgeService` with the kernel and
244238
each source at boot (`service.registerSource` still works later). The `adapter`
245239
id resolves against an adapter plugin — `@objectstack/knowledge-memory`
246-
(`'memory'`, dev/test) or `@objectstack/knowledge-ragflow` (`'ragflow'`);
247-
without one the id is unresolvable.
240+
(`'memory'`, dev/test) or `@objectstack/knowledge-ragflow` (`'ragflow'`).
248241

249242
| Property | Purpose |
250243
|:---------|:--------|
@@ -260,7 +253,7 @@ without one the id is unresolvable.
260253

261254
| `source.kind` | Fields | Hygiene |
262255
|:--------------|:-------|:--------|
263-
| `object` | `object`, `contentFields[]` (min 1; `*` = every readable text field), `metadataFields?`, `where?` (ObjectQL `where` syntax) | `where` keeps drafts and archived rows out of the index; `contentFields` takes meaningful text only (never system fields or ids, `*` sparingly); project what you will filter on at query time (`status`, `owner_id`, `tags`) into `metadataFields` |
256+
| `object` | `object`, `contentFields[]` (min 1; `*` = every readable text field), `metadataFields?`, `where?` (ObjectQL `where` syntax), `split?` (below) | `where` keeps drafts and archived rows out of the index; `contentFields` takes meaningful text only (never system fields or ids, `*` sparingly); project what you will filter on at query time (`status`, `owner_id`, `tags`) into `metadataFields` |
264257
| `file` | `prefix` (storage prefix, e.g. `kb/handbooks/`), `mimeTypes?` | narrow the prefix instead of indexing a whole bucket |
265258
| `http` | `urls[]`, `userAgent?` | enumerate URLs explicitly — there is no crawler |
266259

@@ -283,17 +276,37 @@ export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({
283276
});
284277
```
285278

286-
> **Chunking, top-K, score thresholds and rerankers are NOT platform metadata.**
287-
> The spec scopes them out deliberately (`embedding.zod.ts`): they belong to the
288-
> adapter (`adapterConfig`) or application code. The platform carries only the
289-
> embed + vector primitives, so any RAG strategy can be built on top.
279+
**Splitting (`split`, object sources only).** The knowledge service cuts each
280+
document into passages for an adapter declaring `capabilities.chunks`
281+
(`memory`). Any other adapter (`ragflow`) receives whole documents; `split` has
282+
no effect on it. `split: { strategy, maxChars?, minChars? }`:
283+
284+
- `recursive` (default): cuts at blank lines, then line breaks, then sentence
285+
ends. For prose.
286+
- `markdown`: one section per heading, each passage embedded with its heading
287+
path. For documents with headings.
288+
- `whole`: one passage per document. For short records only: a document over
289+
the embedder's input budget is removed from the index and reported, never
290+
truncated.
291+
292+
`maxChars`, the longest passage in characters (`whole` ignores it), overrides
293+
the **Target chunk size** setting (`knowledge.chunk_target`, else 800); the
294+
embedder's input limit can lower it. Adjacent pieces shorter than `minChars`
295+
(default 200) are merged. Changing `split` re-splits a document only when it
296+
next changes.
297+
298+
Retired and refused: the `knowledge.chunk_overlap` setting (`400 UNKNOWN_KEY`;
299+
passages never overlap) and `KnowledgeChunk.metadata` (parse error; a passage
300+
takes its document's `metadata`).
301+
302+
Top-K, score thresholds and rerankers are not source metadata: they belong to
303+
the adapter or application code.
290304

291305
---
292306

293307
## Tool metadata (`defineTool`) — not the default path
294308

295-
**Default: declare no tool records.** A skill names a platform tool or an
296-
`action_<name>` (ladder above). ADR-0109: a `stack.tools` record "exists only for
309+
**Default: declare no tool records.** ADR-0109: a `stack.tools` record "exists only for
297310
AI-presentation refinement (Phase 2: LLM description, parameter narrowing, flow
298311
exposure) and has no runtime reader until that lands"
299312
(`packages/spec/src/stack.zod.ts:595-602`). Author one only to refine how an
@@ -362,10 +375,6 @@ there is **no top-level `temperature` / `maxTokens`** on an agent
362375
door; a `state_machine` dead-end (`closed: []`) still makes the reached
363376
state final for every writer (**objectstack-automation**
364377
`references/state-machines-and-approvals.md`).
365-
3. **Indexing everything.** A knowledge source without a `where` filter and
366-
curated `contentFields` fills the index with drafts and boilerplate that
367-
pollute retrieval. Source hygiene is the metadata's job; relevance tuning
368-
belongs to the adapter.
369378

370379
---
371380

@@ -375,7 +384,7 @@ there is **no top-level `temperature` / `maxTokens`** on an agent
375384
|:--|:--|:--|
376385
| Reusable skill | `src/skills/lead-qualification.skill.ts` | `defineSkill` — `instructions` + trigger conditions + a toolset where every name resolves; pick a `surface` |
377386
| Knowledge source | `src/knowledge/sales-kb.ts` | `KnowledgeSourceSchema` metadata, registered at boot via `KnowledgeServicePlugin({ sources })` |
378-
| Central registration | `defineStack({ skills: [...] })` | `agents` / `tools` / `skills` are the only AI stack collections — knowledge sources have none, agents are platform-supplied, and `tools` is not the default path |
387+
| Central registration | `defineStack({ skills: [...] })` | `agents` / `tools` / `skills` are the only AI stack collections |
379388

380389
---
381390

@@ -387,8 +396,7 @@ stack-authored agent is filtered out of `listAgents()`, refused outright by
387396
`loadAgent()`, and 404s on chat. `AgentSchema`'s full field list is in
388397
[references/_index.md](./references/_index.md).
389398

390-
The runtime ships **exactly two** agents, bound by *surface* — the user never
391-
picks from a roster, the surface they are in selects the agent. **`ask`** is the
399+
The runtime ships **exactly two** agents, bound by *surface*. **`ask`** is the
392400
data product (≈ Claude Chat): conversational read / query / explore over records
393401
plus running the business actions the app exposes, end-user audience,
394402
RLS-bounded, canonical id `ask` (`ASK_AGENT_NAME`), and the implicit copilot for
@@ -451,8 +459,7 @@ os validate # Zod schema + CEL predicate validation + bindings (no artifact)
451459
# or: os build # the same gates, plus emits dist/
452460
```
453461

454-
It confirms the skill / tool metadata conforms to the protocol. This
455-
domain has no CEL site — a model-registry `promptTemplate.system` / `.user` is
462+
This domain has no CEL site — a model-registry `promptTemplate.system` / `.user` is
456463
the `template` dialect (`{{var}}`); `ToolSchema` carries no expression field of
457464
any kind. In a scaffolded project the gate is `npm run validate`. See
458465
objectstack-platform → **Verify your work**.

‎skills/objectstack-ai/evals/skills-tools-knowledge.json‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{
2525
"id": 3,
2626
"prompt": "Index our `kb_article` records (title and body) so the assistant can answer from them with RAG. Only published articles, and we want to filter by `category` at search time. We run RAGFlow.",
27-
"expected_output": "Emits a `KnowledgeSourceSchema.parse({...})` record with `adapter: 'ragflow'` and `source: { kind: 'object', object: 'kb_article', contentFields: ['title', 'body'], metadataFields: ['category'], where: { published: true } }`, `refresh: { onRecordChange: true }`, registered at boot through `KnowledgeServicePlugin({ sources })`. Chunking / top-K / rerankers are adapter config, not platform metadata.",
27+
"expected_output": "Emits a `KnowledgeSourceSchema.parse({...})` record with `adapter: 'ragflow'` and `source: { kind: 'object', object: 'kb_article', contentFields: ['title', 'body'], metadataFields: ['category'], where: { published: true } }`, `refresh: { onRecordChange: true }`, registered at boot through `KnowledgeServicePlugin({ sources })`. Top-K and rerankers are not source metadata, and no `split` key is written: the RAGFlow adapter receives whole documents, so `split` would have no effect.",
2828
"files": [],
2929
"assertions": {
3030
"must_contain": ["KnowledgeSourceSchema", "contentFields", "metadataFields", "where", "KnowledgeServicePlugin"],
@@ -80,6 +80,16 @@
8080
"must_contain": ["elicitation", "declined", "cancelled", "timed_out", "service_account"],
8181
"must_not_contain": ["recordId, confirm: true"]
8282
}
83+
},
84+
{
85+
"id": 9,
86+
"prompt": "Index our `policy_doc` records (`title`, `body`) for the assistant with the in-memory adapter. Each body is a long Markdown handbook with headings; answers should cite one section, at most 600 characters, and neighbouring passages should overlap by 100 characters.",
87+
"expected_output": "Emits a `KnowledgeSourceSchema.parse({...})` record with `adapter: 'memory'` (the adapter that takes the service's passages) and `source: { kind: 'object', object: 'policy_doc', contentFields: ['title', 'body'], split: { strategy: 'markdown', maxChars: 600 } }`: one section per heading, each passage embedded with its heading path, 600 characters at most unless the embedder's input limit is lower. Declines the overlap: passages never overlap, and the `knowledge.chunk_overlap` setting is retired (a write naming it is refused `400 UNKNOWN_KEY`), so it writes no overlap key and no `chunkSize`.",
88+
"files": [],
89+
"assertions": {
90+
"must_contain": ["split", "strategy", "markdown", "maxChars"],
91+
"must_not_contain": ["chunkSize", "chunkOverlap", "overlap: 100"]
92+
}
8393
}
8494
]
8595
}

0 commit comments

Comments
 (0)