clara

http://www.clara-rules.org/
2019-11-05T08:44:40.016300Z

Is this the indentation metadata you’re referring to @dominicm? https://docs.cider.mx/cider/indent_spec.html I’ve generally been satisfied with the default indentation in Cider when writing rules, are there examples of cases where the indentation is strange? My initial instinct if this sort of thing is desired would be to look for/create an extension mechanism for it so various development environments could be supported without everything needing to be in the main codebase (this is orthogonal to whether it would be in the main repo IMO and this could be separately considered).

dominicm 2019-11-05T08:56:07.017400Z

Cursive looked at implementing the spec, I'm not sure if it happened though. It hasn't seen much adoption in other editors.

sashton 2019-11-05T19:34:43.022700Z

I’m trying out Clara right now. Is there a way to get all the current facts from a session? I’ve tried various inspection functions, and come up short. - inspect/explain-activations - fact-graph/session->fact-graph - inspect/inspect I can get most facts from the above functions. What I am missing is facts inserted directly into the session, which haven’t themselves fired any rules. This would be just for debugging the rules, not for production queries. I don’t want to write a query which includes all Fact types, I’m looking for a simple way to enumerate all current facts in the system. Any ideas?

2019-11-05T20:37:37.023300Z

@sashton easiest is a query on Object.

2019-11-05T20:37:43.023600Z

It doesn’t necessary perform well though

2019-11-05T20:37:57.024300Z

Beyond that, it’s been done with hooking into the listeners Api

2019-11-05T20:38:09.025100Z

I don’t think anything out of the box for it. I may be forgetting

sashton 2019-11-05T20:38:26.025700Z

> listeners api I was just exploring that path

2019-11-05T20:38:44.026300Z

If you watch the alpha node activations.

2019-11-05T20:38:48.026500Z

And retractions.

sashton 2019-11-05T20:39:13.027400Z

I’ll try out the Object query, thanks for the pointer. This is only for debugging, so I’m not worried about performance

2019-11-05T20:39:27.027900Z

But there are some complexities involved depending how precise you need it

2019-11-05T20:41:03.028700Z

Object query is straightforward. It’s slow because it always is activated by all working memory changes

2019-11-05T20:41:11.029Z

And remember to fire rules always before running query

2019-11-05T20:41:22.029400Z

They (can) do some batching/lazy stuff they may delay until fire rules.

sashton 2019-11-05T20:43:16.029700Z

Thanks!

2019-11-05T22:04:16.033900Z

On the subject of the query performance, something that may be counterintuitive is that the cost comes from the presence of the query in the rules session, not the query call itself. In essence when fire-rules is called the query results are computed. Agreed that a query on Object is the simplest way to get all facts in the session if the perf hit doesn't matter e.g. in testing.

👍 1
2019-11-05T22:05:04.035300Z

Assuming we're talking about JVM clojure, not sure offhand what the cljs equivalent would be.