Repository navigation
Commit ecf6a5f
fix(cloud-connection): install-local connects a composed bundle's package-body datasources and judges their names (#34633)
Fixes #34431
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:install-local
安装、升级和重启回灌时,数据源(datasources)、对象(objects)和连接器(connectors)改为与样例数据、翻译相同的读法,读到组合包(`packages[]`)每个子包里的声明;安装前的数据源重名检查(2a)也读子包。
- 为什么改:组合包顶层没有这三类列表。装上返回
200,但子包声明的外部数据源从不注册、不连接,绑在上面的对象无处读写;安装结果里也不列数据源和待配置的凭据;子包数据源与已有数据源重名也不拦。
- 风险与回滚:低。平铺包、以及仍带顶层合并列表的组合包读法不变,有对照测试钉住。行为变化一处:子包声明了他人已持有的数据源名的组合包,以前装上
200,现在与平铺包一样 409(见 Acceptance notes)。回滚即 revert 本 PR。
- 先看:`packages/cloud-connection/src/marketplace-install-local-plugin.ts`
的 `declaredDatasources`、2a 调用处新增的 try/catch、`connectDeclaredDatasources`
开头的读取块;再看 `marketplace-install-local-composed-top-level-reads.test.ts`
末尾两个新 describe。
- 两分钟验证:`pnpm --filter @objectstack/cloud-connection exec vitest run
src/marketplace-install-local-composed-top-level-reads.test.ts`,预期 16
个用例全绿(其中 8 个新用例)。
- 需要你做的:无,席位落地。
## What changes
On a composed bundle (`dist/objectstack.json` with `packages[]`,
ADR-0130 D4) every package-owned collection sits in the package bodies,
and the top level carries none. `MarketplaceInstallLocalPlugin` read
three of them from the top level only:
1. **Datasources** (`declaredDatasources`). This is the one reader for
step 2a (`findHeldDatasourceName`), the 4b′ connect of an install or an
upgrade, and the `kernel:ready` rehydrate
(`connectDeclaredDatasources`). It now reads through
`resolveStackCollection(artifact, 'datasources')`. The map form (keyed
by name) is still read at the top level, where a flat bundle may carry
it. A package body cannot carry it, because the resolver refuses a body
whose `datasources` is not a list (measured below).
2. **Objects handed to `connectPackageDatasources`.**
`connectDeclaredDatasources` read `manifest.objects`. It now reads
`resolveStackCollection(manifest, 'objects')`.
3. **Connectors** (`describeInstalledCredentialRefs`, the install
answer's `credentialRefs`). The card listed this as code-read only. It
reproduced in the same harness, so it is fixed here:
`resolveStackCollection(converted, 'connectors')`.
All three now read the way the seed datasets (#34403) and the
translations (#34407) already do: the top-level list when the body
carries one (a flat bundle, or a composed artifact that still carries
its flattened union, read once), otherwise every package body's, in
package order.
Step 2a now resolves the package bodies, so a `packages` the resolver
refuses is answered at 2a with that refusal (`declaredRefusalAnswer`,
the reader 2b and 2c″ share): its own `422` and code, and nothing is
written. An undeclared throw is still rethrown.
`connectDeclaredDatasources` keeps its contract that it never throws. A
read failure there is logged at `error` and connects nothing. It is not
expected, because register resolved the same bytes before this step.
Ownership is unchanged. Every datasource is stamped with the install's
`manifestId`, the id that the ledger entry, the
`runtime.package-datasources` uninstall cleanup and
`datasourceNameHolder` key on.
Cleanup: `applySideEffects` no longer reads a top-level array `i18n` as
extra translation bundles. In the spec `i18n` is
`TranslationConfigSchema` (an object), no producer in this repository
writes an array there, and the boot path (`AppPlugin`) never read one.
Changeset: `@objectstack/cloud-connection` patch.
## Tests
The new pins are two top-level `describe`s in the existing harness file
`packages/cloud-connection/src/marketplace-install-local-composed-top-level-reads.test.ts`.
That file drives the real `POST /api/v1/marketplace/install-local` route
handler and the `kernel:ready` rehydrate. Its `@objectstack/runtime`
mock now also carries `connectPackageDatasources`, which captures the
datasource names, object names, owners and the `installed` flag, and
`datasourceNameHolder`, which answers `free` unless a case marks a name
held. The boot also has an `automation` service whose credential listing
is empty. No existing assertion changed.
- The composed install hands `connectPackageDatasources` `[erp_db,
wms_db]` and `[crm_account, crm_order]`, in package order: core first,
although the dependent module is listed first in the array. The answer
is `datasources: [{erp_db, connected}, {wms_db, connected}]`.
- The composed bundle and its flat control (the same declarations at the
top level) hand the runtime equal lists and answer equal `datasources`
and `credentialRefs`.
- An upgrade (2.0.0 → 2.1.0) connects every body's datasources again. A
restart's rehydrate does too, from the ledger.
- `credentialRefs` names `ERP_TOKEN` and `WMS_TOKEN` from the two
bodies' connectors.
- Control: a composed artifact that still carries flattened top-level
`datasources` and `objects` connects that union once, not once more per
package.
- Step 2a: a held name declared in a package body answers `409
RESOURCE_CONFLICT` with `details.datasource` set. No ledger entry is
written and nothing is connected. Control: the flat bundle declaring the
same name answers the same.
<details><summary>Red first: base 8dd8192, same test file, plugin as
on main</summary>
`Tests 6 failed | 10 passed (16)`. The four connect pins received
`datasources: []` (and `objects: []`). `credentialRefs` was `undefined`.
The composed 2a case answered `200` with no `datasources` field. The
flattened-union control and the flat 2a control passed, as did the 8
cases already in the file.
On the way there, an earlier fixture of `{ name, driver: 'memory' }`
without `config` was refused `422 INVALID_ARTIFACT_PACKAGE_ENTRY`
(`manifest.datasources.0.config: expected record`): package bodies are
parsed by the entry schema. The fixtures carry `config: {}`.
</details>
<details><summary>Ablation, one leg per behaviour
(scripts/ablation-replace.mjs, at commit 31e95a8)</summary>
The test imports the plugin by relative path (source, not `dist/`), so
no rebuild sits in the loop. Every leg reported the anchor going 1 → 0
and the blob moving off `8405743f5ad9`. Every restore reported `blob
after restore == blob at HEAD (8405743)` and an empty `git diff
HEAD`.
- Datasources (`return resolveStackCollection(artifact, 'datasources');`
→ top-level array only): `Tests 5 failed | 11 passed (16)`. Failed:
install, composed-vs-flat, upgrade, rehydrate, composed 2a.
- Objects (`resolveStackCollection(manifest, 'objects')` →
`manifest.objects`): `4 failed | 12 passed`. Failed: install,
composed-vs-flat, upgrade, rehydrate.
- Connectors (`resolveStackCollection(converted, 'connectors')` →
`converted.connectors`): `2 failed | 14 passed`. Failed:
composed-vs-flat, credentialRefs.
- 2a refusal guard (catch body → `throw err`), run with
`marketplace-install-local-resolver-refusal-34432.test.ts`: `3 failed |
18 passed (21)`. Both #34432 `422` pins and the `isolated` refusal pin
threw the resolver's error out of the handler. My first attempt at this
leg used a replacement that contained its anchor, so the tool refused it
(anchor x1 → x1) and ran nothing. I re-ran it with a non-overlapping
anchor. The numbers above are from that second run.
After the ablations, the `objects` declaration was retyped `any[]` to
satisfy `tsc` (commit eaade30). The ablated line itself is unchanged.
</details>
## Acceptance notes
- **An input that answered 2xx now refuses (for the seat's Clause-②
reading).** FROM, measured on base 8dd8192 through the route: a
composed bundle whose package body declares a datasource name
`datasourceNameHolder` reports held answered `200`. Its datasource was
never registered or connected. Code-read, not measured: an object bound
to that name would be served by the holder's driver. TO: `409
RESOURCE_CONFLICT`, the answer a flat bundle declaring the same name
already gets, with nothing written. The claim's `Clause-②: no` is copied
above unchanged. The report puts the reading to the seat with the
options: keep `no` (a runtime gate the door already declares applied to
bodies it skipped, no schema acceptance changed) or declare `no
(narrowing)`.
- **Step 2a now resolves the packages first.** On a runtime without the
step-1d code judgements (the harness's mocked runtime), step 2a is now
the first step to resolve a composed artifact's packages. The #34432
pins (`422 INVALID_ARTIFACT_PACKAGES` /
`INVALID_ARTIFACT_PACKAGE_ENTRY`) therefore get the same bytes from 2a's
`declaredRefusalAnswer` before 2c″ is reached. They pass unchanged.
Code-read, not measured: 2c″'s own incoming-side pre-resolution is no
longer the step those pins exercise, so an ablation of that guard alone
would now stay green on them. 2c″ still owns the installed-copy side.
- **Duplicate names across bodies.** These are kept as declared, in
package order, and handed to the runtime path, as a flat bundle's
same-name pair is (`declaredDatasources` never deduplicated a flat
list). The runtime judges the pair as it does today. No pin was added
for it.
- **The map form in a package body** is refused by the resolver,
measured: `INVALID_ARTIFACT_PACKAGE_ENTRY` 422, "manifest.datasources:
expected array, received object". `resolveStackCollection` reads a
top-level map as no list (`[]`), so the helper keeps the top-level map
branch it had. A flat map-form bundle reads exactly as before.
- **Test placement.** The claim's file surface names "one new card-named
test file". AGENTS.md (ruling record 6583487846) puts a new pin for a
component with a shared harness into that file as a top-level
`describe`, so the pins went into
`marketplace-install-local-composed-top-level-reads.test.ts`, the #34407
harness for this same family.
## Verification
<details><summary>Package suite and typecheck</summary>
After building the closure (`pnpm --filter
'@objectstack/cloud-connection^...' build`, lock `VERDICT command-exit
0`), at eaade30:
- `pnpm --filter @objectstack/cloud-connection typecheck`: exit 0, both
programs. `tsconfig.test.json --listFiles` includes the harness file.
- `pnpm --filter @objectstack/cloud-connection exec vitest run
--maxWorkers=2`: `Test Files 89 passed (89)`, `Tests 1303 passed
(1303)`, lock `VERDICT command-exit 0`.
</details>
<details><summary>Derived gates at 1edc890 (after merging origin/main
ffa6db1)</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 3 paths, 71 commands, each run with stdin
closed and its exit captured before any pipe. Reconciliation: `Run
reconciliation — 71 derived, 71 run, 0 NOT-MEASURED, 0 UNRUN.` All 71
exit 0. `check:dual-build-cjs-loads` first answered exit 3 (PREREQUISITE
NOT MET, no `dist/`). It was re-run green after a whole-workspace build
(`turbo run build --filter=!@objectstack/docs --concurrency=2`, lock
`VERDICT command-exit 0`): `124 published require entry point(s) across
72 package(s) load`.
```text
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:cli-command-ids :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:durability-log-level :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:error-status-conformance :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:init-service-contract :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:object-def-param-keys :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:optional-error-sink :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:route-envelope :: exit 0
pnpm check:settings-bind-window :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:startup-registry-verdict :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:vouch-for-reference-callers :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
</details>
Full dogfood: not owed, since there is no `!` in the title and no
`(narrowing)` arm.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c1ec627 commit ecf6a5f
3 files changed
Lines changed: 267 additions & 15 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
25 | 32 | | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
32 | 48 | | |
33 | 49 | | |
34 | 50 | | |
| |||
37 | 53 | | |
38 | 54 | | |
39 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
40 | 67 | | |
41 | 68 | | |
42 | 69 | | |
| |||
132 | 159 | | |
133 | 160 | | |
134 | 161 | | |
| 162 | + | |
| 163 | + | |
135 | 164 | | |
136 | 165 | | |
137 | 166 | | |
| |||
169 | 198 | | |
170 | 199 | | |
171 | 200 | | |
| 201 | + | |
| 202 | + | |
172 | 203 | | |
173 | 204 | | |
174 | 205 | | |
| |||
262 | 293 | | |
263 | 294 | | |
264 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
0 commit comments