Repository navigation
Add API groups with generated documentation and Rust marker traits - #11
Merged
Merged
Conversation
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds groups: named sets of definitions that share a compatibility promise.
sidex.toml:#[group(name = "mobile")]assigns a definition to a group. A definition also belongs to the groups of every definition of the same bundle that uses it, through field types, variant payloads, wrapped and aliased types, type arguments, and#[request]responses. Naming an undeclared group is an error.**Groupmobile:** <description>.group_traits = ["mobile"]generates aMobileGroupMarkermarker trait at the bundle root.[backend.rust.group_trait_names]can override the name, for examplemobile = "MobileApi". The group's records, variants, and wrappers implement the trait, so code can use it as a bound to accept only types of the group.guides/api-groups.md, plus a "Group Marker Traits" section in the Rust generation docs and updates to the attribute and manifest references.Rationale
An API often serves consumers that update on different schedules. For example, deployed devices or installed apps keep using old releases long after a web console has been updated. The definitions those consumers depend on need stronger compatibility promises than the rest. Groups make this visible in schemas and generated code. In Rust, the marker traits also let the compiler enforce it, for example by accepting only types of a
devicegroup in code that serves device clients.Membership extends through use because a promise about a request must also cover the types it sends and returns. Compatibility checks against a group's promise are intentionally out of scope for now.
Notes for Reviewers
spannow holds the span of its name. Before, definition spans were never set. As a result, existing lifecycle and JSON attribute diagnostics now show source locations too.sidex_attrs_api::assign_groups). Generators readDef.groups.group_traits, agroup_trait_namesentry for an unselected group, a name that is not a Rust identifier, and two groups with the same trait name.tests/jsongained a smallgroupsschema.sidex-serde-testsuses it to check that the generated traits compile as bounds. The Python and TypeScript test suites also generate from this bundle.mise run regenerate:api-attrstask for the API attribute types, matching the existing regenerate tasks.Created on behalf of @koehlma by Claude Code / claude-opus-5-5 · Task