This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-27
Channels
- # announcements (13)
- # asami (12)
- # babashka (65)
- # beginners (62)
- # calva (14)
- # cider (8)
- # clara (11)
- # clj-kondo (16)
- # clojure (86)
- # clojure-europe (12)
- # clojure-gamedev (4)
- # clojure-nl (2)
- # clojure-sg (4)
- # clojure-uk (5)
- # clojurescript (206)
- # clojureverse-ops (11)
- # community-development (7)
- # conjure (12)
- # core-async (2)
- # core-logic (13)
- # cursive (49)
- # datalevin (1)
- # datomic (30)
- # deps-new (3)
- # duct (8)
- # events (5)
- # fulcro (10)
- # helix (5)
- # jobs (1)
- # klipse (5)
- # lsp (178)
- # luminus (1)
- # malli (8)
- # meander (3)
- # membrane (13)
- # missionary (1)
- # nrepl (5)
- # other-languages (4)
- # pedestal (4)
- # reitit (3)
- # releases (1)
- # reveal (27)
- # shadow-cljs (89)
- # tools-build (6)
- # tools-deps (11)
- # vim (2)
- # xtdb (64)
Well… i guess its a known issue: https://github.com/cerner/clara-rules/issues/329 However, the “schema” error seems to have been lost some where in the updates to the compiler. The issue as it stands:
#clara.rules.engine.NegationNode{:id 1,
:condition [:exists {:type Stuff, :constraints []}],
:children (#clara.rules.engine.ProductionNode{:id 2,
:production {:ns-name
:lhs [[:not
[:exists
{:type Stuff,
:constraints []}]]],
:rhs (do
(println "Add stuff")
(r/insert!
(->MakeStuff
(->Stuff "foo")))),
:name "add-stuff"},
:rhs #object[eval9894$fn__9895
0x386ba022
"eval9894$fn__9895@386ba022"]}),
:binding-keys #{}}
This negation node makes no sense… It has no parent, meaning that post session construction it has no interaction with the session. Something equivalent to a rule with no LHS…. just “do” the RHS.Oh. So it's going to run once no matter what? I guess I could test that.
Verified.
The compiler is extracting this portion of the graph all wrong.
One of the telling bits about this one was, when attaching a listener to the session... the log message from the rule is printed prior to the first interaction with the listener.
This is indicative of:
https://github.com/cerner/clara-rules/blob/5098246a80b521ddc82cf483b4caceba635dc426/src/main/clojure/clara/rules/engine.cljc#L2063-L2069
the "left-activate" here is provided with a "default-listener"(No-Op) as its pushing basically a "none token". This sort of bootstrapping is catching nodes without a proper parent, the fact that this is triggering the negation means that the :exist
and its condition are being ignored all together.
Is the workaround to do something like a count
accumulator and test against zero?
The quick solution would most likely be to replace that sort of rule with something closer to:
(r/defrule add-stuff
[:not [Stuff]]
=>
(println "Add stuff")
(r/insert! (->MakeStuff (->Stuff "foo"))))
Ah. That makes more sense anyway. I'll give that a try.
That works. Thank you!
Just for my own edification: why :exists
at all? Does it work in the non-negated case?