Skip to content

docs(skills): objectstack-ai teaches knowledge_source as metadata; knowledge_source gets a create seed - #38053

Draft
objectstack-fleet[bot] wants to merge 6 commits into
mainfrom
claude/area-o1C-37310
Draft

objectstack-fleet[bot] wants to merge 6 commits into
mainfrom
claude/area-o1C-37310

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP

Fixes #37310

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:用 AI(技能文档或 MCP 搭建)写知识源的作者,现在看到的是新写法:知识源是一份元数据,用 name、逐个列出要索引的字段、可以不写存储;MCP 新建知识源时直接拿到一份能通过校验的起始模板。
  • 为什么做:知识库检索专题(按调用者权限过滤的知识检索)第三阶段的教学一行,替照着技能写知识源的 AI 解决"照文档写出来却被拒绝"的问题。
  • 出错会怎样:最坏是技能里某句教法不准,AI 写出的知识源在保存时被明确拒绝并给出修法;不会悄悄索引错的字段;改动可直接撤回。
  • 要你做什么:合并(技能文档是受治理面,由你亲手落地);另有一小段(发布校验的五条规则名)等对应的校验改动合并后在本分支补上。

What changes

skills/objectstack-ai/SKILL.md, § Knowledge Sources (RAG) (ADR-0161 K4, K5, K6 item 6; rows 3a and 3b as merged):

  • A source is a knowledge_source item: shipped in a package (knowledgeSources, *.knowledge-source.ts / .yml) or authored in Studio or over MCP. KnowledgeServicePlugin({ sources }) and registerSource are a second door for the same schema, and one name is one source (K4 point 3). An item mounts the knowledge service and its store with no requires: ['knowledge'] (knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306, PR feat(knowledge): a knowledge source needs no adapter and no requires entry; it binds to the deployment's store #38026).
  • The key table is the v1 keys of K4: name, label / description, adapter (optional; omitted ⇒ the deployment's store, else the only one registered, refused naming them when several and none is the deployment's), source.kind, source.object, source.content (an explicit non-empty list; why '*' is refused: embedding is egress, K5), source.metadataFields, source.where, source.split, refresh.onRecordChange, aiExposed. The old Hygiene column's advice (meaningful text only, never ids or system fields; where keeps drafts out) now lives in the content and where rows, and says content.
  • Egress and cost (K4): the first build sends every listed field of every matching record to the embedding provider; a run-time save needs manage_knowledge_sources beside manage_metadata and passes save-time admission.
  • The retired keys by name, each with its fix, as the tombstones read: id → name, contentFields → content, embedding, vectorStore, adapterConfig, refresh.cron, and the file / http arms with their four keys; os migrate meta --from 18 for a stack, by hand for a registration in code.
  • The checked example drops adapter: 'pgvector' (the deployment's store) and its comments; it is otherwise row 3a's block.
  • split: strategy is required once split is written (recursive only when split is omitted); the adapter-list aside is gone.
  • The closing note: topK is a search_knowledge argument; rerank and hybrid weights are options of the store's plugin.
  • The routing line in skills/objectstack-mcp-build/SKILL.md ("An agent skill, tool or knowledge source | objectstack-ai") stays true: the section name is unchanged, so it is not edited.

Not in this PR, on purpose (amendments 7221575164 and 7224082428): the five os validate / publish rule ids of PR #37971 (knowledge-source-object-unknown, knowledge-source-field-unknown, knowledge-source-object-not-searchable, knowledge-source-system-object-not-ai-readable, knowledge-source-field-never-indexed). #37971 is still open, so that part follows on this branch after it lands; the PR stays draft until then.

skills/objectstack-ai/evals/skills-tools-knowledge.json. Case 3 (kb_article on PostgreSQL) and case 9 (policy_doc, markdown split) now expect name and content, and forbid a written contentFields: key; case 3 also forbids a written wildcard (['*'],, ['*'] }), embedding: and vectorStore:, and its topK token becomes topK: (the key written) because the skill now names topK as a search argument. New case 13 asks for a source that indexes "every text field" and expects an explicit list, the wildcard declined because embedding is egress, and no written contentFields: or wildcard.

packages/spec/src/kernel/metadata-create-seeds.ts. A knowledge_source create seed: { name: 'new_knowledge_source', label: 'New Knowledge Source', source: { kind: 'object', object: 'example_object', content: ['example_field'] } }, no adapter. K5 makes content non-empty, so the seed carries a placeholder field name, like the placeholder object every seed here carries. knowledge_source leaves KNOWN_UNSEEDED; a new pin asserts the seed's list is explicit, names no adapter, and that the same seed with ['*'] is refused.

packages/runtime/src/domains/mcp-authoring.test.ts. One case beside the flow contract case, over the real protocol and the boot type registry: list_metadata_items with contract: true for knowledge_source answers the seed getMetadataCreateSeed gives; contractPath /properties/source/properties/content serves the content rule (minItems: 1, minLength: 1, a pattern that refuses * and admits body); the served schema carries no id or contentFields tombstone; the seed with one object and one field filled saves as a draft; the same item with content: ['*'], with an id, or with contentFields is refused 422 INVALID_METADATA, the last two naming their tombstone's prescription ("use name", "use content"); nothing else is written.

Token ratchet. The standing ruling, verbatim and untranslated: 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). Paid down first, in the same file: the wiring paragraph's package list, the old source.kind Hygiene column (folded into two rows), the example's four comments restating table rows and its refresh: { onRecordChange: true } line restating the default, and the split passage's adapter aside. The row moves 6609 → 6639, the measured remainder, pinned at the measurement.

Tests

The lock was saturated: about 70 minutes of queueing, two dogfood runs ahead. One locked round ran at 3407f7fe6e; the second round was not reached. What was not measured locally is marked below, and CI runs it.

Locked round at 3407f7f (VERDICT command-exit 0, held 365s)
  • pnpm turbo run build --filter='@objectstack/runtime^...' --concurrency=2: exit 0, Tasks: 41 successful, 41 total.
  • pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/kernel/metadata-create-seeds.test.ts: exit 0, Tests 20 passed (20). The knowledge_source seed is spec-valid, and the new pin passes.
  • pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/mcp-authoring.test.ts: exit 1, Tests 1 failed | 73 passed (74). The failing assertion is the new case's tombstone half: it expected the served schema to carry /properties/id, and the served schema drops tombstones (see Acceptance notes). Its content-rule and seed assertions, which run before it, passed. The tombstone half is rewritten in 01cf7515c2 to assert absence plus the save refusal. NOT MEASURED locally after that rewrite (the second locked round never acquired); CI Test Core runs it.
  • pnpm --filter @objectstack/spec run check:yaml-examples: exit 0, 19 tagged YAML example(s) across 1 file(s) validate.
  • 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 with packages/spec. The generated skill references needed no regeneration: the section rewrite changes no reference input.
  • pnpm --filter @objectstack/spec typecheck: exit 0.
  • pnpm --filter @objectstack/runtime typecheck: exit 1. tsc --noEmit is clean. check:test-typecheck names 3 files this diff does not touch (boolean-written-spelling-row-scope.test.ts, meta-object-publish-column-changes.test.ts, organization-ownership-boot-guard.turso-remote.kernel.test.ts). mcp-authoring.test.ts is not among them. They are read here as the closure build's gaps (only runtime^... was built) and not as this diff's; CI TypeScript Type Check decides.
  • pnpm --filter @objectstack/spec run check:skill-examples: exit 3, PREREQUISITE NOT MET (the @objectstack/client-react dist is outside the built closure). NOT MEASURED; CI runs it.
Unlocked gates (35 derived families, each exit 0, at 3407f7f; the ratchet and nul-bytes re-run at 19f3e11)
  • node scripts/check-skills-token-ratchet.mjs: exit 0, skills/objectstack-ai/SKILL.md is 6639 tokens (ceiling 6639; headroom 0); with --self-test exit 0.
  • Exit 0 each: check-adr-0087-registration (both forms), check-changeset-no-major, check-closing-keyword-parity (both), check-declaration-mirrors (both), check-empty-changeset (both), check-issue-citations, check-self-test-wired (both), docs-audit/check-affected-docs, docs-audit/check-drift-comment, and pnpm check: agent-test-spelling, changeset-gate-self-tests, closed-ceremony-text, corpus-claim-drift, cross-package-test-inputs, doc-authoring, issue-citations, keyed-text-bounds, nul-bytes, pm-skill-id-lint, published-files, ratchet-remedy-authority, role-word, skill-compatibility, skill-frame-sync, skill-identifier-liveness, skill-links, test-source-alias, tier-file-adoption.
  • dispatch-gates --ran: 116 derived, 38 run, 0 NOT-MEASURED, 78 UNRUN. That is a declared narrowing: the lock was saturated, and CI runs the 78.
  • Local-only: check-skill-frame-freshness exit 0. check-dev-prereqs exit 1 ("69 of 110 workspace packages … not on disk"), which is the closure-only build and not a finding.
Eval runner and the ablation (`skill-evals`, claude-code-cli 2.1.332, oauth login, served claude-opus-5-5)

Cases 3, 9 and 13 of objectstack-ai/skills-tools-knowledge, both arms, one repeat each:

skill text #3 with-skill #9 with-skill #13 with-skill no-skill (all three)
this PR pass pass pass fail
main's SKILL.md (8d34c4404f, hash 88a20cb583), new cases (ablation) fail: contentFields: written; name:, content: missing fail: contentFields: written; content: missing fail: contentFields:, ['*'], and id: 'faq written; no egress reason fail

The ablation restored main's SKILL.md into the working tree only (git restore --source=8d34c4404f, git hash-object = 88a20cb583). The run ran, and then HEAD's file came back (fc845724ac both on disk and at HEAD). An earlier run of case 13 on this text failed with-skill only on the token ['*'], which a correct answer quoted while explaining the refusal. The forbidden token is now the written wildcard (['*'], / ['*'] }), and the table above is after that change.

Acceptance notes

Verification

Files to read first, by risk:

  1. skills/objectstack-ai/SKILL.md § Knowledge Sources (RAG): the adapter and content rows and the retired-keys paragraph.
  2. packages/spec/src/kernel/metadata-create-seeds.ts: the knowledge_source seed.
  3. packages/runtime/src/domains/mcp-authoring.test.ts: the new contract case.

Two-minute check: node scripts/check-skills-token-ratchet.mjs. Expect skills/objectstack-ai/SKILL.md is 6639 tokens (ceiling 6639; headroom 0).

Readings: skills/objectstack-ai/SKILL.md 464 → 469 lines, 26462 → 26581 bytes (6609 → 6639 priced tokens). Every published SKILL.md summed: 4936 → 4941 lines, 261366 → 261485 bytes (65342 → 65372 tokens). The eval file is 125 → 137 lines and 13611 → 15185 bytes; eval fixtures are measured, not ratcheted.


Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 0 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 5f48cb06ad6d93ab21fc5541e61cdc12111bace2 → packageMentionDocs.

This branch has not been deployed

No deployments
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 size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants