Skip to content

(AI) Update schema guidance for code review - #1715

Open
Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 1 commit into
PowerShell:mainfrom
michaeltlombardi:maint/main/update-schema-guidance-for-code-review
Open

(AI) Update schema guidance for code review#1715
Mikey Lombardi (He/Him) (michaeltlombardi) wants to merge 1 commit into
PowerShell:mainfrom
michaeltlombardi:maint/main/update-schema-guidance-for-code-review

Conversation

@michaeltlombardi

Copy link
Copy Markdown
Collaborator

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.

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 AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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/writeOnly usage.
  • 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants