//! Build version information.
//!
//! CI sets `FOXHUNT_BUILD_VERSION` env var at runtime (e.g. `2026.03.408`).
//! Local dev falls back to `CARGO_PKG_VERSION`.
//!
//! NOTE: Version is read at runtime (not compile time) so that changing the
//! version tag doesn't invalidate cargo fingerprints for `common` and cascade
//! a full workspace rebuild of all 38+ dependent crates.

use std::sync::LazyLock;

/// Compile-time fallback from Cargo.toml `version` field.
const CARGO_VERSION: &str = env!("CARGO_PKG_VERSION");

static VERSION: LazyLock<String> = LazyLock::new(|| {
    std::env::var("FOXHUNT_BUILD_VERSION").unwrap_or_else(|_| CARGO_VERSION.to_owned())
});

/// Build version string.
///
/// CI: reads `FOXHUNT_BUILD_VERSION` env var at runtime.
/// Local: falls back to Cargo.toml `version` field.
pub fn version() -> &'static str {
    &VERSION
}
