Here's my review of crates/system-adapter-protocol for developer experience:
Overall Assessment: Very Good
This is a well-structured, well-documented protocol crate. It's compact (~700 LOC across 3 files), does one thing clearly, and is pleasant to use. Below are the strengths and concrete improvement opportunities.
Strengths
Clean module organization. Feature-gated client/server modules with root re-exports mean consumers write use system_adapter_protocol::{Client, Handler} without navigating internal structure.
Excellent crate-level docs (lib.rs:17-99). The //! docs include a feature overview and two complete, compilable examples (client + server). This is better than most internal crates.
Thorough field-level docs. Metrics structs document units and semantics ("bytes since last scrape", "0.0-100.0"). Every public struct and field has a doc comment.
Ergonomic constructors. impl Into<String> on factories, JsonRpcRequest::new, JsonRpcResponse::success/error, and the ClientBuilder all reduce boilerplate.
Good defaults. Handler::metrics has a default impl returning MetricsResponse::default(), so existing adapters don't break when new methods are added. Handler::rpc_methods is similarly overridable.
Robust server internals. handle_request never returns Err — all failures serialize into JSON-RPC error responses, so the stdio loop is resilient to bad input.
Improvement Opportunities
1. ClientBuilder::with_args/with_env silently no-op on HTTP
client.rs:332-348 — Calling .with_args(...) on ClientBuilder::http(...) compiles and silently does nothing. This is a footgun. Options:
- Return a compile-time error via separate builder types (
StdioClientBuilder / HttpClientBuilder)
- Or at minimum, log a warning / return
Self with a #[must_use] doc note
2. Hardcoded JSON-RPC id: 1
client.rs:160,185,195,205,215 — Every RPC call uses id: 1. This is fine for the current synchronous-per-call pattern but would break under pipelining. Consider an AtomicU64 counter, or at least document the limitation.
3. Handler error type is String
server.rs:79,85,91,101 — All Handler methods return Result<T, String>. This loses structured error information. A custom HandlerError trait (or a generic E: Display) would let adapter implementors carry context, error codes, and source chains.
4. Double error checking in call_typed/call_raw
client.rs:230-233 and client.rs:260-263,284-287 — Errors are checked in call_raw (early return with ClientError::JsonRpc) and again in call_typed. The call_raw check means call_typed would never see an error in response.error, making lines 230-233 dead code.
5. No Shutdown / graceful lifecycle for stdio Client
client.rs:86-87 — _child: Box<Child> keeps the process alive but is never awaited/killed. When a Client is dropped, the child process may linger. A shutdown() or close() method that closes stdin and awaits the child would be cleaner.
6. Missing Cargo.toml description and #![doc = ...]
Cargo.toml has no description field. cargo doc and crates.io summaries would benefit from one.
7. EtlType and AdbcDriver lack Display parity
AdbcDriver implements Display but EtlType does not. Inconsistent for a protocol crate — consumers will eventually need to display ETL types too.
8. AdbcDriver serde has redundant attributes
lib.rs:127-132 — #[serde(rename_all = "snake_case")] on the enum plus explicit #[serde(rename = "flightsql")] on each variant. The rename_all is sufficient; the per-variant renames are no-ops since "flightsql" is already snake_case. Remove one or the other for clarity.
9. Test coverage is thin
- No tests for the full stdio round-trip (spawn a real child process)
- No tests for error paths (parse error, method not found, invalid params)
- No serde round-trip tests for protocol types (especially
DatasetConfig with SchemaRef)
TestHandler in server.rs:282 duplicates the crate-level doc example — could be a shared test fixture
10. No PartialEq/Eq on response types
Protocol types like SetupResponse, QueryMethodResponse, etc. don't derive PartialEq. This makes assertion-based testing harder for consumers. MetricsResponse and its children are also missing PartialEq.
Summary
| Area | Rating |
|---|
| API surface | Great — clean, minimal, feature-gated |
| Documentation | Great — crate-level examples + field docs |
| Error handling | Good — could improve String handler errors |
| Ergonomics | Good — builder + constructors, minor footguns |
| Testing | Needs work — happy paths only, no integration tests |
| Consistency | Minor gaps (Display, PartialEq derive coverage) |
The highest-value changes would be #4 (dead code), #1 (silent no-op builder), and #10 (PartialEq for testability). Want me to implement any of these?