Solution turns out to be beautifully simple (encoded in a custom DSL I'm developing)
@dave.dixon I think that works. The only caveat is just that there are a few outstanding issues with RHS retract!
. There are some edge cases with how they may work with logical insertions. I think it doesn’t typically come up.
https://github.com/cerner/clara-rules/issues/229
https://github.com/cerner/clara-rules/issues/321
I mention both in http://www.metasimple.org/2017/12/23/clara-updating-facts.html
Other than that though, the rules above seem reasonable. That is something I’d expect should work. To the point @zylox made: It looks like you do have some sort of external retract that is removing the ActiveArticle
in your example.
Ya, i was approaching it from the perspective of using truth maintenance for it because of the "outside of a rule RHS?". glad you found something that works for you.
Yes, ActiveArticle
is removed externally. It does work nicely.
::handle-cancelled-response
is arguably just "nice to have", catches the case of ActiveArticle
changing before the response to the comments request is received. If one ran into the edge-cases around retract!
I think you could just have some sort of periodic clean-up of dangling CommentsResponse
facts.
I like it overall. I really would like to try to get the edge cases of retract!
removed. The issue it has is mostly how it interacts with the truth maintenance of other rules that are firing in the same “cycle”
The removal of the CommentsResponse
cleans up all the Comment
due to truth maintenance, which is nice.
Oh, I guess the ActiveArticle
does too - woops. But either way, it is nice to be able to cleanup old facts liek that