Skip to content

feat(world-local): support Hook minimum retention#2866

Draft
NathanColosimo wants to merge 7 commits into
codex/hook-retention-corefrom
codex/hook-retention-local
Draft

feat(world-local): support Hook minimum retention#2866
NathanColosimo wants to merge 7 commits into
codex/hook-retention-corefrom
codex/hook-retention-local

Conversation

@NathanColosimo

@NathanColosimo NathanColosimo commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • implement experimental_minRetention in the Local World
  • advertise the hookRetention World capability
  • keep a terminal run's Hook discoverable through ID lookup, token lookup, and listing during retention while rejecting resumes
  • keep its token unavailable until retention ends
  • release the Hook and token immediately when dispose() is called
  • rebuild missing Hook storage from the event log
  • serialize token replacement across storage instances and processes

Stacked on #2865, which defines and documents the core API and event contract.

This PR does not add an external token-release API. That can be designed separately; explicit hook.dispose() remains the immediate release path for the owning workflow.

Implementation

Local World already stores a file for atomic Hook-token ownership. This PR adds the absolute tokenRetentionUntil value to that record instead of introducing a second retained-only entity.

Terminal cleanup keeps the Hook and ownership record only while retention remains. The configured time is a minimum: an active run keeps its Hook valid even after that time. Once both the run is terminal and retention has ended, Hook lookup treats it as unavailable and the next claimant removes the stale files before taking ownership.

Completion, failure, and cancellation all reuse the same terminal cleanup path. A cancelled run therefore has the same retention behavior without separate cancellation logic.

Filesystem locks make each read-delete-write replacement atomic. This matters when multiple createStorage() instances or Node processes share one data directory; JavaScript execution within one process does not serialize those independent instances.

Verification

  • @workflow/world, @workflow/errors, @workflow/core, workflow, and @workflow/world-local builds
  • shared example manifest build: 149 workflows
  • full @workflow/core suite
  • Local World suite: 468 tests
  • Local Next.js E2E: hookMinRetentionWorkflow - terminal Hook cannot resume and its token stays unavailable

Focused coverage includes cancellation and terminal retention across all Hook read APIs, event-log recovery, active runs past the retention boundary, replacement across storage instances, explicit disposal, and same-Hook retry stability.

@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f37fa91

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

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

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

Passed Failed Skipped Total
✅ 💻 Local Development 1494 0 200 1694
✅ 📦 Local Production 1629 0 219 1848
✅ 🐘 Local Postgres 1617 0 231 1848
✅ 🪟 Windows 154 0 0 154
✅ 📋 Other 772 0 152 924
Total 5666 0 802 6468

Details by Category

✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 129 0 25
✅ express-stable 129 0 25
✅ fastify-stable 129 0 25
✅ hono-stable 129 0 25
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 129 0 25
✅ nuxt-stable 129 0 25
✅ sveltekit-stable 148 0 6
✅ vite-stable 129 0 25
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 129 0 25
✅ express-stable 129 0 25
✅ fastify-stable 129 0 25
✅ hono-stable 129 0 25
✅ nextjs-turbopack-canary 135 0 19
✅ nextjs-turbopack-stable 154 0 0
✅ nextjs-webpack-canary 135 0 19
✅ nextjs-webpack-stable 154 0 0
✅ nitro-stable 129 0 25
✅ nuxt-stable 129 0 25
✅ sveltekit-stable 148 0 6
✅ vite-stable 129 0 25
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 128 0 26
✅ express-stable 128 0 26
✅ fastify-stable 128 0 26
✅ hono-stable 128 0 26
✅ nextjs-turbopack-canary 134 0 20
✅ nextjs-turbopack-stable 153 0 1
✅ nextjs-webpack-canary 134 0 20
✅ nextjs-webpack-stable 153 0 1
✅ nitro-stable 128 0 26
✅ nuxt-stable 128 0 26
✅ sveltekit-stable 147 0 7
✅ vite-stable 128 0 26
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 154 0 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 129 0 25
✅ e2e-local-dev-tanstack-start- 129 0 25
✅ e2e-local-postgres-nest-stable 128 0 26
✅ e2e-local-postgres-tanstack-start- 128 0 26
✅ e2e-local-prod-nest-stable 129 0 25
✅ e2e-local-prod-tanstack-start- 129 0 25

📋 View full workflow run


Some E2E test jobs failed:

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

Check the workflow run for details.

@NathanColosimo
NathanColosimo force-pushed the codex/hook-retention-core branch from 87b6bd9 to bd33c10 Compare July 9, 2026 23:16
@NathanColosimo
NathanColosimo force-pushed the codex/hook-retention-local branch from 697002e to d6a289a Compare July 9, 2026 23:16
@NathanColosimo
NathanColosimo force-pushed the codex/hook-retention-local branch from 01ebb5f to 5baad78 Compare July 10, 2026 17:12
@NathanColosimo
NathanColosimo force-pushed the codex/hook-retention-local branch from 5baad78 to 67ed50a Compare July 10, 2026 17:21
@socket-security

socket-security Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​types/​proper-lockfile@​4.1.41001007980100

View full report

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Deployment failed with the following error:

Creating the Deployment Timed Out.

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