Skip to content

vol2: ChangeSet delta not passed to EvaluationEngine — engine always does full rebuild #6724

@mdproctor

Description

@mdproctor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions