-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor sub-EPIs as independent nodes for operational fractality #2816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
❌ Deploy Preview for stunning-zabaione-f1f1ef failed. Why did it fail? →
|
Co-authored-by: fermga <203334638+fermga@users.noreply.github.com>
Co-authored-by: fermga <203334638+fermga@users.noreply.github.com>
There was a problem hiding this 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 refactors the THOL operator to create sub-EPIs as independent NFR nodes instead of metadata-only records, enabling operational fractality where sub-nodes can recursively bifurcate and have operators applied to them.
Key changes:
- Sub-EPIs are now created as full NFR nodes with complete state (EPI, νf, θ, ΔNFR)
- Cascade depth computation updated to support recursive multi-level bifurcation
- Backward compatibility maintained through metadata records that reference the actual nodes
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| tests/unit/operators/test_thol_hierarchical.py | Comprehensive test suite covering sub-node creation, recursive bifurcation, hierarchy tracking, and operational fractality |
| src/tnfr/operators/definitions.py | Added _create_sub_node method to instantiate sub-EPIs as independent nodes and updated _spawn_sub_epi to use it |
| src/tnfr/operators/metabolism.py | Enhanced compute_cascade_depth to support true recursive depth computation with independent sub-nodes while maintaining backward compatibility |
Comments suppressed due to low confidence (2)
src/tnfr/operators/definitions.py:1081
- This assignment to 'theta_new' is unnecessary as it is redefined before this value is used.
theta_new = float(theta_new % (2 * np.pi))
src/tnfr/operators/definitions.py:14
- Import of 'cmath' is not used.
import cmath
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| independent NFR nodes rather than metadata, enabling operational fractality. | ||
| References: | ||
| - Issue: #[THOL ARQUITECTURA] Refactorizar sub-EPIs como nodos independientes |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Corrected spelling of 'ARQUITECTURA' to 'ARQUITECTURA' (Spanish) or 'ARCHITECTURE' (English). If this is intentional Spanish, consider keeping it; otherwise use 'ARCHITECTURE' for consistency with English codebase.
| # Ensure ΔNFR hook is set for the sub-node | ||
| # (inherits from graph-level hook, but ensure it's activated) | ||
| if hasattr(G, "graph") and "_delta_nfr_hook" in G.graph: | ||
| # Hook already set at graph level, will apply to sub-node automatically | ||
| pass |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conditional block contains only a comment and pass. Either remove this no-op code or add actual logic if the hook needs to be explicitly activated for sub-nodes. The comment suggests checking but no action is taken.
| # Ensure ΔNFR hook is set for the sub-node | |
| # (inherits from graph-level hook, but ensure it's activated) | |
| if hasattr(G, "graph") and "_delta_nfr_hook" in G.graph: | |
| # Hook already set at graph level, will apply to sub-node automatically | |
| pass | |
| # Ensure ΔNFR hook is set for the sub-node. | |
| # No explicit action needed: if the hook is set at the graph level, | |
| # it will apply to sub-nodes automatically. |
| G.nodes[parent]["epi_history"] = [0.20, 0.50, 0.70] # d²EPI = 0.10 > tau | ||
| SelfOrganization()(G, parent, tau=0.05) | ||
|
|
||
| G.nodes[parent]["epi_history"] = [0.30, 0.60, 0.90] # d²EPI = 0.00 but will show multiple sub-nodes |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states 'd²EPI = 0.00' but this history should not trigger bifurcation with tau=0.05. The calculation is: abs(0.90 - 2*0.60 + 0.30) = abs(0.90 - 1.20 + 0.30) = abs(0.00) = 0.00, which is below the threshold. This test may not create a second bifurcation as intended.
| G.nodes[parent]["epi_history"] = [0.30, 0.60, 0.90] # d²EPI = 0.00 but will show multiple sub-nodes | |
| G.nodes[parent]["epi_history"] = [0.40, 0.60, 0.90] # d²EPI = abs(0.90 - 2*0.60 + 0.40) = 0.10 > tau |
| # Set an accelerating EPI history for the child | ||
| # d²EPI = abs(0.45 - 2*0.30 + 0.10) = abs(0.45 - 0.60 + 0.10) = 0.05 (borderline) | ||
| # Use more acceleration: d²EPI = abs(0.50 - 2*0.30 + 0.10) = 0.10 | ||
| current_epi = float(get_attr(G.nodes[child], ALIAS_EPI, 0.0)) |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable current_epi is not used.
| current_epi = float(get_attr(G.nodes[child], ALIAS_EPI, 0.0)) |
|
|
||
| # Apply operators to child (use valid sequence) | ||
| from tnfr.operators.definitions import Coherence | ||
| initial_epi = G.nodes[child][EPI_PRIMARY] |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable initial_epi is not used.
| initial_epi = G.nodes[child][EPI_PRIMARY] |
| """ | ||
|
|
||
| import pytest | ||
| import networkx as nx |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'nx' is not used.
| import networkx as nx |
| import pytest | ||
| import networkx as nx | ||
|
|
||
| from tnfr.structural import create_nfr, run_sequence |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'run_sequence' is not used.
| from tnfr.structural import create_nfr, run_sequence | |
| from tnfr.structural import create_nfr |
Pull Request: Refactor sub-EPIs as independent nodes
🎯 Intent
Enable operational fractality (Invariant #7) by creating sub-EPIs as independent NFR nodes instead of metadata dictionaries. This allows recursive operator application, hierarchical metrics, and true multi-level bifurcation.
🔧 Changes
Type of Change:
Core Implementation:
SelfOrganization._create_sub_node()- Creates sub-EPIs as full NFR nodes{parent}_sub_{index}epi_historyfor future bifurcationparent_node,hierarchy_levelSelfOrganization._spawn_sub_epi()- Updated to create independent nodes_create_sub_node()instead of storing metadata onlysub_epismetadata listnode_idreference in metadata for cross-compatibilityG.graph["hierarchy"]compute_cascade_depth()- Enhanced for recursive traversalsub_nodeslist for true recursionExample Usage:
🔬 Structural Impact
Operators Involved:
Affected Invariants:
Metrics Impact:
✅ Quality Checklist
Code Quality:
.pyistub files generated/updatedTNFR Canonical Requirements:
Testing:
Documentation:
docs/changelog.d/)Security (if applicable):
make security-audit)🧪 Testing Evidence
Test Coverage:
Health Metrics:
🔗 Related Issues
Closes #[THOL ARQUITECTURA] Refactorizar sub-EPIs como nodos independientes
Related to: #2766, #2767, #2768
📋 Additional Context
Migration Path:
sub_epismetadata list still populated for telemetrysub_nodeslist contains actual node IDssub_nodesPerformance Impact:
Reviewer Notes
Focus areas:
_create_sub_node()initializes all required NFR attributescompute_cascade_depth()correctnessOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.