Skip to content

Rust resolver diverges on allRule with null/missing lists (vacuous truth) #338

@nicklasl

Description

@nicklasl

Summary

The Java resolver treats "all elements of an empty/null/missing collection satisfy condition X" as vacuously true (the standard logical convention). The Rust resolver treats it as non-matching. This affects targeting rules that use allRule when the context attribute is absent or null.

Affected test cases

1. all_rule_null_list

  • Context: The list attribute is explicitly null.
  • Java: MATCH — an allRule over a null list is vacuously true.
  • Rust: NO_SEGMENT_MATCH.

2. all_rule_missing_field

  • Context: The list attribute is missing entirely from the evaluation context.
  • Java: MATCH — an allRule over a missing field is vacuously true.
  • Rust: NO_SEGMENT_MATCH.

3. not_all_null_list

  • Rule: NOT(allRule) with a null list.
  • Java: NO_SEGMENT_MATCH — the inner allRule is vacuously true, so NOT inverts it to non-match.
  • Rust: MATCH — the inner allRule doesn't match, so NOT inverts it to match.

4. not_all_missing_field

  • Rule: NOT(allRule) with the field missing from context.
  • Java: NO_SEGMENT_MATCH — same reasoning as above.
  • Rust: MATCH — same reasoning as above.

Expected behavior

Vacuous truth is the standard logical convention: "for all X in S, P(X)" is true when S is empty. This is the behavior the Java resolver implements. The Rust resolver should match this to ensure consistent targeting behavior regardless of which resolver implementation is used.

Validation

For each fixed test case, remove the "rust" override key from its expectedResult in tests.json. The test should then pass using the "general" expectation, confirming the Rust resolver now matches Java's behavior. Run make -C confidence-resolver test to verify.

Spec test reference

These test cases are tracked in the spec test tests.json files with "rust" override keys that document the divergent behavior. See the test names listed above.

Related

These divergences were discovered while adding conformance tests from the Java resolver (PR #335).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions