oracle-samples/clara-rules

Extracted complex negation rules do not respect binding groups

WilliamParker opened this issue · 0 comments

I'd expect the following test case, added to test-complex-negation, to pass:

    ;; Match the nested negation for location ORD but not for MCI.
    (let [end-session (-> s-with-nested
                          (insert
                           (->WindSpeed 10 "MCI")
                           (->Temperature 10 "MCI")
                           (->Cold 20)
                           (->WindSpeed 20 "ORD")
                           (->Temperature 20 "ORD"))
                          (fire-rules))]
      (is (= [{:?l "ORD"}]
             (query end-session nested-negation-with-prior-bindings)))
      (is (no-system-types? end-session)))

However, it fails:

FAIL in (test-complex-negation) (test_rules.clj:1324)
expected: (= [{:?l "ORD"}] (query end-session nested-negation-with-prior-bindings))
  actual: (not (= [{:?l "ORD"}] ()))

Regarding the test case construction, essentially I combined the last two tests in test-complex-negation with different locations and the temperature changed so one set of WindSpeed and Temperature should have the same temperature as the Cold fact as in the last test, but one set wouldn't as in the second to last.

I believe the root cause of this is that the :not condition created by extract-negation to fix #149 doesn't look at the bindings, so a NegationResult from the same rule but a different binding group will still be used.