Fork me on GitHub
#clara
<
2023-01-17
>
wparker13:01:49

The inspection tools might also be of interest in a case like this @pdmct depending on what exactly you’re trying to accomplish. http://www.clara-rules.org/docs/inspection/ and http://clara-rules.org/apidocs/0.21.1/clojure/clara.tools.inspect.html#var-inspect, particularly :fact->explanations in the return value from the inspect function. They are designed as a public API, primarily for debugging but it could be used other ways as well potentially. There is more information there than just the rulename as well, such as the facts that caused the insertion. If you want the rulename in the fact for downstream logic in clara or otherwise adding it in the rule RHS seems reasonable. If you have to do a lot of it writing your own macro on top of defrule to make that information available wouldn’t be too difficult I think (or your own function if you use the data-oriented APIs, you don’t have to use the macros) or as Ethan says you could use the internal Clara var (but that could potentially change).

pdmct23:01:29

So I have started using this (I'm not sure why I haven't in the past but oh well) with djblue/portal for inspecting the data. The experience for debugging and working out issues is now really good. I would definitely recommend using portal for debugging and inspecting the session state. (in fact it would make a nice addition to the user docs to add that!) thanks for the reminder.

pdmct21:01:20

thats helpful, thanks