fix(a2a): wire AgentRegistry into --connect and fix JWS canonicalization - #6209
Merged
Conversation
AgentRegistry had no runtime construction site anywhere outside crates/zeph-a2a's own tests, so card_trust_policy enforced nothing on a running agent. Wire AgentRegistry::discover into `zeph --connect <URL>`, the only outbound A2A client path in the codebase, converting zeph-config's CardTrustPolicy/TrustedAgentKey to zeph-a2a's types via an explicit non-wildcard mapping and hardening the discovery fetch with the same TLS/SSRF posture already applied to the A2aClient connection. Discovery-fetch failure only aborts the connection under the "require" policy; under "ignore"/"prefer" it is tolerated so card-less peers keep connecting as before. Also fix canonical_payload to strip proto3-default-valued fields before JCS canonicalization, matching the A2A spec text, so a signature computed by a signer that strips defaults still verifies against a card transmitted with defaults present. Closes #6200 Closes #6201
bug-ops
enabled auto-merge (squash)
July 13, 2026 03:46
The doc comment referenced CardTrustPolicy::Require without the zeph_a2a:: qualifier the type needs to resolve outside its defining crate, since the bare name isn't imported into this module's scope. Add the missing reference-style link, matching the two link definitions already used for A2aError's variants right below it.
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.
Summary
Two follow-up fixes to the A2A Agent Card JWS signature verification + trust policy feature (#5928, PR #6202):
AgentRegistryhad no runtime construction site anywhere outsidecrates/zeph-a2a's own tests, so[a2a_client].card_trust_policyenforced nothing on a running agent. WiredAgentRegistry::discoverintozeph --connect <URL>(src/tui_remote.rs) — the only outbound A2A client path in the codebase — using an explicit non-wildcard conversion betweenzeph-configandzeph-a2a'sCardTrustPolicy/key types, and hardening the discovery fetch with the same TLS/SSRF posture already applied to theA2aClientconnection. Also fixes a real bug where the discovery URL was built from the full--connecttarget (including its RPC path) instead of the origin root where/.well-known/agent.jsonis served.card_signing::canonical_payloadcanonicalized the raw received card JSON verbatim, which would reject a genuinely valid card from a signer that strips proto3-default-valued fields before signing, per the A2A spec text. Fixed by stripping the same proto3-default fields recursively before JCS canonicalization, covered by a synthetic regression test (reala2a-sdkinterop is still unvalidated;card_trust_policyremains"ignore"by default pending a real signed-card vector).An adversarial critique round caught a real backward-compat regression in the initial wiring (discovery-fetch failure was unconditionally fatal to
--connect, breaking card-less peers under the defaultignorepolicy) — fixed by gating fatality on the trust policy so onlyrequirehard-fails on a fetch/parse failure; trust-check rejections (untrusted signature, URL-origin mismatch) remain fatal under every policy.Closes #6200
Closes #6201
Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins(13357 passed, 0 failed)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"cargo test --doc -p zeph-a2a -p zeph-config --all-featuresCHANGELOG.md,specs/014-a2a/spec.md,.local/testing/playbooks/a2a.md,.local/testing/coverage-status.md--connectpath against a real signed/unsigned peer (flagged in the playbook as the next live-tester cycle's priority target)