LemonCore.Quality.ArchitectureCheck (lemon_core v0.1.0)

View Source

Enforces architecture boundaries for umbrella dependencies and module references.

The check ensures:

  • each app's direct in_umbrella: true dependencies remain a subset of policy
  • each app's source files do not reference forbidden umbrella namespaces

Summary

Functions

Returns the allowed direct dependencies map for all umbrella apps.

Returns the current enforced direct dependency policy.

Runs all architecture boundary checks for the umbrella project.

Returns the target direct dependency policy used for non-failing drift reports.

Types

issue()

@type issue() :: %{
  code: atom(),
  message: String.t(),
  app: atom() | nil,
  path: String.t() | nil
}

report()

@type report() :: %{
  root: String.t(),
  apps_checked: non_neg_integer(),
  issue_count: non_neg_integer(),
  issues: [issue()],
  actual_dependencies: %{optional(atom()) => [atom()]},
  target_drift_count: non_neg_integer(),
  target_dependency_drifts: [target_drift()]
}

target_drift()

@type target_drift() :: %{
  code: :target_dependency_drift,
  message: String.t(),
  app: atom(),
  dependency: atom(),
  path: nil
}

Functions

allowed_direct_deps()

@spec allowed_direct_deps() :: %{optional(atom()) => [atom()]}

Returns the allowed direct dependencies map for all umbrella apps.

This map defines which umbrella dependencies each app is allowed to have. Used for validating the architecture boundary constraints.

current_allowed_direct_deps()

@spec current_allowed_direct_deps() :: %{optional(atom()) => [atom()]}

Returns the current enforced direct dependency policy.

run(opts \\ [])

@spec run(keyword()) :: {:ok, report()} | {:error, report()}

Runs all architecture boundary checks for the umbrella project.

Checks include:

  • Unknown app detection - apps in apps/ without policy configuration
  • Missing app detection - expected apps that don't exist in apps/
  • Dependency violations - umbrella deps that exceed allowed boundaries
  • Namespace violations - module references to apps not in deps

Returns {:ok, report} if no issues found, {:error, report} otherwise.

Options

  • :root - root directory of the umbrella project (defaults to current working directory)

target_allowed_direct_deps()

@spec target_allowed_direct_deps() :: %{optional(atom()) => [atom()]}

Returns the target direct dependency policy used for non-failing drift reports.