Skip to content

Cache workflow event prefixes and immutable refs#2256

Draft
pranaygp wants to merge 1 commit into
mainfrom
pranaygp/codex/bounded-workflow-cache
Draft

Cache workflow event prefixes and immutable refs#2256
pranaygp wants to merge 1 commit into
mainfrom
pranaygp/codex/bounded-workflow-cache

Conversation

@pranaygp
Copy link
Copy Markdown
Contributor

@pranaygp pranaygp commented Jun 4, 2026

Summary

  • retain bounded event-log prefixes in the core runtime and refresh replay from their cursors
  • cache immutable remote ref bytes in world-vercel, with LRU eviction and in-flight request coalescing
  • add coverage for cursor fallback, stale concurrent prefix writes, size bounds, eviction, and repeated ref hydration

Design

The event-log cache lives in the runtime so it applies to any World implementation used for replay. Entries are scoped by World instance to prevent mixing run/cursor state across backing stores or tenants, and every replay still fetches the append-only tail after the cached cursor.

Remote ref caching stays in world-vercel: remote ref descriptors and the ref endpoint are adapter transport details, not part of the generic World contract. The adapter retains only bounded immutable bytes and decodes fresh values for callers.

Memory Bounds

  • event prefixes: 4 MiB total, 64 runs, 512 KiB per run
  • remote refs: 2 MiB total, 128 refs

Validation

  • pnpm --filter '@workflow/core...' build
  • pnpm --dir packages/core test (1,092 tests passed)
  • pnpm --dir packages/world-vercel exec vitest run src (116 tests passed)
  • git diff --check origin/main...HEAD
  • pnpm changeset status --since=main

Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 4, 2026

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 4, 2026

🦋 Changeset detected

Latest commit: cd6a045

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

This PR includes changesets to release 17 packages
Name Type
@workflow/core Patch
@workflow/world-vercel 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-testing 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

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.

1 participant