Skip to content

fix(sdk-generator): Rust channel leave collision and SSE enum clippy lint - #117

Merged
calvin-archastro merged 1 commit into
mainfrom
fix/rust-channel-leave-collision
Oct 21, 2026
Merged

calvin-archastro merged 1 commit into
mainfrom
fix/rust-channel-leave-collision

Conversation

@calvin-archastro

@calvin-archastro calvin-archastro commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review on ArchCode

Problem and author intent

After the spec refresh (#116) and generator v0.11.12, regenerate-sdk.yml in archastro-rust produced archastro-rust#9, which fails both CI jobs:

  1. error[E0592]: duplicate definitions with name 'leave' in src/generated/channels.rs. The Artifact channel has a client-to-server leave event, and the Rust emitter turned it into a second pub async fn leave next to the lifecycle leave(). fix(sdk-generator): rename channel message methods that collide with leave() #114 fixed this collision for TypeScript and Python only.
  2. Once that was fixed locally, cargo clippy -D warnings failed with large_enum_variant on GetApiV1AgentSessionsAgentSessionStreamEvent in v1.rs. SSE event enums wrap whole models, and types.rs already allows this lint, but the version modules did not.

The goal is that the Rust SDK regenerates from the current spec and passes CI.

What changed

  • rust/identifiers.ts: adds rustChannelJoinMethodName and rustChannelMessageMethodName. A message event that matches leave or one of the channel's join constructors gets a _message suffix (leave_message), the same rule as fix(sdk-generator): rename channel message methods that collide with leave() #114. The wire event stays "leave".
  • The SDK emitter (rust/index.ts) and the contract-test emitter (contract-tests/rust-emitter.ts) both use these helpers, so the generated contract tests call the renamed method.
  • emitVersion adds #![allow(clippy::large_enum_variant)], as emitTypes already does.

Scope: generator only. The Rust SDK output changes; the other languages do not.
Risk: low. Naming changes only for events that would otherwise not compile.
User impact: Rust users call ApiArtifactChannel::leave_message() to push the leave event. leave() still leaves the channel.

Testing

  • New tests in __tests__/backends/rust.test.ts, under "rust channel leave collision" and "allows large enum variants in version modules". The two collision tests fail without the fix.
  • npm test: 431 + 74 pass. npm run build and npm run lint are clean.
  • End-to-end: in a scratch archastro-rust checkout at origin/main, I ran scripts/regenerate_sdk.sh --local <this branch> against the merged spec. Then cargo fmt --check, cargo clippy --all-features --all-targets -D warnings, cargo check --locked --no-default-features --features rustls-tls (the msrv job's command) and cargo test --all-features all pass. The harness-gated contract tests are #[ignore] there, as they are in CI.
  • Not checked: Swift and Go may have the same leave collision. That is a follow-up.

🤖 Generated with Claude Code

…lint

Regenerating archastro-rust from the refreshed platform spec failed to
compile:
- The Artifact channel's client 'leave' event became a second
  `pub async fn leave` next to the lifecycle leave() (E0592). This is the
  Rust half of 9ed4a9b. The message method is now `leave_message`, using
  the same rule as TypeScript and Python. The SDK and contract-test
  emitters share rustChannelMessageMethodName / rustChannelJoinMethodName.
- Version modules now hold SSE event enums that wrap whole models
  (GetApiV1AgentSessionsAgentSessionStreamEvent), which trips
  clippy::large_enum_variant under -D warnings. Version modules now carry
  the same allow as types.rs.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@calvin-archastro
calvin-archastro merged commit 8bef36b into main Oct 21, 2026
2 checks passed
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