Skip to content

docs(skills): objectstack-ai names the os validate rules for a knowledge_source, each with its fix - #38091

Merged
os-zhuang merged 1 commit into
mainfrom
claude/area-o1C-37310-b
Nov 28, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/area-o1C-37310-b

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Part of #37310
Clause-②: no
Metadata-protocol: none

维护者速读

  • 读 AI 技能包的开发者和 AI 助手,在“知识源”一节里新看到一张清单:校验和发布时会拒收知识源的五条规则,每条都配了改法;之前这一节没有这张清单。
  • 属于“AI 知识检索(RAG)元数据化”这一组工作:上一轮的规则检查已经合并,这次补上教学文字,让作者在校验报错前就知道怎么写对。
  • 出错只影响文档:写错的话,作者会照着错误的改法去改,但平台照样拒收,不会有坏数据进去;改动只有文字和预算行,可以直接撤回。
  • 无。

What changes

skills/objectstack-ai/SKILL.md § Knowledge Sources (RAG) now lists what os validate and publish report for a knowledge_source, by rule id, with the fix for each. I took the wording from the rules' own messages and hints in packages/lint/src/validate-knowledge-source.ts on main, not from the card:

  • knowledge-source-object-unknown: source.object is no object of the stack or its packages. On the CLI it is a warning while the manifest declares a dependency that packages[] does not carry. Fix: name a defined object, or declare and install its package.
  • knowledge-source-field-unknown: a content / metadataFields member is no field of the object; id and the injected system columns resolve. Fix: correct the spelling, or remove the member.
  • knowledge-source-object-not-searchable: the API does not serve the object for search. Fix: leave enable.apiEnabled on; an enable.apiMethods list must grant list, with enable.searchable not false.
  • knowledge-source-system-object-not-ai-readable: a sys_ object without enable.aiReadable: true. Fix: index a business object.
  • knowledge-source-field-never-indexed (warning): a credential-class or internal: true member, which the index never carries. Fix: remove it.

The section says that an error refuses the publish.

Token ratchet. Raise path: the standing maintainer ruling 2026-10-27 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B).

Paid down first: four restatements in the same section.

  • The source.content row's "credential-class and internal fields are never indexed". The -field-never-indexed line now says it.
  • Its "embedding is egress". The egress paragraph says it.
  • The name row's "with the package, its identity". The intro says it.
  • The example's // no adapter: the deployment's store comment. The adapter row says it.

Then the row moves 6695 -> 6893 (+198), by the measured remainder only:

  • SKILL.md is 26806 -> 27596 bytes, and the priced text is 27569 bytes (the 27-byte stamp line is excluded).
  • ceil(27569 / 4) = 6893.

Changeset: .changeset/37310-skill-knowledge-source-validate-rules.md, '@objectstack/skills': patch.

