fix(memory): honor read_only on update and recall access times (#7368) - #7369
Vidit-Ostwal merged 4 commits into
Conversation
`Memory.read_only` was enforced only on `remember()` and `remember_many()`. Two other paths still mutated the backing store: - `update()` re-embedded the supplied content and wrote the record back. - `recall()` refreshed `last_accessed` through `touch_records()`, so simply reading a read-only memory left a persistent trace. Both now respect the flag, so a read-only Memory leaves stored records unchanged. `update()` returns the existing record untouched rather than raising, matching the silent no-op behaviour of `remember()`. Explicit deletion through `forget()`/`reset()` is deliberately unaffected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HkDjVYVzHFEj5re9B8JH9p
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesRead-only memory behavior
Suggested reviewers: Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Read-only memory now leaves records and access timestamps unchanged for update and recall operations, while writable behavior remains covered. No merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@lorenzejay Mind taking a look? |
Vidit-Ostwal
left a comment
There was a problem hiding this comment.
Approved. This correctly makes Memory.read_only prevent update writes and recall access-time writes, with focused regression coverage.
Fixes #7368.
Summary
Memory.read_only currently blocks remember and remember_many, but update still rewrites records and recall still persists last_accessed via touch_records. This change makes those two implicit mutation paths honor read_only while leaving explicit deletion through forget and reset unchanged.
Why
A caller using Memory as a read-only retrieval surface should not leave a persistent trace merely by reading. The existing read barrier and reset guards show that the omitted checks were inconsistent with the flag rather than an intentional latency exemption.
Tests