Skip to content

Commit 858bf6b

Browse files
authored
Merge pull request #2802 from fermga/copilot/add-ra-propagation-preconditions
Add RA (Resonance) precondition validation and diagnostic tools
2 parents 827b6cd + 2f27058 commit 858bf6b

File tree

4 files changed

+928
-8
lines changed

4 files changed

+928
-8
lines changed

src/tnfr/config/thresholds.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"EPI_IL_MAX",
2222
"VF_IL_MIN",
2323
"DNFR_IL_CRITICAL",
24+
"EPI_RA_MIN",
25+
"DNFR_RA_MAX",
26+
"VF_RA_MIN",
27+
"PHASE_RA_MAX_DIFF",
2428
]
2529

2630
# -------------------------
@@ -83,3 +87,29 @@
8387
# OZ (Dissonance) → IL sequence for controlled stabilization
8488
# This is a warning threshold, not a hard failure
8589
DNFR_IL_CRITICAL: float = 0.8
90+
91+
# -------------------------
92+
# RA (Resonance) Thresholds
93+
# -------------------------
94+
95+
# Minimum EPI for resonance source - RA requires coherent structural form
96+
# According to TNFR theory, resonance propagates existing coherence through
97+
# network connections. Source node must have sufficient EPI to propagate.
98+
EPI_RA_MIN: float = 0.1
99+
100+
# Maximum ΔNFR for resonance - RA requires controlled dissonance
101+
# Excessive reorganization pressure prevents stable resonance propagation.
102+
# Consider IL (Coherence) first to stabilize before applying RA.
103+
DNFR_RA_MAX: float = 0.5
104+
105+
# Minimum structural frequency for resonance - RA requires active νf
106+
# Resonance amplifies νf across the network. Zero νf prevents propagation
107+
# dynamics from occurring. Consider AL (Emission) or VAL (Expansion) first.
108+
VF_RA_MIN: float = 0.01
109+
110+
# Maximum phase difference for optimal resonance - RA prefers phase alignment
111+
# This is a soft threshold (warning only). Larger phase differences reduce
112+
# resonance effectiveness but don't prevent propagation entirely.
113+
# Measured in radians: π/3 ≈ 1.0 rad ≈ 60 degrees
114+
PHASE_RA_MAX_DIFF: float = 1.0
115+

src/tnfr/operators/preconditions/__init__.py

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"validate_transition",
4343
"validate_recursivity",
4444
"diagnose_coherence_readiness",
45+
"diagnose_resonance_readiness",
4546
]
4647

4748

@@ -382,7 +383,16 @@ def validate_coupling(G: "TNFRGraph", node: "NodeId") -> None:
382383

383384

384385
def validate_resonance(G: "TNFRGraph", node: "NodeId") -> None:
385-
"""RA - Resonance requires neighbors to propagate energy.
386+
"""RA - Resonance requires comprehensive canonical preconditions.
387+
388+
This function delegates to the strict validation implementation in
389+
resonance.py module, which provides canonical precondition checks:
390+
391+
1. Coherent source EPI (minimum structural form)
392+
2. Network connectivity (edges for propagation)
393+
3. Phase compatibility with neighbors (synchronization)
394+
4. Controlled dissonance (stable resonance state)
395+
5. Sufficient νf (propagation capacity)
386396
387397
Parameters
388398
----------
@@ -393,14 +403,58 @@ def validate_resonance(G: "TNFRGraph", node: "NodeId") -> None:
393403
394404
Raises
395405
------
396-
OperatorPreconditionError
397-
If node has no neighbors for resonance propagation
406+
ValueError
407+
If critical preconditions are not met (EPI, connectivity, νf, ΔNFR)
408+
409+
Warnings
410+
--------
411+
UserWarning
412+
For suboptimal conditions (phase misalignment, isolated node)
413+
414+
Notes
415+
-----
416+
For backward compatibility, this function maintains the same signature
417+
as the legacy validate_resonance but now provides enhanced validation.
418+
419+
Typical canonical sequences that satisfy RA preconditions:
420+
- UM → RA: Coupling followed by propagation
421+
- AL → RA: Emission followed by propagation
422+
- IL → RA: Coherence stabilized then propagated
423+
424+
See Also
425+
--------
426+
tnfr.operators.preconditions.resonance.validate_resonance_strict : Full implementation
398427
"""
399-
neighbors = list(G.neighbors(node))
400-
if not neighbors:
401-
raise OperatorPreconditionError(
402-
"Resonance", "Node has no neighbors for resonance propagation"
403-
)
428+
from .resonance import validate_resonance_strict
429+
430+
validate_resonance_strict(G, node)
431+
432+
433+
def diagnose_resonance_readiness(G: "TNFRGraph", node: "NodeId") -> dict:
434+
"""Diagnose node readiness for RA (Resonance) operator.
435+
436+
Provides comprehensive diagnostic report with readiness status and
437+
actionable recommendations for RA operator application.
438+
439+
Parameters
440+
----------
441+
G : TNFRGraph
442+
Graph containing the node
443+
node : NodeId
444+
Node to diagnose
445+
446+
Returns
447+
-------
448+
dict
449+
Diagnostic report with readiness status, check results, values, and recommendations
450+
451+
See Also
452+
--------
453+
tnfr.operators.preconditions.resonance.diagnose_resonance_readiness : Full implementation
454+
"""
455+
from .resonance import diagnose_resonance_readiness as _diagnose
456+
457+
return _diagnose(G, node)
404458

405459

406460
def validate_silence(G: "TNFRGraph", node: "NodeId") -> None:

0 commit comments

Comments
 (0)