test: cover newly-stabilized logout, MCP-over-ACP, and Error edge cases - #7
Draft
cursor[bot] wants to merge 3 commits into
Draft
test: cover newly-stabilized logout, MCP-over-ACP, and Error edge cases#7cursor[bot] wants to merge 3 commits into
cursor[bot] wants to merge 3 commits into
Conversation
Co-authored-by: QuantuM <qumusai@proton.me>
Co-authored-by: QuantuM <qumusai@proton.me>
Co-authored-by: QuantuM <qumusai@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Risky behavior now covered
Three areas that recently changed or had thin coverage and would silently regress on the wire if anything shifted:
#[cfg(feature = "unstable_logout")]gates. Wire-format pinning,_metaround-tripping,AGENT_METHOD_NAMES.logout/ClientRequest::method()linkage, default-on-error tolerance onAgentAuthCapabilities::logout, and threading throughAgentCapabilities.auth.agent.rs. The actualmcp.rstypes (ConnectMcp{Request,Response},MessageMcp{Request,Notification,Response},DisconnectMcp{Request,Response}) had no serialization tests. Particularly important: the docs-stated invariant that omittedparamsand explicitnullparamsMUST both decode toNone, and thatMessageMcpResponse(a transparentArc<RawValue>wrapper) forwards inner MCP results verbatim.Errorhad onlyErrorCodenumeric round-trip coverage. TheDisplayimpl (empty-message fallback, pretty-printeddatasuffix),From<serde_json::Error>(InvalidParams+ message indata),From<anyhow::Error>downcast behavior (the bug-prone branch that must preserve an inner ACPErrorinstead of re-wrapping it asInternalError),into_internal_error, andresource_not_found(uri)with/without URI were all untested.Test files added/updated
src/v1/error.rs— 11 new tests forError::Display, conversions, constructors, andresource_not_foundURI attachment.src/v1/agent.rs— 7 new tests for the stabilized logout method,LogoutRequest/Response/Capabilities, andAgentAuthCapabilities(including the malformed-field tolerance behavior baked in byDefaultOnError).src/v1/mcp.rs— newtestsmodule with 11 tests pinning the MCP-over-ACP wire format end-to-end.src/v2/{error,agent,mcp}.rs— mirrored tests in the v2 scaffold so the parallel module can't drift silently.Net:
+60tests (268 → 328with--all-features;41 → 60default features).cargo test --lib,cargo test --lib --all-features,cargo clippy --all-features, andcargo fmt --checkall pass.Why these tests materially reduce regression risk
#[cfg]flags often silently lose test coverage; pinning the wire name ("logout"), the{}request/response shape, the_metaround-trip, the "supplying{}means supported" capability convention, and theDefaultOnErrortolerance closes that gap before any client integrates against it.skip_serializing_none+Option<Map>), or method-name constants (mcp/connect,mcp/message,mcp/disconnect) would silently break every IDE/agent pair. The "omitted vs explicit null params" test specifically guards a documented invariant that's easy to lose during refactors.Errorconversions are infrastructure for every method. Theanyhow::Errordowncast in particular is the kind of subtle code that's easy to "fix" into re-wrapping behavior; the new test makes that an immediate failure. TheDisplayimpl handles two formatting branches (empty message,datasuffix) that could regress to a bare numeric string or panic ondataformatting.All tests are deterministic, self-contained (
serde_jsononly, no I/O, no concurrency), and run in the existingcargo test --libpipeline.Summary by cubic
Add tests to pin the wire format and behavior for the stabilized logout method, MCP-over-ACP connect/message/disconnect, and
Errorconversions/formatting across v1 and v2. Tests only; no runtime changes."logout",{}request/response,_metaround-trip, capability advertising via{}, andDefaultOnErrortolerance inAgentAuthCapabilities/AgentCapabilities."mcp/connect","mcp/message","mcp/disconnect");ConnectMcp*/MessageMcp*/DisconnectMcp*serialization; omitted vsnullparamsboth decode toNone;MessageMcpResponseforwards inner JSON verbatim;_metaround-trip.Display(empty message falls back to code; prettydatasuffix);From<serde_json::Error>→InvalidParamswith message indata;From<anyhow::Error>preserves inner ACPErrorelseInternalError;into_internal_error;resource_not_foundwith/without URI; numeric code and JSON-RPC object shape pinned.Written for commit 6adb0fe. Summary will update on new commits.
Note
Add tests covering logout, MCP-over-ACP, and Error wire behavior for v1 and v2
LogoutRequest/LogoutResponse) andAgentAuthCapabilitiesin both src/v1/agent.rs and src/v2/agent.rs, includingDefaultOnErrortolerance for malformed logout values.RawValuepreservation.ErrorCodeandErrorbehaviors in src/v1/error.rs and src/v2/error.rs: numeric conversions, constructor codes,Displayoutput,From<serde_json::Error>andFrom<anyhow::Error>mappings, and JSON-RPC object serialization shape.Macroscope summarized 6adb0fe.