Skip to content

[core][world] Include hook_received event ID in resumeHook() wake - #5468

Merged
karthikscale3 merged 5 commits into
mainfrom
ben/wake-names-its-event
Nov 19, 2026
Merged

karthikscale3 merged 5 commits into
mainfrom
ben/wake-names-its-event

Conversation

@benpankow

@benpankow benpankow commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

When operating in spec 9, a resumeHook() wake carries only the run ID. Sometimes the wake reaches a process that has already consumed the run's log. In this case, the delivery must first read the log tail to decide whether the wake is a no-op, and loads the log if not. For a hook resume, that read is wasteful, and it delays the step the payload starts. In traces of an eve chat session it took 40–104ms on Vercel.

This adds wakeEventId to WorkflowInvokePayload, set to the hook_received event that resumeHook() just wrote. If that event is past what this process has already consumed, the delivery skips the tail read and loads the log directly. In every other case nothing changes. It's only a hint: a malformed value parses to undefined, and continuation messages drop it.

How did you test your changes?

New unit tests in resume-hook.durable.test.ts and orchestrator.runtime.test.ts. The orchestrator test fails with the check disabled.

PR Checklist - Required to merge

  • 📦 pnpm changeset was run to create a changelog for this PR
    • Use the correct semver bump type: patch for bug fixes, minor for new features, major for breaking changes.
    • Use pnpm changeset --empty if you are changing documentation or workbench apps
  • 🔒 DCO sign-off passes (run git commit --signoff on your commits)
  • 📝 Ping @vercel/workflow in a comment once the PR is ready, and the above checklist is complete

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
example-nextjs-workflow-turbopack Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
example-nextjs-workflow-webpack Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
example-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-astro-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-express-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-fastify-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-hono-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-nestjs-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-nitro-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-nuxt-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-python-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-sveltekit-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-tanstack-start-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workbench-vite-workflow Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workflow-docs Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workflow-swc-playground Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workflow-tarballs Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC
workflow-web Ready Ready Preview, v0 Nov 19, 2026 1:50am UTC

@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

You must have Developer access to commit code to Vercel Labs on Vercel. If you contact an administrator and receive Developer access, commit again to see your changes.

Learn more: https://vercel.com/docs/accounts/team-members-and-roles/access-roles#team-level-roles

@changeset-bot

changeset-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ea47270

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@workflow/core Patch
@workflow/world Patch
@workflow/world-local Patch
@workflow/world-postgres Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/web Patch
workflow Patch
@workflow/world-cloudflare Patch
@workflow/world-testing Patch
@workflow/errors Patch
@workflow/world-vercel Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
@workflow/nuxt Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

✅ All tests passed

⚠️ Flaky E2E Tests (passed on retry)

These tests failed at least once and passed on a retry. A recurring entry here is a real race worth investigating.

  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running (nextjs-webpack · local-dev / local / node / canary)
  • webhookWorkflow (nuxt · local-dev / local / node / stable)

🛠 Infra Events (absorbed by the harness)

Platform anomalies the e2e harness detected and worked around (e.g. a run the queue never picked up, replaced by a fresh run). Clustered timestamps indicate a backend blip; a steady drip indicates a platform issue worth escalating.

  • run-pickup-stall · runs app-generated source against a registered step (tanstack-start) · at 01:52:06Z · abandoned wrun_01M7RR1HR3VTQTEYT99EE8CAQX
  • cold-start-warmup · suite warmup (tanstack-start) · at 01:52:07Z · abandoned wrun_01M7RR1HR4A6Y9RH9XX3YMHY80

E2E Test Summary

Summary
Passed Failed Skipped Total
✅ ▲ Vercel Production 4649 0 940 5589
✅ 💻 Local Development 5272 0 731 6003
✅ 📦 Local Production 5272 0 731 6003
✅ 🐘 Local Postgres 5417 0 586 6003
✅ 🪟 Windows 401 0 13 414
✅ 🌐 Cross-language Conformance 68 0 114 182
✅ dynamic-runs 0 0 0 0
✅ local-postgres-spec9 0 0 364 364
✅ local-spec9 409 0 5 414
✅ vercel-http-transport 1054 0 188 1242
✅ vercel-multi-region 27 0 0 27
✅ vercel-queue-hold 4 0 0 4
✅ vercel-spec9 395 0 19 414
✅ vercel-ws-transport 712 0 116 828
Total 23680 0 3807 27487
Details by Category

✅ ▲ Vercel Production

App Passed Failed Skipped
✅ astro-node 171 0 36
✅ astro-quickjs 170 0 37
✅ example-node 171 0 36
✅ example-quickjs 170 0 37
✅ express-node 171 0 36
✅ express-quickjs 170 0 37
✅ fastify-node 171 0 36
✅ fastify-quickjs 170 0 37
✅ hono-node 171 0 36
✅ hono-quickjs 170 0 37
✅ nest-node 171 0 36
✅ nest-quickjs 170 0 37
✅ nextjs-turbopack-node 199 0 8
✅ nextjs-turbopack-quickjs 198 0 9
✅ nextjs-webpack-node 199 0 8
✅ nextjs-webpack-quickjs 198 0 9
✅ nitro-node 171 0 36
✅ nitro-quickjs 170 0 37
✅ nuxt-node 171 0 36
✅ nuxt-quickjs 170 0 37
✅ python-node 66 0 141
✅ sveltekit-node 190 0 17
✅ sveltekit-quickjs 189 0 18
✅ tanstack-start-node 171 0 36
✅ tanstack-start-quickjs 170 0 37
✅ vite-node 171 0 36
✅ vite-quickjs 170 0 37

✅ 💻 Local Development

App Passed Failed Skipped
✅ astro-stable-node 172 0 35
✅ astro-stable-quickjs 171 0 36
✅ express-stable-node 172 0 35
✅ express-stable-quickjs 171 0 36
✅ fastify-stable-node 172 0 35
✅ fastify-stable-quickjs 171 0 36
✅ hono-stable-node 172 0 35
✅ hono-stable-quickjs 171 0 36
✅ nest-stable-node 172 0 35
✅ nest-stable-quickjs 171 0 36
✅ nextjs-turbopack-canary-node 201 0 6
✅ nextjs-turbopack-canary-quickjs 200 0 7
✅ nextjs-turbopack-quickjs-snapshot 200 0 7
✅ nextjs-turbopack-stable-node 201 0 6
✅ nextjs-turbopack-stable-quickjs 200 0 7
✅ nextjs-webpack-canary-node 201 0 6
✅ nextjs-webpack-canary-quickjs 200 0 7
✅ nextjs-webpack-stable-node 201 0 6
✅ nextjs-webpack-stable-quickjs 200 0 7
✅ nitro-stable-node 172 0 35
✅ nitro-stable-quickjs 171 0 36
✅ nuxt-stable-node 172 0 35
✅ nuxt-stable-quickjs 171 0 36
✅ sveltekit-stable-node 191 0 16
✅ sveltekit-stable-quickjs 190 0 17
✅ tanstack-start-node 172 0 35
✅ tanstack-start-quickjs 171 0 36
✅ vite-stable-node 172 0 35
✅ vite-stable-quickjs 171 0 36

✅ 📦 Local Production

App Passed Failed Skipped
✅ astro-stable-node 172 0 35
✅ astro-stable-quickjs 171 0 36
✅ express-stable-node 172 0 35
✅ express-stable-quickjs 171 0 36
✅ fastify-stable-node 172 0 35
✅ fastify-stable-quickjs 171 0 36
✅ hono-stable-node 172 0 35
✅ hono-stable-quickjs 171 0 36
✅ nest-stable-node 172 0 35
✅ nest-stable-quickjs 171 0 36
✅ nextjs-turbopack-canary-node 201 0 6
✅ nextjs-turbopack-canary-quickjs 200 0 7
✅ nextjs-turbopack-quickjs-snapshot 200 0 7
✅ nextjs-turbopack-stable-node 201 0 6
✅ nextjs-turbopack-stable-quickjs 200 0 7
✅ nextjs-webpack-canary-node 201 0 6
✅ nextjs-webpack-canary-quickjs 200 0 7
✅ nextjs-webpack-stable-node 201 0 6
✅ nextjs-webpack-stable-quickjs 200 0 7
✅ nitro-stable-node 172 0 35
✅ nitro-stable-quickjs 171 0 36
✅ nuxt-stable-node 172 0 35
✅ nuxt-stable-quickjs 171 0 36
✅ sveltekit-stable-node 191 0 16
✅ sveltekit-stable-quickjs 190 0 17
✅ tanstack-start-node 172 0 35
✅ tanstack-start-quickjs 171 0 36
✅ vite-stable-node 172 0 35
✅ vite-stable-quickjs 171 0 36

✅ 🐘 Local Postgres

App Passed Failed Skipped
✅ astro-stable-node 177 0 30
✅ astro-stable-quickjs 176 0 31
✅ express-stable-node 177 0 30
✅ express-stable-quickjs 176 0 31
✅ fastify-stable-node 177 0 30
✅ fastify-stable-quickjs 176 0 31
✅ hono-stable-node 177 0 30
✅ hono-stable-quickjs 176 0 31
✅ nest-stable-node 177 0 30
✅ nest-stable-quickjs 176 0 31
✅ nextjs-turbopack-canary-node 206 0 1
✅ nextjs-turbopack-canary-quickjs 205 0 2
✅ nextjs-turbopack-quickjs-snapshot 205 0 2
✅ nextjs-turbopack-stable-node 206 0 1
✅ nextjs-turbopack-stable-quickjs 205 0 2
✅ nextjs-webpack-canary-node 206 0 1
✅ nextjs-webpack-canary-quickjs 205 0 2
✅ nextjs-webpack-stable-node 206 0 1
✅ nextjs-webpack-stable-quickjs 205 0 2
✅ nitro-stable-node 177 0 30
✅ nitro-stable-quickjs 176 0 31
✅ nuxt-stable-node 177 0 30
✅ nuxt-stable-quickjs 176 0 31
✅ sveltekit-stable-node 196 0 11
✅ sveltekit-stable-quickjs 195 0 12
✅ tanstack-start-node 177 0 30
✅ tanstack-start-quickjs 176 0 31
✅ vite-stable-node 177 0 30
✅ vite-stable-quickjs 176 0 31

✅ 🪟 Windows

App Passed Failed Skipped
✅ nextjs-turbopack-node 201 0 6
✅ nextjs-turbopack-quickjs 200 0 7

✅ 🌐 Cross-language Conformance

App Passed Failed Skipped
✅ python 68 0 114

✅ dynamic-runs

App Passed Failed Skipped
✅ astro-vercel 0 0 0
✅ example-vercel 0 0 0
✅ express-vercel 0 0 0
✅ fastify-vercel 0 0 0
✅ hono-vercel 0 0 0
✅ nest-vercel 0 0 0
✅ nextjs-turbopack-vercel 0 0 0
✅ nextjs-webpack-vercel 0 0 0
✅ nitro-vercel 0 0 0
✅ nuxt-vercel 0 0 0
✅ sveltekit-vercel 0 0 0
✅ tanstack-start-vercel 0 0 0
✅ vite-vercel 0 0 0

✅ local-postgres-spec9

App Passed Failed Skipped
✅ nextjs-turbopack-stable-node 0 0 182
✅ nextjs-turbopack-stable-quickjs 0 0 182

✅ local-spec9

App Passed Failed Skipped
✅ nextjs-turbopack-node 205 0 2
✅ nextjs-turbopack-quickjs 204 0 3

✅ vercel-http-transport

App Passed Failed Skipped
✅ example 171 0 36
✅ express 171 0 36
✅ hono 171 0 36
✅ nextjs-turbopack 199 0 8
✅ nitro 171 0 36
✅ vite 171 0 36

✅ vercel-multi-region

App Passed Failed Skipped
✅ nextjs-turbopack 27 0 0

✅ vercel-queue-hold

App Passed Failed Skipped
✅ nextjs-turbopack 4 0 0

✅ vercel-spec9

App Passed Failed Skipped
✅ nextjs-turbopack-node 198 0 9
✅ nextjs-turbopack-quickjs 197 0 10

✅ vercel-ws-transport

App Passed Failed Skipped
✅ example 171 0 36
✅ express 171 0 36
✅ nextjs-turbopack 199 0 8
✅ vite 171 0 36

