Module task_graph

Module task_graph 

Source
Expand description

Task graph types for the Director/Worker orchestrator.

A TaskGraph is a directed acyclic graph (DAG) of TaskNodes that the orchestrator executor drives to completion in topological order. Nodes with no unsatisfied dependencies run concurrently; each node executes as an isolated AgentLoop worker with its own tool allowlist and context window.

§Validation

Call TaskGraph::new (preferred) or TaskGraph::validate_acyclic (on a manually-constructed graph) before handing a graph to the executor. Both methods check:

  • All depends_on ids resolve to existing nodes.
  • The dependency edges form a true DAG (no cycles, no self-loops).
  • Node count ≤ MAX_NODES.
  • Longest path depth ≤ MAX_DEPTH.

§Example

use std::collections::HashSet;
use gglib_core::domain::council::task_graph::{
    TaskGraph, TaskNode, TaskNodeKind, NodeId, NodeStatus, HitlMode,
};

let nodes = vec![
    TaskNode {
        id: NodeId("research".into()),
        goal: "Research the topic".into(),
        depends_on: vec![],
        tool_allowlist: vec!["web_search".into()],
        kind: TaskNodeKind::Leaf,
        role: None,
        status: NodeStatus::Pending,
        output: None,
        compacted_output: None,
        error: None,
    },
    TaskNode {
        id: NodeId("draft".into()),
        goal: "Write the first draft".into(),
        depends_on: vec![NodeId("research".into())],
        tool_allowlist: vec![],
        kind: TaskNodeKind::Leaf,
        role: None,
        status: NodeStatus::Pending,
        output: None,
        compacted_output: None,
        error: None,
    },
];
let graph = TaskGraph::new("Write a research doc".into(), HitlMode::None, nodes).unwrap();
let ready = graph.ready_nodes(&HashSet::new());
assert_eq!(ready.len(), 1);
assert_eq!(ready[0], &NodeId("research".into()));

Structs§

DebateAgent
An individual participant in a TaskNodeKind::Debate node.
DebateConfig
Complete configuration for a TaskNodeKind::Debate node.
DebateJudgeConfig
Configuration for the optional judge that assesses each debate round.
NodeId
Opaque node identifier within a TaskGraph.
TaskGraph
A validated directed acyclic graph of TaskNodes.
TaskNode
A single work unit in a TaskGraph.

Enums§

GraphDiff
A single mutation to apply to a TaskGraph at runtime.
HitlMode
Controls when the orchestrator executor pauses to request human approval.
NodeBudget
Advisory upper bound on the aggregate node count across all subgraphs.
NodeStatus
Lifecycle state of a single TaskNode.
TaskGraphError
Error variants produced during TaskGraph construction or validation.
TaskNodeKind
Execution kind for a TaskNode: leaf worker, nested sub-team, or multi-agent debate.

Constants§

BLACK 🔒
GRAY 🔒
MAX_DEPTH
Maximum depth (longest root-to-leaf path) a TaskGraph may have per subgraph.
MAX_NODES
Maximum number of nodes a TaskGraph may contain per subgraph.
MAX_TOTAL_NODES
Soft upper bound on the total node count across all subgraphs combined.
WHITE 🔒

Functions§

compute_depth 🔒
default_min_rounds_before_stop 🔒
dfs_check_cycle 🔒