/** * Error codes for classifying run failures. * These are populated in the `errorCode` field of `run_failed` events * and flow through to `StructuredError.code` on the run entity. */ export const RUN_ERROR_CODES = { /** Error thrown in user workflow or step code */ USER_ERROR: 'USER_ERROR', /** Internal runtime error (missing timestamps, runtime invariant failures) */ RUNTIME_ERROR: 'RUNTIME_ERROR', /** Event log contains orphaned or mismatched events and cannot be replayed */ CORRUPTED_EVENT_LOG: 'CORRUPTED_EVENT_LOG', /** One replay could not consume the event log deterministically; retryable */ REPLAY_DIVERGENCE: 'REPLAY_DIVERGENCE', /** Run exceeded the maximum number of queue deliveries */ MAX_DELIVERIES_EXCEEDED: 'MAX_DELIVERIES_EXCEEDED', /** Run exceeded the maximum number of events per run */ MAX_EVENTS_EXCEEDED: 'MAX_EVENTS_EXCEEDED', /** Workflow replay exceeded the maximum allowed duration */ REPLAY_TIMEOUT: 'REPLAY_TIMEOUT', /** Workflow stream infrastructure failed while reading or writing data */ STREAM_ERROR: 'STREAM_ERROR', /** World response violated the SDK contract and cannot be retried safely */ WORLD_CONTRACT_ERROR: 'WORLD_CONTRACT_ERROR', /** Run was delivered to a deployment other than the one it is pinned to */ DEPLOYMENT_MISMATCH: 'DEPLOYMENT_MISMATCH', /** * The run's workflow is not registered in the deployment executing it * (`WorkflowNotRegisteredError`), e.g. a run started with a workflowId the * deployment does not bundle, or a workflow dropped by the build */ WORKFLOW_NOT_REGISTERED: 'WORKFLOW_NOT_REGISTERED', } as const; export type RunErrorCode = (typeof RUN_ERROR_CODES)[keyof typeof RUN_ERROR_CODES];