Module env_config

Module env_config 

Source
Expand description

2026-09-26: Strict parsing of the numeric process-scoped METRALE_* settings: the rate limits (rate_limiter), the response store and the conversation store.

Owner: server config. Invariants: parse_min never substitutes a default. Unset or blank is Ok(None); any other value that does not parse, or parses below min, is Err.

A lenient read like this one turns a typo into the default, and the default rate limit, 0, means no limit:

ⓘ
let rpm = std::env::var("METRALE_RATE_LIMIT_RPM")
    .ok()
    .and_then(|s| s.parse().ok())   // ← a typo lands here
    .unwrap_or(0);                  // ← and silently becomes "off"

parse_min takes the raw value rather than reading the environment, so tests call it without set_var, which is process-global. Each caller’s from_env reads the variable. Carried::from_env (main_modules/serve_load.rs) runs all three before the listener binds, and serve returns its error, so a bad value stops startup.

Functions§

parse_min
2026-09-26: Parse an optional numeric setting, trimmed at both ends.