Skip to content

[OMEGA-481] Fix: Plugin module identity - #389

Open
timur-ashkenov wants to merge 5 commits into
singnet:mainfrom
timur-ashkenov:fix/plugin-module-identity
Open

timur-ashkenov wants to merge 5 commits into
singnet:mainfrom
timur-ashkenov:fix/plugin-module-identity

Conversation

@timur-ashkenov

@timur-ashkenov timur-ashkenov commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes #360:

Plugins loaded by file location were not registered in sys.modules, so importing the same plugin elsewhere could create a separate module instance with its own state. This could cause components to use different queues or other shared objects.

This change registers location-loaded plugins in sys.modules, ensuring that subsequent imports reuse the same module and shared state. It also renames the OpenAI plugin to omega_openai to avoid naming conflicts with the OpenAI SDK.

How Has This Been Tested?

Verified shared module state, repeated loading, failure cleanup, name collisions, and Telegram queue sharing.

  • tests/: 138 passed, 4 skipped.
  • Autotests/unit/: 176 passed.

Checklist

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

blackhammer116
blackhammer116 previously approved these changes Oct 14, 2026
@MorozovMisha

Copy link
Copy Markdown

Tested: PR #389 f4cbc74

What I checked:

  • Automated tests:
    • pytest -v tests/ -k "plugin": 22 passed of 22.
    • Verified test_import_returns_loaded_plugin[location], test_import_shares_initialized_state_and_outbox[location], and test_telegram_import_uses_registered_channels_outbox.
  • Module registration:
    • Location-loaded plugins register in sys.modules[name] prior to execution.
    • Direct import <plugin> returns the exact module instance stored in _plugins[name].mod with shared globals and outbox state.
  • Name collision protection:
    • If a module name is already occupied by another file or package on sys.path, _initPythonPlugin aborts with _error rather than silently replacing or shadowing the existing import.
  • Shipped providers compatibility:
    • Built-in provider renamed to providers/omega_openai.py to prevent shadowing the external openai SDK.
  • Documentation:
    • docs/reference-plugin-api.md updated with the module identity lifecycle rules, collision handling, and the omega_openai provider rename notes.

Verdict: PASS.

@timur-ashkenov

Copy link
Copy Markdown
Collaborator Author

@blackhammer116 Could you please re-approve it after merge with main?

@aquashade aquashade removed the in-jira The issue has been accepted for fixing label Oct 16, 2026

This branch has not been deployed

No deployments
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

5 participants