Skip to content

feat: Bidirectional link possible between modules#295

Merged
remimd merged 2 commits intodevfrom
bi
Nov 24, 2025
Merged

feat: Bidirectional link possible between modules#295
remimd merged 2 commits intodevfrom
bi

Conversation

@remimd
Copy link
Copy Markdown
Member

@remimd remimd commented Nov 24, 2025

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables bidirectional dependencies between modules by implementing cycle detection mechanisms. Previously, creating circular module dependencies would cause infinite loops during event propagation and broker iteration. The implementation adds duplicate detection for event propagation and uses a visited set to prevent infinite recursion when iterating through module hierarchies.

Key Changes

  • Added cycle detection in event propagation through the is_duplicate property on ModuleEventProxy
  • Modified _iter_brokers to use a visited set, preventing infinite recursion in bidirectional module relationships
  • Changed initialization order in ProfileLoader.__init_subsets_for to mark modules as initialized before processing their subsets

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/loaders/test_profile_loader.py Adds test case verifying bidirectional profile loading works correctly
tests/core/test_module.py Adds test case confirming bidirectional module usage generates expected events
injection/loaders.py Marks modules as initialized before processing subsets to prevent infinite recursion in circular dependencies
injection/_core/module.py Implements core cycle detection: adds is_duplicate, origin, and proxy_history properties to ModuleEventProxy; modifies _iter_brokers to track visited modules; updates on_event to return None for duplicates; enhances UnlockCalled event with module reference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@remimd remimd merged commit 68a368e into dev Nov 24, 2025
6 checks passed
@remimd remimd deleted the bi branch November 24, 2025 12:58
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.

2 participants