RFC: Rule system v2 #3406
Replies: 7 comments 10 replies
-
I like the idea of more specific rule scopes, since most rules in our projects are only used for one of those at a time. I'm not certain that the chicken-egg cart calculation issue would be resolved, though, since the proposed Checkout rules would still affect each other, wouldn't they? Unless the entire flow would be changed. |
Beta Was this translation helpful? Give feedback.
-
I think loop-problems could still exist. E.g. if a promotion is added by a rule but this changes an overall price of the order which changes something else and so on (please correct me if I am wrong). The segregation of scopes is very nice as it allows further and more specific validations of created/applied rules (without adding much complexity because a validation wouldn't have to handle all scopes). The application categories and the order of the application would have to be discussed. |
Beta Was this translation helpful? Give feedback.
-
Hej certainly, performance improvements would be great and as far as I understand this RFC points mostly down to two points:
Please add to my thoughts if I missed a crucial point. The one thing, that is really powerful (mixing contexts: the condition has a different context - eg. cart - as the result-context (e.g. category page)) such as in your example provided
Is something that is really amazing and is a thing that we would miss surely. So coming back to the initial problem statements, what could be alternative solutions:
There are various patterns (such as memoization) which could probably solve this issue as well?! So from a data driven perspective, what is context aka input:
Putting that together into a memoization pattern, and store the desired outcome within this memoized entity could probably solve the performance topic. Of course first calculation would take time. Using well known caching patterns (in-memory, TTL, invalidation) could be used to solve the problem statement on how long and where should this be memoized (such as redis, memcache). I can not forsee how big the memory foodprint would be, so this might imply another problem? On the otherside the memoization of this rules during a storefront session, are usually very shortlived, as common visitor time does not exceed 5-10 minutes in many cases. Maybe even lower. There might be of course cases, where more minutes are appropriate, but if the TTL can be configured for rule-caching on a rule-basis. With this in mind it would be possible to fine tune performance/memory tradeoffs on a rule basis and on the basis of the customers needs. For the other problem statement "endless loop prevention": I can't share any bits right now to this, but there might be patterns available that are commonly used within compilers for languages, that need to take care to handle circular references. As I am not an expert in writing compilers, I can not pinpoint a specific pattern, that helps in detecting & preventing such cases. My point to that is simply, maybe there's a pattern in a different domain, which proves a solid solution which can be applied to the mighty and powerful rule-builder-system as well. Thanks for bringing this topic up for open discussion. Full Disclaimer: My knowledge to the underlying implementation for the current rule builder is very limited. The thoughts presented here merely rely on trying to understand the actual problem statement, and seeking patterns in other domains that might solve this problem, without trying to change the whole system. |
Beta Was this translation helpful? Give feedback.
-
A small example of how we currently use it. Our plugin creates various rules to be used in the rule builder for payment methods. Our rule determines a value via REST that is compared with the value entered in the rule builder. The problem is that this rule may only be executed for a specific event (onFrontendCheckoutFinishOrder) after the customer has confirmed the terms and conditions by clicking on the order button. We therefore had to build a subscriber that now controls the execution of the rule. |
Beta Was this translation helpful? Give feedback.
-
What about a slightly different approach for handling the rule evaluation.
Which will basically mean, rule scopes get a tag applied like for a content rule scope for example
Then in the rule evaluation phase, there could be logic to trigger a set of rule evaluations with their dependency rule scopes. This would keep the awesome dynamic "handle it everywhere" behavior + there could be helpful events for plugin developers to inject their own dependencies. A performance boost will also be kept. Only dependency rule evaluations get executed but not those where a early return happens because of a not applied dependency. If you take it a step further, tags - or better said flags in a individual rule context - can get applied for each rule individually in the administration by orchestrating rule scope dependencies if a user has the right administration permissions. Tags could maybe also have some kind of underlying class where further configurations can get applied for preventing endless loop runs of rule evaluations which are already processed since the last evaluation phase. |
Beta Was this translation helpful? Give feedback.
-
Hey all, I heard from @shyim that there have been some concerns about this RFC at various events. I want to emphasize that we will not be completely removing any functionality from the system. However, our goal is to create a stable and performant base solution that can be easily adjusted to return to the previous feature set. It's crucial for us to establish a solid foundation initially. As consumers of our API, you should only need to add things rather than having to disable unnecessary code from us. Therefore, I want to highlight: Yes, we plan to weaken the Rules by default, but with simple adjustments (php/plugin/.env/.yaml), it should be relatively easy to restore a comparable state. And this can be done concurrently, not months after deprecation or the break! |
Beta Was this translation helpful? Give feedback.
-
See: #3613 |
Beta Was this translation helpful? Give feedback.
-
In this RFC, I would like to discuss how the Rule System should evolve in the coming years.
Current issues
Possible solution
Current rule system will be splitted into three areas content, checkout, flow:
Content rules ...
Checkout rules ...
Flow rules ...
Consequences
The above system is intended to serve as a foundation and standard implementation (also for our SaaS product).
Of course, it will still be possible to manipulate the corresponding input parameters for the different rule types and to individualize them in projects.
Beta Was this translation helpful? Give feedback.
All reactions