Skip to content

feat(metadata-core)!: a knowledge source is saved only on a deployment that mounts the knowledge service - #38013

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

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

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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

维护者速读

  • 作者在没装知识服务的部署上,通过工作台、元数据接口或智能体工具保存知识源时,会当场失败并看到原因和修法(先在应用配置里声明需要知识服务并重启,再保存);以前这种保存显示成功却永远不生效。
  • 属于知识库检索这条线,执行您选的方案 D:让作者在保存那一刻就知道,而不是只在看不到的服务器日志里。
  • 只影响在这类部署上保存知识源的作者;装包、种子数据、迁移照常通过;出问题可整单撤回。
  • 要你做的:批准这次收窄(按审批流程)。

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):

  • 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 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.
  • 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 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 #37306

Held off this branch until #37306 merged (PR #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: knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306 did not touch this file, so main still carried the old text.
  • What knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #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 patch line and its bullet.
  • The MCP draft door on main now passes refused.code through 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 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.

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):

Tests and typecheck at 33acf12
  • 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.
Ablations (one per tested behaviour)
  • 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 cd26e8f520, 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 aa50e2ec54, git diff HEAD empty).
  • The docs pages are not ablated.
Live server (REST door, at dd50936)

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.

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, 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 #38043, #37982 and #37963.

Dogfood battery at 33acf12

NOT MEASURED locally. Reason: the shared verify lock was not reached. Slot dev-37983 waited about 21 minutes over three tries; two of them ended VERDICT 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's Dogfood Regression Gate check-run on this head concluded success.

Acceptance notes

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 #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-27T21:04Z at head 33acf12ec4.


Generated by Claude Code

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

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 5 package(s): @objectstack/metadata-core, @objectstack/objectql, @objectstack/rest, @objectstack/runtime, @objectstack/spec, touching 12 documentable anchor(s).

15 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/connect-mcp.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/ai/knowledge-rag.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/api/client-sdk.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/api/error-catalog.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/api/index.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/automation/webhooks.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/deployment/self-hosting.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/kernel/runtime-services/email-service.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/permissions/authentication.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/permissions/authorization.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/permissions/sharing-rules.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/permissions/system-context.mdx (via authoredKnowledgeSourceRefusal (symbol, a top-level function), handleMetadataRequest (symbol, a top-level function), openWriter (symbol, a top-level function), registerMetaItemWriteRoutes (symbol, a top-level function))
  • content/docs/protocol/kernel/error-handling.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/protocol/knowledge.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/ui/print-pages.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))

⛔ 11 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/implementation-status.mdx (via RestServer (symbol, a top-level class))
  • content/docs/releases/v12.mdx (via RestServer (symbol, a top-level class))
  • content/docs/releases/v16.mdx (via RestServer (symbol, a top-level class))
  • content/docs/releases/v17/17-0.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/releases/v17/17-3.mdx (via RestServer (symbol, a top-level class), SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/releases/v17/17-4.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/releases/v17/17-5.mdx (via RestServer (symbol, a top-level class))
  • content/docs/releases/v17/17-7.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/releases/v18/18-2.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))
  • content/docs/releases/v18/18-3.mdx (via RestServer (symbol, a top-level class))
  • content/docs/releases/v18/18-5.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in noKnowledgeServiceRefusal))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 184 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 8d34c4404f951410083a6caebd6ad8003ea3423d → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 82ef1cd069b02a9a8d769449c2f54a08a2413fca — the merge of head 33acf12ec4b1c5a7d50fe55b99864f867d9e1812 into base 8d34c4404f951410083a6caebd6ad8003ea3423d, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 8d34c4404f951410083a6caebd6ad8003ea3423d → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract-review-claim: session_016WV4czzx9dtSEm3jWWL9c3 · 33acf12 · 2026-11-27T21:08Z

