Skip to content

Commit ed4ec27

Browse files
docs(skills): objectstack-ai teaches knowledge sources over business objects (#38292)
Fixes #37976 repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Clause-②: no Metadata-protocol: none ## 维护者速读 - 用 AI 搭应用的作者和他们的 AI 助手,在技能文档「知识源」一节里,原来只看到按制度库配置的写法;现在多了三条针对普通业务对象的规则,各带一个例子:只索引长文本、一类语料一个知识源并在检索时点名、附件文字先写进文本字段。 - 属于「知识检索」这条线:平台是元数据开发平台,知识源不能只按制度库来教。 - 只改技能文档的文字和一条评测用例,不改任何运行行为;写得不对最多是作者按错的建议配置,可以直接撤回。技能文档因此变长 242 个 token(先删了重复,余额按已有裁定实测上调)。 - 无 ## What changes - `skills/objectstack-ai/SKILL.md`, section "Knowledge Sources (RAG)": one new block, "Sources over business objects", placed after the `supportKb` example and before "Splitting". Three rules, one example each: - (a) Long free text only. `content` lists prose (an article body, a ticket's `description`, a note) with its title or subject line. Numbers, dates, statuses and the names of people or accounts stay out; counts and filters go to the record tools. Example: "Which customers reported login loops?" is `search_knowledge`; "how many tickets are open per priority?" is `aggregate_records` (in-app `ask`: `aggregate_data`). - (b) One source per corpus. A skill's `instructions` say which to pass in `sourceIds`, the argument of the one `search_knowledge` tool. Example: `search_knowledge({ query, sourceIds: ['ticket_bodies'] })`. Omitted, every exposed source is scanned. No second shape is taught. - (c) Attachment text goes through a field. A `file` field in `content` adds no file text (the `file` and `http` kinds are retired). Example: write the extracted text to a `textarea` field, `contract.attachment_text`, and list that field. - Duplicates deleted first (ruling record 6513306068, letter B, 「A:先削重复,余额按实测提高」): - the `source.content` row's "Meaningful text only" (rule (a) says it); the row keeps "Never ids or system fields"; - the `agent.knowledge` pitfall row's "describe intended grounding in `instructions`" is now a pointer to rule (b): "name the `sourceIds` to pass in `instructions` (§ Knowledge Sources)"; - the retired-kinds line's "no form in 19" became the pointer "attachment text: below". - `scripts/check-skills-token-ratchet.mjs`: the `skills/objectstack-ai/SKILL.md` row moves 6906 to 7148, the measured remainder, pinned at the measurement, with the arithmetic in the row note. The row's stale trailing comment is removed. - `skills/objectstack-ai/evals/skills-tools-knowledge.json`: case 15 (two corpora, numeric fields, a PDF file field, a count question) covers (a), (b) and (c). - `.changeset/37976-skill-knowledge-sources-beyond-documents.md`: `@objectstack/skills` patch. Lines of the `adapter` row and its ratchet note, which the open pull request 38224 edits, are not touched. Both pull requests move the same ratchet row; the one that lands second merges `main` and re-measures. ### Review round (second commit, c71105c) - M1: case 15's `must_not_contain` now names wrong shapes only: `kind: 'file',` and `kind: 'http',` inside a literal (both quote styles), `contentFields:`, a `content:` list that starts with `priority`, `status`, `amount` or `contract_pdf`, and a list that puts one of those four directly after `'description'`. `metadataFields: ['status', 'priority']`, `groupBy: ['priority']` and a sentence that names the retired kinds all pass. Residual, stated: a `content` list that carries a short field in another position is not caught, and a non-`content` list that puts `priority` directly after `description` would be refused. - N1: rule (a) says a title or subject line belongs, and names "the names of people or accounts" in place of "short names". - N2: "Never ids or system fields" is back on the `content` row; rule (c) no longer restates that no source reads a file. - N3: the `agent.knowledge` row points to `instructions` and the section again. - N4: rule (a) names both spellings, `aggregate_records` and `aggregate_data`. - N5: the stale trailing comment on the ratchet row is gone. ### Token ratchet arithmetic Priced bytes are file bytes minus the 27-byte release-stamp line; tokens are `ceil(priced bytes / 4)`. | Reading | Before (`main` f19350b) | After (head 742647d) | Delta | |:--|--:|--:|--:| | `skills/objectstack-ai/SKILL.md`, lines | 489 | 505 | +16 | | `skills/objectstack-ai/SKILL.md`, bytes | 27648 | 28617 | +969 | | same file, priced bytes | 27621 | 28590 | +969 | | same file, tokens (the ratchet row) | 6906 | 7148 | +242 | | all `skills/*/SKILL.md`, lines | 4940 | 4956 | +16 | | all `skills/*/SKILL.md`, bytes | 262358 | 263327 | +969 | | ratcheted (authored) subtotal, tokens | 199826 | 200068 | +242 | | eval fixtures (measured, not ratcheted), tokens | 88864 | 89389 | +525 | | bundle total (whole shipped tree), tokens | 303542 | 304309 | +767 | Row note arithmetic: the file is 27648 to 28617 bytes, so the landed priced text is 28590 and `ceil(28590 / 4) = 7148`; the row moves +242, headroom 0. The first commit measured 7109; the review's restored clauses and the second tool spelling add 39. ## Tests Readings on head 742647d unless a line says otherwise. 742647d differs from c71105c by the changeset note only (its wording follows the reviewed skill text); the eval ran on c71105c, whose `skills/` tree is identical. - `node scripts/check-skills-token-ratchet.mjs`: exit 0. "skills/objectstack-ai/SKILL.md is 7148 tokens (ceiling 7148; headroom 0)"; "61 authored bundle file(s) within their ceilings". - `node scripts/check-skills-token-ratchet.mjs --self-test`: exit 0, "self-test: 111 cases pass". - `pnpm --filter @objectstack/spec run check:skill-docs`: exit 0, "Skill docs in sync". - `pnpm --filter @objectstack/spec run check:skill-refs`: exit 0, "10 generated files in sync". - `node scripts/check-nul-bytes.mjs`: exit 0. - `pnpm --filter @objectstack/spec run check:skill-examples`: NOT MEASURED on c71105c (exit 3, prerequisite not met: `packages/client-react/dist` is not built in the recreated worktree, and the shared verify lock was held by a full dogfood run through four 9-minute waits). On the first commit, d16dc4b, it exited 0 with "351 prose examples type-check across 3 surface(s)". The second commit changes prose and no marked code block; CI runs the gate. - The other gates of the `dispatch-gates --commands` list were run on d16dc4b and are not re-run on c71105c; CI runs them on the new head. ### Eval case 15, both arms `pnpm --filter @objectstack/scenarios skill-evals --case objectstack-ai/skills-tools-knowledge#15`, on c71105c, 1 repetition per arm, served model `claude-opus-5-5`, Claude Code 2.1.332, OAuth login, runner defaults. | Arm | Verdict | Missed tokens | Forbidden tokens carried | |:--|:--|:--|:--| | with-skill | PASS | none | none | | no-skill | FAIL | `sourceIds`, `content:`, and none of `aggregate_records` / `query_records` / `aggregate_data` | none | Score: with-skill 1/1, no-skill 0/1. - with-skill, key lines: "Listing a `file` field in a knowledge source adds no text from the file, so a hook, flow or import has to extract the PDF's text into a `textarea` field first, and the source indexes that field." It writes `content: ['subject', 'description']` with `metadataFields: ['priority', 'status']`, tells the skill "Always pass sourceIds; never search all sources at once", and sends the count to `aggregate_data`. That answer carries `metadataFields: ['priority', 'status']`, which the first version of the case would have refused. - no-skill, key lines: "Treat the key names (`source`, `chunking`, `metadata`, …) as illustrative". It invents `fields:`, `fileField: 'contract_pdf'` with an `extraction` block, and a `count_open_tickets_by_priority` tool file; it names no `sourceIds`. - Setup: the runner reads its dependencies' `dist/`. The verify lock was busy, so the built `dist/` of the 16 packages in the runner's closure was copied from sibling worktrees whose package sources are byte-identical to this head (`git diff --quiet` per package, clean status); the seventeenth, `refd-timer-testkit`, is source-only. The skill text and the case came from this head. - Records: the seat's scratchpad, `issue-37976/eval-15` (`round.json`, `summary.md`, `runs/` with one JSON per arm). ## Acceptance notes - Facts read on `main` f19350b before writing: `sourceIds` is an argument of `search_knowledge` (`packages/services/service-knowledge/src/knowledge-tools.ts`, its input keys); `source.kind` has the one arm `object` (`packages/spec/src/ai/knowledge-source.zod.ts`); a document's text is each listed field's value joined as a string (`packages/services/service-knowledge/src/knowledge-service.ts`, the record-to-document function), so a number in `content` is indexed as its digits and a `file` field contributes no file text. - `aggregate_records` is registered only where the data bridge implements `aggregate`; the in-app assistant serves `aggregate_data`. Rule (a) names both. - Not measured against a running app: the text is teaching, and no behaviour is claimed beyond the three facts above. ## Verification Read first, by risk: 1. `skills/objectstack-ai/evals/skills-tools-knowledge.json`, case 15's `must_not_contain`: the risk is a token that refuses a correct answer. 2. `skills/objectstack-ai/SKILL.md`, the "Sources over business objects" block: three bullets, each claim listed under Acceptance notes with the file it was read from. 3. `scripts/check-skills-token-ratchet.mjs`, the row note and the value 7148. Two-minute check: `node scripts/check-skills-token-ratchet.mjs` and read its first line. Expected: "skills/objectstack-ai/SKILL.md is 7148 tokens (ceiling 7148; headroom 0)". ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (No schema touched.) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran. `pnpm lint` is left to CI. - [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` 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 by [Claude Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_ <!-- signed: repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent bd46e3d commit ed4ec27

4 files changed

Lines changed: 66 additions & 4 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): `objectstack-ai` teaches knowledge sources over business objects, not only a document library
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`skills/objectstack-ai` § Knowledge Sources (RAG) gains three rules, one example each:
11+
12+
- **Long free text only.** `content` lists prose fields (an article body, a ticket's `description`, a note) with their title or subject line. Numbers, dates, statuses and the names of people or accounts stay out, and counts and filters go to the record tools (`aggregate_records`, or `aggregate_data` in the in-app assistant).
13+
- **One source per corpus.** A skill's `instructions` say which source to pass in `sourceIds`, the argument of `search_knowledge`; omitted, every exposed source is scanned.
14+
- **Attachment text goes through a field.** A `file` field in `content` adds no file text: write the extracted text to a `textarea` field and list that field.
15+
16+
No behaviour changes.

‎scripts/check-skills-token-ratchet.mjs‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,26 @@ export const CEILINGS = new Map([
513513
// ceil(27623 / 4) = 6906; the row moves +13, the measured remainder only.
514514
// Pinned AT the measurement.
515515
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(27623 / 4)
516-
['skills/objectstack-ai/SKILL.md', 6906], // -18 (was 6824), then -5 A2′ (was 6806)
516+
// 6906 -> 7148 (2026-11-28, knowledge sources over business objects): the
517+
// section taught a source for a document library only. It now says three
518+
// things, one example each: `content` lists long free text only (a title or
519+
// subject line with it), and counts and filters go to the record tools,
520+
// named by both spellings (`aggregate_records`, `aggregate_data` in `ask`);
521+
// one source per corpus, a skill's `instructions` naming which to pass in
522+
// `sourceIds`, the argument of `search_knowledge`; attachment text reaches
523+
// an index through a text field. Raise path the standing ruling
524+
// 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). PAID DOWN
525+
// FIRST: the `content` row's "Meaningful text only" (the first rule says
526+
// it; the row keeps "Never ids or system fields"), and the `agent.knowledge`
527+
// pitfall row's "describe intended grounding in `instructions`", now a
528+
// pointer to the second rule; the retired-kinds line's "no form in 19"
529+
// became a pointer to the third rule. Arithmetic in priced bytes (stamp
530+
// line excluded), against `main`'s 27621 (the row's 6906, headroom 0): the
531+
// file is 27648 -> 28617 bytes, so the LANDED priced text is 28590 ->
532+
// ceil(28590 / 4) = 7148; the row moves +242, the measured remainder only.
533+
// Pinned AT the measurement.
534+
// ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(28590 / 4)
535+
['skills/objectstack-ai/SKILL.md', 7148],
517536
// -12 (was 6331): the `http.server` decision-table row dropped a trailing
518537
// clause that taught `contributes.routes` as a key that "parses but serves
519538
// nothing". The key is retired — an authored entry is now REFUSED, carrying

‎skills/objectstack-ai/SKILL.md‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ object or field, when you may not search that object or query a field it reads.
258258
| `adapter` | Optional store id (`pgvector`, `turso`, `memory`). Omitted: the deployment's store (`pgvector` on PostgreSQL, `turso` otherwise), else the only one registered; several and none the deployment's is refused, naming them |
259259
| `source.kind` | `'object'`, the one kind |
260260
| `source.object` | The object whose records are indexed |
261-
| `source.content` | Non-empty list of the fields whose text is indexed, in order. `'*'` is refused: it would also send fields added later. Meaningful text only, never ids or system fields |
261+
| `source.content` | Non-empty list of the fields whose text is indexed, in order. `'*'` is refused: it would also send fields added later. Never ids or system fields |
262262
| `source.metadataFields` | Fields kept for search-time filtering (`status`, `owner_id`, `tags`) |
263263
| `source.where` | ObjectQL `where`: keeps drafts and archived rows out |
264264
| `source.split` | How documents are cut into passages (below) |
@@ -270,7 +270,7 @@ Retired in 19, each refused with its fix: `id` (use `name`), `contentFields`
270270
deployment configures one embedder), `vectorStore` (the store is `adapter`),
271271
`adapterConfig` (an adapter takes plugin options), `refresh.cron` (call
272272
`reindexSource` from a flow or job), and `source.kind: 'file'` / `'http'` with
273-
`prefix`, `mimeTypes`, `urls`, `userAgent` (no form in 19). `os migrate meta
273+
`prefix`, `mimeTypes`, `urls`, `userAgent` (attachment text: below). `os migrate meta
274274
--from 18` lists a stack's edits; edit a registration in code by hand.
275275

276276
`os validate` and publish check each source; an error refuses the publish:
@@ -306,6 +306,22 @@ export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({
306306
});
307307
```
308308

309+
**Sources over business objects**, not only a document library:
310+
311+
- **Long free text only.** `content` lists prose: an article body, a ticket's
312+
`description`, a note, with its title or subject line. Numbers, dates,
313+
statuses and the names of people or accounts stay out; counts and filters
314+
go to the record tools. "Which customers reported login loops?" is
315+
`search_knowledge`; "how many tickets are open per priority?" is
316+
`aggregate_records` (in-app `ask`: `aggregate_data`).
317+
- **One source per corpus**, and a skill's `instructions` say which to pass in
318+
`sourceIds`: `search_knowledge({ query, sourceIds: ['ticket_bodies'] })`
319+
searches the tickets and not `support_kb`. Omitted, every exposed source is
320+
scanned.
321+
- **Attachment text goes through a field.** A `file` field in `content` adds
322+
no file text. Have the flow, hook or import that extracts the text write it
323+
to a `textarea` field (`contract.attachment_text`), and list that field.
324+
309325
**Splitting (`split`).** The knowledge service cuts each document into passages
310326
for a store declaring `capabilities.chunks`; any other store receives whole
311327
documents. `split: { strategy, maxChars?, minChars? }` — `strategy` is required
@@ -461,7 +477,7 @@ https://objectstack.ai/docs/protocol-upgrade:
461477
| Retired key | Removed in 17, tombstone gone in 18 — why, and what replaces it |
462478
|:--|:--|
463479
| `agent.tools` | The inline slot resolved names against the *full* registry with no surface check. Not a rename: the strict schema refuses the key as unknown; re-declare each tool in a `defineSkill` under the stack's `skills` (ADR-0064) |
464-
| `agent.knowledge` | Declaring sources/indexes on an agent never scoped retrieval — `search_knowledge` takes `sourceIds` from the model's tool-call arguments. Restrict on the knowledge source (`aiExposed`, `source.where`); describe intended grounding in `instructions` |
480+
| `agent.knowledge` | Declaring sources/indexes on an agent never scoped retrieval — `search_knowledge` takes `sourceIds` from the model's tool-call arguments. Restrict on the knowledge source (`aiExposed`, `source.where`); name the `sourceIds` to pass in `instructions` (§ Knowledge Sources) |
465481

466482
---
467483

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@
153153
"must_contain_any": [["requires: ['knowledge']", "requires: [\"knowledge\"]"]],
154154
"must_not_contain": ["contentFields:"]
155155
}
156+
},
157+
{
158+
"id": 15,
159+
"prompt": "Our support app has `kb_article` (`title`, `body`) and `support_ticket` (`subject`, `description` as a textarea, `priority`, `status`, `amount`, and a `contract_pdf` file field holding a signed PDF). The assistant should answer from article bodies, from ticket descriptions and from what the PDFs say, and also tell us how many open tickets there are per priority. Design the knowledge sources and say how a skill should search them. None of the project's files are in this directory: write the files in your answer.",
160+
"expected_output": "Writes two `knowledge_source` items, one per corpus (articles, tickets), each `source: { kind: 'object', … }` with an explicit `content` list of long free-text fields only: `title` / `body` for articles, `subject` / `description` for tickets. `priority`, `status` and `amount` are not in `content` (at most `metadataFields`), and the count of open tickets per priority is answered by a record tool (`aggregate_records` / `query_records`), not by `search_knowledge`. The PDF is not indexed from the `contract_pdf` file field and no `kind: 'file'` or `'http'` source is written (both retired): the extracted text is first written to a text field on the record (a `textarea`, filled by a flow, hook or import) and that field is listed in `content`. The skill's `instructions` tell the model which source to search by passing `sourceIds` to `search_knowledge`, so a question does not scan every source; no second argument shape and no `knowledge` key on the skill is invented.",
161+
"files": [],
162+
"assertions": {
163+
"must_contain": ["sourceIds", "content:", "textarea"],
164+
"must_contain_any": [["aggregate_records", "query_records", "aggregate_data"]],
165+
"must_not_contain": ["kind: 'file',", "kind: \"file\",", "kind: 'http',", "kind: \"http\",", "contentFields:", "content: ['priority'", "content: ['status'", "content: ['amount'", "content: ['contract_pdf'", "'description', 'priority'", "'description', 'status'", "'description', 'amount'", "'description', 'contract_pdf'"]
166+
}
156167
}
157168
]
158169
}

0 commit comments

Comments
 (0)