Repository navigation
feat(metadata-core)!: a knowledge source is saved only on a deployment that mounts the knowledge service - #38013
objectstack-fleet[bot] wants to merge 6 commits into
Conversation
…ployment with no knowledge service Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude <noreply@anthropic.com>
…y door that saves a knowledge_source Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude <noreply@anthropic.com>
…nowledge_source save refusal Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude <noreply@anthropic.com>
… mounts a knowledge service; the door isSystem hold lives at the predicate Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 5 package(s): 15 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 11 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 184 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 82ef1cd069b02a9a8d769449c2f54a08a2413fca && git checkout 82ef1cd069b02a9a8d769449c2f54a08a2413fca
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8d34c4404f951410083a6caebd6ad8003ea3423d 33acf12ec4b1c5a7d50fe55b99864f867d9e1812 && git checkout -B drift-repro 8d34c4404f951410083a6caebd6ad8003ea3423d && git merge --no-ff 33acf12ec4b1c5a7d50fe55b99864f867d9e1812
node scripts/docs-audit/affected-docs.mjs --json 8d34c4404f951410083a6caebd6ad8003ea3423d
|
…s mounted; the boot line names the same remedy Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 Contract-review-claim: session_016WV4czzx9dtSEm3jWWL9c3 · 33acf12 · 2026-11-27T21:08Z |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 Contract reviewServed-tier: Inputs: card #37983 body and all four comments (ruling 7220511579, claim 7220546046, dev reports 7222789795 and 7228132286; no earlier contract-review record), PR #38013 body and file list, the net diff against ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix, no should-fix. Hits file,
Implementing files, against the ruling:
Observation outside the diff, not graded: Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 L1 review — REWORK (dogfood battery only); merits acceptedHead: Merits: accepted. The contract-tier review is record 7228262724: PASS, no must-fix, no should-fix, five nits. The record verifies at tier. The predicate change matches ruling D: the no-service refusal comes after the system-identity return and before the member check. Each of the three ruled doors, plus the package-duplicate door, passes The l1-face changeset flag is answered. The REWORK — one item. The title carries
To close it, run the full battery on For the Tier H approval: the contract review escalates one boundary item rather than grading it. The package-duplicate door is a fourth refusing door, while the ruling's parenthesis names three. The area ruled to keep it refused, because the rule sentence covers every door that saves one. That refusal blocks duplicating a whole package because of one source, and the body's maintainer summary does not mention it. The approver should read the PR's Open question section. Nits from the record, optional, for a follow-up card: N1 entry 19's surface text includes stacks that already mount the service by shipping a source; N3 a scoped-factory miss would get the no-service sentence; N4 the |
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Fixes #37983
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — no page under skills/** teaches saving a knowledge_source at run time through Studio, REST or MCP (skills/objectstack-ai/SKILL.md wires sources through KnowledgeServicePlugin at boot); the two docs pages are updated on this branch
维护者速读
What changes
Ruling D (maintainer, recorded on #37983, comment 7220511579) is implemented in the one predicate every save door asks,
authoredKnowledgeSourceRefusal(packages/metadata-core/src/knowledge-source-save-admission.ts):resolveKnowledgeService()answeringundefined(ornull) used to admit the save; it now answers503 SERVICE_UNAVAILABLEwith a message that names the item, the reason and the remedy in order: addrequires: ['knowledge']to the stack (or, on a host that composes its own kernel,KnowledgeServicePluginand a knowledge store), restart, then save the source again. Nothing is written.isSystem: package install, seed, migration) is never refused (theisSystemcheck still runs before the service is resolved); a REGISTERED knowledge service with noadmitAuthoredSource(not the platform's, for example host-mounted) keeps today's accept. The module doc (:33-34on main) now says both, and gains a section on the no-service case.PUT /meta/:type/:nameinpackages/restpassesrefused.codethrough for a non-403 (SERVICE_UNAVAILABLE), the runtime dispatcherPUTderivesSERVICE_UNAVAILABLEfrom503, and the MCPsave_metadata_draftpassesrefused.codethrough for a non-403 (onmainsince knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306). Only their comments are updated. Each door is pinned.503 SERVICE_UNAVAILABLE(ADR-0112 status table,STATUS_TO_STANDARD_CODEinpackages/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 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 nosaveMetaItem),409 RESOURCE_CONFLICTand428 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".Metadata-protocol: narrowedowes 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 carriesregisteredwith that id.Boot line and docs (ruling items 2 and 4), landed after #37306
Held off this branch until #37306 merged (PR #38026, dbe0716);
mainis now merged in (1ca3a31) and the held commit is re-applied as 33acf12.packages/objectql/src/knowledge-source-unserved.ts): the line forknowledge_sourceitems held with no knowledge service now names the same remedy as the save refusal, from the item-4 patch'sUNSERVED_REMEDY: declarerequires: ['knowledge']and restart (or, on a host that composes its own kernel,KnowledgeServicePluginand a knowledge store). Before, it said "addKnowledgeServicePluginand a knowledge adapter to the composition". Only the boot-line half of that patch was taken: knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306 did not touch this file, somainstill carried the old text.knowledgeSourcesnow mounts the service by itself, andadapteris 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'sknowledge-rag.mdxalready said "the token is for an app that ships none and authors its sources at run time", which matches.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 --3wayconflicted onknowledge-rag.mdx.@objectstack/objectqlpatch line and its bullet.mainnow passesrefused.codethrough for a non-403 (knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306), so this refusal still arrives there asSERVICE_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 inpackages-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 forundefined/null; an unnamed item;isSystemnot refused and the service never resolved; a registered service without the member still admits.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.PUT(packages/runtime/src/domains/meta-save-capability-gate.test.ts): refused on a realObjectKernelwith nothing registered; system write saved; host-mounted service saved.save_metadata_draft(packages/runtime/src/domains/mcp-authoring.test.ts): refused, nothing written, another type still saves; host-mounted service saved.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.packages/objectql/src/knowledge-source-unserved.test.ts): namesDeclare requires: ['knowledge'] in the stack and restart.Readings at head
33acf12ec4(main merged in; shared container; every build and test throughscripts/pm/os-verify-lock.sh, verdictcommand-exit 0each round):Tests and typecheck at 33acf12
turbo run build, all but docs) exit 0,packages/runtime/.objectstackcleared,@objectstack/spec check:generatedexit 0.@objectstack/metadata-corepnpm test: Tests 1113 passed;typecheckexit 0.@objectstack/objectqlknowledge-source-unserved.test.ts: Tests 7 passed;typecheckexit 0.@objectstack/rest, 4 files (door enumeration, type-write capability, both org-scope suites): Tests 161 passed;typecheckexit 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;typecheckexit 0.knowledge_sourceas 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-levelisSystemcases were dropped because inbound HTTP never carriesisSystem(metaTypeWriteRefusalanswers 401 first); that hold is tested at the predicate instead.test:repo, and the derived families not listed under Gates run in CI.Ablations (one per tested behaviour)
scripts/ablation-replace.mjsreplaced the one new line (anchor 1 -> 0, marker 0 -> 1).@objectstack/metadata-corewas rebuilt, andablation-dist-preflightfound the marker indist/index.jsanddist/index.cjs. Exactly these went red: the predicate test (1 of 9), RESTPUT(1 of 81), and dispatcherPUT, MCP draft save and package duplicate (3 of 162). Restored withgit checkout HEAD(blob back to cd26e8f520,git diff HEADempty), rebuilt, and preflight--absentwas clean.names the item, the missing service and both remedies(1 of 7). Restored withgit checkout HEAD(blob aa50e2ec54,git diff HEADempty).Live server (REST door, at dd50936)
After a full build I ran
pnpm dev:crm -- --fresh -p 38937; the CRM stack declaresrequires: ['ui', 'automation']and no knowledge. Signed in as the seeded admin,PUT /api/v1/meta/knowledge_source/faqanswered503,error.codeSERVICE_UNAVAILABLE, with the remedy sentence. AGETof the item then answered404, so nothing was written. The server was stopped by its recorded pid. A positive control on a stack withrequires: ['knowledge']was not run (NOT MEASURED); the unit tests cover the admitted path.Gates at 33acf12
Local, exit 0 each:
check-adr-0087-registration(1 declared-breaking changeset, with its disposition),check-changeset-no-major,check-empty-changeset, speccheck: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-checkbefore the push: clean againstmainand against #38043, #37982 and #37963.Dogfood battery at 33acf12
NOT MEASURED locally. Reason: the shared verify lock was not reached. Slot
dev-37983waited about 21 minutes over three tries; two of them endedVERDICT queue-timeout (exit 99) · never acquired. Another agent's dogfood run held the lock (held 1084s at the last try), and four more runs were queued ahead. CI'sDogfood Regression Gatecheck-run on this head concludedsuccess.Acceptance notes
400 VALIDATION_ERRORarriving at the MCP draft door asSERVICE_UNAVAILABLEis obsolete: knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306 merged with the MCP door passingrefused.codethrough.content/docs/ai/knowledge-rag.mdxandcontent/docs/protocol/knowledge.mdxare updated on this branch.content/docs/permissions/system-context.mdxrow 46 is re-read and still true: the refusal is not on theisSystempath. The other pages match on theSERVICE_UNAVAILABLEliteral only and say nothing about knowledge sources. The release-owned pages are not edited.Verification
Read first (by risk):
packages/metadata-core/src/knowledge-source-save-admission.ts(theservice === undefined || nullbranch, 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 #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 lineif (service === undefined || service === null) return noKnowledgeServiceRefusal(input.item);out and they go red.Body refreshed 2026-11-27T21:04Z at head
33acf12ec4.Generated by Claude Code