@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: 33acf12ec4b1c5a7d50fe55b99864f867d9e1812
Local-runs: none
Scope: packages/spec/src/migrations/entries/semantic/19.knowledge-source-save-refused-without-knowledge-service.ts + packages/metadata-core/src/knowledge-source-save-admission.ts, packages/objectql/src/knowledge-source-unserved.ts, packages/rest/src/meta-item-write-routes.ts, packages/rest/src/rest-server.ts, packages/runtime/src/domains/meta.ts, packages/runtime/src/domains/mcp-authoring.ts, and the eleven test files of the diff (narrowing face: every path outside the prose faces). Read in the cited code, not reviewed: packages/runtime/src/domains/packages.ts (the duplicate door), packages/runtime/src/http-dispatcher.ts (resolveServiceOrLoud, classifyService), packages/rest/src/rest-api-plugin.ts (kernelServiceProvider), packages/services/service-knowledge/src/knowledge-service.ts and knowledge-service-plugin.ts, packages/spec/src/kernel/platform-capabilities.ts, packages/spec/src/api/errors.zod.ts, packages/spec/src/migrations/types.ts, packages/rest/src/meta-item-history-routes.ts.

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 main (merge base 8d34c44, which is origin/main), and the check-runs on the head: 59 success, 12 skipped (opt-in and queue-only jobs), 0 failure, 0 pending.

① Derived judgments

  • Accept set, narrowed, right: authoredKnowledgeSourceRefusal answered undefined (admit) on main when resolveKnowledgeService answered undefined or null for a non-system writer; at this head it answers a 503 SERVICE_UNAVAILABLE refusal. One new line decides it, placed after the isSystem return and the resolve try/catch and before the member check. This is the narrowing ruling D item 1 orders, and the PR declares it.
  • Accept set, held, right: isSystem === true returns before the service is resolved (ruling item 2); a registered service with no admitAuthoredSource still admits (the claim's fold-or-serial line: only "no knowledge service registered" is ruled). Both are pinned at the predicate.
  • Public surface, unchanged, right: the exported function's signature, AuthoredKnowledgeSourceRefusal, KnowledgeSourceSaveAdmitter and KNOWLEDGE_SOURCE_ADMISSION_SERVICE are untouched; noKnowledgeServiceRefusal is module-private; UNSERVED_REMEDY in objectql is module-private. No Zod schema changes. The spec package gains one semantic migration entry (discovered by file name, id unique in the tree).
  • Doors, right: no door changes shape. REST PUT passes refused.code through for a non-403; the dispatcher PUT answers deps.error(message, 503); the MCP draft save passes refused.code through for a non-403; each is pinned with code, status, the reason sentence, the ordered remedy and a zero-write assertion.
  • Derived and wider than the ruling's enumerated doors: the package duplicate door (refuseDuplicatedKnowledgeSources, not in the diff) asks the same predicate, so a non-system duplicate of a package holding a source is refused 503 on a no-service deployment. Declared in the changeset, the entry's surface, the protocol docs page and a pin. See ③.
  • Boot line, right: text only; describeUnservedKnowledgeSources keeps its signature and its warn, never-refuse posture (ADR-0078 §4, ruling item 2). UNSERVED_REMEDY is a const declared below the function that reads it; it is read at call time, after module evaluation, so there is no temporal-dead-zone fault.

② Semver level

  • Clause-②: no (narrowing) and Metadata-protocol: narrowed appear line-initial in both the PR body and the changeset body. narrowed is the right kind ("a value refused or a requirement tightened"): an author's knowledge_source save that main accepts is refused. no is right: no published export or schema moves (check:api-surface unchanged per the green Lint families).
  • Level: @objectstack/metadata-core minor satisfies "a kind takes at least minor on a package the diff moves"; @objectstack/objectql patch (a log sentence) and @objectstack/spec patch (one upgrade-guide entry) are right for what those packages publish. packages/rest and packages/runtime change comments only and carry no line; nothing they publish moves except through the metadata-core dependency.
  • BREAKING banner, the ! title, the FROM to TO mapping and exactly one ADR-0087 marker (registered knowledge-source-save-refused-without-knowledge-service) are present, and the id matches the entry. Both Check Changeset runs and Lint & Repo Gates are green on this head.

③ Boundary flags

  • Open question (both dev reports, PR body): keep the package duplicate door refused? Answer: A, keep it, as pushed. It is a non-system save of the same item through the one predicate; the ruling's rule sentence reads "at each door that saves one", and its reasoning (ADR-0078 §1) applies to the copy equally; a carve-out needs a new input on an exported function, which the ruling did not order. ESCALATED all the same, because the ruling's parenthesis enumerates three doors and this is a fourth: the refusal blocks the duplicate of a whole package (objects, pages, flows) because it holds one source, and the PR body's maintainer summary does not name it. The Tier H approval is where it is decided; the approver should read the "Open question" section before approving. Not a finding against this head.
  • Dev flag, two door-level isSystem cases dropped: accepted. Inbound HTTP carries no isSystem; the hold is pinned at the predicate, with the resolver asserted never called.
  • Dev flag, five collateral suites now mount an admitting knowledge service: accepted. Each harness change is confined to the knowledge name and keeps the branded not-registered miss for every other name.
  • Dev flag, dogfood battery NOT MEASURED locally: answered by the check-run Dogfood Regression Gate, success on this head.
  • Dev flag, positive live control with requires: ['knowledge'] NOT MEASURED: accepted; the admitted path is unchanged code, pinned by the CONTROL cases, and Test Core 1 to 10 are green.
  • Deviations (commit trailers, a throwaway dev-server session token printed to a transcript and the server stopped): no contract effect; noted, nothing owed here.
  • security_findings: none in both reports: this review found none either. The fail direction stays closed; no accept is widened.
  • SQL push-down: no query, no id materialisation and no in-app join is added anywhere in the diff.
  • Author: user.login is objectstack-fleet[bot]; no relay bypass.
  • Tier: ruling item 3 fixes the landing as Tier H by authorised approval. This record does not replace that approval.

④ Design judgment

No must-fix, no should-fix.

Hits file, 19.knowledge-source-save-refused-without-knowledge-service.ts, against ruling D and its first consumer (the upgrade guide, os migrate meta TODOs):

  • Notice-only with no conversionIds is correct: no key or value of the item changes, and the repair is the deployment's composition, so there is no D2 rewrite to judge. The shape matches SemanticMigration (id, surface, replacement, reason, acceptanceCriteria).
  • replacement and reason agree with the code sentence by sentence: 503 SERVICE_UNAVAILABLE, nothing written, system writes held, a host-registered service answering for its own sources, stored items neither rewritten nor refused at boot (the boot path in knowledge-source-unserved.ts only warns).
  • The remedy is real: platform-capabilities.ts lists knowledge as a requested token that mounts the service and the deployment's store, and KnowledgeServicePlugin registers under the name the doors resolve (KNOWLEDGE_SERVICE, 'knowledge').
  • N1 (nit) — surface, acceptanceCriteria and the changeset's FROM line describe the affected deployment as one whose stack "does not declare requires: ['knowledge']". Since knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306 a stack that ships a knowledgeSources entry also mounts the service (mountedBy: { collection: 'knowledgeSources' }), and saves there are accepted. The entry over-includes that deployment; following it there adds a redundant token and breaks nothing. Accepted deviation, or a follow-up docs-face card.

Implementing files, against the ruling:

  • knowledge-source-save-admission.ts: holds. Order of checks is type, isSystem, resolve (throw answers the pre-existing unavailable 503), absent service (new refusal), member check, verdict. The message names the item, the reason and the remedy in the ruled order (token, restart, save) and does not say "try again". The module doc's claim that the knowledge service answers the same code for a store that is not mounted is true (UNMOUNTED_ADAPTER_CODE is SERVICE_UNAVAILABLE, status 503). Tried to break: an unnamed or non-object item (handled, pinned); null service (handled, pinned); a resolver that throws (unchanged path).
  • N2 (nit) — code choice. errors.zod.ts glosses SERVICE_UNAVAILABLE as "temporarily unavailable", and this condition lasts until the stack changes. The ruling left the code open ("a coded refusal (ADR-0112)"), the knowledge service already uses the same code for the same kind of composition fact, and no door needs a new mapping. Accepted deviation.
  • N3 (nit) — on the dispatcher transport and the duplicate door resolveServiceOrLoud also answers undefined for the no-instance-in-scope classification, which would be told "this deployment runs no knowledge service". The platform plugin registers a plain instance (ctx.registerService), so the platform's service cannot reach that state; a host that registers a scoped knowledge factory answering nothing for a scope could. Follow-up card at most.
  • knowledge-source-unserved.ts: holds. The line names the same remedy as the refusal (ruling item 2) and keeps "or remove the item(s)". The module doc's account of where such items come from (a system write after boot, or a save made before the refusal) agrees with the predicate.
  • meta-item-write-routes.ts, rest-server.ts, meta.ts, mcp-authoring.ts: comment-only hunks, each true of the code beside it. REST resolveKnowledgeService answers undefined on no provider and on the branded not-registered miss, and rethrows anything else. N4 (nit) — the reworded jsdoc on OpenAuthoringWriter.itemSaveRefusal ("..., or on a deployment with no knowledge service, or undefined ...") no longer parses as a sentence.
  • N5 (nit) — through the duplicate door the predicate's sentence is appended verbatim, so a caller duplicating a package is told to "save the source again" and that "Nothing was written" after "nothing was copied". Wording only.
  • Tests: the new pins assert code, status, reason, ordered remedy and zero writes at the predicate, REST PUT (branded miss and no provider), dispatcher PUT (real kernel and a double), MCP draft save and the duplicate; the host-mounted accept is pinned at each door. The suites that mount an admitting service do so to stay on their own subject and say so.

Observation outside the diff, not graded: POST /meta/:type/:name/publish and /rollback (meta-item-history-routes.ts) write an item without asking this predicate, as on main. After this change no new draft of a source can be created on a no-service deployment, so the residue is rows that predate the refusal, which the boot line names. A follow-up card can decide whether those doors ask too.

Implemented-by: claude/area-o1C-37983
Reviewed-by: session_016WV4czzx9dtSEm3jWWL9c3

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

L1 review — REWORK (dogfood battery only); merits accepted

Head: 33acf12ec4b1c5a7d50fe55b99864f867d9e1812 (card #37983, ruling D 7220511579)

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 503 SERVICE_UNAVAILABLE through, and each door is pinned with its code, status, remedy and zero writes. The boot line names the same remedy. The declarations, levels and ADR-0087 entry 19 agree with the diff. All 62 check-runs on the head are green, with 12 skipped by design.

The l1-face changeset flag is answered. The @objectstack/rest and @objectstack/runtime hunks change comments only and no behavior, so they owe no entry, and Check Changeset is green.

REWORK — one item. The title carries ! and the body declares Clause-②: no (narrowing), so the full dogfood battery is owed on this head and recorded under dogfood_battery. That has not happened yet.

  • The report says the local battery is NOT MEASURED.
  • Dogfood Regression Gate shows success on this head, but its job reads OS_DOGFOOD_RESULT: skipped and OS_VERIFY_RESULT: skipped. The three shards and Dogfood Verify CLI did not run on the PR; they run in the merge queue.
  • So no run of the battery is pinned to this head.

To close it, run the full battery on 33acf12ec4 and record it. If the head does not move and the battery is green, the merits acceptance stands and no delta read is owed. A red result that needs a fix moves the head, and the moved head needs a delta read.

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 itemSaveRefusal jsdoc no longer parses; N5 a duplicating caller is told to save the source again. A second follow-up candidate, outside the diff: the meta publish and rollback routes write an item without asking the predicate. The same is true on main.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

knowledge: what a knowledge_source saved at run time does on a deployment that mounted no knowledge service (split from #37306 item 4)

2 participants