"""
The single broadcast control gate — one definition shared by every server/agent in this package.

WRITE (actuating) broadcast tools — cut a scene, start/stop the stream, take the broadcast public/end it —
are exposed ONLY when this returns True. Default OFF: per docs/plans/trwc-obs-production-workflow.md the
human operator (Johan) owns the switch box, so anything pointed at it is read-only unless a VR-owned /
unmanned box (the 2 Aug rehearsal, walk-test, GSYS demo) explicitly opts in via BROADCAST_ALLOW_CONTROL.

Kept here (not duplicated per module) so the OBS server, the YouTube server, and the director agent can
never drift on what "control is allowed" means.
"""
from __future__ import annotations

import os


def control_enabled() -> bool:
    """True iff BROADCAST_ALLOW_CONTROL is set to a truthy value (1/true/yes/on)."""
    return os.environ.get("BROADCAST_ALLOW_CONTROL", "").strip().lower() in ("1", "true", "yes", "on")
