Skip to content

feat(core): record replay lineage in run executionContext#2872

Open
mitul-s wants to merge 6 commits into
mainfrom
c+ms/replay-lineage-execution-context
Open

feat(core): record replay lineage in run executionContext#2872
mitul-s wants to merge 6 commits into
mainfrom
c+ms/replay-lineage-execution-context

Conversation

@mitul-s

@mitul-s mitul-s commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Replays currently start a brand-new run with no link back to the run they were replayed from, so tooling can't tell that a run originated as a replay. This adds that link.

  • recreateRunFromExisting now stamps the source run id into the new run's executionContext as replayedFromRunId.
  • start gains an optional replayedFromRunId option (used by recreateRunFromExisting; rarely needed directly) that is merged into the run's executionContext on both the run_created event and the resilient-start queue input.

executionContext is the right home per the repo's own architecture notes ("flexible object that can store arbitrary data without schema changes… flows through all worlds"), and it's already returned on WorkflowRunWithoutData from runs.list, so consumers can read it without resolving full run data.

Motivation

This is the SDK half of a dashboard feature in vercel/front that shows a "Replay of <run id>" indicator next to the workflow name in the all-runs table (mirroring the deployment list's "Redeploy of …"). That PR already reads executionContext.replayedFromRunId; this change is what populates it. Until this lands, the indicator is a no-op because the origin is never recorded.

Changes

  • packages/core/src/runtime/start.ts — add replayedFromRunId? to StartOptionsBase; include it in executionContext when set.
  • packages/core/src/runtime/runs.ts — pass replayedFromRunId: runId from recreateRunFromExisting into start.
  • Tests: start records/omits the key correctly; recreateRunFromExisting forwards the source run id.
  • Changeset (minor, @workflow/core).

Testing

  • pnpm -F @workflow/core vitest run src/runtime/runs.test.ts src/runtime/start.test.ts → 50 passed (incl. 3 new).
  • pnpm -F @workflow/core typecheck → clean.

Notes

  • Observability hydration (hydrateResourceIO) strips executionContext before UI display in this repo's own dashboard; the vercel/front runs list reads world.runs.list directly and is unaffected. If the workflow-repo dashboard should also show this, the value would need to be extracted before stripping (follow-up).

Made with Cursor

recreateRunFromExisting now stamps the source run id into the new run's
executionContext as `replayedFromRunId`, and `start` accepts a matching
option. This lets tooling (e.g. the dashboard runs list) surface a run as
a replay and link back to the run it was replayed from — previously a
replay started a brand-new run with no link to its origin.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mitul-s mitul-s requested review from a team and ijjk as code owners July 10, 2026 15:13
@vercel

vercel Bot commented Jul 10, 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 10, 2026 8:08pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jul 10, 2026 8:08pm
example-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workbench-astro-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workbench-express-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workbench-fastify-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workbench-hono-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workbench-nitro-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workbench-nuxt-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workbench-tanstack-start-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workbench-vite-workflow Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workflow-docs Ready Ready Preview, Comment, Open in v0 Jul 10, 2026 8:08pm
workflow-swc-playground Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workflow-tarballs Ready Ready Preview, Comment Jul 10, 2026 8:08pm
workflow-web Ready Ready Preview, Comment Jul 10, 2026 8:08pm

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f6029ed

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

This PR includes changesets to release 16 packages
Name Type
@workflow/core Minor
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/web Patch
workflow Minor
@workflow/world-testing Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/nuxt Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite 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 Jul 10, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

⚠️ Results below are stale and not from the latest commit. This comment will be updated when CI completes on the latest run.

Tests are running...


_Started at: _


All tests passed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1453 0 230 1683
✅ 💻 Local Development 1483 0 200 1683
✅ 📦 Local Production 1617 0 219 1836
✅ 🐘 Local Postgres 1617 0 219 1836
✅ 🪟 Windows 153 0 0 153
✅ 📋 Other 894 0 177 1071
Total 7217 0 1045 8262

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 126 0 27
✅ example 126 0 27
✅ express 126 0 27
✅ fastify 126 0 27
✅ hono 126 0 27
✅ nextjs-turbopack 150 0 3
✅ nextjs-webpack 150 0 3
✅ nitro 126 0 27
✅ nuxt 126 0 27
✅ sveltekit 145 0 8
✅ vite 126 0 27
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 128 0 25
✅ express-stable 128 0 25
✅ fastify-stable 128 0 25
✅ hono-stable 128 0 25
✅ nextjs-turbopack-canary 134 0 19
✅ nextjs-turbopack-stable 153 0 0
✅ nextjs-webpack-stable 153 0 0
✅ nitro-stable 128 0 25
✅ nuxt-stable 128 0 25
✅ sveltekit-stable 147 0 6
✅ vite-stable 128 0 25
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 128 0 25
✅ express-stable 128 0 25
✅ fastify-stable 128 0 25
✅ hono-stable 128 0 25
✅ nextjs-turbopack-canary 134 0 19
✅ nextjs-turbopack-stable 153 0 0
✅ nextjs-webpack-canary 134 0 19
✅ nextjs-webpack-stable 153 0 0
✅ nitro-stable 128 0 25
✅ nuxt-stable 128 0 25
✅ sveltekit-stable 147 0 6
✅ vite-stable 128 0 25
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 128 0 25
✅ express-stable 128 0 25
✅ fastify-stable 128 0 25
✅ hono-stable 128 0 25
✅ nextjs-turbopack-canary 134 0 19
✅ nextjs-turbopack-stable 153 0 0
✅ nextjs-webpack-canary 134 0 19
✅ nextjs-webpack-stable 153 0 0
✅ nitro-stable 128 0 25
✅ nuxt-stable 128 0 25
✅ sveltekit-stable 147 0 6
✅ vite-stable 128 0 25
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 153 0 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 128 0 25
✅ e2e-local-dev-tanstack-start- 128 0 25
✅ e2e-local-postgres-nest-stable 128 0 25
✅ e2e-local-postgres-tanstack-start- 128 0 25
✅ e2e-local-prod-nest-stable 128 0 25
✅ e2e-local-prod-tanstack-start- 128 0 25
✅ e2e-vercel-prod-tanstack-start 126 0 27

📋 View full workflow run


Some E2E test jobs failed:

  • Vercel Prod: success
  • Local Dev: failure
  • Local Prod: success
  • Local Postgres: success
  • Windows: success

Check the workflow run for details.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

Benchmarks are running for f6029ed... (run logs)

Results below are from a previous run.

commit 1f516ed · Fri, 10 Jul 2026 18:02:02 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Avg (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS stream 1424 (-1.5%) 1779 🔴 1828 🔴 2055 🔴 30
TTFS hook + stream 1666 (-7.8%) 2035 🔴 2085 🔴 2230 🔴 30
STSO 1020 steps (1-20) 320 (+3.9%) 335 🔴 358 🔴 744 🔴 19
STSO 1020 steps (101-120) 467 (+4.3%) 527 🔴 588 🔴 645 🔴 19
STSO 1020 steps (1001-1020) 889 (±0%) 918 🔴 1035 🔴 1302 🔴 19
WO stream 1424 (-1.5%) 1779 1828 2055 30
WO hook + stream 1666 (-7.8%) 2035 2085 2230 30
SL stream 4387 (-11%) 4918 🔴 5673 🔴 6060 🔴 30
SL hook + stream 4851 (±0%) 5445 🔴 5642 🔴 5887 🔴 30
📜 Previous results (1)

df8ab47

Fri, 10 Jul 2026 15:34:19 GMT · run logs

vercel / nextjs-turbopack

Metric Scenario Avg (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS stream 1431 (+22%) 1775 🔴 1868 🔴 2274 🔴 30
TTFS hook + stream 1844 (+34%) 2056 🔴 2158 🔴 2259 🔴 30
STSO 1020 steps (1-20) 301 (+11%) 320 🔴 454 🔴 548 🔴 19
STSO 1020 steps (101-120) 474 (+14%) 509 🔴 604 🔴 918 🔴 19
STSO 1020 steps (1001-1020) 915 (-15%) 927 🔴 1068 🔴 1254 🔴 19
WO stream 1431 (+22%) 1775 1868 2274 30
WO hook + stream 1844 (+34%) 2056 2158 2259 30
SL stream 4562 (-7.4%) 4850 🔴 5765 🔴 5899 🔴 30
SL hook + stream 4678 (-6.9%) 4628 🔴 5502 🔴 5748 🔴 30

Avg deltas compare against the most recent benchmark run on main at the time of this run.

Metrics — TTFS: time to first step body execution · STSO: step-to-step overhead (gap between consecutive step bodies) · WO: workflow overhead (time outside step bodies, client start → last step body exit) · SL: stream latency (first chunk write → visible to the reader)

Scenarios — stream: one step that streams chunks back to the client; no hooks, so the run stays in turbo mode · hook + stream: registers a hook before the same streaming step, which exits turbo mode · 1020 steps: 1020 trivial sequential steps; STSO is measured between consecutive steps in the given step ranges

🟢/🔴 mark percentiles within/above target. Targets (p75/p90/p99, ms) — TTFS 200/300/600 · SL 50/60/125 · STSO (1-20) 20/30/60 · STSO (101-120) 30/45/90 · STSO (1001-1020) 40/60/120

TTFS/WO compare client vs deployment clocks and SL compares the step runner’s clock vs the client’s (NTP-synced in CI). WO ends at the last step body exit, the closest observable proxy for the final step-completion request.

Comment thread packages/core/src/runtime/runs.ts Outdated
Signed-off-by: Mitul Shah <mitulxshah@gmail.com>
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