oracle-samples/clara-rules

Expose flag to retain compile-ctx instead of maintaining it

EthanEChristian opened this issue · 1 comments

As part of #381, i added batching to the evaluation of forms generated by the rules. Prior to my changes the compile-ctx was only bound at the time of evaluation and was discarded as it was "no longer needed".

Compile-ctx acts as a way of providing additional information when a portion of a rule fails to compile, for instance an alpha-expr would also provide the constraints that were included in the alpha-expr.

With the changes in #381, instead of discarding the compile-ctx it was instead stored on the rulebase along with the un-eval'd forms for later use with durability. This allows for the compile-ctx to be used as additional data for exceptions in the event that the environment where the rules are being deserialized doesn't maintain a state consistent to that of the pre-serialization one, ex. rules containing symbols being able to be resolved pre-serialization but not post.

At the time, I didn't give much thought to the addition of the compile-ctx but with #419 i noticed that it might be holding unnecessary memory for consumers that will not be using durability or consumers that can provide an identical deserialization environment for durability.

The idea with this issue would be to expose a flag at session construction time that would opt into maintaining this data post rulebase construction.

Now that #423 is merged, I am going to close this issue