📋 View full workflow run

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit ea47270 · Thu, 19 Nov 2026 01:54:42 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 1744 (+598%) 🔻 1818 🔴 (+26%) 🔻 1843 🔴 (+18%) 🔻 1975 🔴 (-2.5%) 30
TTFS stream 1718 (+563%) 🔻 1796 🔴 (+27%) 🔻 1828 🔴 (+18%) 🔻 1882 🔴 (+15%) 🔻 30
TTFS hook + stream 1918 (+335%) 🔻 2012 🔴 (+12%) 2042 🔴 (+8.7%) 2200 🔴 (+4.7%) 30
Fan-out TTFS Promise.all(100 steps) 328 (-10%) 610 (+17%) 🔻 664 (+19%) 🔻 2114 (+202%) 🔻 10
Fan-out TTLS Promise.all(100 steps) 1018 (+13%) 3640 (-2.2%) 3792 (-1.6%) 7265 (+80%) 🔻 10
STSO 1020 steps (inline) 72 (-28%) 💚 93 (-32%) 💚 109 (-33%) 💚 151 (-59%) 💚 1019
WO 1020 steps 91964 (-33%) 💚 91964 (-33%) 💚 91964 (-33%) 💚 91964 (-33%) 💚 1
📈 STSO distribution vs main (inline / queue-hop histograms)

1020 steps (inline)

Cumulative STSO time: main 136400ms → this run 91756ms (Δ -44644ms, -33%)

 50-100 ms  ░░░░░░░░░░░░░░░░░░░░░░░┃  main   0  this 857  +857
100-150 ms  ███┃████████████████████  main 860  this 150  -710
150-200 ms  ┃██                       main 109  this  11   -98
200-250 ms  ┃                         main  23  this   1   -22
250-300 ms  ┃                         main   9  this   0    -9
300-350 ms  ┃                         main   6  this   0    -6
350-400 ms  ┃                         main   5  this   0    -5
400-450 ms  ┃                         main   6  this   0    -6
450-500 ms  ┃                         main   1  this   0    -1
ℹ️ Metric definitions & methodology

The collapsed STSO distribution section above buckets every step gap, split inline (same warm process — pure framework overhead) vs queue-hop (fresh process — dispatch, reinit, replay). █ = main, ┃ = this run, ░ = fill.

Best/P75/P90/P99 deltas compare against the most recent benchmark run on main at the time of this run. 🔻 flags a delta worse than +15%, 💚 one better than −15%.

Metrics — TTFS: time to first step body (in-deployment start() → first step body) · Fan-out TTFS: fan-out time to first step (in-deployment start() → first of the parallel step bodies to complete) · Fan-out TTLS: fan-out time to last step (in-deployment start() → last of the parallel step bodies to complete, i.e. when the Promise.all resolves) · STSO: step-to-step overhead (gap between consecutive step bodies) · WO: workflow overhead (whole-run time outside step bodies, in-deployment anchored)

Scenarios — step: one trivial no-op step, no stream; no hooks, so the run stays in turbo mode (in-process fast path) · stream: one streaming step; no hooks, so the run stays in turbo mode (in-process fast path) · hook + stream: registers a hook before one step, which exits turbo mode (dispatch path) · 1020 steps: 1020 trivial sequential steps; STSO is measured between consecutive steps in the given step ranges, and WO is the whole-run overhead outside step bodies · Promise.all(100 steps): 100 trivial no-op steps started together in a single Promise.all; Fan-out TTFS is the first of them to complete and Fan-out TTLS the last, both from the in-deployment clientStart, so their gap is the spread the runtime adds across the fan-out

🔴 marks a percentile over its target (within target is left unmarked). Targets (p75/p90/p99, ms) — TTFS 200/300/600

All timestamps are deployment-side; runs are triggered in-deployment, so the CI runner and api.vercel.com sit outside every measured window. TTFS = start() → first step body (includes dispatch + any cold start); Fan-out TTFS/TTLS = first/last step completion of one Promise.all from the same anchor (the gap is the runtime’s fan-out spread); STSO/WO between step bodies. Streaming delivery performance is measured in durabench.

Cold starts stay in the numbers (real bursty-workload latency, inflates P75+); Best is the warm floor.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Sim World

Simulated world deterministic testing for races. Traces

🟢 world-sim scenario book — 0 fail of 45 total
scenario outcome events virt replay violations
✅ smoke-no-steps completed 3 0ms ok 0
✅ smoke-one-step completed 5 0ms ok 0
✅ hook-at-step-started completed 9 0ms ok 0
✅ hook-at-step-completed completed 9 0ms ok 0
✅ hook-at-hook-created completed 9 0ms ok 0
✅ claim-hook-at-registration completed 9 0ms ok 0
✅ claim-hook-at-step-started completed 9 0ms ok 0
✅ deadline-hook-wins completed 6 1.0h ok 0
✅ deadline-expires completed 6 1.0h ok 0
✅ step-vs-timer-early-settlement completed 6 1.0h ok 0
✅ long-sleep completed 9 30.0d ok 0
✅ hook-never-arrives stalled 3 0ms skipped 0
✅ step-retries-twice completed 9 2.0s ok 0
✅ parallel-steps completed 7 0ms ok 0
✅ hook-on-execution-state completed 9 0ms ok 0
✅ peek-hook-before-branch completed 9 0ms ok 0
✅ peek-hook-after-branch completed 9 0ms ok 0
✅ peek-hook-at-registration completed 9 0ms ok 0
✅ race-hook-before-probe completed 9 0ms ok 0
✅ race-hook-after-probe completed 9 0ms ok 0
✅ race-duplicate-delivery completed 10 0ms ok 0
✅ attr-hook-before-step completed 9 0ms ok 0
✅ attr-hook-after-step completed 9 0ms ok 0
✅ attr-from-step-body completed 10 0ms ok 0
✅ fork-hook-after-timeout completed 11 1.0m ok 0
✅ fork-hook-before-timeout completed 11 1.0m ok 0
✅ count-hook-after-timeout completed 13 1.0m ok 0
✅ count-hook-before-timeout completed 15 1.0m ok 0
✅ stale-read-step-count-fork completed 15 1.0m ok 0
✅ stale-read-equal-step-counts completed 11 1.0m ok 0
✅ step-vs-step-fork completed 9 0ms ok 0
✅ step-vs-step-fork-fenced completed 9 1.0s ok 0
✅ fence-catches-benign-direction completed 9 1.0s ok 0
✅ run-ahead-fenced-overlap completed 10 1.0s ok 0
✅ in-flight-before-decision completed 15 1.0m ok 0
✅ in-flight-before-decision-counted completed 13 1.0m ok 0
✅ in-flight-after-decision completed 15 2.0m ok 0
✅ stale-read-step-count-fork-fenced completed 15 1.0m ok 0
✅ fork-hook-wins completed 10 1.0m ok 0
✅ fork-timeout-wins completed 10 1.0m ok 0
✅ unclaimed-payload-under-fork completed 14 1.0m ok 0
✅ claimed-payload-under-fork completed 14 1.0m ok 0
✅ writers-independent-step-bodies completed 9 0ms ok 0
✅ writers-scripted-tempo completed 9 0ms ok 0
✅ cancel-mid-step cancelled 6 0ms skipped 0

Full trace: world-sim.txt

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor
Framework Flow route Step reg. Framework output
hono 306.4 KiB (+174 B) 124.0 KiB (+44 B) 2.40 MiB (+712 B)
nextjs-turbopack 397.9 KiB (+167 B) 491 B (±0) 1.13 MiB (+272 B)
About these numbers

Sizes are gzip; parentheses show the change against main.
Flow route and Step reg. gate this job, on raw bytes rather than the gzip shown, at max(2%, 50.0 KiB). Framework output is informational.

ea47270 · run

@benpankow benpankow changed the title [core][world] Name the hook_received on its resumeHook() wake [core][world] Include hook_received event ID in resumeHook() wake Nov 16, 2026
@benpankow
benpankow marked this pull request as ready for review November 16, 2026 19:46
@benpankow
benpankow requested a review from a team as a code owner November 16, 2026 19:46
@benpankow

Copy link
Copy Markdown
Contributor Author

@vercel/workflow another eve improvement, this one for resume hooks for suspended sessions

@benpankow

Copy link
Copy Markdown
Contributor Author

Folded into #5573, which keeps this wake naming and builds the parked-VM handoff on it (stacked on #5470).

@benpankow benpankow closed this Nov 18, 2026
@benpankow benpankow reopened this Nov 18, 2026
benpankow and others added 4 commits November 18, 2026 09:22
Signed-off-by: benpankow <ben.pankow@vercel.com>
QuickJS records no consumed position and never reads the tail, so its
assertions held whatever the wake named.

Signed-off-by: benpankow <ben.pankow@vercel.com>
Signed-off-by: benpankow <ben.pankow@vercel.com>
Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
8b9b845 carries wakeEventId through coalesced re-runs on world-local and world-postgres (the first run's already-consumed value is stripped, the absorbed wake's is carried with its resume timing), records workflow.noop_check_skipped on the span when the hint skips the tail read, and covers a malformed or non-slot hint, the replay the hinted wake runs, and the resolved-fallback write's event ID. Its message lost everything but a mismatched sign-off.

I, Ben Pankow <pankow.ben@gmail.com>, hereby add my Signed-off-by to this commit: 8b9b845

Signed-off-by: Ben Pankow <pankow.ben@gmail.com>

Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.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.

(AI) Preliminary review:

AI review: no blocking issues

// Node only: the QuickJS engine records no consumed position, so it never
// reads the tail and there is nothing for the wake to skip.
it.runIf(engine === 'node')(
'skips the tail read for a wake that names an event it has not consumed',

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.

AI Review: Note

The two halves are tested separately. resume-hook.durable.test.ts mocks createEvent to return { event: { eventId } }, and this test enqueues a hand-built wake. No test runs a real resumeHook() wake through a delivery. If a World's events.create response stopped carrying event.eventId for an out-of-band hook_received, the hint would go away without any test failing.

I ran a throwaway test in the style of hook-wait.runtime.test.ts (real resumeHook() against AppendOnlyWorld, node engine). It's a multi-turn chat loop (for await (const p of hook) await tick(p.value)):

  • Every wake carried the hook_received id that the World wrote.
  • Each turn's delivery did 0 tail reads, the run completed, and a cold replay gave the same result.
  • With !wakesForNewEvent() removed, it fails on the first turn (tailReads: 1).
  • Two resumes before any delivery: the first wake skips the tail read and consumes both events. The second wake then names an event at or below the consumed position, so it does exactly one tail read and acknowledges as a no-op (no new events, no extra step run).

Consider adding a version of the first case to hook-wait.runtime.test.ts. It would catch a break anywhere between producer and consumer:

await resumeHook(TOKEN, { value });
expect((world.held.at(-1)!.message as { wakeEventId?: string }).wakeEventId)
  .toBe(eventsOf(world, 'hook_received').at(-1)!.eventId);
const before = world.listCalls.filter(isTailRead).length;
await world.runUntilIdle();
expect(world.listCalls.filter(isTailRead).length).toBe(before);

const wakesForNewEvent = (): boolean => {
const slot = wakeEventId ? eventIdToSlot(wakeEventId) : null;
const isNew = slot !== null && isAboveConsumedPosition(world, runId, slot);
if (isNew) span?.setAttributes(Attribute.WorkflowNoopCheckSkipped(true));

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.

AI Review: Nit

wakesForNewEvent() sets the span attribute inside the if condition. workflow.noop_check_skipped only means "skipped the tail read" because this call is the last conjunct and only runs once every other condition holds. If someone reorders the conjuncts, the attribute would be set on deliveries that never reach the tail read. Two options: say so in a comment, or compute skip before the if and set the attribute next to where the read would have happened.

Separately, a wake that names an event the hint can't use (already consumed, or not slot-numbered) leaves no trace. Recording a false (or a reason) when wakeEventId is present but unused would show how often the hint actually fires in traces. It's optional, but it's the number you'd want when deciding whether the hint pays off.

string,
unknown
>;
return hookResumeTiming === undefined

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.

AI Review: Nit

resumeOf here and in world-local/src/queue.ts:459 only carries wakeEventId to the re-run when the absorbed wake also has hookResumeTiming. That's fine for resumeHook(), which always sends both. But the schema doc in world/src/queue.ts describes wakeEventId generally ("the event an out-of-band writer committed before it sent this wake"). A future producer that sets only wakeEventId would lose it silently on a coalesced re-run. It's harmless, since the field is only a hint. Either narrow the doc to hook resumes, or carry wakeEventId on its own.

"@workflow/world-postgres": patch
---

A `resumeHook()` wake names the `hook_received` it was sent for, so a spec 9 orchestrator delivery in a process that already consumed the run's log below that event skips the tail read that checks for a no-op wake.

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.

AI Review: Note

The last comment says this was folded into #5573, but this PR is still the base of #5467, which #5470 and #5573 stack on, and all three contain these commits. Is the plan to land #5468 first and then the stack, or to close it and land everything through #5573? If it's closed, #5467 has to be retargeted to main. I reviewed this PR on its own and only skimmed how #5467 (the test change in b7129b6) and #5573 (matching kept events by wakeEventId) use the field.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Karthik Kalyanaraman <karthik.kalyanaraman@vercel.com>
@karthikscale3

Copy link
Copy Markdown
Contributor

AI note: I merged main into this branch (clean, no conflicts) and then tested it. Everything I checked is verified and I found no issues. @VaguelySerious has already reviewed, so I will leave the approval to Peter.

Why I think it is safe by construction. The new check sits in front of the "nothing new, acknowledge without a replay" exit. When it fires, the delivery skips that exit's tail read and takes the normal load and replay. It adds no new way to acknowledge early, so a wrong or stale wakeEventId can cost an extra read but cannot drop a resume. The earlier "run already ended in this process" exit still runs first.

What I ran

  • Suites at this head: core runtime (2777 passed), world-local queue (58), world (300), and the Postgres queue tests against a real Postgres container (62). The new orchestrator test fails with the check disabled, so it does test the change.
  • A real resumeHook() from this build against a locally running server, with the wake delivered to a process that already held the run's position. This also covers the review note that no test runs a real resumeHook() wake through a delivery:
Scenario Tail reads Result
Wake with wakeEventId 0 payload delivered, run continues
Same wake without it 1 same outcome, one more read
Duplicate of a wake already consumed 1 nothing new, acknowledged
Two resumes, wakes delivered in reverse order 0 all payloads delivered, run completes
Wake after the run completed 0 acknowledged with no reads
  • On the real local World, four resumes with two arriving while a delivery was running (absorbed into it): every payload reached the workflow once, in order, and tail reads went from 2 on main to 0.
  • Old receiver, new sender: a build of main without this change handled wakes carrying wakeEventId exactly as it handles plain ones (same steps, same order, same reads).
  • Edge cases: a hint naming an event the load cannot see yet (loads, finds nothing, acknowledges, no loop); two wakes for new events at once; malformed values (empty, null, object, array, negative, out of range, non-slot ids) all fall back to the tail read; a redelivered wake carrying the hint takes the normal path.

Not covered. A real multi-region deployment (the hint is a position in the run's own log, so it compares the same anywhere, and a stale read there would cost an extra load); a 4.x receiver; and the latency saving itself, which I did not measure.

Two observations, neither blocking

  • On the Vercel queue a coalesced re-run reuses the original message, so it keeps that wake's wakeEventId rather than taking the absorbed resume's as the local and Postgres queues now do. By then that event is consumed, so it falls back to the tail read.
  • Absorbed resumes cost no tail read even on main, since a coalesced re-run always loads the log. The saving is for resumes that arrive while the run is idle.

@karthikscale3
karthikscale3 merged commit 80d89c0 into main Nov 19, 2026
200 checks passed
@karthikscale3
karthikscale3 deleted the ben/wake-names-its-event branch November 19, 2026 14:41
@github-actions

Copy link
Copy Markdown
Contributor

No backport to stable for 80d89c0 (AI decision).

This is a latency optimization for the opt-in spec 9 orchestrator, not a fix for a defect: it adds a new wakeEventId field to WorkflowInvokePayload so a resumeHook() wake can skip a tail read. Behavior is already correct without it. Performance work and new payload/API surface are feature work and do not belong on the stable maintenance line.

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

80d89c07d77f2382b7b6d7cecf285fe2159c22a9

@github-actions github-actions Bot mentioned this pull request Nov 19, 2026

This branch was successfully deployed

1 active deployment
Preview – workflow-docs — ea472705 Deployed Nov 19, 2026 by vercel[bot]
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.

3 participants