(AI) Update schema guidance for code review - #1715
Open
Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 1 commit into
Open
Conversation
This change extends the guidance for library and resources to clarify some best practices for defining types and JSON Schemas. The guidance centers on ensuring we correctly define resource schemas and follow best practices for types defined in the library crates that need to derive `JsonSchema`.
Copilot started reviewing on behalf of
Mikey Lombardi (He/Him) (michaeltlombardi)
September 10, 2026 15:26
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new guidance contains Markdown formatting and Rust attribute syntax issues that could mislead reviewers and break rendered instructions.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR extends the repository’s AI-assisted code review guidance for DSC libraries and resources, focusing on best practices around defining types that derive JsonSchema and authoring resource JSON Schemas/manifests.
Changes:
- Added resource-schema guidance around canonical properties and
readOnly/writeOnlyusage. - Added library guidance for when to inline schemas vs. derive
DscRepoSchema, and when to apply schema transforms for enums.
File summaries
| File | Description |
|---|---|
| .github/instructions/code-review/resource.instructions.md | Adds resource manifest/schema review guidance (canonical properties, readOnly/writeOnly). |
| .github/instructions/code-review/library.instructions.md | Adds library schema/type guidance (inlining, DscRepoSchema, enum transforms). |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+29
to
+33
| - **Inline schemas when possible**: Add the `[schemars(inline)]` attribute to struct and enum type definitions unless they are non-trivial or are used across multiple other types. Never inline types that derive `DscRepoSchema`. | ||
| - **Derive `DscRepoSchema` for all non-inlined types**: Any struct or enum that is not marked with `[schemars(inline)]` should derive `DscRepoSchema` to ensure it is included in the schema catalog. | ||
| - **Add `should_bundle` attribute to root document types**: Any struct that DSC reads directly from user input or outputs to the user should have the `should_bundle` attribute defined as `true` in the `dsc_repo_schema` derive macro helper attribute when deriving `DscRepoSchema` to ensure that consumers can point to a canonically bundled schema when authoring input or validating output. | ||
| - **Add the `idiomaticize_string_enum` transform to string enums**: When deriving `JsonSchema` for string enums, include the `idiomaticize_string_enum` transform in the `schemars` helper attribute to ensure that the JSON Schema is idiomatic. | ||
| - **Add the `idiomaticize_externally_tagged_enum` transform to externally tagged enums**: When deriving `JsonSchema` for externally tagged enums, include the `idiomaticize_externally_tagged_enum` transform in the `schemars` helper attribute to ensure that the JSON Schema is idiomatic. |
Comment on lines
+18
to
+19
| - **Canonical property definitions:** Always define a canonical property in the `properties` keyword with the `$ref` keyword pointing to the absolute URI for the canonical property schema. Always insert the canonical | ||
| property schema in the `$defs` keyword with the absolute URI for the canonical property schema as the key and the schema as the value. |
| - **Canonical property definitions:** Always define a canonical property in the `properties` keyword with the `$ref` keyword pointing to the absolute URI for the canonical property schema. Always insert the canonical | ||
| property schema in the `$defs` keyword with the absolute URI for the canonical property schema as the key and the schema as the value. | ||
| - **Mark properties read-only as needed**: Define the `readOnly` keyword as `true` for properties that the resource can't directly use from user input but will return as part of the output representing the actual state of an instance. Don't define the keyword as `false` for any properties. | ||
| - **Mark properties write-only as needed**: Define the `writeOnly` keyword as `true` for properties that the resource accepts from user input but doesn't return in the output. Always mark secret and credential properties as write-only.Don't define the keyword as `false` for any properties. |
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.
PR Summary
This change extends the guidance for library and resources to clarify some best practices for defining types and JSON Schemas. The guidance centers on ensuring we correctly define resource schemas and follow best practices for types defined in the library crates that need to derive
JsonSchema.PR Context
Adding guidance to AI review to make common schema feedback built into the automated review cycle instead of relying on guidance from specific reviewers who may not review a PR or might forget one or more items in the guidance.