feat(oauth-client): add discovery stage - fetch metadata doc or synthesize implicit
Implement Task 2 of Phase 3: the discovery stage that resolves client metadata
documents for HTTPS targets or synthesizes implicit metadata for loopback
clients. Adds DiscoveryFacts, ClientIdKind, and RawMetadata types for facts
transport, Check enum with stable diagnostic codes, and the async run function
that handles HTTP metadata fetches with content-type tracking.
Extends HttpClient trait in src/common/identity.rs with get_bytes_with_content_type
method and implements it on RealHttpClient to read Content-Type header. Default
implementation maintains backward compatibility with existing stages.
Check results include:
- ClientIdWellFormed: always passes for valid targets
- MetadataDocumentFetchable: passes for 2xx responses, network error or
non-2xx status, skipped for loopback (implicit metadata)
- MetadataIsJson: passes for valid JSON, spec violation for parse errors
with source context, skipped for loopback clients
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>