Repository navigation
Retain protection across native memory callbacks - #905
Merged
Merged
Conversation
Signed-off-by: zlareb1 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
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.
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):
Native memory blocks and retrievers retain conversation protection across callbacks. A refused flush leaves its active window available for retry.
Why
Memory blocks and retrievers can outlive constructor and earlier callback contributors. A flush also awaits its native buffer before dispatch, allowing a changed transport binding to hide an entry contributor.
Scope and risk
The existing callback helper retains constructor, earlier and entry contributors before SDK work, authentication, retries and sync-worker dispatch. An existing ambient automatic scope selects automatic protection; explicit calls retain response observers.
Before reading the native buffer,
aflushenters every Loom memory block's scope and retains it through dispatch and archive. Refusal raises without archiving the active window or acknowledging an unsent extraction. Ordinary blocks still receive the same messages, and all started blocks finish before their exceptions propagate. The native framework owns overflow archival; this change does not roll it back.The existing sender census renews only this adapter's reviewed source hash. The shared callback helper resolves entry contributors before taking a lock, then merges them with the latest retained tuple under that lock. Concurrent callbacks cannot overwrite each other's retained contributors; observer resolution and SDK work run outside the lock.
Compatibility, rollout and rollback
SessionProtection.automatic()scope. Explicit operations remain explicit.Tests
The unchanged adapter reproduces 19 retention failures and 26 passes on both hosted dependency legs. The complete 45-case module and all 120 assertions remain byte-identical for the correction; the original 24 test bodies are preserved.
The final combined head passes all 45 cases with llama-index-core 0.14.26 on Python 3.12 in 4.15 seconds and 0.14.0 on Python 3.11 in 3.34 seconds. Strict adapter typing passes on both legs. Reproduce with
python -m pytest sdk/python/tests/test_llamaindex.pyin the native adapter environment.Changed-file Ruff lint, formatting and statement limits, strict adapter typing, guide and census formatting, prose and whitespace checks pass. Source checks preserve all four SDK send-call ASTs and the generic delivery method. No local tests, collection, application imports or dependency installation ran.
Fresh independent review of all five files reports no findings or nits. All 45 check results are terminal: 43 succeed and the two publication jobs are expected skips. All four workflows succeed; all 44 underlying jobs are terminal, with 42 successes and those two publication skips.
AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated: An agent wrote the change. The entire adapter, regression diff, guide addition and census change were read before publication; fresh independent review has no findings or nits, and native execution and full hosted CI pass.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist