Repository navigation
fix(metadata-protocol, runtime)!: refuse navigationContributions on a package created at runtime - #30707
Conversation
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz2siW3GknVnPzUXgd
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz2siW3GknVnPzUXgd
…fusal at the door's import Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz2siW3GknVnPzUXgd
📓 Docs Drift CheckThis PR changes 2 package(s): 5 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 33 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 483539c78981a4423207511856e0dbc1e7bbca5d && git checkout 483539c78981a4423207511856e0dbc1e7bbca5d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 4bf9a2d7eeeec7c07971aba1a8734c227acaaa3a 10809d6bc19064085c0d62fcd6fa1297baef697d && git checkout -B drift-repro 4bf9a2d7eeeec7c07971aba1a8734c227acaaa3a && git merge --no-ff 10809d6bc19064085c0d62fcd6fa1297baef697d
node scripts/docs-audit/affected-docs.mjs --json 4bf9a2d7eeeec7c07971aba1a8734c227acaaa3a
|
|
domain:server#1 · os-elon-musk · session_016WV4cytLmJxfAmgPVjUbbW Contract-review-claim: session_016WV4cytLmJxfAmgPVjUbbW · head 10809d6 · 2026-11-05T22:57Z |
|
domain:server#1 · os-elon-musk · session_016WV4cytLmJxfAmgPVjUbbW Contract reviewServed-tier: Independent review of the tree at the head above against ① Derived judgments
② Semver levelChangeset bumps ③ Boundary flags
④ Design judgment
Should-fix, non-blocking:
Implemented-by: VERDICT: PASS |
|
domain:server#1 · os-elon-musk · session_016WV4cytLmJxfAmgPVjUbbW 席位核对 · ACCEPT · 2026-11-05T23:24Z · #30072Head-sha: 10809d6
|
Requested by Elon · project thread
Fixes #30072
Clause-②: yes (narrowing) —
POST /api/v1/packages(both install limbs, the no-protocol fallback included) and the protocol install primitiveinstallPackage(so the package duplicate and every in-process caller too) refuse a manifest whosenavigationContributionsis a non-empty list with400 VALIDATION_ERROR, where they stored it and answered201before. Widened:@objectstack/metadata-protocolpublishes one new export,runtimeNavigationContributionsRefusal, the predicate both doors ask (the shapecustomizationPairManifestRefusalalready has).Metadata-protocol: narrowed
Skills-docs: follow-up #30711
维护者速读
POST /api/v1/packages)如果带navigationContributions,现在直接拒绝(400),不再存下来;代码包的菜单贡献照旧生效。sys_packages的旧包照常加载(其菜单本来就不生效)。示例与 HotCRM 只在代码包里用这个键,不受影响。回滚即还原本 PR。packages/metadata-protocol/src/protocol-package-install.ts(判定函数与原语里的调用点)、packages/runtime/src/domains/packages.ts(入口在两条安装分支之前、409 之前询问)、packages/runtime/src/domains/packages-install-navigation-contributions.test.ts。pnpm --filter @objectstack/runtime exec vitest run src/domains/packages-install-navigation-contributions.test.ts,预期 10 个用例全过(两条分支各 5 个:拒绝、裸清单拒绝、先于 409、无键或空数组放行、代码包贡献照常)。What changes
runtimeNavigationContributionsRefusal(manifest)(new,protocol-package-install.ts, exported from the package entry):undefinedwhen the manifest carries nonavigationContributionsor an empty list; otherwise the refusal sentence. It names the key and the package, and both routes that work: an override of the app in its customization package for a customer's own menu (ADR-0146 D2, what Studio's navigation editor writes), and a code package for a contribution into another package's app.installPackage) asks it right after the whole-manifest declaration parse, so a malformed manifest keeps the declaration's located answer, and before every write and every server-state read. It throws withstatusCode: 400, which an HTTP boundary answers asVALIDATION_ERROR. Every caller passes here: the HTTP door's composed limb,duplicatePackage(a base stored with the key before this change is now refused on duplicate, by the rethrow rule that refuses a duplicate whose record is refused), and an embedder.POST /api/v1/packagesasks the same predicate after the whole-body verdict and ahead of the duplicate-id409, so both install limbs are judged (the no-protocol fallback writes the registry directly and never reaches the primitive) and the answer does not depend on whether the id is installed.id,version, whole body, customization pair) all answer400 VALIDATION_ERROR. Nothing inpackages/specmoves.Why
On
mainthe runtime door storednavigationContributionsand answered201, but onlyObjectQL.registerApp(the door a code package takes at boot, from the marketplace or on an artifact reload) registers contributions.SchemaRegistry.installPackage, which the runtime install and thesys_packagesreplay at boot both use, registers none, so the entry never appeared, not after a restart either. The maintainer ruled option A on the card (record 6631177389), verbatim: 「…其他全部同意」 — refuse the key loudly and name the working routes.Doors enumerated. Every runtime door that stores a manifest:
POST /api/v1/packages(both limbs) and the protocol primitive (with its in-process callers:duplicatePackage,ensureCustomizationPackage, which builds its own manifest without the key, and the unmanaged install's base, which carries identity keys only and whose plan already refusesnavigationContributionsas422 UNMANAGED_INSTALL_UNCOPYABLE).PATCH /api/v1/packages/:idaccepts onlyname,description,versionanddependencies, so it never stores the key. Marketplace installs and code packages go throughregisterApp, which registers contributions, and are untouched.ADR-0087 disposition:
not-required (no-migration-prescription), in the changeset. No key of any schema is added, removed or renamed;ManifestSchema.navigationContributionskeeps its shape and meaning for code packages. A refused contribution never reached any app's navigation, so there is no rewrite that keeps what the author meant: the author takes one of the two routes the refusal names. First-party users of the key, measured:examples/app-multi-package(ordersmodule) and HotCRM (its artifact modules) use it only in code packages, which register throughregisterApp; the platform's own users (Setup capability plugins,cloud-connection,mcp,plugin-approvals) are code packages too. Rows already insys_packagesare data at rest and replay as stored.Tests
packages/metadata-protocol/src/protocol.install-navigation-contributions.test.ts: the primitive refuses (envelope400/VALIDATION_ERRORviaresolveThrownHttpError, neither the registry write nor the durablepublishran); the sentence's first clause and the two routes; a malformed manifest keeps the declaration's answer first; lit controls (no key, empty list) install.packages/runtime/src/domains/packages-install-navigation-contributions.test.ts, on both the composed and the no-protocol arm, over a realObjectQLengine and protocol: refusal with the ADR-0112 envelope (code,status,ApiErrorSchemaparse) and nothing stored (GETanswers404); the bare-manifest body form; refused ahead of the409; lit controls; and a code package's contribution registered throughregisterAppis still served and untouched by the refusal.Ablation, one per guarded behaviour, through
scripts/ablation-replace.mjs(anchor hit 1 → 0, blob changed, restored to theHEADblob with an emptygit diff HEAD; both suites import the source, so nodist/leg):navRefusal !== undefined→&& false) turned the runtime suite red,5 failed | 5 passed: all four fallback-arm refusal cases, plus the composed arm's "ahead of the 409" case (the 409 answers first without it).1 failed | 3 passed: the refusal case.Acceptance notes
navigationContributions: []installs: it promises nothing and registers nothing.POST /api/v1/packageswithoverwrite: true);PATCHcannot remove a manifest key. The refusal on duplicate is the same sentence.Verification
All at head
10809d6b, after the@objectstack/runtime^...closure build (plus@objectstack/driver-turso, whichruntime's test typecheck reads).Package tests and typecheck
pnpm --filter @objectstack/metadata-protocol test: exit 0,Test Files 318 passed | 4 skipped (322),Tests 22458 passed | 26 skipped.pnpm --filter @objectstack/runtime test: exit 0,Test Files 545 passed (545),Tests 8718 passed | 19 skipped.pnpm --filter @objectstack/metadata-protocol typecheck: exit 0.pnpm --filter @objectstack/runtime typecheck: exit 0 (a first run exited 1 onTS2307 @objectstack/driver-tursoin an untouched test file because that package'sdistwas not built; rebuilt, exit 0).Derived gate families (dispatch-gates)
node scripts/pm/dispatch-gates.mjs --ran: 60 derived families accounted for, 59 run green, 1 NOT MEASURED:pnpm check:dual-build-cjs-loadsexited 3 (PREREQUISITE NOT MET: it needs a whole-tree build); CI'sLint & Repo Gatesruns it.node scripts/check-plugin-teardown-shape.mjs --self-testfirst exited 3 on the shallow clone, and exited 0 after fetching its pinned fixture commit.pnpm lint: exit 0.check-adr-0087-registration --base origin/main: exit 0, the changeset carriesnot-required (no-migration-prescription).check-changeset-no-major --base origin/main: exit 0.Dogfood battery (owed by the narrowing arm)
pnpm --filter @objectstack/dogfood testunder the verify lock, after the@objectstack/dogfood^...closure build:VERDICT command-exit 0,Test Files 421 passed | 3 skipped (424),Tests 3513 passed | 36 skipped (3549), no failures.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cz2siW3GknVnPzUXgd
Generated by Claude Code