Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions app/spicedb/concepts/schema/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,35 @@ Examples:
to a _computed_ set of subjects.
</Callout>

### Private/Internal Identifiers

SpiceDB supports using an underscore (`_`) prefix for identifiers to establish a convention for marking definitions, relations, or permissions as "private" or "internal". This is a naming convention only—they are not treated any different at runtime, and they can still be used in relationships and permission checks like
any other identifier.

```zed
definition document {
relation viewer: user
relation _internal_viewer: user // private: internal use only

permission _can_view = viewer + _internal_viewer // private: synthetic
permission view = _can_view // public API
}
```

This convention is useful for:

- **Synthetic permissions**: Permissions that exist only to compose other permissions
- **Internal relations**: Relations not meant to be directly referenced by application code
- **Implementation details**: Parts of your schema that may change without affecting the public API

#### Identifier Rules

- Identifiers can begin with a lowercase letter (`a-z`) or underscore (`_`)
- After the first character, identifiers can contain lowercase letters, numbers, and underscores
- Identifiers must be 3-64 characters long and end with an alphanumeric character
- Valid: `_ab`, `_private`, `_internal_relation`, `_helper123`
- Invalid: `_` (too short), `_a` (too short), `_trailing_` (cannot end with underscore)

## Comments

### Documentation Comments
Expand Down
Loading