"""Call-time switches for long-report rendering and same-chart reuse. Values are read on every call so one process can measure the old path and the new path back to back. The old path stays in place when a switch is off. """ from __future__ import annotations import os # Masked Windows A/B on 2026-10-14. Render shortcuts are byte-identical and use # less memory, but the end-to-end drop was 20–23%, short of the 35% gate, so # the fast path stays off. Cache hits matched the miss bytes and returned in # about 0.06s, under the 1.5s gate. A missing or unknown GITHUB_SHA still # disables the cache at the call site. RENDER_FAST_DEFAULT = False REFERENCE_CACHE_DEFAULT = True _ON = {"1", "true", "yes", "on"} def _enabled(name: str, default: bool) -> bool: raw = os.environ.get(name) if raw is None or not raw.strip(): return default return raw.strip().lower() in _ON def report_render_fast_enabled() -> bool: """True when the equivalent render and hash shortcuts may run.""" return _enabled("JYOTISH_REPORT_RENDER_FAST", RENDER_FAST_DEFAULT) def report_reference_cache_enabled() -> bool: """True when a full_data markdown response may be reused from disk. A missing or ``unknown`` ``GITHUB_SHA`` still disables the cache at the call site. This function only reads the switch. """ return _enabled("JYOTISH_REPORT_REFERENCE_CACHE", REFERENCE_CACHE_DEFAULT)