Skip to content

docs: correct the workflow ID claim in publishing libraries - #3153

Merged
pranaygp merged 3 commits into
mainfrom
pgp-fix-publishing-libraries-id-claim
Jul 28, 2026
Merged

docs: correct the workflow ID claim in publishing libraries#3153
pranaygp merged 3 commits into
mainfrom
pgp-fix-publishing-libraries-id-claim

Conversation

@pranaygp

@pranaygp pranaygp commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #3152

The problem

The "Re-Exporting for Workflow ID Stability" section tells library authors that the consumer re-export file relocates a library's workflow and step IDs into the consumer's source tree, where they then survive package upgrades. That is not what happens.

resolveModuleSpecifier (packages/builders/src/module-specifier.ts:370-402) derives an ID from where a file lives, not from how it was imported. Any file under node_modules or a workspace package that is reachable through the package's exports map gets ${pkg.name}${subpath}@${pkg.version} — re-exported or not. So a package version bump renames every workflow and step the package ships, and the re-export file does nothing to prevent it.

That renaming is intended invalidation rather than a hazard, because runs are pinned to the deployment that recorded their IDs: resume re-enqueues against workflowRun.deploymentId (packages/core/src/runtime/resume-hook.ts:215-227, runs.ts:168), and moving a run onto newer code takes an explicit deploymentId: 'latest' (start.ts:279-306). After a consumer upgrades, new runs execute the new version and in-flight runs keep replaying on the deployment that started them.

The fix

