Skip to content

Centralize workflow event semantics#2790

Open
NathanColosimo wants to merge 10 commits into
mainfrom
codex/centralize-event-semantics
Open

Centralize workflow event semantics#2790
NathanColosimo wants to merge 10 commits into
mainfrom
codex/centralize-event-semantics

Conversation

@NathanColosimo

@NathanColosimo NathanColosimo commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add targeted event type helpers and lifecycle classifiers in @workflow/world
  • centralize eventData ref/payload field lookup for lazy-start and v4 split handling
  • replace duplicated event/status groups across local, postgres, vercel, web-shared, web, and CLI

Tests

  • ./node_modules/.bin/tsc -p packages/world/tsconfig.json
  • ./node_modules/.bin/tsc -p packages/world-local/tsconfig.json --noEmit
  • ./node_modules/.bin/tsc -p packages/world-postgres/tsconfig.json --noEmit
  • cd packages/world-vercel && ./node_modules/.bin/genversion --es6 src/version.ts && ../../node_modules/.bin/tsc --noEmit
  • ./node_modules/.bin/tsc -p packages/web-shared/tsconfig.json --noEmit
  • ./node_modules/.bin/tsc -p packages/cli/tsconfig.json --noEmit
  • cd packages/world-vercel && ../../node_modules/.bin/vitest run src event
  • cd packages/world-local && ../../node_modules/.bin/vitest run src
  • cd packages/web-shared && ../../node_modules/.bin/vitest run

@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0b57804

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

This PR includes changesets to release 20 packages
Name Type
@workflow/world Minor
@workflow/core Patch
@workflow/world-local Patch
@workflow/world-postgres Patch
@workflow/world-vercel Patch
@workflow/web-shared Patch
@workflow/web Patch
@workflow/cli Patch
@workflow/vitest Patch
@workflow/world-testing Patch
@workflow/builders Patch
@workflow/next Patch
@workflow/nitro Patch
workflow 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

@vercel

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

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit 0b57804 · Thu, 09 Jul 2026 22:23:47 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Avg (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS stream 1266 (+26%) 1678 🔴 1789 🔴 1941 🔴 30
TTFS hook + stream 1509 (+21%) 1923 🔴 1967 🔴 2116 🔴 30
STSO 1020 steps (1-20) 296 (+24%) 319 🔴 451 🔴 500 🔴 19
STSO 1020 steps (101-120) 408 (+0.7%) 449 🔴 470 🔴 548 🔴 19
STSO 1020 steps (1001-1020) 1037 (±0%) 953 🔴 1274 🔴 3804 🔴 19
WO stream 1266 (+26%) 1678 1789 1941 30
WO hook + stream 1509 (+21%) 1923 1967 2116 30
SL stream 4132 (-14%) 5093 🔴 5650 🔴 6056 🔴 30
SL hook + stream 5130 (+2.7%) 5733 🔴 5821 🔴 5961 🔴 30
📜 Previous results (1)

b670eda

Thu, 09 Jul 2026 00:30:42 GMT · run logs

vercel / nextjs-turbopack

Metric Scenario Avg (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS stream 2306 3291 🔴 3760 🔴 4941 🔴 30
TTFS hook + stream 1548 1929 🔴 2057 🔴 2141 🔴 30
STSO 1020 steps (1-20) 274 307 🔴 368 🔴 450 🔴 19
STSO 1020 steps (101-120) 423 499 🔴 528 🔴 546 🔴 19
STSO 1020 steps (1001-1020) 824 850 🔴 959 🔴 969 🔴 19
WO stream 2306 3291 3760 4941 30
WO hook + stream 1548 1929 2057 2141 30
SL stream 4377 4879 🔴 5593 🔴 7929 🔴 30
SL hook + stream 4811 5405 🔴 5592 🔴 5881 🔴 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.

@NathanColosimo NathanColosimo force-pushed the codex/centralize-event-semantics branch from dd190fb to 394f4c2 Compare July 6, 2026 22:19
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1453 0 230 1683
✅ 💻 Local Development 1617 0 219 1836
✅ 📦 Local Production 1617 0 219 1836
✅ 🐘 Local Postgres 1617 0 219 1836
✅ 🪟 Windows 153 0 0 153
✅ 📋 Other 894 0 177 1071
Total 7351 0 1064 8415

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-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 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

…t-semantics

# Conflicts:
#	packages/cli/src/commands/cancel.ts
…t-semantics

# Conflicts:
#	packages/web-shared/src/components/sidebar/entity-detail-panel.tsx
…t-semantics

# Conflicts:
#	packages/world-local/src/storage/hooks-storage.ts

@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.

human review, ai tbd

input?: any;
output?: any;
metadata?: any;
eventType?: string;

@VaguelySerious VaguelySerious Jul 9, 2026

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.

eventType should never be encrypted, but result might be

Suggested change
eventType?: string;
result?: any;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, eventType isn't being decrypted

for (const field of getEventDataRefFields(result.eventType ?? '')) {    //line 355
        eventData[field] = await maybeDecrypt(eventData[field], k);
      }

since

  const result = { ...resource }; // line 337

in order to access result.eventType we need to have eventType on the generic T because resource: T in the function

@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 review: no blocking issues.

This pass only flags possible behavior changes introduced by the event-semantics centralization. None are clearly incorrect, but each is a semantic shift from the code it replaced and worth a maintainer's confirmation. See inline notes.

Comment thread packages/world/src/events.ts
Comment thread packages/world/src/events.ts Outdated
Comment thread packages/world/src/events.ts Outdated
Comment thread packages/core/src/serialization-format.ts
Comment thread packages/cli/src/lib/inspect/hydration.ts
Comment thread packages/web-shared/src/lib/event-materialization.ts
Comment thread packages/web-shared/src/components/sidebar/events-list.tsx
Comment thread packages/web-shared/src/components/sidebar/events-list.tsx
Comment thread packages/web-shared/src/components/sidebar/events-list.tsx
Comment thread packages/web/app/components/run-detail-view.tsx
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.

2 participants