You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fa30414
Browse filesBrowse the repository at this point in the historyBrowse files
fix(metadata-protocol)!: an unmanaged rename refuses a package without namespace whose object names all share a prefix other than the derived one (#36138)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X7DBJdArz6UfcraENi1dMpg)_Fixes#35823
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: updated here — the refusal row in
content/docs/deployment/install-modes.mdx; no skills/** file teaches the
unmanaged rename (git grep targetNamespace under skills: 0 hits)
## 维护者速读
-
用户能看到什么变化:把未声明命名空间的软件包以副本方式装进新命名空间时,若它的对象名全都带着同一个别的前缀,安装会被拒绝并说清两个前缀,不再生成带双重前缀的副本。
- 为什么做:云端发布快照曾丢掉命名空间,副本里同一个应用出现三种拼法且无任何提示,属于数据静默出错。
- 出错会怎样:只影响带新命名空间的副本安装,拒绝发生在写入前,什么都不会装;声明了命名空间的包、只有一个对象或对象名没有共同前缀的包照旧安装。
- 要你做什么:这次改动让原来能装的一类请求改为拒绝(收紧),按规则需要你本人批准后才能合并。
## What changes
`planUnmanagedImport`
(`packages/metadata-protocol/src/package-unmanaged-install.ts`) derives
the source namespace from the package id when the body declares no
`namespace`. On the rename path (a `targetNamespace` different from that
namespace) the rename engine trusted the guess: an object name without
the derived prefix takes the target prefix in front of its whole name. A
name that carries the producer's real prefix (`demoasset_asset`, under
an id that derives `asset_lifecycle_b`) was copied as
`trialdemoasset_demoasset_asset`, while its view `demoasset_asset_all`
kept its name.
Now, on the rename path of a body that declares no `namespace`, the copy
is judged by its object names' COMMON prefix (the card's signal; seat
reading 7066371354 after L1 R1): when there are at least two objects,
none carries the derived prefix, and every object name begins with the
same first segment, the copy is refused through the existing rename
refusal: `400 INVALID_REQUEST`, one `details.refused` entry per object,
each reason naming the derived namespace, the common prefix and the
missing `namespace` key, and asking to declare it (no namespace value is
suggested). No new error code, no new `details` key; the refusal comes
before the base exists, so nothing is written. Object names only
(ADR-0129 D2 puts the namespace on object names): the gallery package
this came from names its flows, datasets, reports and skills without the
prefix, and translation items are named by the planner.
Unchanged, and pinned as controls:
- a body that declares `namespace` is renamed exactly as before,
whatever its names look like (`namespace: 'other'` with `demoasset_*`
objects still copies as `trialdemoasset_demoasset_*`; this control reds
when the declared-namespace gate is removed);
- a multi-segment unprefixed name keeps ADR-0048 §3.5's amended rename:
`purchase_order` copies as `trialdemoasset_purchase_order`, alone or
beside `asset_owner` (no common first segment);
- a single-object package, bare one-segment names, and any package with
an object carrying the derived prefix keep the rename;
- without a `targetNamespace` nothing changes: the save door's prefix
rule already refuses these names (`422 NAMESPACE_PREFIX`, rolled back,
nothing kept), measured on main 30b0987.
The refusal row is added to the rename table in
`content/docs/deployment/install-modes.mdx` (file surface widened by the
seat for that one row).
Read first, by risk:
1. `package-unmanaged-install.ts`, `derivedNamespaceContradiction` and
its one call before the rename loop: the rule that decides what is
refused.
2. `package-unmanaged-install.test.ts`, the describe block `a namespace
derived from the id, contradicted by the object names' common prefix`:
the pins and the controls.
3. The changeset: the BREAKING sentence and the ADR-0087 disposition.
## Why
Data silently wrong: one copied app held three spellings of one
package's names, with no refusal (card #35823, found on
objectstack-ai/cloud#4856 whose publish snapshot dropped
`manifest.namespace`; the cloud side is fixed there). Loud over lenient:
a derived namespace the names contradict is refused, never renamed.
## Tests
- `pnpm --filter @objectstack/metadata-protocol exec vitest run
--maxWorkers=2 src/package-unmanaged-install.test.ts`: 105/105 passed (8
cases in the new block).
- Ablations on the committed round (a7b3062), on-disk mutation by
`scripts/ablation-replace.mjs`, each trap-restored with `git diff HEAD`
empty and the HEAD blob hash matched after:
- the common-prefix refusal made a no-op (blob 0944eee ->
cb234f9d5ba6) => 2 failed / 103 passed: the refusal naming both, and the
verb's zero-write refusal;
- the declared-namespace gate forced open (blob 0944eee ->
d0bfa966ec7f) => 1 failed / 104 passed: the declared-`namespace` control
(contract review S2).
- The tests import the module from `src/`, so no build is in the path.
## Acceptance notes
- The common prefix is the first `_` segment. Two objects sharing a
short first word (`purchase_order`, `purchase_item`) in a namespace-less
package are refused too, and declaring `namespace` clears it; the docs
row says so.
- The no-`targetNamespace` path keeps its existing `422
NAMESPACE_PREFIX` answer (base created then rolled back) rather than a
plan-time `400`; aligning the two would change an existing answer and is
not this card's.
- filed #36166 — the silent cases the set-level signal leaves (contract
review 7066464020, boundary flag ③): a single-object package with a
foreign prefix, one stray object beside the prefixed ones, and a
declared `namespace` the object names contradict still copy
double-prefixed; plus the dated ADR-0048 §3.5 note for the
`purchase_order` + `purchase_item` refusal.
## Verification
Two-minute check: run the test file above; the describe block `a
namespace derived from the id, contradicted by the object names' common
prefix — refused, never double-prefixed` passes, 8 cases.
Round 1 (head ca5b93e, the per-name rule): CI all green or skipped,
95/95 derived gates exit 0, full dogfood battery green (PR comment
7066311396). This round's head is re-verified the same way and declared
in a PR comment when the runs finish.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [ ] 3. No formatter ran; `pnpm lint` passes. (no formatter ran; `pnpm
lint` is CI's run, read from its check-run)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5nwb5fUkxg7Q9NVxvR)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01FEkQ5nwb5fUkxg7Q9NVxvR
<!-- signed: repo:objectstack#4 · os-project-manager ·
session_01FEkQ5krBqrrgxCYgjXmfbv -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(metadata-protocol)!: an unmanaged install renamed into a `targetNamespace` refuses a package that declares no namespace when its object names all share a prefix other than the derived one, instead of copying them under a second prefix
6
+
7
+
Clause-②: no (narrowing)
8
+
Metadata-protocol: none
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. What moves is the answer the unmanaged install gives one request: a package body with no `namespace`, renamed into a `targetNamespace`, whose object names all begin with one first word that is not the namespace derived from its id. No stored row, registry key or authored value changes, so there is nothing for a migration to rewrite and no tombstone. -->
11
+
12
+
**BREAKING** for a caller of the unmanaged install (`importUnmanagedPackage`, and `POST /api/v1/marketplace/install-local` with `installMode: 'unmanaged'`) that sends a `targetNamespace` with a package body that declares no `namespace`.
13
+
14
+
Such a body's namespace is derived from its id (`ai.objectstack.gallery.asset-lifecycle-b` derives `asset_lifecycle_b`), and the rename trusted it: an object named `demoasset_asset`, which carries its real prefix, was copied into `trialdemoasset` as `trialdemoasset_demoasset_asset`, while its view `demoasset_asset_all` kept its name, so one copy held three spellings and nothing said why. Now, when such a body has two or more objects, none carries the derived prefix, and every object name begins with the same first word (`demoasset_`), the copy is refused before the base exists: `400 INVALID_REQUEST`, with one rename-refusal `details.refused` entry per object naming the derived namespace, the common prefix and the missing `namespace` key. Nothing is installed. Two objects sharing a short first word (`purchase_order`, `purchase_item`) are refused the same way, and declaring `namespace` clears it.
15
+
16
+
A body that declares `namespace` is renamed exactly as before, whatever its names look like. In a namespace-less body, every other case keeps the rename: a single object, objects with no common first word (`purchase_order` beside `asset_owner`), or any object carrying the derived prefix each take the target prefix in front of a name that lacks it (`purchase_order` copies as `trialdemoasset_purchase_order`). Without a `targetNamespace` nothing changes: the save door's prefix rule already refuses those names (`422 NAMESPACE_PREFIX`).
17
+
18
+
The fix is in the package: declare `namespace` on it, the prefix its object names carry, then install again.
Copy file name to clipboardExpand all lines: content/docs/deployment/install-modes.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -267,6 +267,7 @@ refusal is answered before the base exists, so nothing is installed:
267
267
|:---|:---|
268
268
| A `targetNamespace` the namespace rule refuses, or a shared one |`400 INVALID_REQUEST`, naming `targetNamespace`|
269
269
| An object whose copy name another object's copy takes (`ticket` beside `crm_ticket`) |`400 INVALID_REQUEST`, naming the object and the rename that clears it |
270
+
| A package that declares no `namespace`, with two or more objects whose names all begin with the same first word, not the namespace derived from the package id (`demoasset_asset` and `demoasset_site` in `com.acme.asset-lifecycle`, which derives `asset_lifecycle`; `purchase_order` and `purchase_item` too) |`400 INVALID_REQUEST`, naming each object, the derived namespace and the common prefix; declaring `namespace` on the package clears it |
270
271
| A copy name that is not a legal item name, longer than an object's table name may be (63 characters), or longer than an item name may be (255) |`400 INVALID_REQUEST`, naming each item |
271
272
| A renamed key that meets a key the item already holds (a permission set granting both `crm_lead` and `acme_lead`) |`400 INVALID_REQUEST`, naming the item and both keys |
272
273
| A capability whose copy name another capability of the package declares (`crm.approve` beside `acme.approve`) |`400 INVALID_REQUEST`, naming the capability |
0 commit comments