Open riesel opened 2 years ago
Hi @riesel, I believe that at the moment your interpretation is correct. At the moment, there's no way to match a speed rule without inherently violating it.
I think that new interpretation of "match" might work, however it'd have to be clear that things which have matched but have also violated a rule could be "saved" by subsequent rules. So, something like "vehicles which have matched with a previous rule, but have not exceeded its bounds, will not be considered for further evaluation". This is because for count rules, vehicles which have exceeded the bounds may be considered for further evaluation, in order to try and "save" them; I imagine that this may pose issues for speed rules (and perhaps time as well).
I believe at the moment to create a policy which had areas which had more relaxed speed limits, you'd have to take a cookie-cutter approach to the geographies, and ensure that the rules don't overlap.
I think that new interpretation of "match" might work, however it'd have to be clear that things which have matched but have also violated a rule could be "saved" by subsequent rules. So, something like "vehicles which have matched with a previous rule, but have not exceeded its bounds, will not be considered for further evaluation". This is because for count rules, vehicles which have exceeded the bounds may be considered for further evaluation, in order to try and "save" them; I imagine that this may pose issues for speed rules (and perhaps time as well).
In our understanding, this "matching" only works for rules that are evaluated against single vehicles (speed, time) and not a whole fleet (count).
I believe at the moment to create a policy which had areas which had more relaxed speed limits, you'd have to take a cookie-cutter approach to the geographies, and ensure that the rules don't overlap.
Unfortunately the cookie-cutter approach will also have its limitations: Imagine a speed relaxation only during the night, in a specified zone.
Would you be willing to consider this issue further and maybe even accept a MR after we have concluded a possible solution?
@avatarneil What about swapping the order of the rules, such that the restrictive rule covering the LA geography goes first and the relaxed rule goes second? Any devices that were in violation of the LA rule would then be evaluated by the Venice Beach rule, and if they matched, they wouldn't be in violation. But if they didn't match the Venice Beach rule, by still going over 15 mph, they'd be counted as in violation.
We are tying to model a scenario similar to this policy example here. Imagine a speed limit in Venice Beach of 15 mph and in the overarching greater LA we have a speed limit of 10 mph. Difference to the mentioned example is that Venice Beach Rule "relaxes" the regulation instead of being more restrictive.
Looking at mds-core code in packages/mds-compliance-engine/engine/speed_processors.ts we do not see a way to model this scenario accurately. E.g. if we have the Venice Beach Rule first, and greater LA second and than imagine a vehicle driving 11 mph in Venice beach, the first rule would not produce a violation (< 15 mph) but then the second rule would be considered cause the first rule did not "match". The second one would then produce a violation.
You would be able to model this scenario if you interpret the term "match" - mentioned in Order of Operations - differently. A Rule would consist of a regulation (e.g the speed limit) plus conditions (basically everything else but the speed limit, e.g vehicle_type, geography etc). In that case, the vehicle would match the Venice Beach rule without producing a violation. Policy execution would be stopped because of the match.
Did we miss anything or is it just not possible currently to model this scenario? What do you think about the interpretation of "match"?