Propagate an unresolvable path in the shared script launcher so gates cannot silently skip

Merged
UN
3mo ago
+55-9

The defect

isMainInvocation in scripts/script-launcher.ts caught a realpathSync failure and
returned false. runIfMain reads false as "not the entry point", so the script it guards
never runs — and npm run docstring exits 0 having scanned nothing. A required release
check reporting success without doing its job is the single failure this gate exists to
prevent. Letting realpathSync throw turns it into a loud non-zero exit.

The docstring argued the right principle and then described the opposite behaviour: it said
"a release script that no-ops without erroring is worse than one that throws" and then used
fail closed to name the branch that no-ops. Here the crash is the safe outcome.

Why this repo was missed by the fleet sweep

The fleet-wide fix for this defect surveyed scripts/docstring-gate.ts for the guard. This
repo had refactored it into a shared script-launcher.ts, with the gate only re-exporting
it, so the survey found nothing and reported the repo clean. Factoring a defect out of the
file people search makes it invisible to the search.

What was deliberately kept

Unlike the copies elsewhere, this variant resolves both sides through realpathSync to
normalise Windows drive-letter casing. That reasoning is sound, so only the catch was
removed — the fix does not reintroduce the casing bug the both-sides comparison prevents.

Verification

  • npm test — 71 tests, all pass
  • npm run coverage — thresholds met, unchanged
  • npm run changelog:check — passes
  • Behavioural probe: isMainInvocation(["node","/nonexistent/x.ts"], ...) now throws ENOENT

pm items

  • pm-linear-lonp — The shared script launcher skipped every gate it guarded when a path could not be resolved

Summary by Sourcery

Ensure the shared script launcher fails loudly when entry paths cannot be resolved so release gates cannot silently skip.

Bug Fixes:

  • Propagate realpath resolution failures from isMainInvocation instead of treating them as non-main invocations that skip guarded scripts.

Enhancements:

  • Clarify isMainInvocation documentation to explain propagation of unresolvable paths and the safety rationale for crashing over silent skips.

Tests:

  • Add a docstring gate test asserting that isMainInvocation throws on an unresolvable entry path instead of silently declining to run the gate.

Chores:

  • Record the pm-linear-lonp incident in the PM agent history and issues metadata.

Summary by cubic

Propagate unresolvable entry paths in the shared script launcher so gates cannot silently skip. Release checks now fail loudly (non-zero) instead of exiting 0 when the entry path can’t be resolved (Linear pm-linear-lonp).

  • Bug Fixes
    • isMainInvocation: let realpathSync errors bubble instead of returning false; still returns false only when paths resolve to different files.
    • Keep both-sides realpathSync comparison to normalize Windows drive-letter casing; add a test that asserts the throw on ENOENT.