Surgical correction to the one section, in both the v4 and v5 copies (they were byte-identical before and after).

  • Section renamed to "Re-Exporting for Compiler Discovery", and rewritten to state the real purpose: discovery starts from the consumer's workflows/ directory and follows imports, so the re-export is what puts the package's "use workflow" / "use step" files on that graph and gives the entry point a resolvable address. The re-export is still required — only the reason changes.
  • Dropped the three-point "the re-export pattern ensures... stable IDs / replay safety / version upgrades" list.
  • Added a callout describing the actual semantics: package-shipped IDs embed the version (step//@acme/media/workflows@1.4.0//transcode), deployment pinning is what makes a version bump safe, and re-exporting does not change either fact.
  • Added a note to prefer the package's dedicated ./workflows export over a deep dist/ path, since only export-reachable files get the name/subpath@version form; deeper files fall back to a path-based ID.

The claim had also spread beyond the prose, so it is corrected in all three places it appeared: the section body, the page summary frontmatter, and the <CopyPrompt> text. The CopyPrompt one matters most — it was instructing agents to document the wrong rationale into every library scaffolded from this page. The in-page anchor link at line 257 is updated to the renamed heading; no other page links to the old anchor.

The second commit walks back a wrong turn in the first: it had replaced one incorrect claim ("IDs are stable across upgrades") with another ("in-flight runs cannot replay across an upgrade — drain them first"), missing the deployment pinning above. The page now describes the pinning instead, and the drain checklist item is gone.

Alternative resolution

If the team would rather fix the compiler than the docs — strip versions from package-shipped IDs, or relocate them on re-export so the current promise becomes true — that is a perfectly good way to close #3152, and this PR should be dropped in favor of it. This only makes the docs honest about today's behavior.

Related

Found while writing the Mastra integration cookbook page (#3150), which originally repeated this claim and no longer does.

Pinning is per-world, so the callout is scoped to "worlds with deployment pinning, such as Vercel" rather than stating it flatly: world-vercel preserves deploymentId across re-enqueue (packages/world-vercel/src/queue.ts:406,417-418,490), world-local pins only per SDK version (packages/world-local/src/queue.ts:400-402), and world-postgres returns a constant (packages/world-postgres/src/queue.ts:133-135), so replay there breaks on any code change, not just a library upgrade. The page does not spell out that postgres case: it is a general self-hosting property rather than something a library author controls — happy to add a line if reviewers disagree.

Testing

Docs CI: Docs Code Samples, Docs Links, Docs Preview Smoke Checks.

🤖 Generated with Claude Code

The consumer re-export file does not relocate a library's workflow and
step IDs into the consumer's source tree. An ID is derived from where the
file lives, so any export-reachable package file keeps a name@version ID
whether or not it is re-exported.

Rename the section to describe what the re-export actually does — put the
package's directive files on the compiler's discovery graph and give the
entry point a resolvable address — and add the upgrade guidance that
follows from the real behavior: a package version bump renames every
workflow and step it ships, so in-flight runs must drain first.

The wrong claim also appeared in the page summary and the CopyPrompt, so
it is corrected in all three places, in both the v4 and v5 copies.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: cfe02e8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Jul 28, 2026 6:36am
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jul 28, 2026 6:36am
example-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-astro-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-express-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-fastify-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-hono-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-nestjs-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-nitro-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-nuxt-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-sveltekit-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-tanstack-start-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workbench-vite-workflow Ready Ready Preview, Comment Jul 28, 2026 6:36am
workflow-docs Ready Ready Preview, Comment, Open in v0 Jul 28, 2026 6:36am
workflow-swc-playground Ready Ready Preview, Comment Jul 28, 2026 6:36am
workflow-tarballs Ready Ready Preview, Comment Jul 28, 2026 6:36am
workflow-web Ready Ready Preview, Comment Jul 28, 2026 6:36am

@pranaygp
pranaygp marked this pull request as ready for review July 28, 2026 06:02
@pranaygp
pranaygp requested review from a team and ijjk as code owners July 28, 2026 06:02
Copilot AI review requested due to automatic review settings July 28, 2026 06:02
@pranaygp
pranaygp requested a review from a team as a code owner July 28, 2026 06:02
Runs are pinned to the deployment that recorded their step IDs, so a
library version bump does not strand in-flight runs: new runs execute
the new version, in-flight runs keep replaying on their original
deployment. Replaces the incorrect drain-before-upgrade advice.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Corrects the “Publishing Libraries” docs to accurately explain why consumers must re-export a library’s workflow entry point: to ensure the compiler discovers and transforms the library’s "use workflow" / "use step" files, not to “relocate” IDs for stability across package upgrades. This aligns the guidance with the builder’s actual module-specifier behavior (package-shipped IDs include name@version).

Changes:

  • Renames and rewrites the re-export section to focus on compiler discovery/import-graph inclusion rather than ID stability.
  • Adds explicit upgrade guidance warning that package version bumps change IDs and can break in-flight runs; re-exporting does not prevent this.
  • Updates frontmatter summary, <CopyPrompt> text, and the in-page anchor reference; adds a checklist item to drain in-flight runs before upgrading.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
docs/content/docs/v5/cookbook/advanced/publishing-libraries.mdx Rewrites re-export guidance to reflect compiler discovery and adds upgrade warning/checklist item.
docs/content/docs/v4/cookbook/advanced/publishing-libraries.mdx Mirrors the same corrections in the v4 docs copy for consistency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>

@VaguelySerious VaguelySerious left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM but see one comment

The workflow compiler only transforms files it discovers, and discovery starts from the consumer's `workflows/` directory and follows imports out from there. A library's workflow functions are not on that graph by default, so nothing compiles them and the runtime has no definition to run.

The fix is a **re-export file**. The consumer creates a file in their `workflows/` directory that re-exports the library's workflows. The build system then processes this file and assigns stable IDs.
The fix is a **re-export file**. The consumer creates a file in their `workflows/` directory that re-exports the library's workflows, which pulls the library's source onto the discovery graph and gives its entry point an address the runtime can resolve.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't we also look at the framework entrypoint and follow that?

@pranaygp
pranaygp merged commit 7d7effd into main Jul 28, 2026
54 checks passed
@pranaygp
pranaygp deleted the pgp-fix-publishing-libraries-id-claim branch July 28, 2026 18:42
@github-actions

Copy link
Copy Markdown
Contributor

No backport to stable for 7d7effd (AI decision).

The commit only edits docs/content/docs/{v4,v5}/cookbook/advanced/publishing-libraries.mdx, and I verified via git ls-tree origin/stable that neither file — nor any cookbook/ directory under docs/content/ — exists on stable. There is no content on the maintenance line for this correction to fix, so the cherry-pick would add a new page rather than correct existing documentation.

To override, re-run the Backport to stable workflow manually via workflow_dispatch and paste this commit SHA into the ref input:

7d7effd49fd6e43a68469e6a893e15a4fdd21be3

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.

publishing-libraries.mdx overstates the consumer re-export: package step IDs still embed name@version

3 participants