Skip to content

feat: reach the host's internal revision RPC over the mesh (h2c) - #16

Merged
antoinetoussaint-byte merged 1 commit into
mainfrom
feat/mesh-h2c-revision-client
Sep 23, 2026
Merged

antoinetoussaint-byte merged 1 commit into
mainfrom
feat/mesh-h2c-revision-client

Conversation

@antoinetoussaint-byte

Copy link
Copy Markdown
Contributor

Summary

The host's own contract says this library cannot reach a current host, and this PR fixes that.

module-saas-starter #864 (closing #859) published module/INTERNAL_TRANSPORT.md. It says the internal tier, including WorkContextService.CheckAuthorizationRevision, is cleartext HTTP/2 (h2c) multiplexed onto accounts' private rest endpoint. In-cluster transport security belongs to the mesh. It also says: "A library that requires an explicit https:// origin, or that dials with channel credentials built from a CA bundle, cannot reach a current host." GRPCClient does both of those things.

  • MeshGRPCClient(address, credential): dials the host:port Codefly resolved for accounts' rest endpoint over h2c (grpc.aio.insecure_channel), and adds no TLS of its own. It refuses a scheme, a path, a query, credentials or a zero/invalid port in the address, because the address is resolved, not configured as a URL. The check itself (one total budget including the credential refresh, no retries, x-codefly-internal-token metadata, an exact empty response, and RevisionDenied/RevisionUnavailable mapping) moved unchanged into a shared _GRPCRevision base. GRPCClient behaves exactly as before.
  • WorkContextUnavailable: a WorkContextError subclass. JWKSVerifier raises it when the key set cannot be fetched, is not JSON, is oversized, or is malformed. The same contract makes the published JWKS the only key producer, so a consumer that verifies through it needs to tell "the authority is down" (retryable, 503) apart from "this capability is invalid" (401). Existing except WorkContextError handlers still catch it.

Classification: a fix, in the library the host's contract names. The earlier form refused the only transport the host serves.

Why now

The model gateway's Codefly-hosted runtime (obin-ai/module-model-gateway, PR linked from there) checks the current authorization revision on every admitted request, and verifies Work Contexts against the published JWKS. It pins this repository by commit.

Test plan

  • python -m pytest -q: 165 passed.
  • Every existing gRPC conformance test now runs twice: against a TLS server with GRPCClient, and against an h2c server with MeshGRPCClient. Covered: wire shape and credential refresh, typed errors with no retry, exact empty response, caller cancellation, and the total budget including the credential.
  • The new address tests cover refused forms (scheme, path, query, fragment, credentials, bad or missing port, whitespace) and accepted forms (DNS name, IPv4, bracketed IPv6).
  • The JWKS outage tests (boot, backoff, redirect, malformed, oversized) now assert WorkContextUnavailable. A new test asserts that a token the served keys reject is not reported as unavailable.

Not verified

  • Nothing was run against a real accounts service or inside a mesh. The h2c server in the tests is a plain grpc.aio insecure port.
  • Using MeshGRPCClient safely depends on the mesh enforcing mutual TLS on the hop (STRICT PeerAuthentication in the host's contract). This library cannot check that, and the docstring and README say so.

🤖 Generated with Claude Code

The host serves WorkContextService.CheckAuthorizationRevision as h2c
multiplexed onto accounts' private rest endpoint and leaves in-cluster
transport security to the mesh (module-saas-starter
module/INTERNAL_TRANSPORT.md, #859/#864). GRPCClient requires an https
origin and CA roots, which that contract calls unsatisfiable.

Add MeshGRPCClient: it dials the host:port Codefly resolved, with no
TLS of its own, and shares GRPCClient's check, budget and error
mapping. GRPCClient is unchanged.

Add WorkContextUnavailable, a WorkContextError subclass JWKSVerifier
raises when the key set cannot be fetched or read, so a consumer can
report a verifier outage as unavailable instead of as an invalid
capability.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@antoinetoussaint-byte
antoinetoussaint-byte merged commit efdbd2d into main Sep 23, 2026
2 checks passed
@antoinetoussaint-byte
antoinetoussaint-byte deleted the feat/mesh-h2c-revision-client branch September 23, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant