Repository navigation
feat(runtime): export resolveArtifactCollections, the reader of every collection of a composed suite - #32928
Conversation
… collection of a composed suite
A `composeStacks(stacks, { manifest: 'preserve' })` artifact keeps each
collection in its package's body; the runtime's own merge across the
flattened top level and every `packages[]` body (ADR-0130 D4) is now
importable from `@objectstack/runtime`, so an app reads its suite without
a flat composition or a copy of the merge.
Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cxVtcSKjKVFjVEV46E
…rtion, not a TypeError Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cxVtcSKjKVFjVEV46E
…ollections reader Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cxVtcSKjKVFjVEV46E
… consumer pin Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cxVtcSKjKVFjVEV46E
📓 Docs Drift Check
What this run could not see
Coarse fallback — 29 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
|
domain:server#8 · os-elon-musk · session_016WV4cwqTK71kjQzHae8T5J Contract reviewServed-tier: Face: ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#8 · os-elon-musk · session_016WV4cwqTK71kjQzHae8T5J Contract reviewServed-tier: Head moved only by a merge of Face: ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#8 · os-elon-musk · session_016WV4cwqTK71kjQzHae8T5J ACCEPT · PR #32928 · head 席位核对
|
Requested by Elon · project thread
Fixes #32827
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
@objectstack/runtime新导出一个函数resolveArtifactCollections,它把「按包保留」方式组合出来的套件里,每个包各自的对象、应用、流程、翻译、钩子等合成一份完整视图。函数本身早已存在、启动时就在用,这次只是公开出来,没有新逻辑。resolveArtifactCollections(composeStacks(包列表, { manifest: 'preserve' })),不用在应用里自己抄一份合并逻辑。packages[]的产物原样返回);回滚即撤回index.ts的一行导出。packages/runtime/src/index.ts新增的导出行;②packages/runtime/src/artifact-collections.public-reader.test.ts(从包入口导入,对比扁平组合的内容);③artifact-collections.ts的文档注释。pnpm --filter @objectstack/runtime exec vitest run src/artifact-collections.public-reader.test.ts,预期 1 个文件 2 个用例全绿。What changes
packages/runtime/src/index.ts: exportsresolveArtifactCollectionsfrom./artifact-collections.js. One export line; the merge itself is the existing one the boot paths read (app-plugin.ts,load-artifact-bundle.ts,standalone-stack.ts,app-artifact-handlers.ts,resolve-project-database.ts). No second copy.packages/runtime/src/artifact-collections.ts: docblock only.resolveArtifactCollectionsgains a "Public reader" section that teaches the consumer use,resolveArtifactCollections(composeStacks(packageStacks, { manifest: 'preserve' })), and says why a flat composition is not the route (it puts every package's app under one package id, whichSTACK_SINGLE_APP_VIOLATIONrefuses for a suite, ADR-0019 D3 as amended). The note onpackageOwnedCollectionKeysthat said neither function is importable from@objectstack/runtimeis corrected: that one stays module scope.packages/runtime/src/artifact-collections.public-reader.test.ts(new): the consumer-side pin. Amanifest: 'preserve'composition of oneapppackage and twomodulepackages, read through the reader imported from the package entry (./index), yields every input's objects, apps, flows, translations and hooks with the contents a flat composition gave. It also pins that the entry's export IS the module's function (no second copy)..changeset/runtime-export-artifact-collections-reader.md:@objectstack/runtimepatch, both declaration lines.Tests
artifact-collections.test.ts: 2 files, 24 tests passed.pnpm --filter @objectstack/runtime test: 589 files passed, 10253 tests passed, 19 skipped (run at merge head f58a4da; the later commit only adds one side-effect import to the new test file, re-run green).pnpm --filter @objectstack/runtime run typecheck(includescheck:test-typecheck): exit 0.scripts/ablation-replace.mjs, restore proved by blob == HEAD and an emptygit diff HEAD; the test resolves the source entry, so no dist leg):index.ts: both new tests red.if (declared === undefined || 'ABLATED_MERGE') return artifact;): the consumer test red,objects: expected [] to deeply equal [ Array(3) ]; the identity test stays green.claude/project-thread-2eliu6applied (git applyof its three-dot spec diff) and@objectstack/specrebuilt, both reader files stay green (24/24), while a flat composition of anappand amodulepackage with one app each is refusedSTACK_SINGLE_APP_VIOLATION422 on that build. The pin's flat baseline is taken without the apps for exactly this reason. Tree restored and spec rebuilt from this branch afterwards.pnpm --filter @objectstack/runtime build:node -e "const m=require('./dist/index.cjs');console.log('cjs', typeof m.resolveArtifactCollections)"printscjs function.node --input-type=module -e "const m=await import('./dist/index.js');console.log('esm', typeof m.resolveArtifactCollections)"printsesm function.grep -c resolveArtifactCollections dist/index.d.ts dist/index.d.ctsprints5for each.Acceptance notes
check:api-surfaceis apackages/specgate (packages/spec/api-surface/*.json);@objectstack/runtimehas no api-surface baseline, so there is nothing to regenerate for this export.content/docs/**page documents this reader today, so no docs edit.test/helpers/composed-stack.tsmoves to the preserve composition plus this reader in the hotcrm lane, after the@objectstack/*bump that carries this export.Verification
Local gates at head 3a3fc0b (merge of origin/main at f58a4da), file
gates-ran-3a3fc0b8.txt:dispatch-gates --ran: 60 derived, 58 run, 2 NOT MEASURED
node scripts/pm/dispatch-gates.mjs --ran FILE: exit 0,60 derived famil(ies) accounted for — 58 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3).node scripts/check-plugin-teardown-shape.mjs --self-test: its fixture is pinned to a commit a shallow clone cannot reach (the gate asks forgit fetch --unshallow origin main).pnpm check:dual-build-cjs-loads: it reads built output and 41 packages had nodist/(only the runtime dependency closure was built). The runtime's own CJS and ESM entries were probed by hand instead, output under Tests.check:test-source-aliaswas red once at f58a4da: the entry import reaches@objectstack/metadatathrough a dynamic import inside a clocked case. Fixed per the gate's prescription with a module-topimport '@objectstack/metadata';(the convention other runtime tests follow); re-run exit 0, with the test-file-reading gates (nul-bytes,cross-package-test-inputs,registry-log-declared,rest-log-spy-declared,refd-timer-probe,type-check-debt,logger-receiver-detach,tier-file-adoption,undeclared-dep-imports), all exit 0.pnpm lintexit 0;check:authz-resolver,check:changeset-fixed,check:error-code-casing,check:filter-alias-parity,check:route-ledger-censusexit 0.Dogfood battery: n/a (no
!in the title, no(narrowing)arm).Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cxVtcSKjKVFjVEV46E