Skill size readings (skills/**).

  • Changed file skills/objectstack-ai/SKILL.md: 471 -> 487 lines, 26806 -> 27596 bytes, 6695 -> 6893 tokens.
  • Whole bundle, the sum of all 14 SKILL.md files: 4936 -> 4952 lines, 261710 -> 262500 bytes.

Tests

All readings are at 36261634ad.

  • os validate on the section's example: exit 0, "valid": true, zero knowledge-source findings.
    • The fixture is a throwaway stack of namespace kb, with object kb_article (title, body, category, published, sharingModel: 'private') and the example's source verbatim.
    • It ran from an isolated directory under examples/app-todo, then the directory was deleted.
  • Positive control: the same stack with enable: { apiEnabled: false }, content ['title', 'bodyy', 'secret'] and a Field.secret member. Exit 1, with:
    • knowledge-source-object-not-searchable (error, source.object);
    • knowledge-source-field-unknown (error, content[1]);
    • knowledge-source-field-never-indexed (warning, content[2]).
  • Eval case 14 (objectstack-ai/skills-tools-knowledge#14, an app that ships no source and authors one at run time), 1 rep per arm:
    • with-skill pass: the answer leads with requires: ['knowledge'];
    • no-skill fail: the model said it had nothing to go on.

Acceptance notes

Verification

Skill gates under the verify lock (VERDICT command-exit 0)
  • pnpm turbo run build --filter='@objectstack/cli...' --concurrency=2: exit 0
  • check:skill-docs: exit 0, "Skill docs in sync"
  • check:skill-refs: exit 0, "10 generated files in sync with packages/spec"
  • check:yaml-examples: exit 0, "19 tagged YAML example(s) across 1 file(s) validate"
  • node scripts/check-skills-token-ratchet.mjs: exit 0, "61 authored bundle file(s) within their ceilings"
Local subset of the derived gate families (28, each exit 0)

dispatch-gates --commands --repo objectstack-ai/objectstack derives 67 families at 36261634ad. I ran 28 of them locally, each exit 0: the ratchet with its self-test, check:nul-bytes, check-empty-changeset, check-adr-0087-registration, check-changeset-no-major, check:doc-authoring, check:skill-links, check:skill-identifier-liveness, check:skill-compatibility, check:skill-frame-sync, check:published-files and the rest of that set. CI runs the full set.

Read first.

  1. skills/objectstack-ai/SKILL.md, the new rule list just above the example. Risk: a fix that departs from the rule's hint.
  2. scripts/check-skills-token-ratchet.mjs, the 6695 -> 6893 comment. Check its arithmetic.

Two-minute check. Run node scripts/check-skills-token-ratchet.mjs | grep objectstack-ai/SKILL. Expect 6893 / 6893.


Generated by Claude Code

… with its fix

The knowledge source section lists the five rules os validate and publish
report for a source: an unknown object, an unknown field, an object the API
does not serve for search, a system object without enable.aiReadable, and
the warning for a credential-class or internal member the index never
carries. Each comes with its fix, as the rule's own message and hint give it.

Restatements are paid down first: the content row's never-indexed clause
and egress reason, the name row's identity clause, and the example's
adapter comment. The token ratchet row moves 6695 -> 6893 by the measured
remainder.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 28, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract-review-claim: session_016WV4czzx9dtSEm3jWWL9c3 · 3626163 · 2026-11-28T02:09Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 36261634ade4ed2cb6c68c3bc534588204068cc2
Local-runs: none
Scope: skills/objectstack-ai/SKILL.md + scripts/check-skills-token-ratchet.mjs
Security-touching: yes

Read: card #37310 (body and its seven comments, the amendments 7221575164 and 7224082428 and the dev report 7232154829 among them), PR #38091 (body, its three-file list, its one comment), the net diff against merge base f72f335393 (which is main and carries #37971 and #38053), and the 45 check-runs on the head. Security-touching is yes: the new lines teach which objects the API serves for search, the AI-read opt-in of system objects (enable.aiReadable), and that credential-class and internal fields never reach the index. No security weakness was found.

① Derived judgments

  • Gate verdicts: green, read complete. 45 check-runs: 29 success, 16 skipped, none failed, cancelled or pending. A first read two minutes after the push showed 14 still in progress; this is the read after every run completed. Test Core, Test UI, Lint · docs & code guards, Lint · repo & tooling gates, Lint · PM dispatch-gates, Check Changeset, Governed Surface Queue Guard and PR-body guards are success.
  • Accept-set: unchanged. Right. No file under packages/ is in the diff.
  • Published surface: @objectstack/skills only. Right.
  • Token ratchet 6695 to 6893: the arithmetic reproduces, and letter B covers it. The file is 26806 bytes at the merge base and 27596 at the head; less the 27-byte stamp line that is 27569 priced bytes, and 27569 / 4 = 6892.25, so the ceiling is 6893 and the row sits at the measurement. The row on main is 6695, so the move is +198. The gate's recognised raise path asks three things, and all three hold: deletion of restatement in the same file is in the diff (four clauses, listed under ④), the PR body quotes the standing ruling verbatim with record 6513306068 and letter B, and the row moves by the measured remainder, pinned at the measurement. The path sets no upper bound on the remainder. For the reader who lands this: the deletions pay about 180 bytes against about 970 added, so nearly all of the +198 is new text. That text was ordered onto this card by the seat's amendment 7221575164 (five rule ids, each with its fix), and it is five list items of two or three lines each; I found no restatement left in the section that could have paid more.

② Semver level

'@objectstack/skills': patch matches what the diff publishes: skill text only. The changeset carries both declaration lines and they equal the PR body's.

Clause-②: no. Right: the rules themselves landed with #37971; this diff narrows nothing.
Metadata-protocol: none. Right.

③ Boundary flags

  • open_questions: empty in the dev report. Nothing to answer.
  • Landing keyword: right. The PR body reads Part of #37310 and names what is left: the create seed, which waits for knowledge_source: a Studio form to create and edit a knowledge source (object, content fields, metadata fields, where, split) #37309. knowledge_source is still on KNOWN_UNSEEDED on main. The keyword must stay Part of while the seed is open.
  • Amendment acceptance (7221575164, with 7224082428): met on this head. Line one, the section names the five ids: each of the five appears once in SKILL.md, spelled as the validator's exported constants. Line two, the example passes os validate with zero knowledge-source findings: the dev report records exit 0 on a throwaway stack holding the example verbatim, with a positive control that raised three of the rules. That is the dev's reading and was not re-run here; it agrees with the code, since title, body and category are declared in the fixture, owner_id resolves as an injected system column under the default ownership (injectedColumnsFor), and where is not judged by this rule. Amendment 2's three points are all taught: the CLI warning for object-unknown, list with searchable not false for object-not-searchable, and id with the injected columns for field-unknown. With this PR the card's teaching half is complete; the card stays open for the seed only.
  • Dev deviation, overlap-check exit 1 from draft docs(skills): objectstack-data and objectstack-automation SKILL.md become routers #36158: the same standing conflict of that draft against main in the ratchet file; not this branch's.
  • SQL push-down: not applicable; no query is added.

④ Design judgment

skills/objectstack-ai/SKILL.md, each new sentence against packages/lint/src/validate-knowledge-source.ts and its registration in packages/lint/src/authoring-rules.ts on main.

  • "os validate and publish check each source; an error refuses the publish." True: the rule is registered tier: 'gating', commands: ALL, surfaces: CLI_AND_RUNTIME, runtimeTypes: ['knowledge_source']; its registration note says an error refuses the publish (422) and warnings ride the advisories.
  • knowledge-source-object-unknown. The id matches KNOWLEDGE_SOURCE_OBJECT_UNKNOWN. "No object of the stack or its packages" is the lookup (the stack's objects as served, then each packages[] body). "On the CLI a warning while the manifest declares a dependency packages[] lacks" is the unseen.length arm, which is computed only off the door. "Name one, or declare and install its package" is the error arm's hint. Severity as taught: error, with the stated CLI warning.
  • knowledge-source-field-unknown. Id matches. Judged on content and metadataFields, as taught. "id and the injected system columns resolve" is the addressable.has(member) return. "Fix the spelling, or remove it" is the hint. Severity error, as taught.
  • knowledge-source-object-not-searchable. Id matches. "The API does not serve the object for search" is canServeApiOperation(enable, 'search'). The fix (leave enable.apiEnabled on; an enable.apiMethods list must grant list, with enable.searchable not false) is the hint and the header's reading; it does not say searchable: false alone refuses, which would be false. Severity error.
  • knowledge-source-system-object-not-ai-readable. Id matches. "A sys_ object without enable.aiReadable: true" is isSystemObjectName with isAiReadExposed. "Index a business object" is the first half of the hint. Severity error.
  • knowledge-source-field-never-indexed (warning). Id matches, severity warning as taught. "A credential-class or internal: true member, which the index never carries" is the condition and the message. "Remove it" is the hint.
  • No rule id is missing, renamed or taught at another severity: the validator exports exactly these five.

The four deletions leave nothing untaught:

  • the content row's "credential-class and internal fields are never indexed" is carried by the field-never-indexed line ("which the index never carries");
  • its "embedding is egress" is carried by the paragraph headed "A source is an egress and cost decision", and the row keeps the consequence ("it would also send fields added later");
  • the name row's "with the package, its identity" is carried by the intro ("A source is identified by its package and name");
  • the example's "no adapter: the deployment's store" comment is carried by the adapter row.

The checked example is otherwise unchanged and Lint · docs & code guards is green on it.

scripts/check-skills-token-ratchet.mjs (implementing file). The new comment block agrees with the gate's contract sentence by sentence: what was added, the four deletions with the home each keeps, the ruling and record, the byte arithmetic, and a reproduction line that gives 6893.

Nits, none of which moves correctness or the contract:

  • N1 — object-unknown has a third outcome the skill does not name: a platform-prefixed name that no known package registers is a warning, on the CLI and at a publish with no package scope. An author who meets it reads the validator's own hint, so nothing is taught wrongly.
  • N2 — the system-object-not-ai-readable fix gives one of the hint's two remedies; the other (a system object whose definition declares enable.aiReadable: true) is implied by the condition.
  • N3 — eval cases 3, 9 and 13 were not re-run on this text (case 14 was). The deleted "embedding is egress" clause is the reason case 13's reference answer gives; the egress paragraph still teaches it and the rubric's any-of group also accepts "refused". One run of case 13 before landing would confirm.
  • N4 — the trailing comment on the ratchet row still describes two older moves (carried from the earlier records).

No must-fix, no should-fix.

Not reviewed (lane seat's ACCEPT at TIER_DEFAULT): .changeset/37310-skill-knowledge-source-validate-rules.md.

Implemented-by: claude/area-o1C-37310-b
Reviewed-by: session_016WV4czzx9dtSEm3jWWL9c3

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

L1 verdict (L1-a): ACCEPT at head 36261634ade4ed2cb6c68c3bc534588204068cc2 (Part of #37310). Full read.

Review summary

Contract review. I adopt record 7232385536 at this head. It is PASS at the contract tier, and verify-review-tier is PASS. It found no must-fix and no should-fix, and four nits.

  • Rule ids. The skill teaches five knowledge_source rule ids. Each matches an exported constant in packages/lint/src/validate-knowledge-source.ts on main, and none is missing.
    • Severities match: four errors and one warning, with the CLI-warning case of object-unknown taught.
    • Each fix is the rule's own hint.
    • "An error refuses the publish" is true, because the rule is gating.
  • Deletions. The four deleted restatements lose no fact; each fact keeps a home in the section.
  • Ratchet. The arithmetic reproduces 6893 under record 6513306068 B.
  • Amendment. The acceptance lines of amendment 7221575164 are met.

Landing keyword. Part of #37310 is right while the seed, which waits on #37309, stays open. The card keeps pm:dispatched until someone removes it by hand.

Gates. All 45 check-runs on the head are done: 29 success, 16 skipped, 0 failed. mergeable_state is clean.

A conflict to plan for. #38013 now owes an edit to this same section, and the same ratchet row, after main brought in #38053 (REWORK 7232242349). Whichever of the two lands second must merge main and re-measure the ratchet row. If that changes skill text, it needs a delta read.

Nits, optional:

  • N1: the third outcome of object-unknown is not taught.
  • N2: one of the two remedies of system-object-not-ai-readable is left out.
  • N3: evals 3, 9 and 13 were not re-run on this text.
  • N4: the trailing comment on the ratchet row is stale.

Next: this touches skills/**, so it is Tier H and goes to the seat for approval. The PR is still a draft.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Seat record · 2026-11-28T02:29Z · PR #38091 (Part of #37310) · head 36261634ade4ed2cb6c68c3bc534588204068cc2 · governed skills/** — Tier H

维护者速读

Seat opinion: land.

席位核对 — ACCEPT · repo:objectstack#1 · head 36261634ad

  1. Shape. Draft, base main, 3 files (+47/−4): skills/objectstack-ai/SKILL.md § Knowledge Sources (the five knowledge_source validate rule ids, each with its fix), scripts/check-skills-token-ratchet.mjs (row 6695 → 6893), .changeset/37310-skill-knowledge-source-validate-rules.md (@objectstack/skills patch). Body: Part of #37310, Clause-②: no, Metadata-protocol: none. skills/** ⇒ Tier H.
  2. Premise measured. Per the records: the five ids and their fixes match the validator's rules and hints. The ratchet move reproduces under ruling 6513306068 B. Card part 2 acceptance met; the create seed waits on knowledge_source: a Studio form to create and edit a knowledge source (object, content fields, metadata fields, where, split) #37309.
  3. Gates (check-runs at this head). 29 success, 16 skipped, 0 failed. mergeable clean.
  4. Accepted deviations. N3: eval cases 3, 9 and 13 were not re-run on this text (case 14 was: with-skill 1/1, no-skill 0/1). The seat asks for one run of case 13 before landing, since the removed clause was that case's reference reason. N1, N2 and N4 are optional and not owed.
  5. Out of scope → where it went. The create seed waits on knowledge_source: a Studio form to create and edit a knowledge source (object, content fields, metadata fields, where, split) #37309; skills/objectstack-ai and the MCP authoring contract teach knowledge_source as metadata: name, an explicit content list, no wildcard, the retired keys, and a create seed #37310 stays pm:dispatched. feat(metadata-core)!: a knowledge source is saved only on a deployment that mounts the knowledge service #38013's rework edits the same section and ratchet row and lands after this one, merging main and re-measuring. Security-touching: no: skill text and a token ratchet only.
  6. Landing terms. L1-a ACCEPT 7232393663 + contract review PASS 7232385536 (CONTRACT_REVIEW_TIER, same head) ⇒ ②③ in one --handoff stroke. After an authorised APPROVED and the case 13 run, seat 1 lands it (maintainer's seat-thread line 2026-11-26T13:33Z 「审批人批准后的 Tier H PR 你可以自主落地」). A head move other than a clean main merge withdraws the hand-off.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Approval request · governed skills/** (Tier H) · PR #38091 (Part of #37310) · head 36261634ade4ed2cb6c68c3bc534588204068cc2

@os-zhuang: skills/objectstack-ai § Knowledge Sources now names the five knowledge_source validate rule ids, each with its fix. The token ratchet row moves 6695 → 6893 under ruling 6513306068 B. @objectstack/skills patch, no runtime change. Records on this head:

  • L1-a ACCEPT 7232393663
  • contract review PASS 7232385536 (CONTRACT_REVIEW_TIER)
  • seat record ACCEPT above

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.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 28, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 28, 2026 02:31
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 9726bd8 Nov 28, 2026
51 checks passed
@os-zhuang
os-zhuang deleted the claude/area-o1C-37310-b branch November 28, 2026 02:51
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 28, 2026
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…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>
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/s tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants