OSSS.ai.dependencies.graph_engine¶
OSSS.ai.dependencies.graph_engine
¶
Advanced dependency graph engine with topological ordering and circular dependency detection.
This module provides sophisticated dependency management that extends beyond simple sequential execution to support complex dependency graphs with validation, optimization, and advanced routing capabilities.
DependencyType
¶
Bases: Enum
Types of dependencies between agents.
ExecutionPriority
¶
Bases: Enum
Execution priority levels for agents.
ResourceConstraint
¶
Bases: BaseModel
Resource constraint for agent execution.
Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.
DependencyEdge
¶
Bases: BaseModel
An edge in the dependency graph representing a dependency relationship.
Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.
is_satisfied(context)
¶
Check if dependency condition is satisfied.
DependencyNode
¶
Bases: BaseModel
A node in the dependency graph representing an agent and its constraints.
Migrated from dataclass to Pydantic BaseModel for enhanced validation, serialization, and integration with the OSSS Pydantic ecosystem.
can_execute(context)
¶
Check if node can execute given current context.
CircularDependencyError
¶
Bases: Exception
Raised when circular dependencies are detected in the graph.
DependencyValidationError
¶
Bases: Exception
Raised when dependency graph validation fails.
TopologicalSort
¶
Utility class for topological sorting with cycle detection.
sort(nodes, edges)
staticmethod
¶
DependencyGraphEngine
¶
Advanced dependency graph engine for agent execution planning.
Provides topological ordering, circular dependency detection, conditional dependencies, and optimization capabilities for complex agent execution graphs.
add_node(node)
¶
Add a node to the dependency graph.
add_edge(edge)
¶
Add a dependency edge to the graph.
remove_node(agent_id)
¶
Remove a node and all its edges from the graph.
add_dependency(from_agent, to_agent, dependency_type=DependencyType.HARD, condition=None, weight=1.0, **kwargs)
¶
Convenience method to add a dependency between two agents.
get_execution_order(context=None)
¶
get_parallel_groups(context=None)
¶
Get groups of agents that can execute in parallel.
Returns¶
List[List[str]] List of groups, where each group contains agents that can run in parallel
validate_graph()
¶
Validate the dependency graph for consistency and correctness.
Returns¶
List[str] List of validation warnings/errors
get_dependency_impact(agent_id)
¶
optimize_for_latency()
¶
Optimize execution order to minimize total latency.
optimize_for_reliability()
¶
Optimize execution order to maximize reliability.
get_execution_statistics()
¶
Get statistics about the dependency graph and execution patterns.