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
impl DependencyGate
Sourcepub fn declare(
&mut self,
task_id: TaskId,
depends_on: Vec<TaskId>,
) -> Result<(), CycleError>
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.
Sourcepub fn check_cycle(
&self,
task_id: TaskId,
depends_on: &[TaskId],
) -> Result<(), CycleError>
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).
Sourcepub fn is_eligible(&self, task_id: TaskId) -> bool
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).
Sourcepub fn is_dependency_failed(&self, task_id: TaskId) -> bool
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.
Sourcepub fn has_prerequisites(&self, task_id: TaskId) -> bool
pub fn has_prerequisites(&self, task_id: TaskId) -> bool
Returns true if task_id has any declared prerequisites.
Sourcepub fn waiting_task_ids(&self) -> impl Iterator<Item = TaskId> + '_
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).
Sourcepub fn notify_completed(&mut self, completed_task_id: TaskId) -> Vec<TaskId>
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).
Sourcepub fn notify_failed(&mut self, failed_task_id: TaskId) -> Vec<TaskId>
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).
Sourcepub fn propagate_failures(&mut self) -> Vec<TaskId>
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.
Sourcepub fn force_satisfy(&mut self, task_id: TaskId)
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).
Sourcepub fn force_fail(&mut self, task_id: TaskId)
pub fn force_fail(&mut self, task_id: TaskId)
Directly marks a task as failed (used during gate reconstruction).
Sourcepub fn gc_task(&mut self, task_id: TaskId)
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 receivednotify_completedand their eligibility was recomputed. - If the task failed (
failed), all dependents already receivednotify_failedand cascades are complete. - Removing a satisfied prerequisite from a dependent’s set is safe; the remaining prerequisites still gate eligibility correctly.
Sourcepub fn recompute_satisfaction_pub(&mut self, task_id: TaskId)
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
impl Clone for DependencyGate
Source§fn clone(&self) -> DependencyGate
fn clone(&self) -> DependencyGate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more