Repository navigation
fix(cloud-connection): install-local connects a composed bundle's package-body datasources and judges their names - #34633
Conversation
…undle's package-body datasources Step 2a, the 4b′ connect (install and upgrade) and the kernel:ready rehydrate read datasources and objects through resolveStackCollection, so a composed bundle hands connectPackageDatasources every package body's datasources and objects in package order, and a body's datasource name is judged against held names before any write. The install answer's credentialRefs read every body's connectors the same way. The dead top-level array i18n read in applySideEffects is removed. Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz Co-authored-by: Claude <noreply@anthropic.com>
…tasource reads Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz Co-authored-by: Claude <noreply@anthropic.com>
…path reads it Claude-Session: https://claude.ai/code/session_01ADHkmRXuRn93HphKp7kXEz Co-authored-by: Claude <noreply@anthropic.com>
…mposed-bundle-datasources
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 7 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 c9aab2fc696f33febd74e011c2d2ffe9142b9f80 && git checkout c9aab2fc696f33febd74e011c2d2ffe9142b9f80
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 082f9c2945260fd9b29951caff1c49f6dccab4ea 1edc890930f3a50cb7331138404cbba4f8858426 && git checkout -B drift-repro 082f9c2945260fd9b29951caff1c49f6dccab4ea && git merge --no-ff 1edc890930f3a50cb7331138404cbba4f8858426
node scripts/docs-audit/affected-docs.mjs --json 082f9c2945260fd9b29951caff1c49f6dccab4ea
|
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Clause-② call on the dev's open question (os-dev report, card #34431): The one input that moves is a composed bundle whose package body declares a datasource name another holder already owns: |
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Final head for review: |
|
repo:objectstack#2 · os-steve · session_01ADHkmTHGRTjPqZAcBuo9WH 席位核对L1 first review · ACCEPT · head The one moved answer, and why
|
|
repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz Landing
No other open PR touches |
Fixes #34431
Clause-②: no
Metadata-protocol: none
维护者速读
packages[])每个子包里的声明;安装前的数据源重名检查(2a)也读子包。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.jsonwithpackages[], ADR-0130 D4) every package-owned collection sits in the package bodies, and the top level carries none.MarketplaceInstallLocalPluginread three of them from the top level only:declaredDatasources). This is the one reader for step 2a (findHeldDatasourceName), the 4b′ connect of an install or an upgrade, and thekernel:readyrehydrate (connectDeclaredDatasources). It now reads throughresolveStackCollection(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 whosedatasourcesis not a list (measured below).connectPackageDatasources.connectDeclaredDatasourcesreadmanifest.objects. It now readsresolveStackCollection(manifest, 'objects').describeInstalledCredentialRefs, the install answer'scredentialRefs). 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
packagesthe resolver refuses is answered at 2a with that refusal (declaredRefusalAnswer, the reader 2b and 2c″ share): its own422and code, and nothing is written. An undeclared throw is still rethrown.connectDeclaredDatasourceskeeps its contract that it never throws. A read failure there is logged aterrorand 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, theruntime.package-datasourcesuninstall cleanup anddatasourceNameHolderkey on.Cleanup:
applySideEffectsno longer reads a top-level arrayi18nas extra translation bundles. In the speci18nisTranslationConfigSchema(an object), no producer in this repository writes an array there, and the boot path (AppPlugin) never read one.Changeset:
@objectstack/cloud-connectionpatch.Tests
The new pins are two top-level
describes in the existing harness filepackages/cloud-connection/src/marketplace-install-local-composed-top-level-reads.test.ts. That file drives the realPOST /api/v1/marketplace/install-localroute handler and thekernel:readyrehydrate. Its@objectstack/runtimemock now also carriesconnectPackageDatasources, which captures the datasource names, object names, owners and theinstalledflag, anddatasourceNameHolder, which answersfreeunless a case marks a name held. The boot also has anautomationservice whose credential listing is empty. No existing assertion changed.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 isdatasources: [{erp_db, connected}, {wms_db, connected}].datasourcesandcredentialRefs.credentialRefsnamesERP_TOKENandWMS_TOKENfrom the two bodies' connectors.datasourcesandobjectsconnects that union once, not once more per package.409 RESOURCE_CONFLICTwithdetails.datasourceset. No ledger entry is written and nothing is connected. Control: the flat bundle declaring the same name answers the same.Red first: base 8dd8192, same test file, plugin as on main
Tests 6 failed | 10 passed (16). The four connect pins receiveddatasources: [](andobjects: []).credentialRefswasundefined. The composed 2a case answered200with nodatasourcesfield. 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' }withoutconfigwas refused422 INVALID_ARTIFACT_PACKAGE_ENTRY(manifest.datasources.0.config: expected record): package bodies are parsed by the entry schema. The fixtures carryconfig: {}.Ablation, one leg per behaviour (scripts/ablation-replace.mjs, at commit 31e95a8)
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 off8405743f5ad9. Every restore reportedblob after restore == blob at HEAD (8405743f5ad9)and an emptygit diff HEAD.return resolveStackCollection(artifact, 'datasources');→ top-level array only):Tests 5 failed | 11 passed (16). Failed: install, composed-vs-flat, upgrade, rehydrate, composed 2a.resolveStackCollection(manifest, 'objects')→manifest.objects):4 failed | 12 passed. Failed: install, composed-vs-flat, upgrade, rehydrate.resolveStackCollection(converted, 'connectors')→converted.connectors):2 failed | 14 passed. Failed: composed-vs-flat, credentialRefs.throw err), run withmarketplace-install-local-resolver-refusal-34432.test.ts:3 failed | 18 passed (21). Both install-local: an artifact the resolver refuses answers 503 "retry once the database answers" instead of the resolver's 422 #34432422pins and theisolatedrefusal 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
objectsdeclaration was retypedany[]to satisfytsc(commit eaade30). The ablated line itself is unchanged.Acceptance notes
datasourceNameHolderreports held answered200. 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'sClause-②: nois copied above unchanged. The report puts the reading to the seat with the options: keepno(a runtime gate the door already declares applied to bodies it skipped, no schema acceptance changed) or declareno (narrowing).422 INVALID_ARTIFACT_PACKAGES/INVALID_ARTIFACT_PACKAGE_ENTRY) therefore get the same bytes from 2a'sdeclaredRefusalAnswerbefore 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.declaredDatasourcesnever deduplicated a flat list). The runtime judges the pair as it does today. No pin was added for it.INVALID_ARTIFACT_PACKAGE_ENTRY422, "manifest.datasources: expected array, received object".resolveStackCollectionreads 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.describe, so the pins went intomarketplace-install-local-composed-top-level-reads.test.ts, the install-local: composed artifacts read package-owned collections from the top level only (translationsLoaded 0; global-unique gate sees no objects) #34407 harness for this same family.Verification
Package suite and typecheck
After building the closure (
pnpm --filter '@objectstack/cloud-connection^...' build, lockVERDICT command-exit 0), at eaade30:pnpm --filter @objectstack/cloud-connection typecheck: exit 0, both programs.tsconfig.test.json --listFilesincludes the harness file.pnpm --filter @objectstack/cloud-connection exec vitest run --maxWorkers=2:Test Files 89 passed (89),Tests 1303 passed (1303), lockVERDICT command-exit 0.Derived gates at 1edc890 (after merging origin/main ffa6db1)
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-loadsfirst answered exit 3 (PREREQUISITE NOT MET, nodist/). It was re-run green after a whole-workspace build (turbo run build --filter=!@objectstack/docs --concurrency=2, lockVERDICT command-exit 0):124 published require entry point(s) across 72 package(s) load.Full dogfood: not owed, since there is no
!in the title and no(narrowing)arm.Generated by Claude Code