-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial support for Intersection arrow #1937
Conversation
41f0eb8
to
44c6555
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks really good!
I'm mostly concerned about test coverage for more complex schemas, though I think there's some low-hanging performance fruit as well.
tuple.MustParse("document:doc2#parent@folder:folder2-2"), | ||
tuple.MustParse("document:doc2#parent@folder:folder2-3"), | ||
tuple.MustParse("folder:folder2-1#viewer@user:tom"), | ||
tuple.MustParse("folder:folder2-2#viewer@user:tom"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a 0
case: a document that is in no folders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
), | ||
}, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any test cases for (not just for LR, the other methods too):
- an
all
over a recursive relationship - an
all
that is part of an expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
internal/graph/check.go
Outdated
return checkIntersectionTupleToUserset(ctx, cc, crc, child.FunctionedTupleToUserset) | ||
|
||
default: | ||
return checkResultError(spiceerrors.MustBugf("unknown functioned tuple to userset function `%s`", child.FunctionedTupleToUserset.Function), emptyMetadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit/suggestion:
return checkResultError(spiceerrors.MustBugf("unknown functioned tuple to userset function `%s`", child.FunctionedTupleToUserset.Function), emptyMetadata) | |
return checkResultError(spiceerrors.MustBugf("unknown tuple to userset function `%s`", child.FunctionedTupleToUserset.Function), emptyMetadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
func (ce *ConcurrentExpander) expandTupleToUserset(_ context.Context, req ValidatedExpandRequest, ttu *core.TupleToUserset) ReduceableExpandFunc { | ||
type expandFunc func(ctx context.Context, start *core.ObjectAndRelation, requests []ReduceableExpandFunc) ExpandResult | ||
|
||
func expandTupleToUserset[T relation]( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any tests for expand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
internal/graph/lookupsubjects.go
Outdated
it.Close() | ||
|
||
// Wait for all dispatched operations to complete. | ||
if err := g.Wait(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to wait here - since this is an AND
operation, you can just add in the sets as you get them (it's associative and commutative). That should keep memory lower too.
ns.MustFunctionedTupleToUserset("owner", "any", "something"), | ||
)), | ||
ns.MustRelation("thirdwithall", ns.Union( | ||
ns.MustFunctionedTupleToUserset("owner", "all", "something"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some cases in here with expressions containing the fn arrows to make sure they canonicalize the same?
i.e. owner.all(something) + foo
== foo + owner.all(something)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
|
||
case core.FunctionedTupleToUserset_FUNCTION_ALL: | ||
// Mark as a conditional result. | ||
operationResultState = core.ReachabilityEntrypoint_REACHABLE_CONDITIONAL_RESULT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this conditional? I would think it would be marked the same as a regular arrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intersection results in a check being required. This ensures that all
is checked post reachable resources.
} | ||
|
||
// Create a membership set per-subject-type, representing the membership for each of the dispatched subjects. | ||
resultsByDispatchedSubject := map[string]*MembershipSet{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a similar comment on one of the other graph methods, but you don't have to collect up all of the results before you combine them; you can combine as you get responses back.
44c6555
to
1cb8e3d
Compare
Updated |
1cb8e3d
to
263823b
Compare
Adds support for intersection arrow and new syntax for existing arrows.
Existing arrow, two syntaxes:
New syntax for intersection arrow:
The
folder.all(view)
syntax will ensure that a subject is found forview
in all folders for the parent resourceFixes #597