[Superseded by #204] Widen SessionStatus to a u32 bitset (Rust + Kotlin) — SemVer-major#208
Closed
joshmouch wants to merge 3 commits into
Closed
[Superseded by #204] Widen SessionStatus to a u32 bitset (Rust + Kotlin) — SemVer-major#208joshmouch wants to merge 3 commits into
joshmouch wants to merge 3 commits into
Conversation
b296285 to
66f29d4
Compare
Adds a language-agnostic round-trip corpus under types/test-cases/round-trips/: each fixture is a wire payload that a client decodes into its generated types and must re-encode byte-for-byte (modulo null/empty normalization). Includes harnesses for the Go, TypeScript, and Swift clients plus the Swift encode-fidelity fixes needed to pass them. KNOWN-FIDELITY-GAPS.md documents the two genuine gaps (TS unknown-key passthrough; schema-invalid fixture 019) with per-client drift tripwires. Purely additive: no public type changes. The Rust and Kotlin clients need a SemVer-major SessionStatus widening to round-trip the bitset fixtures losslessly; that lands in a companion PR.
SessionStatus is an unsigned 32-bit wire bitset: named status flags combine bitwise, and a newer host can set forward-compat bits this client version does not model yet. The previous Rust `#[repr(u32)] enum` (a closed set) and Kotlin `Int` (signed, overflows at bit 31) could not hold those bits, so they were lost on decode->re-encode. This widens both: - Rust: SessionStatus becomes a `struct SessionStatus(pub u32)` newtype with named flag constants; combine with `|`, test with `contains(..)`, read the raw value (including unknown bits) with `bits()`. - Kotlin: SessionStatus.rawValue becomes `Long` (was `Int`); flag constants are Long literals; serialized as a JSON number. Both are SemVer-major. Closes the Rust/Kotlin round-trip gaps against the shared corpus (fixtures 004/005/016); their harnesses ride with this change.
…tries to [Unreleased], rename corpus discriminator - Copy byte-identical corpus files from microsoft#204 (fixture 002/003 renamed discriminator to "Unknown", KNOWN-FIDELITY-GAPS.md folded 019 into 017 section). - Rust CHANGELOG: move SessionStatus breaking-change (### Changed) and encode/decode fidelity fix (### Fixed) from [0.3.0] to [Unreleased]. - Kotlin CHANGELOG: same — move SessionStatus rawValue Long breaking-change and decode-fidelity fix from [0.3.0] to [Unreleased]. - Kotlin BitsetEnumTest.kt: fix class-level KDoc "wrappers over [Int]" → "[Long]". - Kotlin TypesRoundTripFixtureTest.kt: update StateActionUnknown and CustomizationUnknown variant-name returns from "JsonElement" to "Unknown".
66f29d4 to
96df695
Compare
Contributor
Author
|
Closing in favor of #204. This branch was opened before #211 ( #204 carries the same |
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.
Widen
SessionStatusto a u32 bitset (Rust + Kotlin) — SemVer-majorSessionStatusis an unsigned 32-bit wire bitset: named status flags combine bitwise, and a newer host can set forward-compat bits a client version doesn't model yet. To round-trip those bits losslessly, the in-memory type must be able to hold anyu32. The previous Rust#[repr(u32)] enum(a closed set) and KotlinInt(signed — overflows at bit 31) couldn't, so unknown/combined bits were silently dropped on decode→re-encode.This widens both as one logical change:
SessionStatusbecomesstruct SessionStatus(pub u32)with named flag constants — combine with|, test membership with.contains(..), read the raw value (including unknown forward-compat bits) with.bits().SessionStatus.rawValuebecomesLong(wasInt); flag constants areLongliterals; serialized as a JSON number.Both are SemVer-major.
Verification
cargo test72 passed ·cargo fmt --checkclean ·cargo clippycleangradlew test --rerun-tasks— 254/254