The SpiceDB VScode extension formats
# spicedb
c
The SpiceDB VScode extension formats
permission view = ((viewer + organisation_wide_access->view) & organisation->view) + public_viewer + edit
to
permission view = (viewer + organisation_wide_access->view & organisation->view) + public_viewer + edit
It removed the set of parenthesis enclosing
viewer + organisation_wide_access->view
That can't be correct right?
y
the formatter is using spicedb's canonicalization - it's taking the text input and turning it into the AST that SpiceDB actually operates on, and then using spicedb's generator code to turn that back into a schema. it's correct in the sense that it's what SpiceDB is actually using. it looks weird because
+
and
&
are set operations, not bitwise or arithemetic operations, and those operations don't have operator precedence in the same way that arithmetic/bitwise operators do. the union and intersection here are read left-to-right by SpiceDB.
j
we also highly recommend breaking complex instructions into sub-permissions
for readability
c
Okay thanks for the clarification! 🙏
I suppose this is the standard in set theory?Nevertheless, perhaps you could consider adding this to the docs? 🙏
y
there isn't really a standard in set theory 😅 it's basically "use parens when clarification is needed," but part of what the SpiceDB formatter does is only keep parentheses that would change the evaluation of the expression. i'll add an issue on the docs repo
c
Oh okay, then it would definitely be nice with a short little section or info box on operator precedence 😄
4 Views