language
language copied to clipboard
Detecting if a tuple cycle is "recursive"
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]
--–
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]
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