language icon indicating copy to clipboard operation
language copied to clipboard

Fix: correctly assign weights for intersections with multiple direct types

Open willvedd opened this issue 7 months ago • 0 comments

Description

Currently, there is a bug when assigning weights to intersection operations involving more than two direct terminal types. Two examples illustrate this issue:

First, the user3 type should be pruned from the edge because that type assignment does not exist on both sides of the and operation. Screenshot 2025-05-28 at 10 36 46 AM

Secondly, and more serious, the types on both sides of the and are balanced but only the user3 weight exists on the edge. Screenshot 2025-05-28 at 10 36 35 AM

NOTE: This changes causes the TestInvalidWeight1NotMatchingTerminalTypes test to fail but it begs the question about what the correct behavior is when types are unbalanced across the and operation; is it better to prohibit the model or quietly prune away the weights?

References

Review Checklist

  • [ ] I have clicked on "allow edits by maintainers".
  • [ ] I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • [ ] The correct base branch is being used, if not main
  • [ ] I have added tests to validate that the change in functionality is working as expected

willvedd avatar May 28 '25 20:05 willvedd