mdproctor opened a new issue, #6724:
URL: https://github.com/apache/incubator-kie-drools/issues/6724

   ## Problem
   
   `RuleBase.apply(changeSet)` builds a `ChangeSet` containing the delta 
(added/removed rules), but throws it away after accumulating the rules into 
`UnitDescriptor`. When `EvaluationEngine.compile()` is then called (lazily on 
next `createUnit()`), it receives the full `UnitDescriptor` — all rules ever 
added — not the delta. The engine rebuilds the entire `Router` + 
`BetaProcessor` chain from scratch on every changeset.
   
   ## Current flow
   
   ```
   apply(changeSet)
     → unitDescriptor.addRule(rule)   // all rules accumulated here
     → compiledEngine = null           // invalidate → full rebuild next 
createUnit()
   createUnit()
     → engine.compile(unitDescriptor, rete)  // sees ALL rules, full rebuild 
every time
   ```
   
   ## Correct design
   
   The `ChangeSet` IS the diff. The engine should receive the delta and patch 
the existing `CompiledEngine` incrementally:
   
   ```
   apply(changeSet)
     → if compiledEngine exists:
         engine.patch(compiledEngine, added, removed, rete)
         // Router gets new slot processors for added rules
         // Existing unit instances see new rules immediately (or on next 
context append)
     → else:
         compiledEngine = engine.compile(unitDescriptor, rete)  // initial build
   ```
   
   ## Impact
   
   - For rulesets that never change: no impact (initial compile is fine)
   - For dynamic rule addition/removal: currently O(total rules) per changeset; 
should be O(delta)
   - Also relates to the `compile()` naming concern — `compile()` implies full 
build; an incremental operation needs a different API shape (`patch()`? 
`update()`?)
   
   ## Prerequisite
   
   Proper NotNode/ExistsNode Rete evaluation (#6713) — incremental patching 
requires knowing which processor chains to update, which requires the full Rete 
traversal model.
   
   Refs #6712, #6718


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to