Byte-identical to the legacy path on four fictional charts (PyJHora masked), -19–26% end to end (median 23%). Short of the 25% written on the ticket; the product owner chose to turn it on anyway. JYOTISH_REPORT_RENDER_FAST=0 restores the old path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoz1Qk3y9buDv1mkmTu
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
"""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 byte-identical, less memory,
|
||
# end-to-end -20–23%, short of the 35% gate then set, so the path stayed off.
|
||
# Linux A/B on 2026-10-28 (four fictional charts, PyJHora masked): byte-identical
|
||
# again, -19–26% (median 23%). The product owner chose to turn it on anyway
|
||
# (issue #121, option A); JYOTISH_REPORT_RENDER_FAST=0 restores the old path.
|
||
# 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 = True
|
||
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)
|