#!/usr/bin/env python3
"""Codex MMO package and development-schema identity."""

from __future__ import annotations

import re
from pathlib import Path

PACKAGE_ROOT = Path(__file__).resolve().parents[1]
PACKAGE_VERSION = (PACKAGE_ROOT / "VERSION").read_text(encoding="utf-8").strip()
_VERSION_MATCH = re.fullmatch(
    r"(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)",
    PACKAGE_VERSION,
)
if _VERSION_MATCH is None:
    raise RuntimeError("VERSION must contain MAJOR.MINOR.PATCH")

# During active development every MMO-owned serialized format advances as one
# deliberately breaking generation. Independently versioned upstream formats
# (Codex app-server, MCP, and Switchyard) do not use this value.
MMO_SCHEMA_VERSION = int(_VERSION_MATCH.group(1))

# Codex app-server schemas are generated artifacts tied to one exact CLI
# release.  Runtime admission and the optional installer deliberately share
# this single pin so an installer upgrade cannot silently outrun the reviewed
# wire contract.
APP_SERVER_PROTOCOL_CODEX_VERSION = "0.149.0"

# Switchyard's generated route schema and optional installer are reviewed
# against one baseline release.  The MCP namespace bridge is a separate,
# deliberately literal compatibility pin.  Upstream fix NVIDIA-NeMo/Switchyard
# #384 (commit c7beccd4891fa5cfe3a3b94fdd376f5765864507) is merged but is not in
# v0.2.0.  The first published switchyard-server release containing that commit
# is the removal trigger.  When the baseline advances, the guard test requires
# this shim to be removed instead of silently carrying it into that release.
SWITCHYARD_BASELINE_VERSION = "0.2.0"
SWITCHYARD_MCP_NAMESPACE_BRIDGE_VERSION = "0.2.0"
