feat: allow underscore prefix for private identifiers#2733
feat: allow underscore prefix for private identifiers#2733ivanauth wants to merge 10 commits intoauthzed:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (74.30%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2733 +/- ##
==========================================
- Coverage 74.35% 74.30% -0.04%
==========================================
Files 483 484 +1
Lines 56954 57307 +353
==========================================
+ Hits 42341 42575 +234
- Misses 11644 11741 +97
- Partials 2969 2991 +22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
641584f to
835c8e9
Compare
docs/schema-language.md
Outdated
There was a problem hiding this comment.
Why are we writing this doc here? This will not get published anywhere. Maybe we should update https://authzed.com/docs/spicedb/concepts/schema instead?
There was a problem hiding this comment.
Thank you, i removed docs from this pr and created a new docs pr.
Document the ability to use underscore prefixes for definitions, relations, and permissions to signal that they are private/internal. This is a naming convention that helps developers distinguish between public API and internal implementation details in their schemas. Related: authzed/spicedb#2733 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Document the ability to use underscore prefixes for definitions, relations, and permissions to signal that they are private/internal. This is a naming convention that helps developers distinguish between public API and internal implementation details in their schemas. Related: authzed/spicedb#2733 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Document the ability to use underscore prefixes for definitions, relations, and permissions to signal that they are private/internal. This is a naming convention that helps developers distinguish between public API and internal implementation details in their schemas. Related: authzed/spicedb#2733 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…n identifiers
Updates regex patterns across all API protos to allow identifiers to
begin with an underscore (`_`). This enables a convention for marking
identifiers as "private" or "internal".
Use cases:
- **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
Example:
```zed
definition document {
relation viewer: user
relation _internal_viewer: user
// Private synthetic permission
permission _can_view = viewer + _internal_viewer
// Public permission
permission view = _can_view
}
```
Companion PR to authzed/spicedb#2733
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
I think if we introduce this, we should enforce that private identifiers cannot be accessed outside the scope of either the definition or the file (in composable schemas) and perhaps even enforce that they cannot be used in API calls |
The schema-language.md file won't be published from this repo. Documentation for underscore prefix identifiers should be added to https://github.com/authzed/docs instead.
b624462 to
48c6e78
Compare
|
@josephschorr good point - do you want me to try adding definition-scoped + API rejection by default? |
…n identifiers
Updates regex patterns across all API protos to allow identifiers to
begin with an underscore (`_`). This enables a convention for marking
identifiers as "private" or "internal".
Use cases:
- **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
Example:
```zed
definition document {
relation viewer: user
relation _internal_viewer: user
// Private synthetic permission
permission _can_view = viewer + _internal_viewer
// Public permission
permission view = _can_view
}
```
Companion PR to authzed/spicedb#2733
7235660 to
94b74be
Compare
6bc0762 to
f4a1810
Compare
Resolve merge conflict in pkg/schemadsl/lexer/lex_test.go by keeping both underscore prefix tests and unicode/singlequoted string tests.
f4a1810 to
0eb64b1
Compare
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The CI was pinning authzed/actions/setup-go to a commit that defaulted to Go 1.25.3, while go.mod requires Go 1.25.5. This caused Go to attempt auto-downloading the 1.25.5 toolchain from the proxy, which fails when the proxy is unreachable (as seen in the postgres 17 consistency test failure due to network timeout). Update the pin from 6cde6aeb (Go 1.25.3) to 882cac02 (Go 1.25.5) across all workflow files.
3d23234 to
ddd8b7b
Compare
Summary
_) for definition, relation, and permission identifiersDescription
This PR implements the feature requested in issue #2066 by updating the identifier regex patterns from
[a-z]to[a-z_]to allow identifiers to begin with an underscore.This is useful for:
Changes
Example Usage
Note
End-user documentation for this feature should be added to authzed/docs at
pages/spicedb/concepts/schema.mdx.Fixes #2066