• Enables safe code changes to running workflows by branching on a named change marker. On first execution of a new workflow, patched records the marker and returns true — the workflow takes the new code path. On replay of a workflow that was started before the patch existed, no marker is found and patched returns false — the old code path is followed.

    Markers are accumulated in the workflow context and written to the job hash by the engine (via the YAML schema's job.maps) when the worker responds — no direct hash writes from the worker.

    patched does not increment the execution counter, so it can be inserted into existing workflow code without shifting the replay positions of other durable operations.

    1. Add the patch: wrap the new behavior with if (await patched('id')). Keep the old behavior in the else branch.
    2. Wait for drain: once all workflows started before the patch have completed, the else branch is dead code.
    3. Deprecate: replace patched with deprecatePatch and remove the else branch.
    4. Clean up: remove both deprecatePatch and the if wrapper, leaving only the new code.
    import { Durable } from '@hotmeshio/hotmesh';

    export async function orderWorkflow(orderId: string): Promise<string> {
    const acts = Durable.workflow.proxyActivities<typeof activities>({
    activities,
    retry: { maximumAttempts: 3 },
    });

    if (await Durable.workflow.patched('v2-validation')) {
    // New path: stricter validation
    await acts.validateOrderV2(orderId);
    } else {
    // Old path: legacy validation (for in-flight workflows)
    await acts.validateOrder(orderId);
    }

    return await acts.processOrder(orderId);
    }

    Parameters

    • changeId: string

      A unique, stable identifier for this code change. Must not be reused across different changes.

    Returns Promise<boolean>

    true for new workflows (take new path), false for pre-patch workflows being replayed (take old path).