Skip to content

[Superseded by #204] Widen SessionStatus to a u32 bitset (Rust + Kotlin) — SemVer-major#208

Closed
joshmouch wants to merge 3 commits into
microsoft:mainfrom
joshmouch:pr/rust-sessionstatus-bitset
Closed

[Superseded by #204] Widen SessionStatus to a u32 bitset (Rust + Kotlin) — SemVer-major#208
joshmouch wants to merge 3 commits into
microsoft:mainfrom
joshmouch:pr/rust-sessionstatus-bitset

Conversation

@joshmouch

@joshmouch joshmouch commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🔁 Superseded by #204 (closed 2026-06-10 — not abandoned). #204 carries the same SessionStatus u32 bitset widening (Rust + Kotlin) plus the shared round-trip corpus, and is current with main. This branch was opened on a pre-#211 base, so against current main it would revert #211's reducer _meta propagation; the bitset work has been consolidated into #204 instead.


Widen SessionStatus to a u32 bitset (Rust + Kotlin) — SemVer-major

SessionStatus is 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 any u32. The previous Rust #[repr(u32)] enum (a closed set) and Kotlin Int (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:

  • Rust: SessionStatus becomes struct SessionStatus(pub u32) with named flag constants — combine with |, test membership with .contains(..), read the raw value (including unknown forward-compat bits) with .bits().
  • Kotlin: SessionStatus.rawValue becomes Long (was Int); flag constants are Long literals; serialized as a JSON number.

Both are SemVer-major.

Review note: the types/test-cases/round-trips/ fixtures in this diff are shared with #204 (byte-identical) and deduplicate on merge — they're best reviewed there. This PR's unique change is the widening itself: clients/rust/, clients/kotlin/, scripts/generate-{rust,kotlin}.ts. The two PRs are independent and merge cleanly in either order; this one closes the Rust/Kotlin round-trip gaps against fixtures 004/005/016.

Verification

client result
Rust cargo test 72 passed · cargo fmt --check clean · cargo clippy clean
Kotlin gradlew test --rerun-tasks — 254/254

joshmouch added 3 commits June 9, 2026 14:59
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".
@joshmouch joshmouch force-pushed the pr/rust-sessionstatus-bitset branch from 66f29d4 to 96df695 Compare June 9, 2026 19:31
@joshmouch

Copy link
Copy Markdown
Contributor Author

Closing in favor of #204.

This branch was opened before #211 (reducers: propagate tool call action metadata) landed on main, so when diffed against current main it reverts #211's _meta propagation across TypeScript (types/channels-session/reducer.ts — removes the tcBaseWithMeta helper), Go (clients/go/ahp/reducers.go), and Swift (Reducers.swift), and removes the associated reducer fixtures (deletes 220-toolcall-actions-update-meta.json; strips _meta expectations from 026/070).

#204 carries the same SessionStatus u32 bitset widening (Rust + Kotlin) and the shared round-trip corpus, is current with main (includes #211), and leaves the reducer _meta work intact. Consolidating the bitset + corpus work there.

@joshmouch joshmouch closed this Jun 10, 2026
@joshmouch joshmouch changed the title Widen SessionStatus to a u32 bitset (Rust + Kotlin) — SemVer-major [Superseded by #204] Widen SessionStatus to a u32 bitset (Rust + Kotlin) — SemVer-major Jun 10, 2026
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