# Layering contracts for mgf.common — enforces the dependency
# direction documented in docs/standards/DESIGN_PRINCIPLES.md
# (rule DP-01) and the lift-readiness rule (LIFT-1) from
# docs/STANDARD_GAP.md.
#
# Run locally:      lint-imports
# Run in CI:        see .woodpecker.yml lint step
#
# Adding contracts? Each contract is phrased as a hard MUST NOT —
# import-linter fails the CI build on any violation. When adding a
# new rule, add a ``reason = ...`` comment so a future engineer
# (or AI) knows why it exists before deciding to relax it.

[importlinter]
root_packages =
    mgf.common
# Required because the contracts below name external packages
# (vmanager, mgf.cli, mgf.gui) as forbidden — without this flag,
# import-linter refuses to start.
include_external_packages = True

# ---------------------------------------------------------------------------
# Contract 1 — mgf.common is a leaf (the lift-readiness invariant).
#
# Reason: mgf.common is the SHARED library that every consumer
# project depends on. The dependency direction MUST be one-way:
# consumers (vmanager, future projects) depend on mgf.common, never
# the reverse. Without this contract, a casual ``import vmanager.X``
# inside mgf.common would create a cycle that breaks every other
# consumer. Better to fail loudly in CI here than at integration
# time in some downstream project.
#
# The "forbidden_modules" list is deliberately broad — anything not
# in mgf.common's own deps (pydantic, pydantic-settings, pyyaml,
# stdlib, opentelemetry, sentry_sdk) is by definition off-limits.
# The contract relies on import-linter's behaviour: only top-level
# packages we control or explicitly forbid are checked; third-party
# deps not listed here are fine.
# ---------------------------------------------------------------------------

[importlinter:contract:mgf-common-is-a-leaf]
name = mgf.common does not import any consumer project
type = forbidden
source_modules =
    mgf.common
forbidden_modules =
    vmanager
# NOTE: future ``mgf.cli`` / ``mgf.gui`` siblings would also be
# forbidden in principle, but import-linter rejects "subpackages of
# external packages" in the forbidden_modules list. Consumers in the
# ``mgf.<sibling>`` namespace will be added as separate top-level
# entries here when they exist.
