Skip to content

Fix order-dependent deletion for superset value lists (#260) - #263

Draft
Pybsama wants to merge 1 commit into
aws:mainfrom
Pybsama:codex/fix-superset-value-delete
Draft

Fix order-dependent deletion for superset value lists (#260)#263
Pybsama wants to merge 1 commit into
aws:mainfrom
Pybsama:codex/fix-superset-value-delete

Conversation

@Pybsama

@Pybsama Pybsama commented Jul 30, 2026

Copy link
Copy Markdown

Issue #, if available:

Closes #260

Description of changes:

Machine.deleteRule could silently fail when the supplied rule contained a
superset of the stored values. Values within a field have OR semantics, but
the delete path reused a mutable candidate set across those alternatives and
also used an empty set to mean both "not initialized yet" and "no candidates
matched the preceding keys." The result depended on value order.

This change:

  • tracks candidate-set initialization explicitly;
  • evaluates every value/NameState alternative from the same candidates inherited
    from preceding keys;
  • prevents an empty candidate set at a later key from being reinitialized; and
  • limits an empty branch to that branch instead of skipping the remaining
    alternatives for the field.

The existing multi-NameState wildcard teardown guard remains unchanged.

Testing:

  • Added order-independent reproductions for exact and wildcard value lists.
  • Added prior-key and terminal boundary tests to prevent candidate reinitialization.
  • Added coverage for deleting independent sub-rules with the same rule name.
  • The five focused regressions passed in 20 consecutive runs.
  • mvn -Dtest=MachineTest test: 91 tests passed.
  • mvn verify: 772 tests passed; Checkstyle and SpotBugs reported no findings.

Benchmark / Performance (for source code changes):

Environment:

  • Apple Silicon, macOS 26.5.1
  • OpenJDK 21.0.12
  • Maven 3.9.16

Full comparison command:

./scripts/perf-compare.sh \
  337e8d99026d3f6687f783535f157be8bf4ebbb7 \
  0e0b36545d52b71be24355349a0ce7f314706db0 \
  -- -Dstyle.color=never -Druler.perf.warmup=5 -Druler.perf.measure=10
rule_type                     before_eps     after_eps   delta_pct  verdict
---------                     ----------     ---------   ---------  -------
EXACT                             431543        428359       -0.7%  noise (±2.8%)
WILDCARD                          276394        341981      +23.7%  improvement (noise ±3.2%)
PREFIX                            433777        429462       -1.0%  noise (±2.1%)
PREFIX_EIC                        424932        429335       +1.0%  noise (±9.5%)
SUFFIX                            422192        425125       +0.7%  noise (±4.2%)
SUFFIX_EIC                        421414        422822       +0.3%  noise (±2.3%)
EQUALS_IGNORE_CASE                380035        382514       +0.7%  noise (±2.7%)
NUMERIC                           279480        281772       +0.8%  noise (±1.3%)
ANYTHING_BUT                      250883        242854       -3.2%  REGRESSION (noise ±3.0%)
ANYTHING_BUT_IGNORE_CASE          243198        245030       +0.8%  noise (±2.4%)
ANYTHING_BUT_PREFIX               254955        259433       +1.8%  noise (±2.6%)
ANYTHING_BUT_SUFFIX               254234        252456       -0.7%  noise (±2.6%)
ANYTHING_BUT_WILDCARD             231962        282701      +21.9%  improvement (noise ±1.9%)
COMPLEX_ARRAYS                     55038         54984       -0.1%  noise (±1.7%)

The only full-run flag was ANYTHING_BUT, 0.2 percentage points outside the
script's heuristic noise band. I repeated the whole ANYTHING_BUT family with
5 warmup and 15 measurement passes:

rule_type                     before_eps     after_eps   delta_pct  verdict
---------                     ----------     ---------   ---------  -------
ANYTHING_BUT                      254288        235802       -7.3%  noise (±17.4%)
ANYTHING_BUT_IGNORE_CASE          242591        245506       +1.2%  noise (±1.9%)
ANYTHING_BUT_PREFIX               255447        258124       +1.0%  noise (±7.0%)
ANYTHING_BUT_SUFFIX               251671        251312       -0.1%  noise (±4.5%)
ANYTHING_BUT_WILDCARD             232983        234265       +0.6%  noise (±3.1%)

No matching-throughput regression was reproducible. This change only affects
rule deletion; the benchmark exercises event matching.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Machine.deleteRule with a superset value list can silently no-op depending on value order

1 participant