Skip to main content

TaskEnvelope

Struct TaskEnvelope 

Source
pub struct TaskEnvelope {
    pub format_version: u32,
    pub task_id: String,
    pub parent: Option<String>,
    pub sender: String,
    pub recipient: String,
    pub worker_version: Option<String>,
    pub input: PayloadRef,
    pub output_contract: Option<ArtifactContract>,
    pub deadline: Option<DateTime<Utc>>,
    pub budget: Option<TaskBudget>,
    pub idempotency_key: Option<String>,
    pub effect: Effect,
}
Expand description

The unit of durable work: one task handed from a sender to a recipient through the queue.

The envelope is everything the scheduler and the recipient need and nothing they don’t — the input travels as a PayloadRef (inline for small values, content-addressed above the inline threshold), so the queue row stays cheap to scan and the envelope composes with the Flight Recorder’s artifact addressing.

Every field after format_version that was added after v1 carries a serde default, so envelopes queued by an older client keep deserializing; the default Effect is the conservative NonIdempotent, meaning an undeclared task is never silently retried.

Fields§

§format_version: u32

Envelope format version; TASK_ENVELOPE_FORMAT_VERSION for anything written now.

§task_id: String

Unique task id, assigned by the sender. Server-side ids are tenant-namespaced like every other id ({tenant}/…); the envelope itself is namespace-agnostic.

§parent: Option<String>

The causal parent: the run event or task that created this one ({run_id}:{seq} or a task id). Task lineage composes with the journal’s causal chain, so a fan-out of durable tasks is one connected evidence tree. None for root tasks.

§sender: String

Who submitted the task — a run id, a node name, or an agent identity. Used for attribution, quotas, and cancellation scoping.

§recipient: String

Who executes the task: a worker pool name (the queue routes by pool) or a specific worker identity for pinned placement.

§worker_version: Option<String>

Version pin (R0.6 wave 3): the exact worker version string this task may be dispatched to. A run started against worker version w1 stamps its tasks with w1, so a mid-run deploy never changes semantics under an in-flight execution — the scheduler keeps handing the task to w1-advertising workers until it finishes.

The pin is an exact string match, deliberately: semver range matching (^1.4) makes a claim’s outcome depend on the version grammar’s rules rather than on what the run actually recorded, and range resolution belongs to the scheduler’s policy, not to a frozen wire contract. Ranges are documented future work; None (the default) means unpinned — any worker may claim the task.

§input: PayloadRef

The task input, inline or content-addressed. Small inputs travel inside the queue row; large ones are artifacts the recipient resolves through the journal’s artifact map.

§output_contract: Option<ArtifactContract>

What the task is expected to produce. None means the result is an unconstrained JSON value (the common case for node executions).

§deadline: Option<DateTime<Utc>>

Wall-clock deadline for the whole task, across all attempts. The scheduler does not re-queue a task whose deadline has passed; the worker treats an expired deadline as ErrorClass::Cancelled.

§budget: Option<TaskBudget>

Attempt and timeout budget. None means the queue’s defaults.

§idempotency_key: Option<String>

The deduplication key for effectively-once execution: the queue refuses a duplicate submission with an existing key, and the recipient passes it to the effect it performs. Required for any task whose effect is Effect::Idempotent — the key is what the idempotency declaration means at the wire. None is honest only for Pure / ReadOnly work.

§effect: Effect

The declared effect classification of the work this task performs — the same taxonomy the Flight Recorder journals. Defaults to the conservative NonIdempotent, so a task that does not declare its effect is never silently retried; declaring Idempotent (with an idempotency key) is what unlocks automatic retry.

Implementations§

Source§

impl TaskEnvelope

Source

pub fn new( task_id: impl Into<String>, sender: impl Into<String>, recipient: impl Into<String>, input: PayloadRef, ) -> Self

A minimal envelope: sender, recipient, and input, with every optional field unset and the effect conservatively Effect::NonIdempotent. Set the optional fields directly; they are public.

Trait Implementations§

Source§

impl Clone for TaskEnvelope

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TaskEnvelope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TaskEnvelope

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TaskEnvelope

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for TaskEnvelope

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TaskEnvelope

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more