Repository navigation
feat: reach the host's internal revision RPC over the mesh (h2c) - #16
Merged
Merged
Conversation
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>
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
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, includingWorkContextService.CheckAuthorizationRevision, is cleartext HTTP/2 (h2c) multiplexed onto accounts' privaterestendpoint. In-cluster transport security belongs to the mesh. It also says: "A library that requires an explicithttps://origin, or that dials with channel credentials built from a CA bundle, cannot reach a current host."GRPCClientdoes both of those things.MeshGRPCClient(address, credential): dials thehost:portCodefly resolved for accounts'restendpoint 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-tokenmetadata, an exact empty response, andRevisionDenied/RevisionUnavailablemapping) moved unchanged into a shared_GRPCRevisionbase.GRPCClientbehaves exactly as before.WorkContextUnavailable: aWorkContextErrorsubclass.JWKSVerifierraises 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). Existingexcept WorkContextErrorhandlers 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.GRPCClient, and against an h2c server withMeshGRPCClient. Covered: wire shape and credential refresh, typed errors with no retry, exact empty response, caller cancellation, and the total budget including the credential.WorkContextUnavailable. A new test asserts that a token the served keys reject is not reported as unavailable.Not verified
grpc.aioinsecure port.MeshGRPCClientsafely 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