Skip to main content

DependencyGate

Struct DependencyGate 

Source
pub struct DependencyGate { /* private fields */ }
Expand description

Gates task promotion based on declared inter-task dependencies.

Tasks with unsatisfied prerequisites are blocked from Scheduled → Ready promotion in the dispatch loop. The gate is notified when tasks complete or fail, updating eligibility accordingly.

The gate is not persisted directly — it is reconstructed at bootstrap from WAL events stored in the recovery reducer.

Implementations§

Source§

impl DependencyGate

Source

pub fn new() -> Self

Creates an empty gate (no dependencies, all tasks implicitly eligible).

Source

pub fn declare( &mut self, task_id: TaskId, depends_on: Vec<TaskId>, ) -> Result<(), CycleError>

Declares that task_id depends on all tasks in depends_on.

§Errors

Returns CycleError if adding this dependency would create a cycle in the dependency graph.

Source

pub fn check_cycle( &self, task_id: TaskId, depends_on: &[TaskId], ) -> Result<(), CycleError>

Checks whether declaring these dependencies would create a cycle, without modifying the gate.

Use this to pre-validate before a WAL append, so that cycles are rejected before being durably persisted.

§Errors

Returns CycleError if any prerequisite in depends_on can already reach task_id through existing edges (i.e., adding these edges would close a cycle).

Source

pub fn is_eligible(&self, task_id: TaskId) -> bool

Returns true if task_id may be promoted to Ready.

A task is eligible when it has no declared dependencies, OR when all its prerequisites have been satisfied. Tasks with failed prerequisites are NOT eligible (they will be canceled by the dispatch loop instead).

Source

pub fn is_dependency_failed(&self, task_id: TaskId) -> bool

Returns true if task_id’s prerequisites have permanently failed.

When this returns true, the dispatch loop should cancel the task’s non-terminal runs rather than waiting for prerequisites to be satisfied.

Source

pub fn has_prerequisites(&self, task_id: TaskId) -> bool

Returns true if task_id has any declared prerequisites.

Source

pub fn waiting_task_ids(&self) -> impl Iterator<Item = TaskId> + '_

Returns all task_ids that are waiting for their prerequisites to be met.

Excludes tasks whose prerequisites have all been satisfied and tasks whose prerequisites have failed (those are in the failed set).

Source

pub fn notify_completed(&mut self, completed_task_id: TaskId) -> Vec<TaskId>

Called when a prerequisite task has reached terminal success.

Returns the list of task_ids that became newly eligible as a result (all prerequisites now satisfied).

Source

pub fn notify_failed(&mut self, failed_task_id: TaskId) -> Vec<TaskId>

Called when a prerequisite task has permanently failed (all runs reached Failed or Canceled, with no successful completion).

Returns the list of task_ids that are now permanently blocked (their prerequisites will never succeed).

Source

pub fn propagate_failures(&mut self) -> Vec<TaskId>

Cascades the failed set to all transitive dependents.

After bootstrap populates force_fail for directly-failed prerequisites, this method BFS-cascades to ensure all reachable dependents are also marked as failed.

Returns the list of newly-failed (dependent) task IDs.

Source

pub fn force_satisfy(&mut self, task_id: TaskId)

Directly marks a task as satisfied (used during gate reconstruction from WAL events at bootstrap — bypasses cycle check since declarations are already validated).

Source

pub fn force_fail(&mut self, task_id: TaskId)

Directly marks a task as failed (used during gate reconstruction).

Source

pub fn gc_task(&mut self, task_id: TaskId)

Removes all gate state for a fully-terminal task.

Called by the dispatch loop after a task reaches full terminal state and all dependency notifications have been issued. Safe to call because:

  • If the task completed (satisfied), all dependents already received notify_completed and their eligibility was recomputed.
  • If the task failed (failed), all dependents already received notify_failed and cascades are complete.
  • Removing a satisfied prerequisite from a dependent’s set is safe; the remaining prerequisites still gate eligibility correctly.
Source

pub fn recompute_satisfaction_pub(&mut self, task_id: TaskId)

Re-evaluates satisfaction for task_id using the current satisfied set.

Called by the dispatch loop after restoring prerequisite satisfaction state from the projection (e.g., when declaring a dependency after a prerequisite completed and was GC’d from the satisfied set).

Trait Implementations§

Source§

impl Clone for DependencyGate

Source§

fn clone(&self) -> DependencyGate

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DependencyGate

Source§

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

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

impl Default for DependencyGate

Source§

fn default() -> DependencyGate

Returns the “default value” for a type. Read more
Source§

impl PartialEq for DependencyGate

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for DependencyGate

Source§

impl StructuralPartialEq for DependencyGate

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<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> 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<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