# Import-linter contracts for mgf-cloud (DP-01 / WF-02).
#
# mgf-cloud is a provider-agnostic cloud interface. Closed-box invariant: it
# may depend on its cornerstone (mgf-common), its provider SDKs (openstacksdk,
# boto3, paramiko — confined to the adapter modules) and, behind the [web]
# extra, the web stack (fastapi/uvicorn/jinja2/mgf-fastapi) — and NOTHING
# unrelated. The per-module "core stays light" contract (core must not import a
# provider SDK or the web framework — adapters load lazily) is added in Pass 2
# once those modules exist. CI runs lint-imports.

[importlinter]
root_packages =
    mgf.cloud
include_external_packages = True

[importlinter:contract:mgf-cloud-closed-box]
name = mgf.cloud imports no unrelated framework or heavy SDK
type = forbidden
source_modules =
    mgf.cloud
forbidden_modules =
    django
    PySide6
    PyQt6
    PyQt5
    textual
    click
    typer
    fire
    rich
    prompt_toolkit
    qasync
    flask
    sqlalchemy
    redis
    celery
    numpy
    pandas
    requests

# The core stays light: the abstraction modules must never import a provider SDK
# or the web framework — those belong only in the adapter modules
# (providers/infomaniak.py, providers/aws.py), remote.py, and web/, which the
# factory + the CLI load lazily. This keeps `import mgf.cloud` SDK-free.
[importlinter:contract:mgf-cloud-core-light]
name = mgf.cloud core (models/config/exceptions/providers.base) imports no provider SDK or web framework
type = forbidden
source_modules =
    mgf.cloud.models
    mgf.cloud.config
    mgf.cloud.exceptions
    mgf.cloud.cost
    mgf.cloud.defaults
    mgf.cloud.providers.base
    mgf.cloud.providers.fake
forbidden_modules =
    openstack
    boto3
    botocore
    paramiko
    fastapi
    starlette
    uvicorn
    jinja2

# PR-04: the CLI and the web GUI are independent surfaces. The ONLY allowed edge
# is the CLI lazily launching the GUI (`mgf-cloud web`), whitelisted below; the
# web app must never reach back into the CLI.
[importlinter:contract:mgf-cloud-cli-web-independence]
name = mgf.cloud.cli and mgf.cloud.web are independent (bar the lazy launcher edge)
type = independence
modules =
    mgf.cloud.cli
    mgf.cloud.web
ignore_imports =
    mgf.cloud.cli._app -> mgf.cloud.web
