Skip to content

Retain protection across native memory callbacks - #905

Merged
zlareb1 merged 4 commits into
mainfrom
docsrc-d6-llamaindex-tests-20261118
Nov 18, 2026
Merged

zlareb1 merged 4 commits into
mainfrom
docsrc-d6-llamaindex-tests-20261118

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix

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, aflush enters 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

  • Wire, schema, settings and dependencies: unchanged.
  • Automatic callbacks use the application's existing SessionProtection.automatic() scope. Explicit operations remain explicit.
  • Operator steps: none.
  • Rollback: revert the adapter, guide and census changes together.

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.py in 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

  • Original tests and assertions are preserved.
  • Native regressions demonstrate the failure and pass after its correction.
  • Fresh independent review has no unresolved findings.
  • Required CI checks pass on the final head.
  • Commits are signed off.

@zlareb1 zlareb1 changed the title Exercise retained protection in native memory blocks and retrievers Retain protection across native memory callbacks Nov 18, 2026
@zlareb1
zlareb1 marked this pull request as ready for review November 18, 2026 19:40
@zlareb1
zlareb1 merged commit 4d234d5 into main Nov 18, 2026
45 checks passed
@zlareb1 zlareb1 mentioned this pull request Nov 18, 2026
6 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant