fix(website-policy): key blocklist cache on the real default config path

The cache used a '__default__' sentinel as its path key, so switching
HERMES_HOME (profiles, tests) within one process kept serving the stale
policy loaded from the previous home. Key the cache on the actual
resolved default config path instead, so a home/config-path change
naturally misses the cache.

Trimmed from bundled PR #3923 (the other sub-fixes are superseded on
main); authored by @aydnOktay.
This commit is contained in:
aydnOktay 2026-07-04 15:08:49 -07:00 committed by teknium1
parent e670d9cdd6
commit d91083b2f7
No known key found for this signature in database

View file

@ -137,7 +137,8 @@ def load_website_blocklist(config_path: Optional[Path] = None) -> Dict[str, Any]
"""
global _cached_policy, _cached_policy_path, _cached_policy_time
resolved_path = str(config_path) if config_path else "__default__"
default_path = str(_get_default_config_path())
resolved_path = str(config_path) if config_path else default_path
now = time.monotonic()
# Return cached policy if still fresh and same path
@ -193,7 +194,7 @@ def load_website_blocklist(config_path: Optional[Path] = None) -> Dict[str, Any]
if config_path == _get_default_config_path():
with _cache_lock:
_cached_policy = result
_cached_policy_path = "__default__"
_cached_policy_path = resolved_path
_cached_policy_time = now
return result