Repository navigation
feat(objectql, cli, metadata-protocol, spec, runtime)!: a namespace never equals an object name at every door - #31887
Conversation
…ever equals an object name at every door ADR-0150 D6: every door that makes a namespace or an object live now asks the spec's predicate (findNamespaceObjectNameClashes) and refuses a namespace equal to an object name in either direction, or an object short-named `custom` (NS_custom), naming both spellings: - defineStack: one call beside the namespace-prefix check, over every namespace and object the one artifact holds. - os validate / os build: findNamespaceObjectNameRefusals over the same. - SchemaRegistry.installPackage: NAMESPACE_CONFLICT 422 with clashes[], against every installed namespace and registered object. - Studio object doors (publish-mode save, per-item publish, the publishPackageDrafts pre-flight, the draft verdict): NAMESPACE_CONFLICT 422; the pre-flight audit row spells it namespace_conflict. - POST /packages/:id/publish: judged before MetadataManager.publishPackage, NAMESPACE_CONFLICT 422. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmQv69sQL5nfT8xuPWs
📓 Docs Drift CheckThis PR changes 6 package(s): 37 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 13 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 183 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 45662d2a542d700f904e0593e5cc28468c0e5ae8 && git checkout 45662d2a542d700f904e0593e5cc28468c0e5ae8
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 6a8f4151d53203268a1913dfcde9caf4d547384e 8ef0c16897bc975eb49920df22db292c019f9e45 && git checkout -B drift-repro 6a8f4151d53203268a1913dfcde9caf4d547384e && git merge --no-ff 8ef0c16897bc975eb49920df22db292c019f9e45
node scripts/docs-audit/affected-docs.mjs --json 6a8f4151d53203268a1913dfcde9caf4d547384e
|
|
domain:server#1 · os-steve · session_01ADHkmPF1skfu2kx89BEXZi Contract-review-claim: session_01ADHkmPF1skfu2kx89BEXZi · head 8ef0c16 · 2026-11-09T11:12Z Narrowing face ( |
|
domain:server#1 · os-steve · session_01ADHkmPF1skfu2kx89BEXZi Contract reviewServed-tier: ① Derived judgmentsEvery accept-set and public-surface change the diff implies, judged against the tree, not the PR body.
Doors tried and found closed: boot in either order; nested First-party census (read, not run): 24 distinct ② Semver levelChangeset Nit (prose face): ③ Boundary flagsDev
Dev Card red lines: (1) resolution never loosens — no resolver or fallback touched; (2) ambiguity reported, never guessed — every clash is listed ( Check-runs on the head at render time: 29 concluded, every one success (Check Changeset, Governed Surface Queue Guard, PR-body guards, every Lint family, Type Check source/consumer/debt, Dogfood Regression Gate, Spec property liveness, Live E2E UI, Build Core, Build UI Deps); 0 failed; 13 skipped by design; 25 still in progress (Test Core 1-8, Test UI 1-16, Type Check workspace, Type Check UI). The dispatching seat confirms those conclude green before posting; a red one reopens ③. ④ Design judgmentThe narrowing read against ADR-0150 D6 and row K on main: it makes the spec's own refusal real ("a namespace never equals an object name, refused in both directions at every object door, naming both spellings; no object short-named Findings:
Nits alone: the round ends here. Implemented-by: VERDICT: PASS |
Requested by Steve · project thread
Fixes #31681
ADR-0150 child K (D6, Q3 = A, ruling 6724530715). Claim 6734122356 (
domain:server#1, card-thread session_01ADHkmQv69sQL5nfT8xuPWs).Clause-②: no (narrowing) — measured on head 8ef0c16 (main merged at 97458ba + main), and for base by the ablations below that remove each added call:
defineStack,os validate/os build, the package door (SchemaRegistry.installPackage, soPOST /api/v1/packagestoo), the Studio object doors (publish-mode save, per-item publish,publishPackageDraftspre-flight) andPOST /api/v1/packages/:id/publisheach refuse what they accepted on base: a namespace equal to an object name in either direction, or an object short-namedcustom(NS_custom). Nothing is widened.Metadata-protocol: narrowed
Skills-docs: none —
skills/**does not teach a namespace spelled like an object name, or an object namedNS_custom; the rule ships in the refusal text and in ADR-0150 D6.packages/specexception (seat ruling, option A, 2026-11-09T06:51Z, restated in claim 6734122356): the standard order barspackages/spec/**. The seat granted exactly one call to P'sfindNamespaceObjectNameClashesinstack.zod.ts, besidevalidateNamespacePrefix, plus its test. No schema key, no schema shape change, no second predicate. That is all this PR does there, and the changeset bumps@objectstack/specminor for it.This is a narrowing, so the review of record runs at CONTRACT_REVIEW_TIER.
维护者速读
custom(NS_custom)。规格卡 P 的谓词findNamespaceObjectNameClashes现在接到所有入口:defineStack、os validate/os build、安装门、Studio 的保存 / 单项发布 / 批量发布预检 / 草稿判定,以及POST /packages/:id/publish。双向拒绝,消息里点出两种拼写和两个包。NS-NAME和OBJECT-ACTION,命名空间和对象名相同会让一个地址指向两样东西。谓词已在 P 里,但没有任何入口调用它。registry.ts的refuseNamespaceObjectNameClashes,protocol-save-door-refusals.ts的namespaceObjectNameClashOf(Studio 各门和运行时发布门共用的判定),stack.zod.ts的validateNamespacePrefix(唯一一处规格改动)。pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.namespace-object-name-doors.test.ts,预期 7 passed。runtime的发布门、metadata-core的审计码文档)席位已裁定保留,见文末。What changes
packages/objectql/src/registry.ts:installPackagecalls the new privaterefuseNamespaceObjectNameClashes(manifest, selfId)after N's namespace-name refusal. The incoming package's namespace and objects (its own and itsplugins[]', bydeclaredOwnedObjectNames) are judged against every installed namespace and every registered object whose owner is another package. The package itself is never a second holder. It throwsNamespaceObjectNameConflictError(NAMESPACE_CONFLICT, 422,clashes[], the predicate's sentences).packages/cli/src/utils/namespace-object-names.ts(new):findNamespaceObjectNameRefusals(parsed)walks every namespace and object one artifact holds: eachpackages[]body, plus the stack's own manifest with its top-level objects. It makes one call to the predicate.validate.ts(step 2c-ter) andcompile.ts(step 3a-quater) refuse with it, text and--json. The build-gate parity roster lists it.packages/spec/src/stack.zod.ts:validateNamespacePrefixmakes the one granted predicate call over the same set. Its refusals rideStackNamespacePrefixInvalidError(issuesare the predicate's sentences). No new key, schema or error class.packages/metadata-protocol:protocol-save-door-refusals.tsaddsobjectNamespaceObjectNameClash(the protocol method),namespaceObjectNameClashOf(engine-only) andrefuseNamespaceObjectNameClashes(throwsNAMESPACE_CONFLICT/ 422). They judge one object's name against every installed package's namespace (its own package excluded) and against its own package'sNS_custom.NAMESPACE_PREFIXcheck at the publish-mode save (protocol-save.ts), the per-item publish (protocol-history-and-publish.ts), thepublishPackageDraftspre-flight (protocol.ts, newPreflightViolationCodeNAMESPACE_CONFLICT, audit spellingnamespace_conflict) and the draft verdict (protocol-authoring-gate.ts, ruleNAMESPACE_CONFLICT).refuseNamespaceObjectNameClashesis exported for the runtime door.packages/runtime/src/domains/packages.ts:POST /packages/:id/publishjudges every object the metadata service holds under the package (the membershippublishPackagecollects) beforeMetadataManager.publishPackageruns. It answersNAMESPACE_CONFLICT/ 422 througherrorFromThrown.MetadataManageritself is untouched: it has no manifest, so it cannot name an installed namespace (its own docblock), and its refusals aresuccess: falserows, not a 422. The refusal belongs to the door that holds the registry, asWRITABLE_PACKAGE_REQUIREDdoes.packages/metadata-core/src/objects/sys-metadata-audit.object.ts: doc only. The closed pre-flight code list namesnamespace_conflict.scripts/engine-double-contract.pinned.json: the ledger learns the new test's engine double (--write)..changeset/31681-namespace-object-names.md: minor for spec, objectql, cli, metadata-protocol, metadata-core and runtime. It has both declaration lines, the BREAKING Why / Before / Now / Who moves / Unchanged, the census, the one-line fix (rename the namespace or the object) andadr-0087: not-required (no-migration-prescription).Forced test edits: none. No existing assertion changed.
Step 0 (measured on
maincc16008a)findNamespaceObjectNameClashes(incoming, installed = {}). Equality is exact and case-sensitive. Direction A: each incoming namespace against every object, incoming and installed. Direction B: each incoming object against every installed namespace.custom:object.name === object.namespace + '_custom'. Every door here calls it; none re-spells it.os validate/os build: every namespace and object in the one artifact, plusNS_custom.NS_custom. The other direction there, a new namespace, lands throughinstallPackage(POST /packagesand the authored-package create both reach it).defineStackandos validate/os builddo not judge packages outside the artifact, and never guess a namespace from an id. The install door judges them.ADR-0150's four readings
bare-name-one-holder.tsis untouched, and its tests run inside the objectql suite (580 files / 11870 passed). N's namespace-name tests run there too.crm_lead_notebeside namespacecrm_lead),NS_custom_*, the same package registering again, and an object's own package never counting as a second holder.Clause-②: no (narrowing)above and in the changeset;Metadata-protocol: narrowed;adr-0087: not-required (no-migration-prescription).Verification
Head 8ef0c16 (origin/main merged into 97458ba, no conflicts). Every heavy run went under
os-verify-lock.registry-namespace-object-name.test.ts);os validate/os buildwalk 7 plus the parity roster (42 with the parity file);defineStack7 (stack-namespace-object-name.test.ts); Studio doors 7 (protocol.namespace-object-name-doors.test.ts); runtime doors 5 (package-door-namespace-object-name.test.ts:POST /packageswith a new namespace equal to an object,POST /packages/:id/publishwith an object equal to a namespace, andcustom).custom, with CONTROLs.command-exit 0: spec 828 files / 26135 passed; objectql 581 / 11942 passed; metadata-protocol 331 (+5 skipped) / 22633 passed (29 skipped); cli 619 (+2 skipped) / 7715 passed (10 skipped); runtime 567 / 9164 passed (19 skipped); metadata 71 / 987 passed; metadata-core 27 / 1003 passed; the whole dogfood package 441 (+3 skipped) / 3662 passed (42 skipped).tsc --noEmitpasses for spec, objectql, cli, metadata-protocol, runtime and metadata-core.eslint --no-inline-configpasses on every changed file.dispatch-gates --commandsderived 108 families on the merged head 8ef0c16; all 108 ran, exit 0.--ranreconcile: 108 run, 0 NOT-MEASURED, 0 UNRUN. The first round surfaced three findings, now fixed:check:error-code-provenance(the CLI rows no longer stamp a wire code, and the runtime door throws metadata-protocol's ledgered refusal),check:engine-double-contract(ledger--write), andcheck:test-source-alias(module-top@objectstack/lintimport).check:type-check-debt: 0 entries above their numbers.Ablations (on the committed code, each file restored and checked with
git diff --quiet)registry.ts:this.refuseNamespaceObjectNameClashes(manifest, selfId);replaced byvoid 0;→ 3 of 7 red: both directions andcustominstall.protocol-save.ts: save-door judge forced tonull→ 2 of 7 red: the save refusal and thecustomsave.protocol-history-and-publish.ts: per-item judge forced tonull→ 1 of 7 red: the per-item publish promotes.protocol.ts: pre-flight judge forced tonull→ 1 of 7 red. With two offending drafts, the promotion stops at the first and calls the secondBATCH_ABORTED; the pre-flight names bothNAMESPACE_CONFLICT.protocol-authoring-gate.ts: draft-verdict judge forced tonull→ 1 of 7 red: the draft reads with noNAMESPACE_CONFLICT.runtime/src/domains/packages.ts: the door's refusal call removed → 2 of 5 red: the publish andcustomcases publish (200).stack.zod.ts: the predicate call replaced byvoid findNamespaceObjectNameClashes;→ 5 of 7 red: every refusal; the CONTROLs stay green.validate.ts: the call renamed away → 3 of 35 red in the parity test.compile.tsholds the same call, so the parity roster turns red if either command drops it.Open questions (ruled by the seat)
Surface beyond the claim. The claim names cli, objectql
registry.ts, metadata-protocol and thestack.zod.tswiring. This PR also touches:packages/runtime/src/domains/packages.ts: thePOST /packages/:id/publishdoor. That is whereMetadataManager.publishPackagemakes a package's objects live, and the only place holding the registry.packages/metadata-core/src/objects/sys-metadata-audit.object.ts: doc comment only. It is the closed pre-flight code list thePREFLIGHT_AUDIT_CODErecord points to.Options: A, keep them (as built); B, drop the runtime door and state the bound. Recommendation: A, because without it Studio "全部发布" publishes a clashing object with no refusal. Seat ruling: keep (A).
New pre-flight code
NAMESPACE_CONFLICT/ audit spellingnamespace_conflict. It reuses the install door's ledgered code (listed under@objectstack/metadata-protocolalready) and adds one value to the closed pre-flight set. Recommendation: keep, sinceNAMESPACE_PREFIXnames a different rule. Seat ruling: keep.defineStackheader. A K clash ridesStackNamespacePrefixInvalidError, whose header says "namespace-prefix validation failed" and whose hint is about the prefix. Theissuesand the lines are the predicate's own sentences. A separate error class would be a new spec export, beyond the granted exception. Recommendation: keep. Seat ruling: keep; the message names the clash and both spellings, pinned instack-namespace-object-name.test.ts(err.messagecontains both packages' spellings,issuesequal the predicate's sentences).NamespaceObjectNameConflictError,SchemaRegistry.refuseNamespaceObjectNameClashes(private),findNamespaceObjectNameRefusals,objectNamespaceObjectNameClash,namespaceObjectNameClashOf,refuseNamespaceObjectNameClashes(metadata-protocol export). No new error code.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmQv69sQL5nfT8xuPWs