clara

http://www.clara-rules.org/
2020-05-08T00:17:15.081500Z

That’s probably accurate

ethanc 2020-05-08T00:24:07.084400Z

Ok looking at this, I would say that clara.rules/query(https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules.cljc#L47-L57) could use a bit of validation on the args. As the user provides both the query and key/values to query already it should be pretty straight forward to determine if the map of arguments match that of the params on the query itself. similar to how we validate that the query is in rulebase today: https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules/engine.cljc#L1976 a disjunction between the keys of the params provided and params on the node itself(https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules/engine.cljc#L432) in the event that the user provided more/less the query behaves quite differently as demonstrated in the examples provided. This simply comes down to the implementation of query itself: https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules/engine.cljc#L1978

2👍
ethanc 2020-05-08T00:25:26.084900Z

as it uses bindings to retrieve the tokens from memory

ethanc 2020-05-08T00:26:23.086Z

so the assumption i mentioned above is technically true, and has to be true as it would be inforced by the behavior of the memory

ethanc 2020-05-08T15:50:32.087900Z

I have logged: https://github.com/cerner/clara-rules/issues/454 for the conversation above. Please feel free to add Comments/Concerns, it seems pretty straight forward and if i get time this weekend i might knock it out

oskarkv 2020-05-08T17:09:42.089Z

I'm not completely sure I understand everything you said. Can I only use = in query constraints?

ethanc 2020-05-08T19:37:08.089200Z

yes

ethanc 2020-05-08T19:42:33.094Z

in the context of the query

(= ?x x)
is defining a binding of :?x, when querying the memory of a session the bindings of the query denoted by the query parameters are used. meaning a defquery like:
(defquery some-query
  [:?x]
  [?a <- SomeFact (= ?x x) (= ?y y)])
would use:
{:?x <val>}
to retrieve the values of the query from the session.

ethanc 2020-05-08T19:43:57.095200Z

where value is provided from the clara.rule/query function like:

(r/query session some-query :?x 42)

ethanc 2020-05-08T19:48:30.097900Z

however today clara allows arbitrary values to be provided to the query, like:

(r/query session some-query :?x 42 :?v 1 :?w 2)
this causes the retrieval from memory to miss tokens as it simply assumes that all values passed are valid bindings.