Please have a look at the Rule Development Kit here:
There is also a helpful discussion ongoing here: