feat(a2a-nats): server-side wire framing and a2a-error type - #302
Conversation
JSON-RPC request/response/error envelopes plus the A2aError type that handler implementations return — the wire surface every per-operation PR will share. The A2aExecutor trait itself grows method-by-method as each operation lands separately, so this slice ships only what every operation needs unconditionally. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
PR SummaryLow Risk Overview The workspace pins
Reviewed by Cursor Bugbot for commit 698ff38. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning Review limit reached
More reviews will be available in 24 minutes and 25 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughAdds an ChangesA2A-NATS Server Module
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b019461. Configure here.
Code Coverage SummaryDetailsDiff against mainResults for commit: 698ff38 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Coverage gate flagged 6 new uncovered lines for the Display impl in jsonrpc.rs once PR5 surfaced the file in the diff baseline. Add the display test covering all three variants. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Cursor Bugbot caught that #[serde] on Option<JsonRpcId> conflates an explicit null id (a request whose response carries id:null) with an absent id field (a notification — no response). Use a custom deserializer that maps json null to Some(JsonRpcId::Null) and serde's default to None, so the bridge can route replies correctly. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rsworkspace/crates/a2a-nats/src/server/handler.rs`:
- Around line 21-31: The A2aError::new factory method accepts any i32 for the
code parameter without validation, allowing invalid JSON-RPC/A2A error codes to
be constructed. Replace the raw i32 code parameter and field in the A2aError
struct with a dedicated value object or enum that represents only valid error
codes, then update the A2aError::new method to accept this restricted type
instead. This ensures invalid codes are unrepresentable at construction time.
In `@rsworkspace/crates/a2a-nats/src/server/wire.rs`:
- Around line 29-42: In the deserialize_optional_id function, the map_err
closure on the final line is discarding structured error context by converting
the serde_json::Error to a String via to_string(). Instead of calling
e.to_string(), pass the error directly to the custom() method since
serde::de::Error::custom accepts anything implementing Display. Use &e or a
similar approach that preserves the typed error context rather than converting
it to a string first.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 72dbaa14-f9c2-4abf-99e2-6d79297a064f
⛔ Files ignored due to path filters (1)
rsworkspace/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
rsworkspace/Cargo.tomlrsworkspace/crates/a2a-nats/Cargo.tomlrsworkspace/crates/a2a-nats/src/jsonrpc.rsrsworkspace/crates/a2a-nats/src/lib.rsrsworkspace/crates/a2a-nats/src/server/handler.rsrsworkspace/crates/a2a-nats/src/server/mod.rsrsworkspace/crates/a2a-nats/src/server/wire.rs
…ches Coverage gate flagged trogon-scheduler dispatcher.rs non-deterministically (varies +1 to +4 missed lines per run) because four branches were only reachable via tokio task races. Extract two helpers (flush_pending_reports and resolve_ready_key) and unit-test each branch directly; the run loop keeps byte-identical runtime semantics. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
coderabbitai feedback: pass the serde_json::Error directly to serde::de::Error::custom instead of .to_string() so structured error context survives the conversion. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
coderabbitai flagged A2aError::new accepting raw i32. Documented as the explicit escape hatch with a follow-up to introduce a typed A2aErrorCode value object once the protocol-stream crates stabilize. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>

A2aErrorand emits the same JSON-RPC envelope shapes; lifting them out of any specific operation lets each per-op PR focus on its method signature and dispatch case without re-deriving the wire framing in every review.a2a(=a2a-lf) workspace dep that downstream a2a-nats slices (handler trait, stream responses, agent-card schema) will reach for; centralizing the version pin here keeps the upstream-protocol upgrade path mechanical.