pub struct Task {Show 17 fields
pub id: TaskId,
pub run_id: RunId,
pub task_key: String,
pub description: String,
pub state: TaskState,
pub command_class: CommandClass,
pub depends_on: Vec<TaskId>,
pub evidence_ids: Vec<Uuid>,
pub attempt_no: u32,
pub max_attempts: u32,
pub blocker: Option<BlockerCode>,
pub last_error: Option<String>,
pub blocker_detail: Option<String>,
pub correlation_id: CorrelationId,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub priority: u32,
}Expand description
A task within a run.
Fields§
§id: TaskIdUnique task identifier (UUIDv7 for time-ordering).
run_id: RunIdThe run this task belongs to.
task_key: StringHuman-readable key for deduplication (unique per run).
description: StringDescription of what this task should accomplish.
state: TaskStateCurrent FSM state.
command_class: CommandClassCommand class for concurrency caps.
depends_on: Vec<TaskId>Tasks this task depends on (must be TaskComplete before this can run).
evidence_ids: Vec<Uuid>Evidence IDs attached to this task.
attempt_no: u32Current attempt number (starts at 1, incremented on retry).
max_attempts: u32Maximum allowed attempts before permanent failure.
blocker: Option<BlockerCode>Blocker code when in TaskBlocked state.
last_error: Option<String>Root-cause error message preserved across state changes. Set on first failure; not overwritten by subsequent kills or timeouts.
blocker_detail: Option<String>Free-form annotation for blocker context (e.g. “see blocker-001.md”).
Set by external agents or the task annotate CLI command.
correlation_id: CorrelationIdCorrelation ID (inherited from parent run).
created_at: DateTime<Utc>When the task was created.
updated_at: DateTime<Utc>When the task last changed state.
priority: u32Priority for queue ordering (0-100, higher is more urgent).
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(
run_id: RunId,
task_key: impl Into<String>,
description: impl Into<String>,
command_class: CommandClass,
correlation_id: CorrelationId,
) -> Self
pub fn new( run_id: RunId, task_key: impl Into<String>, description: impl Into<String>, command_class: CommandClass, correlation_id: CorrelationId, ) -> Self
Create a new task in TaskOpen state.
Sourcepub fn depends_on(&mut self, task_id: TaskId)
pub fn depends_on(&mut self, task_id: TaskId)
Add a dependency on another task.
Sourcepub fn with_priority(self, priority: u32) -> Self
pub fn with_priority(self, priority: u32) -> Self
Set the task priority (0-100, higher is more urgent).
Sourcepub fn with_max_attempts(self, max: u32) -> Self
pub fn with_max_attempts(self, max: u32) -> Self
Set the maximum number of attempts.
Sourcepub fn set_last_error(&mut self, error: impl Into<String>)
pub fn set_last_error(&mut self, error: impl Into<String>)
Set the root-cause error message. Only sets if not already populated, preserving the original failure reason across subsequent state changes.
Sourcepub fn set_blocker_detail(&mut self, detail: impl Into<String>)
pub fn set_blocker_detail(&mut self, detail: impl Into<String>)
Set the blocker detail annotation.
Sourcepub fn clear_blocker_detail(&mut self)
pub fn clear_blocker_detail(&mut self)
Clear the blocker detail annotation.
Sourcepub fn attach_evidence(&mut self, evidence_id: Uuid)
pub fn attach_evidence(&mut self, evidence_id: Uuid)
Attach evidence to this task.
Sourcepub fn transition(
&mut self,
to: TaskState,
reason: impl Into<String>,
actor: impl Into<String>,
causation_id: Option<EventId>,
) -> Result<Transition, TransitionError>
pub fn transition( &mut self, to: TaskState, reason: impl Into<String>, actor: impl Into<String>, causation_id: Option<EventId>, ) -> Result<Transition, TransitionError>
Attempt a state transition. Returns a Transition event on success.
Enforces Section 7.2 rules:
- Terminal states are immutable.
- Only valid transitions are allowed.
TaskBlockedrequires a blocker code.- Retry from
TaskFailedtoTaskReadyincrements attempt_no.
Sourcepub fn block(
&mut self,
blocker: BlockerCode,
reason: impl Into<String>,
actor: impl Into<String>,
causation_id: Option<EventId>,
) -> Result<Transition, TransitionError>
pub fn block( &mut self, blocker: BlockerCode, reason: impl Into<String>, actor: impl Into<String>, causation_id: Option<EventId>, ) -> Result<Transition, TransitionError>
Transition to TaskBlocked with a mandatory blocker code.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnsafeUnpin for Task
impl UnwindSafe for Task
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request