language icon indicating copy to clipboard operation
language copied to clipboard

Detecting if a tuple cycle is "recursive"

Open willvedd opened this issue 7 months ago • 0 comments

Description

This PR introduces detection of "recursive cycles" which are subsets of tuple cycles. These are cycles that are self-referential and only include one node of specific type and relation. This detection enables downstream query planning operations that require knowledge of these recursive cycles versus regular tuple cycles.

Examples

There are two types of "recursive cycles" – usersets and TTU, both self-referential.

Userset This is a recursive cycle because the group#member relation references itself.

model
  schema 1.1
type user
type group
  relations
    define member: [user, group#member]
Screenshot 2025-05-27 at 3 58 52 PM

--–

TTU This is a recursive cycle despite the intermediate union operation; there is still only one node of specific type and relation.

model
  schema 1.1
type user
type group
  relations
    define member: [user] or member from parent
    define parent: [group]
Screenshot 2025-05-27 at 3 59 11 PM

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 27 '25 20:05 willvedd