From 1b63e8ac8c170d46a71fb4499007ad69a4a074e1 Mon Sep 17 00:00:00 2001 From: Michael Andrews Date: Thu, 22 Oct 2026 17:45:40 -0700 Subject: [PATCH 01/11] fix(workflow-runtime): reject deliveries for unregistered run versions A signal, approval, or timer delivered to a run whose workflow version is no longer registered was consumed by the store before core detected the mismatch, leaving the run `running` with no lease, no error, and nothing awaited. Restoring the version didn't help: redelivery returned `not-waiting`, and stale-run recovery skips runs whose lease was released. The runtime now checks the run's persisted version against the current workflow and its `previousVersions` before handing the delivery to the store. On a mismatch it returns `version-mismatch` and leaves the run `paused`, so fixing the deploy lets the same delivery resume it. Sweeps stop the timer pass instead of re-claiming a rejected timer. Fixes #24 Co-Authored-By: Claude Opus 5.5 --- .changeset/quiet-signals-wait.md | 7 + docs/concepts/replay-and-resume.md | 2 + .../workflow-runtime/src/runtime-driver.ts | 97 +++++++++-- packages/workflow-runtime/src/types.ts | 1 + .../tests/runtime-driver.test.ts | 160 ++++++++++++++++++ 5 files changed, 253 insertions(+), 14 deletions(-) create mode 100644 .changeset/quiet-signals-wait.md diff --git a/.changeset/quiet-signals-wait.md b/.changeset/quiet-signals-wait.md new file mode 100644 index 0000000..e69c4a2 --- /dev/null +++ b/.changeset/quiet-signals-wait.md @@ -0,0 +1,7 @@ +--- +'@tanstack/workflow-runtime': patch +--- + +Reject signal, approval, and timer deliveries for a run whose workflow version +is not registered, returning `version-mismatch` and leaving the run paused +instead of consuming the delivery and stranding the run. diff --git a/docs/concepts/replay-and-resume.md b/docs/concepts/replay-and-resume.md index 1dac4ef..a6e1448 100644 --- a/docs/concepts/replay-and-resume.md +++ b/docs/concepts/replay-and-resume.md @@ -106,6 +106,8 @@ On resume the engine reads `RunState.workflowVersion` and routes to the matching Mismatched version with nothing in `previousVersions` → `RUN_ERRORED { code: 'workflow_version_mismatch' }`. +When the run is driven through `@tanstack/workflow-runtime`, signal, approval, and timer deliveries to such a run are rejected before they are consumed: the result kind is `version-mismatch` and the run stays `paused`, so restoring the missing version lets the same delivery resume it. + ## Attach (read-only subscribe) A second subscriber (browser refresh, mobile reconnect) reads current state without driving the run forward: diff --git a/packages/workflow-runtime/src/runtime-driver.ts b/packages/workflow-runtime/src/runtime-driver.ts index 904895c..9c4d95d 100644 --- a/packages/workflow-runtime/src/runtime-driver.ts +++ b/packages/workflow-runtime/src/runtime-driver.ts @@ -212,6 +212,15 @@ async function deliverSignal< args.minYieldRemainingMs, ) const leaseMs = resolveLeaseMs(config, args.leaseMs) + const rejected = await rejectUnregisteredRunVersion( + config, + telemetry, + args.runId, + ) + if (rejected) { + span.setAttribute('tanstack.workflow.result_kind', rejected.kind) + return rejected + } const delivery = { signalId: args.signalId, stepId: args.stepId, @@ -279,6 +288,12 @@ async function deliverSignalFromRuntime< args.minYieldRemainingMs, ) const leaseMs = resolveLeaseMs(config, args.leaseMs) + const rejected = await rejectUnregisteredRunVersion( + config, + telemetry, + args.runId, + ) + if (rejected) return rejected const delivery = { signalId: args.signalId, stepId: args.stepId, @@ -338,6 +353,15 @@ async function deliverApproval< args.minYieldRemainingMs, ) const leaseMs = resolveLeaseMs(config, args.leaseMs) + const rejected = await rejectUnregisteredRunVersion( + config, + telemetry, + args.runId, + ) + if (rejected) { + span.setAttribute('tanstack.workflow.result_kind', rejected.kind) + return rejected + } const delivered = await traceStoreOperation( telemetry, 'store.deliver_approval', @@ -419,6 +443,7 @@ async function sweep>( const recovered: Array = [] const scheduled: Array = [] const timers: Array = [] + const rejectedTimers = new Set() let deadlineReached = false while (recovered.length < maxRecoveredRuns) { @@ -569,21 +594,25 @@ async function sweep>( ) const timer = dueTimers[0] if (!timer) break + // A rejected timer keeps this sweep's lease, so the store hands it + // back on the next claim. Stop rather than spin on it. + const timerKey = `${timer.runId}:${timer.signalId}` + if (rejectedTimers.has(timerKey)) break - timers.push( - await deliverTimer(config, telemetry, { - timer, - now, - leaseOwner, - leaseMs, - includeEvents: args.includeEvents, - maxEvents: args.maxEvents, - deadline, - minYieldRemainingMs, - yieldResumeAt: now + 1, - publish: args.publish, - }), - ) + const result = await deliverTimer(config, telemetry, { + timer, + now, + leaseOwner, + leaseMs, + includeEvents: args.includeEvents, + maxEvents: args.maxEvents, + deadline, + minYieldRemainingMs, + yieldResumeAt: now + 1, + publish: args.publish, + }) + if (result.kind === 'version-mismatch') rejectedTimers.add(timerKey) + timers.push(result) } const result = { @@ -853,6 +882,46 @@ async function syncTimerFromRunState< ) } +// Deliveries are checked before the store consumes them: once consumed, +// a run whose version this runtime can't replay would be left `running` +// with no lease and nothing awaited, and redelivery would be refused. +async function rejectUnregisteredRunVersion< + TWorkflows extends Record, +>( + config: WorkflowRuntimeConfig, + telemetry: WorkflowTelemetry, + runId: string, +): Promise { + const run = await traceStoreOperation( + telemetry, + 'store.load_run', + { runId }, + () => config.store.loadRun(runId), + ) + // Unversioned runs replay against the current workflow (see core's + // `selectVersionForRun`), so only versioned runs can mismatch. + if (!run?.workflowVersion) return undefined + + const workflow = await loadWorkflow(config, run.workflowId) + if ( + workflow.version === run.workflowVersion || + workflow.previousVersions?.some( + (previous) => previous.version === run.workflowVersion, + ) + ) { + return undefined + } + + return { + kind: 'version-mismatch', + runId, + workflowId: run.workflowId, + run, + events: [], + eventCount: 0, + } +} + async function loadWorkflow< TWorkflows extends Record, >( diff --git a/packages/workflow-runtime/src/types.ts b/packages/workflow-runtime/src/types.ts index d8c3d08..7867c9c 100644 --- a/packages/workflow-runtime/src/types.ts +++ b/packages/workflow-runtime/src/types.ts @@ -445,6 +445,7 @@ export type WorkflowRuntimeRunResultKind = | 'not-claimable' | 'not-waiting' | 'duplicate' + | 'version-mismatch' export interface WorkflowRuntimeRunResult { kind: WorkflowRuntimeRunResultKind diff --git a/packages/workflow-runtime/tests/runtime-driver.test.ts b/packages/workflow-runtime/tests/runtime-driver.test.ts index a618d05..16a6f31 100644 --- a/packages/workflow-runtime/tests/runtime-driver.test.ts +++ b/packages/workflow-runtime/tests/runtime-driver.test.ts @@ -731,6 +731,166 @@ describe('workflow runtime driver', () => { expect(due.timers[0]?.kind).toBe('completed') }) + it('rejects a signal for an unregistered version without consuming it', async () => { + const store = inMemoryWorkflowExecutionStore() + const define = (version: string) => + createWorkflow({ id: 'versioned', version }).handler(async (ctx) => { + return ctx.waitForEvent<{ ok: boolean }>('go', { id: 'go' }) + }) + const v1 = defineWorkflowRuntime({ + store, + workflows: { versioned: { load: async () => define('v1') } }, + }) + const v2 = defineWorkflowRuntime({ + store, + workflows: { versioned: { load: async () => define('v2') } }, + }) + + const start = await v1.startRun({ + workflowId: 'versioned', + runId: 'versioned:1', + input: {}, + now: 0, + }) + const rejected = await v2.deliverSignal({ + runId: 'versioned:1', + stepId: 'go', + signalId: 'signal-1', + name: 'go', + payload: { ok: true }, + now: 10, + }) + const afterReject = await store.loadRun('versioned:1') + const resumed = await v1.deliverSignal({ + runId: 'versioned:1', + stepId: 'go', + signalId: 'signal-1', + name: 'go', + payload: { ok: true }, + now: 20, + }) + + expect(start.kind).toBe('paused') + expect(rejected.kind).toBe('version-mismatch') + expect(rejected.run?.status).toBe('paused') + expect(afterReject?.status).toBe('paused') + expect(afterReject?.lease).toBeUndefined() + expect(resumed.kind).toBe('completed') + }) + + it('rejects an approval for an unregistered version without consuming it', async () => { + const store = inMemoryWorkflowExecutionStore() + const define = (version: string) => + createWorkflow({ id: 'approval', version }).handler(async (ctx) => { + return ctx.approve({ title: 'Ship it?' }) + }) + const v1 = defineWorkflowRuntime({ + store, + workflows: { approval: { load: async () => define('v1') } }, + }) + const v2 = defineWorkflowRuntime({ + store, + workflows: { approval: { load: async () => define('v2') } }, + }) + + await v1.startRun({ + workflowId: 'approval', + runId: 'approval:1', + input: {}, + now: 0, + }) + const approvalId = (await store.loadRun('approval:1'))?.pendingApproval + ?.approvalId + const approval = { approvalId: approvalId!, approved: true } + const rejected = await v2.deliverApproval({ + runId: 'approval:1', + approval, + now: 10, + }) + const afterReject = await store.loadRun('approval:1') + const resumed = await v1.deliverApproval({ + runId: 'approval:1', + approval, + now: 20, + }) + + expect(approvalId).toBeDefined() + expect(rejected.kind).toBe('version-mismatch') + expect(afterReject?.status).toBe('paused') + expect(resumed.kind).toBe('completed') + }) + + it('leaves a timer pending when its run version is unregistered', async () => { + const store = inMemoryWorkflowExecutionStore() + const define = (version: string) => + createWorkflow({ id: 'sleeper', version }).handler(async (ctx) => { + await ctx.sleepUntil(100) + return { awoke: true } + }) + const v1 = defineWorkflowRuntime({ + store, + workflows: { sleeper: { load: async () => define('v1') } }, + }) + const v2 = defineWorkflowRuntime({ + store, + workflows: { sleeper: { load: async () => define('v2') } }, + }) + + await v1.startRun({ + workflowId: 'sleeper', + runId: 'sleeper:1', + input: {}, + now: 0, + }) + const rejected = await v2.sweep({ now: 100, leaseMs: 50 }) + const afterReject = await store.loadRun('sleeper:1') + const resumed = await v1.sweep({ now: 200 }) + + expect(rejected.timers.map((timer) => timer.kind)).toEqual([ + 'version-mismatch', + ]) + expect(afterReject?.status).toBe('paused') + expect(resumed.timers.map((timer) => timer.kind)).toEqual(['completed']) + }) + + it('accepts a signal for a version registered via previousVersions', async () => { + const store = inMemoryWorkflowExecutionStore() + const define = (version: string) => + createWorkflow({ id: 'migrated', version }).handler(async (ctx) => { + return ctx.waitForEvent<{ ok: boolean }>('go', { id: 'go' }) + }) + const v1 = defineWorkflowRuntime({ + store, + workflows: { migrated: { load: async () => define('v1') } }, + }) + const v2 = defineWorkflowRuntime({ + store, + workflows: { + migrated: { + load: async () => define('v2'), + previousVersions: { v1: async () => define('v1') }, + }, + }, + }) + + await v1.startRun({ + workflowId: 'migrated', + runId: 'migrated:1', + input: {}, + now: 0, + }) + const resumed = await v2.deliverSignal({ + runId: 'migrated:1', + stepId: 'go', + signalId: 'signal-1', + name: 'go', + payload: { ok: true }, + now: 10, + }) + + expect(resumed.kind).toBe('completed') + }) + it('sweeps due schedule buckets into deterministic runs', async () => { const store = inMemoryWorkflowExecutionStore() const workflow = createWorkflow({ id: 'scheduled' }).handler( From 3cc8f4d27e3f3634c178c0215f0049ab7732fba5 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 5 Nov 2026 16:22:54 -0700 Subject: [PATCH 02/11] Keep delivery version checks and timer sweeps consistent --- .../workflow-runtime/src/runtime-driver.ts | 132 ++++++++++-------- .../tests/runtime-driver.test.ts | 73 ++++++++++ 2 files changed, 144 insertions(+), 61 deletions(-) diff --git a/packages/workflow-runtime/src/runtime-driver.ts b/packages/workflow-runtime/src/runtime-driver.ts index 9c4d95d..8b659d7 100644 --- a/packages/workflow-runtime/src/runtime-driver.ts +++ b/packages/workflow-runtime/src/runtime-driver.ts @@ -212,14 +212,13 @@ async function deliverSignal< args.minYieldRemainingMs, ) const leaseMs = resolveLeaseMs(config, args.leaseMs) - const rejected = await rejectUnregisteredRunVersion( - config, - telemetry, - args.runId, - ) - if (rejected) { - span.setAttribute('tanstack.workflow.result_kind', rejected.kind) - return rejected + const prepared = await prepareRunDelivery(config, telemetry, args.runId) + if (prepared.rejected) { + span.setAttribute( + 'tanstack.workflow.result_kind', + prepared.rejected.kind, + ) + return prepared.rejected } const delivery = { signalId: args.signalId, @@ -245,7 +244,9 @@ async function deliverSignal< return result } - const workflow = await loadWorkflow(config, delivered.run.workflowId) + const workflow = + prepared.workflow ?? + (await loadWorkflow(config, delivered.run.workflowId)) const result = await driveClaimedRun(config, telemetry, { workflow, workflowId: delivered.run.workflowId, @@ -288,12 +289,8 @@ async function deliverSignalFromRuntime< args.minYieldRemainingMs, ) const leaseMs = resolveLeaseMs(config, args.leaseMs) - const rejected = await rejectUnregisteredRunVersion( - config, - telemetry, - args.runId, - ) - if (rejected) return rejected + const prepared = await prepareRunDelivery(config, telemetry, args.runId) + if (prepared.rejected) return prepared.rejected const delivery = { signalId: args.signalId, stepId: args.stepId, @@ -316,7 +313,8 @@ async function deliverSignalFromRuntime< return resultFromSignalDelivery(args.runId, delivered) } - const workflow = await loadWorkflow(config, delivered.run.workflowId) + const workflow = + prepared.workflow ?? (await loadWorkflow(config, delivered.run.workflowId)) return driveClaimedRun(config, telemetry, { workflow, workflowId: delivered.run.workflowId, @@ -353,14 +351,13 @@ async function deliverApproval< args.minYieldRemainingMs, ) const leaseMs = resolveLeaseMs(config, args.leaseMs) - const rejected = await rejectUnregisteredRunVersion( - config, - telemetry, - args.runId, - ) - if (rejected) { - span.setAttribute('tanstack.workflow.result_kind', rejected.kind) - return rejected + const prepared = await prepareRunDelivery(config, telemetry, args.runId) + if (prepared.rejected) { + span.setAttribute( + 'tanstack.workflow.result_kind', + prepared.rejected.kind, + ) + return prepared.rejected } const delivered = await traceStoreOperation( telemetry, @@ -379,7 +376,9 @@ async function deliverApproval< return result } - const workflow = await loadWorkflow(config, delivered.run.workflowId) + const workflow = + prepared.workflow ?? + (await loadWorkflow(config, delivered.run.workflowId)) const result = await driveClaimedRun(config, telemetry, { workflow, workflowId: delivered.run.workflowId, @@ -443,7 +442,8 @@ async function sweep>( const recovered: Array = [] const scheduled: Array = [] const timers: Array = [] - const rejectedTimers = new Set() + const seenTimers = new Set() + let rejectedTimer = false let deadlineReached = false while (recovered.length < maxRecoveredRuns) { @@ -579,7 +579,6 @@ async function sweep>( deadlineReached = true break } - const dueTimers = await traceStoreOperation( telemetry, 'store.claim_due_timers', @@ -587,32 +586,38 @@ async function sweep>( () => config.store.claimDueTimers({ now, - limit: 1, + limit: maxTimers, leaseOwner, leaseMs, }), ) - const timer = dueTimers[0] - if (!timer) break - // A rejected timer keeps this sweep's lease, so the store hands it - // back on the next claim. Stop rather than spin on it. - const timerKey = `${timer.runId}:${timer.signalId}` - if (rejectedTimers.has(timerKey)) break - - const result = await deliverTimer(config, telemetry, { - timer, - now, - leaseOwner, - leaseMs, - includeEvents: args.includeEvents, - maxEvents: args.maxEvents, - deadline, - minYieldRemainingMs, - yieldResumeAt: now + 1, - publish: args.publish, - }) - if (result.kind === 'version-mismatch') rejectedTimers.add(timerKey) - timers.push(result) + let advanced = false + for (const timer of dueTimers) { + const timerKey = JSON.stringify([timer.runId, timer.signalId]) + if (seenTimers.has(timerKey)) continue + if (timers.length >= maxTimers) break + if (shouldStopForDeadline(deadline, minYieldRemainingMs)) { + deadlineReached = true + break + } + seenTimers.add(timerKey) + advanced = true + const result = await deliverTimer(config, telemetry, { + timer, + now, + leaseOwner, + leaseMs, + includeEvents: args.includeEvents, + maxEvents: args.maxEvents, + deadline, + minYieldRemainingMs, + yieldResumeAt: now + 1, + publish: args.publish, + }) + if (result.kind === 'version-mismatch') rejectedTimer = true + timers.push(result) + } + if (!advanced || deadlineReached) break } const result = { @@ -622,6 +627,7 @@ async function sweep>( summary: summarizeSweep(recovered, scheduled, timers), deadlineReached, remainingMayExist: + rejectedTimer || deadlineReached || recovered.length >= maxRecoveredRuns || scheduled.length >= maxScheduledRuns || @@ -885,40 +891,44 @@ async function syncTimerFromRunState< // Deliveries are checked before the store consumes them: once consumed, // a run whose version this runtime can't replay would be left `running` // with no lease and nothing awaited, and redelivery would be refused. -async function rejectUnregisteredRunVersion< +async function prepareRunDelivery< TWorkflows extends Record, >( config: WorkflowRuntimeConfig, telemetry: WorkflowTelemetry, runId: string, -): Promise { +): Promise<{ + workflow?: AnyWorkflowDefinition + rejected?: WorkflowRuntimeRunResult +}> { const run = await traceStoreOperation( telemetry, 'store.load_run', { runId }, () => config.store.loadRun(runId), ) - // Unversioned runs replay against the current workflow (see core's - // `selectVersionForRun`), so only versioned runs can mismatch. - if (!run?.workflowVersion) return undefined + if (!run) return {} const workflow = await loadWorkflow(config, run.workflowId) if ( + !run.workflowVersion || workflow.version === run.workflowVersion || workflow.previousVersions?.some( (previous) => previous.version === run.workflowVersion, ) ) { - return undefined + return { workflow } } return { - kind: 'version-mismatch', - runId, - workflowId: run.workflowId, - run, - events: [], - eventCount: 0, + rejected: { + kind: 'version-mismatch', + runId, + workflowId: run.workflowId, + run, + events: [], + eventCount: 0, + }, } } diff --git a/packages/workflow-runtime/tests/runtime-driver.test.ts b/packages/workflow-runtime/tests/runtime-driver.test.ts index 16a6f31..72ec9ae 100644 --- a/packages/workflow-runtime/tests/runtime-driver.test.ts +++ b/packages/workflow-runtime/tests/runtime-driver.test.ts @@ -891,6 +891,79 @@ describe('workflow runtime driver', () => { expect(resumed.kind).toBe('completed') }) + it('executes the same workflow definition that passed the delivery check', async () => { + const store = inMemoryWorkflowExecutionStore() + const define = (version: string) => + createWorkflow({ id: 'loaded-once', version }).handler(async (ctx) => + ctx.waitForEvent('go', { id: 'go' }), + ) + const first = define('v1') + const load = vi + .fn() + .mockResolvedValueOnce(first) + .mockResolvedValueOnce(first) + .mockResolvedValue(define('v2')) + const runtime = defineWorkflowRuntime({ + store, + workflows: { 'loaded-once': { load } }, + }) + await runtime.startRun({ + workflowId: 'loaded-once', + runId: 'once', + input: {}, + }) + const result = await runtime.deliverSignal({ + runId: 'once', + name: 'go', + stepId: 'go', + signalId: 'go-1', + payload: true, + }) + expect(result.kind).toBe('completed') + expect(load).toHaveBeenCalledTimes(2) + }) + + it('continues to other due timers when one workflow version is missing', async () => { + const store = inMemoryWorkflowExecutionStore() + const define = (id: string, version: string) => + createWorkflow({ id, version }).handler(async (ctx) => { + await ctx.sleepUntil(100) + return true + }) + const old = defineWorkflowRuntime({ + store, + workflows: { + missing: { load: async () => define('missing', 'v1') }, + available: { load: async () => define('available', 'v1') }, + }, + }) + await old.startRun({ + workflowId: 'missing', + runId: 'missing', + input: {}, + now: 0, + }) + await old.startRun({ + workflowId: 'available', + runId: 'available', + input: {}, + now: 0, + }) + const current = defineWorkflowRuntime({ + store, + workflows: { + missing: { load: async () => define('missing', 'v2') }, + available: { load: async () => define('available', 'v1') }, + }, + }) + const result = await current.sweep({ now: 100, maxTimers: 10 }) + expect(result.timers.map((timer) => timer.kind)).toEqual([ + 'version-mismatch', + 'completed', + ]) + expect(result.remainingMayExist).toBe(true) + }) + it('sweeps due schedule buckets into deterministic runs', async () => { const store = inMemoryWorkflowExecutionStore() const workflow = createWorkflow({ id: 'scheduled' }).handler( From 37538b2f84865caf2b5ed49012faf43cd41390bd Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 5 Nov 2026 22:26:57 -0700 Subject: [PATCH 03/11] fix(runtime): validate replay versions and preserve delivery retries --- docs/concepts/replay-and-resume.md | 2 + .../cloudflare-d1/src/worker.ts | 9 ++- .../workflow-runtime/src/runtime-driver.ts | 28 ++++++-- .../tests/runtime-driver.test.ts | 64 ++++++++++++++++++- 4 files changed, 91 insertions(+), 12 deletions(-) diff --git a/docs/concepts/replay-and-resume.md b/docs/concepts/replay-and-resume.md index a6e1448..bcb74cf 100644 --- a/docs/concepts/replay-and-resume.md +++ b/docs/concepts/replay-and-resume.md @@ -108,6 +108,8 @@ Mismatched version with nothing in `previousVersions` → `RUN_ERRORED { code: ' When the run is driven through `@tanstack/workflow-runtime`, signal, approval, and timer deliveries to such a run are rejected before they are consumed: the result kind is `version-mismatch` and the run stays `paused`, so restoring the missing version lets the same delivery resume it. +A rejected signal or approval payload is not stored by the runtime. Keep it in a durable inbox or return a retryable HTTP response, such as 503, to a sender that retries. Retry with the same signal ID or approval ID after restoring the missing workflow version. The Cloudflare D1 payment example returns 503 for this case. + ## Attach (read-only subscribe) A second subscriber (browser refresh, mobile reconnect) reads current state without driving the run forward: diff --git a/examples/deployment-pocs/cloudflare-d1/src/worker.ts b/examples/deployment-pocs/cloudflare-d1/src/worker.ts index f4a07d8..e66e18f 100644 --- a/examples/deployment-pocs/cloudflare-d1/src/worker.ts +++ b/examples/deployment-pocs/cloudflare-d1/src/worker.ts @@ -73,12 +73,11 @@ export default { } if (url.pathname === '/signals/payment' && request.method === 'POST') { - return json( - await deliverPayment( - runtime, - await readJson(request), - ), + const result = await deliverPayment( + runtime, + await readJson(request), ) + return json(result, result.kind === 'version-mismatch' ? 503 : 200) } if (url.pathname === '/sweep' && request.method === 'POST') { diff --git a/packages/workflow-runtime/src/runtime-driver.ts b/packages/workflow-runtime/src/runtime-driver.ts index 8b659d7..b0445c2 100644 --- a/packages/workflow-runtime/src/runtime-driver.ts +++ b/packages/workflow-runtime/src/runtime-driver.ts @@ -907,15 +907,31 @@ async function prepareRunDelivery< { runId }, () => config.store.loadRun(runId), ) - if (!run) return {} + if (!run) { + return { + rejected: { kind: 'not-found', runId, events: [], eventCount: 0 }, + } + } + if ( + run.status === 'finished' || + run.status === 'errored' || + run.status === 'aborted' + ) { + return {} + } + const state = await traceStoreOperation( + telemetry, + 'store.load_run_state', + { runId }, + () => config.store.loadRunState(runId), + ) + const version = state?.workflowVersion ?? run.workflowVersion const workflow = await loadWorkflow(config, run.workflowId) if ( - !run.workflowVersion || - workflow.version === run.workflowVersion || - workflow.previousVersions?.some( - (previous) => previous.version === run.workflowVersion, - ) + !version || + workflow.version === version || + workflow.previousVersions?.some((previous) => previous.version === version) ) { return { workflow } } diff --git a/packages/workflow-runtime/tests/runtime-driver.test.ts b/packages/workflow-runtime/tests/runtime-driver.test.ts index 72ec9ae..3538252 100644 --- a/packages/workflow-runtime/tests/runtime-driver.test.ts +++ b/packages/workflow-runtime/tests/runtime-driver.test.ts @@ -778,6 +778,66 @@ describe('workflow runtime driver', () => { expect(resumed.kind).toBe('completed') }) + it('checks replay state when the execution summary has no version', async () => { + const store = inMemoryWorkflowExecutionStore() + const define = (version: string) => + createWorkflow({ id: 'legacy-summary', version }).handler(async (ctx) => + ctx.waitForEvent('go', { id: 'go' }), + ) + const old = defineWorkflowRuntime({ + store, + workflows: { 'legacy-summary': { load: async () => define('v1') } }, + }) + await old.startRun({ + workflowId: 'legacy-summary', + runId: 'legacy', + input: {}, + }) + const loadRun = store.loadRun.bind(store) + vi.spyOn(store, 'loadRun').mockImplementation(async (runId) => { + const run = await loadRun(runId) + return run ? { ...run, workflowVersion: undefined } : undefined + }) + const current = defineWorkflowRuntime({ + store, + workflows: { 'legacy-summary': { load: async () => define('v2') } }, + }) + const delivery = { + runId: 'legacy', + signalId: 'go-1', + name: 'go', + stepId: 'go', + payload: true, + } + expect((await current.deliverSignal(delivery)).kind).toBe( + 'version-mismatch', + ) + expect((await store.loadRun('legacy'))?.status).toBe('paused') + expect((await old.deliverSignal(delivery)).kind).toBe('completed') + }) + + it('preserves duplicate delivery results after a workflow is unregistered', async () => { + const store = inMemoryWorkflowExecutionStore() + const workflow = createWorkflow({ id: 'retired', version: 'v1' }).handler( + async (ctx) => ctx.waitForEvent('go', { id: 'go' }), + ) + const old = defineWorkflowRuntime({ + store, + workflows: { retired: { load: async () => workflow } }, + }) + await old.startRun({ workflowId: 'retired', runId: 'retired', input: {} }) + const delivery = { + runId: 'retired', + signalId: 'go-1', + name: 'go', + stepId: 'go', + payload: true, + } + expect((await old.deliverSignal(delivery)).kind).toBe('completed') + const current = defineWorkflowRuntime({ store, workflows: {} }) + expect((await current.deliverSignal(delivery)).kind).toBe('duplicate') + }) + it('rejects an approval for an unregistered version without consuming it', async () => { const store = inMemoryWorkflowExecutionStore() const define = (version: string) => @@ -857,7 +917,8 @@ describe('workflow runtime driver', () => { const store = inMemoryWorkflowExecutionStore() const define = (version: string) => createWorkflow({ id: 'migrated', version }).handler(async (ctx) => { - return ctx.waitForEvent<{ ok: boolean }>('go', { id: 'go' }) + await ctx.waitForEvent<{ ok: boolean }>('go', { id: 'go' }) + return { version } }) const v1 = defineWorkflowRuntime({ store, @@ -889,6 +950,7 @@ describe('workflow runtime driver', () => { }) expect(resumed.kind).toBe('completed') + expect(resumed.run?.output).toEqual({ version: 'v1' }) }) it('executes the same workflow definition that passed the delivery check', async () => { From c65e60a94f4dfd4d6bf766097bbbb6ed247ccad8 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 9 Nov 2026 10:27:28 -0700 Subject: [PATCH 04/11] fix(runtime): advance timer claims and release unused leases --- .changeset/fair-timer-claims.md | 7 ++ docs/api/runtime.md | 2 +- docs/api/store-adapters.md | 16 ++++- .../workflow-runtime/src/in-memory-store.ts | 30 +++++++- packages/workflow-runtime/src/index.ts | 2 + .../workflow-runtime/src/runtime-driver.ts | 69 +++++++++++-------- packages/workflow-runtime/src/types.ts | 12 ++++ .../workflow-execution-store.contract.ts | 63 +++++++++++++++++ .../tests/runtime-driver.test.ts | 63 ++++++++++++++++- .../workflow-store-cloudflare-d1/src/store.ts | 28 +++++++- .../src/store.ts | 19 ++++- 11 files changed, 275 insertions(+), 36 deletions(-) create mode 100644 .changeset/fair-timer-claims.md diff --git a/.changeset/fair-timer-claims.md b/.changeset/fair-timer-claims.md new file mode 100644 index 0000000..ada1ecf --- /dev/null +++ b/.changeset/fair-timer-claims.md @@ -0,0 +1,7 @@ +--- +'@tanstack/workflow-runtime': patch +'@tanstack/workflow-store-cloudflare-d1': patch +'@tanstack/workflow-store-drizzle-postgres': patch +--- + +Prevent unavailable workflow versions from starving other due timers, and release unused timer claims when a sweep stops or fails. Custom execution stores must implement cursor-based timer claims and ownership-checked timer lease release. diff --git a/docs/api/runtime.md b/docs/api/runtime.md index 346a97a..d9a0f33 100644 --- a/docs/api/runtime.md +++ b/docs/api/runtime.md @@ -210,7 +210,7 @@ Options: | `limit` | Backward-compatible shared limit for recoveries, schedules, and timers. | | `maxRecoveredRuns` | Maximum expired running executions to recover. | | `maxScheduledRuns` | Maximum due schedule buckets to start. | -| `maxTimers` | Maximum due timers to resume. | +| `maxTimers` | Maximum due timers to process, excluding unavailable workflow versions. Rejected timers remain in the results, so the result array can exceed this limit. | | `deadline` | Absolute wall-clock deadline in UTC milliseconds. | | `maxDurationMs` | Wall-clock budget for this sweep. | | `minYieldRemainingMs` | Stops claims and fresh durable work inside this margin. | diff --git a/docs/api/store-adapters.md b/docs/api/store-adapters.md index cfbc8e0..b251c14 100644 --- a/docs/api/store-adapters.md +++ b/docs/api/store-adapters.md @@ -17,7 +17,7 @@ The runtime store contract includes: | Run lifecycle | `createRun`, `loadRun`, `loadExecution`, `markRunPaused`, `markRunFinished`, `markRunErrored` | | Event log | `appendEvents`, `readEvents`, optional `subscribeEvents` | | Leases | `claimRun`, `heartbeatRunLease`, `releaseRunLease`, `claimStaleRuns` | -| Timers | `scheduleTimer`, `claimDueTimers` | +| Timers | `scheduleTimer`, `claimDueTimers`, `releaseTimerLease` | | Signals | `deliverSignal` | | Approvals | `deliverApproval` | | Schedules | `upsertSchedule`, `claimDueScheduleBuckets`, `markScheduleBucketStarted` | @@ -26,6 +26,20 @@ The runtime store contract includes: Adapter authors should run the shared contract tests from `@tanstack/workflow-runtime`. +### Timer claims + +`claimDueTimers` returns at most `limit` timers in ascending +`wakeAt`, `runId`, `signalId` order. Its optional `after` cursor is exclusive, +and must use the same ordering as the returned rows. This lets a sweep move +past a timer whose workflow version is unavailable without consuming it. +Timers created behind the cursor are picked up by the next sweep. + +`releaseTimerLease` clears a claim only when both `leaseOwner` and +`leaseExpiresAt` match. A missing timer or a changed lease is a no-op. Sweeps +release their batch in cleanup, including on a deadline or error, so unused +claims do not block other workers. Custom stores must implement both additions; +the bundled stores include them without a schema migration. + ## Drizzle/Postgres Install: diff --git a/packages/workflow-runtime/src/in-memory-store.ts b/packages/workflow-runtime/src/in-memory-store.ts index 9e73b55..91f2ebe 100644 --- a/packages/workflow-runtime/src/in-memory-store.ts +++ b/packages/workflow-runtime/src/in-memory-store.ts @@ -29,6 +29,7 @@ import type { MarkScheduleBucketStartedArgs, ReadEventsArgs, ReleaseRunLeaseArgs, + ReleaseTimerLeaseArgs, RunClaim, RunId, RunSummary, @@ -301,7 +302,23 @@ export function inMemoryWorkflowExecutionStore(): InMemoryWorkflowExecutionStore async claimDueTimers(args: ClaimDueTimersArgs) { const due: Array = [] - for (const [key, timer] of timers.entries()) { + const ordered = [...timers.entries()].sort( + ([, a], [, b]) => + a.wakeAt - b.wakeAt || + (a.runId < b.runId ? -1 : a.runId > b.runId ? 1 : 0) || + (a.signalId < b.signalId ? -1 : a.signalId > b.signalId ? 1 : 0), + ) + for (const [key, timer] of ordered) { + const after = args.after + if ( + after && + (timer.wakeAt < after.wakeAt || + (timer.wakeAt === after.wakeAt && + (timer.runId < after.runId || + (timer.runId === after.runId && + timer.signalId <= after.signalId)))) + ) + continue if (due.length >= args.limit) break if (timer.wakeAt > args.now) continue if (!canClaim(timer.lease, args.leaseOwner, args.now)) continue @@ -315,6 +332,17 @@ export function inMemoryWorkflowExecutionStore(): InMemoryWorkflowExecutionStore return due }, + async releaseTimerLease(args: ReleaseTimerLeaseArgs) { + const key = timerKey(args.runId, args.signalId) + const timer = timers.get(key) + if ( + timer?.lease?.owner === args.leaseOwner && + timer.lease.expiresAt === args.leaseExpiresAt + ) { + timers.set(key, { ...timer, lease: undefined }) + } + }, + async deliverSignal( args: DeliverSignalArgs, ): Promise { diff --git a/packages/workflow-runtime/src/index.ts b/packages/workflow-runtime/src/index.ts index 7c6e2c8..a5ad9cb 100644 --- a/packages/workflow-runtime/src/index.ts +++ b/packages/workflow-runtime/src/index.ts @@ -51,6 +51,8 @@ export type { ScheduleId, ScheduleTimerArgs, StoredWorkflowEvent, + TimerCursor, + ReleaseTimerLeaseArgs, TimerWakeup, UpsertScheduleArgs, WorkflowExecution, diff --git a/packages/workflow-runtime/src/runtime-driver.ts b/packages/workflow-runtime/src/runtime-driver.ts index b0445c2..494b6ac 100644 --- a/packages/workflow-runtime/src/runtime-driver.ts +++ b/packages/workflow-runtime/src/runtime-driver.ts @@ -442,7 +442,8 @@ async function sweep>( const recovered: Array = [] const scheduled: Array = [] const timers: Array = [] - const seenTimers = new Set() + let timerCursor: TimerWakeup | undefined + let processedTimers = 0 let rejectedTimer = false let deadlineReached = false @@ -574,7 +575,7 @@ async function sweep>( scheduled.push(result) } - while (timers.length < maxTimers) { + while (processedTimers < maxTimers) { if (shouldStopForDeadline(deadline, minYieldRemainingMs)) { deadlineReached = true break @@ -586,38 +587,50 @@ async function sweep>( () => config.store.claimDueTimers({ now, - limit: maxTimers, + limit: maxTimers - processedTimers, + after: timerCursor, leaseOwner, leaseMs, }), ) - let advanced = false - for (const timer of dueTimers) { - const timerKey = JSON.stringify([timer.runId, timer.signalId]) - if (seenTimers.has(timerKey)) continue - if (timers.length >= maxTimers) break - if (shouldStopForDeadline(deadline, minYieldRemainingMs)) { - deadlineReached = true - break + if (dueTimers.length === 0) break + try { + for (const timer of dueTimers) { + if (processedTimers >= maxTimers) break + if (shouldStopForDeadline(deadline, minYieldRemainingMs)) { + deadlineReached = true + break + } + timerCursor = timer + const result = await deliverTimer(config, telemetry, { + timer, + now, + leaseOwner, + leaseMs, + includeEvents: args.includeEvents, + maxEvents: args.maxEvents, + deadline, + minYieldRemainingMs, + yieldResumeAt: now + 1, + publish: args.publish, + }) + if (result.kind === 'version-mismatch') rejectedTimer = true + else processedTimers++ + timers.push(result) } - seenTimers.add(timerKey) - advanced = true - const result = await deliverTimer(config, telemetry, { - timer, - now, - leaseOwner, - leaseMs, - includeEvents: args.includeEvents, - maxEvents: args.maxEvents, - deadline, - minYieldRemainingMs, - yieldResumeAt: now + 1, - publish: args.publish, - }) - if (result.kind === 'version-mismatch') rejectedTimer = true - timers.push(result) + } finally { + await Promise.all( + dueTimers.map((timer) => + config.store.releaseTimerLease({ + runId: timer.runId, + signalId: timer.signalId, + leaseOwner, + leaseExpiresAt: now + leaseMs, + }), + ), + ) } - if (!advanced || deadlineReached) break + if (deadlineReached) break } const result = { diff --git a/packages/workflow-runtime/src/types.ts b/packages/workflow-runtime/src/types.ts index 7867c9c..5977cc4 100644 --- a/packages/workflow-runtime/src/types.ts +++ b/packages/workflow-runtime/src/types.ts @@ -143,7 +143,18 @@ export interface ScheduleTimerArgs { now: number } +export type TimerCursor = Pick + +export interface ReleaseTimerLeaseArgs { + runId: RunId + signalId: string + leaseOwner: LeaseOwner + leaseExpiresAt: number +} + export interface ClaimDueTimersArgs { + /** Only claim timers strictly after this cursor, in wakeAt/runId/signalId order. */ + after?: TimerCursor now: number limit: number leaseOwner: LeaseOwner @@ -320,6 +331,7 @@ export interface WorkflowExecutionStore extends WorkflowRunStoreAdapterStore { claimDueTimers: ( args: ClaimDueTimersArgs, ) => Promise> + releaseTimerLease: (args: ReleaseTimerLeaseArgs) => Promise deliverSignal: ( args: DeliverSignalArgs, ) => Promise diff --git a/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts b/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts index b50e9c6..4dfaafb 100644 --- a/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts +++ b/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts @@ -236,6 +236,69 @@ export function runWorkflowExecutionStoreContractTests( expect(reclaimed).toHaveLength(1) }) + it('pages past rejected timers and releases only the matching lease', async () => { + const store = await options.createStore() + for (const runId of ['c', 'b', 'a']) { + await store.createRun({ + runId, + workflowId: 'timer-workflow', + input: {}, + now: 0, + }) + await store.scheduleTimer({ + runId, + workflowId: 'timer-workflow', + signalId: 'timer', + wakeAt: 100, + now: 0, + }) + } + const claim = { now: 100, limit: 1, leaseOwner: 'worker-a', leaseMs: 50 } + const first = await store.claimDueTimers(claim) + expect(first.map((t) => t.runId)).toEqual(['a']) + const second = await store.claimDueTimers({ ...claim, after: first[0] }) + expect(second.map((t) => t.runId)).toEqual(['b']) + await store.releaseTimerLease({ + runId: 'a', + signalId: 'timer', + leaseOwner: 'wrong-worker', + leaseExpiresAt: 150, + }) + expect( + (await store.claimDueTimers({ ...claim, leaseOwner: 'worker-b' })).map( + (t) => t.runId, + ), + ).toEqual(['c']) + await store.releaseTimerLease({ + runId: 'a', + signalId: 'timer', + leaseOwner: 'worker-a', + leaseExpiresAt: 150, + }) + expect( + (await store.claimDueTimers({ ...claim, leaseOwner: 'worker-b' })).map( + (t) => t.runId, + ), + ).toEqual(['a']) + // An expired claim must not clear a newer lease, even for the same owner. + await store.claimDueTimers({ ...claim, now: 151, leaseOwner: 'worker-b' }) + await store.releaseTimerLease({ + runId: 'a', + signalId: 'timer', + leaseOwner: 'worker-b', + leaseExpiresAt: 150, + }) + expect( + ( + await store.claimDueTimers({ + ...claim, + now: 152, + leaseOwner: 'worker-c', + }) + ).map((t) => t.runId), + ).not.toContain('a') + }) + it('delivers signals idempotently and marks the run ready', async () => { const store = await options.createStore() await store.saveRunState({ diff --git a/packages/workflow-runtime/tests/runtime-driver.test.ts b/packages/workflow-runtime/tests/runtime-driver.test.ts index 3538252..f12f1ea 100644 --- a/packages/workflow-runtime/tests/runtime-driver.test.ts +++ b/packages/workflow-runtime/tests/runtime-driver.test.ts @@ -1001,13 +1001,13 @@ describe('workflow runtime driver', () => { }) await old.startRun({ workflowId: 'missing', - runId: 'missing', + runId: 'a-missing', input: {}, now: 0, }) await old.startRun({ workflowId: 'available', - runId: 'available', + runId: 'z-available', input: {}, now: 0, }) @@ -1018,7 +1018,7 @@ describe('workflow runtime driver', () => { available: { load: async () => define('available', 'v1') }, }, }) - const result = await current.sweep({ now: 100, maxTimers: 10 }) + const result = await current.sweep({ now: 100, maxTimers: 1 }) expect(result.timers.map((timer) => timer.kind)).toEqual([ 'version-mismatch', 'completed', @@ -1026,6 +1026,63 @@ describe('workflow runtime driver', () => { expect(result.remainingMayExist).toBe(true) }) + it.each(['deadline', 'error'])( + 'releases a timer batch after %s', + async (stop) => { + const store = inMemoryWorkflowExecutionStore() + const workflow = createWorkflow({ id: 'release-timers' }).handler( + async (ctx) => { + await ctx.sleepUntil(100) + return true + }, + ) + const runtime = defineWorkflowRuntime({ + store, + workflows: { 'release-timers': { load: async () => workflow } }, + }) + for (const runId of ['a', 'b']) + await runtime.startRun({ + workflowId: 'release-timers', + runId, + input: {}, + now: 0, + }) + let wallNow = 0 + const clock = vi.spyOn(Date, 'now').mockImplementation(() => wallNow) + const claim = store.claimDueTimers.bind(store) + vi.spyOn(store, 'claimDueTimers').mockImplementation(async (args) => { + const timers = await claim(args) + if (stop === 'deadline') wallNow = 1000 + return timers + }) + if (stop === 'error') + vi.spyOn(store, 'loadRun').mockRejectedValue( + new Error('storage unavailable'), + ) + try { + const sweep = runtime.sweep({ + now: 100, + maxTimers: 2, + deadline: 500, + minYieldRemainingMs: 0, + }) + if (stop === 'error') + await expect(sweep).rejects.toThrow('storage unavailable') + else expect((await sweep).deadlineReached).toBe(true) + expect( + await claim({ + now: 100, + limit: 2, + leaseOwner: 'next-worker', + leaseMs: 50, + }), + ).toHaveLength(2) + } finally { + clock.mockRestore() + } + }, + ) + it('sweeps due schedule buckets into deterministic runs', async () => { const store = inMemoryWorkflowExecutionStore() const workflow = createWorkflow({ id: 'scheduled' }).handler( diff --git a/packages/workflow-store-cloudflare-d1/src/store.ts b/packages/workflow-store-cloudflare-d1/src/store.ts index 9692001..90fe5ce 100644 --- a/packages/workflow-store-cloudflare-d1/src/store.ts +++ b/packages/workflow-store-cloudflare-d1/src/store.ts @@ -29,6 +29,7 @@ import type { MarkScheduleBucketStartedArgs, ReadEventsArgs, ReleaseRunLeaseArgs, + ReleaseTimerLeaseArgs, RunClaim, RunId, RunSummary, @@ -525,12 +526,16 @@ export function createCloudflareD1WorkflowStore( }, async claimDueTimers(args: ClaimDueTimersArgs) { + const after = args.after + ? 'and (wake_at, run_id, signal_id) > (?, ?, ?)' + : '' const due = await query<{ run_id: string; signal_id: string }>( db, ` select run_id, signal_id from ${tables.timers} where wake_at <= ? + ${after} and ( lease_owner is null or lease_owner = ? @@ -539,7 +544,15 @@ export function createCloudflareD1WorkflowStore( order by wake_at asc, run_id asc, signal_id asc limit ? `, - [args.now, args.leaseOwner, args.now, args.limit], + [ + args.now, + ...(args.after + ? [args.after.wakeAt, args.after.runId, args.after.signalId] + : []), + args.leaseOwner, + args.now, + args.limit, + ], ) const timers: Array = [] @@ -575,6 +588,19 @@ export function createCloudflareD1WorkflowStore( return timers }, + async releaseTimerLease(args: ReleaseTimerLeaseArgs) { + await query( + db, + ` + update ${tables.timers} + set lease_owner = null, lease_expires_at = null + where run_id = ? and signal_id = ? and lease_owner = ? and lease_expires_at = ? + returning run_id + `, + [args.runId, args.signalId, args.leaseOwner, args.leaseExpiresAt], + ) + }, + async deliverSignal( args: DeliverSignalArgs, ): Promise { diff --git a/packages/workflow-store-drizzle-postgres/src/store.ts b/packages/workflow-store-drizzle-postgres/src/store.ts index 200f202..013616e 100644 --- a/packages/workflow-store-drizzle-postgres/src/store.ts +++ b/packages/workflow-store-drizzle-postgres/src/store.ts @@ -31,6 +31,7 @@ import type { MarkScheduleBucketStartedArgs, ReadEventsArgs, ReleaseRunLeaseArgs, + ReleaseTimerLeaseArgs, RunClaim, RunId, RunSummary, @@ -472,6 +473,9 @@ export function createDrizzlePostgresWorkflowStore( }, async claimDueTimers(args: ClaimDueTimersArgs) { + const after = args.after + ? sql`and (wake_at, run_id, signal_id) > (${args.after.wakeAt}, ${args.after.runId}, ${args.after.signalId})` + : sql`` const rows = await queryRows( db, sql` @@ -479,6 +483,7 @@ export function createDrizzlePostgresWorkflowStore( select run_id, signal_id from ${tableSql.timers} where wake_at <= ${args.now} + ${after} and ( lease_owner is null or lease_owner = ${args.leaseOwner} @@ -487,7 +492,7 @@ export function createDrizzlePostgresWorkflowStore( order by wake_at asc, run_id asc, signal_id asc limit ${args.limit} for update skip locked - ) + ), claimed as ( update ${tableSql.timers} timer set lease_owner = ${args.leaseOwner}, @@ -496,11 +501,23 @@ export function createDrizzlePostgresWorkflowStore( where timer.run_id = due.run_id and timer.signal_id = due.signal_id returning timer.* + ) + select * from claimed order by wake_at asc, run_id asc, signal_id asc `, ) return rows.map(timerFromRow) }, + async releaseTimerLease(args: ReleaseTimerLeaseArgs) { + await db.execute(sql` + update ${tableSql.timers} + set lease_owner = null, lease_expires_at = null + where run_id = ${args.runId} and signal_id = ${args.signalId} + and lease_owner = ${args.leaseOwner} + and lease_expires_at = ${args.leaseExpiresAt} + `) + }, + async deliverSignal( args: DeliverSignalArgs, ): Promise { From 366c6efb27a332c89063c584431a2ad4d43d00cf Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 9 Nov 2026 10:43:54 -0700 Subject: [PATCH 05/11] fix(runtime): persist fair bounded timer claims and atomically claim D1 batches --- .changeset/fair-timer-claims.md | 2 +- docs/api/runtime.md | 6 +- docs/api/store-adapters.md | 14 ++-- .../workflow-runtime/src/in-memory-store.ts | 14 +--- packages/workflow-runtime/src/index.ts | 1 - .../workflow-runtime/src/runtime-driver.ts | 23 +++--- packages/workflow-runtime/src/types.ts | 4 - .../workflow-execution-store.contract.ts | 11 ++- .../tests/runtime-driver.test.ts | 69 +++++++++++++++- .../SCHEMA_MIGRATIONS.md | 12 +++ .../migrations/0001_fair_timer_claims.sql | 4 + .../src/migrations.ts | 16 +++- .../src/schema-contract.ts | 11 +++ .../workflow-store-cloudflare-d1/src/store.ts | 80 +++++++------------ .../tests/store.test.ts | 77 ++++++++++++++++++ .../SCHEMA_MIGRATIONS.md | 12 +++ .../migrations/0001_fair_timer_claims.sql | 4 + .../src/migrations.ts | 15 +++- .../src/schema-contract.ts | 11 +++ .../src/store.ts | 26 ++++-- .../src/tables.ts | 1 + .../tests/store.test.ts | 43 ++++++++++ 22 files changed, 355 insertions(+), 101 deletions(-) create mode 100644 packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql create mode 100644 packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql diff --git a/.changeset/fair-timer-claims.md b/.changeset/fair-timer-claims.md index ada1ecf..e3d8b5a 100644 --- a/.changeset/fair-timer-claims.md +++ b/.changeset/fair-timer-claims.md @@ -4,4 +4,4 @@ '@tanstack/workflow-store-drizzle-postgres': patch --- -Prevent unavailable workflow versions from starving other due timers, and release unused timer claims when a sweep stops or fails. Custom execution stores must implement cursor-based timer claims and ownership-checked timer lease release. +Bound timer inspections and rotate persisted claims so unavailable workflow versions cannot starve other due timers. Release unused claims on deadlines and errors, and claim D1 batches atomically. Existing SQL stores must apply migration 0001_fair_timer_claims before upgrading the runtime, or run ensureSchema during deployment. Custom stores must implement fair claims and ownership-checked timer lease release. diff --git a/docs/api/runtime.md b/docs/api/runtime.md index d9a0f33..35bf316 100644 --- a/docs/api/runtime.md +++ b/docs/api/runtime.md @@ -210,7 +210,7 @@ Options: | `limit` | Backward-compatible shared limit for recoveries, schedules, and timers. | | `maxRecoveredRuns` | Maximum expired running executions to recover. | | `maxScheduledRuns` | Maximum due schedule buckets to start. | -| `maxTimers` | Maximum due timers to process, excluding unavailable workflow versions. Rejected timers remain in the results, so the result array can exceed this limit. | +| `maxTimers` | Maximum due timers to inspect, including unavailable workflow versions. Stores rotate claims across sweeps so rejected timers do not starve other work. | | `deadline` | Absolute wall-clock deadline in UTC milliseconds. | | `maxDurationMs` | Wall-clock budget for this sweep. | | `minYieldRemainingMs` | Stops claims and fresh durable work inside this margin. | @@ -233,8 +233,8 @@ interface WorkflowRuntimeSweepResult { } ``` -`remainingMayExist` means the sweep stopped at a count or time budget, so more -due work may be available. +`remainingMayExist` means the sweep stopped at a count or time budget, or +rejected a timer whose workflow version is unavailable. More due work may remain. ## `cron` diff --git a/docs/api/store-adapters.md b/docs/api/store-adapters.md index b251c14..dadfa9b 100644 --- a/docs/api/store-adapters.md +++ b/docs/api/store-adapters.md @@ -28,17 +28,17 @@ Adapter authors should run the shared contract tests from ### Timer claims -`claimDueTimers` returns at most `limit` timers in ascending -`wakeAt`, `runId`, `signalId` order. Its optional `after` cursor is exclusive, -and must use the same ordering as the returned rows. This lets a sweep move -past a timer whose workflow version is unavailable without consuming it. -Timers created behind the cursor are picked up by the next sweep. +`claimDueTimers` returns at most `limit` due timers. Stores persist a claim +order and prefer the least recently claimed timers. This keeps each sweep +bounded while giving other timers a turn on subsequent sweeps, even when a +workflow version stays unavailable. Newly scheduled timers start unclaimed. `releaseTimerLease` clears a claim only when both `leaseOwner` and `leaseExpiresAt` match. A missing timer or a changed lease is a no-op. Sweeps release their batch in cleanup, including on a deadline or error, so unused -claims do not block other workers. Custom stores must implement both additions; -the bundled stores include them without a schema migration. +claims do not block other workers. Custom stores must implement fair claims +and lease release. Existing SQL stores must apply `0001_fair_timer_claims.sql` +before deploying this runtime. `ensureSchema()` also applies this migration. ## Drizzle/Postgres diff --git a/packages/workflow-runtime/src/in-memory-store.ts b/packages/workflow-runtime/src/in-memory-store.ts index 91f2ebe..4bf2f63 100644 --- a/packages/workflow-runtime/src/in-memory-store.ts +++ b/packages/workflow-runtime/src/in-memory-store.ts @@ -49,6 +49,7 @@ import type { } from './types' interface TimerRecord extends TimerWakeup { + claimOrder?: number lease?: WorkflowLease } @@ -75,6 +76,7 @@ export function inMemoryWorkflowExecutionStore(): InMemoryWorkflowExecutionStore const runStates = new Map() const logs = new Map>() const timers = new Map() + let timerClaimOrder = 0 const signalDeliveries = new Map() const schedules = new Map() const scheduleBuckets = new Map() @@ -304,27 +306,19 @@ export function inMemoryWorkflowExecutionStore(): InMemoryWorkflowExecutionStore const due: Array = [] const ordered = [...timers.entries()].sort( ([, a], [, b]) => + (a.claimOrder ?? 0) - (b.claimOrder ?? 0) || a.wakeAt - b.wakeAt || (a.runId < b.runId ? -1 : a.runId > b.runId ? 1 : 0) || (a.signalId < b.signalId ? -1 : a.signalId > b.signalId ? 1 : 0), ) for (const [key, timer] of ordered) { - const after = args.after - if ( - after && - (timer.wakeAt < after.wakeAt || - (timer.wakeAt === after.wakeAt && - (timer.runId < after.runId || - (timer.runId === after.runId && - timer.signalId <= after.signalId)))) - ) - continue if (due.length >= args.limit) break if (timer.wakeAt > args.now) continue if (!canClaim(timer.lease, args.leaseOwner, args.now)) continue timers.set(key, { ...timer, + claimOrder: ++timerClaimOrder, lease: lease(args.leaseOwner, args.leaseMs, args.now), }) due.push(cloneTimerWakeup(timer)) diff --git a/packages/workflow-runtime/src/index.ts b/packages/workflow-runtime/src/index.ts index a5ad9cb..a1709a4 100644 --- a/packages/workflow-runtime/src/index.ts +++ b/packages/workflow-runtime/src/index.ts @@ -51,7 +51,6 @@ export type { ScheduleId, ScheduleTimerArgs, StoredWorkflowEvent, - TimerCursor, ReleaseTimerLeaseArgs, TimerWakeup, UpsertScheduleArgs, diff --git a/packages/workflow-runtime/src/runtime-driver.ts b/packages/workflow-runtime/src/runtime-driver.ts index 494b6ac..04dc622 100644 --- a/packages/workflow-runtime/src/runtime-driver.ts +++ b/packages/workflow-runtime/src/runtime-driver.ts @@ -442,8 +442,8 @@ async function sweep>( const recovered: Array = [] const scheduled: Array = [] const timers: Array = [] - let timerCursor: TimerWakeup | undefined - let processedTimers = 0 + let inspectedTimers = 0 + const seenTimers = new Set() let rejectedTimer = false let deadlineReached = false @@ -575,7 +575,7 @@ async function sweep>( scheduled.push(result) } - while (processedTimers < maxTimers) { + while (inspectedTimers < maxTimers) { if (shouldStopForDeadline(deadline, minYieldRemainingMs)) { deadlineReached = true break @@ -587,21 +587,25 @@ async function sweep>( () => config.store.claimDueTimers({ now, - limit: maxTimers - processedTimers, - after: timerCursor, + limit: maxTimers - inspectedTimers, leaseOwner, leaseMs, }), ) if (dueTimers.length === 0) break + let advanced = false try { for (const timer of dueTimers) { - if (processedTimers >= maxTimers) break + if (inspectedTimers >= maxTimers) break if (shouldStopForDeadline(deadline, minYieldRemainingMs)) { deadlineReached = true break } - timerCursor = timer + inspectedTimers++ + const timerKey = JSON.stringify([timer.runId, timer.signalId]) + if (seenTimers.has(timerKey)) continue + seenTimers.add(timerKey) + advanced = true const result = await deliverTimer(config, telemetry, { timer, now, @@ -615,7 +619,6 @@ async function sweep>( publish: args.publish, }) if (result.kind === 'version-mismatch') rejectedTimer = true - else processedTimers++ timers.push(result) } } finally { @@ -630,7 +633,7 @@ async function sweep>( ), ) } - if (deadlineReached) break + if (deadlineReached || !advanced) break } const result = { @@ -644,7 +647,7 @@ async function sweep>( deadlineReached || recovered.length >= maxRecoveredRuns || scheduled.length >= maxScheduledRuns || - timers.length >= maxTimers, + inspectedTimers >= maxTimers, } span.setAttribute( 'tanstack.workflow.event_count', diff --git a/packages/workflow-runtime/src/types.ts b/packages/workflow-runtime/src/types.ts index 5977cc4..e725853 100644 --- a/packages/workflow-runtime/src/types.ts +++ b/packages/workflow-runtime/src/types.ts @@ -143,8 +143,6 @@ export interface ScheduleTimerArgs { now: number } -export type TimerCursor = Pick - export interface ReleaseTimerLeaseArgs { runId: RunId signalId: string @@ -153,8 +151,6 @@ export interface ReleaseTimerLeaseArgs { } export interface ClaimDueTimersArgs { - /** Only claim timers strictly after this cursor, in wakeAt/runId/signalId order. */ - after?: TimerCursor now: number limit: number leaseOwner: LeaseOwner diff --git a/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts b/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts index 4dfaafb..cfb92c5 100644 --- a/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts +++ b/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts @@ -236,7 +236,7 @@ export function runWorkflowExecutionStoreContractTests( expect(reclaimed).toHaveLength(1) }) - it('pages past rejected timers and releases only the matching lease', async () => { + it('rotates timer claims and releases only the matching lease', async () => { const store = await options.createStore() for (const runId of ['c', 'b', 'a']) { await store.createRun({ @@ -256,7 +256,7 @@ export function runWorkflowExecutionStoreContractTests( const claim = { now: 100, limit: 1, leaseOwner: 'worker-a', leaseMs: 50 } const first = await store.claimDueTimers(claim) expect(first.map((t) => t.runId)).toEqual(['a']) - const second = await store.claimDueTimers({ ...claim, after: first[0] }) + const second = await store.claimDueTimers(claim) expect(second.map((t) => t.runId)).toEqual(['b']) await store.releaseTimerLease({ runId: 'a', @@ -281,7 +281,12 @@ export function runWorkflowExecutionStoreContractTests( ), ).toEqual(['a']) // An expired claim must not clear a newer lease, even for the same owner. - await store.claimDueTimers({ ...claim, now: 151, leaseOwner: 'worker-b' }) + await store.claimDueTimers({ + ...claim, + now: 151, + limit: 3, + leaseOwner: 'worker-b', + }) await store.releaseTimerLease({ runId: 'a', signalId: 'timer', diff --git a/packages/workflow-runtime/tests/runtime-driver.test.ts b/packages/workflow-runtime/tests/runtime-driver.test.ts index f12f1ea..f31d8cb 100644 --- a/packages/workflow-runtime/tests/runtime-driver.test.ts +++ b/packages/workflow-runtime/tests/runtime-driver.test.ts @@ -1021,11 +1021,78 @@ describe('workflow runtime driver', () => { const result = await current.sweep({ now: 100, maxTimers: 1 }) expect(result.timers.map((timer) => timer.kind)).toEqual([ 'version-mismatch', - 'completed', ]) + const next = await current.sweep({ now: 100, maxTimers: 1 }) + expect(next.timers.map((timer) => timer.kind)).toEqual(['completed']) expect(result.remainingMayExist).toBe(true) }) + it('bounds inspections while rotating past a backlog of missing versions', async () => { + const store = inMemoryWorkflowExecutionStore() + const define = (version: string) => + createWorkflow({ id: 'backlog', version }).handler(async (ctx) => { + await ctx.sleepUntil(100) + return true + }) + const old = defineWorkflowRuntime({ + store, + workflows: { backlog: { load: async () => define('v1') } }, + }) + for (let i = 0; i < 4; i++) + await old.startRun({ + workflowId: 'backlog', + runId: `missing-${i}`, + input: {}, + now: 0, + }) + const current = defineWorkflowRuntime({ + store, + workflows: { backlog: { load: async () => define('v2') } }, + }) + await current.startRun({ + workflowId: 'backlog', + runId: 'z-healthy', + input: {}, + now: 0, + }) + const claim = vi.spyOn(store, 'claimDueTimers') + for (let i = 0; i < 5; i++) { + claim.mockClear() + const sweep = await current.sweep({ now: 100, maxTimers: 1 }) + expect(claim).toHaveBeenCalledTimes(1) + expect(sweep.timers).toHaveLength(1) + expect(sweep.timers[0]?.kind).toBe( + i < 4 ? 'version-mismatch' : 'completed', + ) + } + }) + + it('resumes newly created timers even when their IDs sort earlier', async () => { + const store = inMemoryWorkflowExecutionStore() + const workflow = createWorkflow({ id: 'reverse-timers' }).handler( + async (ctx) => { + await ctx.sleepUntil(100, { id: 'z' }) + await ctx.sleepUntil(100, { id: 'a' }) + return true + }, + ) + const runtime = defineWorkflowRuntime({ + store, + workflows: { 'reverse-timers': { load: async () => workflow } }, + }) + await runtime.startRun({ + workflowId: 'reverse-timers', + runId: 'reverse', + input: {}, + now: 0, + }) + expect( + (await runtime.sweep({ now: 100, maxTimers: 3 })).timers.map( + (t) => t.kind, + ), + ).toEqual(['paused', 'completed']) + }) + it.each(['deadline', 'error'])( 'releases a timer batch after %s', async (stop) => { diff --git a/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md b/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md index 6da7193..343f0c5 100644 --- a/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md +++ b/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md @@ -24,3 +24,15 @@ pnpm --filter @tanstack/workflow-store-cloudflare-d1 test:eslint pnpm --filter @tanstack/workflow-store-cloudflare-d1 build pnpm --filter @tanstack/workflow-store-cloudflare-d1 pack --dry-run ``` + +## Upgrading existing stores + +Apply `migrations/0001_fair_timer_claims.sql` once before deploying the timer +fairness runtime. It adds `claim_order` with a zero default, preserving existing +timers and leases. Fresh databases apply `0000_workflow_store.sql` then `0001`. +`ensureSchema()` checks the migration ledger and applies missing migrations; +run it once during deployment, before starting workers. + +The singular `getCloudflareD1WorkflowStoreMigrationSql` helper remains the original +bootstrap SQL. Use the package's `getCloudflareD1WorkflowStoreMigrations()` helper for +the complete ordered migration list, including custom table names. diff --git a/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql b/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql new file mode 100644 index 0000000..b6a6ac2 --- /dev/null +++ b/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql @@ -0,0 +1,4 @@ +alter table "workflow_timers" add column claim_order integer not null default 0; + +insert into "workflow_schema_migrations" (migration_id, package_name, package_version, applied_at) + values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer)); diff --git a/packages/workflow-store-cloudflare-d1/src/migrations.ts b/packages/workflow-store-cloudflare-d1/src/migrations.ts index ff74056..e5b720a 100644 --- a/packages/workflow-store-cloudflare-d1/src/migrations.ts +++ b/packages/workflow-store-cloudflare-d1/src/migrations.ts @@ -1,4 +1,7 @@ -import { getCloudflareD1WorkflowStoreSchemaStatements } from './schema-contract' +import { + getCloudflareD1TimerFairnessStatements, + getCloudflareD1WorkflowStoreSchemaStatements, +} from './schema-contract' import type { CloudflareD1WorkflowStoreSchemaOptions } from './schema-contract' export interface CloudflareD1WorkflowStoreMigration { @@ -9,7 +12,7 @@ export interface CloudflareD1WorkflowStoreMigration { sql: string } -export const cloudflareD1WorkflowStoreSchemaVersion = '0000_workflow_store' +export const cloudflareD1WorkflowStoreSchemaVersion = '0001_fair_timer_claims' export function getCloudflareD1WorkflowStoreMigrations( options?: CloudflareD1WorkflowStoreSchemaOptions, @@ -18,12 +21,19 @@ export function getCloudflareD1WorkflowStoreMigrations( return [ { - id: cloudflareD1WorkflowStoreSchemaVersion, + id: '0000_workflow_store', name: 'Create TanStack Workflow Cloudflare D1 store tables', order: 0, statements, sql: `${statements.join(';\n\n')};\n`, }, + { + id: '0001_fair_timer_claims', + name: 'Fair timer claims', + order: 1, + statements: getCloudflareD1TimerFairnessStatements(options), + sql: `${getCloudflareD1TimerFairnessStatements(options).join(';\n\n')};\n`, + }, ] } diff --git a/packages/workflow-store-cloudflare-d1/src/schema-contract.ts b/packages/workflow-store-cloudflare-d1/src/schema-contract.ts index cf2f178..ebdf150 100644 --- a/packages/workflow-store-cloudflare-d1/src/schema-contract.ts +++ b/packages/workflow-store-cloudflare-d1/src/schema-contract.ts @@ -185,3 +185,14 @@ function normalizeSqlStatement(statement: string) { ) .join('\n') } + +export function getCloudflareD1TimerFairnessStatements( + options: CloudflareD1WorkflowStoreSchemaOptions = {}, +): Array { + const tables = resolveCloudflareD1WorkflowStoreTables(options.tables) + return [ + `alter table ${quoteIdent(tables.timers)} add column claim_order integer not null default 0`, + `insert into ${quoteIdent(tables.schemaMigrations)} (migration_id, package_name, package_version, applied_at) + values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer))`, + ].map(normalizeSqlStatement) +} diff --git a/packages/workflow-store-cloudflare-d1/src/store.ts b/packages/workflow-store-cloudflare-d1/src/store.ts index 90fe5ce..d944026 100644 --- a/packages/workflow-store-cloudflare-d1/src/store.ts +++ b/packages/workflow-store-cloudflare-d1/src/store.ts @@ -1,5 +1,6 @@ import { LogConflictError } from '@tanstack/workflow-core' import { + getCloudflareD1TimerFairnessStatements, getCloudflareD1WorkflowStoreSchemaStatements, quoteIdent, resolveCloudflareD1WorkflowStoreTables, @@ -103,6 +104,18 @@ export function createCloudflareD1WorkflowStore( })) { await execute(db, statement) } + const applied = await query( + db, + `select migration_id from ${tables.schemaMigrations} where migration_id = ?`, + ['0001_fair_timer_claims'], + ) + if (!applied.length) + await executeMany( + db, + getCloudflareD1TimerFairnessStatements({ tables: tableNames }).map( + (sql) => statement(sql), + ), + ) }, async createRun(args: CreateRunArgs): Promise { @@ -526,66 +539,31 @@ export function createCloudflareD1WorkflowStore( }, async claimDueTimers(args: ClaimDueTimersArgs) { - const after = args.after - ? 'and (wake_at, run_id, signal_id) > (?, ?, ?)' - : '' - const due = await query<{ run_id: string; signal_id: string }>( + // One statement makes selection and every lease update atomic in D1. + const rows = await query( db, ` - select run_id, signal_id - from ${tables.timers} - where wake_at <= ? - ${after} - and ( - lease_owner is null - or lease_owner = ? - or lease_expires_at <= ? - ) - order by wake_at asc, run_id asc, signal_id asc + update ${tables.timers} + set lease_owner = ?, lease_expires_at = ?, + claim_order = (select coalesce(max(claim_order), 0) + 1 from ${tables.timers}) + where (run_id, signal_id) in ( + select run_id, signal_id from ${tables.timers} + where wake_at <= ? and (lease_owner is null or lease_owner = ? or lease_expires_at <= ?) + order by claim_order asc, wake_at asc, run_id asc, signal_id asc limit ? - `, + ) + returning * + `, [ + args.leaseOwner, + args.now + args.leaseMs, args.now, - ...(args.after - ? [args.after.wakeAt, args.after.runId, args.after.signalId] - : []), args.leaseOwner, args.now, args.limit, ], ) - const timers: Array = [] - - for (const timer of due) { - const rows = await query( - db, - ` - update ${tables.timers} - set - lease_owner = ?, - lease_expires_at = ? - where run_id = ? - and signal_id = ? - and ( - lease_owner is null - or lease_owner = ? - or lease_expires_at <= ? - ) - returning * - `, - [ - args.leaseOwner, - args.now + args.leaseMs, - timer.run_id, - timer.signal_id, - args.leaseOwner, - args.now, - ], - ) - if (rows[0]) timers.push(timerFromRow(rows[0])) - } - - return timers + return rows.map(timerFromRow) }, async releaseTimerLease(args: ReleaseTimerLeaseArgs) { @@ -943,6 +921,7 @@ export function createCloudflareD1WorkflowStore( } interface TableSqls { + schemaMigrations: string runs: string runStates: string eventLocks: string @@ -1030,6 +1009,7 @@ interface Statement { function tableSqls(tables: CloudflareD1WorkflowStoreTables): TableSqls { return { + schemaMigrations: quoteIdent(tables.schemaMigrations), runs: quoteIdent(tables.runs), runStates: quoteIdent(tables.runStates), eventLocks: quoteIdent(tables.eventLocks), diff --git a/packages/workflow-store-cloudflare-d1/tests/store.test.ts b/packages/workflow-store-cloudflare-d1/tests/store.test.ts index 2aa7c47..d87e875 100644 --- a/packages/workflow-store-cloudflare-d1/tests/store.test.ts +++ b/packages/workflow-store-cloudflare-d1/tests/store.test.ts @@ -32,6 +32,12 @@ describe('cloudflare-d1 schema contract', () => { const migrationSql = await readFile(migrationFile, 'utf8') expect(getCloudflareD1WorkflowStoreMigrationSql()).toBe(migrationSql) + expect(getCloudflareD1WorkflowStoreMigrations()[1]!.sql).toBe( + await readFile( + new URL('../migrations/0001_fair_timer_claims.sql', import.meta.url), + 'utf8', + ), + ) expect(getCloudflareD1WorkflowStoreMigrations()).toEqual([ { id: '0000_workflow_store', @@ -40,6 +46,13 @@ describe('cloudflare-d1 schema contract', () => { statements: expect.any(Array), sql: migrationSql, }, + { + id: '0001_fair_timer_claims', + name: 'Fair timer claims', + order: 1, + statements: expect.any(Array), + sql: expect.any(String), + }, ]) }) @@ -57,10 +70,70 @@ describe('cloudflare-d1 schema contract', () => { expect(sql).toContain('create table if not exists "workflow_events"') }) + test('upgrades existing timers and preserves fairness across store instances', async () => { + const db = createTestD1Database() + await db.exec!(getCloudflareD1WorkflowStoreMigrationSql()) + await db.exec!( + `insert into workflow_timers (run_id, signal_id, workflow_id, wake_at, lease_owner, lease_expires_at) values ('a', 'timer', 'workflow', 100, 'old-worker', 50), ('b', 'timer', 'workflow', 100, null, null)`, + ) + const store = createCloudflareD1WorkflowStore({ db }) + await store.ensureSchema() + await store.ensureSchema() + const args = { now: 100, limit: 1, leaseOwner: 'worker', leaseMs: 50 } + expect((await store.claimDueTimers(args)).map((t) => t.runId)).toEqual([ + 'a', + ]) + await store.releaseTimerLease({ + runId: 'a', + signalId: 'timer', + leaseOwner: 'worker', + leaseExpiresAt: 150, + }) + const restarted = createCloudflareD1WorkflowStore({ db }) + expect((await restarted.claimDueTimers(args)).map((t) => t.runId)).toEqual([ + 'b', + ]) + }) + + test('rolls back every timer claim if a batch update fails', async () => { + const db = createTestD1Database() + const store = createCloudflareD1WorkflowStore({ db }) + await store.ensureSchema() + for (const runId of ['a', 'b']) + await store.scheduleTimer({ + runId, + workflowId: 'workflow', + signalId: 'timer', + wakeAt: 100, + now: 0, + }) + await db.exec!( + "create trigger fail_second_claim before update on workflow_timers when new.run_id = 'b' begin select raise(abort, 'claim failed'); end", + ) + await expect( + store.claimDueTimers({ + now: 100, + limit: 2, + leaseOwner: 'failed-worker', + leaseMs: 50, + }), + ).rejects.toThrow('claim failed') + await db.exec!('drop trigger fail_second_claim') + expect( + await store.claimDueTimers({ + now: 100, + limit: 2, + leaseOwner: 'next-worker', + leaseMs: 50, + }), + ).toHaveLength(2) + }) + test('records the applied schema migration during ensureSchema', async () => { const db = createTestD1Database() const store = createCloudflareD1WorkflowStore({ db }) + await store.ensureSchema() await store.ensureSchema() const rows = await db @@ -70,6 +143,10 @@ describe('cloudflare-d1 schema contract', () => { .all<{ migration_id: string; package_name: string }>() expect(rows.results).toEqual([ + { + migration_id: '0000_workflow_store', + package_name: '@tanstack/workflow-store-cloudflare-d1', + }, { migration_id: cloudflareD1WorkflowStoreSchemaVersion, package_name: '@tanstack/workflow-store-cloudflare-d1', diff --git a/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md b/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md index 0aa3461..72534b2 100644 --- a/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md +++ b/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md @@ -83,3 +83,15 @@ pnpm test:sherif ``` Confirm the dry-run tarball includes every SQL file under `migrations/`. + +## Upgrading existing stores + +Apply `migrations/0001_fair_timer_claims.sql` once before deploying the timer +fairness runtime. It adds `claim_order` with a zero default, preserving existing +timers and leases. Fresh databases apply `0000_workflow_store.sql` then `0001`. +`ensureSchema()` checks the migration ledger and applies missing migrations; +run it once during deployment, before starting workers. + +The singular `getDrizzlePostgresWorkflowStoreMigrationSql` helper remains the original +bootstrap SQL. Use the package's `getDrizzlePostgresWorkflowStoreMigrations()` helper for +the complete ordered migration list, including custom table names. diff --git a/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql b/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql new file mode 100644 index 0000000..508da89 --- /dev/null +++ b/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql @@ -0,0 +1,4 @@ +alter table "workflow_timers" add column claim_order bigint not null default 0; + +insert into "workflow_schema_migrations" (migration_id, package_name, package_version, applied_at) + values ('0001_fair_timer_claims', '@tanstack/workflow-store-drizzle-postgres', null, cast(extract(epoch from now()) * 1000 as bigint)); diff --git a/packages/workflow-store-drizzle-postgres/src/migrations.ts b/packages/workflow-store-drizzle-postgres/src/migrations.ts index 273d5c0..7f1a2d2 100644 --- a/packages/workflow-store-drizzle-postgres/src/migrations.ts +++ b/packages/workflow-store-drizzle-postgres/src/migrations.ts @@ -1,4 +1,7 @@ -import { getDrizzlePostgresWorkflowStoreSchemaStatements } from './schema-contract' +import { + getDrizzlePostgresTimerFairnessStatements, + getDrizzlePostgresWorkflowStoreSchemaStatements, +} from './schema-contract' import type { DrizzlePostgresWorkflowStoreSchemaOptions } from './schema-contract' export interface DrizzlePostgresWorkflowStoreMigration { @@ -9,7 +12,8 @@ export interface DrizzlePostgresWorkflowStoreMigration { sql: string } -export const drizzlePostgresWorkflowStoreSchemaVersion = '0000_workflow_store' +export const drizzlePostgresWorkflowStoreSchemaVersion = + '0001_fair_timer_claims' export function getDrizzlePostgresWorkflowStoreMigrations( options?: DrizzlePostgresWorkflowStoreSchemaOptions, @@ -24,6 +28,13 @@ export function getDrizzlePostgresWorkflowStoreMigrations( statements, sql: `${statements.join(';\n\n')};\n`, }, + { + id: '0001_fair_timer_claims', + name: 'Fair timer claims', + order: 1, + statements: getDrizzlePostgresTimerFairnessStatements(options), + sql: `${getDrizzlePostgresTimerFairnessStatements(options).join(';\n\n')};\n`, + }, ] } diff --git a/packages/workflow-store-drizzle-postgres/src/schema-contract.ts b/packages/workflow-store-drizzle-postgres/src/schema-contract.ts index d19b53d..5e4f06b 100644 --- a/packages/workflow-store-drizzle-postgres/src/schema-contract.ts +++ b/packages/workflow-store-drizzle-postgres/src/schema-contract.ts @@ -206,3 +206,14 @@ function normalizeSqlStatement(statement: string) { ) .join('\n') } + +export function getDrizzlePostgresTimerFairnessStatements( + options: DrizzlePostgresWorkflowStoreSchemaOptions = {}, +): Array { + const tables = resolveDrizzlePostgresWorkflowStoreTables(options.tables) + return [ + `alter table ${qualifiedTableName(options.schema, tables.timers)} add column claim_order bigint not null default 0`, + `insert into ${qualifiedTableName(options.schema, tables.schemaMigrations)} (migration_id, package_name, package_version, applied_at) + values ('0001_fair_timer_claims', '@tanstack/workflow-store-drizzle-postgres', null, cast(extract(epoch from now()) * 1000 as bigint))`, + ].map(normalizeSqlStatement) +} diff --git a/packages/workflow-store-drizzle-postgres/src/store.ts b/packages/workflow-store-drizzle-postgres/src/store.ts index 013616e..7090aea 100644 --- a/packages/workflow-store-drizzle-postgres/src/store.ts +++ b/packages/workflow-store-drizzle-postgres/src/store.ts @@ -1,6 +1,7 @@ import { LogConflictError } from '@tanstack/workflow-core' import { sql } from 'drizzle-orm' import { + getDrizzlePostgresTimerFairnessStatements, getDrizzlePostgresWorkflowStoreSchemaStatements, qualifiedTableName, resolveDrizzlePostgresWorkflowStoreTables, @@ -83,6 +84,18 @@ export function createDrizzlePostgresWorkflowStore( })) { await db.execute(sql.raw(statement)) } + const applied = await queryRows( + db, + sql`select migration_id from ${tableSql.schemaMigrations} where migration_id = '0001_fair_timer_claims'`, + ) + if (!applied.length) + await withTransaction(db, async (tx) => { + for (const statement of getDrizzlePostgresTimerFairnessStatements({ + schema: options.schema, + tables: tableNames, + })) + await tx.execute(sql.raw(statement)) + }) }, async createRun(args: CreateRunArgs): Promise { @@ -473,9 +486,6 @@ export function createDrizzlePostgresWorkflowStore( }, async claimDueTimers(args: ClaimDueTimersArgs) { - const after = args.after - ? sql`and (wake_at, run_id, signal_id) > (${args.after.wakeAt}, ${args.after.runId}, ${args.after.signalId})` - : sql`` const rows = await queryRows( db, sql` @@ -483,18 +493,18 @@ export function createDrizzlePostgresWorkflowStore( select run_id, signal_id from ${tableSql.timers} where wake_at <= ${args.now} - ${after} and ( lease_owner is null or lease_owner = ${args.leaseOwner} or lease_expires_at <= ${args.now} ) - order by wake_at asc, run_id asc, signal_id asc + order by claim_order asc, wake_at asc, run_id asc, signal_id asc limit ${args.limit} for update skip locked ), claimed as ( update ${tableSql.timers} timer set + claim_order = (select coalesce(max(claim_order), 0) + 1 from ${tableSql.timers}), lease_owner = ${args.leaseOwner}, lease_expires_at = ${args.now + args.leaseMs} from due @@ -502,7 +512,7 @@ export function createDrizzlePostgresWorkflowStore( and timer.signal_id = due.signal_id returning timer.* ) - select * from claimed order by wake_at asc, run_id asc, signal_id asc + select * from claimed order by claim_order asc, wake_at asc, run_id asc, signal_id asc `, ) return rows.map(timerFromRow) @@ -817,6 +827,7 @@ export function createDrizzlePostgresWorkflowStore( } interface TableSqls { + schemaMigrations: SQL runs: SQL runStates: SQL eventLocks: SQL @@ -902,6 +913,9 @@ function tableSqls( tables: DrizzlePostgresWorkflowStoreTables, ): TableSqls { return { + schemaMigrations: sql.raw( + qualifiedTableName(schema, tables.schemaMigrations), + ), runs: sql.raw(qualifiedTableName(schema, tables.runs)), runStates: sql.raw(qualifiedTableName(schema, tables.runStates)), eventLocks: sql.raw(qualifiedTableName(schema, tables.eventLocks)), diff --git a/packages/workflow-store-drizzle-postgres/src/tables.ts b/packages/workflow-store-drizzle-postgres/src/tables.ts index 7b12515..5f9f728 100644 --- a/packages/workflow-store-drizzle-postgres/src/tables.ts +++ b/packages/workflow-store-drizzle-postgres/src/tables.ts @@ -87,6 +87,7 @@ export const workflowTimers = pgTable( wakeAt: bigint('wake_at', { mode: 'number' }).notNull(), leaseOwner: text('lease_owner'), leaseExpiresAt: bigint('lease_expires_at', { mode: 'number' }), + claimOrder: bigint('claim_order', { mode: 'number' }).notNull().default(0), }, (table) => [ primaryKey({ columns: [table.runId, table.signalId] }), diff --git a/packages/workflow-store-drizzle-postgres/tests/store.test.ts b/packages/workflow-store-drizzle-postgres/tests/store.test.ts index 160df11..f693f88 100644 --- a/packages/workflow-store-drizzle-postgres/tests/store.test.ts +++ b/packages/workflow-store-drizzle-postgres/tests/store.test.ts @@ -29,6 +29,12 @@ describe('drizzle-postgres schema contract', () => { const migrationSql = await readFile(migrationFile, 'utf8') expect(getDrizzlePostgresWorkflowStoreMigrationSql()).toBe(migrationSql) + expect(getDrizzlePostgresWorkflowStoreMigrations()[1]!.sql).toBe( + await readFile( + new URL('../migrations/0001_fair_timer_claims.sql', import.meta.url), + 'utf8', + ), + ) expect(getDrizzlePostgresWorkflowStoreMigrations()).toEqual([ { id: '0000_workflow_store', @@ -37,6 +43,13 @@ describe('drizzle-postgres schema contract', () => { statements: expect.any(Array), sql: migrationSql, }, + { + id: '0001_fair_timer_claims', + name: 'Fair timer claims', + order: 1, + statements: expect.any(Array), + sql: expect.any(String), + }, ]) }) @@ -58,6 +71,32 @@ describe('drizzle-postgres schema contract', () => { ) }) + test('upgrades existing timers and preserves fairness across store instances', async () => { + const client = new PGlite() + const db = drizzle(client) + await client.exec(getDrizzlePostgresWorkflowStoreMigrationSql()) + await client.exec( + `insert into workflow_timers (run_id, signal_id, workflow_id, wake_at, lease_owner, lease_expires_at) values ('a', 'timer', 'workflow', 100, 'old-worker', 50), ('b', 'timer', 'workflow', 100, null, null)`, + ) + const store = createDrizzlePostgresWorkflowStore({ db }) + await store.ensureSchema() + await store.ensureSchema() + const args = { now: 100, limit: 1, leaseOwner: 'worker', leaseMs: 50 } + expect((await store.claimDueTimers(args)).map((t) => t.runId)).toEqual([ + 'a', + ]) + await store.releaseTimerLease({ + runId: 'a', + signalId: 'timer', + leaseOwner: 'worker', + leaseExpiresAt: 150, + }) + const restarted = createDrizzlePostgresWorkflowStore({ db }) + expect((await restarted.claimDueTimers(args)).map((t) => t.runId)).toEqual([ + 'b', + ]) + }) + test('records the applied schema migration during ensureSchema', async () => { const client = new PGlite() const db = drizzle(client) @@ -73,6 +112,10 @@ describe('drizzle-postgres schema contract', () => { ) expect(result.rows).toEqual([ + { + migration_id: '0000_workflow_store', + package_name: '@tanstack/workflow-store-drizzle-postgres', + }, { migration_id: drizzlePostgresWorkflowStoreSchemaVersion, package_name: '@tanstack/workflow-store-drizzle-postgres', From 2b73afb879cc4693f5cc58123925594ac76b436a Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 9 Nov 2026 10:45:16 -0700 Subject: [PATCH 06/11] fix(stores): include timer fairness migration in fresh setup helpers --- docs/api/store-adapters.md | 5 +++-- docs/cookbook/index.md | 4 ++-- docs/guide/deployment.md | 5 +++-- docs/guide/index.md | 2 +- docs/guide/persistence.md | 2 +- docs/installation.md | 3 ++- examples/deployment-pocs/cloudflare-d1/README.md | 1 + .../cloudflare-d1/migrations/0001_fair_timer_claims.sql | 4 ++++ packages/workflow-store-cloudflare-d1/README.md | 1 + .../workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md | 6 +++--- packages/workflow-store-cloudflare-d1/src/migrations.ts | 4 +++- packages/workflow-store-cloudflare-d1/tests/store.test.ts | 8 ++++++-- packages/workflow-store-drizzle-postgres/README.md | 2 +- .../workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md | 6 +++--- .../workflow-store-drizzle-postgres/src/migrations.ts | 4 +++- .../workflow-store-drizzle-postgres/tests/store.test.ts | 8 ++++++-- 16 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql diff --git a/docs/api/store-adapters.md b/docs/api/store-adapters.md index dadfa9b..4a3915a 100644 --- a/docs/api/store-adapters.md +++ b/docs/api/store-adapters.md @@ -62,7 +62,7 @@ const store = createDrizzlePostgresWorkflowStore({ db }) Apply the package-owned migration during setup/deploy: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql +psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` Use it in the runtime: @@ -101,7 +101,7 @@ the SQL artifact from the installed package instead of mirroring `workflow_*` tables in application Drizzle schema files. ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql +psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` Programmatic setup can use the exported migration helpers: @@ -147,6 +147,7 @@ Apply the package-owned D1 migration during setup/deploy: ```txt node_modules/@tanstack/workflow-store-cloudflare-d1/migrations/0000_workflow_store.sql +node_modules/@tanstack/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql ``` Programmatic setup can use the exported migration helpers: diff --git a/docs/cookbook/index.md b/docs/cookbook/index.md index 00e6bb5..381a30a 100644 --- a/docs/cookbook/index.md +++ b/docs/cookbook/index.md @@ -135,7 +135,7 @@ during setup/deploy instead of copying `workflow_*` tables into your app's Drizzle schema. ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql +psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` If your deploy system wants a package script: @@ -143,7 +143,7 @@ If your deploy system wants a package script: ```json { "scripts": { - "workflow:migrate": "psql \"$DATABASE_URL\" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql" + "workflow:migrate": "psql \"$DATABASE_URL\" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql" } } ``` diff --git a/docs/guide/deployment.md b/docs/guide/deployment.md index 4c2cb6c..51dffcb 100644 --- a/docs/guide/deployment.md +++ b/docs/guide/deployment.md @@ -67,13 +67,14 @@ the package-owned migration against the same database your deployed functions use: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql +psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` For Cloudflare D1, use the D1-compatible package-owned migration artifact: ```txt node_modules/@tanstack/workflow-store-cloudflare-d1/migrations/0000_workflow_store.sql +node_modules/@tanstack/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql ``` Wire it into your app scripts if your deploy provider runs package scripts: @@ -81,7 +82,7 @@ Wire it into your app scripts if your deploy provider runs package scripts: ```json { "scripts": { - "workflow:migrate": "psql \"$DATABASE_URL\" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql", + "workflow:migrate": "psql \"$DATABASE_URL\" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql", "workflow:sweep": "tsx scripts/workflow-sweep.ts" } } diff --git a/docs/guide/index.md b/docs/guide/index.md index cddaec2..12ccd79 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -202,7 +202,7 @@ Apply the package-owned Workflow store migration before runtime sweeps or requests hit that database: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql +psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` Then pass `store` to `defineWorkflowRuntime`. The runtime will use it for: diff --git a/docs/guide/persistence.md b/docs/guide/persistence.md index 0ee01bb..c17a5ff 100644 --- a/docs/guide/persistence.md +++ b/docs/guide/persistence.md @@ -170,7 +170,7 @@ const store = createDrizzlePostgresWorkflowStore({ Apply the package-owned migration during setup/deploy: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql +psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` Workflow owns the `workflow_*` table definitions, indexes, leases, timers, diff --git a/docs/installation.md b/docs/installation.md index cc80cf2..2e481e9 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -49,7 +49,7 @@ const store = createDrizzlePostgresWorkflowStore({ db }) Apply the package-owned store migration during setup/deploy: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql +psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` For Cloudflare D1: @@ -66,6 +66,7 @@ const store = createCloudflareD1WorkflowStore({ db: env.WORKFLOW_DB }) Copy or reference the package-owned SQL artifact from `node_modules/@tanstack/workflow-store-cloudflare-d1/migrations/0000_workflow_store.sql` +`node_modules/@tanstack/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql` in your D1 migration flow. ## Server framework diff --git a/examples/deployment-pocs/cloudflare-d1/README.md b/examples/deployment-pocs/cloudflare-d1/README.md index 90013ce..231d869 100644 --- a/examples/deployment-pocs/cloudflare-d1/README.md +++ b/examples/deployment-pocs/cloudflare-d1/README.md @@ -39,6 +39,7 @@ copy of the package-owned artifact from: ```txt packages/workflow-store-cloudflare-d1/migrations/0000_workflow_store.sql +packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql ``` Apply it locally: diff --git a/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql b/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql new file mode 100644 index 0000000..b6a6ac2 --- /dev/null +++ b/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql @@ -0,0 +1,4 @@ +alter table "workflow_timers" add column claim_order integer not null default 0; + +insert into "workflow_schema_migrations" (migration_id, package_name, package_version, applied_at) + values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer)); diff --git a/packages/workflow-store-cloudflare-d1/README.md b/packages/workflow-store-cloudflare-d1/README.md index 7a478e3..2a2c079 100644 --- a/packages/workflow-store-cloudflare-d1/README.md +++ b/packages/workflow-store-cloudflare-d1/README.md @@ -36,6 +36,7 @@ The SQL artifact lives at: ```txt node_modules/@tanstack/workflow-store-cloudflare-d1/migrations/0000_workflow_store.sql +node_modules/@tanstack/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql ``` `store.ensureSchema()` remains available for tests, local demos, and explicit diff --git a/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md b/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md index 343f0c5..5aad605 100644 --- a/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md +++ b/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md @@ -33,6 +33,6 @@ timers and leases. Fresh databases apply `0000_workflow_store.sql` then `0001`. `ensureSchema()` checks the migration ledger and applies missing migrations; run it once during deployment, before starting workers. -The singular `getCloudflareD1WorkflowStoreMigrationSql` helper remains the original -bootstrap SQL. Use the package's `getCloudflareD1WorkflowStoreMigrations()` helper for -the complete ordered migration list, including custom table names. +`getCloudflareD1WorkflowStoreMigrationSql()` returns the complete SQL for a fresh +installation. For upgrades, use `getCloudflareD1WorkflowStoreMigrations()` and apply +only entries absent from the migration ledger. Both helpers support custom table names. diff --git a/packages/workflow-store-cloudflare-d1/src/migrations.ts b/packages/workflow-store-cloudflare-d1/src/migrations.ts index e5b720a..5bb03a9 100644 --- a/packages/workflow-store-cloudflare-d1/src/migrations.ts +++ b/packages/workflow-store-cloudflare-d1/src/migrations.ts @@ -40,5 +40,7 @@ export function getCloudflareD1WorkflowStoreMigrations( export function getCloudflareD1WorkflowStoreMigrationSql( options?: CloudflareD1WorkflowStoreSchemaOptions, ): string { - return getCloudflareD1WorkflowStoreMigrations(options)[0]!.sql + return getCloudflareD1WorkflowStoreMigrations(options) + .map((migration) => migration.sql) + .join('\n') } diff --git a/packages/workflow-store-cloudflare-d1/tests/store.test.ts b/packages/workflow-store-cloudflare-d1/tests/store.test.ts index d87e875..dab1b70 100644 --- a/packages/workflow-store-cloudflare-d1/tests/store.test.ts +++ b/packages/workflow-store-cloudflare-d1/tests/store.test.ts @@ -31,7 +31,11 @@ describe('cloudflare-d1 schema contract', () => { ) const migrationSql = await readFile(migrationFile, 'utf8') - expect(getCloudflareD1WorkflowStoreMigrationSql()).toBe(migrationSql) + expect(getCloudflareD1WorkflowStoreMigrationSql()).toBe( + getCloudflareD1WorkflowStoreMigrations() + .map((migration) => migration.sql) + .join('\n'), + ) expect(getCloudflareD1WorkflowStoreMigrations()[1]!.sql).toBe( await readFile( new URL('../migrations/0001_fair_timer_claims.sql', import.meta.url), @@ -72,7 +76,7 @@ describe('cloudflare-d1 schema contract', () => { test('upgrades existing timers and preserves fairness across store instances', async () => { const db = createTestD1Database() - await db.exec!(getCloudflareD1WorkflowStoreMigrationSql()) + await db.exec!(getCloudflareD1WorkflowStoreMigrations()[0]!.sql) await db.exec!( `insert into workflow_timers (run_id, signal_id, workflow_id, wake_at, lease_owner, lease_expires_at) values ('a', 'timer', 'workflow', 100, 'old-worker', 50), ('b', 'timer', 'workflow', 100, null, null)`, ) diff --git a/packages/workflow-store-drizzle-postgres/README.md b/packages/workflow-store-drizzle-postgres/README.md index 01b351e..876e8c2 100644 --- a/packages/workflow-store-drizzle-postgres/README.md +++ b/packages/workflow-store-drizzle-postgres/README.md @@ -28,7 +28,7 @@ const store = createDrizzlePostgresWorkflowStore({ db }) Apply the package-owned migration during setup/deploy: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql +psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` `store.ensureSchema()` remains available for tests, local demos, and explicit diff --git a/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md b/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md index 72534b2..05d1c86 100644 --- a/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md +++ b/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md @@ -92,6 +92,6 @@ timers and leases. Fresh databases apply `0000_workflow_store.sql` then `0001`. `ensureSchema()` checks the migration ledger and applies missing migrations; run it once during deployment, before starting workers. -The singular `getDrizzlePostgresWorkflowStoreMigrationSql` helper remains the original -bootstrap SQL. Use the package's `getDrizzlePostgresWorkflowStoreMigrations()` helper for -the complete ordered migration list, including custom table names. +`getDrizzlePostgresWorkflowStoreMigrationSql()` returns the complete SQL for a fresh +installation. For upgrades, use `getDrizzlePostgresWorkflowStoreMigrations()` and apply +only entries absent from the migration ledger. Both helpers support custom table names. diff --git a/packages/workflow-store-drizzle-postgres/src/migrations.ts b/packages/workflow-store-drizzle-postgres/src/migrations.ts index 7f1a2d2..f966b11 100644 --- a/packages/workflow-store-drizzle-postgres/src/migrations.ts +++ b/packages/workflow-store-drizzle-postgres/src/migrations.ts @@ -41,5 +41,7 @@ export function getDrizzlePostgresWorkflowStoreMigrations( export function getDrizzlePostgresWorkflowStoreMigrationSql( options?: DrizzlePostgresWorkflowStoreSchemaOptions, ): string { - return getDrizzlePostgresWorkflowStoreMigrations(options)[0]!.sql + return getDrizzlePostgresWorkflowStoreMigrations(options) + .map((migration) => migration.sql) + .join('\n') } diff --git a/packages/workflow-store-drizzle-postgres/tests/store.test.ts b/packages/workflow-store-drizzle-postgres/tests/store.test.ts index f693f88..46f67f7 100644 --- a/packages/workflow-store-drizzle-postgres/tests/store.test.ts +++ b/packages/workflow-store-drizzle-postgres/tests/store.test.ts @@ -28,7 +28,11 @@ describe('drizzle-postgres schema contract', () => { ) const migrationSql = await readFile(migrationFile, 'utf8') - expect(getDrizzlePostgresWorkflowStoreMigrationSql()).toBe(migrationSql) + expect(getDrizzlePostgresWorkflowStoreMigrationSql()).toBe( + getDrizzlePostgresWorkflowStoreMigrations() + .map((migration) => migration.sql) + .join('\n'), + ) expect(getDrizzlePostgresWorkflowStoreMigrations()[1]!.sql).toBe( await readFile( new URL('../migrations/0001_fair_timer_claims.sql', import.meta.url), @@ -74,7 +78,7 @@ describe('drizzle-postgres schema contract', () => { test('upgrades existing timers and preserves fairness across store instances', async () => { const client = new PGlite() const db = drizzle(client) - await client.exec(getDrizzlePostgresWorkflowStoreMigrationSql()) + await client.exec(getDrizzlePostgresWorkflowStoreMigrations()[0]!.sql) await client.exec( `insert into workflow_timers (run_id, signal_id, workflow_id, wake_at, lease_owner, lease_expires_at) values ('a', 'timer', 'workflow', 100, 'old-worker', 50), ('b', 'timer', 'workflow', 100, null, null)`, ) From 61a1bdf859ed432a1df5a8c06d5fa2a85e392a0a Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 9 Nov 2026 10:46:10 -0700 Subject: [PATCH 07/11] perf(stores): index persisted timer claim order --- .../cloudflare-d1/migrations/0001_fair_timer_claims.sql | 2 ++ .../migrations/0001_fair_timer_claims.sql | 2 ++ packages/workflow-store-cloudflare-d1/src/schema-contract.ts | 1 + .../migrations/0001_fair_timer_claims.sql | 2 ++ packages/workflow-store-drizzle-postgres/src/schema-contract.ts | 1 + packages/workflow-store-drizzle-postgres/src/tables.ts | 1 + 6 files changed, 9 insertions(+) diff --git a/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql b/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql index b6a6ac2..1633848 100644 --- a/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql +++ b/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql @@ -1,4 +1,6 @@ alter table "workflow_timers" add column claim_order integer not null default 0; +create index "workflow_timers_claim_order_idx" on "workflow_timers" (claim_order); + insert into "workflow_schema_migrations" (migration_id, package_name, package_version, applied_at) values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer)); diff --git a/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql b/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql index b6a6ac2..1633848 100644 --- a/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql +++ b/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql @@ -1,4 +1,6 @@ alter table "workflow_timers" add column claim_order integer not null default 0; +create index "workflow_timers_claim_order_idx" on "workflow_timers" (claim_order); + insert into "workflow_schema_migrations" (migration_id, package_name, package_version, applied_at) values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer)); diff --git a/packages/workflow-store-cloudflare-d1/src/schema-contract.ts b/packages/workflow-store-cloudflare-d1/src/schema-contract.ts index ebdf150..dcddc97 100644 --- a/packages/workflow-store-cloudflare-d1/src/schema-contract.ts +++ b/packages/workflow-store-cloudflare-d1/src/schema-contract.ts @@ -192,6 +192,7 @@ export function getCloudflareD1TimerFairnessStatements( const tables = resolveCloudflareD1WorkflowStoreTables(options.tables) return [ `alter table ${quoteIdent(tables.timers)} add column claim_order integer not null default 0`, + `create index ${quoteIdent(`${tables.timers}_claim_order_idx`)} on ${quoteIdent(tables.timers)} (claim_order)`, `insert into ${quoteIdent(tables.schemaMigrations)} (migration_id, package_name, package_version, applied_at) values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer))`, ].map(normalizeSqlStatement) diff --git a/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql b/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql index 508da89..24779bc 100644 --- a/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +++ b/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql @@ -1,4 +1,6 @@ alter table "workflow_timers" add column claim_order bigint not null default 0; +create index "workflow_timers_claim_order_idx" on "workflow_timers" (claim_order); + insert into "workflow_schema_migrations" (migration_id, package_name, package_version, applied_at) values ('0001_fair_timer_claims', '@tanstack/workflow-store-drizzle-postgres', null, cast(extract(epoch from now()) * 1000 as bigint)); diff --git a/packages/workflow-store-drizzle-postgres/src/schema-contract.ts b/packages/workflow-store-drizzle-postgres/src/schema-contract.ts index 5e4f06b..a916d58 100644 --- a/packages/workflow-store-drizzle-postgres/src/schema-contract.ts +++ b/packages/workflow-store-drizzle-postgres/src/schema-contract.ts @@ -213,6 +213,7 @@ export function getDrizzlePostgresTimerFairnessStatements( const tables = resolveDrizzlePostgresWorkflowStoreTables(options.tables) return [ `alter table ${qualifiedTableName(options.schema, tables.timers)} add column claim_order bigint not null default 0`, + `create index ${quoteIdent(`${tables.timers}_claim_order_idx`)} on ${qualifiedTableName(options.schema, tables.timers)} (claim_order)`, `insert into ${qualifiedTableName(options.schema, tables.schemaMigrations)} (migration_id, package_name, package_version, applied_at) values ('0001_fair_timer_claims', '@tanstack/workflow-store-drizzle-postgres', null, cast(extract(epoch from now()) * 1000 as bigint))`, ].map(normalizeSqlStatement) diff --git a/packages/workflow-store-drizzle-postgres/src/tables.ts b/packages/workflow-store-drizzle-postgres/src/tables.ts index 5f9f728..e3274fb 100644 --- a/packages/workflow-store-drizzle-postgres/src/tables.ts +++ b/packages/workflow-store-drizzle-postgres/src/tables.ts @@ -92,6 +92,7 @@ export const workflowTimers = pgTable( (table) => [ primaryKey({ columns: [table.runId, table.signalId] }), index('workflow_timers_due_idx').on(table.wakeAt, table.leaseExpiresAt), + index('workflow_timers_claim_order_idx').on(table.claimOrder), ], ) From d68fe5797cffa61b05fd10b31bcde34c44937247 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 9 Nov 2026 10:48:44 -0700 Subject: [PATCH 08/11] docs: keep rejected cookbook webhook deliveries retryable --- docs/cookbook/index.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/cookbook/index.md b/docs/cookbook/index.md index 381a30a..130bfcf 100644 --- a/docs/cookbook/index.md +++ b/docs/cookbook/index.md @@ -201,10 +201,16 @@ export async function POST(request: Request) { includeEvents: false, }) - return Response.json({ kind: result.kind }) + return Response.json( + { kind: result.kind }, + { status: result.kind === 'version-mismatch' ? 503 : 200 }, + ) } ``` +The sender must retry 503 responses with the same event ID. If it cannot retry, +store the delivery in a durable inbox before acknowledging it. + ## Wait for approval Workflow: From c3d079ece3c641be32c1bc67391cf7a0ca7bc837 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Mon, 9 Nov 2026 17:55:29 -0700 Subject: [PATCH 09/11] fix: preserve timer turns and make schema upgrades retry-safe --- docs/api/store-adapters.md | 4 +- docs/cookbook/index.md | 4 +- docs/guide/deployment.md | 4 +- docs/guide/index.md | 2 +- docs/guide/persistence.md | 2 +- docs/installation.md | 2 +- .../migrations/0001_fair_timer_claims.sql | 4 +- .../workflow-runtime/src/runtime-driver.ts | 3 +- .../workflow-execution-store.contract.ts | 20 +++++-- .../tests/runtime-driver.test.ts | 58 +++++++++++++++++++ .../SCHEMA_MIGRATIONS.md | 9 ++- .../migrations/0001_fair_timer_claims.sql | 4 +- .../src/schema-contract.ts | 4 +- .../workflow-store-cloudflare-d1/src/store.ts | 22 +++---- .../tests/store.test.ts | 51 ++++++++++++++++ .../workflow-store-drizzle-postgres/README.md | 2 +- .../SCHEMA_MIGRATIONS.md | 8 ++- .../migrations/0001_fair_timer_claims.sql | 6 +- .../src/schema-contract.ts | 6 +- .../src/store.ts | 20 +++---- .../tests/store.test.ts | 39 +++++++++++++ 21 files changed, 219 insertions(+), 55 deletions(-) diff --git a/docs/api/store-adapters.md b/docs/api/store-adapters.md index 4a3915a..5ad077f 100644 --- a/docs/api/store-adapters.md +++ b/docs/api/store-adapters.md @@ -62,7 +62,7 @@ const store = createDrizzlePostgresWorkflowStore({ db }) Apply the package-owned migration during setup/deploy: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +psql -v ON_ERROR_STOP=1 --single-transaction "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` Use it in the runtime: @@ -101,7 +101,7 @@ the SQL artifact from the installed package instead of mirroring `workflow_*` tables in application Drizzle schema files. ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +psql -v ON_ERROR_STOP=1 --single-transaction "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` Programmatic setup can use the exported migration helpers: diff --git a/docs/cookbook/index.md b/docs/cookbook/index.md index 130bfcf..4148445 100644 --- a/docs/cookbook/index.md +++ b/docs/cookbook/index.md @@ -135,7 +135,7 @@ during setup/deploy instead of copying `workflow_*` tables into your app's Drizzle schema. ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +psql -v ON_ERROR_STOP=1 --single-transaction "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` If your deploy system wants a package script: @@ -143,7 +143,7 @@ If your deploy system wants a package script: ```json { "scripts": { - "workflow:migrate": "psql \"$DATABASE_URL\" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql" + "workflow:migrate": "psql -v ON_ERROR_STOP=1 --single-transaction \"$DATABASE_URL\" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql" } } ``` diff --git a/docs/guide/deployment.md b/docs/guide/deployment.md index 51dffcb..9de1700 100644 --- a/docs/guide/deployment.md +++ b/docs/guide/deployment.md @@ -67,7 +67,7 @@ the package-owned migration against the same database your deployed functions use: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +psql -v ON_ERROR_STOP=1 --single-transaction "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` For Cloudflare D1, use the D1-compatible package-owned migration artifact: @@ -82,7 +82,7 @@ Wire it into your app scripts if your deploy provider runs package scripts: ```json { "scripts": { - "workflow:migrate": "psql \"$DATABASE_URL\" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql", + "workflow:migrate": "psql -v ON_ERROR_STOP=1 --single-transaction \"$DATABASE_URL\" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql", "workflow:sweep": "tsx scripts/workflow-sweep.ts" } } diff --git a/docs/guide/index.md b/docs/guide/index.md index 12ccd79..f099108 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -202,7 +202,7 @@ Apply the package-owned Workflow store migration before runtime sweeps or requests hit that database: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +psql -v ON_ERROR_STOP=1 --single-transaction "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` Then pass `store` to `defineWorkflowRuntime`. The runtime will use it for: diff --git a/docs/guide/persistence.md b/docs/guide/persistence.md index c17a5ff..f38b2f1 100644 --- a/docs/guide/persistence.md +++ b/docs/guide/persistence.md @@ -170,7 +170,7 @@ const store = createDrizzlePostgresWorkflowStore({ Apply the package-owned migration during setup/deploy: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +psql -v ON_ERROR_STOP=1 --single-transaction "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` Workflow owns the `workflow_*` table definitions, indexes, leases, timers, diff --git a/docs/installation.md b/docs/installation.md index 2e481e9..0d0aa8a 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -49,7 +49,7 @@ const store = createDrizzlePostgresWorkflowStore({ db }) Apply the package-owned store migration during setup/deploy: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +psql -v ON_ERROR_STOP=1 --single-transaction "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` For Cloudflare D1: diff --git a/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql b/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql index 1633848..6c6c05b 100644 --- a/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql +++ b/examples/deployment-pocs/cloudflare-d1/migrations/0001_fair_timer_claims.sql @@ -1,6 +1,6 @@ alter table "workflow_timers" add column claim_order integer not null default 0; -create index "workflow_timers_claim_order_idx" on "workflow_timers" (claim_order); +create index if not exists "workflow_timers_claim_order_idx" on "workflow_timers" (claim_order); insert into "workflow_schema_migrations" (migration_id, package_name, package_version, applied_at) - values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer)); + values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer)) on conflict (migration_id) do nothing; diff --git a/packages/workflow-runtime/src/runtime-driver.ts b/packages/workflow-runtime/src/runtime-driver.ts index 04dc622..bc5170c 100644 --- a/packages/workflow-runtime/src/runtime-driver.ts +++ b/packages/workflow-runtime/src/runtime-driver.ts @@ -587,7 +587,8 @@ async function sweep>( () => config.store.claimDueTimers({ now, - limit: maxTimers - inspectedTimers, + // Claim only the next turn, so a deadline cannot rotate untouched timers. + limit: 1, leaseOwner, leaseMs, }), diff --git a/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts b/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts index cfb92c5..8859bc0 100644 --- a/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts +++ b/packages/workflow-runtime/tests/contracts/workflow-execution-store.contract.ts @@ -265,9 +265,13 @@ export function runWorkflowExecutionStoreContractTests( leaseExpiresAt: 150, }) expect( - (await store.claimDueTimers({ ...claim, leaseOwner: 'worker-b' })).map( - (t) => t.runId, - ), + ( + await store.claimDueTimers({ + ...claim, + limit: 3, + leaseOwner: 'worker-b', + }) + ).map((t) => t.runId), ).toEqual(['c']) await store.releaseTimerLease({ runId: 'a', @@ -276,9 +280,13 @@ export function runWorkflowExecutionStoreContractTests( leaseExpiresAt: 150, }) expect( - (await store.claimDueTimers({ ...claim, leaseOwner: 'worker-b' })).map( - (t) => t.runId, - ), + ( + await store.claimDueTimers({ + ...claim, + limit: 1, + leaseOwner: 'worker-b', + }) + ).map((t) => t.runId), ).toEqual(['a']) // An expired claim must not clear a newer lease, even for the same owner. await store.claimDueTimers({ diff --git a/packages/workflow-runtime/tests/runtime-driver.test.ts b/packages/workflow-runtime/tests/runtime-driver.test.ts index f31d8cb..ee285b0 100644 --- a/packages/workflow-runtime/tests/runtime-driver.test.ts +++ b/packages/workflow-runtime/tests/runtime-driver.test.ts @@ -1027,6 +1027,64 @@ describe('workflow runtime driver', () => { expect(result.remainingMayExist).toBe(true) }) + it('gives untouched timers their turn after repeated short sweeps', async () => { + const store = inMemoryWorkflowExecutionStore() + const define = (version: string) => + createWorkflow({ id: 'short-sweep', version }).handler(async (ctx) => { + await ctx.sleepUntil(100) + return true + }) + let version = 'v1' + let wallNow = 0 + let expireDuringLoad = false + const runtime = defineWorkflowRuntime({ + store, + workflows: { + 'short-sweep': { + load: async () => { + if (expireDuringLoad) wallNow = 1000 + return define(version) + }, + }, + }, + }) + await runtime.startRun({ + workflowId: 'short-sweep', + runId: 'a-missing', + input: {}, + now: 0, + }) + version = 'v2' + await runtime.startRun({ + workflowId: 'short-sweep', + runId: 'z-healthy', + input: {}, + now: 0, + }) + const clock = vi.spyOn(Date, 'now').mockImplementation(() => wallNow) + try { + expireDuringLoad = true + const first = await runtime.sweep({ + now: 100, + maxTimers: 10, + deadline: 500, + minYieldRemainingMs: 0, + }) + expect(first.timers[0]?.kind).toBe('version-mismatch') + wallNow = 0 + expireDuringLoad = false + const next = await runtime.sweep({ + now: 100, + maxTimers: 1, + deadline: 500, + minYieldRemainingMs: 0, + }) + expect(next.timers[0]?.kind).toBe('completed') + } finally { + clock.mockRestore() + } + }) + it('bounds inspections while rotating past a backlog of missing versions', async () => { const store = inMemoryWorkflowExecutionStore() const define = (version: string) => diff --git a/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md b/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md index 5aad605..046fc77 100644 --- a/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md +++ b/packages/workflow-store-cloudflare-d1/SCHEMA_MIGRATIONS.md @@ -30,9 +30,14 @@ pnpm --filter @tanstack/workflow-store-cloudflare-d1 pack --dry-run Apply `migrations/0001_fair_timer_claims.sql` once before deploying the timer fairness runtime. It adds `claim_order` with a zero default, preserving existing timers and leases. Fresh databases apply `0000_workflow_store.sql` then `0001`. -`ensureSchema()` checks the migration ledger and applies missing migrations; +`ensureSchema()` checks the configured tables and safely completes this upgrade; run it once during deployment, before starting workers. `getCloudflareD1WorkflowStoreMigrationSql()` returns the complete SQL for a fresh installation. For upgrades, use `getCloudflareD1WorkflowStoreMigrations()` and apply -only entries absent from the migration ledger. Both helpers support custom table names. +only entries absent from the migration ledger. Give separate stores separate ledgers +when using an external migration runner. Both helpers support custom table names. + +For D1, apply SQL files through Wrangler migrations. If a custom non-batch +bootstrap was interrupted after adding the column, rerun `ensureSchema()` to +finish the index and ledger entry without repeating the column addition. diff --git a/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql b/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql index 1633848..6c6c05b 100644 --- a/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql +++ b/packages/workflow-store-cloudflare-d1/migrations/0001_fair_timer_claims.sql @@ -1,6 +1,6 @@ alter table "workflow_timers" add column claim_order integer not null default 0; -create index "workflow_timers_claim_order_idx" on "workflow_timers" (claim_order); +create index if not exists "workflow_timers_claim_order_idx" on "workflow_timers" (claim_order); insert into "workflow_schema_migrations" (migration_id, package_name, package_version, applied_at) - values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer)); + values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer)) on conflict (migration_id) do nothing; diff --git a/packages/workflow-store-cloudflare-d1/src/schema-contract.ts b/packages/workflow-store-cloudflare-d1/src/schema-contract.ts index dcddc97..7fce2bc 100644 --- a/packages/workflow-store-cloudflare-d1/src/schema-contract.ts +++ b/packages/workflow-store-cloudflare-d1/src/schema-contract.ts @@ -192,8 +192,8 @@ export function getCloudflareD1TimerFairnessStatements( const tables = resolveCloudflareD1WorkflowStoreTables(options.tables) return [ `alter table ${quoteIdent(tables.timers)} add column claim_order integer not null default 0`, - `create index ${quoteIdent(`${tables.timers}_claim_order_idx`)} on ${quoteIdent(tables.timers)} (claim_order)`, + `create index if not exists ${quoteIdent(`${tables.timers}_claim_order_idx`)} on ${quoteIdent(tables.timers)} (claim_order)`, `insert into ${quoteIdent(tables.schemaMigrations)} (migration_id, package_name, package_version, applied_at) - values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer))`, + values ('0001_fair_timer_claims', '@tanstack/workflow-store-cloudflare-d1', null, cast(unixepoch('subsec') * 1000 as integer)) on conflict (migration_id) do nothing`, ].map(normalizeSqlStatement) } diff --git a/packages/workflow-store-cloudflare-d1/src/store.ts b/packages/workflow-store-cloudflare-d1/src/store.ts index d944026..e615f2e 100644 --- a/packages/workflow-store-cloudflare-d1/src/store.ts +++ b/packages/workflow-store-cloudflare-d1/src/store.ts @@ -104,18 +104,20 @@ export function createCloudflareD1WorkflowStore( })) { await execute(db, statement) } - const applied = await query( + // Inspect this table, since custom stores may share a migration ledger. + const columns = await query<{ name: string }>( db, - `select migration_id from ${tables.schemaMigrations} where migration_id = ?`, - ['0001_fair_timer_claims'], + `pragma table_info(${tables.timers})`, + ) + const hasClaimOrder = columns.some( + (column) => column.name === 'claim_order', + ) + await executeMany( + db, + getCloudflareD1TimerFairnessStatements({ tables: tableNames }) + .filter((_, index) => index !== 0 || !hasClaimOrder) + .map((sql) => statement(sql)), ) - if (!applied.length) - await executeMany( - db, - getCloudflareD1TimerFairnessStatements({ tables: tableNames }).map( - (sql) => statement(sql), - ), - ) }, async createRun(args: CreateRunArgs): Promise { diff --git a/packages/workflow-store-cloudflare-d1/tests/store.test.ts b/packages/workflow-store-cloudflare-d1/tests/store.test.ts index dab1b70..e5a62ef 100644 --- a/packages/workflow-store-cloudflare-d1/tests/store.test.ts +++ b/packages/workflow-store-cloudflare-d1/tests/store.test.ts @@ -133,6 +133,57 @@ describe('cloudflare-d1 schema contract', () => { ).toHaveLength(2) }) + test('upgrades separate timer tables sharing a migration ledger', async () => { + const db = createTestD1Database() + const first = createCloudflareD1WorkflowStore({ db }) + await first.ensureSchema() + const second = createCloudflareD1WorkflowStore({ + db, + tables: { timers: 'other_timers' }, + }) + await second.ensureSchema() + await second.ensureSchema() + await second.scheduleTimer({ + runId: 'a', + workflowId: 'workflow', + signalId: 'timer', + wakeAt: 100, + now: 0, + }) + expect( + await second.claimDueTimers({ + now: 100, + limit: 1, + leaseOwner: 'worker', + leaseMs: 50, + }), + ).toHaveLength(1) + }) + + test('resumes a non-batch upgrade after the column was added', async () => { + const db = createTestD1Database() + db.batch = undefined + await db.exec!(getCloudflareD1WorkflowStoreMigrations()[0]!.sql) + await db.exec!( + 'alter table workflow_timers add column claim_order integer not null default 0', + ) + const store = createCloudflareD1WorkflowStore({ db }) + await store.ensureSchema() + await store.ensureSchema() + const indexes = await db + .prepare( + "select name from sqlite_master where name = 'workflow_timers_claim_order_idx'", + ) + .all() + expect(indexes.results).toHaveLength(1) + const ledger = await db + .prepare( + "select migration_id from workflow_schema_migrations where migration_id = '0001_fair_timer_claims'", + ) + .all() + expect(ledger.results).toHaveLength(1) + }) + test('records the applied schema migration during ensureSchema', async () => { const db = createTestD1Database() const store = createCloudflareD1WorkflowStore({ db }) diff --git a/packages/workflow-store-drizzle-postgres/README.md b/packages/workflow-store-drizzle-postgres/README.md index 876e8c2..cde2f5e 100644 --- a/packages/workflow-store-drizzle-postgres/README.md +++ b/packages/workflow-store-drizzle-postgres/README.md @@ -28,7 +28,7 @@ const store = createDrizzlePostgresWorkflowStore({ db }) Apply the package-owned migration during setup/deploy: ```bash -psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +psql -v ON_ERROR_STOP=1 --single-transaction "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql ``` `store.ensureSchema()` remains available for tests, local demos, and explicit diff --git a/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md b/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md index 05d1c86..af62c54 100644 --- a/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md +++ b/packages/workflow-store-drizzle-postgres/SCHEMA_MIGRATIONS.md @@ -89,9 +89,13 @@ Confirm the dry-run tarball includes every SQL file under `migrations/`. Apply `migrations/0001_fair_timer_claims.sql` once before deploying the timer fairness runtime. It adds `claim_order` with a zero default, preserving existing timers and leases. Fresh databases apply `0000_workflow_store.sql` then `0001`. -`ensureSchema()` checks the migration ledger and applies missing migrations; +`ensureSchema()` checks the configured tables and safely completes this upgrade; run it once during deployment, before starting workers. `getDrizzlePostgresWorkflowStoreMigrationSql()` returns the complete SQL for a fresh installation. For upgrades, use `getDrizzlePostgresWorkflowStoreMigrations()` and apply -only entries absent from the migration ledger. Both helpers support custom table names. +only entries absent from the migration ledger. Give separate stores separate ledgers +when using an external migration runner. Both helpers support custom table names. + +The PostgreSQL migration can be rerun safely. Use `psql -v ON_ERROR_STOP=1 +--single-transaction` so a failed statement stops deployment and rolls back the migration. diff --git a/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql b/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql index 24779bc..7ae7c83 100644 --- a/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql +++ b/packages/workflow-store-drizzle-postgres/migrations/0001_fair_timer_claims.sql @@ -1,6 +1,6 @@ -alter table "workflow_timers" add column claim_order bigint not null default 0; +alter table "workflow_timers" add column if not exists claim_order bigint not null default 0; -create index "workflow_timers_claim_order_idx" on "workflow_timers" (claim_order); +create index if not exists "workflow_timers_claim_order_idx" on "workflow_timers" (claim_order); insert into "workflow_schema_migrations" (migration_id, package_name, package_version, applied_at) - values ('0001_fair_timer_claims', '@tanstack/workflow-store-drizzle-postgres', null, cast(extract(epoch from now()) * 1000 as bigint)); + values ('0001_fair_timer_claims', '@tanstack/workflow-store-drizzle-postgres', null, cast(extract(epoch from now()) * 1000 as bigint)) on conflict (migration_id) do nothing; diff --git a/packages/workflow-store-drizzle-postgres/src/schema-contract.ts b/packages/workflow-store-drizzle-postgres/src/schema-contract.ts index a916d58..ad2d7fa 100644 --- a/packages/workflow-store-drizzle-postgres/src/schema-contract.ts +++ b/packages/workflow-store-drizzle-postgres/src/schema-contract.ts @@ -212,9 +212,9 @@ export function getDrizzlePostgresTimerFairnessStatements( ): Array { const tables = resolveDrizzlePostgresWorkflowStoreTables(options.tables) return [ - `alter table ${qualifiedTableName(options.schema, tables.timers)} add column claim_order bigint not null default 0`, - `create index ${quoteIdent(`${tables.timers}_claim_order_idx`)} on ${qualifiedTableName(options.schema, tables.timers)} (claim_order)`, + `alter table ${qualifiedTableName(options.schema, tables.timers)} add column if not exists claim_order bigint not null default 0`, + `create index if not exists ${quoteIdent(`${tables.timers}_claim_order_idx`)} on ${qualifiedTableName(options.schema, tables.timers)} (claim_order)`, `insert into ${qualifiedTableName(options.schema, tables.schemaMigrations)} (migration_id, package_name, package_version, applied_at) - values ('0001_fair_timer_claims', '@tanstack/workflow-store-drizzle-postgres', null, cast(extract(epoch from now()) * 1000 as bigint))`, + values ('0001_fair_timer_claims', '@tanstack/workflow-store-drizzle-postgres', null, cast(extract(epoch from now()) * 1000 as bigint)) on conflict (migration_id) do nothing`, ].map(normalizeSqlStatement) } diff --git a/packages/workflow-store-drizzle-postgres/src/store.ts b/packages/workflow-store-drizzle-postgres/src/store.ts index 7090aea..435d422 100644 --- a/packages/workflow-store-drizzle-postgres/src/store.ts +++ b/packages/workflow-store-drizzle-postgres/src/store.ts @@ -84,18 +84,14 @@ export function createDrizzlePostgresWorkflowStore( })) { await db.execute(sql.raw(statement)) } - const applied = await queryRows( - db, - sql`select migration_id from ${tableSql.schemaMigrations} where migration_id = '0001_fair_timer_claims'`, - ) - if (!applied.length) - await withTransaction(db, async (tx) => { - for (const statement of getDrizzlePostgresTimerFairnessStatements({ - schema: options.schema, - tables: tableNames, - })) - await tx.execute(sql.raw(statement)) - }) + // Idempotent DDL checks each configured table, even with a shared ledger. + await withTransaction(db, async (tx) => { + for (const statement of getDrizzlePostgresTimerFairnessStatements({ + schema: options.schema, + tables: tableNames, + })) + await tx.execute(sql.raw(statement)) + }) }, async createRun(args: CreateRunArgs): Promise { diff --git a/packages/workflow-store-drizzle-postgres/tests/store.test.ts b/packages/workflow-store-drizzle-postgres/tests/store.test.ts index 46f67f7..2fb14fa 100644 --- a/packages/workflow-store-drizzle-postgres/tests/store.test.ts +++ b/packages/workflow-store-drizzle-postgres/tests/store.test.ts @@ -101,6 +101,45 @@ describe('drizzle-postgres schema contract', () => { ]) }) + test('upgrades separate timer tables sharing a migration ledger', async () => { + const client = new PGlite() + const db = drizzle(client) + const first = createDrizzlePostgresWorkflowStore({ db }) + await first.ensureSchema() + const second = createDrizzlePostgresWorkflowStore({ + db, + tables: { timers: 'other_timers' }, + }) + await second.ensureSchema() + await second.ensureSchema() + await second.scheduleTimer({ + runId: 'a', + workflowId: 'workflow', + signalId: 'timer', + wakeAt: 100, + now: 0, + }) + expect( + await second.claimDueTimers({ + now: 100, + limit: 1, + leaseOwner: 'worker', + leaseMs: 50, + }), + ).toHaveLength(1) + }) + + test('retries the exported migration after a partial application', async () => { + const client = new PGlite() + const migrations = getDrizzlePostgresWorkflowStoreMigrations() + await client.exec(migrations[0]!.sql) + await client.exec(migrations[1]!.statements[0]!) + await client.exec(migrations[1]!.sql) + await client.exec(migrations[1]!.sql) + const result = await client.query('select claim_order from workflow_timers') + expect(result.rows).toEqual([]) + }) + test('records the applied schema migration during ensureSchema', async () => { const client = new PGlite() const db = drizzle(client) From b121c3bacf8105fbd37f9254bcd5cf6820496c71 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 10 Nov 2026 09:29:27 -0700 Subject: [PATCH 10/11] docs: clarify timer batch ordering contract --- docs/api/store-adapters.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/api/store-adapters.md b/docs/api/store-adapters.md index 5ad077f..41e41b2 100644 --- a/docs/api/store-adapters.md +++ b/docs/api/store-adapters.md @@ -33,6 +33,10 @@ order and prefer the least recently claimed timers. This keeps each sweep bounded while giving other timers a turn on subsequent sweeps, even when a workflow version stays unavailable. Newly scheduled timers start unclaimed. +Ordering within a claimed batch is not guaranteed. SQL stores give a batch one +claim order, while the in-memory store assigns each timer its own order. Runtime +sweeps claim one timer at a time so deadlines do not rotate untouched timers. + `releaseTimerLease` clears a claim only when both `leaseOwner` and `leaseExpiresAt` match. A missing timer or a changed lease is a no-op. Sweeps release their batch in cleanup, including on a deadline or error, so unused From 6774e601263cd251c81d315ff16321568a7a6fdf Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Wed, 11 Nov 2026 01:32:03 -0700 Subject: [PATCH 11/11] fix(build): upgrade tsdown to await package reads before cleanup --- package.json | 2 +- pnpm-lock.yaml | 753 ++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 622 insertions(+), 133 deletions(-) diff --git a/package.json b/package.json index 9800c2c..a976243 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "sherif": "^1.11.1", "size-limit": "^12.1.0", "tinyglobby": "^0.2.16", - "tsdown": "^0.21.10", + "tsdown": "^0.22.14", "typescript": "6.0.3", "vitest": "^4.1.5" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b3fb73..53ec5e0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -69,8 +69,8 @@ importers: specifier: ^0.2.16 version: 0.2.16 tsdown: - specifier: ^0.21.10 - version: 0.21.10(oxc-resolver@11.19.1)(publint@0.3.18)(typescript@6.0.3) + specifier: ^0.22.14 + version: 0.22.14(oxc-resolver@11.19.1)(publint@0.3.18)(typescript@6.0.3)(unrun@0.2.37) typescript: specifier: 6.0.3 version: 6.0.3 @@ -193,31 +193,10 @@ importers: packages: - '@babel/generator@8.0.0-rc.3': - resolution: {integrity: sha512-em37/13/nR320G4jab/nIIHZgc2Wz2y/D39lxnTyxB4/D/omPQncl/lSdlnJY1OhQcRGugTSIF2l/69o31C9dA==} - engines: {node: ^20.19.0 || >=22.12.0} - - '@babel/helper-string-parser@8.0.0-rc.3': - resolution: {integrity: sha512-AmwWFx1m8G/a5cXkxLxTiWl+YEoWuoFLUCwqMlNuWO1tqAYITQAbCRPUkyBHv1VOFgfjVOqEj6L3u15J5ZCzTA==} - engines: {node: ^20.19.0 || >=22.12.0} - - '@babel/helper-validator-identifier@8.0.0-rc.3': - resolution: {integrity: sha512-8AWCJ2VJJyDFlGBep5GpaaQ9AAaE/FjAcrqI7jyssYhtL7WGV0DOKpJsQqM037xDbpRLHXsY8TwU7zDma7coOw==} - engines: {node: ^20.19.0 || >=22.12.0} - - '@babel/parser@8.0.0-rc.3': - resolution: {integrity: sha512-B20dvP3MfNc/XS5KKCHy/oyWl5IA6Cn9YjXRdDlCjNmUFrjvLXMNUfQq/QUy9fnG2gYkKKcrto2YaF9B32ToOQ==} - engines: {node: ^20.19.0 || >=22.12.0} - hasBin: true - '@babel/runtime@7.28.6': resolution: {integrity: sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==} engines: {node: '>=6.9.0'} - '@babel/types@8.0.0-rc.3': - resolution: {integrity: sha512-mOm5ZrYmphGfqVWoH5YYMTITb3cDXsFgmvFlvkvWDMsR9X8RFnt7a0Wb6yNIdoFsiMO9WjYLq+U/FMtqIYAF8Q==} - engines: {node: ^20.19.0 || >=22.12.0} - '@changesets/apply-release-plan@7.1.1': resolution: {integrity: sha512-9qPCm/rLx/xoOFXIHGB229+4GOL76S4MC+7tyOuTsR6+1jYlfFDQORdvwR5hDA6y4FL2BPt3qpbcQIS+dW85LA==} @@ -344,6 +323,9 @@ packages: '@emnapi/core@1.9.2': resolution: {integrity: sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==} + '@emnapi/core@2.0.0-beta.2': + resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==} + '@emnapi/runtime@1.10.0': resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==} @@ -356,6 +338,9 @@ packages: '@emnapi/runtime@1.9.2': resolution: {integrity: sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw==} + '@emnapi/runtime@2.0.0-beta.2': + resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==} + '@emnapi/wasi-threads@1.0.4': resolution: {integrity: sha512-PJR+bOmMOPH8AtcTGAyYNiuJ3/Fcoj2XN/gBEWzDIKh254XO+mM9XoXHk5GNEhodxeMznbg7BlRojVbKN+gC6g==} @@ -365,6 +350,9 @@ packages: '@emnapi/wasi-threads@1.2.1': resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==} + '@emnapi/wasi-threads@2.2.0': + resolution: {integrity: sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==} + '@esbuild/aix-ppc64@0.27.3': resolution: {integrity: sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==} engines: {node: '>=18'} @@ -953,6 +941,13 @@ packages: '@emnapi/core': ^1.7.1 '@emnapi/runtime': ^1.7.1 + '@napi-rs/wasm-runtime@1.2.6': + resolution: {integrity: sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + peerDependencies: + '@emnapi/core': ^1.7.1 || 2.0.0-beta.2 + '@emnapi/runtime': ^1.7.1 || 2.0.0-beta.2 + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1153,6 +1148,9 @@ packages: '@oxc-project/types@0.127.0': resolution: {integrity: sha512-aIYXQBo4lCbO4z0R3FHeucQHpF46l2LbMdxRvqvuRuW2OxdnSkcng5B8+K12spgLDj93rtN3+J2Vac/TIO+ciQ==} + '@oxc-project/types@0.156.0': + resolution: {integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==} + '@oxc-resolver/binding-android-arm-eabi@11.19.1': resolution: {integrity: sha512-aUs47y+xyXHUKlbhqHUjBABjvycq6YSD7bpxSW7vplUmdzAlJ93yXY6ZR0c1o1x5A/QKbENCvs3+NlY8IpIVzg==} cpu: [arm] @@ -1277,36 +1275,72 @@ packages: '@quansync/fs@1.0.0': resolution: {integrity: sha512-4TJ3DFtlf1L5LDMaM6CanJ/0lckGNtJcMjQ1NAV6zDmA0tEHKZtxNKin8EgPaVX1YzljbxckyT2tJrpQKAtngQ==} + '@rolldown/binding-android-arm-eabi@1.2.19': + resolution: {integrity: sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + '@rolldown/binding-android-arm64@1.0.0-rc.17': resolution: {integrity: sha512-s70pVGhw4zqGeFnXWvAzJDlvxhlRollagdCCKRgOsgUOH3N1l0LIxf83AtGzmb5SiVM4Hjl5HyarMRfdfj3DaQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [android] + '@rolldown/binding-android-arm64@1.2.19': + resolution: {integrity: sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + '@rolldown/binding-darwin-arm64@1.0.0-rc.17': resolution: {integrity: sha512-4ksWc9n0mhlZpZ9PMZgTGjeOPRu8MB1Z3Tz0Mo02eWfWCHMW1zN82Qz/pL/rC+yQa+8ZnutMF0JjJe7PjwasYw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [darwin] + '@rolldown/binding-darwin-arm64@1.2.19': + resolution: {integrity: sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + '@rolldown/binding-darwin-x64@1.0.0-rc.17': resolution: {integrity: sha512-SUSDOI6WwUVNcWxd02QEBjLdY1VPHvlEkw6T/8nYG322iYWCTxRb1vzk4E+mWWYehTp7ERibq54LSJGjmouOsw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [darwin] + '@rolldown/binding-darwin-x64@1.2.19': + resolution: {integrity: sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + '@rolldown/binding-freebsd-x64@1.0.0-rc.17': resolution: {integrity: sha512-hwnz3nw9dbJ05EDO/PvcjaaewqqDy7Y1rn1UO81l8iIK1GjenME75dl16ajbvSSMfv66WXSRCYKIqfgq2KCfxw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [freebsd] + '@rolldown/binding-freebsd-x64@1.2.19': + resolution: {integrity: sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.17': resolution: {integrity: sha512-IS+W7epTcwANmFSQFrS1SivEXHtl1JtuQA9wlxrZTcNi6mx+FDOYrakGevvvTwgj2JvWiK8B29/qD9BELZPyXQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + resolution: {integrity: sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.17': resolution: {integrity: sha512-e6usGaHKW5BMNZOymS1UcEYGowQMWcgZ71Z17Sl/h2+ZziNJ1a9n3Zvcz6LdRyIW5572wBCTH/Z+bKuZouGk9Q==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1314,6 +1348,13 @@ packages: os: [linux] libc: [glibc] + '@rolldown/binding-linux-arm64-gnu@1.2.19': + resolution: {integrity: sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.17': resolution: {integrity: sha512-b/CgbwAJpmrRLp02RPfhbudf5tZnN9nsPWK82znefso832etkem8H7FSZwxrOI9djcdTP7U6YfNhbRnh7djErg==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1321,6 +1362,13 @@ packages: os: [linux] libc: [musl] + '@rolldown/binding-linux-arm64-musl@1.2.19': + resolution: {integrity: sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.17': resolution: {integrity: sha512-4EII1iNGRUN5WwGbF/kOh/EIkoDN9HsupgLQoXfY+D1oyJm7/F4t5PYU5n8SWZgG0FEwakyM8pGgwcBYruGTlA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1328,6 +1376,13 @@ packages: os: [linux] libc: [glibc] + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + resolution: {integrity: sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.17': resolution: {integrity: sha512-AH8oq3XqQo4IibpVXvPeLDI5pzkpYn0WiZAfT05kFzoJ6tQNzwRdDYQ45M8I/gslbodRZwW8uxLhbSBbkv96rA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1335,6 +1390,13 @@ packages: os: [linux] libc: [glibc] + '@rolldown/binding-linux-s390x-gnu@1.2.19': + resolution: {integrity: sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.17': resolution: {integrity: sha512-cLnjV3xfo7KslbU41Z7z8BH/E1y5mzUYzAqih1d1MDaIGZRCMqTijqLv76/P7fyHuvUcfGsIpqCdddbxLLK9rA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1342,6 +1404,13 @@ packages: os: [linux] libc: [glibc] + '@rolldown/binding-linux-x64-gnu@1.2.19': + resolution: {integrity: sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + '@rolldown/binding-linux-x64-musl@1.0.0-rc.17': resolution: {integrity: sha512-0phclDw1spsL7dUB37sIARuis2tAgomCJXAHZlpt8PXZ4Ba0dRP1e+66lsRqrfhISeN9bEGNjQs+T/Fbd7oYGw==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1349,32 +1418,65 @@ packages: os: [linux] libc: [musl] + '@rolldown/binding-linux-x64-musl@1.2.19': + resolution: {integrity: sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + '@rolldown/binding-openharmony-arm64@1.0.0-rc.17': resolution: {integrity: sha512-0ag/hEgXOwgw4t8QyQvUCxvEg+V0KBcA6YuOx9g0r02MprutRF5dyljgm3EmR02O292UX7UeS6HzWHAl6KgyhA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [openharmony] + '@rolldown/binding-openharmony-arm64@1.2.19': + resolution: {integrity: sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + '@rolldown/binding-wasm32-wasi@1.0.0-rc.17': resolution: {integrity: sha512-LEXei6vo0E5wTGwpkJ4KoT3OZJRnglwldt5ziLzOlc6qqb55z4tWNq2A+PFqCJuvWWdP53CVhG1Z9NtToDPJrA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [wasm32] + '@rolldown/binding-wasm32-wasi@1.2.19': + resolution: {integrity: sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + cpu: [wasm32] + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.17': resolution: {integrity: sha512-gUmyzBl3SPMa6hrqFUth9sVfcLBlYsbMzBx5PlexMroZStgzGqlZ26pYG89rBb45Mnia+oil6YAIFeEWGWhoZA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [win32] + '@rolldown/binding-win32-arm64-msvc@1.2.19': + resolution: {integrity: sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.17': resolution: {integrity: sha512-3hkiolcUAvPB9FLb3UZdfjVVNWherN1f/skkGWJP/fgSQhYUZpSIRr0/I8ZK9TkF3F7kxvJAk0+IcKvPHk9qQg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [win32] + '@rolldown/binding-win32-x64-msvc@1.2.19': + resolution: {integrity: sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + '@rolldown/pluginutils@1.0.0-rc.17': resolution: {integrity: sha512-n8iosDOt6Ig1UhJ2AYqoIhHWh/isz0xpicHTzpKBeotdVsTEcxsSA/i3EVM7gQAj0rU27OLAxCjzlj15IWY7bg==} + '@rolldown/pluginutils@1.1.0': + resolution: {integrity: sha512-K+NU2HDCEem4sClgHH4ZZXwdJeNFkJo+hRk479DIwdIviAPN2hFJH1KHHwg8CxHQXvi0M5XY4deTXINfIiSG6w==} + '@shikijs/engine-oniguruma@3.21.0': resolution: {integrity: sha512-OYknTCct6qiwpQDqDdf3iedRdzj6hFlOPv5hMvI+hkWfCKs5mlJ4TXziBG9nyabLwGulrUjHiCq3xCspSzErYQ==} @@ -1441,6 +1543,9 @@ packages: '@tybys/wasm-util@0.10.1': resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==} + '@tybys/wasm-util@0.10.4': + resolution: {integrity: sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==} + '@tybys/wasm-util@0.9.0': resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==} @@ -1459,9 +1564,6 @@ packages: '@types/hast@3.0.4': resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} - '@types/jsesc@2.5.1': - resolution: {integrity: sha512-9VN+6yxLOPLOav+7PwjZbxiID2bVaeq0ED4qSQmdQTdjnXJSaCVKTR58t15oqH1H5t8Ng2ZX1SabJVoN9Q34bw==} - '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} @@ -1678,6 +1780,165 @@ packages: '@yarnpkg/lockfile@1.1.0': resolution: {integrity: sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==} + '@yuku-codegen/binding-android-arm64@0.8.7': + resolution: {integrity: sha512-C/0zV5IhgVdYhGJTwrY0v8dknxlhiKwtVJkMUaexu9/QvRmzlV4vfU3hZlUSgqc2BxQHntL1mCVbDq8j0FRFDw==} + cpu: [arm64] + os: [android] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-darwin-arm64@0.8.7': + resolution: {integrity: sha512-/u+REDMI4a0/lsJXTM4c53/w31OGZLOReZIyg62uhgLs0kc8NHsj/nOcxTdlQjq5gi0zhdkccD9LaLTXcdzPvw==} + cpu: [arm64] + os: [darwin] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-darwin-x64@0.8.7': + resolution: {integrity: sha512-sMMzFOwCo4WXR+/6zIBThOocSC50iIIZZdfiIDbaLvj0Ax/rWt/iavyfEAqajyvzydLyCqR/ZItdLWSRlu1umw==} + cpu: [x64] + os: [darwin] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-freebsd-x64@0.8.7': + resolution: {integrity: sha512-MpdpKXix9P+Y1rKgjvcNeNtGjXeL1CmttNhYINrWls8kRpm4xM/oBGTmn6w7to8lAlwj5jm8q03dQPl5mRv4Qw==} + cpu: [x64] + os: [freebsd] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-linux-arm-gnu@0.8.7': + resolution: {integrity: sha512-rr1srFLlPAmC1vtxfc9C1YLDe3iH09YjfSeeIidBqKhzx1MATjOAq4mjlRUOnhr/L27MotWIYOFKwVsd5JZFOg==} + cpu: [arm] + os: [linux] + libc: [glibc] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-linux-arm-musl@0.8.7': + resolution: {integrity: sha512-eAufXh8qBRpiSO6ueaMDL+yyoXIGLhpUce72YbcACtZU2qhExwBIJyEtQf5kH2Ki0X2aqkSjSfog4OPtKXan3Q==} + cpu: [arm] + os: [linux] + libc: [musl] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-linux-arm64-gnu@0.8.7': + resolution: {integrity: sha512-gw4w6wPoHObBrdIC4duVWLmJOvpdE25j5D7yrM5mACNlK4klRz/lv8hK+ssQk9EJHBgZjSaqZIJVFgqNYbfv7A==} + cpu: [arm64] + os: [linux] + libc: [glibc] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-linux-arm64-musl@0.8.7': + resolution: {integrity: sha512-L68N6Y4XkqcIaKo3Ra88JEvBEH4AHff44A4INcrxeVWZ8CZtu2tCpfVxe3hR8qQQMcvBSQlDn24KpkCKEhVvfA==} + cpu: [arm64] + os: [linux] + libc: [musl] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-linux-x64-gnu@0.8.7': + resolution: {integrity: sha512-dzyAbltJmf3Cqlb8HcFuYIf5Yn0fl1vTr3XJ9HiVNNvOlhqPSArOqtw9vI1p6/VTXTjrMLXlU+s+/kNHiIy/Cw==} + cpu: [x64] + os: [linux] + libc: [glibc] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-linux-x64-musl@0.8.7': + resolution: {integrity: sha512-Otw4MH3404q0Bbvl+YTdW9aoUV5vXmUw8260bWvt1XlaoIX/ceSgI4ygheRDMfBPoHt6FDayQaO9OLVUZAgkFA==} + cpu: [x64] + os: [linux] + libc: [musl] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-win32-arm64@0.8.7': + resolution: {integrity: sha512-qo/jyrzryiBuKEsFiuWaBCBe3tRMynQ0qFWFgOEjcCMQeZfBm+wKiVEUEFXXLc7bh8YezguAWp0Mtnhq4ARNyA==} + cpu: [arm64] + os: [win32] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-codegen/binding-win32-x64@0.8.7': + resolution: {integrity: sha512-D5lDsVDx6m00E6bWySlWdH72Ca4TPSaphDqB6QjU6MpuNLIJqoGoatYyq2rOmBE8Zv/kunot/o58KGL03P3eiA==} + cpu: [x64] + os: [win32] + deprecated: yuku-codegen is pure JavaScript since 0.14 + + '@yuku-parser/binding-android-arm64@0.8.7': + resolution: {integrity: sha512-eGKYiUDX7Y0V7tDTmg+JTVnXnjMqfXXsorZ+EDf5kxwchQ3Or1HS14MzI2fw+jFhHR85fCWt+mtX33Yao73hIQ==} + cpu: [arm64] + os: [android] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-darwin-arm64@0.8.7': + resolution: {integrity: sha512-Re0RHelKLnjEURulY2/KxW+Ngb8zuNA4BRZuMwgGQNzVumT6u4U2N2hc01oeYVNVof0i7GrXE4UCNBgbpRRnjQ==} + cpu: [arm64] + os: [darwin] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-darwin-x64@0.8.7': + resolution: {integrity: sha512-Hn8DROtQkjlA1ACbPgj4a7eP9IuVOI504oiTwpkWPbpaDWD9KdmnVYCqW+1LfenNK/g7O9NhWGpXEdaCNX7lIA==} + cpu: [x64] + os: [darwin] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-freebsd-x64@0.8.7': + resolution: {integrity: sha512-bAP2OV8wRuzplX/jYxv9+vvqQT8JxyNphI8fLfXGL054Xs+4/J5u33cIm3y4rxY8rdoLmmdiJs2Tq7r7lrDRfA==} + cpu: [x64] + os: [freebsd] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-linux-arm-gnu@0.8.7': + resolution: {integrity: sha512-kTYwJQQgmZeAWdDIWabiReIZMpmfLueIj1tCmjStUtFGhR1Z0qwxonKVfUC4N7h/VhGGzLZ//7O1kgt1QKqgCg==} + cpu: [arm] + os: [linux] + libc: [glibc] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-linux-arm-musl@0.8.7': + resolution: {integrity: sha512-uL4jE8HPT2BLlxAXyD10LqgPuXa9eDa0BKpCdSANmzIJghq/2eZo3/gQNtaxPZMupWoxjYzSad9IXrwu7aYPXQ==} + cpu: [arm] + os: [linux] + libc: [musl] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-linux-arm64-gnu@0.8.7': + resolution: {integrity: sha512-3gVN4pWSKZmXiNX7cU164dR9MPvesCHnlH6nPfpK+yQsCuYphjKKplcb4SnZBrhiqmXbgb2HR0c2TS0IZUPhgA==} + cpu: [arm64] + os: [linux] + libc: [glibc] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-linux-arm64-musl@0.8.7': + resolution: {integrity: sha512-S0mwfEjoLpxzXeZw802Wa4RaELsQiPtWqG6INcy8j4GtvNFtl4LCX3eGO1XLn9pyLAISLzTRyU3zUCBUPin8lg==} + cpu: [arm64] + os: [linux] + libc: [musl] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-linux-x64-gnu@0.8.7': + resolution: {integrity: sha512-lnbWdPmerE5D1uH1G4IEZKnPzCrWCStRGrtgpSIe1RibAo5bZIjDbbbPYXmMHCEh4F+x/JaJpElh26a3r+BPbg==} + cpu: [x64] + os: [linux] + libc: [glibc] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-linux-x64-musl@0.8.7': + resolution: {integrity: sha512-769uwndMvMzUvATWbAcEvyLHKA+DzhHSCl/obBUrRdYfRo26yxui6S8y3z7uJ+Naup7UKrDxrpK7OnQkxkl9KQ==} + cpu: [x64] + os: [linux] + libc: [musl] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-win32-arm64@0.8.7': + resolution: {integrity: sha512-mEB/9PlaAkisJ6KWGz0zvywXoU6+80dTlR2LwS7s/jcXXoU6fm2+sitBZXtqu3+Q4DcDgPxM45uWMCzPs0TSRw==} + cpu: [arm64] + os: [win32] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-parser/binding-win32-x64@0.8.7': + resolution: {integrity: sha512-8vNB2DP0ou61nGb8tc/qfi41gfyDXz1MHr2zqL3nR+cJ6CEbiuWV/l/a/vv151gCgiZLLAyGkQGENpozdg716w==} + cpu: [x64] + os: [win32] + deprecated: yuku-parser runs on yuku-core since 0.14 + + '@yuku-toolchain/types@0.8.7': + resolution: {integrity: sha512-2Z53dNxAJL6UvFoIrDZvYf3zlO8s4VJK4O2hhaB4mXVwwpX/7ajtss3cmfqKvamlNLWyt9FSWs4eoYdlbxpnHA==} + '@zkochan/js-yaml@0.0.7': resolution: {integrity: sha512-nrUSn7hzt7J6JWgWGz78ZYI8wj+gdIJdk0Ynjpp8l+trkn58Uqsf6RYrYkEK+3X18EX+TNdtJI0WxAtc+L84SQ==} hasBin: true @@ -1712,8 +1973,8 @@ packages: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} - ansis@4.2.0: - resolution: {integrity: sha512-HqZ5rWlFjGiV0tDm3UxxgNRqsOTniqoKZu0pIAfh7TZQMGuZK+hH0drySty0si0QXj1ieop4+SkSfPZBPPkHig==} + ansis@4.5.0: + resolution: {integrity: sha512-KwIVkfFfJSSzBmZhDGuTmkhWqTdyB5oNVzzznBJbBZ5bZtHiqSrcugRF0RKJKT4Ss3d7ZrcjnlFVDlQNmtWfWw==} engines: {node: '>=14'} argparse@1.0.10: @@ -1734,10 +1995,6 @@ packages: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} - ast-kit@3.0.0-beta.1: - resolution: {integrity: sha512-trmleAnZ2PxN/loHWVhhx1qeOHSRXq4TDsBBxq3GqeJitfk3+jTQ+v/C1km/KYq9M7wKqCewMh+/NAvVH7m+bw==} - engines: {node: '>=20.19.0'} - asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} @@ -1766,9 +2023,6 @@ packages: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} - birpc@4.0.0: - resolution: {integrity: sha512-LShSxJP0KTmd101b6DRyGBj57LZxSDYWKitQNW/mi8GRMvZb078Uf9+pveax1DrVL89vm7mWe+TovdI/UDOuPw==} - bl@4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} @@ -2044,9 +2298,9 @@ packages: sqlite3: optional: true - dts-resolver@2.1.3: - resolution: {integrity: sha512-bihc7jPC90VrosXNzK0LTE2cuLP6jr0Ro8jk+kMugHReJVLIpHz/xadeq3MhuwyO4TD4OA3L1Q8pBBFRc08Tsw==} - engines: {node: '>=20.19.0'} + dts-resolver@3.0.0: + resolution: {integrity: sha512-1T1f+z+4tl9XD+m+0HBgWoL/nm0bOIffyWaUuUSBlFg/86IWvfx+wjNaO/ybU0AJzG9/Mi5hBUgGV6zCmWEN7Q==} + engines: {node: ^22.18.0 || >=24.0.0} peerDependencies: oxc-resolver: '>=11.0.0' peerDependenciesMeta: @@ -2065,8 +2319,8 @@ packages: emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - empathic@2.0.0: - resolution: {integrity: sha512-i6UzDscO/XfAcNYD75CfICkmfLedpyPDdozrLMmQc5ORaQcdMoc21OnlEylMIqI7U8eniKrPMxxtj8k0vhmJhA==} + empathic@2.1.0: + resolution: {integrity: sha512-AnfC1ATldl49/cvZdLPDjBfrRNwbDO05aibiOtzQu3qtlbJtomNLhF30HEtn/7iBz50dlMECqATo3fG0LrdEgw==} engines: {node: '>=14'} encoding-sniffer@0.2.1: @@ -2389,6 +2643,10 @@ packages: get-tsconfig@4.14.0: resolution: {integrity: sha512-yTb+8DXzDREzgvYmh6s9vHsSVCHeC0G3PI5bEXNBHtmshPnO+S5O7qgLEOn0I5QvMy6kpZN8K1NKGyilLb93wA==} + get-tsconfig@5.0.0-beta.5: + resolution: {integrity: sha512-/6gFNr0N04nob252sTQxyFLi3eKFRqIg1I87YcqAMT1i6SQrSF6KujUEQrtrjMV0H/eejTCltLdDSTEMzHbnsQ==} + engines: {node: '>=20.20.0'} + glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -2471,9 +2729,9 @@ packages: resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} engines: {node: '>= 4'} - import-without-cache@0.3.3: - resolution: {integrity: sha512-bDxwDdF04gm550DfZHgffvlX+9kUlcz32UD0AeBTmVPFiWkrexF2XVmiuFFbDhiFuP8fQkrkvI2KdSNPYWAXkQ==} - engines: {node: '>=20.19.0'} + import-without-cache@0.4.1: + resolution: {integrity: sha512-vXoV9PjKHEednCUu01e98TkImxy67e3BJXbTIOmIq4Hyzw3IAwYRcuPkfeTzJzwyyts4kjuA73x+pWJLc4f86A==} + engines: {node: ^22.18.0 || >=24.0.0} imurmurhash@0.1.4: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} @@ -2541,11 +2799,6 @@ packages: resolution: {integrity: sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==} hasBin: true - jsesc@3.1.0: - resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} - engines: {node: '>=6'} - hasBin: true - json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} @@ -2813,6 +3066,10 @@ packages: obug@2.1.1: resolution: {integrity: sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==} + obug@2.2.1: + resolution: {integrity: sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==} + engines: {node: '>=12.20.0'} + once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} @@ -2918,6 +3175,10 @@ packages: resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} engines: {node: '>=12'} + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + pify@4.0.1: resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} engines: {node: '>=6'} @@ -3008,20 +3269,20 @@ packages: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - rolldown-plugin-dts@0.23.2: - resolution: {integrity: sha512-PbSqLawLgZBGcOGT3yqWBGn4cX+wh2nt5FuBGdcMHyOhoukmjbhYAl8NT9sE4U38Cm9tqLOIQeOrvzeayM0DLQ==} - engines: {node: '>=20.19.0'} + rolldown-plugin-dts@0.27.14: + resolution: {integrity: sha512-ZvuDDwoIpRK9RPxDXratCpklFO9QZZWndf/sd0VBFb4LEj0jj07UcHK9OCh7V4XiFz2Z89ziyBC2K6tJiDjrbw==} + engines: {node: ^22.18.0 || >=24.11.0} peerDependencies: - '@ts-macro/tsc': ^0.3.6 - '@typescript/native-preview': '>=7.0.0-dev.20260325.1' - rolldown: ^1.0.0-rc.12 - typescript: ^5.0.0 || ^6.0.0 - vue-tsc: ~3.2.0 + '@typescript/native-preview': '*' + '@volar/typescript': ~2.4.0 + rolldown: ^1.0.0 + typescript: ^5.0.0 || ^6.0.0 || ~7.0.0 + vue-tsc: ~3.2.0 || ~3.3.0 peerDependenciesMeta: - '@ts-macro/tsc': - optional: true '@typescript/native-preview': optional: true + '@volar/typescript': + optional: true typescript: optional: true vue-tsc: @@ -3032,6 +3293,11 @@ packages: engines: {node: ^20.19.0 || >=22.12.0} hasBin: true + rolldown@1.2.19: + resolution: {integrity: sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + rosie-skills-darwin-arm64@0.6.4: resolution: {integrity: sha512-rn1s5hqFKcxeiDEWWoFa1hdGPshR8TkwHLzy/cBavb9XJNAaUxbe3oQ78W9sQkRHAgRyzJYyk9tw68Qrdnizgg==} cpu: [arm64] @@ -3229,14 +3495,18 @@ packages: resolution: {integrity: sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==} engines: {node: '>=18'} - tinyexec@1.1.1: - resolution: {integrity: sha512-VKS/ZaQhhkKFMANmAOhhXVoIfBXblQxGX1myCQ2faQrfmobMftXeJPcZGp0gS07ocvGJWDLZGyOZDadDBqYIJg==} + tinyexec@1.3.1: + resolution: {integrity: sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==} engines: {node: '>=18'} tinyglobby@0.2.16: resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==} engines: {node: '>=12.0.0'} + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + tinyrainbow@3.1.0: resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==} engines: {node: '>=14.0.0'} @@ -3271,18 +3541,20 @@ packages: resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} engines: {node: '>=6'} - tsdown@0.21.10: - resolution: {integrity: sha512-3wk73yBhZe/wX7REqSdivNQ84TDs1mJ+IlnzrrEREP70xlJ/AEIzqaI04l/TzMKVIdkTdC3CPaADn2Lk/0SkdA==} - engines: {node: '>=20.19.0'} + tsdown@0.22.14: + resolution: {integrity: sha512-ule7Y+fsAN2iZbLDoo7C4KYljFJNJJ+fLshyn+9gozeTspVersWHxwdGB+Dm2hzA38s6muFnUTl0jK3vJm9ifQ==} + engines: {node: ^22.18.0 || >=24.11.0} hasBin: true peerDependencies: '@arethetypeswrong/core': ^0.18.1 - '@tsdown/css': 0.21.10 - '@tsdown/exe': 0.21.10 + '@tsdown/css': 0.22.14 + '@tsdown/exe': 0.22.14 '@vitejs/devtools': '*' - publint: ^0.3.0 - typescript: ^5.0.0 || ^6.0.0 + publint: ^0.3.8 + tsx: '*' + typescript: ^5.0.0 || ^6.0.0 || ^7.0.0 unplugin-unused: ^0.5.0 + unrun: '*' peerDependenciesMeta: '@arethetypeswrong/core': optional: true @@ -3294,10 +3566,14 @@ packages: optional: true publint: optional: true + tsx: + optional: true typescript: optional: true unplugin-unused: optional: true + unrun: + optional: true tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} @@ -3383,6 +3659,10 @@ packages: util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + verkit@0.3.2: + resolution: {integrity: sha512-zj/ob3UsvJGN0whEAKFp53REA5X66hvffVqoCtVQAakJKnKlH+/PcOfMoFwIG/o4rElqLv/ycAFlx8ZlXUorCg==} + engines: {node: '>=18.12.0'} + vite@8.0.10: resolution: {integrity: sha512-rZuUu9j6J5uotLDs+cAA4O5H4K1SfPliUlQwqa6YEwSrWDZzP4rhm00oJR5snMewjxF5V/K3D4kctsUTsIU9Mw==} engines: {node: ^20.19.0 || >=22.12.0} @@ -3591,6 +3871,15 @@ packages: youch@4.1.0-beta.10: resolution: {integrity: sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==} + yuku-ast@0.8.7: + resolution: {integrity: sha512-h6+4bDfyootiMB9vckk5uKo5r5j0GHrkr17FQTDNfEsFT3DWlN9uu1HJwQwc64pgmLCI945fWM3lbTIqxjT3GQ==} + + yuku-codegen@0.8.7: + resolution: {integrity: sha512-adwDZSh8oVDzhE6Du9PwVWxcOxeV0e2EVhUuMKWfhSY4wkrDq9eqixlxFF3l/XGUV1E7UFzhpz9393MUumkyNw==} + + yuku-parser@0.8.7: + resolution: {integrity: sha512-vRD9nwt4L3aYpxNqeSC4WqLv58xrXef0Ong1Mc45CTXTIpvLafx7JO05sczmQZwdLEZvywrLOGdNC5+Rp5N1BQ==} + zimmerframe@1.1.4: resolution: {integrity: sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==} @@ -3599,30 +3888,8 @@ packages: snapshots: - '@babel/generator@8.0.0-rc.3': - dependencies: - '@babel/parser': 8.0.0-rc.3 - '@babel/types': 8.0.0-rc.3 - '@jridgewell/gen-mapping': 0.3.13 - '@jridgewell/trace-mapping': 0.3.31 - '@types/jsesc': 2.5.1 - jsesc: 3.1.0 - - '@babel/helper-string-parser@8.0.0-rc.3': {} - - '@babel/helper-validator-identifier@8.0.0-rc.3': {} - - '@babel/parser@8.0.0-rc.3': - dependencies: - '@babel/types': 8.0.0-rc.3 - '@babel/runtime@7.28.6': {} - '@babel/types@8.0.0-rc.3': - dependencies: - '@babel/helper-string-parser': 8.0.0-rc.3 - '@babel/helper-validator-identifier': 8.0.0-rc.3 - '@changesets/apply-release-plan@7.1.1': dependencies: '@changesets/config': 3.1.4 @@ -3834,6 +4101,12 @@ snapshots: tslib: 2.8.1 optional: true + '@emnapi/core@2.0.0-beta.2': + dependencies: + '@emnapi/wasi-threads': 2.2.0 + tslib: 2.8.1 + optional: true + '@emnapi/runtime@1.10.0': dependencies: tslib: 2.8.1 @@ -3852,6 +4125,11 @@ snapshots: tslib: 2.8.1 optional: true + '@emnapi/runtime@2.0.0-beta.2': + dependencies: + tslib: 2.8.1 + optional: true + '@emnapi/wasi-threads@1.0.4': dependencies: tslib: 2.8.1 @@ -3865,6 +4143,11 @@ snapshots: tslib: 2.8.1 optional: true + '@emnapi/wasi-threads@2.2.0': + dependencies: + tslib: 2.8.1 + optional: true + '@esbuild/aix-ppc64@0.27.3': optional: true @@ -4261,6 +4544,13 @@ snapshots: '@tybys/wasm-util': 0.10.1 optional: true + '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@tybys/wasm-util': 0.10.4 + optional: true + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -4371,6 +4661,8 @@ snapshots: '@oxc-project/types@0.127.0': {} + '@oxc-project/types@0.156.0': {} + '@oxc-resolver/binding-android-arm-eabi@11.19.1': optional: true @@ -4451,42 +4743,81 @@ snapshots: dependencies: quansync: 1.0.0 + '@rolldown/binding-android-arm-eabi@1.2.19': + optional: true + '@rolldown/binding-android-arm64@1.0.0-rc.17': optional: true + '@rolldown/binding-android-arm64@1.2.19': + optional: true + '@rolldown/binding-darwin-arm64@1.0.0-rc.17': optional: true + '@rolldown/binding-darwin-arm64@1.2.19': + optional: true + '@rolldown/binding-darwin-x64@1.0.0-rc.17': optional: true + '@rolldown/binding-darwin-x64@1.2.19': + optional: true + '@rolldown/binding-freebsd-x64@1.0.0-rc.17': optional: true + '@rolldown/binding-freebsd-x64@1.2.19': + optional: true + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.17': optional: true + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + optional: true + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.17': optional: true + '@rolldown/binding-linux-arm64-gnu@1.2.19': + optional: true + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.17': optional: true + '@rolldown/binding-linux-arm64-musl@1.2.19': + optional: true + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.17': optional: true + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + optional: true + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.17': optional: true + '@rolldown/binding-linux-s390x-gnu@1.2.19': + optional: true + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.17': optional: true + '@rolldown/binding-linux-x64-gnu@1.2.19': + optional: true + '@rolldown/binding-linux-x64-musl@1.0.0-rc.17': optional: true + '@rolldown/binding-linux-x64-musl@1.2.19': + optional: true + '@rolldown/binding-openharmony-arm64@1.0.0-rc.17': optional: true + '@rolldown/binding-openharmony-arm64@1.2.19': + optional: true + '@rolldown/binding-wasm32-wasi@1.0.0-rc.17': dependencies: '@emnapi/core': 1.10.0 @@ -4494,14 +4825,29 @@ snapshots: '@napi-rs/wasm-runtime': 1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) optional: true + '@rolldown/binding-wasm32-wasi@1.2.19': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2) + optional: true + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.17': optional: true + '@rolldown/binding-win32-arm64-msvc@1.2.19': + optional: true + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.17': optional: true + '@rolldown/binding-win32-x64-msvc@1.2.19': + optional: true + '@rolldown/pluginutils@1.0.0-rc.17': {} + '@rolldown/pluginutils@1.1.0': {} + '@shikijs/engine-oniguruma@3.21.0': dependencies: '@shikijs/types': 3.21.0 @@ -4587,6 +4933,11 @@ snapshots: tslib: 2.8.1 optional: true + '@tybys/wasm-util@0.10.4': + dependencies: + tslib: 2.8.1 + optional: true + '@tybys/wasm-util@0.9.0': dependencies: tslib: 2.8.1 @@ -4606,8 +4957,6 @@ snapshots: dependencies: '@types/unist': 3.0.3 - '@types/jsesc@2.5.1': {} - '@types/json-schema@7.0.15': {} '@types/node@12.20.55': {} @@ -4819,6 +5168,80 @@ snapshots: '@yarnpkg/lockfile@1.1.0': {} + '@yuku-codegen/binding-android-arm64@0.8.7': + optional: true + + '@yuku-codegen/binding-darwin-arm64@0.8.7': + optional: true + + '@yuku-codegen/binding-darwin-x64@0.8.7': + optional: true + + '@yuku-codegen/binding-freebsd-x64@0.8.7': + optional: true + + '@yuku-codegen/binding-linux-arm-gnu@0.8.7': + optional: true + + '@yuku-codegen/binding-linux-arm-musl@0.8.7': + optional: true + + '@yuku-codegen/binding-linux-arm64-gnu@0.8.7': + optional: true + + '@yuku-codegen/binding-linux-arm64-musl@0.8.7': + optional: true + + '@yuku-codegen/binding-linux-x64-gnu@0.8.7': + optional: true + + '@yuku-codegen/binding-linux-x64-musl@0.8.7': + optional: true + + '@yuku-codegen/binding-win32-arm64@0.8.7': + optional: true + + '@yuku-codegen/binding-win32-x64@0.8.7': + optional: true + + '@yuku-parser/binding-android-arm64@0.8.7': + optional: true + + '@yuku-parser/binding-darwin-arm64@0.8.7': + optional: true + + '@yuku-parser/binding-darwin-x64@0.8.7': + optional: true + + '@yuku-parser/binding-freebsd-x64@0.8.7': + optional: true + + '@yuku-parser/binding-linux-arm-gnu@0.8.7': + optional: true + + '@yuku-parser/binding-linux-arm-musl@0.8.7': + optional: true + + '@yuku-parser/binding-linux-arm64-gnu@0.8.7': + optional: true + + '@yuku-parser/binding-linux-arm64-musl@0.8.7': + optional: true + + '@yuku-parser/binding-linux-x64-gnu@0.8.7': + optional: true + + '@yuku-parser/binding-linux-x64-musl@0.8.7': + optional: true + + '@yuku-parser/binding-win32-arm64@0.8.7': + optional: true + + '@yuku-parser/binding-win32-x64@0.8.7': + optional: true + + '@yuku-toolchain/types@0.8.7': {} + '@zkochan/js-yaml@0.0.7': dependencies: argparse: 2.0.1 @@ -4850,7 +5273,7 @@ snapshots: dependencies: color-convert: 2.0.1 - ansis@4.2.0: {} + ansis@4.5.0: {} argparse@1.0.10: dependencies: @@ -4864,12 +5287,6 @@ snapshots: assertion-error@2.0.1: {} - ast-kit@3.0.0-beta.1: - dependencies: - '@babel/parser': 8.0.0-rc.3 - estree-walker: 3.0.3 - pathe: 2.0.3 - asynckit@0.4.0: {} axios@1.15.0: @@ -4894,8 +5311,6 @@ snapshots: dependencies: is-windows: 1.0.2 - birpc@4.0.0: {} - bl@4.1.0: dependencies: buffer: 5.7.1 @@ -5078,7 +5493,7 @@ snapshots: '@electric-sql/pglite': 0.3.16 '@opentelemetry/api': 1.9.1 - dts-resolver@2.1.3(oxc-resolver@11.19.1): + dts-resolver@3.0.0(oxc-resolver@11.19.1): optionalDependencies: oxc-resolver: 11.19.1 @@ -5092,7 +5507,7 @@ snapshots: emoji-regex@8.0.0: {} - empathic@2.0.0: {} + empathic@2.1.0: {} encoding-sniffer@0.2.1: dependencies: @@ -5392,6 +5807,10 @@ snapshots: optionalDependencies: picomatch: 4.0.4 + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + figures@3.2.0: dependencies: escape-string-regexp: 1.0.5 @@ -5484,6 +5903,10 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 + get-tsconfig@5.0.0-beta.5: + dependencies: + resolve-pkg-maps: 1.0.0 + glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -5564,7 +5987,7 @@ snapshots: ignore@7.0.5: {} - import-without-cache@0.3.3: {} + import-without-cache@0.4.1: {} imurmurhash@0.1.4: {} @@ -5613,8 +6036,6 @@ snapshots: dependencies: argparse: 2.0.1 - jsesc@3.1.0: {} - json-buffer@3.0.1: {} json-schema-traverse@0.4.1: {} @@ -5958,6 +6379,8 @@ snapshots: obug@2.1.1: {} + obug@2.2.1: {} + once@1.4.0: dependencies: wrappy: 1.0.2 @@ -6103,6 +6526,8 @@ snapshots: picomatch@4.0.4: {} + picomatch@4.0.7: {} + pify@4.0.1: {} postcss@8.5.10: @@ -6171,19 +6596,15 @@ snapshots: reusify@1.1.0: {} - rolldown-plugin-dts@0.23.2(oxc-resolver@11.19.1)(rolldown@1.0.0-rc.17)(typescript@6.0.3): + rolldown-plugin-dts@0.27.14(oxc-resolver@11.19.1)(rolldown@1.2.19)(typescript@6.0.3): dependencies: - '@babel/generator': 8.0.0-rc.3 - '@babel/helper-validator-identifier': 8.0.0-rc.3 - '@babel/parser': 8.0.0-rc.3 - '@babel/types': 8.0.0-rc.3 - ast-kit: 3.0.0-beta.1 - birpc: 4.0.0 - dts-resolver: 2.1.3(oxc-resolver@11.19.1) - get-tsconfig: 4.14.0 - obug: 2.1.1 - picomatch: 4.0.4 - rolldown: 1.0.0-rc.17 + dts-resolver: 3.0.0(oxc-resolver@11.19.1) + get-tsconfig: 5.0.0-beta.5 + obug: 2.2.1 + rolldown: 1.2.19 + yuku-ast: 0.8.7 + yuku-codegen: 0.8.7 + yuku-parser: 0.8.7 optionalDependencies: typescript: 6.0.3 transitivePeerDependencies: @@ -6210,6 +6631,28 @@ snapshots: '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.17 '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.17 + rolldown@1.2.19: + dependencies: + '@oxc-project/types': 0.156.0 + '@rolldown/pluginutils': 1.1.0 + optionalDependencies: + '@rolldown/binding-android-arm-eabi': 1.2.19 + '@rolldown/binding-android-arm64': 1.2.19 + '@rolldown/binding-darwin-arm64': 1.2.19 + '@rolldown/binding-darwin-x64': 1.2.19 + '@rolldown/binding-freebsd-x64': 1.2.19 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.19 + '@rolldown/binding-linux-arm64-gnu': 1.2.19 + '@rolldown/binding-linux-arm64-musl': 1.2.19 + '@rolldown/binding-linux-ppc64-gnu': 1.2.19 + '@rolldown/binding-linux-s390x-gnu': 1.2.19 + '@rolldown/binding-linux-x64-gnu': 1.2.19 + '@rolldown/binding-linux-x64-musl': 1.2.19 + '@rolldown/binding-openharmony-arm64': 1.2.19 + '@rolldown/binding-wasm32-wasi': 1.2.19 + '@rolldown/binding-win32-arm64-msvc': 1.2.19 + '@rolldown/binding-win32-x64-msvc': 1.2.19 + rosie-skills-darwin-arm64@0.6.4: optional: true @@ -6406,13 +6849,18 @@ snapshots: tinyexec@1.0.2: {} - tinyexec@1.1.1: {} + tinyexec@1.3.1: {} tinyglobby@0.2.16: dependencies: fdir: 6.5.0(picomatch@4.0.4) picomatch: 4.0.4 + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + tinyrainbow@3.1.0: {} tmp@0.2.4: {} @@ -6440,32 +6888,31 @@ snapshots: minimist: 1.2.8 strip-bom: 3.0.0 - tsdown@0.21.10(oxc-resolver@11.19.1)(publint@0.3.18)(typescript@6.0.3): + tsdown@0.22.14(oxc-resolver@11.19.1)(publint@0.3.18)(typescript@6.0.3)(unrun@0.2.37): dependencies: - ansis: 4.2.0 + ansis: 4.5.0 cac: 7.0.0 defu: 6.1.7 - empathic: 2.0.0 + empathic: 2.1.0 hookable: 6.1.1 - import-without-cache: 0.3.3 - obug: 2.1.1 - picomatch: 4.0.4 - rolldown: 1.0.0-rc.17 - rolldown-plugin-dts: 0.23.2(oxc-resolver@11.19.1)(rolldown@1.0.0-rc.17)(typescript@6.0.3) - semver: 7.7.4 - tinyexec: 1.1.1 - tinyglobby: 0.2.16 + import-without-cache: 0.4.1 + obug: 2.2.1 + picomatch: 4.0.7 + rolldown: 1.2.19 + rolldown-plugin-dts: 0.27.14(oxc-resolver@11.19.1)(rolldown@1.2.19)(typescript@6.0.3) + tinyexec: 1.3.1 + tinyglobby: 0.2.17 tree-kill: 1.2.2 unconfig-core: 7.5.0 - unrun: 0.2.37 + verkit: 0.3.2 optionalDependencies: publint: 0.3.18 typescript: 6.0.3 + unrun: 0.2.37 transitivePeerDependencies: - - '@ts-macro/tsc' - '@typescript/native-preview' + - '@volar/typescript' - oxc-resolver - - synckit - vue-tsc tslib@2.8.1: {} @@ -6553,6 +7000,7 @@ snapshots: unrun@0.2.37: dependencies: rolldown: 1.0.0-rc.17 + optional: true uri-js@4.4.1: dependencies: @@ -6560,6 +7008,8 @@ snapshots: util-deprecate@1.0.2: {} + verkit@0.3.2: {} + vite@8.0.10(@types/node@25.6.0)(esbuild@0.28.0)(jiti@2.6.1)(yaml@2.8.2): dependencies: lightningcss: 1.32.0 @@ -6718,6 +7168,45 @@ snapshots: cookie: 1.1.1 youch-core: 0.3.3 + yuku-ast@0.8.7: + dependencies: + '@yuku-toolchain/types': 0.8.7 + + yuku-codegen@0.8.7: + dependencies: + '@yuku-toolchain/types': 0.8.7 + optionalDependencies: + '@yuku-codegen/binding-android-arm64': 0.8.7 + '@yuku-codegen/binding-darwin-arm64': 0.8.7 + '@yuku-codegen/binding-darwin-x64': 0.8.7 + '@yuku-codegen/binding-freebsd-x64': 0.8.7 + '@yuku-codegen/binding-linux-arm-gnu': 0.8.7 + '@yuku-codegen/binding-linux-arm-musl': 0.8.7 + '@yuku-codegen/binding-linux-arm64-gnu': 0.8.7 + '@yuku-codegen/binding-linux-arm64-musl': 0.8.7 + '@yuku-codegen/binding-linux-x64-gnu': 0.8.7 + '@yuku-codegen/binding-linux-x64-musl': 0.8.7 + '@yuku-codegen/binding-win32-arm64': 0.8.7 + '@yuku-codegen/binding-win32-x64': 0.8.7 + + yuku-parser@0.8.7: + dependencies: + '@yuku-toolchain/types': 0.8.7 + yuku-ast: 0.8.7 + optionalDependencies: + '@yuku-parser/binding-android-arm64': 0.8.7 + '@yuku-parser/binding-darwin-arm64': 0.8.7 + '@yuku-parser/binding-darwin-x64': 0.8.7 + '@yuku-parser/binding-freebsd-x64': 0.8.7 + '@yuku-parser/binding-linux-arm-gnu': 0.8.7 + '@yuku-parser/binding-linux-arm-musl': 0.8.7 + '@yuku-parser/binding-linux-arm64-gnu': 0.8.7 + '@yuku-parser/binding-linux-arm64-musl': 0.8.7 + '@yuku-parser/binding-linux-x64-gnu': 0.8.7 + '@yuku-parser/binding-linux-x64-musl': 0.8.7 + '@yuku-parser/binding-win32-arm64': 0.8.7 + '@yuku-parser/binding-win32-x64': 0.8.7 + zimmerframe@1.1.4: {} zod@4.3.6: {}