OK. It took me a few laps with the debugger to understand what is happening with the following:
rule when $assignment: Assignment($resource: resource) not Booking(resource == $resource) then insertLogical(new Booking($resource)); end
Basically, in the rhs the insertion of the new Booking causes the lhs to be reevaluated, and since in the reevaluation, there IS a Booking, it is retracted. Then the lhs is reevaluated to see that there is NOT a Booking, and so the rhs is run again, and loop and loop and loop.
But what I don't understand, is if I add an update in the rhs like this:
rule when $assignment: Assignment($resource: resource) not Booking(resource == $resource) then update($assignment); insertLogical(new Booking($resource)); end
there isn't a loop. I didn't take the journey with the debugger to answer this question, but am still wondering: why does the update break the infinite loop?
Thanks, John