Summary
Removed global mutable cache state from the user configuration module. The previous implementation used module-level _config_fingerprint and _config_cache variables for a fast-path optimization that was likely premature for configuration file handling.
Context
The original load_config() function stored parsed config and its SHA-1 fingerprint in module globals to avoid re-parsing unchanged files. This added complexity and hidden state that could cause cache staleness issues.
Root Cause
The fast-path optimization was unnecessary overhead for configuration files that:
- Are small (typically < 1KB)
- Are read infrequently (once per session or on demand)
- May change externally between calls
The cost of hashing and comparing fingerprints likely exceeded the cost of simply parsing the JSON.
Changes
- Removed
_config_fingerprintand_config_cachemodule-level globals - Simplified
load_config()to read and parse file directly - Changed
save_config()return type frombooltoNone(always returnedTrue) - Changed
set_default_model()return type frombooltoNone - Removed dead
except ConfigurationError: raisecode inset_default_model()
Behavioral Impact
- Config loading is now simpler and more predictable
- No functional change in behavior - callers already handled
Nonereturns and exceptions - Slightly more straightforward debugging with no hidden cache state
Related Cards
- [[utils]] - Parent system