Skip to content

@objectstack/hono runs its tests against @objectstack/plugin-hono-server's dist — the missing vitest alias was hidden by the unbounded import regex until #12555 #12767

Description

@os-zhuang

Filed unassigned by the #12555 dev, as the one repo-wide finding that card's detector fix unmasked. Not fixed there: the remediation makes a suite execute another package's source and so needs its own verification, which is a different surface from a gate-script PR.

What was hidden

packages/adapters/hono/src/index.ts imports at module scope:

export type EnvironmentDriverRegistry = any;
import {
  createOriginMatcher,
  hasWildcardPattern,
  DEFAULT_CORS_ALLOW_HEADERS,
  DEFAULT_CORS_EXPOSE_HEADERS,
} from '@objectstack/plugin-hono-server';

check-test-source-alias.mjs never saw that import. Its IMPORT_PATTERNS clause capture was an unbounded [\s\S]*?, so the match started at the preceding export, ran through the ; and swallowed the whole import statement — leaving a clause that BEGINS with type, which isTypeOnlyClause then discarded as erased-at-compile-time. A real runtime import was filtered out as type-only.

Reproduced against the pre-#12555 regex:

CURRENT  runtime imports kept: []            discarded as TYPE-ONLY: ["@objectstack/plugin-hono-server"]
FIXED    runtime imports kept: ["@objectstack/plugin-hono-server"]

Independent corroboration on main, from an artifact nobody edited for this: check-type-source-resolution.mjs has carried @objectstack/plugin-hono-server in ITS entry for this package all along, because extractTypeImports reads only the specifier captures and never applies the type-only filter. The two gates disagreed about the same package for exactly this reason.

Current state after #12555

The detector is corrected and the ledger re-measured, so KNOWN_UNALIASED_TEST_IMPORTS['@objectstack/hono'] now records the truth:

'@objectstack/hono': ['@objectstack/plugin-hono-server', '@objectstack/types'],

That is a LEDGER CORRECTION, not a remediation. The hazard the ledger exists to track is still live for this pair: @objectstack/hono's unit verdicts are a function of build state for @objectstack/plugin-hono-server, so a stale or behind dist/ runs those tests green against old behaviour.

The remediation the gate prescribes

packages/adapters/hono/vitest.config.ts today aliases only @objectstack/runtime, in the OBJECT form. The gate asks for an anchored array-form entry, and verified the target file exists in the checkout:

alias: [
  { find: /^@objectstack\/plugin-hono-server$/, replacement: path.resolve(__dirname, '../../plugins/plugin-hono-server/src/index.ts') },
]

Note this converts the existing @objectstack/runtime object entry to array form as well, and it points that suite at plugin-hono-server's SOURCE — so it needs the package's tests actually run, not just the gate re-run. That is the whole reason this is a separate card.

⛔ Do not resolve this by widening KNOWN_UNALIASED_TEST_IMPORTS: that registry is shrink-only and the entry above is already the corrected measurement.

Blast radius is exactly this one pair — --list before and after the detector fix differ in one line repo-wide (303 -> 304 package-dependency pairs, 61 of 72 packages unchanged).

Found while implementing #12555 (branch claude/issue-12555-import-regex-statement-bound).

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions