Skip to article

Durable operation reference

Checkpoint states, storage requirements, and reconciliation errors for resumable remote work.

On this page

Options

FieldContract
keyCheckpoint key, 1–200 letters/digits/underscore/dot/colon/hyphen.
operationStatic operation identity, 1–128 allowed identifier characters.
inputFingerprintCaller-owned opaque input/account binding; never a credential.
storeCheckpointStore with load and atomic compareAndSet.
submit({ signal })One explicit submission returning { remoteId }.
poll(remoteId, { signal })Read-only status; pending, completed with value, or failed.
timeoutMs, pollIntervalMs, maxPollsPositive integer invocation limits; 30,000 / 1,000 / 100 defaults.
signalOptional caller cancellation.

Checkpoint states

  • submitting: intent persisted; an unknown outcome requires reconciliation.
  • submitted: saved remote ID; safe to resume read-only polling.
  • completed: JSON result stored and returned on resume.
  • failed: remote failure retained; no automatic resubmission.

A checkpoint has version 1, a monotonically advancing revision, operation/input binding, and an updatedAt timestamp. Remote IDs are present after submission. Results are present only when completed.

Explicit remote-ID reconciliation

Import attachDurableRemoteId from @belweave/search-sdk/durable. Supply store, key, operation, inputFingerprint, and a verified remoteId. The helper accepts only a matching submitting checkpoint, atomically advances its revision to submitted, and returns that checkpoint. Missing, mismatched, or concurrently changed state returns checkpoint_conflict.

DurableOperationError

CodeAction
configurationCorrect invalid options, identifiers, or checkpoint values.
storage_failureReconcile persisted state before continuing.
checkpoint_conflictAnother writer or a different input binding owns the checkpoint.
ambiguous_submissionRemote work may exist; do not automatically submit again.
poll_failedRead failed; resume using the saved remote identifier.
remote_failedProvider reported a terminal failure.
poll_limitResume the saved job in a later bounded invocation.
aborted, timeoutPersisted state remains; these do not cancel the remote job.

A remoteId can be exposed on the durable error when submission returned an ID but checkpoint persistence failed. Preserve it for reconciliation. Error messages omit raw storage and provider error details.