Code-generate inbound (server→client) RPC dispatch for the Rust SDK
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- rust, typescript
- Lĩnh vực
- api, backend-api-design, tooling
Hướng nghiên cứu
Bắt đầu với scripts/codegen/rust.ts và so sánh việc phát sinh inbound trong scripts/codegen/{csharp,go,python,typescript}.ts. Sau đó kiểm tra rust/src/canvas_dispatch.rs, rust/src/session_fs_dispatch.rs và rust/src/copilot_request_handler.rs, đồng thời giữ nguyên các traits mang tính ergonomic và streaming bridge. Hoàn thành có nghĩa là các inbound traits và dispatch được sinh tự động thay thế các matches viết thủ công, trong khi cargo build, clippy và toàn bộ Rust e2e suite vẫn vượt qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Background
The SDK protocol has two directions of RPC:
- Outbound (client→server): the SDK calls into the runtime.
- Inbound (server→client): the runtime calls back into the SDK — e.g.
clientSession.*(canvas,sessionFs) and the newclientGlobal.*(llmInference) callbacks added in #1689.
For inbound dispatch, the four SDKs split into two camps:
-
C#, Go, Python, TypeScript code-generate the inbound handler scaffolding (handler interfaces + the dispatch/registration glue) from
api.schema.json. Adding theclientGlobalbucket in #1689 required teaching all fourscripts/codegen/*.tsgenerators about it. -
Rust generates only the inbound wire types (
generated/api_types.rs) and method-name constants (rpc_methods::*ingenerated/rpc.rs). The per-group dispatch + handler trait is hand-written, consistently, across all three inbound groups:canvas.*→rust/src/canvas_dispatch.rssessionFs.*→rust/src/session_fs_dispatch.rsllmInference.*→rust/src/copilot_request_handler.rs(dispatch)
Each follows the identical shape: prefix-check → match
rpc_methods::*constant → deserialize generated params → call the hand-written handler trait → serialize the result. -
Java has no codegen pipeline at all (entire RPC surface hand-authored), so it's out of scope here.
Proposal
Bring Rust to parity with the other generated SDKs by code-generating the inbound handler trait + dispatch helper per group into rust/src/generated/, so future inbound callbacks (new clientSession / clientGlobal groups) come for free, as they already do in C#/Go/Python/TS.
Why this is its own PR, not part of #1689
This was investigated during #1689 and deliberately deferred:
-
Do all three groups, not a one-off. Rust's hand-written-dispatch convention is currently uniform across
canvas,sessionFs, andllmInference. Generating onlyllmInference(the group #1689 touches) would trade Rust's internal consistency for cross-SDK symmetry and leave a confusing one-off. The clean change converts all three groups together — a cross-cutting refactor of shipped, well-tested dispatchers and their public trait surfaces (CanvasHandler,SessionFsProvider,CopilotRequestHandler), out of scope for a callbacks PR. -
Generate only the low-level wire trait; keep ergonomic traits + streaming bridges hand-written. The public
CopilotRequestHandler(send_request+open_websocket) does not mirror the wire methods (httpRequestStart+httpRequestChunk); ~1200 lines bridge frame-oriented streaming ↔ that 2-method seam with stateful exchange correlation. Codegen should emit only the thin wire-level trait + dispatch (mirroring what TS generates), with the ergonomic traits and the llmInference bridge staying hand-written. Net hand-written savings are small (≈ the dispatchmatch+ method constants); the value is future-proofing and symmetry, not LOC. -
Validation. The streaming handler is heavily covered by Rust e2e (cancel / error / session-id) record-replay tests that should gate the refactor in CI.
Suggested scope of work
- Add inbound handler-trait + dispatch emission to
scripts/codegen/rust.ts(readclientSession+clientGlobal), emitting intorust/src/generated/. - Migrate
canvas_dispatch.rs,session_fs_dispatch.rs, andcopilot_request_handler.rsto implement/use the generated trait + dispatch instead of their hand-rolledmatch+ local method-name constants. - Keep ergonomic public traits (
CanvasHandler,SessionFsProvider,CopilotRequestHandler) and the llmInference streaming bridge hand-written. - Verify
cargo build+ clippy + the full Rust e2e suite stay green.
References
- PR #1689 (LLM inference callbacks) — where the
clientGlobalbucket and the C#/Go/Python/TS generator changes landed. - Generators with inbound support:
scripts/codegen/{csharp,go,python,typescript}.ts(emitClientGlobalApiRegistration/emitClientSessionApiRegistration). - Rust generator (outbound only today):
scripts/codegen/rust.ts.
- Ngôn ngữ chính
- Java
- Star
- 10.5k
- Fork
- 1.5k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 130
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/copilot-sdk
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2760 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2759 ·
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
github/copilot-sdk#2758 ·
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
github/copilot-sdk#2709 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
github/copilot-sdk#2673 ·
Tất cả issue của github/copilot-sdk
Issue tương tự
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
inu-appcenter/memorIN-backend#288 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
frontend maui-pilot pilot-ask question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Đang mởarea/plugin
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
kestra-io/plugin-kestra#190 ·