-
Notifications
You must be signed in to change notification settings - Fork 290
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
caveat in MemDB datastore #807
Conversation
4edd111
to
dff6f68
Compare
8951238
to
2efc7c2
Compare
d9bea35
to
30d445d
Compare
015507d
to
a972c8e
Compare
instead of using protobuf.Any, we use protobuf.Struct that better maps a map[string]any we move away from the concept of caveat digest and will reference them by name. Anonymous caveats will have a globally-unique name that may likely be the result of performing a digest of the signature and payload we replace "caveat logic" with "caveat expression" we also change the term "predefined variables" with "caveat context" to refer to the state persisted alongside the tuple. these are variables that will be injected at caveat evaluation time as a minor inconvenience the relationship.RelationTuple method now has to return an error, propagated from the call to structpb.NewStruct. That led to changes in all callsites using it.
cavat names are not a good source for database ID. The ID will be used as the foreign key used in in tuples to keep track of caveats.
we are going to punt on anonymous caveats for now as we've found named caveats can fulfil most requirements we've stumbled upon as a consequence the caveat reference is simplified and now we use the caveat id if we ever are to introduce anonymous caveats, we can do a proto oneof between a named caveat ID and an anonymous caveat payload
I couldn't determine why go-memdb does not honor secondary index uniqueness, so I added a safeguard.
this commit removes validating that a caveated tuple references an existing caveat. The controller layer is responsible to maintain the integrity. It also helps avoid duplicated validation across layers
if was formerly named "CaveatReference" in the proto def
77b11ff
to
8a6548b
Compare
max_bytes : 128, | ||
} ]; | ||
|
||
/** expression is the byte representation of a caveat's logic */ |
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 wonder if we should just make this DecodedCaveat
and move it in here...
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.
honestly it's not clear to me what is the design rationale behind the impl
proto package. It feels like both would overlap in responsibility.
this is important in order to provide a good experience in dev tooling
for safety until those datastores implement caveat support
in order to demonstrate snapshot reads the caveat write operation had to be adjusted to support upserts. Thus it's no longer returning an error on duplicate caveats
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.
LGTM
#757
This PR introduces datastore interface to do CRUD operations with Caveats. We choose to start with MemDB because it does not require migrations, it's not meant to be used in production, and thus allows us to start building the graph evaluation logic without requiring modifications to all datastores. Once we've nailed its usage, we can go back to add support in the rest of datastores.
The main design choices are:
Namespaces
definition
ID
.caveat context
, which will be passed along to the caveat evaluator. Think input arguments of a function.