Dispatch durable FIFO work and recover uncertainty
Use stable deduplication, claim/start/ack transitions and deliberate recovery around external actions.
ONF's durable queue stores business work inside a workspace namespace. It does not execute an agent or provider call by itself. A workflow claims work, records the start, performs the chosen external action, then acknowledges or reports failure.
Identity and FIFO#
Create the owning conversation first. Enqueue with its conversationKey, a stable dedupKey and JSON payload. Deduplication is namespace-scoped: reusing a key for a different payload/conversation conflicts instead of silently creating another task.
FIFO is per conversation. An unavailable, failed or uncertain head blocks later items in that conversation. Other conversations can progress independently. Do not change keys simply to bypass a blocked head; that discards the relationship needed to reconcile an uncertain action.
Claim, start and finish#
- Claim the conversation head and retain the returned key, current version and lease token inside running code.
- Await
queue.startwith those exact guards immediately before the external action. - Use the returned new version for the next transition.
- Perform the explicitly intended provider/model action.
- Acknowledge with the current version/token and optional result, or fail with precise retryable/known-safe information.
Reads and lists omit lease credentials. A successful claim returns its new token; do not log or persist it in public context. Every transition validates current version and ownership. A stale version or expired token conflicts.
Uncertain is a real state#
Every expired lease becomes uncertain, including a claim that never recorded start. A process may have crossed an external-effects boundary even when no final response was saved. Restart, timeout or cancellation does not prove the provider did nothing.
Failed/uncertain heads require explicit recovery with a reason. Inspect the retained run, recorded transitions and external system before choosing retry, complete or discard. Only a specifically known-safe failure before external start can schedule a bounded retry.
Completion/discard is terminal. A recovery decision is an operator action with its own current-version guard, not an automatic redelivery loop. Use provider idempotency keys derived from stable business identity when supported; a new ONF run ID alone cannot deduplicate a manually repeated business action.
Useful bounds#
Queue payloads are limited to 1 MiB. Maximum attempts is between 1 and 20. Lease durations are 1,000–300,000 ms. Choose a lease appropriate to the operation's explicit bound, and reconcile uncertainty instead of assuming a longer lease creates exactly-once delivery.
List/filter states include queued, leased, running, completed, failed, uncertain and discarded. Storage's metadata-first view supports deliberate inspection. Run storage history records transitions attributed to the executing node/attempt without exposing lease credentials.
Pruning and clearing#
Prune can remove eligible terminal payload/result/error bodies while keeping deduplication tombstones. Failed/uncertain heads remain. A missing pruned body is different from a key that never existed.
Clearing a namespace deliberately removes data and history and is blocked by active leases. Keep it for explicitly disposable scopes, not production recovery. Read storage and backup/restore before changing retained queue state.
Source provenance
Reviewed against maintained source and topic documentation on 23 October 2026. This is a source snapshot; installed versions and provider access may differ.
docs/STORAGE.mddocs/AUTHORING.md