Commit Graph

1736 Commits

Author SHA1 Message Date
vercel[bot] d257a171ba fix(world-vercel): resolve terminal run event responses
Co-Authored-By: Shalabh Chaturvedi <7066873+shalabhc@users.noreply.github.com>
2026-08-31 18:01:18 +00:00
Mitul Shah 695a1b76d0 fix(web-shared): describe map-like iterables via entries() (#3806)
* fix(web-shared): expand Web API iterables

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

* fix(web-shared): inspect generic iterables

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

* fix(web-shared): compare iterator identity safely

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

* test(web-shared): cover inspector iterable entries

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

* fix(web-shared): describe map-like iterables via entries()

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

---------

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-08-31 11:34:29 -04:00
Peter Wielander 855e47990c [core] Make a duplicate attr_set inert instead of terminal (#3849)
* [core] Make a duplicate attr_set inert instead of terminal

A workflow-body attribute write draws a correlation id that resolves exactly
once: the dispatcher's consumer takes the matching event and deregisters. A
second event under that id therefore has no callback left and never will.

`attr_set` had no entry in ENTITY_EVENT_CLASS_BY_TYPE, so the duplicate skip
could not take it, and `PARKABLE_EVENT_TYPES` does list the type, so it was
parked for a consumer that could never come. Parking is settled by the workflow
function returning, and a survivor there is reported through `strandedEvent` as
a replay divergence. So the run did all of its work, every step succeeded, and
the final replay failed it, deterministically enough to burn the whole
replay-divergence recovery budget and terminate with CORRUPTED_EVENT_LOG.

Give `attr_set` a class so the straggler is skipped like every other one:
committed but inert. Parking still covers the first arrival, for a replay that
walks past an attribute event before the body reaches the call that claims it.
An attribute write from a step body carries no correlation id and is consumed by
the structural lifecycle consumer, so it is unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* [core] Release a parked duplicate, and agree with the UI about one

The class map alone decides a straggler only where the walk meets it after a
consumption recorded the class. When neither copy has a consumer yet both
park — the walk steps over the first and re-enters in the same tick, with
nothing consumed and so no class recorded — and the drain then claims one and
holds the other for a callback that will never be registered. That survivor is
`strandedEvent`, which is the CORRUPTED_EVENT_LOG this branch set out to stop,
reached by the other road. `dropParkedDuplicates` releases it on the same terms
the walk skips one. Not an `attr_set` property: `wait_completed` parks in pairs
too, and `ONE_SHOT_EVENT_TYPES` only sees the order where the consumption came
first.

Giving `attr_set` a class also moved the observability UI, which reads the same
`entityEventClass` to grey out events a run passed over. It kept treating the
straggler as live, because its terminal-class set had no `attr_set` while the
dispatcher's consumer does deregister on the first event under an id. The two
now share `classifyEntityEvent` and `TERMINAL_EVENT_CLASSES` rather than each
keeping a copy of the rule.

That sharing needs the entity rule to be exact, because a step-written
`attr_set` carries no correlation id: keyed on the run it would collapse every
attribute write a run made into one class, and a captured production log in
`__fixtures__` holds forty. `classifyEntityEvent` gives such an event no class
at all, so neither side can read the second as a repeat of the first.

The shared fixture corpus had nothing for `attr_set`, which is why the drift
between the two halves went unseen. It has four now, and each of them fails on
both sides without the fix above it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
2026-08-28 11:45:56 -07:00
Mitul Shah 4d5852b901 Alt-click focus behavior (#3872)
* fix(web-shared): keep Alt+hover working after selecting a span

Chrome's Alt menu-bar handling blurred the page and cleared the overlay
flag, which also killed span hover until the window was refocused.

* test(web-shared): drop useAltHeld unit tests

* refactor(web-shared): let useAltHeld own Alt tracking

Drop the event union, reducer, and timeline mouse-move graft. The hook
listens for keys, blur, and window pointermove itself and returns only
altHeld.

* style(web-shared): trim useAltHeld comment

* fix(web-shared): keep Alt gap overlay when nothing is selected

pointermove was copying e.altKey, so Chrome's post-preventDefault
pointermove with altKey false cleared the flag on Alt press.

* Revert "fix(web-shared): keep Alt gap overlay when nothing is selected"

This reverts commit ba142906f7.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-08-28 18:36:11 +00:00
Nathan Rajlich 88f5d214d4 fix(builders): shim __dirname/__filename in fully-bundled ESM output (#3876)
* fix(builders): shim __dirname/__filename in fully-bundled ESM output

esbuild leaves the CJS globals __dirname/__filename as free identifiers
when inlining CJS modules into ESM output, so dependencies that reference
them at module scope (google-gax via @google-cloud/pubsub, Prisma's
runtime) crash the deployed Vercel function at init with
'ReferenceError: __dirname is not defined in ES module scope' before any
workflow code runs. v4 was immune because the Build Output API function
was CJS; #1562 switched it to ESM with a banner that shimmed only
require().

Extend the ESM banner to define __filename/__dirname from
import.meta.url, matching the shim verified live in #2770.

* chore(builders): clarify interop banner scope and tighten its regression test

Review follow-ups to the __dirname/__filename shim; no behavior change.

The ESM banner now declares require, __filename and __dirname, but the
flag that suppresses it is still named skipEsmRequireBanner and its
JSDoc described it purely in terms of __createRequire. Document the full
surface instead of renaming, since BaseBuilder is exported and
createStepsBundle is protected, so a rename would break external
subclasses in a patch release. The note calls out #3778 specifically:
reaching for this flag to silence a duplicate require declaration also
drops the dirname shim.

Assert the banner's import binding is emitted exactly once. A duplicated
banner fails at parse time on the redeclared import, before the var ever
runs, so that is the assertion that matches the real failure mode. Also
note that createWorkflowsBundle's final wrapper and createWebhookBundle
emit the same banner and are not covered here.

Finally, record in the changeset that CJS dependencies which
feature-detect via `typeof __dirname !== 'undefined'` now take their CJS
branch, where __dirname is the function root rather than the
dependency's own directory.

Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(builders): assert the webhook function bundle carries the ESM interop shim

The webhook route is a separately deployed function built through its own
esbuild pass (createWebhookBundle); a CJS dependency referencing __dirname
reachable from it would have crashed identically, so cover that emit site
rather than only noting it as untested.

---------

Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-28 08:45:33 +00:00
Nathan Colosimo a3da6b791b fix(next): discover every Next entrypoint (#3801)
* fix(next): discover every Next entrypoint

* fix(next): exclude declaration files from entries

* fix(next): align entry discovery with Next

* Revert "fix(next): align entry discovery with Next"

This reverts commit 7e16d144e5.

* fix(next): tighten entrypoint discovery
2026-08-27 22:53:18 -07:00
Pranay Prakash ffc58078d0 Stop logging on healthy workflow execution (#3878)
A successful run printed several lines that described the runtime working
correctly. Most of it was fallout from defaulting the events transport to
WebSockets (#3702): three breadcrumbs written while the transport was opt-in
became default-path output, because each one reported a choice the caller no
longer makes.

- `world-vercel: using ws events transport (…)` ran once per cold start on
  every deployment, naming the transport it was always going to use.
- The `projectConfig` proxy fallback warned once per process. That World cannot
  hold a socket, so with WS on by default every CLI command and the
  observability app warned about a fallback nobody asked for and nobody can act
  on. Debug-gated and reworded from "requested but" to "unavailable for".
- The `max_duration` / `auth_expiry` drain notice is routine: the transport
  reconnects from the close that follows and no write is lost.

Swept for the same shape elsewhere:

- `world-local`'s queue-concurrency notice fired per message once a fan-out
  exceeded the limit — the semaphore doing its job.
- `@workflow/world`'s active-run recovery line printed on every dev-server
  restart with work in flight. The re-enqueue *failure* above it stays
  unconditional; that one leaves a run unresumed.
- The port-detection diagnostics in `@workflow/utils` keyed off
  `NODE_ENV=development`, which is the only environment that reaches them, so
  the gate made them unconditional for their whole audience.

All of it moves behind `DEBUG=workflow:*` via a new `debugLog` in
`@workflow/utils`, joining world-vercel's existing `httpLog` and `logRetry`
output under one selector. Warnings and errors are untouched, so a run that
actually goes wrong is no quieter than before — the ws-transport tests that
assert failures are never silent still pass unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Co-Authored-By: Pranay Prakash <1797812+pranaygp@users.noreply.github.com>
2026-08-27 20:45:20 -07:00
Michael J. Sullivan ff7248fb9e Make the python docs codeownership more targeted (#3840)
* Make the python docs codeownership more targetted

I had originally left it broad so that things would be smooth when we
start reorganizing the python docs, but we'll adjust that when it
happens.

* Update .github/CODEOWNERS

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Signed-off-by: Michael J. Sullivan <sully@msully.net>

---------

Signed-off-by: Michael J. Sullivan <sully@msully.net>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2026-08-27 16:01:21 -07:00
Peter Wielander 1c44cc8c3f [world-vercel] Fail the run on a lost event payload instead of retrying forever (#3742)
* fix(world-vercel): fail the run on a lost event payload instead of retrying

A frame stream that dies mid-body reaches us as a truncated response, which
is exactly what a dropped socket looks like. So an event whose stored payload
is permanently gone was indistinguishable from a transient blip, and the
runtime kept redelivering a replay that could never succeed: one run re-read
a single missing payload 12,932 times in 26 minutes, and the backend query
behind each attempt throttled its table.

The World now sends a terminal `{_error: 1, code}` frame for failures that a
retry cannot fix. Handle it:

- `payload-missing` raises `CorruptedEventLogError`, so the run fails with
  `CORRUPTED_EVENT_LOG` rather than looping. The log does reference a payload
  nothing can produce.
- An unknown code raises a `WorkflowWorldError` with no retryable code and no
  status, which is also terminal. A future code stays safe without needing a
  client release first.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Revert the world-vercel URL override to empty

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(world-vercel): classify terminal stream errors

Signed-off-by: Alex Langenfeld <alex.langenfeld@vercel.com>

---------

Signed-off-by: Alex Langenfeld <alex.langenfeld@vercel.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Alex Langenfeld <alex.langenfeld@vercel.com>
2026-08-27 13:32:39 -05:00
Peter Wielander cc6eb7e837 [world-vercel] Fix deploymentId "latest" resolving against the wrong team (#3844) 2026-08-27 09:48:38 -07:00
Alex Langenfeld 36944cdcad feat(web-shared): allow product step span attributes (#3825)
Signed-off-by: Alex Langenfeld <alex.langenfeld@vercel.com>
2026-08-27 10:31:49 -05:00
Andrew Barba 3e0c18a4ca fix(world-local): abort deliveries on shutdown (#3824) 2026-08-26 14:07:26 -07:00
github-actions[bot] d3d240c003 Version Packages (beta) (#3816)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
workflow@5.0.0-beta.46
2026-08-26 12:36:41 -07:00
Karthik Kalyan 985d36d8b6 fix: repair empty changeset (#3814) 2026-08-26 12:33:05 -07:00
github-actions[bot] 2c953640e7 Version Packages (beta) (#3775)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-26 12:04:15 -07:00
Nathan Rajlich f806f8c258 fix(builders): dedupe pnpm peer-variant copies instead of failing on duplicate step IDs (#3795)
* fix(builders): dedupe pnpm peer-variant copies instead of failing on duplicate step IDs

When pnpm resolves the same package version into multiple virtual-store
instances (one per peer-dependency resolution), each instance is a
byte-identical copy of the same module that generates the same canonical
step/workflow ID. The duplicate-ID check treated these as a fatal
collision, failing builds for apps whose dependency graphs pull in two
peer variants of the Workflow SDK (or any step-defining package).

The duplicate-ID check now fingerprints (SHA-256) the source of each
file that contributes manifest entries. When two different files emit
the same ID for the same symbol and their contents are identical, the
registration is deduplicated and the build continues. Files with
differing contents still fail with the existing collision error.

Content hashing is used rather than realpath()/inode identity because
pnpm materializes virtual instances via hard links (Linux) or
clones/copies (macOS APFS), neither of which realpath resolves and the
latter of which allocates fresh inodes.

The previously duplicated merge/assert logic in swc-esbuild-plugin.ts
and base-builder.ts is consolidated into a shared manifest-ids.ts.

* Update .changeset/dedupe-pnpm-peer-variant-step-ids.md

Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Signed-off-by: Nathan Rajlich <n@n8.io>

---------

Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
2026-08-26 11:30:17 -07:00
Peter Wielander d9e0777eb8 [core] Never write hook_received eagerly on the lazy resume path (#3794) 2026-08-26 09:14:40 -07:00
Peter Wielander 0750fe8958 fix(astro,sveltekit): skip generated writes that would not change the file (#3688) 2026-08-25 15:47:09 -07:00
Nathan Colosimo 82e2678939 [core] Retain workflow VMs across attributes (#3609)
* Retain workflow VMs across attributes

* Restore runtime logger spy automatically

* Explain retained attribute race ordering

* Update retained attribute telemetry expectation

* Clarify retained attribute replay coverage

* Clarify retained attribute execution comment
2026-08-25 15:30:16 -07:00
Nathan Colosimo 556f3f080a [core] Retain workflow VMs across hooks (#3604)
* Retain workflow VMs across hooks

* Refine retained VM decisions and diagnostics

* Fix hook suspension assertion

* Harden retained hook race coverage

* Simplify retention blocker log metadata

* Preserve workflow suspension compatibility

* Bound retained VM serialization diagnostics

* Clarify bounded serialization diagnostics
2026-08-25 15:09:52 -07:00
christopherkindl 91eb1ae924 chore(docs): use geistdocs 1.23.1 (#3777)
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Peter Wielander <peter.wielander@vercel.com>
2026-08-25 13:56:02 -07:00
Sergio 66af295590 fix(skills): quote v4→v5 migration skill description so it parses as YAML (#3779)
Signed-off-by: Sergio Diez <sergiodiez@users.noreply.github.com>
2026-08-25 13:21:47 -07:00
Pranay Prakash a2e513303e [world-local] Skip chmod-based permission tests where the bits aren't enforced (#3771) 2026-08-25 13:18:19 -07:00
Peter Wielander c8bcde53d0 [ci] Track the /flow route bundle size against main (#3739) 2026-08-25 13:06:49 -07:00
Peter Wielander 584155897f [core] Fail dev HMR cleanup on a stranded step registration (#3682) 2026-08-25 12:07:18 -07:00
Nathan Colosimo d62b44473b [core] Prune schema modules from workflow bundles (#3550)
* [core] Prune schema modules from workflow bundles

* [world] Inline one-off validation options

* refactor(world): simplify event schema boundaries

* refactor(world): simplify event schema boundaries

* fix(world): keep noop metadata schema-free

* refactor(world): drop zod 4.4 compatibility

* test(builders): cover workflow API bundle boundary
2026-08-25 11:11:54 -07:00
Peter Wielander 27cab14adc [core] Send the disposed hook's token from the QuickJS engine (#3773) 2026-08-25 07:49:35 -07:00
Shalabh Chaturvedi f7fb012652 feat(runtime): report replay cost for every step batch, flagged by retained-VM mode (#3490)
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2026-08-24 19:49:57 -07:00
Nathan Colosimo c332a9cc59 ci: make Python conformance advisory (#3772)
Signed-off-by: Nathan Colosimo <110621881+NathanColosimo@users.noreply.github.com>
2026-08-25 00:00:34 +00:00
github-actions[bot] 3c0d60be90 Version Packages (beta) (#3717) workflow@5.0.0-beta.44 2026-08-21 22:17:38 -07:00
Peter Wielander bf9de1cd81 [core] Re-arm a wait continuation delivered before its wait elapses (#3743) 2026-08-21 19:36:11 -07:00
Shin 71bc027a6c fix(world-postgres): make step creation atomic (#3575)
Signed-off-by: Shin <128954611+shin4141@users.noreply.github.com>
2026-08-21 19:18:44 -07:00
Peter Wielander 7e48e7b4de Re-enable the sealed log by default (#3737)
* Revert "[world] Make the sealed log opt-in instead of default-on (#3735)"

Reverts b2cac623d3. New runs are stamped at spec 7 again, now that a
read which cannot see past an unfilled position waits for it instead of
reporting a log that ends there (workflow-server: derive the in-request
seal poll budget from the staleness bound).

Two things are kept from #3735 rather than reverted:

- the world-testing conformance floor at mintedSpecVersion(), which was
  wrong for any staged bump and not specific to this default
- a note on mintedSpecVersion recording what default-on rests on: the
  events density requirement, and that a sealed log meets it by repair
  rather than by construction, so the READ has to wait

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* TEMPORARY: point world-vercel at workflow-server#839 preview

Validating the seal-poll-budget fix end to end with spec 7 on. Reverted
before merge; the override lint guard is expected to fail meanwhile.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Revert "TEMPORARY: point world-vercel at workflow-server#839 preview"

This reverts commit 5e17cc9335.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 17:32:08 -07:00
Shalabh Chaturvedi dc68611fbf Default the events transport to WebSockets (#3702)
* Default the events transport to WebSockets

WORKFLOW_EVENTS_TRANSPORT=http is the opt-out. Only that exact value
disables it, so a typo'd or empty value fails toward the default rather
than quietly pinning a deployment to HTTP.

The prerequisite the gate named for defaulting on is met:
postEventFrameOverWs opens a client span per frame. What is still missing
is Vercel's outgoing-requests view, which reads instrumented fetch calls
rather than spans and so cannot show a transport that issues no request.

Co-Authored-By: opencode <opencode@vercel.com>

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>

* docs: WORKFLOW_EVENTS_TRANSPORT defaults to ws

Three places still documented http as the default. Each now states the
opt-out is the exact value http, rather than leaving 'default: ws' to
imply that anything non-ws disables it — the asymmetry is deliberate in
the code and is the part a reader would otherwise get wrong.

Also drops 'Experimental' from the Vercel World page: a setting that is
on for everyone by default is not opt-in experimental, whatever else it
is.

Co-Authored-By: opencode <opencode@vercel.com>

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>

* Fix the gate's own unit tests for the flipped default

Five tests in ws-transport.test.ts still encoded the opt-in semantics.
Three were the isWsEventsTransportEnabled table itself; the other two
(openWsChannel 'does nothing when the gate is off', and the channel
release equivalent) relied on the suite's ambient unset environment
meaning 'off', which it no longer does. Both now set http explicitly.

Two tests in ws-transport-spans.test.ts asserted HTTP-side span
behaviour the same way. The write one would have kept passing by
falling through resolveWsTransport's null rather than because the gate
was off - passing for the wrong reason, which is what this file exists
to catch.

Also makes the opt-out case-insensitive and trimmed. The gate is
deliberately asymmetric - unrecognized values take the default - but
that asymmetry should not extend to swallowing HTTP or ' http '.
Whoever reaches for the escape hatch is plausibly mid-incident, and
silently ignoring their opt-out over a capital letter is the same class
of silent-wrong-transport bug this flip is meant to stop shipping.

554 tests pass in packages/world-vercel.

Co-Authored-By: opencode <opencode@vercel.com>

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>

* ci: add a required forced-HTTP e2e lane (#3703)

Flipping the default makes e2e-vercel-prod a WebSocket lane: it sets no
WORKFLOW_EVENTS_TRANSPORT, and unset now means ws. Nothing in the file
would exercise the HTTP events transport against a real deployment any
more, so this is not additive coverage — it replaces coverage the flip
silently removed.

Unconditional and required rather than label-gated like the WS lane.
HTTP is now the fallback, and the fallback is silent: resolveWsTransport
returning null costs a write nothing and logs nothing, which is the
shape of the durabench bug this stack came out of.

Two apps rather than the WS lane's four, since every row is a real
vercel deploy charged to every PR. nextjs-turbopack is the only fixture
emitting OTEL spans, so it is the one that can show which transport
actually ran; express covers the non-Next server path.

Also corrects the WS lane's docblock, which claimed every other job
exercises HTTP only. That stopped being true one commit ago.

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>

* Fail loudly when step_completed falls back to HTTP under a strict flag

The WS e2e lane asserts that the transport is harmless, not that it is
used: an event written over HTTP produces the same run outcome as one
written over the socket, so the lane stayed green through the entire
period the transport was silently demoted.

WORKFLOW_INTERNAL_EVENTS_TRANSPORT_STRICT turns that one case into a
failed run, and the WS lane now sets it.

Scoped to step_completed alone, because most fallback is legitimate:
run_created is written outside any invocation that opens a channel;
run_started routinely lands before the channel is registered (34% HTTP
on a healthy deployment); step_created and wait_created mostly fold into
events.createBatch, which is not wired to the socket; and a write after
the invocation released its claim falls back by design. step_completed
is issued after a step body has run, and was 100% ws across every
WS-enabled deployment measured on two SDK versions.

The flag reads as off unless the value is exactly 1 or true - the
opposite asymmetry from the transport gate, which treats an unrecognized
value as on. That gate risks a deployment sitting quietly on the wrong
transport; this one fails runs, and should not be acquired by a typo.

Co-Authored-By: opencode <opencode@vercel.com>

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>

* ci: run the WS transport lane on every PR

It was opt-in behind ws-transport-test because four real vercel deploys
were too much to charge an unrelated PR for a transport that was off by
default. Flipping the default expires that reasoning from both ends: the
cost is no longer for someone else's feature, and this is now the only
lane that asserts the socket carried the events. e2e-vercel-prod
inherits the new default but checks nothing, so behind a label the
average PR would move every deployment onto WebSockets with nothing
verifying they were used.

Drops WS_REQUIRED from the gate along with it. That existed only to let
the lane be legitimately skipped on an unlabelled PR; with no label the
lane is required unconditionally, like e2e-vercel-prod and the HTTP
lane, and the skipped case is now a failure rather than a warning.

Gate script extracted and run against the cases that matter: ws skipped
fails on a standard PR, ws skipped fails under workflow-server-test, and
all-green passes.

Co-Authored-By: opencode <opencode@vercel.com>

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>

* ci: widen the HTTP transport lane to six server shapes

Before the flip, HTTP was the default and all 28 e2e-vercel-prod
lane-runs covered it. After the flip they cover WebSockets instead, and
this lane is the entirety of the HTTP coverage - two apps was too thin
for a transport that is still supported.

Six, not the full 14, because every row is a real vercel deploy charged
to every PR. Chosen by server shape rather than count: example
(baseline), nextjs-turbopack (Next, and the only fixture emitting OTEL
spans), vite (Vite SSR), express (Node req/res), nitro (h3, also covers
nuxt) and hono (fetch-API Request/Response, a different mount shape from
express). The rest duplicate a shape already covered; python is left out
because it has no conformance gate and needs routes this suite does not
serve.

The first four match the WS lane's matrix on purpose, so the same
fixture runs on both transports and a failure on one can be read against
the other.

Project ids and slugs are copied from e2e-vercel-prod and verified equal
to it; both lanes already use the same team and token.

Co-Authored-By: opencode <opencode@vercel.com>

Co-Authored-By: shalabhc <shalabh.chaturvedi@vercel.com>

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2026-08-21 17:17:04 -07:00
Pranay Prakash f771585486 fix(world-vercel,world-local): hold process-wide state on globalThis (#3728)
* fix(world-vercel,world-local): hold process-wide state on globalThis

Both packages are bundled into the host application's server build, and a
bundler keys module identity on (resource, layer) — Next.js alone builds
`instrument`, app-route, `ssr` and `edge` layers, so one process holds one
copy of each of these modules per layer. Every module-scope `const`/`let` in
them was therefore per-copy state wearing the costume of a process singleton.

vercel/workflow#3493 made `@workflow/world-vercel` bundled rather than
external and the events WebSocket transport regressed to HTTP for exactly
this reason: the queue consumer registered its channel in the `instrument`
copy's `Map` and the write path looked it up in the route copy's empty one. A
deterministic miss, for the life of the process. `@workflow/world-local` had
the same exposure all along — including `runFileLocks`, where a duplicated
mutex simply stops mutually excluding.

Add `globalSingleton()` to `@workflow/utils` (the primitive `@workflow/core`
already hand-rolls for its World cache) and route every mutable module-scope
binding in both worlds through it.

Regression cover, in three layers:

- `global-singleton.test.ts` pins the primitive's semantics.
- `ws-transport-module-copies.test.ts` imports the module twice in one
  process and asserts a transport registered by one copy is found by the
  other — it fails on a plain module-scope `Map`, which is the shipped bug.
- `scripts/lint/module-scope-state.mjs` fails the class: an AST rule banning
  mutable module-scope state in these packages, with `// per-copy-ok: <why>`
  as the deliberate escape. Wired into both packages' `vitest run src`, with
  fixture self-tests so it cannot rot into a no-op.

* test(world-postgres): pin the module-scope-state rule for the postgres world

It is deduped today only because `getRuntimeRequire()` loads it — a property
of how it is loaded, not how it is written, and exactly what changed for
world-vercel in #3493. The package is already clean; this keeps it that way.

* docs(worlds): codify "a world must not hold mutable module state"

A world package is loaded one of two ways, and only one of them gives it a
single module instance: a runtime `require()` (deduped by Node) or the host's
bundler (one copy per layer). Which one you get is a property of how the world
is loaded, not of how it is written, and it changed under `world-vercel` in
#3493 — so the rule has to be "never rely on module scope", not "rely on it
until someone flips a config".

Written down in the four places someone can meet it:

- `docs/content/worlds/{v4,v5}/building-a-world.mdx` — a "Process-wide state"
  section for custom-world authors, with the loading modes spelled out and a
  nudge to prefer World-instance state over a global.
- `packages/world/README.md` — the same constraint on the contract package.
- `CLAUDE.md` — so the next contributor working in these packages sees it.
- `packages/core/src/runtime/world.ts` — at the two static imports, which is
  where the difference between a bundled world and a required one originates.

The rule's own error message now teaches it too, rather than naming a helper.

Consolidates the guard while here: `@workflow/utils` owns the rule and its
fixture self-tests, and sweeps every *published* `packages/world-*` discovered
at runtime, so a world package added later is covered without anyone
remembering. Each world keeps a one-assertion mirror for locality.

* style: drop prose em dashes from this branch's new text

#3704 landed a repo-wide writing pass hours after this branch was written and
took `world-vercel/src` from 406 em dashes to 130 (`ws-transport.ts` alone went
35 to 1). This branch's docs section, README, comments and lint messages were
written before that and would have put 36 of them straight back into the files
that were just cleaned.

Rewritten sentence by sentence rather than by substitution: an em dash becomes a
colon, a comma, a full stop or a parenthetical depending on what it was doing.

Also fixes a real defect the sweep surfaced: `world-postgres`'s guard test was
generated through a shell heredoc and had literal backslash-backticks in its
doc comment.

* Update .changeset/world-module-scope-state.md

Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>

* fix(core): build the entrypoint's queue handler from getWorld()

Adopted from #3666 by @MintedKenny, which implements #3665 and could not run
CI as a fork PR. One line of behavior: `workflowEntrypoint`'s lazy handler
init calls `getWorld()` rather than `getWorldHandlers()`.

`getWorldHandlers()` owns a second, build-time-safe cache, so calling it from
the runtime route built a *second* World in the same process. That costs a
stateful World duplicate resources on every instance — world-postgres eagerly
constructs a `pg.Pool` (default `max: 10`) and a nested world-local World in
`createWorld()`, so self-hosted users have been paying for two of each — and,
for a bundled world package, the two Worlds are built by two different module
copies, which is the mechanism behind the WS transport regression the rest of
this branch contains.

The public `getWorldHandlers()` and its separate build-time cache are
unchanged; only the runtime route stops using it.

Kept from the original: the regression test asserting the factory runs exactly
once, and the api-reference wording (re-applied over #3704's list punctuation).
Not taken: renaming the `workflow.route.get_world_handlers` span. It is a
distinct span from the per-request `workflow.route.get_world` at the top of the
flow route, and reusing that name would collide with it in traces and in
`runtime-trace-mode.test.ts`; a comment records why the name outlived the call.

Co-authored-by: Kenneth <kenneth@standardforensics.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: address AI review on the module-scope work

Two blocking findings, both real:

- **Cross-version state sharing** (`ws-transport.ts`). A process can hold two
  *published versions* of `@workflow/world-vercel` (a transitive dependency
  pinning an older `@workflow/core`, which depends on this package by exact
  version). Both wrote to the same unversioned `Symbol.for` key, so one
  version's write path could be handed a `WsEventsTransport` built by the
  other's class and frame against a protocol it may not share — with no version
  negotiation on the socket to catch it. `shapeVersion` cannot express this: the
  container is stable, the hazard is its contents. The registry and the events
  dispatcher recycler are now keyed by package version. The plain connection
  pools stay unversioned; sharing those across copies is the point.

- **The documented pattern failed the rule this PR adds.** The custom-world docs
  teach `store[StateKey] ??= …`, which the rule flagged as a field write. It now
  recognizes state rooted at `globalThis`, following one alias hop, which is
  also what `core/private.ts:23` and `next/src/index.ts:58` are already doing
  correctly (core drops 26 findings to 22, next 7 to 6). The docs also now say
  outright that `globalSingleton()` is the same thing, since AGENTS.md
  prescribes it and the page did not mention it.

Rule precision, from the review's probes:

- `.mts`/`.cts` are scanned. `@workflow/world-testing` is authored in `.mts`, so
  its entry in the sweep was passing vacuously — with the walk fixed it reports
  a real finding, now annotated (it is a standalone `serve()` entry).
- Mutations in top-level statements no longer count. A table filled at module
  evaluation is identical in every copy; divergence needs a later write.
- `static` class fields are collected, attributed to the class name.
- An *exported* binding initialized to an empty collection is a finding on its
  own, which approximates the cross-file case the walk cannot resolve.

Six fixtures pin the new behavior. The rule's header now states what it does not
see, and AGENTS.md states where the sweep stops and why core is not gated yet.

Also tags `resetGlobalSingletonForTest` `@internal`.

* fix(lint): attribute a static-field write to the field, not the class

The static-field support added in the previous commit keyed `declared` on the
class name, so a class carrying more than one mutable static reported one
finding instead of one per field, and labelled the survivor with whichever
mutation was seen first. On a two-static fixture it reported
`static Registry.latch  (`.set()`)`: the name of one field, the reason
belonging to the other, pointing the reader at the wrong line.

Key static fields `Class.field` and resolve a write to the same shape, via a
new `memberPath()` that takes the first two segments of a member chain and
tries that key before the bare root identifier. Two follow-ons fall out of
having the path:

- `this.field` inside a `static` member resolves to the class, which is the
  ordinary way to write the mutation. `staticClassOf()` returns nothing for an
  instance member, where `this` is an instance and the state is per-instance
  rather than per-copy, and nothing inside a nested `function`, which rebinds
  `this`.
- `state.count++` is now a finding, like the `state.count += 1` that
  `assignment()` already reported.

Fixtures pin all four, including the instance-field case that must stay clean.
The four world packages still report zero, and the extracted `recordMutation()`
keeps the file at its previous two Biome complexity warnings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: make module duplication inert across every bundled package

`@workflow/core` is bundled into the host server build the same way the worlds
are, and always has been — the original repro measured three live copies in
every arm, including the pre-#3493 external one. One instance is not reachable:
layers cannot share a module, and core cannot be external because it *is*
workflow code (`runtime/start.ts:253` and nine methods in `runtime/run.ts` are
`'use step'`), so it must go through the SWC loader. The Next integration
already encodes that rule by removing workflow-bearing packages from
`serverExternalPackages`.

So the duplication stays and the hazard is removed instead, everywhere the
duplication can happen.

`@workflow/core` (22 findings to 0): warn-once latches in `constants.ts`,
`start.ts` and `telemetry.ts`; the source-map tracer cache; the VM script cache;
the QuickJS compiled-assets and baseline caches; the dev-server port cache (its
own comment already said "per process"); the text codecs; the zstd browser
decoder; and the `useStep` closure brand, where a function marked by one copy
was invisible to another.

The one with teeth was `step-single-flight.ts`: a per-copy map is not
single-flight. Two invocations reaching it through different layers would each
believe they were alone in the process and both run the step body, silently
degrading in-process dedup to the cross-process residual its own doc scopes out
to the ownership lease.

Also `@workflow/world` (a warn-once set, hand-rolled onto `globalThis` to keep
that package dependency-free), `@workflow/ai` (the lazy OTel API), and
`@workflow/nest` (bootstrap config in a module-level `let` and two static class
fields — configure one copy, read another, and the controller is unconfigured
for the life of the process).

Five sites are deliberately per-copy and now say why: state keyed on objects
that never cross copies (the barrier safety-net `WeakSet`, the QuickJS pending
byte `WeakMap`), the synchronously-scoped guest-code sink, and the OTel
diagnostic that reports what *this* copy sees.

The sweep now covers all of it. Packages with a single module graph stay out
(build-time code, the CLI, the o11y UI, the test runner) and AGENTS.md records
which and why.

Found while doing this: two static fields on one class collapsed into a single
entry in the rule, so `WorkflowModule.options` was invisible behind
`WorkflowModule.outDir`. Statics are now keyed `Class.field`.

* fix(world): suppress noAssignInExpressions on the globalThis idiom

The hand-rolled form trips Biome, as it does in `packages/core/src/private.ts`,
which carries the same suppression. Restructuring it into a helper function
instead would hide the state behind a call the module-scope rule cannot follow,
so the binding would stop being recognized as off-module and the package would
report a finding for correct code.

* fix: sweep every bundled package, and mark utils side-effect free

@shalabhc asked on review whether `@workflow/utils` needs this too. It does,
and so do three others: `utils`, `errors`, `serde` and `workflow` all end up in
the host application's server build and none were in the sweep. All four report
zero today, which is exactly the state `world-testing` appeared to be in before
the `.mts` walk was fixed and it turned out to have a real finding. Being clean
and being *checked* are different properties, and only the second one survives
the next contributor.

`sideEffects: false` on `@workflow/utils`: verified that every module in the
package only declares (no import-time work), so a bundler can now drop the
unused parts of the barrel instead of keeping all ~64 KB of it because three
packages import one 476-byte function.

---------

Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Kenneth <kenneth@standardforensics.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Peter Wielander <peter.wielander@vercel.com>
2026-08-21 16:55:24 -07:00
Peter Wielander b2cac623d3 [world] Make the sealed log opt-in instead of default-on (#3735) 2026-08-21 16:32:25 -07:00
Pranay Prakash 447013b73a Run the test suites CI was silently skipping (#3733)
* Run the test suites CI was silently skipping

`turbo test` runs a package's tests only if that package declares a `test`
script, so a suite can sit in the repo for months without ever running. Four
were in that state: @workflow/world (13 files, 160 tests), @workflow/cli (5 /
51), @workflow/nitro (1 / 30), and two files under packages/core/e2e that no
workflow named.

Wire each one up, and add scripts/check-test-suites-wired.mjs plus a lint job
so the next unwired suite fails CI instead of going unnoticed.

Fixes #3731

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Drop the changesets and rename the guard job

The PR only wires up existing suites and adds a CI check, so there is nothing
to release. Rename the job to match its `no-test-overrides` sibling.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 15:59:29 -07:00
Peter Wielander 9760f640bb [e2e] Change race repro hook poke to soft-degrade instead of hard-stop at budget (#3561) 2026-08-21 15:31:52 -07:00
Karthik Kalyan 5a59bb82e8 Add disabled state to decrypt controls (#3715) 2026-08-21 14:35:55 -07:00
Nathan Rajlich e1e64e3de3 docs: apply Vercel technical writing standards (#3704)
* docs: apply Vercel technical writing standards

Audit the complete documentation corpus, package READMEs, skills, and
source TSDoc/comments against the vercel-technical-writing skill and
style-rules.md. Normalize sentence-case headings without changing
published anchors, remove prose em dashes and filler wording, improve
active voice and self-contained phrasing, standardize product/brand
capitalization, American English, list punctuation, units, and code
fence languages, and preserve exact runtime strings/table placeholders.

All executable code is unchanged. Modified skills have their metadata
versions bumped.

* docs: extend writing audit to repository Markdown

Apply the same technical-writing rules to design documents, compiler
specifications, workbench guides, package changelogs, and the remaining
tracked Markdown outside the deployed docs corpus. Preserve historical
meaning, commands, output literals, table placeholders, and heading
anchors.

* docs: exclude generated package changelogs from audit
2026-08-21 14:24:31 -07:00
Shalabh Chaturvedi 252a292f18 [ci] Keep workflow-server override formatting stable (#3713)
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2026-08-21 13:18:49 -07:00
Pranay Prakash 7b79ba37cc Add support for 'noop' event type - spec version 7 (#3634)
Co-authored-by: Peter Wielander <peter.wielander@vercel.com>
2026-08-21 12:53:59 -07:00
Peter Wielander b3dbc6d264 [docs] v5 changes docs: what's new, world upgrade guide, migration skills (#3100) 2026-08-21 12:45:05 -07:00
Karthik Kalyan d012bf0fe3 Preserve run-key HTTP errors (#3599) 2026-08-21 11:59:04 -07:00
Rich Haines d5d19fc8d5 docs: update Geistdocs to 1.20.4 (#3654) 2026-08-21 11:43:41 -07:00
Peter Wielander 9b1b8c7111 [core] Pin correlation-id draw order to event-log order (#3700) 2026-08-21 11:31:42 -07:00
Pranay Prakash 9454d51db0 feat(core): resolve run.returnValue via a World long poll instead of a 1s poll (#3570)
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Peter Wielander <peter.wielander@vercel.com>
2026-08-20 13:19:25 -07:00
Peter Wielander c431cc18fd [e2e] Add blocked-branch scenario to the event-log race repro (#3696) 2026-08-20 12:41:57 -07:00
Mitul Shah a06afeefe6 Prefix marker context cards with Hook received / Attribute set (#3692)
* fix(web-shared): use UTC tooltips for trace viewer markers

Replace the relative-time context card on hook and attribute ticks with the
shared tooltip, labeled `Hook received [UTC] …` and `Attribute set [UTC] …`.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Mitul Shah <mitulxshah@gmail.com>

* fix(web-shared): format marker helpers and drop invalid aria-label

Biome requires the kind filter ternary on one line, and aria-label is not
valid on the tooltip trigger span.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

* fix(web-shared): prefix marker context cards with event kind

Restore the relative-time context card on hook and attribute ticks, and
prefix the relative time with "Hook received" or "Attribute set".

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

* refactor(web-shared): slim marker context-card prefix

Drop the label helper, type guard, and unused DefaultTimeText prefix path.
Keep kind on the marker, map copy at the tick, and prefix only the card heading.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

* refactor(web-shared): drop prefix comments and generic event-mark helper

Leave sortedEventMarks as a plain string filter. The prefix prop does not
need a JSDoc restatement.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

---------

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-08-20 10:06:22 -07:00
Simon H 37ed0493e1 fix: Better loading of SvelteKit routes directory (#3509)
Instead of accessing private files from SvelteKit, we use @sveltejs/load-config to load the Svelte config (that package also knows about checking Vite config). The deadlock is avoided by having a module-level Set to see if we're currently recursing or not.

This is necessary for SvelteKit 3 since there the config lives exclusively in the vite config, and the previous logic did not handle that.

This also uncovered that we're needlessly rebuilding the generated files in sub builds/workers (SvelteKit, at least below 3, starts off secondary builds; and some things are done in workers), which a new file cache now checks.

Picked from stable branch PR #3474

Signed-off-by: Simon Holthausen <simon.holthausen@vercel.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
2026-08-20 09:22:16 +00:00