Raxol.Core.Runtime.Plugins.DependencyResolver (Raxol Core v2.4.0)

Copy Markdown View Source

Install-time and load-time dependency resolution for plugins.

Uses Kahn's algorithm for topological sort with cycle detection, conflict checking, and capability matching.

Summary

Functions

Checks for conflicts between manifests.

Resolves load order for a set of manifests using topological sort.

Resolves load order for new manifests given already-loaded plugin ids.

Checks that all requires capabilities are satisfied by some plugin's provides.

Types

reason()

@type reason() ::
  {:cycle, [atom()]}
  | {:missing, plugin :: atom(), dependency :: atom()}
  | {:conflict, atom(), atom()}
  | {:unmet_capability, plugin :: atom(), capability :: atom()}

resolution()

@type resolution() :: {:ok, load_order :: [atom()]} | {:error, reason()}

Functions

check_conflicts(manifests)

@spec check_conflicts([Raxol.Core.Runtime.Plugins.Manifest.t()]) ::
  :ok | {:error, {:conflict, atom(), atom()}}

Checks for conflicts between manifests.

resolve(manifests)

Resolves load order for a set of manifests using topological sort.

Returns {:ok, [plugin_id]} in dependency order (dependencies first), or {:error, reason} on failure.

resolve_incremental(manifests, already_loaded)

@spec resolve_incremental(
  [Raxol.Core.Runtime.Plugins.Manifest.t()],
  already_loaded :: [atom()]
) ::
  resolution()

Resolves load order for new manifests given already-loaded plugin ids.

Treats already_loaded as satisfied dependencies that don't need ordering.

satisfy_capabilities(manifests)

@spec satisfy_capabilities([Raxol.Core.Runtime.Plugins.Manifest.t()]) ::
  :ok | {:error, {:unmet_capability, atom(), atom()}}

Checks that all requires capabilities are satisfied by some plugin's provides.