Skip to content

Commit 614b9b5

Browse files
fix(cloud-connection)!: install-local parses manifest.namespace through its declaration (#34316)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbTGhxJSYAmQXU7efVdNqrpw)_ Fixes #33922 Clause-②: no (narrowing) Metadata-protocol: none (the declaration `ManifestSchema.shape.namespace` already refuses these values; this door now enforces it. The dev confirms against the diff.) Skills-docs: follow-up #34370 (`content/docs/deployment/publish-and-preview.mdx` names the namespace refusal beside the id; L1 6909138595 N1) ## 维护者速读 - 改了什么:本地安装入口 `POST /api/v1/marketplace/install-local` 现在按清单声明校验 `namespace`,与它已经校验 `id` 的方式一致。 - 为什么改:`''`、`QA_N`、`9-Bad Ns!` 这类作者根本写不出来的命名空间能装进来,`QA_N` 还能绕过 `qa_n` 已有主人的命名空间唯一性检查。 - 风险与回滚:只收紧这一扇门;不写 `namespace` 的包照常安装,已装的旧包照常加载和卸载。回滚即撤销本 PR 一个提交区间。 - 先看:`packages/cloud-connection/src/marketplace-install-local-plugin.ts` 中 `namespaceRefusal` 与步骤 1b″;再看新测试 `marketplace-install-local-namespace-gate-33922.test.ts`。 - 两分钟验证:`pnpm --filter @objectstack/cloud-connection exec vitest run src/marketplace-install-local-namespace-gate-33922.test.ts`,预期 15 条全绿。 - 需要你做的:无,席位落地。 ## What changes - The install-local door parses the package's `namespace` through its declaration, `ManifestSchema.shape.namespace` (`NAMESPACE_PATTERN`), by reference, right after the id gate and at the same converged point of the inline and cloud branches. It reads the top-level `manifest.namespace` of the body this door hands `manifest.register` (after `normalizeBundle` flattens a compiled bundle), which is the key registration reads: `registerApp` installs the package under that key of that same body. It does not read through the nested-manifest helper `declaredPackageManifest`, because on a body that still carries a nested `manifest` after the flatten, that helper answers about a namespace nothing installs under. - A refused value answers `PLUGIN_MANIFEST_INVALID` with the id gate's status split: `400` for a caller's inline manifest, `502` for an upstream snapshot (the grant path's inline manifest included). Nothing is registered, synced or ledgered. The message uses the frame the door already uses for an invalid `installModes`, with the declaration's own sentence inside it: ``Package 'ID' declares an invalid `namespace`: SENTENCE.`` No code and no wording is minted. - An absent `namespace` is admitted, because the declaration makes the key optional. - Rehydrate and the `:manifestId` routes are not gated, for the id gate's reason. An entry an older build ledgered under such a namespace still loads at boot and can still be removed. - BREAKING (patch, `Clause-②: no (narrowing)`): the changeset carries the FROM/TO lines and the ADR-0087 disposition `not-required (no-migration-prescription)`. ## Tests New file `packages/cloud-connection/src/marketplace-install-local-namespace-gate-33922.test.ts`, 15 cases: - `''`, `'QA_N'`, `'9-Bad Ns!'` and a non-string value, on a flat inline manifest: `400` in the declared ADR-0112 envelope (`BaseResponseSchema`, `envelopeViolations`, `ApiErrorSchema`), code `PLUGIN_MANIFEST_INVALID`. The message contains the declaration's sentence, read from the schema at test time and never copied. No `manifest.register`, no `syncSchemas`, no ledger file. - A compiled bundle whose nested `manifest.namespace` is `QA_N`: the same `400`. - A cloud snapshot declaring `QA_N`: `502`, after exactly one fetch. - The body registration reads: a body that still carries a nested `manifest` after the flatten, with a conforming nested `namespace` (`qa_ok`) and `QA_N` at its top level. It gets the `400` inline and the `502` from a snapshot (after exactly one fetch), with nothing written, and over the real engine below the registry holds nothing under `QA_N`. These three cases are red when the gate reads through the nested-manifest helper instead (the ablation below). - Lit controls: a conforming namespace installs, an absent one installs, and a conforming multi-package artifact installs. - UNMOVED: an artifact member declaring `QA_N` keeps the artifact-entry parse's refusal (`INVALID_ARTIFACT_PACKAGE_ENTRY`, 422), and nothing is written. - Over a real `ObjectKernel` + `ObjectQLPlugin`, with `com.qa.n-one` owning `qa_n`: `QA_N` gets the `400`. The registry does not hold it, `getNamespaceOwners('qa_n')` is still the owner alone, and the ledger holds only the owner. CONTROL: `qa_n` beside that owner still gets the registry's own namespace refusal (`422 PLUGIN_REGISTER_FAILED`, naming the owner). The gate's comparison needed no change. ## Acceptance notes - PM hypothesis 1 held in part. The id leg's code and status split are reused, but its message is not: the id leg's sentence (`manifestIdRefusal`) names the key and the value, while the namespace declaration's sentence names neither. So the refusal uses the door's existing `installModes` frame around the declaration's sentence. - Hypothesis 2 held: `namespace` is `.optional()` in `ManifestSchema`, and absence installs (pinned). - Hypothesis 3: every install-local install (HTTP POST and the grant door's `installForGrant`) goes through `handleInstall`, so one leg covers them all. The members of a multi-package artifact were measured to be already judged: each `packages[]` entry is parsed whole through `ArtifactPackageSchema` (the core's `resolveArtifactPackageOrder`, reached through `unrunnableCode` before any write), and it throws `INVALID_ARTIFACT_PACKAGE_ENTRY` / 422 for the same namespace. A first draft of this PR added a second judge for members, and the ablation showed that it moved an existing answer without closing any gap, so it was removed. The member case is pinned as unmoved. - Hypothesis 4 held: the registry gate's comparison is unchanged (the CONTROL case above). - Not in this diff: `POST /api/v1/packages` (`packages/runtime`) is another door and outside the claim's surface. Nothing was measured or changed there. ## Verification All readings below were taken at head `1c648e29e2`, the merge of `origin/main` `d5e6b2028e` into `6d8f7954b2`, unless a line names another head. The merge was clean and needed no regeneration (no deferred generated artifact). Main had changed `marketplace-install-local-plugin.ts` again in this window (#34418 and #34428, the composed-bundle uninstall and the per-body translations and global uniques), and the PR's own diff against main is unchanged line for line: the same 3 files, +443/-0, only the hunk offsets moved. <details><summary>Dogfood battery (full, the narrowing arm): green at 1c648e2</summary> Build first: `pnpm --workspace-concurrency=2 --filter '@objectstack/dogfood^...' build` under the lock, `VERDICT command-exit 0`. Then, with `DOGFOOD_HEAD` printed as `1c648e29e24ff5e51867dfefcd5c1b0fd067cf87` before and after the run and a clean working tree, `pnpm --filter @objectstack/dogfood test` under `scripts/pm/os-verify-lock.sh` with `NODE_OPTIONS=--max-old-space-size=4096` and no `OS_TEST_SHARD`: ```text Test Files 476 passed | 3 skipped (479) Tests 4022 passed | 44 skipped (4066) os-verify-lock: VERDICT command-exit 0 · held the lock 1871s (31m11s) ``` One run, no failures. The file that went red once in the previous round (`activation-ledger-package-key.dogfood.test.ts`) was green in this run. </details> <details><summary>Package suite, typecheck and the pin file: green</summary> Under the lock at `1c648e29e2`, after the `@objectstack/cloud-connection^...` closure build (`VERDICT command-exit 0`), each exit captured before any pipe: ```text pnpm --filter @objectstack/cloud-connection build && test && typecheck VERDICT command-exit 0 test Test Files 87 passed (87) Tests 1273 passed (1273) typecheck (tsc --noEmit && tsc --noEmit -p tsconfig.test.json) pnpm --filter @objectstack/cloud-connection exec vitest run --maxWorkers=2 src/marketplace-install-local-namespace-gate-33922.test.ts exit 0 Test Files 1 passed (1) Tests 15 passed (15) ``` </details> <details><summary>Ablations: not re-run at this head (NOT MEASURED, and why)</summary> NOT MEASURED at `1c648e29e2`. The reason: the merge moved none of the PR's lines, and an ablation is a one-time proof of the tested behaviour, which this round does not change. The two readings stand at the heads they were taken on. - At `ceaa9449c5` (`scripts/ablation-replace.mjs`, the anchor `const refusal = namespaceRefusal(manifest, manifestId);` swapped for `const refusal: string | null = null;`): `ok mutation landed: anchor 1 -> 0, blob 5062243 -> 88b4a29b2be8`, then `Tests 7 failed | 5 passed (12)`, then `ok restored: blob == HEAD (5062243) and git diff HEAD is empty`. The 5 that stayed green were the three lit controls, the UNMOVED member pin and the `qa_n` CONTROL. - At `efb9823b32` (the gate's read swapped back to the nested-manifest helper): `ok mutation landed: anchor 1 -> 0, blob 84bcb35 -> 3af50423a8a2`, then `Tests 3 failed | 12 passed (15)`. The 3 red cases were exactly the three body-registration-reads pins (`expected 200 to be 400` twice, `expected 200 to be 502` once). Then `ok restored: blob == HEAD (84bcb35) and git diff HEAD is empty`. </details> <details><summary>Derived gate families (dispatch-gates): 71 of 71 run, all exit 0</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at `1c648e29e2` (merge base `d5e6b2028`, the same 3 paths) derived 71 families. They ran unlocked in sequence. Two first answered PREREQUISITE NOT MET (exit 3, nothing measured) and were re-run: `pnpm check:type-check-debt` had queued behind the dogfood battery and timed out on the lock, so it ran again under the lock (`VERDICT command-exit 0`, `0 ledger entr(ies) re-measured`, `0 raw tsc error(s)`); `pnpm check:dual-build-cjs-loads` had found packages with no `dist/`, so it ran again after that gate's full `packages/*` build (exit 0, `124 published require entry point(s) across 72 package(s) load`). The `--ran` reconciliation over a record carrying each final exit code: `71 derived, 71 run, 0 NOT-MEASURED, 0 UNRUN` (exit 0). The repo-wide `pnpm lint` is CI's: `Lint · ESLint` succeeded on this head. </details> <details><summary>CI on this head: in progress when this body was written</summary> At the time of writing, `1c648e29e2` read 21 success, 16 skipped, 0 failure, and 11 still in progress (`Test Core` 1/8 to 7/8, the `Type Check` workspace, consumer and debt lanes, and `Lint · repo & tooling gates`). Among the successes are `Build Core`, `Test Core` 8/8, `Governed Surface Queue Guard`, `Live E2E UI`, `Test UI`, `Dogfood Regression Gate`, `Check Changeset`, `Lint · ESLint` and the PR-body guards. The final CI verdict is the PR's checks tab, not this line. </details> Session: `session_01QsR2jTEivi2wogPpeo3xd5` (domain:server#5, os-dev sub-agent), through head `efb9823b32`. Pre-landing rounds (main merges at `6d8f7954b2` and `1c648e29e2`, readings on each new head, this body): area o1-C of seat repo:objectstack#1, `session_01FEkQ5kgF3mo9f7LXuv5hac`, os-dev sub-agent. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent a0056d8 commit 614b9b5

3 files changed

Lines changed: 443 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/cloud-connection': patch
3+
---
4+
5+
fix(cloud-connection)!: `POST /api/v1/marketplace/install-local` parses the manifest `namespace` through its declaration, as it already parses the id
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none (the declaration `ManifestSchema.shape.namespace` already refuses these values; this door now enforces it. The dev confirms against the diff.)
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export changes shape. The install door now refuses a namespace `ManifestSchema.shape.namespace` already refuses everywhere else, `defineStack` and `objectstack build` included; no stored row, ledger entry or authored value is rewritten (an entry an older build ledgered still rehydrates), so there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
**BREAKING** for a caller of the install-local door whose package declares a `namespace` the manifest declaration refuses: anything but 2–20 characters of lowercase letters, digits and `_` opening with a lowercase letter.
13+
14+
- FROM: an inline manifest declaring `namespace: ''`, `'QA_N'` or `'9-Bad Ns!'` answered `200`, was registered and ledgered under that namespace, and `QA_N` installed beside an existing owner of `qa_n` without the install-time namespace gate answering. TO: it answers `400 PLUGIN_MANIFEST_INVALID` with the declaration's own sentence and nothing is registered, synced or written.
15+
- FROM: an inline manifest declaring `namespace: null` or a non-string `namespace` was admitted, the key unparsed (a `null` read as no namespace). TO: it answers the same `400 PLUGIN_MANIFEST_INVALID`; only an absent key means no namespace.
16+
- FROM: a cloud-fetched snapshot declaring such a namespace installed the same way. TO: it answers `502 PLUGIN_MANIFEST_INVALID`, the status the door already gives an invalid upstream snapshot.
17+
18+
**Not moved.** A manifest whose `namespace` key is absent installs as before (the key is optional). A member of a multi-package artifact declaring such a namespace keeps the artifact-entry refusal it already had (`INVALID_ARTIFACT_PACKAGE_ENTRY`, 422). A conforming namespace installs as before, and one another package owns still meets the registry's own namespace gate. A package an older build already installed under such a namespace still rehydrates at boot and can still be uninstalled; it cannot be re-installed until its namespace conforms.
19+
20+
The fix for a caller: declare the namespace in lowercase snake form (`qa_n`, not `QA_N`), or omit it.

0 commit comments

Comments
 (0)