feat: First-class multi-instance provider support#41
Merged
Conversation
…stance Cache the resolved entry point (raw mount function) in _loaded_modules, not the config-bound closure. Each load() call now creates a fresh closure wrapping the cached raw function with the current config. This fixes the bug where two provider entries sharing the same module_id but with different configs would silently reuse the first instance's closure, discarding the second config entirely. Changes: - _load_entry_point(): remove config param, return raw mount_fn (no closure) - _load_filesystem(): remove config param, return raw mount_fn (no closure) - _load_direct(): cache raw fn, create fresh closure with current config - load() cache hit: create fresh closure from cached raw fn with current config - load() resolver path: cache raw fn, create fresh closure with current config Tests added (tests/test_loader_cache.py): - test_loader_returns_different_closures_for_same_module_different_config - test_loader_caches_entry_point_resolution - test_loader_backward_compat_single_instance
- Extract instance_id from provider config in both session init paths - After a provider self-mounts under its default name, remap the mount entry to use instance_id as the key when instance_id is specified - Default name is derived by stripping 'provider-' prefix from module_id - Changes applied to both session.py (PyAmplifierSession) and _session_init.py (Rust bridge path) - Add tests/test_multi_instance.py with 5 tests covering: - single instance, no instance_id → no remapping (backwards compat) - instance_id remapping removes default key - two providers same module, different instance_ids, both accessible - session.py path instance_id remapping - session.py path no instance_id, no remap
3 tasks
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.
Summary
Adds first-class multi-instance provider support to the kernel, enabling multiple instances of the same provider module with different configs.
Changes
instance_idsupport — extractsinstance_idfrom mount plan, remaps provider mount names after self-mountinstance_idMount Plan Schema
No Rust changes. No proto changes. No provider module changes required.
Stats
After merge: version bump + tag + push required per release mandate.