Repository navigation
docs(skills): objectstack-ai teaches knowledge_source as metadata (shipped vs run-time mount, package-scoped identity) - #38053
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
… changeset Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…h the save, not the served schema Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
… a mention of it Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
📓 Docs Drift CheckNothing 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): |
…ds its source Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Patch round at 2026-11-27T22:50Z, head Cause. The Fix: the seed is withdrawn, not the expectation. PR body is now stale in the paragraphs on the Readings at |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 Contract-review-claim: session_016WV4czzx9dtSEm3jWWL9c3 · 4c965f4 · 2026-11-27T22:58Z |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 Contract reviewServed-tier: Read: card #37310 (body and all six comments), PR #38053 (body, file list, both comments), the net diff against merge base ① Derived judgments
② Semver level
Clause-②: no. Right: the diff narrows nothing an author could write; the refusals the skill now names landed with #37304 and #37306 and their own changesets. ③ Boundary flags
④ Design judgmentEvery sentence of the rewritten section was read against skills/objectstack-ai/SKILL.md What holds, checked key by key: M1 (must-fix) — "An item mounts the knowledge service and its store with no S1 (should-fix) — the S2 (should-fix) — "rerank and hybrid weights are options of the store's plugin" names options no shipped store has. Nits:
skills/objectstack-ai/evals/skills-tools-knowledge.json The file is well formed for the runner ( Nits:
scripts/check-skills-token-ratchet.mjs (implementing file) The row and its comment agree with the gate's contract sentence by sentence: deletion in the same file is shown, the ruling and record are named, the move is the measured remainder and is pinned at the measurement, and the reproduction line in the comment gives 6639. The comment's phrase "the item that mounts the service" inherits M1's wording and should follow its fix. The fixes for M1, S1 and S2 add text, so the row moves again in the delta under the same path. Not reviewed (lane seat's ACCEPT at Implemented-by: VERDICT: FAIL |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 L1 verdict (L1-a): REWORK at head Review summaryContract review. Record 7229853573 is FAIL at the contract tier ( Must fix in the next head:
Landing keyword. Also, without moving the contract:
What holds:
The three fixes add text, so the ratchet row moves again in the delta. Next: fix M1, S1 and S2, then a delta L2 (same reviewer) and a delta L1, then the seat for Tier H. |
…me one needs requires; a source is identified by package and name The section said any item mounts the knowledge service. Only a source the stack ships in knowledgeSources does (stackItemCapabilities, mountedBy); an app that ships none and authors sources at run time needs requires: ['knowledge']. The platform catalog's Boot cell now says so for a provider an item also mounts, and the skill ref is regenerated. A source's identity is its package and name, and search_knowledge lists a package's source as NAMESPACE-NAME. The closing note no longer says the store plugins carry rerank or hybrid-weight options: no shipped store has either setting. A new eval case asks for a run-time-authored source. The token ratchet row moves 6639 -> 6695 by the measured remainder after the duplicates were paid down. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Review round at 2026-11-28T00:06Z, head M1: which items mount the service. The section no longer says that any item mounts the knowledge service. It now says that a shipped item (a S1: identity. A source is identified by its package and S2: the closing note. It no longer says that rerank and hybrid weights are store-plugin options. It now reads: "Rerank and hybrid weighting are no source key, and no shipped store has a setting for either." Evidence: Token ratchet. The Readings at
|
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 Contract-review-claim: session_016WV4czzx9dtSEm3jWWL9c3 · 6f2e756 · 2026-11-28T00:11Z |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 Contract reviewServed-tier: Delta of record 7229853573 (head M1 (must-fix): closed S1 (should-fix): closed S2 (should-fix): closed ① Derived judgments
② Semver level
Clause-②: no. Right, as before. ③ Boundary flags
④ Design judgmentRead against the live code at merge base skills/objectstack-ai/SKILL.md
skills/objectstack-ai/evals/skills-tools-knowledge.json N3 and N4 are taken: cases 3 and 13 now also forbid the double-quoted wildcard, case 13 the double-quoted skills/objectstack-project/references/platform-catalog.md, with its generator and pin The one changed row reads "on scripts/check-skills-token-ratchet.mjs The second comment block agrees with the gate's contract: what was added, what was deleted first, the ruling and record, the byte arithmetic and the reproduction line, which gives 6695. Nits, none of which moves correctness or the contract:
Not reviewed (lane seat's ACCEPT at No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 L1 verdict (L1-a): ACCEPT at head Review summaryContract review. I adopt delta record 7230755130 at this head. It is PASS at the contract tier, and
The rest of the delta holds.
Landing keyword. Gates.
Nits, optional:
Next: this PR touches |
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwoXEE1amuRAGHdPBs Seat record · 2026-11-28T00:16Z · PR #38053 (Part of #37310) · head 维护者速读
Seat opinion: land. 席位核对 — ACCEPT · repo:objectstack#1 · head
|
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwoXEE1amuRAGHdPBs Approval request · governed @os-zhuang:
Every check is green or expected-skip. An APPROVED review on this head lets seat repo:objectstack#1 ready and land it; nothing else is asked. |
…t that mounts the knowledge service (objectstack-ai#38013) repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Fixes objectstack-ai#37983 Clause-②: no (narrowing) Metadata-protocol: narrowed Skills-docs: skills/objectstack-ai/SKILL.md § Knowledge Sources (RAG) — the run-time clause now says that where an app ships no source, a run-time save is refused (`503 SERVICE_UNAVAILABLE`, nothing written) until the stack declares `requires: ['knowledge']` and the server restarts (it said such items are never indexed); the matching eval case in `skills/objectstack-ai/evals/skills-tools-knowledge.json` expects the same; the token-ratchet row moves 6893 → 6906 under ruling record 6513306068, letter B ## 维护者速读 - 作者在没装知识服务的部署上,通过工作台、元数据接口或智能体工具保存知识源时,会当场失败并看到原因和修法(先在应用配置里声明需要知识服务并重启,再保存);以前这种保存显示成功却永远不生效。 - 属于知识库检索这条线,执行您选的方案 D:让作者在保存那一刻就知道,而不是只在看不到的服务器日志里。 - 只影响在这类部署上保存知识源的作者;在这类部署上复制一个含知识源的整个应用包也会被拒、什么都不复制(这是裁决点名的三处之外的第四处,请批准前读下方的待定问题一节);装包、种子数据、迁移照常通过;出问题可整单撤回。 - 要你做的:批准这次收窄(按审批流程)。 ## What changes Ruling D (maintainer, recorded on objectstack-ai#37983, comment 7220511579) is implemented in the one predicate every save door asks, `authoredKnowledgeSourceRefusal` (`packages/metadata-core/src/knowledge-source-save-admission.ts`): - **No knowledge service registered + a non-system writer ⇒ refused.** `resolveKnowledgeService()` answering `undefined` (or `null`) used to admit the save; it now answers `503 SERVICE_UNAVAILABLE` with a message that names the item, the reason and the remedy in order: add `requires: ['knowledge']` to the stack (or, on a host that composes its own kernel, `KnowledgeServicePlugin` and a knowledge store), restart, then save the source again. Nothing is written. - **Held as ruled:** the engine's own write (`isSystem`: package install, seed, migration) is never refused (the `isSystem` check still runs before the service is resolved); a REGISTERED knowledge service with no `admitAuthoredSource` (not the platform's, for example host-mounted) keeps today's accept. The module doc (`:33-34` on main) now says both, and gains a section on the no-service case. - **Doors.** No door code changed shape: `PUT /meta/:type/:name` in `packages/rest` passes `refused.code` through for a non-403 (`SERVICE_UNAVAILABLE`), the runtime dispatcher `PUT` derives `SERVICE_UNAVAILABLE` from `503`, and the MCP `save_metadata_draft` passes `refused.code` through for a non-403 (on `main` since objectstack-ai#37306). Only their comments are updated. Each door is pinned. - **Why `503 SERVICE_UNAVAILABLE`** (ADR-0112 status table, `STATUS_TO_STANDARD_CODE` in `packages/spec/src/api/errors.zod.ts`): the save needs a service this deployment does not run. It is the code this module already answers for a knowledge service that cannot be reached, and the code the knowledge service answers at index and search for a source whose store is not mounted (the same kind of composition fact). It is also the one code all three doors already carry without a door change. Rejected: `400 VALIDATION_ERROR` (the item is valid; a validation code sends the author to fix the item), `403` (not a permission), `501 NOT_IMPLEMENTED` (the meta door's answer for a protocol with no `saveMetaItem`), `409 RESOURCE_CONFLICT` and `428 PRECONDITION_REQUIRED` (no conflicting resource, no missing request precondition), and a new ledger code (a contract change the ruling did not make). The message carries the remedy and does not say "try again". - **ADR-0087:** `Metadata-protocol: narrowed` owes a registered entry: `packages/spec/src/migrations/entries/semantic/19.knowledge-source-save-refused-without-knowledge-service.ts` (notice only, no D2 conversion: the fix is the deployment's composition, never the item). The changeset carries `registered` with that id. ## Boot line and docs (ruling items 2 and 4), landed after objectstack-ai#37306 Held off this branch until objectstack-ai#37306 merged (PR objectstack-ai#38026, dbe0716); `main` is now merged in (1ca3a31) and the held commit is re-applied as 33acf12. - **Boot line** (`packages/objectql/src/knowledge-source-unserved.ts`): the line for `knowledge_source` items held with no knowledge service now names the same remedy as the save refusal, from the item-4 patch's `UNSERVED_REMEDY`: declare `requires: ['knowledge']` and restart (or, on a host that composes its own kernel, `KnowledgeServicePlugin` and a knowledge store). Before, it said "add `KnowledgeServicePlugin` and a knowledge adapter to the composition". Only the boot-line half of that patch was taken: objectstack-ai#37306 did not touch this file, so `main` still carried the old text. - **What objectstack-ai#37306 changed, and what that changes here.** A source the app ships in `knowledgeSources` now mounts the service by itself, and `adapter` is optional. So a source saved at run time (Studio, the metadata API, MCP) is never one that mounts the service, and the remedy the maintainer ruled (`requires: ['knowledge']`, restart, then save) is still the one that fixes such a save. The refusal sentence is unchanged. The docs now also say that a source saved at run time does not mount the service. The boot-line module doc says that the items it names are ones the stack does not ship. Main's `knowledge-rag.mdx` already said "the token is for an app that ships none and authors its sources at run time", which matches. - **Docs.** `content/docs/ai/knowledge-rag.mdx`: a bullet beside "Without a source or the token", plus a clause on the run-time-authoring bullet. `content/docs/protocol/knowledge.mdx`: the boot-line paragraph names the remedy (it named the plugin and an adapter), and a paragraph under "Who may author one" covers the refusal, the duplicate and the holds. Rewritten against main's merged text, not patched blindly: `git am --3way` conflicted on `knowledge-rag.mdx`. - **Changeset:** gains the `@objectstack/objectql` and `@objectstack/skills` patch lines and their bullets. - The MCP draft door on `main` now passes `refused.code` through for a non-403 (objectstack-ai#37306), so this refusal still arrives there as `SERVICE_UNAVAILABLE`. ## Open question The package **duplicate** door (`POST /packages/:id/duplicate`) asks the same predicate for each knowledge source it copies, so on a deployment with no knowledge service it now refuses a duplicate of a package that holds one, `503`, naming the remedy (pinned in `packages-knowledge-source-gate.test.ts`). The ruling names three doors; this is the fourth door that saves a source as the caller. Keeping it refused is the predicate's own reading and the ruling's principle (the copy would be kept and never served); carving it out needs a new input on an exported function. Recommendation: keep it. ## Tests - `packages/metadata-core/src/knowledge-source-save-admission.test.ts`: refusal with code, status, the reason sentence and the ordered remedy, for both URL spellings and for `undefined`/`null`; an unnamed item; `isSystem` not refused and the service never resolved; a registered service without the member still admits. - REST `PUT` (`packages/rest/src/meta-write-door-capability-enumeration.test.ts`): refused on the kernel's branded "never registered" miss and on a server with no kernel provider; system write saved; host-mounted service saved. - Runtime dispatcher `PUT` (`packages/runtime/src/domains/meta-save-capability-gate.test.ts`): refused on a real `ObjectKernel` with nothing registered; system write saved; host-mounted service saved. - MCP `save_metadata_draft` (`packages/runtime/src/domains/mcp-authoring.test.ts`): refused, nothing written, another type still saves; host-mounted service saved. - Package duplicate (`packages/runtime/src/domains/packages-knowledge-source-gate.test.ts`): refused, nothing copied; a package with no source and the engine's own call copy as before. - Boot line (`packages/objectql/src/knowledge-source-unserved.test.ts`): names `Declare requires: ['knowledge'] in the stack and restart`. Head is now `5bc3ee1a00`. Since `33acf12ec4` it adds only: the test-harness fix `6e4a904ea1` (the MCP `knowledge_source` contract case from objectstack-ai#38053 mounts an admitting knowledge service; comment 7232197442), the skills text, eval expectation, ratchet row and changeset line above, the module-doc wording at index and search, and two clean merges of `main` (the second carries objectstack-ai#38091). No runtime or rest code moved after `33acf12ec4`, so the dogfood battery below stands. On `5bc3ee1a00`: the skills token ratchet exits 0 (6906, headroom 0; self-test 111 cases pass), `check:skill-docs` and `check:skill-refs` exit 0, and the changeset, ADR-0087, NUL-byte and issue-citation gates exit 0. After the harness fix, runtime reads 12315 passed, 0 failed. Readings at head `33acf12ec4` (main merged in; shared container; every build and test through `scripts/pm/os-verify-lock.sh`, verdict `command-exit 0` each round): <details><summary>Tests and typecheck at 33acf12</summary> - Full build (`turbo run build`, all but docs) exit 0, `packages/runtime/.objectstack` cleared, `@objectstack/spec check:generated` exit 0. - `@objectstack/metadata-core` `pnpm test`: Tests 1113 passed; `typecheck` exit 0. - `@objectstack/objectql` `knowledge-source-unserved.test.ts`: Tests 7 passed; `typecheck` exit 0. - `@objectstack/rest`, 4 files (door enumeration, type-write capability, both org-scope suites): Tests 161 passed; `typecheck` exit 0. - `@objectstack/runtime`, 10 files (dispatcher save gate, MCP authoring, package knowledge gate, error passthrough, capability parity, org scope, ensure-customization, publish-drafts x2, package state store): Tests 304 passed; `typecheck` exit 0. - On the first head, 5 suites that save a `knowledge_source` as a capable author with no knowledge service went red: that is the ruled refusal. Their harnesses now mount a knowledge service that admits every source. Two door-level `isSystem` cases were dropped because inbound HTTP never carries `isSystem` (`metaTypeWriteRefusal` answers 401 first); that hold is tested at the predicate instead. - Narrowed locally: the full rest and runtime suites, `test:repo`, and the derived families not listed under Gates run in CI. </details> <details><summary>Ablations (one per tested behaviour)</summary> - **The save refusal** (at dd50936): `scripts/ablation-replace.mjs` replaced the one new line (anchor 1 -> 0, marker 0 -> 1). `@objectstack/metadata-core` was rebuilt, and `ablation-dist-preflight` found the marker in `dist/index.js` and `dist/index.cjs`. Exactly these went red: the predicate test (1 of 9), REST `PUT` (1 of 81), and dispatcher `PUT`, MCP draft save and package duplicate (3 of 162). Restored with `git checkout HEAD` (blob back to cd26e8f, `git diff HEAD` empty), rebuilt, and preflight `--absent` was clean. - **The boot line** (at 33acf12): the remedy was put back to main's text (anchor 1 -> 0, marker 0 -> 1; the test imports source, so no build was needed). Red: `names the item, the missing service and both remedies` (1 of 7). Restored with `git checkout HEAD` (blob aa50e2e, `git diff HEAD` empty). - The docs pages are not ablated. </details> <details><summary>Live server (REST door, at dd50936)</summary> After a full build I ran `pnpm dev:crm -- --fresh -p 38937`; the CRM stack declares `requires: ['ui', 'automation']` and no knowledge. Signed in as the seeded admin, `PUT /api/v1/meta/knowledge_source/faq` answered `503`, `error.code` `SERVICE_UNAVAILABLE`, with the remedy sentence. A `GET` of the item then answered `404`, so nothing was written. The server was stopped by its recorded pid. A positive control on a stack with `requires: ['knowledge']` was not run (NOT MEASURED); the unit tests cover the admitted path. </details> <details><summary>Gates at 33acf12</summary> Local, exit 0 each: `check-adr-0087-registration` (1 declared-breaking changeset, with its disposition), `check-changeset-no-major`, `check-empty-changeset`, spec `check:upgrade-guide`, `check:spec-changes`, `check:api-surface` (unchanged), `check:nul-bytes`, `check:doc-authoring`, `check-affected-docs`, `check:issue-citations`, `check:dispatcher-error-vocabulary`, `check:startup-registry-verdict`, `check:durability-log-level`. At dd50936 these were also exit 0: `check:authorable-surface`, `check:route-envelope`, `check:error-status-conformance`, `check-closing-keyword-parity`, `check:cross-package-test-inputs`, `check:test-source-alias`, `check:adr-anchors`. `overlap-check` before the push: clean against `main` and against objectstack-ai#38043, objectstack-ai#37982 and objectstack-ai#37963. </details> <details><summary>Dogfood battery at 33acf12</summary> The full battery, run as CI runs it (no `OS_TEST_SHARD`, no path), under `scripts/pm/os-verify-lock.sh`. The build was `turbo run build --filter='@objectstack/dogfood^...'` and exited 0. The test was `pnpm --filter @objectstack/dogfood test`. - Verdict: `VERDICT command-exit 0 · held the lock 1727s (28m47s)`, in shared-box seconds. - `Test Files 490 passed | 3 skipped (493)` - `Tests 4144 passed | 68 skipped (4212)` - Failures: none. Recorded in comment 7229739676. CI's `Dogfood Regression Gate` on the PR reads `OS_DOGFOOD_RESULT: skipped` (the shards run in the merge queue), so it is not evidence for this head. </details> ## Acceptance notes - The note on this PR's first head about objectstack-ai#37306's `400 VALIDATION_ERROR` arriving at the MCP draft door as `SERVICE_UNAVAILABLE` is obsolete: objectstack-ai#37306 merged with the MCP door passing `refused.code` through. - Docs Drift Check (comment 7222797378) is receipted here. `content/docs/ai/knowledge-rag.mdx` and `content/docs/protocol/knowledge.mdx` are updated on this branch. `content/docs/permissions/system-context.mdx` row 46 is re-read and still true: the refusal is not on the `isSystem` path. The other pages match on the `SERVICE_UNAVAILABLE` literal only and say nothing about knowledge sources. The release-owned pages are not edited. - Contract review 7228262724 (PASS) and L1 7228292666 (REWORK: dogfood battery only) are receipted here. The battery is recorded in comment 7229739676: green, and the head is unchanged. The review's nits N1 to N5 are left for a follow-up card; none of them is changed on this head. ## Verification Read first (by risk): `packages/metadata-core/src/knowledge-source-save-admission.ts` (the `service === undefined || null` branch, before the member check), `packages/runtime/src/domains/packages-knowledge-source-gate.test.ts` (the fourth door), `content/docs/protocol/knowledge.mdx` (the two paragraphs rewritten against objectstack-ai#37306's text). Two-minute check: `pnpm --filter @objectstack/metadata-core exec vitest run src/knowledge-source-save-admission.test.ts` — expect the "no knowledge service registered" cases green; flip line `if (service === undefined || service === null) return noKnowledgeServiceRefusal(input.item);` out and they go red. Body refreshed 2026-11-28T03:15Z at head `5bc3ee1a00`; the readings in the three blocks above were taken at `33acf12ec4`. --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
…r the running deployment does not mount (objectstack-ai#38060) repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Fixes objectstack-ai#37961 Clause-②: no (narrowing) Metadata-protocol: narrowed Skills-docs: follow-up objectstack-ai#38158 — `skills/objectstack-ai/SKILL.md` § Knowledge Sources (its `adapter` row, added on `main` by objectstack-ai#38053) does not yet name this PR's save refusal of an unmounted adapter; objectstack-ai#38158 teaches it there. `content/docs/ai/knowledge-rag.mdx` and `content/docs/protocol/knowledge.mdx` name the refusal here ## 维护者速读 - 用户能看到什么变化:在 Studio、通过接口或用 AI(MCP)保存知识源时,如果写了本部署没装的存储(例如已退役的 ragflow 或拼错),保存会当场被拒,错误里写明知识源、写的存储名和本部署已装的存储;不写存储、或写已装的存储,照常保存。 - 为什么做:知识库检索专题(按调用者权限过滤的知识检索)的收尾一项,替写知识源的作者和 AI 解决“写错存储要到启动日志或检索报错时才发现”。 - 出错会怎样:最坏是某个本该能保存的知识源被拒;改动只在保存这一处,可直接撤回。包安装、代码注册和离线校验不经过这一检查,仍由启动日志和检索报错兜底。 - 要你做什么:无(这是收窄,按惯例走契约审核)。 ## What changes - **The check** (`packages/services/service-knowledge/src/knowledge-service.ts`, `admitAuthoredSource`): a `knowledge_source` item whose `adapter` is a string naming no adapter the running deployment has registered is refused `400 VALIDATION_ERROR`. The message names the source, the adapter and the mounted adapters, as a rule and its remedy: "it names adapter 'ragflow', which this deployment does not mount (mounted: memory), and a source's `adapter` must name a mounted store. Name one of 'memory' as its `adapter`, or leave `adapter` out, and the deployment's store holds it, or mount the 'ragflow' store and save it again." Leaving `adapter` out is offered only where an omitted adapter would be placed (the deployment's store is mounted, or one adapter is). The hunk sits beside the existing unplaced-source check (several adapters, none the deployment's), the other "which store holds it" refusal, and reads the registry at request time, after every store's `start()`: nothing is recorded. - **Not refused:** an omitted `adapter` (legal since the deployment's-store change; it is placed by `adapterIdFor`); a named adapter that is mounted. - **Doors reached:** every caller of `authoredKnowledgeSourceRefusal` (`@objectstack/metadata-core`), unchanged: `PUT /meta/knowledge_source/:name` on both transports, the MCP `save_metadata_draft` tool, and the package duplicate (`refuseDuplicatedKnowledgeSources`), which judges each source it copies for the caller and now refuses a copy whose source names an unmounted adapter, as it already refused an unplaced one. - **Not covered by this door, said in the docs and the changeset:** a package install and any other engine write (`isSystem`, skipped by `authoredKnowledgeSourceRefusal` before the knowledge service is asked); a source registered in code (`registerSource`, `KnowledgeServicePlugin({ sources })`), which registers at `init()` before its store's `start()`, so "not mounted yet" is no verdict there; `objectstack validate`, which runs with no deployment. For those, `reportUnmountedAdapters` at boot (`error`) and the `503 SERVICE_UNAVAILABLE` at index and search stay the signal. - **How the refusals at this door order:** with no knowledge service mounted, the door never reaches `admitAuthoredSource`, so the no-service refusal that objectstack-ai#38013 adds (`503`) comes before this one (`400`). Inside `admitAuthoredSource`: no identity (`403`), then the unplaced source (`400`), then this check (`400`), then no data engine (`503`), then the exposure and field gates (`403`/`503`). The code is the existing `VALIDATION_ERROR`, the sibling unplaced refusal's code: no new error code. - **Docs:** `content/docs/ai/knowledge-rag.mdx` (the not-mounted bullet) and `content/docs/protocol/knowledge.mdx` (the "Named" binding rule and guard two, source admission at save). - **ADR-0087:** semantic entry `knowledge-source-unmounted-adapter-refused-at-save` (`packages/spec/src/migrations/entries/semantic/`), registered by the changeset. ## Tests - `packages/services/service-knowledge/src/__tests__/knowledge-source-admission.test.ts`, in the `admitAuthoredSource` describe, through the real `KnowledgeService`: a retired (`ragflow`), mistyped (`memroy`) and empty adapter are each refused `VALIDATION_ERROR`/`400` naming the source, the adapter and `mounted: memory`; the refusal comes before the field gate; the system context is admitted; with none mounted the message says `mounted: none`, with two it names both; CONTROL: a mounted adapter, and an omitted one (deployment's store, two registered), are admitted. One existing fixture (`new KnowledgeService({})` in the fail-closed case) now registers the `memory` adapter its item names, so it still reaches the no-engine `503` it pins. - `packages/qa/dogfood/test/knowledge-source-unmounted-adapter-save.dogfood.test.ts`, a real booted showcase (knowledge service plus `memory`) with the MCP server: `PUT /meta/knowledge_source` refuses `ragflow` and `memroy` `400 VALIDATION_ERROR`, nothing stored (GET `404`, not registered); MCP `save_metadata_draft` with a real OAuth token (`metadata:write actions:execute`) refuses `ragflow` the same way, and no draft is stored; CONTROL: a named `memory` source and an omitted-adapter source save at both doors. <details><summary>Local runs on head 0b2a3bc (all under os-verify-lock)</summary> - Dependency closure `pnpm exec turbo run build --filter='@objectstack/dogfood^...' --concurrency=2`: exit 0 (covers `service-knowledge^...`). - `service-knowledge`: vitest Test Files 18 passed (18), Tests 573 passed (573); `typecheck` (tsc plus `check:test-typecheck`) exit 0. - `metadata-core`: Test Files 29 passed (29), Tests 1111 passed (1111); typecheck exit 0. - Door tests that pin save refusals: runtime `mcp-authoring`, `meta-save-capability-gate`, `packages-knowledge-source-gate`, `meta-type-write-capability-parity`: 4 files, 195 passed; rest `meta-write-door-capability-enumeration`, `meta-type-write-capability`: 2 files, 135 passed. - `spec` `src/migrations`: 5 files, 206 passed. New dogfood file: 4 passed (4). - **Dogfood battery** (`pnpm --filter @objectstack/dogfood test`, no shard, no path): `VERDICT command-exit 0`, held the lock 2405 s; Test Files 491 passed, 3 skipped (494); Tests 4148 passed, 68 skipped (4216). </details> <details><summary>Ablation: the check removed, both layers red; restored, green</summary> Through `scripts/ablation-replace.mjs` (anchor hit, restore trap) on the condition `if (typeof authoredAdapter === 'string' && ...)`, prefixed with an always-false string comparison carrying the marker `ABLATED_UNMOUNTED_CHECK`. - Unit leg (vitest reads `src`; marker count 1 on disk): 2 failed, 43 passed (45). Red: the two refusal cases (`ragflow: expected { admitted: true } to match object { admitted: false, ... }`). Green: the CONTROL. - Door leg: `service-knowledge` rebuilt, `ablation-dist-preflight` found the marker in `dist/` (exit 0); dogfood file 2 failed, 2 passed (4). Red: the PUT leg (`Saved knowledge_source 'ks_retired_store' ... expected 200 to be 400`) and the MCP leg. Green: the booted-store check and the CONTROL. - A first attempt spelled the mutation as a literal comparison, which the DTS build refused (TS2367), so that door leg ran with no `dist/` and is discarded; the unit leg of that attempt is the one above. - Restore: `git diff HEAD` empty, `git status --porcelain` empty, rebuilt, `ablation-dist-preflight --absent` exit 0, unit file 45 passed, dogfood file 4 passed. </details> ## Acceptance notes - The claim's file surface names `knowledge-source-admission.ts` for `admitAuthoredSource`; on 8d34c44 that function lives in `knowledge-service.ts`, beside the other adapter refusals. The admission module (`knowledge-source-admission.ts`, the gates) is untouched, so objectstack-ai#38038's gate-2 rewording and objectstack-ai#37963 do not meet this hunk; overlap-check reads clean against both. - `metadata-core` `knowledge-source-save-admission.ts` needed no threading: the verdict carries `status`/`code`/`message`, which the doors already pass through. - A source already stored with an unmounted adapter is not touched; it keeps answering `503` until it is saved again. ## Verification Read first: (1) `knowledge-service.ts` the new hunk after the unplaced-source check in `admitAuthoredSource`, and `unmountedAdapterSaveText` (remedy wording); (2) the dogfood file's MCP leg (token, `save_metadata_draft`); (3) the semantic migration entry. Two-minute check: `pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2 src/__tests__/knowledge-source-admission.test.ts` shows 45 passed, three of them the new unmounted-adapter cases. <details><summary>Gates</summary> - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`: 118 families, all run locally on 0b2a3bc, exit codes captured before any pipe. `--ran`: "118 derived famil(ies) accounted for — 115 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3)". - NOT MEASURED: `check:skill-examples`, reason: it reads `packages/client-react/dist`, outside the dogfood closure built here (PREREQUISITE NOT MET). - NOT MEASURED: `check:dual-build-cjs-loads`, reason: it needs a whole-tree `dist/` build (PREREQUISITE NOT MET). - NOT MEASURED: `check:type-check-debt`, reason: its re-measure build waited on the shared verify lock while this branch's battery held it, and exited 3. - Local-only: `check:skill-frame-freshness` exit 0; `check:dev-prereqs` exit 1, "38 of 110 workspace packages declare an entry point under dist/ that is not on disk" (only the dogfood closure is built in this worktree; a local reading, not a finding). - `check:adr-0087-registration`: "1 declared-breaking changeset(s), each carrying an ADR-0087 disposition ... registered knowledge-source-unmounted-adapter-refused-at-save (new here)". - `overlap-check` before the PR: "VERDICT clean exit 0" against origin/main 27ee984 and six open PR heads (objectstack-ai#38056, objectstack-ai#38050, objectstack-ai#38038, objectstack-ai#38013, objectstack-ai#37982, objectstack-ai#37963). - CI check-runs: not yet reported at the time of writing; the seat reads them. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Part of #37310
Clause-②: no
Metadata-protocol: none
维护者速读
name、逐个列出要索引的字段、可以不写存储;MCP 新建知识源暂不提供起始模板(模板里的占位对象和字段会被当成真实值存进去),等设置页表单从作者输入构建source后再加。What changes
skills/objectstack-ai/SKILL.md, § Knowledge Sources (RAG) (ADR-0161 K4, K5, K6 item 6; rows 3a and 3b as merged):knowledge_sourceitem: shipped in a package (knowledgeSources,*.knowledge-source.ts/.yml) or authored in Studio or over MCP.KnowledgeServicePlugin({ sources })andregisterSourceare a second door for the same schema, and a code registration and an environment item of one name are one slot, the second refused. A source's identity is its package andname:search_knowledgelists a package's source asNAMESPACE-NAME(bare for a source no package holds). A shipped item (aknowledgeSourcesentry) mounts the knowledge service and its store with norequires: ['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); an app that ships no source and authors its sources at run time needsrequires: ['knowledge'], or its items are never indexed (as main'sknowledge-rag.mdx§ Turning it on says).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;wherekeeps drafts out) now lives in thecontentandwhererows, and sayscontent.manage_knowledge_sourcesbesidemanage_metadataand passes save-time admission.id→name,contentFields→content,embedding,vectorStore,adapterConfig,refresh.cron, and thefile/httparms with their four keys;os migrate meta --from 18for a stack, by hand for a registration in code.adapter: 'pgvector'(the deployment's store) and its comments; it is otherwise row 3a's block.split:strategyis required oncesplitis written (recursiveonly whensplitis omitted); the adapter-list aside is gone.topKis asearch_knowledgeargument; rerank and hybrid weighting are no source key, and no shipped store has a setting for either (knowledge-pgvectorandknowledge-tursofuse their legs by RRF with a fixedRRF_K = 60,pgvector-adapter.ts:124,turso-adapter.ts:95; no store plugin's options interface has a rerank, weight or fusion key).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 this PR isPart of #37310: that part follows on this branch after #37971 lands (the keyword then returns toFixes), or on a later PR if this one lands first. The create seed is also left open: it waits for the Studio form (#37309, row 5).skills/objectstack-ai/evals/skills-tools-knowledge.json. Case 3 (kb_article on PostgreSQL) and case 9 (policy_doc,markdownsplit) now expectnameandcontent, and forbid a writtencontentFields:key; case 3 also forbids a written wildcard (['*'],,['*'] }),embedding:andvectorStore:, and itstopKtoken becomestopK:(the key written) because the skill now namestopKas a search argument. Case 9 also requiresname:and forbids anid:spelling; case 13 forbids the double-quoted wildcard forms. New case 14 asks for an app that ships no source and authors one at run time, and requires therequires: ['knowledge']line (either quote style), with nocontentFields:. 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 writtencontentFields:or wildcard.packages/spec/src/kernel/metadata-create-seeds.ts: unchanged (byte-identical tomain). Aknowledge_sourcecreate seed was tried and withdrawn at4c965f4a5e(comment 7229668414). Its object binding and content list sit insidesource, and the Studio create flow (buildCreateModeBody/seedPlaceholderKeysin app-shell'screateBody.ts) clears placeholder identity at the top level only, so it would have savedexample_object/example_fieldinto a new source: the objectui#12810 defect. No schema-valid seed avoids this, becausesource.objectand a non-emptycontent(K5) are required and nested.knowledge_sourcestays onKNOWN_UNSEEDED, whose comment now gives the reason: a seed waits until the Studio form (#37309, row 5) buildssourcefrom the author's input. The card allows this ("or the type stays onKNOWN_UNSEEDEDwith the reason").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_itemswithcontract: trueforknowledge_sourceserves nocreateSeed;contractPath/properties/source/properties/contentserves the content rule (minItems: 1,minLength: 1, a pattern that refuses*and admitsbody); the served schema carries noidorcontentFieldstombstone; a hand-written source with one object and one field saves as a draft; the same item withcontent: ['*'], with anid, or withcontentFieldsis refused422 INVALID_METADATA, the last two naming their tombstone's prescription ("usename", "usecontent"); nothing else is written.Platform catalog (review round,
6f2e756f58). The generator's Boot cell (packages/spec/scripts/lib/platform-catalog.ts) readson `requires`, or a shipped `knowledgeSources` itemfor a provider that declaresmountedBy;packages/spec/scripts/platform-catalog.test.tspins that cell, withrecord-contextas the control that still readson `requires`.skills/objectstack-project/references/platform-catalog.mdis regenerated.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.kindHygiene column (folded into two rows), the example's four comments restating table rows and itsrefresh: { 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. Review round (6f2e756f58): after paying down the intro's restating clause, its separatesearch_knowledgesentence, the "one name is one source" clause and the longer closing note, the row moves 6639 → 6695 (+56, the measured remainder) under the same ruling. Reproduction:ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4)= ceil(26779 / 4) = 6695.Tests
Review round at
6f2e756f58(mergesmainat58be6770ab; note 7230668192): unlocked, 35 commands, each exit 0, includingcheck-skills-token-ratchet(row 6695),check:nul-bytes,check-empty-changeset,check-adr-0087-registration,check-changeset-no-major,check:issue-citations,check:doc-authoring,check:skill-links,check:skill-identifier-liveness,check:skill-frame-sync,check:published-files;gen:skill-refsexit 0. NOT MEASURED locally (verify lock never acquired in six tries):check:skill-docs,check:skill-refs,check:yaml-examples, the platform-catalog test,metadata-create-seeds.test.ts, the MCP contract case, eval case 14. CI on this head is the reading for them. overlap-check:VERDICT overlap exit 1, the same #36158-against-main conflict in the ratchet file;origin/main, #38032 and #38013 merge cleanly.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.metadata-create-seeds.test.ts(spec): the seed pin run here (Tests 20 passed (20)) belonged to the withdrawn seed; the file is back tomain's, so CITest Coreis the reading. Patch round at4c965f4a5e: the app-shellcreateBody.seedPlaceholders-12810.test.ts(red at19f3e118f2, 2 failures, unedited), the spec create-seeds test and the rewritten MCP case are NOT MEASURED locally (verify lock saturated); their inputs equalmain's, so CITest UIandTest Coreon this head are the evidence. Unlocked gates at4c965f4a5e, exit 0 each:check-skills-token-ratchet(6639/6639),check-empty-changeset,check-adr-0087-registration,check-changeset-no-major,check:nul-bytes,check:issue-citations,check:doc-authoring. The changeset no longer lists@objectstack/spec.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 in01cf7515c2to assert absence plus the save refusal. NOT MEASURED locally after that rewrite (the second locked round never acquired); CITest Coreruns 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 --noEmitis clean.check:test-typechecknames 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.tsis not among them. They are read here as the closure build's gaps (onlyruntime^...was built) and not as this diff's; CITypeScript Type Checkdecides.pnpm --filter @objectstack/spec run check:skill-examples: exit 3, PREREQUISITE NOT MET (the@objectstack/client-reactdist 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-testexit 0.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, andpnpm 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.check-skill-frame-freshnessexit 0.check-dev-prereqsexit 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:main'sSKILL.md(8d34c4404f, hash88a20cb583), new cases (ablation)contentFields:written;name:,content:missingcontentFields:written;content:missingcontentFields:,['*'],andid: 'faqwritten; no egress reasonThe ablation restored
main'sSKILL.mdinto the working tree only (git restore --source=8d34c4404f,git hash-object=88a20cb583). The run ran, and thenHEAD's file came back (fc845724acboth on disk and atHEAD). 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
git grep -n -E "contentFields|'\*'|adapter: 'ragflow'" skills/objectstack-ai) returns eight lines. InSKILL.md, three: thecontentrow ("'*'is refused") and two lines of the retired-keys paragraph. In the eval file, five: the reference answers of cases 3 and 13, which name both as retired, and themust_not_containlists of cases 3, 9 and 13, which forbid a writtencontentFields:and a written wildcard (['*'],,['*'] }). The card itself asks the eval to fail oncontentFieldsor'*', which puts the forbidden token on the assertion line. The reviewer decides whether those lines count as "naming a retired key as retired".adapter: 'ragflow'has no hit: Retire @objectstack/knowledge-ragflow: package, settings option, docs and skill mentions #37004 already removed it.itinside the existing real-protocoldescribeofmcp-authoring.test.ts, beside the flow contract case, because that describe holds the real-protocol harness (realProtocol,STUDIO_BASE). It is in the shared harness file, not a new file.retiredKey()tombstone ({ not: {} }; see the note inpackages/metadata-protocol/src/protocol-meta-type-schema.ts: the served schema publishes what an author MAY write). The prescription reaches an MCP author through the save refusal instead. The pin asserts both halves: the tombstone is absent from the served schema, and a save that writes the retired key is refused naming its replacement.VERDICT overlap exit 1.origin/main, chore: version packages (next) #38032 and feat(metadata-core)!: a knowledge source is saved only on a deployment that mounts the knowledge service #38013 merge cleanly. docs(skills): objectstack-data and objectstack-automation SKILL.md become routers #36158 (a draft last updated 2026-11-25) conflicts inscripts/check-skills-token-ratchet.mjs. That conflict is docs(skills): objectstack-data and objectstack-automation SKILL.md become routers #36158's own againstorigin/main:git merge-tree origin/mainwith docs(skills): objectstack-data and objectstack-automation SKILL.md become routers #36158's head conflicts in the same file, and every conflict hunk is at line 798 or later, away from this branch's hunk near line 453. Reported here, not resolved.Verification
Files to read first, by risk:
skills/objectstack-ai/SKILL.md§ Knowledge Sources (RAG): theadapterandcontentrows and the retired-keys paragraph.packages/spec/src/kernel/metadata-create-seeds.test.ts: theKNOWN_UNSEEDEDreason forknowledge_source(no seed;metadata-create-seeds.tsis byte-identical tomain).packages/runtime/src/domains/mcp-authoring.test.ts: the new contract case.Two-minute check:
node scripts/check-skills-token-ratchet.mjs. Expectskills/objectstack-ai/SKILL.md is 6695 tokens (ceiling 6695; headroom 0).Readings:
skills/objectstack-ai/SKILL.md464 → 469 lines, 26462 → 26806 bytes (6609 → 6695 priced tokens, in two moves). Every publishedSKILL.mdsummed: 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