Repository navigation
Commit 2becfd6
fix(cloud-connection): uninstalling a composed app through install-local uninstalls every package body it installed (#34418)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
Fixes #34396
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:install-local 卸载一个组合包(一个 `type: app` 包加若干 `type: module`
包,ADR-0130 D4)时,按"安装时的同一个单元"卸载:安装登记的每个子包都会被撤下,扩展了其他子包对象的模块先撤,被扩展的应用后撤。
- **为什么改**:某个模块用 `objectExtensions` 扩展了应用自己的对象时,卸载应用返回 409
要求"先卸载模块",但模块没有自己的安装记录(404),包接口又把它当只读(422),结果什么都删不掉,只能去主机上删缓存文件再重启。
- **风险与回滚**:低。单包安装的卸载路径不变(原有 withdrawal 测试与新增对照测试钉住);来自另一次安装的扩展依旧被 409
拒绝且不动任何东西。回滚即 revert 本 PR。
-
**先看**:`packages/cloud-connection/src/marketplace-install-local-plugin.ts`
的 `planUnitWithdrawal` 与 `handleUninstall`
中逐成员撤下的那段;`marketplace-install-local-composed-uninstall.test.ts`。
- **两分钟验证**:`pnpm --filter @objectstack/cloud-connection exec vitest run
src/marketplace-install-local-composed-uninstall.test.ts`,预期 8
条全过;把插件文件换回 main 版本再跑,预期 4 条以 409 RESOURCE_CONFLICT 失败。
- **需要你做的**:无,席位落地。
## What changes
`DELETE /api/v1/marketplace/install-local/:manifestId` now uninstalls
the unit the install entry installed.
- **The unit.** The ledger entry's stored body is read the way the
rehydrate reads it. A `packages[]` artifact yields every member id, in
the reverse of the install's dependency order (`orderHydrationBatch`). A
single-package entry yields its own id alone, so that path is unchanged.
- **The decision, before anything moves.** The registry's one predicate,
`assertPackageUninstallable`, is asked of every member while the whole
unit is still registered. A new pure helper, `planUnitWithdrawal`, reads
each refusal's `extenders` and `customizationPackageId`:
- If every cause is another member of the same unit, the refusal sets
the order instead of refusing: those members are withdrawn first, so
extending modules go before the package they extend.
- A cause outside the unit refuses the whole uninstall with the
registry's own `409 RESOURCE_CONFLICT` sentence, as before. That
includes a package of a different install and a pair this install did
not deliver. So does a refusal that carries no readable causes, and a
cycle of members that extend each other.
- **The withdrawal.** For each member, in the planned order, the door
captures the declared permission names and then withdraws the member,
all synchronously with no `await` after the ledger removal. Then it
withdraws each withdrawn member's object copies, restores the copies its
extensions rewrote, and runs each member's uninstall cleanups under its
own package id. Artifact handlers are unbound once, under the entry's
id, which is where the install bound them. The `metadata:reloaded`
re-sync is announced once, and only when at least one member was
withdrawn. The `package_uninstall` ledger row is written once for the
entry.
- The uninstall guards (`runUninstallGuards`) are asked of every member,
not only the entry's id.
- The response shape is unchanged. `cleanups` holds the outcomes of
every member, in order.
No `packages/objectql` file changed: the registry's predicate and its
refusal fields are read as they are. The claim's file surface allowed
the split registry modules, and none needed an edit.
## Tests
New
`packages/cloud-connection/src/marketplace-install-local-composed-uninstall.test.ts`
runs on a real `ObjectKernel` with `ObjectQLPlugin`. It installs through
the door, then uninstalls.
- Reporter's doors: the module's own `DELETE` answers `404
RESOURCE_NOT_FOUND`, and `isWritablePackage` answers false for it. That
predicate is the one behind the package door's `422
WRITABLE_PACKAGE_REQUIRED`. Both stay true after the fix, by design.
- The composed uninstall answers 200, withdraws all three members with
the module before the app, and leaves no contributor on the app's
object.
- The module goes first even when the artifact lists it ahead of the
app. Here the base order puts the app first, so this case exercises the
planner.
- A reinstall after the uninstall registers the unit again.
- An extension from a different install: the uninstall answers `409
RESOURCE_CONFLICT` naming that package, and nothing of the unit moves.
The control: after that install is uninstalled, the unit's uninstall
answers 200.
- A single-package install withdraws only itself. A single package
extended by another install still gets the registry's 409.
<details><summary>Red leg (plugin at the merged main parent cfcba53)
and green leg, HEAD c965590</summary>
- Red: `Tests 4 failed | 4 passed (8)`. Each failure is the reporter's
refusal: `{"code":"RESOURCE_CONFLICT","message":"Uninstall the package
that extends an object of \"com.probe.suite\" first
(com.probe.suite.carbon), then uninstall \"com.probe.suite\" again: ...
(objectExtensions, ADR-0029). ..."}: expected 409 to be 200`.
- The mutation was proven on disk: the file hash equalled `cfcba53920:`
+ path, and `planUnitWithdrawal` occurred 0 times. The restore went
through `git checkout HEAD --`, was proven by an empty `git diff HEAD`,
and the hash matched the HEAD blob.
- Green: `Test Files 1 passed (1) · Tests 8 passed (8)`.
- Whole package, `pnpm --filter @objectstack/cloud-connection test`:
`Test Files 84 passed (84) · Tests 1235 passed (1235)`. This includes
the existing `marketplace-install-local-uninstall-withdrawal.test.ts`
pins of the single-package order and the 409.
- `pnpm --filter @objectstack/cloud-connection typecheck`: exit 0.
`tsconfig.test.json` lists the new test file.
</details>
## Acceptance notes
- **Mixed refusal text.** If a member is extended both by another member
and by a foreign package, the 409 is the registry's sentence for that
member, so it also names the same-unit module among the packages to
uninstall first. The decision is right (refused), but that part of the
prescription has no door of its own. The sentence is the registry's, and
this PR leaves it untouched.
- **Same-unit dependent rules.** The uninstall guards are asked per
member and cannot tell a same-unit dependent from a foreign one. Suppose
a member's field, added through `objectExtensions`, is read by an active
validation rule of another member of the same artifact. The runtime's
dependent-rule guard would then refuse that member's uninstall. Not
measured on a real artifact. The reporter's shape (a module adding
fields to the app's objects) does not hit it.
- **Partial withdrawal note.** The pre-check refuses everything the
registry would refuse. A withdrawal that still throws for some other
cause leaves that member registered, and the response `note` speaks of
"the package". The operator log names the members that were withdrawn.
- **Overlaps.** Before the PR, `git merge-tree` ran against the open PRs
that touch `marketplace-install-local-plugin.ts`: #34403
(`claude/issue-34336-composed-bundle-seeds`) and #34316
(`claude/area-A5-33922`). Both merged with no conflict.
## Verification
Local subset, at HEAD c965590. The CI-owned farm is read from this
PR's check-runs.
- `pnpm --filter '@objectstack/cloud-connection^...' build` (the
dependency closure) ran under `os-verify-lock.sh` and ended with
`VERDICT command-exit 0`.
- The gate families `dispatch-gates.mjs --commands` derived for this
diff: 71 derived, 70 run at exit 0, and `--ran` reconciles `71 derived,
70 run, 0 NOT-MEASURED, 1 UNRUN`.
- The unrun family is `pnpm check:dual-build-cjs-loads`, NOT MEASURED
locally: `PREREQUISITE NOT MET — this gate reads built output, and some
package has no dist/` (39 packages unbuilt in this worktree). CI's `Lint
& Repo Gates` runs it.
- No exported symbol was renamed or deleted, so
`check-platform-checklist --changed-from` is not owed.
- No full dogfood run is owed: the title has no `!` and no `(narrowing)`
arm.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5pHNFS9mn8hS13iGyL)_
<!-- signed: repo:objectstack#1 · os-project-manager ·
session_01FEkQ5pHNFS9mn8hS13iGyL -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8c6ddc5 commit 2becfd6
3 files changed
Lines changed: 475 additions & 29 deletions
File tree
- .changeset
- packages/cloud-connection/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
0 commit comments