Skip to content

Implement the "use typechecking" directive, annotating the source, and checking against the schema if the types are present #2457

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

barakmich
Copy link
Contributor

No description provided.

@barakmich barakmich requested a review from a team as a code owner June 17, 2025 21:29
@github-actions github-actions bot added area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Jun 17, 2025

permission view: user = viewer
permission edit: user = viewer
permission admin: group = viewer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add additional tests for error cases:

  • : but no type before the =
  • : something |
  • : |

}

// Find existing PERMISSION RelationMetadata and update it, or create new one
for i, metadataAny := range relation.Metadata.MetadataMessage {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this logic into https://github.com/authzed/spicedb/blob/main/pkg/namespace/metadata.go and follow a similar style to there

@@ -77,6 +77,7 @@ message RelationMetadata {
}

RelationKind kind = 1;
repeated string type_annotations = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this under a TypeAnnotations message so we can change it in the future if we want

@@ -103,6 +106,24 @@ func translate(tctx *translationContext, root *dslNode) (*CompiledSchema, error)

// Check for typechecking after all definitions are processed.
if slices.Contains(tctx.enabledFlags, "typechecking") {
resolver := ResolverForCompiledSchema(compiledSchema)
ts := schema.NewTypeSystem(resolver)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done as part of the .Validate call on the type system, rather than the schema translator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants