Problem
RuleBaseModifier.apply(changeSet) builds the delta (added/removed rules) but throws it away after accumulating into UnitDescriptor. The engine receives the full UnitDescriptor — all rules ever added — not the delta. Every changeset triggers a full Router + BetaProcessor rebuild.
Current flow
RuleBaseModifier.apply(changeSet)
→ unitDescriptor.addRule(rule) // all rules accumulated
→ compiledEngine = null // invalidate → full rebuild next createUnit()
createUnit()
→ engine.compile(unitDescriptor, rete) // sees ALL rules, full rebuild
Correct design
The ChangeSet IS the diff. RuleBaseModifier.apply() is the right seam to coordinate incremental engine updates — NOT a new method on RuleBase (which stays minimal, see indirection principle).
RuleBaseModifier.apply(changeSet)
→ if compiledEngine exists:
engine.patch(compiledEngine, added, removed, rete)
// Router gets new processors for added rules, removes for removed rules
→ else:
compiledEngine = engine.compile(unitDescriptor, rete) // initial build only
Design context
RuleBase intentionally exposes no mutation methods — all changes go through RuleBaseModifier. This is the vol2 "one degree of separation" principle: RuleBaseModifier owns changeset coordination and engine patching; RuleBase holds compiled state only. This avoids the vol1 mistake of coupling session creation directly to KieBase, which made the API impossible to refactor.
Also connects to
Refs #6712, #6718
Problem
RuleBaseModifier.apply(changeSet)builds the delta (added/removed rules) but throws it away after accumulating intoUnitDescriptor. The engine receives the fullUnitDescriptor— all rules ever added — not the delta. Every changeset triggers a fullRouter+BetaProcessorrebuild.Current flow
Correct design
The
ChangeSetIS the diff.RuleBaseModifier.apply()is the right seam to coordinate incremental engine updates — NOT a new method onRuleBase(which stays minimal, see indirection principle).Design context
RuleBaseintentionally exposes no mutation methods — all changes go throughRuleBaseModifier. This is the vol2 "one degree of separation" principle:RuleBaseModifierowns changeset coordination and engine patching;RuleBaseholds compiled state only. This avoids the vol1 mistake of coupling session creation directly toKieBase, which made the API impossible to refactor.Also connects to
compile()naming concern —compile()implies a full build; an incremental operation needs a different verb (patch()?update()?)Refs #6712, #6718