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§
- Auth
Config - Config
- Top-level config schema matching the canonical TOML structure.
- Endpoint
Config - Telemetry
Config
Enums§
Functions§
- default_
path - Default config-file path:
$HOME/.cleanlibrary/config.toml. ReturnsNoneif 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()ifpathisNoneor the file doesn’t exist. - migrate_
telemetry_ consent - CLEANLIB-627 §1/§4: force a file-persisted
telemetry.enabled = trueback tofalse, once. Returnstrueif a reset was performed, so the caller can show the one-time §4 notice. Self-clearing — after the rewrite the file holdsfalse, so this is a no-op on every subsequent run (no marker needed). The rewrite is what makescat config.tomlhonestly showfalse(§5); the runtime already ignores file-true viatelemetry_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
Configfield 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 statusMUST call this rather than readingTelemetryConfig::enabled, so the file’s pre-tickedtruecan never be reported as enabled (CLEANLIB-627, the status-honesty defect + PM gate c). See [resolve_telemetry] for the rules.