The cache returns mutable data structures (dictionaries and lists) directly without copying. This means callers can inadvertently modify the cached data, affecting subsequent calls.
For example:
session1 = bridge.get_current_session()
session1["patterns"].append({"new": "pattern"}) # Modifies cache!
session2 = bridge.get_current_session() # Returns modified data
Consider returning deep copies of cached data to prevent unintended mutations:
import copy
return copy.deepcopy(entry["data"])
Originally posted by @Copilot in #17 (comment)
The cache returns mutable data structures (dictionaries and lists) directly without copying. This means callers can inadvertently modify the cached data, affecting subsequent calls.
For example:
Consider returning deep copies of cached data to prevent unintended mutations:
Originally posted by @Copilot in #17 (comment)