Repository navigation
Mastra native memory retains conversation protection - #874
Merged
Merged
Conversation
Signed-off-by: zlareb1 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…tra-memory-session-protection Signed-off-by: zlareb1 <[email protected]> # Conflicts: # tests/unit/session_content_senders.json
Keep the deliberate trace function inside the existing CPU measurement context so collections of prior test heaps do not enter the ratio. Preserve every input and assertion. Signed-off-by: zlareb1 <[email protected]>
5 of 7 tasks
…tra-memory-session-protection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #849
Related: #878
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
Mastra native memory accepts an app-owned conversation capture and retains its protection across asynchronous callbacks, batches and conditional updates.
Why
Native memory calls the Loom client directly. A callback can outlive the context that created it, so choosing its family after hashing or a credential await can lose the family that supplied its content. The storage snapshots the supplied capture and contributing client families before asynchronous work, then carries that scope through every request and continuation. Completed callbacks retain their contributors for later callbacks, so rebinding cannot discard an earlier family.
Scope and risk
LoomMemoryStorageOptions.captureaccepts an optionalSessionCapture. With it, native callbacks are automatic: protected families refuse before dispatch, response marks commit to every contributing family before content returns, and a marked write refuses acknowledgement. Batches, pagination, conditional-update retries and thread timestamp updates stop when protection changes. Earlier writes in a refused batch can remain stored; the adapter provides no transaction.Calls without
captureremain explicitly owned CRUD and retain response observers. Model-selectedloomToolscalls remain explicit. Resource, store and thread IDs identify rows; they cannot restore protection authority. Each automatic storage instance belongs to one end-user and one complete conversation family, whose durable state the app restores.The sender inventory retains the same classifications and body producers. The adapter creates no family or durable backend and makes no client capability declaration.
The deep-key cost check also uses the existing CPU measurement context around its deliberate trace function. This excludes unrelated heap collections while retaining the input sizes, samples and strict cost bound.
Compatibility, rollout and rollback
LoomMemoryStorageOptions.capture; existing explicit CRUD remains supported.Tests
Memorycalls, captured clients, constructor and callback rebinding, credential waits, durable multi-family marking, unavailable protection storage, marked writes, listing continuation, conditional-update conflicts, pending thread touches and explicit CRUD.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated: An agent wrote the change; fresh independent whole-diff review and final-head CI are required before merge.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist