Skip to content

Support experimental schema types in codegen#1267

Merged
stephentoub merged 9 commits into
mainfrom
stephentoub/experimental-types
May 12, 2026
Merged

Support experimental schema types in codegen#1267
stephentoub merged 9 commits into
mainfrom
stephentoub/experimental-types

Conversation

@stephentoub
Copy link
Copy Markdown
Collaborator

Schema definitions can now carry experimental stability independently of RPC methods, but the SDK generators only propagated experimental markers from methods. This adds schema-level experimental handling so generated types surface the same non-stable signal as experimental APIs.

Summary

  • Add a shared isSchemaExperimental helper for schema stability: "experimental" checks.
  • Thread schema experimental metadata through the TypeScript, C#, Python, Go, and Rust generators.
  • Emit language-appropriate experimental markers: C# [Experimental(Diagnostics.Experimental)], TypeScript @experimental, Python/Go comments, and Rust doc warnings.
  • Move the C# experimental diagnostic ID into the SDK namespace so generated RPC and session-event types can reference it without cross-namespace generated usings.
  • Regenerate affected outputs against the repo-imported schema.

Validation

  • cd scripts\codegen && npm run generate
  • cd dotnet && dotnet build .\src\GitHub.Copilot.SDK.csproj --no-restore --verbosity quiet
  • cd go && go build ./...
  • cd nodejs && npx tsc --noEmit
  • cd python && python -c "import copilot"
  • cd rust && cargo check --features test-support

Copilot AI review requested due to automatic review settings May 12, 2026 13:18
@stephentoub stephentoub requested a review from a team as a code owner May 12, 2026 13:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the multi-language code generators to treat JSON Schema definitions marked with stability: "experimental" as experimental independently of RPC method stability, ensuring generated types surface appropriate experimental warnings/annotations across SDKs.

Changes:

  • Add a shared isSchemaExperimental helper and thread schema-level experimental metadata through TypeScript, C#, Python, Go, and Rust generators.
  • Emit language-appropriate experimental markers on generated types (JSDoc/attributes/comments/rustdoc warnings).
  • Move the C# Diagnostics.Experimental constant out of generated RPC code into the SDK namespace for reuse by generated outputs.
Show a summary per file
File Description
scripts/codegen/utils.ts Adds isSchemaExperimental helper for schema-level stability detection.
scripts/codegen/typescript.ts Annotates generated TS types as @experimental when definitions or method shapes are experimental.
scripts/codegen/rust.ts Adds rustdoc experimental warnings for experimental schemas and adjusts generator CLI arg handling.
scripts/codegen/python.ts Adds experimental comments for generated Python enums/classes/unions and RPC type annotation.
scripts/codegen/go.ts Adds experimental comments for generated Go enums/types and session-event surfaces.
scripts/codegen/csharp.ts Propagates schema experimental markers into generated C# attributes and centralizes attribute strings.
rust/src/generated/rpc.rs Regenerated Rust RPC output (import split reflects generator changes).
dotnet/src/Types.cs Introduces Diagnostics.Experimental constant in GitHub.Copilot.SDK namespace.
dotnet/src/Generated/Rpc.cs Removes the generated Diagnostics helper (now sourced from Types.cs).

Copilot's findings

  • Files reviewed: 7/8 changed files
  • Comments generated: 1

Comment thread scripts/codegen/rust.ts Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@stephentoub stephentoub force-pushed the stephentoub/experimental-types branch from 2ed69af to 63358c7 Compare May 12, 2026 14:51
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Generated by SDK Consistency Review Agent for issue #1267 · ● 2.1M

Comment thread scripts/codegen/python.ts
@github-actions

This comment has been minimized.

stephentoub and others added 7 commits May 12, 2026 13:03
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@stephentoub stephentoub force-pushed the stephentoub/experimental-types branch from d64143a to 61abbe6 Compare May 12, 2026 17:11
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Generated by SDK Consistency Review Agent for issue #1267 · ● 925.4K

Comment thread scripts/codegen/rust.ts Outdated
Comment thread scripts/codegen/python.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR threads experimental schema-level annotations through all five SDK code generators (TypeScript, C#, Python, Go, Rust) consistently. Here's a summary of the cross-language findings:

Coverage across generators

Generator isSchemaExperimental on structs/types On enum types On discriminated unions On event data types On event type constants/classes
TypeScript ✅ (via definition scan)
C# ✅ (dataExperimental) ✅ (eventExperimental)
Go ✅ (dataExperimental) ✅ (eventExperimental)
Python ✅ (via emitPyClass) ✅ (eventExperimental)
Rust ✅ (dataExperimental) ✅ (eventExperimental)

One minor observation

In scripts/codegen/python.ts, PyEventVariant.dataExperimental is set in extractPyEventVariants but never directly consumed — the Python generator achieves the same result because emitPyClass independently calls isSchemaExperimental(schema). This is functionally correct but leaves dataExperimental as a dead field, unlike the C#/Go/Rust generators which reference it explicitly. I've left an inline comment with options to clean this up.

Idiom consistency

Language-specific markers are appropriately idiomatic:

  • C#: [Experimental(Diagnostics.Experimental)] attribute
  • TypeScript: /** @experimental */ JSDoc
  • Go: // Experimental: ... doc comment prefix
  • Python: # Experimental: ... comment
  • Rust: <div class="warning"> rustdoc warning block

The refactoring of the C# Diagnostics class from the generated Rpc.cs into Types.cs (hand-authored SDK namespace) is a good move that removes a coupling between generated and hand-authored code.

Overall this PR maintains strong cross-SDK parity. 👍

Generated by SDK Consistency Review Agent for issue #1267 · ● 1.4M ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Generated by SDK Consistency Review Agent for issue #1267 · ● 1.4M

Comment thread scripts/codegen/python.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request May 12, 2026
@stephentoub stephentoub merged commit 81b7b01 into main May 12, 2026
29 checks passed
@stephentoub stephentoub deleted the stephentoub/experimental-types branch May 12, 2026 18:07
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