Raxol.Core.Runtime.Plugins.DependencyManager.Core (Raxol v0.5.0)

View Source

Core module for managing plugin dependencies and dependency resolution. Provides the main public API for dependency checking and load order resolution.

Summary

Functions

Checks for circular dependencies in the plugin graph.

Resolves dependencies between plugins.

Resolves the load order for a set of plugins based on their dependencies. Uses Tarjan's algorithm for efficient cycle detection and component identification.

Validates a list of dependencies.

Types

dependency()

@type dependency() :: {String.t(), version_constraint()} | String.t()

dependency_chain()

@type dependency_chain() :: [String.t()]

dependency_error()

@type dependency_error() ::
  {:error, :missing_dependencies, [String.t()], dependency_chain()}
  | {:error, :version_mismatch,
     [{String.t(), String.t(), version_constraint()}], dependency_chain()}
  | {:error, :circular_dependency, [String.t()], dependency_chain()}

version_constraint()

@type version_constraint() :: String.t()

Functions

check_circular_dependencies(plugin_id, dependencies, loaded_plugins)

Checks for circular dependencies in the plugin graph.

Parameters

  • plugin_id - The ID of the plugin to check
  • dependencies - List of dependencies to check
  • loaded_plugins - Map of currently loaded plugins

Returns

  • :ok - If no circular dependencies are found
  • {:error, :circular_dependency, cycle, chain} - If a circular dependency is detected

check_dependencies(plugin_id, plugin_metadata, loaded_plugins, dependency_chain \\ [])

Checks if a plugin's dependencies are satisfied.

Parameters

  • plugin_id - The ID of the plugin to check
  • plugin_metadata - The plugin's metadata containing its dependencies
  • loaded_plugins - Map of currently loaded plugins
  • dependency_chain - List of plugin IDs in the current dependency chain (for error reporting)

Returns

  • :ok - If all dependencies are satisfied
  • {:error, :missing_dependencies, missing, chain} - If any dependencies are missing
  • {:error, :version_mismatch, mismatches, chain} - If any dependencies have incompatible versions
  • {:error, :circular_dependency, cycle, chain} - If a circular dependency is detected

resolve_dependencies(plugin_metadata, loaded_plugins)

Resolves dependencies between plugins.

Parameters

  • plugin_metadata - The plugin's metadata containing its dependencies
  • loaded_plugins - Map of currently loaded plugins

Returns

  • {:ok, resolved_deps} - List of resolved dependencies
  • {:error, reason} - If dependency resolution fails

resolve_load_order(plugins)

Resolves the load order for a set of plugins based on their dependencies. Uses Tarjan's algorithm for efficient cycle detection and component identification.

Parameters

  • plugins - Map of plugin metadata, keyed by plugin ID

Returns

  • {:ok, load_order} - List of plugin IDs in the correct load order
  • {:error, :circular_dependency, cycle, chain} - If a circular dependency is detected

validate_dependencies(dependencies)

Validates a list of dependencies.

Parameters

  • dependencies - List of dependencies to validate

Returns

  • :ok - If all dependencies are valid
  • {:error, reason} - If any dependencies are invalid