Here is a simpler example where the behavior differs depending on whether you assert the fact first or load the rules first. This is just a simple fact class with a string variable called field1. I create and assert the fact with the string "hello" for field1, then I load the following rule file:

package com.vsasset.rules.isolate;
import java.lang.String;

rule "simpleDependence"
no-loop true
    when
        a: factA(field1=="hello")
    then
        a.setField1 ("world");
        modify(a);
        System.out.println("a: " + a.getField1());
        TestCase.fireRules();
end
rule "simpleRetract"
no-loop true
    when
        a: factA(field1 == "world")
    then
        retract(a);
        System.out.println("Retracted a");
end


The second rule (simpleRetract) does not print when the initial factA is asserted before the rules are loaded. If the rules are loaded first, then the second rule prints.

To be honest, I'm not sure whether to expect the second rule to print -- does it get immediately de-activated upon the retract so that any further statements are not executed?

In any event, I would expect the behavior to be the same whether I assert factA first or load the rules first.

Am I missing something fundamental? Perhaps I am mis-using the API...

Thanks,
Justine