feat: implement profile activation and runtime identity clarity (#131)

This commit is contained in:
2026-07-04 02:04:07 -04:00
parent b1256d73b4
commit a0e7d3360e
4 changed files with 685 additions and 11 deletions
+21
View File
@@ -192,11 +192,32 @@ def config_path():
return (os.environ.get(ENV_CONFIG_PATH) or "").strip() or None
_active_profile_override = None
def selected_profile_name():
"""Return the selected profile name from the environment, or None."""
if _active_profile_override is not None:
return _active_profile_override
return (os.environ.get(ENV_PROFILE) or "").strip() or None
def is_runtime_switching_enabled(path=None):
"""Check if runtime profile switching is explicitly enabled in config."""
try:
config = load_config(path)
except Exception:
return False
if not config:
return False
rules = config.get("rules") or {}
if rules.get("allow_runtime_switching") is True:
return True
if config.get("allow_runtime_switching") is True:
return True
return False
def load_config(path=None):
"""Load and minimally validate the canonical JSON config.