Skip to content

[Conductor] Add Rust client API - #4651

Merged
Chase-Rong merged 3 commits into
kvcache-ai:mainfrom
Bourn3z:port/rust-api
Oct 19, 2026
Merged

Chase-Rong merged 3 commits into
kvcache-ai:mainfrom
Bourn3z:port/rust-api

Conversation

@Bourn3z

@Bourn3z Bourn3z commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Expose ConductorClient through a C ABI (conductor_c.h) and wrap it in a safe Rust crate at mooncake-conductor/rust, following the Mooncake Store Rust bindings: bindgen-generated FFI over the C ABI, static linking of libconductor_cpp_core, and C-allocated outputs released by *_free.

  • C ABI: create/destroy, setup/close, health_check, query, register, unregister, get_global_view and list_services. Return codes equal the ErrorCode values, and outputs are left zeroed on failure.
  • Rust crate: ConductorClient (Send + Sync; the C++ client serializes calls on its mutex), typed request/result structs mirroring the Python client, and ConductorError mapped from the C return codes.
  • CMake: WITH_CONDUCTOR_RUST option (OFF by default, requires WITH_CONDUCTOR) adding build_mooncake_conductor_rust{,_tests}.
  • Tests: ConductorCApiTest checks the C ABI against the C++ client on an in-process conductor; tests/minimal_smoke.rs covers server-free errors and, with MC_RUST_CONDUCTOR_RUN_INTEGRATION=1, a round trip against a running mooncake_conductor.

Description

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • Mooncake Conductor (mooncake-conductor)
  • Reshard (mooncake-reshard)
  • Mooncake EP (mooncake-ep)
  • Mooncake PG (mooncake-pg)
  • Integration (mooncake-integration)
  • P2P Store (mooncake-p2p-store)
  • Python Wheel (mooncake-wheel)
  • Common (mooncake-common)
  • Mooncake RL (mooncake-rl)
  • CI/CD
  • Docs
  • Other

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Documentation update
  • Performance improvement
  • Other

How Has This Been Tested?

Test commands:

# Example: bash scripts/run_ci_test.sh

Test results:

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing done (describe below)

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have updated the documentation (if applicable)
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

  • No AI tools were used
  • AI tools were used (specify below)

Expose ConductorClient through a C ABI (conductor_c.h) and wrap it in a
safe Rust crate at mooncake-conductor/rust, following the Mooncake Store
Rust bindings: bindgen-generated FFI over the C ABI, static linking of
libconductor_cpp_core, and C-allocated outputs released by *_free.

- C ABI: create/destroy, setup/close, health_check, query, register,
  unregister, get_global_view and list_services. Return codes equal the
  ErrorCode values, and outputs are left zeroed on failure.
- Rust crate: ConductorClient (Send + Sync; the C++ client serializes
  calls on its mutex), typed request/result structs mirroring the Python
  client, and ConductorError mapped from the C return codes.
- CMake: WITH_CONDUCTOR_RUST option (OFF by default, requires
  WITH_CONDUCTOR) adding build_mooncake_conductor_rust{,_tests}.
- Tests: ConductorCApiTest checks the C ABI against the C++ client on an
  in-process conductor; tests/minimal_smoke.rs covers server-free errors
  and, with MC_RUST_CONDUCTOR_RUN_INTEGRATION=1, a round trip against a
  running mooncake_conductor.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions github-actions Bot added run-ci CI/Build Mooncake Conductor Changes related to mooncake-conductor labels Oct 14, 2026
@Chase-Rong
Chase-Rong self-requested a review October 18, 2026 05:22

@Chase-Rong Chase-Rong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR. The C ABI's memory conventions are consistent (zeroed outputs, counts set right after each allocation, *_free safe on partial/failed outputs) and the Rust Output RAII wrapper is clean.

Verified locally (standalone conductor build + mooncake_conductor server):

  • conductor_test: 250/250 pass, including the 5 new ConductorCApiTest.*
  • cargo build --release --locked, cargo test (lib + tests), cargo fmt --check, cargo clippy --all-targets: clean
  • smoke_round_trip with MC_RUST_CONDUCTOR_RUN_INTEGRATION=1 against a live conductor: pass

Two things I'd like addressed (can be a follow-up PR), plus a few nits inline:

  1. health_check semantics diverge from PyConductorClient.
  2. No CI job builds or tests this crate, so bindgen/build.rs/link regressions would go unnoticed.

@Chase-Rong
Chase-Rong merged commit a4fe839 into kvcache-ai:main Oct 19, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/Build Mooncake Conductor Changes related to mooncake-conductor run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants