# Layering contracts for flotilla-forensics — enforces the dependency
# direction within the forensics subpackage and the federation-leaf rule
# (DP-01 / import-linter; the federation cornerstone enforcement).
#
# Run locally:  uv run lint-imports   (or: python -m importlinter, via
#               the cli entry point — see .woodpecker.yml).
#
# Every contract is a hard MUST NOT — import-linter fails CI on any
# violation. When relaxing a rule, document why in a `reason` comment.
#
# Root note: grimp requires a *top-level* package as the root, and this
# repo extends the PEP-420 `mgf` namespace, so the root is `mgf` (not
# `mgf.flotilla.forensics`). See DEPS.md.

[importlinter]
root_packages =
    mgf
include_external_packages = True

# ---------------------------------------------------------------------------
# Contract 1 — federation leaf: forensics never imports a consumer app.
#
# `mgf.flotilla.forensics` is a sibling library. It MUST NOT import any
# consumer application (the CLI / GUI that consume it) — that would
# invert the dependency direction and make the library un-extractable.
# ---------------------------------------------------------------------------
[importlinter:contract:forensics-is-a-leaf]
name = forensics does not import any consumer application
type = forbidden
source_modules =
    mgf.flotilla.forensics
forbidden_modules =
    flotilla
    vm_vmanager_app

# ---------------------------------------------------------------------------
# Contract 2 — internal layering inside the forensics subpackage.
#
# Top: the orchestrators (render, archive) compose everything.
# Then: analysis + reports (read-only over stored artifacts).
# Then: capture (writes artifacts).
# Then: manifest + store (on-disk persistence).
# Bottom: case (the frozen data model — imports nothing internal).
#
# Higher layers MAY import lower layers; the reverse is forbidden.
# `analysis` legitimately reads `capture`'s typed result models, so
# capture sits below analysis. `independent = false` allows same-layer
# siblings to coexist without cross-import claims.
# ---------------------------------------------------------------------------
[importlinter:contract:forensics-layers]
name = forensics internal layering points downward
type = layers
layers =
    render | archive
    reports
    analysis
    capture
    manifest | store
    case
containers =
    mgf.flotilla.forensics

[importlinter:contract:forensics-no-ui]
name = forensics imports no UI framework (PR-01)
type = forbidden
source_modules =
    mgf.flotilla.forensics
forbidden_modules =
    PySide6
    PyQt6
    PyQt5
    textual
    tkinter
