The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(cron): strip external-source residue in strip_launch_profile_env itself
kshitijk4poor03d3c52855f0
diff --git a/cron/scheduler_script.py b/cron/scheduler_script.pyindex ed8618334b3..e84bae6faa8 100644--- a/cron/scheduler_script.py+++ b/cron/scheduler_script.py@@ -479,22 +479,9 @@ def _run_job_script(# then overlay the installed scope, then sanitize, so routed values pass the same scrub /# passthrough rules as any other (#114209 declared names included). No-op outside multiplex# or for the launch profile's own fires; the parent process is never mutated.- from agent.secret_scope import _is_global_env, current_secret_scope, is_multiplex_active- from hermes_cli.env_loader import secret_source_names+ from agent.secret_scope import current_secret_scopefrom tools.environments.local import restore_managed_env, strip_launch_profile_envbase = strip_launch_profile_env(dict(os.environ))- # strip_launch_profile_env only knows dotenv- and terminal-config-owned names. External- # secret sources (vault, 1Password, ...) also write their names into the shared os.environ,- # tracked in secret_source_names(), and a name the LAUNCH profile's source supplied is not- # this profile's to see. Drop them; the overlay below puts back exactly the ones the routed- # profile's own sources supply (build_profile_secret_scope folds get_secret_source_values in).- # Guarded like strip_launch_profile_env itself: with no multiplexing there is no other- # profile to leak from -- os.environ IS this profile's environment -- so a single-profile- # child keeps byte-identical env even if a source's per-home snapshot is ever missing.- if is_multiplex_active():- for name in secret_source_names():- if not _is_global_env(name):- base.pop(name, None)scope = current_secret_scope()if scope:base.update(scope)diff --git a/tools/environments/local.py b/tools/environments/local.pyindex 7cd9a38c538..353e0cd41e4 100644--- a/tools/environments/local.py+++ b/tools/environments/local.py@@ -467,15 +467,18 @@ def strip_launch_profile_env(env: dict, target_home: "str | Path | None" = None)# recognized as a global name and left alone.# Current file AND every key any dotenv load put into os.environ this process lifetime: a key# removed or renamed in the launch .env after boot is still in os.environ with the old value, and- # a re-parse of the file alone no longer names it (#107695 review). The administrator-managed .env- # is NOT residue: its values are policy for every profile (``_apply_managed_env`` applies it last,- # with override, so it beats the user's own .env) — leave them in place.- from hermes_cli.env_loader import launch_dotenv_keys, managed_dotenv_keys+ # a re-parse of the file alone no longer names it (#107695 review). External secret sources+ # (vault, 1Password, ...) write their names into the same shared os.environ, and a name the+ # LAUNCH profile's source supplied is not the target profile's to see; the caller's scope+ # overlay puts back exactly the ones the target's own sources supply. The administrator-managed+ # .env is NOT residue: its values are policy for every profile (``_apply_managed_env`` applies+ # it last, with override, so it beats the user's own .env) — leave them in place.+ from hermes_cli.env_loader import launch_dotenv_keys, managed_dotenv_keys, secret_source_namesmanaged_names = {key.upper() for key in managed_dotenv_keys()}residue_names = {key.upper() for key inset(load_env_file(launch_home / ".env")) | set(launch_dotenv_keys())- | set(TERMINAL_CONFIG_ENV_MAP.values())+ | set(TERMINAL_CONFIG_ENV_MAP.values()) | set(secret_source_names())if not _is_global_env(key.upper()) or key.upper().startswith("TERMINAL_")} - managed_namesfor key in [k for k in env if k.upper() in residue_names]:del env[key]