# Layering contracts for mgf-vm-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 (transitional): 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.vm.forensics`). While the `mgf-vm` umbrella is the
# dependency it ships its own `mgf.vm.forensics`, which shadows this
# repo's copy at import time; the contracts below describe the intended
# direction and flip onto `mgf-vm-core` in Phase 0 Stream A. See DEPS.md.

[importlinter]
root_packages =
    mgf
include_external_packages = True

# ---------------------------------------------------------------------------
# Contract 1 — federation leaf: forensics never imports a consumer app.
#
# `mgf.vm.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.vm.forensics
forbidden_modules =
    vmanager
    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.vm.forensics

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