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.
Scanned 6/1/2026
Install via CLI
openskills install tools-only/X-Skills---
title: Remove global cache state from user_configuration
link: delta/remove-global-cache-user-config
type: delta
path: src/tunacode/utils/config/user_configuration.py
depth: 3
seams: [M] module
ontological_relations:
- relates_to: [[utils]]
- affects: [[user_configuration.py]]
tags:
- utils
- config
- state-management
- cleanup
created_at: 2026-01-12T00:00:00Z
updated_at: 2026-01-12T00:00:00Z
uuid: 3383a720-0203-4a5b-9c1c-7b2f8c4d5e6f
---
## 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_fingerprint` and `_config_cache` module-level globals
- Simplified `load_config()` to read and parse file directly
- Changed `save_config()` return type from `bool` to `None` (always returned `True`)
- Changed `set_default_model()` return type from `bool` to `None`
- Removed dead `except ConfigurationError: raise` code in `set_default_model()`
## Behavioral Impact
- Config loading is now simpler and more predictable
- No functional change in behavior - callers already handled `None` returns and exceptions
- Slightly more straightforward debugging with no hidden cache state
## Related Cards
- [[utils]] - Parent system
No comments yet. Be the first to comment!
Ultra-compressed commit message generator. Cuts noise from commit messages while preserving intent and reasoning. Conventional Commits format. Subject ≤50 chars, body only when "why" isn't obvious. Use when user says "write a commit", "commit message", "generate commit", "/commit", or invokes /caveman-commit. Auto-triggers when staging changes.
Ultra-compressed code review comments. Cuts noise from PR feedback while preserving the actionable signal. Each comment is one line: location, problem, fix. Use when user says "review this PR", "code review", "review the diff", "/review", or invokes /caveman-review. Auto-triggers when reviewing pull requests.
Remove unused code from this project with ultrawork mode, LSP-verified safety, atomic commits. Triggers: remove dead code, dead code, cleanup, remove unused.
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
一个全面的 Claude Code 会话验证系统。