"""Douanier config — paths, dev token, version. Env-overridable, sane defaults.

Flat-module layout (run from this dir): the service imports `config` and
`engines.*` directly, matching the tide-table analyzers' sibling-import style.
"""
import os
from pathlib import Path

# ── identity ──────────────────────────────────────────────────────────────────
SERVICE = "douanier"
VERSION = "v1"                       # forced route prefix; SRE maps the public path in.

# ── repo-relative paths ─────────────────────────────────────────────────────────
HERE = Path(__file__).resolve().parent          # armada/api
ARMADA = HERE.parent                             # armada
TIDE_TABLE = ARMADA / "tide-table"               # the ears engines live here
FOUNDRY = ARMADA.parent / "tools" / "foundry"    # the Foundry engines

# ── cache / data roots (transient — freebox is the SSOT later) ───────────────────
# Default to a local dir for dev; point CACHE_ROOT at the freebox mount in prod.
CACHE_ROOT = Path(os.environ.get("DOUANIER_CACHE", HERE / "_cache"))
DB_PATH = Path(os.environ.get("DOUANIER_DB", HERE / "_cache" / "douanier.db"))

# ── auth ─────────────────────────────────────────────────────────────────────
# WALKING-SKELETON stub (#36): one hardcoded bearer from the env, swapped for the
# SQLite token store in #23. No token set → the guarded routes return 503 (not
# wide open) so we never accidentally ship an unauthenticated endpoint.
DEV_TOKEN = os.environ.get("DOUANIER_DEV_TOKEN", "")

# ── limits ─────────────────────────────────────────────────────────────────────
MAX_UPLOAD_MB = int(os.environ.get("DOUANIER_MAX_UPLOAD_MB", "40"))

# ── engine selection ─────────────────────────────────────────────────────────
# "clap"  = CLAP/torch (rich, ~4 GB, needs the GPU/dev box) — default for local dev.
# "light" = librosa-heuristic V/A (no torch, fits the erable container) — set in prod.
EMOTION_ENGINE = os.environ.get("DOUANIER_EMOTION_ENGINE", "clap").lower()
