Skip to content

Add shared round-trip corpus + wire-fidelity fixes (Swift/Rust/Kotlin)#204

Open
joshmouch wants to merge 2 commits into
microsoft:mainfrom
joshmouch:pr/round-trip-corpus
Open

Add shared round-trip corpus + wire-fidelity fixes (Swift/Rust/Kotlin)#204
joshmouch wants to merge 2 commits into
microsoft:mainfrom
joshmouch:pr/round-trip-corpus

Conversation

@joshmouch

Copy link
Copy Markdown
Contributor

Introduce a language-agnostic round-trip test corpus under
types/test-cases/round-trips/ (24 fixtures) and wire each client up to
decode → re-encode every fixture through its real generated types. The
corpus pins forward-compatibility and exact-bit fidelity across clients.

Fidelity fixes driven by the corpus:

  • Rust: SessionStatus becomes a u32 bitset newtype (was a #[repr(u32)]
    enum) so combined flags and unknown forward-compat bits round-trip
    instead of being dropped or rejected. Generated via generate-rust.ts.
  • Kotlin: SessionStatus.rawValue widens Int → Long so an unknown bit at
    or above 2^31 round-trips as a plain JSON integer instead of throwing.
    Generated via generate-kotlin.ts.
  • Swift: open unions (StateAction, Customization, ResponsePart,
    ToolCallState, TerminalClaim, …) decode an unknown discriminant to a
    raw passthrough and re-encode it verbatim instead of throwing or
    emitting {}; ChangesetOperation*Target now encode their kind
    discriminant. Generated via generate-swift.ts; hand-written
    NativeReducer / ToolCallStateExtensions handle the .unknown variant.

Tests: round-trip corpus runners for Go, Kotlin, Swift, and TypeScript,
plus Kotlin bitset tests covering the Long high-bit case. CHANGELOG
entries for the Swift, Rust, and Kotlin clients.

Shares the reducer fixtures with #203 and a follow-up; cleanest to land after #203.

joshmouch added 2 commits June 8, 2026 22:08
Introduce a language-agnostic round-trip test corpus under
types/test-cases/round-trips/ (24 fixtures) and wire each client up to
decode → re-encode every fixture through its real generated types. The
corpus pins forward-compatibility and exact-bit fidelity across clients.

Fidelity fixes driven by the corpus:

- Rust: SessionStatus becomes a u32 bitset newtype (was a #[repr(u32)]
  enum) so combined flags and unknown forward-compat bits round-trip
  instead of being dropped or rejected. Generated via generate-rust.ts.
- Kotlin: SessionStatus.rawValue widens Int → Long so an unknown bit at
  or above 2^31 round-trips as a plain JSON integer instead of throwing.
  Generated via generate-kotlin.ts.
- Swift: open unions (StateAction, Customization, ResponsePart,
  ToolCallState, TerminalClaim, …) decode an unknown discriminant to a
  raw passthrough and re-encode it verbatim instead of throwing or
  emitting {}; ChangesetOperation*Target now encode their kind
  discriminant. Generated via generate-swift.ts; hand-written
  NativeReducer / ToolCallStateExtensions handle the .unknown variant.

Tests: round-trip corpus runners for Go, Kotlin, Swift, and TypeScript,
plus Kotlin bitset tests covering the Long high-bit case. CHANGELOG
entries for the Swift, Rust, and Kotlin clients.
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.

1 participant