Repository navigation
Commit ed4ec27
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
- .changeset
- scripts
- skills/objectstack-ai
- evals
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
516 | | - | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
517 | 536 | | |
518 | 537 | | |
519 | 538 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
| 261 | + | |
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
309 | 325 | | |
310 | 326 | | |
311 | 327 | | |
| |||
461 | 477 | | |
462 | 478 | | |
463 | 479 | | |
464 | | - | |
| 480 | + | |
465 | 481 | | |
466 | 482 | | |
467 | 483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
156 | 167 | | |
157 | 168 | | |
158 | 169 | | |
0 commit comments