Endless loop
maacl opened this issue · 1 comments
maacl commented
Below results in an endless loop. I would expect the rule to stop matching -> nothing inserted -> steady state after the first match.
I am using:
[org.clojure/clojure "1.10.1"]
[com.cerner/clara-rules "0.20.0"]]
(defrule test-rule
"test guard"
[:not [:guard (= (:active this) true)]]
=>
(do
(println "Inserting guard!")
(insert! {:type :guard :active true})))
(-> (mk-session [test-rule]
:fact-type-fn :type)
(fire-rules))
maacl commented
Got answer from slack:
the rules attempt to find a logical consistency balance
1:30
Your rule Left side condition is invalidated when the right side inserts.
1:31
The engine then retracts that’s fact because it is no longer logically supported.
1:31
It’s called the truth maintenance system
1:31
Then it can activate again and re insert. And again it invalidates itself. So it’s logical looping