package engines import "strings" // UnsafeEnv reports whether a profile may not set an environment variable, // and why. // // A profile's env is the escape hatch for tuning no adapter can guess — // CUDA_*, NCCL_*, VLLM_*, HF_* — and it reaches an engine the agent starts as // root. Some variables are not tuning but a way to run other code in that // process: the dynamic loader's LD_PRELOAD, Python's PYTHONSTARTUP, a shell's // BASH_ENV. Set from a model definition, which an admin API or a config file // supplies, they would turn "add a model" into "run this as root on every // node". They are refused where a model is defined and again where an engine // starts. func UnsafeEnv(key string) (bool, string) { k := strings.ToUpper(key) switch { case strings.HasPrefix(k, "LD_"), strings.HasPrefix(k, "DYLD_"): return true, "it changes what the dynamic loader loads" case k == "PATH": return true, "it changes which binaries run" case strings.HasPrefix(k, "PYTHON") && k != "PYTHONUNBUFFERED" && k != "PYTHONHASHSEED": return true, "it changes what Python imports or runs at start" case k == "BASH_ENV" || k == "ENV" || k == "PERL5OPT" || k == "PERL5LIB" || k == "NODE_OPTIONS" || k == "RUBYOPT" || k == "GCONV_PATH" || k == "OPENSSL_CONF": return true, "it makes an interpreter or library load code" } return false, "" }