Version 38



    Module (SVN) name: drools-verifier

    Verifier rules itself (eat our own dog food) to statically analyse and produce a report that can be displayed to the user with info on the quality of a knowledge package

    How it works

    Verifier takes in the Drools resources. Internally it examines the Drools AST. It will break it apart into a flat structure and figures out component relations for the validation rules to reason over.


    Items that the Verifier rules looks for

    1. Range validation (missing ranges, making sure they are all covered)
    2. Missing equality (when there are inequalities, but not equality being catered for)
    3. Redundancy (when 2 rules have the same LHS and RHS - but with different attributes and names possibly)
    4. Subsumption: when there multiple rules that have the same RHS, and the LHS has some overlapping conditions
    5. Rule equivalence (rule A is equivalent with rule B)
    6. Rule incoherence (nothing can meet rule A) - eg if there are some constraints that contradict themselves. (a == b && a != b etc
    7. Warn if excessive use of "eval": if all rules in a set consist entirely (mostly) of eval statements, that is problem
    8. If an eval is used, it should be after any fact patterns are declared.
    9. Check that rule has an action.
    10. Rule optimization
    11. Rules and Patterns that are always satisfied. Pattern( a > b || a <= b )


    Items that the Verifier rules will look for

    These are the items that are planned.


    1. Rule combination
    2. Rule deduction
    3. Rule "compression
    4. Warn for combination explosion: if a rule has multiple fact patterns of  the same type with no constraints, then warn users (it may not be a  problem).
    5. Loop warning: if a rule modifies a fact that is bound on the LHS, and  has no constraints on the LHS, and there is no no-loop attribute, then  warn about a infinite loop.
    6. Excessive use of salience
    7. Rule incompatibility (if x meets rule A then it cannot meet rule B)
    8. Dominance checking (rule A is dominated by ruleSet S if the addition  of rule A does not alter the behaviour of the system, i.e. find  redundant rules)
    9. Rule conflict (rule A and B are in conflict is they cannot be  satisfied simultaneously in a certain circumstance)
    10. Coverage  checking (check whether a rule is defined for a certain circumstance)
    11. Pattern that is not placed in to a variable and has no restrictions.  Like TestPattern(), should probably have an exists or not
    12. Person( age == age ) or Person( age > age ) user is compares two values from two person facts and forgets to use $person1.age in the pattern. There should be a warning for this.


    How the results will be presented

    Verifier returns the VerifierReport object that contains the verifier messages that the verification rules produce.


    • Three Verification message types

      • Notes: needs attention, may be ignored

      • Warnings: possible problem, usually may be an alternative way

      • Errors: needs correction, logical falacy etc.


    How to use

    Ant task




    Using Java




            // Create verifier builder [1]
            VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
            // Create verifier [2]
            Verifier verifier = vBuilder.newVerifier();
            // Add Resources you want to verify [3] 
            verifier.addResourcesToVerify( new ClassPathResource( "TestFile.drl",
                                                                  ThisClass.class ),
                                           ResourceType.DRL );
            // Run the verification rules [4]
            // Get the result object [5]
            VerifierReport result = verifier.getResult();
            // Print the the errors [6]
            for(VerifierMessageBase base: result.getBySeverity( Severity.ERROR ) ){
                System.out.println( base );

    1. Creates the builder. You can pass VerifierBuilderConfiguration as a parameter if you want something else than the default set of verfication rules.
    2. Creates the Verifier
    3. Add the resources you want to verify. In this case we are just verifying one DRL file.
    4. Runs the verification rules
    5. Returns the verifier report object that contains information about all the issues in the TestFile.drl file.
    6. Prints all the errors. There are 3 levels of severity (ERROR, WARNING, NOTIFICATION).


    Some info:
    Esteban's Blog - Guvnor's Field Constraints: