Expand description
Edge-resolved configuration.
Config is the single value that carries all environment-derived
state through the crate. Library code never reads std::env
directly — the binary’s main resolves the env once into a Config
and passes &Config down the call graph.
§Why this lives here
Env reads are a side effect of the process boundary. Putting them in library functions makes the library:
- unsafe to test in parallel (process env is global mutable state)
- dependent on global ordering (which fn ran first wins)
- untestable without
unsafe { set_var }in tests
By contrast, with Config resolved once at the outer rim and threaded
through as &Config:
- tests construct a
Configwith literal field values; no env writes - the only place that needs env-mock testing is
Config::from_env_lookup, which is a pure function over an injectable lookup closure - the binary’s
mainis the only place that callsConfig::from_env(=std::env::var)
§What env vars are read
| Var | Field | Default |
|---|---|---|
AGENTSEC_HOME | Paths::home | $HOME/.agentsec ↓ |
HOME | Paths::user_home (and home fallback) | . |
ANTHROPIC_API_KEY | LlmConfig::api_key | None (semantic sanitize layer no-op) |
AGENTSEC_LLM_MODEL | LlmConfig::model | claude-haiku-4-5-20251001 |
AGENTSEC_PASTE_THRESHOLD | PasteConfig::threshold_bytes | 1024 |
AGENTSEC_WEB_TIMEOUT | WebConfig::timeout_secs | 10 |
Structs§
- Config
- All edge-resolved runtime configuration. Constructed once by the
binary’s
mainand passed by reference to library functions. - LlmConfig
- Semantic-sanitize-layer configuration. See
crate::web::sanitize::semantic_layerfor fail-open semantics. - Paste
Config - Paste detection configuration.
- Paths
- Filesystem paths. See crate root §Runtime data root for the layout rules and crate root §Read-only invariants for what may / may not be written.
- WebConfig
- Web fetch configuration.
Constants§
- DEFAULT_
LLM_ MODEL - Default LLM model id used when
AGENTSEC_LLM_MODELis not set. - DEFAULT_
PASTE_ THRESHOLD_ BYTES - Default paste detection threshold (bytes). Content smaller than this limit is still inspected; the threshold governs log verbosity in future versions. Currently kept as a configuration hook for downstream callers.
- DEFAULT_
WEB_ TIMEOUT_ SECS - Default web-fetch timeout in seconds used when
AGENTSEC_WEB_TIMEOUTis not set. Distinct from the old hard-codedDEFAULT_TIMEOUT_SECSconstant inweb/fetch.rs(which was 15 s); the new config-driven default is 10 s.