Skip to content

[finding] inspectDistFreshness()'s refusal message hardcodes "packages/spec/dist" regardless of the pkgDir argument #11250

Description

@os-elon

Found while implementing #10969 (adding packages/client-react/packages/client as a second
resolution surface for check:skill-examples). Filing rather than fixing inline — see below.

The bug

packages/spec/scripts/lib/dist-freshness.ts's inspectDistFreshness(pkgDir, mode, rerun)
already takes an arbitrary pkgDir and is designed to be reusable (its own docblock: "the
caller names ITSELF" for the rerun command). But the refusal message's cause strings are
hardcoded literals, not derived from pkgDir:

constcause=state==='missing'
? `packages/spec/dist holds no .d.ts declarations — the package is not built …`
: `packages/spec/dist/**/*.d.ts is OLDER than packages/spec/src — the declarations …`;

Same shape in inspectBundleFreshness(). Until #10969, every real caller (check:api-surface,
check:exported-any, check:dual-source-exports, check:skill-examples) only ever passed
SPEC_DIR, so the hardcoded text happened to always be correct. #10969 is the first caller to
pass a differentpkgDir (packages/client-react, packages/client) — on a stale-dist
refusal for that surface, the printed message would say "packages/spec/dist … OLDER than
packages/spec/src", misnaming the actually-stale package. The refusal itself (exit 1, correct
verdict) is unaffected; only the diagnostic text is wrong.

Why filed instead of fixed in the same PR

dist-freshness.test.ts pins the exact hardcoded strings (.toContain('OLDER than packages/spec/src'), .toContain('no .d.ts declarations')) against a throwaway sandbox dir
that is NOT shaped like packages/spec — the test's own design assumes the wording is a fixed
literal, not derived from pkgDir. A correct fix has to also update those pinned assertions
(and ideally add a case with a non-spec-shaped pkgDir to prove the label is genuinely
dynamic), which is a second verification surface beyond #10969's own diff — outside the
"mechanical, no new verification surface" bar for a same-PR fix.

Suggested direction

Derive a packages/<name> display label from pkgDir (e.g. find the packages path segment
and take the next one, falling back to the raw path if the shape doesn't match) and interpolate
it into both cause strings in inspectDistFreshness and inspectBundleFreshness. Update
dist-freshness.test.ts's pinned assertions to match, and add a case that passes a
non-spec-shaped sandbox to prove the label is dynamic rather than coincidentally correct.

Refs: #10969, #7181, #7122 (which landed this primitive).

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions