Skip to content

[OMEGA-481] Preserve module identity and reuse cache for location plugins - #386

Closed
Biruktie wants to merge 1 commit into
singnet:mainfrom
Biruktie:fix/plugin-module-identity
Closed

Biruktie wants to merge 1 commit into
singnet:mainfrom
Biruktie:fix/plugin-module-identity

Conversation

@Biruktie

@Biruktie Biruktie commented Oct 7, 2026 •

Copy link
Copy Markdown

Description

Fixes #360.

Python plugins loaded by file location were not registered in sys.modules, which could cause the same plugin to be loaded as multiple module instances when imported elsewhere.

This change:

  • preserves module identity when loading Python plugins by location;
  • reuses an already-cached module when the file path matches;
  • avoids overwriting an existing importable module when a name collision occurs;
  • rolls back module registration when plugin loading fails;
  • adds tests covering module identity, cache reuse, name collisions, and error rollback;
  • updates the plugin API documentation.

How Has This Been Tested?

  • Added tests/test_python_plugin_loader.py covering module identity, cache reuse, module name collisions, and error rollback.
  • Ran py -m pytest tests/test_python_plugin_loader.py.
  • Result: 5 passed.
  • Ran the full test suite with py -m pytest.
  • The full suite could not complete because of 3 test-collection errors related to missing/unavailable dependencies and existing test-module import conflicts:
    • channels.slack could not be imported in Autotests/mock_slack/test_slack_unwrap.py.
    • RealTgDriver could not be imported during Autotests/mock_telegram collection.
    • py_landlock was not installed for profile/test_policy.py.

Checklist

  • PR contains autogenerated code
  • Self-review completed
  • Test scenarios above are passed with the version of the code from PR

@MartinEbner

@Biruktie Biruktie changed the title fix(plugin): preserve module identity and reuse cache for location pl… [OMEGA-360] Preserve module identity and reuse cache for location pl… Oct 7, 2026
@Biruktie Biruktie changed the title [OMEGA-360] Preserve module identity and reuse cache for location pl… [OMEGA-360] Preserve module identity and reuse cache for location plugins Oct 7, 2026
@aquashade aquashade changed the title [OMEGA-360] Preserve module identity and reuse cache for location plugins [OMEGA-381] Preserve module identity and reuse cache for location plugins Oct 15, 2026
@aquashade aquashade changed the title [OMEGA-381] Preserve module identity and reuse cache for location plugins [OMEGA-481] Preserve module identity and reuse cache for location plugins Oct 15, 2026
@aquashade aquashade added the bug Something isn't working label Oct 16, 2026
timur-ashkenov added a commit to timur-ashkenov/OmegaClaw-Core that referenced this pull request Oct 19, 2026
Adapt the import-path collision check proposed in PR singnet#386.
Preserve explicit failure on naming conflicts.

Co-authored-by: Biruktie <BiruktieAsebelign@gmail.com>
@timur-ashkenov

Copy link
Copy Markdown
Collaborator

Hi @Biruktie,
Thanks for the PR and the effort put into this solution. Your check for conflicting modules that are available but not yet imported is a great addition.
We’ve decided to proceed with the parallel PR #389, which also addresses plugin initialization and registry cleanup. We incorporated your import-path collision check into that implementation and credited you as a co-author using Co-authored-by.
I’ll close this PR now to keep the tracker organized. Thanks again for your contribution, and we welcome your future PRs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OMEGA-481] Plugins loaded by location are not registered in sys.modules, so importing one elsewhere creates a second instance

3 participants