All,
I'm putting together a proof of concept for using OPA as a rules engine, and I'm running into issues modelling our somewhat simple policies. I seem to be missing the ability to evaluate rules conditionally, based on given criteria - at least in natural language. I can jump through hoops to force the correct evaluation, but I feel as if I'm missing something.
For example, consider the case in which different rules and subrules are enforced based on the class of a subject. So this subject can have a class of A,B,C,D,E only, and I must validate this fact. Then certain rules must be enforced only on classes A,B and C, such as having completed a certain test and further rules on B, such as additional tests based on the age of the subject.
So, in pseudocode, or even natural language, I would put together the following (I show it nested but it could be flat):
the subject must have a valid class
subjects having class A,B or C must be subject to the following rules
rule 1
rule 2
rule 3
subjects having class B must also be subject to the following rules
rule 4
rule 5
The challenge I'm having is that I don't seem to able to evaluate rules only on a certain subset, without including the rest of the classes at the end of the 'any' or 'all' structure and it's becoming really cumbersome. It comes out to something like:
the subjects must have a valid class (evaluates on truth table)
all
any
all
any
The class is A or
The class is B or
The class is C
all
rule 1 and
rule 2 and
rule 3
any (I seem to need to add this to not fail the entire ruleset based on D and E)
The class is D or
The class is E
and
any
all
The class is B and
rule 4 and
rule 5
any (I seem to need to add this to not fail the entire ruleset based on A, C, D and E)
The class is A or
The class is C or
The class is D or
The class is E
Which is really quite messy - am I missing the ability to add any kind of if or conditional functionality? Also, in this model, if we were to add the class of F, which had no rules required to be applied other than it was a valid class, we would have to add it to the logic table (as expected) AND make sure it's reflected in the other logical blocks to make sure we have a positive outcome.
Thoughts? Thanks for reading to the end