Skip to content

packages/runtime's vitest alias list omits @objectstack/spec/cloud, so any runtime test that loads a compiled artifact dies with ENOTDIR #9457

Description

@os-zhuang

Found while implementing #9380 (PR pending), where the first draft of the regression test lived in packages/runtime and could not boot. Not fixed there — different defect class, different file surface. Filing unassigned.

The gap

packages/runtime/vitest.config.ts maps @objectstack/spec and thirteen of its subpath exports to source:

{ find: '@objectstack/spec/ai', replacement: …/spec/src/ai/index.ts },
{ find: '@objectstack/spec/api', replacement: …/spec/src/api/index.ts },
{ find: '@objectstack/spec/automation',…}, contracts, data, identity, kernel,
shared, system, ui, security, qa,
{ find: '@objectstack/spec', replacement: …/spec/src/index.ts },

cloud is missing from that list, and packages/spec/src/cloud/index.ts exists.

Because the bare @objectstack/spec entry is a stringfind, it prefix-matches and its replacement is a FILE — so @objectstack/spec/cloud resolves to …/spec/src/index.ts/cloud. This is the identical failure mode the config's own comments already document twice, for @objectstack/core/logger ("without this entry … resolves to the garbage path …/core/src/index.ts/logger") and for @objectstack/platform-objects ("it also swallows the /identity subpath … ENOTDIR, at run time, from a config that reads as correct").

Measured

Any packages/runtime test that boots MetadataPlugin against a compiled artifact on disk hits it, because _parseAndRegisterArtifact does await import('@objectstack/spec/cloud'):

Error: Plugin com.objectstack.metadata failed to start - rollback complete:
ENOTDIR: not a directory, open
'/home/user/objectstack-issue-9380/packages/spec/src/index.ts/cloud'
❯ MetadataPlugin._parseAndRegisterArtifact ../metadata/src/plugin.ts:597:47
❯ MetadataPlugin._loadFromLocalFile ../metadata/src/plugin.ts:785:9
❯ MetadataPlugin.start ../metadata/src/plugin.ts:373:17

The same boot in packages/cli (which has no vitest config, so it resolves through package exports to dist) works — that is why duplicates.integration.test.ts has never seen this.

Why it is a finding and not a defect report

No product path is affected: the published package resolves @objectstack/spec/cloud through its exports map correctly, and every shipped build does. This is unexercised drift in one test config — it fails only the runtime test that nobody has written yet. Its cost is that packages/runtime is currently unable to host any artifact-loading integration test, silently, and the next author to try will spend the same lap I did diagnosing an error that points at the metadata plugin rather than at an alias table.

Likely fix

One line beside its thirteen siblings:

{ find: '@objectstack/spec/cloud', replacement: path.resolve(__dirname, '../spec/src/cloud/index.ts') },

Worth checking whether the enumeration should become an anchored regex the way @objectstack/platform-objects did in PR #8128 — the config's own note there says "one rule for every namespace rather than an enumeration of the ones reached today, so it cannot go stale as tests reach new subpaths". This card is that note coming true. Sibling configs with the same enumerated @objectstack/spec subpath list are worth the same sweep.

Backlink: #9380.


Generated by Claude Code

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions