"""App version, read from the single-source-of-truth VERSION file.

Per /srv/projects/standards/coding.md the running app must surface its version:
it is how a deploy is confirmed to have landed. VERSION is the one place the
number lives — the Docker build copies it, /api/version serves it, and the UI
footer renders it. Never hardcode a version string anywhere else.
"""

from __future__ import annotations

from pathlib import Path

# VERSION sits at the instance root: app/version.py -> app/ -> main/
_VERSION_FILE = Path(__file__).resolve().parent.parent / "VERSION"


def _read_version() -> str:
    try:
        return _VERSION_FILE.read_text(encoding="utf-8").strip() or "0.0.0"
    except OSError:
        return "0.0.0"


APP_VERSION = _read_version()
