# =============================================================================
# Import Linter Configuration
# =============================================================================
# Enforces architectural boundaries to maintain clean code structure.
# Run with: lint-imports (or tools/lint_imports.bat)
# =============================================================================

[importlinter]
root_packages =
    mcp_workspace
    tests
root_package_paths =
    src
    .
include_external_packages = True

# -----------------------------------------------------------------------------
# Contract: Layered Architecture
# -----------------------------------------------------------------------------
# Ensures dependencies flow in one direction:
#   main -> server -> file_tools -> (no internal dependencies)
#
# Why this matters:
# - Prevents circular dependencies
# - Keeps entry point (main) as thin orchestration layer
# - Server focuses on MCP protocol, delegates to file_tools
# - File tools are independent, reusable utilities
# -----------------------------------------------------------------------------
[importlinter:contract:layered_architecture]
name = Layered Architecture
type = layers
layers =
    mcp_workspace.main
    mcp_workspace.server
    mcp_workspace.file_tools

# -----------------------------------------------------------------------------
# Contract: MCP Library Isolation
# -----------------------------------------------------------------------------
# The 'mcp' package should only be imported by main.py and server.py.
# File tools should remain MCP-agnostic for reusability.
# -----------------------------------------------------------------------------
[importlinter:contract:mcp_library_isolation]
name = MCP Library Isolation
type = forbidden
source_modules =
    mcp_workspace
forbidden_modules =
    mcp
ignore_imports =
    mcp_workspace.server -> mcp

# -----------------------------------------------------------------------------
# Contract: GitPython Library Isolation
# -----------------------------------------------------------------------------
# The 'git' package should only be used by git_operations module.
# -----------------------------------------------------------------------------
[importlinter:contract:gitpython_isolation]
name = GitPython Library Isolation
type = forbidden
source_modules =
    mcp_workspace
forbidden_modules =
    git
ignore_imports =
    mcp_workspace.file_tools.git_operations -> git

# -----------------------------------------------------------------------------
# Contract: Structlog Library Isolation
# -----------------------------------------------------------------------------
# Structured logging should only be configured in log_utils.
# Other modules should use standard logging.
# -----------------------------------------------------------------------------
[importlinter:contract:structlog_isolation]
name = Structlog Library Isolation
type = forbidden
source_modules =
    mcp_workspace
forbidden_modules =
    structlog

# -----------------------------------------------------------------------------
# Contract: Python JSON Logger Isolation
# -----------------------------------------------------------------------------
# python-json-logger should only be used via mcp_coder_utils (external).
# No direct imports allowed from mcp_workspace.
# -----------------------------------------------------------------------------
[importlinter:contract:pythonjsonlogger_isolation]
name = Python JSON Logger Isolation
type = forbidden
source_modules =
    mcp_workspace
forbidden_modules =
    pythonjsonlogger

# -----------------------------------------------------------------------------
# Contract: Source Code Independence from Tests
# -----------------------------------------------------------------------------
# Production code should never import from test modules.
# -----------------------------------------------------------------------------
[importlinter:contract:no_test_imports_in_source]
name = Source Code Independence from Tests
type = forbidden
source_modules =
    mcp_workspace
forbidden_modules =
    tests
