jruizgit / rules

Durable Rules Engine
MIT License
1.14k stars 209 forks source link

Correct way to handle rules triggered by current and previous rules/facts #365

Open charlesjankowski opened 3 years ago

charlesjankowski commented 3 years ago

Hi,

I was wondering the correct way in durable-rules to have the notion of "fire this rule if the m.something == X (the simple case) AND any of a number of previously fired rules is Y". I keep track of all the previously fired rules in a list as part of c.s (Do I need to do that?). Are c and/or s available during simple antecedents? When I try and use them, I get errors that they are not defined. Not sure events are correct since they can only be tested once. I can't guarantee the order of when previous rules were fired so I'm not sure contexts are totally right either.

Thanks!

jruizgit commented 3 years ago

Hi, thanks for asking the question. I would assert a fact "rule Y has been fired" when rule Y is fired. Then write a rule "when something is X and rule Y has been fired". I'm not 100% sure this will work for your scenario. Hope this helps.