feat(federation): outbound mTLS FederationClient (FED-M3-08) #508
Reference in New Issue
Block a user
Delete Branch "feat/federation-m3-client"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements
FederationClientService— outbound mTLS HTTP client for federation verb requests.Closes #462
Changes
apps/gateway/src/federation/client/federation-client.service.tsapps/gateway/src/federation/client/index.tsFederationModulewired to includeFederationClientServicein providers + exportsundiciadded as direct dependency toapps/gateway/package.jsonError Code Taxonomy
PEER_NOT_FOUND, PEER_INACTIVE, PEER_MISCONFIGURED, NETWORK, FORBIDDEN, HTTP_{status}, INVALID_RESPONSE
Pre-PR Gates
Generated with Claude Code
Implements FederationClientService — a NestJS injectable that dials peer gateways over mTLS (undici Agent with cert+sealed-key from federation_peers), invokes list/get/capabilities verbs, validates responses via Zod, and surfaces all failure modes as typed FederationClientError with a coherent error code taxonomy (PEER_NOT_FOUND, PEER_INACTIVE, PEER_MISCONFIGURED, NETWORK, FORBIDDEN, HTTP_{status}, INVALID_RESPONSE). Per-peer Agent instances are cached in a Map for the service lifetime; flushPeer(peerId) invalidates the cache for M5/M6 cert rotation and revocation events. Wired into FederationModule providers + exports so QuerySourceService (M3-09) can inject it. 13 unit tests covering all required scenarios via undici MockAgent + real sealClientKey/unsealClientKey round-trip. Closes #462 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>