Skip to main content

Module config

Module config 

Source
Expand description

Config-file + env-var loader per Client spec rev1 §5 and SDK config-file format decision 2026-05-20. TOML on disk at ~/.cleanlibrary/config.toml; env vars override file values.

Precedence (highest wins): explicit constructor args > env vars > ~/.cleanlibrary/config.toml > defaults. Constructor-arg precedence is consumer-side (CLI flags / SDK options); this module exposes file + env merging.

Structs§

AuthConfig
Config
Top-level config schema matching the canonical TOML structure.
EndpointConfig
TelemetryConfig

Enums§

ConfigError

Functions§

default_path
Default config-file path: $HOME/.cleanlibrary/config.toml. Returns None if the OS has no discoverable home dir.
load
Load + parse a TOML config file.
load_with_env_overrides
Load config with env-var overrides applied on top of file values. Returns Config::default() if path is None or the file doesn’t exist.
migrate_telemetry_consent
CLEANLIB-627 §1/§4: force a file-persisted telemetry.enabled = true back to false, once. Returns true if a reset was performed, so the caller can show the one-time §4 notice. Self-clearing — after the rewrite the file holds false, so this is a no-op on every subsequent run (no marker needed). The rewrite is what makes cat config.toml honestly show false (§5); the runtime already ignores file-true via telemetry_enabled, so a failed rewrite still leaves telemetry off. Best-effort: IO errors are swallowed.
save
Save config to TOML file. Creates parent dirs if needed. Overwrites existing content as a whole-file rewrite — preserves all explicit Config field values (auth/endpoint/telemetry) but does NOT preserve comments or non-Config keys. Customer should use env-var precedence for dynamic auth values to avoid hand-editing the file.
telemetry_enabled
The EFFECTIVE telemetry-enabled state — the single source of truth for “is telemetry on?”. Both a future emitter and cleanlib status MUST call this rather than reading TelemetryConfig::enabled, so the file’s pre-ticked true can never be reported as enabled (CLEANLIB-627, the status-honesty defect + PM gate c). See [resolve_telemetry] for the rules.