Repository navigation
fix(service-knowledge): the knowledge-source save door names an absent object or field as such - #38465
fix(service-knowledge): the knowledge-source save door names an absent object or field as such#38465objectstack-fleet[bot] wants to merge 4 commits into
Conversation
…wledge-source reference Claude-Session: https://claude.ai/code/session_016WV4d13AraSmVmgVtCvkWk Co-authored-by: Claude <noreply@anthropic.com>
…t object or field as such A knowledge_source naming no object, or a content / metadataFields member naming no field of its object, is refused 400 VALIDATION_ERROR with the os validate rule names, ahead of every permission arm, decided from the object's registered definition alone. Claude-Session: https://claude.ai/code/session_016WV4d13AraSmVmgVtCvkWk Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d13AraSmVmgVtCvkWk Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d13AraSmVmgVtCvkWk Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 4 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 68751642f8deb7a8b7b73771b7b77f43d144bae3 && git checkout 68751642f8deb7a8b7b73771b7b77f43d144bae3
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f459c863e37c0a31656c6cc471323f92659fff18 cf125c960904f666a895a6f2e797a98d838b1ed7 && git checkout -B drift-repro f459c863e37c0a31656c6cc471323f92659fff18 && git merge --no-ff cf125c960904f666a895a6f2e797a98d838b1ed7
node scripts/docs-audit/affected-docs.mjs --json f459c863e37c0a31656c6cc471323f92659fff18
|
|
repo:objectstack#1 · os-elon-musk · session_016WV4d13AraSmVmgVtCvkWk 席位核对ACCEPT at head cf125c9 (L1, repo:objectstack#1, read by the dispatching seat; first round, no REWORK).
|
|
repo:objectstack#1 · os-elon-musk · session_016WV4d13AraSmVmgVtCvkWk Landing · ACCEPT → PR #38465 comment 7250429083
State: ready + auto-merge now; on MERGED #38419 closes by |
Fixes #38419
Clause-②: no
Metadata-protocol: none
维护者速读
os validate相同的规则名。What changes
KnowledgeService.admitAuthoredSource(the save-time admission every knowledge-source save door asks:PUT /meta/knowledge_source/:name, the runtime/metadoor, the MCP draft save, and the package duplicate) gains a "does not exist" arm ahead of every permission arm (ADR-0161 K4, row 4):source.objectnames no object the registry defines ⇒400 VALIDATION_ERROR, naming the object and the ruleknowledge-source-object-unknown.source.content/source.contentFields/source.metadataFieldsmember names neither a declared field noridor a system column the registry injects (resolveInjectedSystemColumns, the derivationos validateuses) ⇒400 VALIDATION_ERROR, naming the object, the field (fieldon the verdict) and the ruleknowledge-source-field-unknown.Before this PR, with a platform-like security service, the same saves answered
503 SERVICE_UNAVAILABLE"... could not be judged ... try again" (absent object),403"is a system object that does not opt into AI reads" (absentsys_object), and403"you may not query field ... hidden from you" (absent field). With no security service they were admitted.The arm reads the object's registered definition only. It never reads a permission answer. Every door that asks this verdict admits only a
manage_metadataholder, and ADR-0106 D4 serves that caller every object definition whole. So the arm tells the author nothing they could not already read. It draws no verdict for an engine with no schema registry, for an object of a disabled package (that gate still answers it), or for an object whose fields cannot be enumerated. A registry that throws keeps the503, reported once. No new error code:VALIDATION_ERRORis the code this method already answers for an unmounted adapter.The refusal is worded for the door, as the other arms are: the duplicate's caller is told the source cannot be copied, then to duplicate the package again.
Read first
packages/services/service-knowledge/src/knowledge-service.ts,absentSourceReference: the riskiest hunk is the three early returns (nogetSchema, disabled package, no field map). Each one keeps a case that exists from being read as absent.packages/services/service-knowledge/src/knowledge-service.ts,admitAuthoredSource, the new block after the engine check: its position decides which arm wins.packages/services/service-knowledge/src/__tests__/knowledge-source-save-absent-reference.test.ts, theno permission answer changes for an object or a field that existsblock, which holds the full answers taken on the base.Two-minute verification
pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2 src/__tests__/knowledge-source-save-absent-reference.test.ts. Expect 15 passed. Restoreknowledge-service.tsfrom0c1b2ffeand the same command shows 7 failed and 8 passed: the absent references answer 503 / 403, and every pin for what exists still passes.Tests
New file: knowledge-source-save-absent-reference.test.ts (15 cases)
sys_object, with and without a security service:VALIDATION_ERROR/400,objectset, nofield, message carriesknowledge-source-object-unknown, never "could not be judged", "try again", "does not opt into AI reads" or "may not query". The engine's own write (isSystem) is admitted.content,metadataFieldsand retiredcontentFieldsmember, for a member and a manager, with and without a security service:VALIDATION_ERROR/400,object+field, message carriesknowledge-source-field-unknown.id,created_at,owner_id(not declared, injected) are admitted.door: duplicate: same status, code, object and field as the save, worded for the duplicate.toEqual, sentences taken from the base: hidden field (403),sys_object withoutenable.aiReadable(403), security service that answers neither question (503), disabled package with and without a served definition (403), registry that throws (503, logged once), engine with no schema registry (admitted).Red on the base, green on the head
Base
knowledge-service.ts(0c1b2ffe), head test file:Head
cf125c96, afterpnpm turbo run build --filter='@objectstack/service-knowledge...' --concurrency=2(20/20):Acceptance notes
wherereads are not checked for existence here.os validatedoes not check them either (validate-knowledge-source.tscheckscontentandmetadataFieldsonly), so no rule name exists for them. Measured oncf125c96: awherenaming an absent field answers403 PERMISSION_DENIED"which you may not query (it is hidden from you ...)" when a security service is mounted, and is admitted when none is. Reported to the seat to file; not changed here.objectstack-aiskill saysos validateand publish check the two rules. That is still true. It does not mention the save door, and this PR leavesskills/**untouched.admitSources) is untouched by this PR. Only the save-time verdict changes.Verification
Local derived gates at cf125c9 (dispatch-gates --commands, 71 commands)
Each derived command ran on head
cf125c96(after mergingorigin/mainat1afd9c13), exit captured before any pipe:The other 69 commands exit 0, among them
check:nul-bytes,check:doc-authoring,check:issue-citations,check:published-files,check:type-check-coverage,check:type-check-debt,check:undeclared-dep-imports,check:engine-double-contract,check:error-status-conformance,check:adr-0087-registration --base origin/mainandcheck:empty-changeset --base origin/main. Every family CI runs beyond these is read from this PR's check-runs, not re-run locally.Generated by Claude Code