-
Notifications
You must be signed in to change notification settings - Fork 4
Reduce Resource base class coupling to config and global context #425
Copy link
Copy link
Open
Labels
area:corePart of the core Hassette framework, not necessarily user-facingPart of the core Hassette framework, not necessarily user-facingenhancementNew feature or requestNew feature or requestsize:smallQuick win, < 1 hourQuick win, < 1 hour
Milestone
Description
Summary
The Resource base class hardcodes access to Hassette config for cache setup and shutdown timeouts, and the global singleton in context.py enables implicit coupling bypass.
Findings
From the comprehensive codebase audit:
- MEDIUM:
Resource.cacheproperty directly accessesself.hassette.config.data_diranddefault_cache_size(resources/base.py:164-173). Every Resource carries this dependency whether it uses caching or not. - MEDIUM:
Resource.cleanup()accessesself.hassette.config.resource_shutdown_timeout_seconds(resources/base.py:328). - MEDIUM: Global
ContextVarsingleton incontext.pymakes the Hassette instance available globally, enabling any code to bypass the explicit dependency graph.
Acceptance Criteria
- Cache setup moved to an opt-in mixin (only caching-aware resources carry the dependency)
- Shutdown timeout uses a default with optional override, not direct config access
-
context.get_hassette()call sites audited and limited to framework plumbing - Existing tests pass
Audit Reports
- coupling.md — Findings 5, 6
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:corePart of the core Hassette framework, not necessarily user-facingPart of the core Hassette framework, not necessarily user-facingenhancementNew feature or requestNew feature or requestsize:smallQuick win, < 1 hourQuick win, < 1 hour
Projects
Status
Refinement