Skip to content

ci: fail verify:stackblitz once the release is published - #59

Merged
stackloomdev merged 2 commits into
mainfrom
ci/fail-on-stackblitz-version-drift
Jul 28, 2026
Merged

stackloomdev merged 2 commits into
mainfrom
ci/fail-on-stackblitz-version-drift

Conversation

@stackloomdev

Copy link
Copy Markdown
Owner

Closes the gap that let the public StackBlitz lab serve [email protected] for four days after beta.9 shipped.

What was actually wrong

My earlier description of this ("verify:stackblitz doesn't fail on drift") was wrong. assertLiveLabVersion already rejects a pin more than one release behind. The predecessor allowance is deliberate and necessary: a release PR must merge before its target version can be published, and the lab installs from the public registry with --frozen-lockfile, so during that window it cannot pin the target.

The real defect is that nothing ever closed the window. Once beta.9 was published the justification disappeared, but the gate kept accepting beta.8 indefinitely — and printed both versions in the success line, which reads as confirmation rather than as a warning:

Verified the standalone pnpm StackBlitz lab with causescope@1.0.0-beta.8 for repository release 1.0.0-beta.9

RELEASING.md:71 only required the sync "before another release can pass", so no gate fired in between.

Change

verify:stackblitz now asks the registry whether the repository version exists, and passes that into the policy:

  • published → predecessor no longer allowed; failure names the fix.
  • not published (release PR in flight) → unchanged, predecessor allowed.
  • registry unreachable → window stays open. An npm outage must not fail an unrelated build, and the --frozen-lockfile install downstream already reports that case far more clearly.

The success line now states which rule applied rather than printing two version numbers side by side:

... with [email protected] (matching the repository release): ...

Verification

Reverting the pin to beta.8 locally now exits 1:

Error: The live lab pins [email protected], but [email protected] is
already published on npm. Update examples/stackblitz/package.json and its frozen
lockfile so the public lab runs the version consumers install.

Restored, pnpm verify:stackblitz passes with a real dev transform and clean production build. verify:release (14 policy tests, up from 11) and verify:links pass.

One note for reviewers

The first version of this used Accept: application/vnd.npm.install-v1+json. That abbreviated type is only valid on the packument root — the single-version endpoint answers it with 406, which my catch-all mapped to "unknown" and left the window open. The gate looked correct and enforced nothing. Caught by testing the failure path rather than the success path; it now sends application/json, verified 200 for a published version and 404 for an absent one.

🤖 Generated with Claude Code

The live-lab gate already rejected a pin more than one release behind,
but it accepted the immediate predecessor unconditionally. That
allowance exists for a narrow reason: a release PR must merge before its
target version can be published, and the lab installs from the public
registry with a frozen lockfile, so it cannot pin an unpublished
version.

Nothing closed the window afterwards. beta.9 shipped, the post-release
sync PR never landed, and every run kept passing while printing both
versions side by side, so the public lab served beta.8 for four days.

verify:stackblitz now asks the registry whether the repository version
exists. If it does, the predecessor is no longer allowed and the failure
names the fix. If the registry cannot be reached the window stays open,
because an npm outage must not fail an unrelated build; the lockfile
install downstream already reports that case far more clearly.

The success line now states which rule applied instead of printing two
version numbers and leaving the reader to compare them.

RELEASING.md said the sync "must merge before another release can pass";
it is now required immediately, which is what the gate enforces.

Verified by reverting the pin to beta.8 locally: the run exits 1 with
"[email protected] is already published on npm".

Co-Authored-By: Claude Opus 5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aace228723

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/verify-stackblitz.ts Outdated
Review caught a real regression in the previous commit. release.yml runs
`pnpm check` before the step that detects an already-published version,
so holding a tagged run to the published pin breaks the documented
recovery path: when npm publication succeeds but GitHub release creation
fails, rerunning the same tag would now fail in `pnpm check` before it
could skip republishing.

The rule is incoherent there anyway. A tagged commit is immutable, so
the lab pin inside it cannot be changed; the failure would name a fix
that is impossible to apply. Branch and pull-request runs are always
fixable by the post-release synchronization PR, so they keep enforcing
it.

Verified against the exact pre-synchronization state (lab and lockfile
on beta.8, beta.9 published): a tag run passes, a branch run exits 1.

Co-Authored-By: Claude Opus 5 <[email protected]>
@stackloomdev

Copy link
Copy Markdown
Owner Author

Confirmed and fixed in d03c19e — this was a real regression, thanks.

Verified the mechanism: release.yml:40 runs pnpm check before the "Check npm registry" step at line 64, so on a tag rerun after a successful publish the assertion would fail before the workflow could skip republishing, breaking the recovery path in RELEASING.md:78.

The rule was also incoherent there: a tagged commit is immutable, so the pin inside it cannot be changed — the error would name a fix that is impossible to apply. Branch and pull-request runs are always fixable by the post-release synchronization PR, so those keep enforcing it.

enforcesPublishedLiveLabPin now skips the registry check when GITHUB_REF_TYPE === "tag", with unit coverage for tag / branch / unset.

Verified against the exact pre-synchronization state (lab and lockfile on beta.8, beta.9 published on npm):

  • GITHUB_REF_TYPE=tag → exit 0, trailing repository release 1.0.0-beta.9 on a tagged run, where the pin cannot be changed
  • GITHUB_REF_TYPE=branch → exit 1, [email protected] is already published on npm

RELEASING.md now documents both exemptions (tagged runs, unreachable registry).

@stackloomdev
stackloomdev merged commit 6709921 into main Jul 28, 2026
11 checks passed
@stackloomdev
stackloomdev deleted the ci/fail-on-stackblitz-version-drift branch July 28, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant