[build-system]
requires = ["hatchling>=1.21"]
build-backend = "hatchling.build"

[project]
name = "styrened"
dynamic = ["version"]
description = "Unified Styrene library and headless daemon for RNS/LXMF mesh networking"
readme = "README.md"
requires-python = ">=3.11"
license = {text = "MIT"}
authors = [
    {name = "Vanderlyn Labs"}
]
keywords = ["reticulum", "mesh", "daemon", "rpc", "edge", "lxmf"]
classifiers = [
    "Development Status :: 3 - Alpha",
    "Environment :: No Input/Output (Daemon)",
    "Intended Audience :: Developers",
    "Intended Audience :: System Administrators",
    "License :: OSI Approved :: MIT License",
    "Operating System :: POSIX :: Linux",
    "Operating System :: MacOS",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13",
    "Topic :: System :: Systems Administration",
    "Topic :: Communications",
]

# Core dependencies (merged from styrene-core)
dependencies = [
    "rns>=1.0.0",
    "lxmf>=0.8.0",
    "pyyaml>=6.0",
    "platformdirs>=4.0",
    "sqlalchemy>=2.0",
    "msgpack>=1.0",
    "packaging>=21.0",
    "cryptography>=41.0",
]

[project.optional-dependencies]
web = [
    "fastapi>=0.109",
    "uvicorn[standard]>=0.27",
]
metrics = [
    "prometheus-client>=0.19",
]
yubikey = [
    "python-fido2>=1.0",
]
pqc = [
    "liboqs-python>=0.10.0",
]
tui = [
    "textual>=0.47.0",
    "pyte>=0.8",
    "psutil>=5.9",
    "textual-image>=0.8.0",
    "Pillow>=10.0",
    "rumps>=0.4.0; sys_platform == 'darwin'",
]
dev = [
    "pytest>=8.0",
    "pytest-cov>=4.1",
    "pytest-asyncio>=0.23",
    "pytest-xdist>=3.5",
    "pytest-textual-snapshot>=1.0",
    "pytest-forked>=1.6",
    "textual-dev>=1.0",
    "mypy>=1.8",
    "ruff>=0.4.0",
    "types-pyyaml>=6.0",
]
docs = [
    "pdoc>=14.0",
]

[project.scripts]
styrened = "styrened.__main__:main"
styrene = "styrened.tui.__main__:main"

[project.urls]
Homepage = "https://github.com/styrene-lab/styrened"
Repository = "https://github.com/styrene-lab/styrened"
Documentation = "https://docs.styrene.io/styrened/api/"

[tool.hatch.version]
path = "src/styrened/__init__.py"

[tool.hatch.build.targets.wheel]
packages = ["src/styrened"]


[tool.ruff]
line-length = 100
target-version = "py311"

[tool.ruff.lint]
select = [
    "E",   # pycodestyle errors
    "W",   # pycodestyle warnings
    "F",   # pyflakes
    "I",   # isort
    "B",   # flake8-bugbear
    "C4",  # flake8-comprehensions
    "UP",  # pyupgrade
    "N",   # pep8-naming
]
ignore = [
    "E501",  # line too long (handled by formatter)
]

[tool.ruff.lint.isort]
known-first-party = ["styrened"]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]  # Allow unused imports in __init__ files
"src/styrened/ipc/handlers.py" = ["E402"]  # Import after try/except for optional LXMF
"src/styrened/services/yubikey.py" = ["E402"]  # Import after try/except for optional fido2
"tests/bare-metal/conftest.py" = ["E402"]  # Import after sys.path manipulation
"tests/k8s/conftest.py" = ["E402"]  # Import after sys.path manipulation

[tool.mypy]
python_version = "3.11"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = false
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["RNS.*", "LXMF.*", "msgpack", "fido2.*"]
ignore_missing_imports = true

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_functions = ["test_*"]
addopts = "-v --strict-markers"
markers = [
    "slow: marks tests as slow (load/scaling tests, >10min)",
    "requires_metrics: requires metrics-server (for resource usage tests)",
    "smoke: marks tests as smoke tests (fast validation, <2min)",
    "integration: marks tests as integration tests (moderate complexity, <10min)",
    "comprehensive: marks tests as comprehensive tests (deep validation, <30min)",
    "rns_singleton: tests requiring RNS singleton isolation",
    "propagation: LXMF propagation and multi-hop routing tests",
    "resilience: failover and recovery tests",
    "convergence: mesh discovery and convergence tests",
    "mesh: requires Docker mesh topology (two styrened containers)",
    "multihop: requires multi-hop Docker topology (three containers, two networks)",
]
# pytest-xdist configuration
# Use --dist loadscope to keep session-scoped fixtures shared within workers
# Use -n auto to auto-detect CPU count, or -n <number> for explicit worker count
asyncio_mode = "auto"
filterwarnings = [
    "ignore:setDaemon\\(\\) is deprecated:DeprecationWarning:LXMF",
]
