Repository navigation
Description
Problem
A Rust host embedding Switchyard may authenticate a request before routing and need to carry trusted request-scoped state, such as a tenant ID or authorization decision, through routing and request clones. That state should not come from client headers or be forwarded to an upstream model.
#578 proposed an http::Extensions type map on protocol Metadata, and #580 proposed server ingress hooks. Both closed without merging. We still need to decide which layer should own this state before changing the public protocol type.
The target-label work in #1164 has landed, but it is narrower than this issue. It does not provide general typed tenant or authorization context through routing, clients and response handling.
Proposed solution
Agree on ownership and the public API before revisiting the implementation.
Questions to settle:
- Should trusted context live in protocol
Metadata, the runner, or the server/host layer? - Does it need to reach algorithms and clients, or only ingress and response hooks?
- Should Switchyard expose
http::Extensionsdirectly? - If it belongs in
Metadata, should it wait for the next breaking protocol release?
Alternatives considered
- Keep the context in server-owned ingress state and pass it only to response hooks.
- Add an opaque runner-owned request context instead of exposing
http::Extensionsfrom the protocol crate. - Use existing string metadata. This is less suitable for trusted typed values and makes ownership less clear.
Scope notes
- Earlier context proposal, closed unmerged: feat(protocol): add typed request context #578
- Earlier ingress-hook proposal, closed unmerged: feat(server): add composable ingress hooks #580
- Adding a field to public
Metadatais source-breaking for downstream struct literals and exhaustive patterns. - This is a Rust embedding API decision; it does not change the wire format.
Additional context
The immediate use case is an embedded host authenticating a request, attaching trusted state, and retaining it while Switchyard routes or clones the request.
Activity
ilexpoon commentedon Sep 1, 2026
I validated the embedding requirement against the consuming gateway. The trusted context must:
Requestand any request clones;RoutedLlmClient;A server-only extension would not satisfy point 4 without a broader change to the runner, route, algorithm, and client trait signatures.
My preferred direction is therefore a protocol-owned but opaque typed context carried with the request. Switchyard would expose typed
insert/getmethods rather than exposinghttp::Extensionsdirectly. Because adding the field is source-breaking, this should ship in the next breaking protocol release; that release could also makeMetadatanon-exhaustive to avoid repeating this problem.I will keep #578 in draft until the team agrees on this boundary.
ljefford2-cmyk commentedon Sep 5, 2026
An opaque typed context seems reasonable for the propagation requirements described above. This also connects to #427’s distinction between target eligibility and routing preference.
One contract worth clarifying: cloning trusted context preserves its provenance, but does not automatically extend an authorization decision to a changed operation. Tenant identity may remain valid after a fallback, while permission limited to the original target may not.
Could the contract explicitly leave scope validation with the embedding host at dispatch, including fallback and auxiliary judge calls?
A useful integration example would authorize target A, force fallback to unauthorized target B, and verify that B receives no request. A companion case permitting both targets would show that ordinary fallback still works. This would clarify the boundary without requiring Switchyard to implement authorization policy.
Ilexpwh commentedon Sep 10, 2026
will there be a native bedrock adapter? Curerntly i need to use litellm service to translate the requests.
afourniernv commentedon Sep 28, 2026
@Ilexpwh I split the Bedrock question into #864 so it doesn’t get lost in the trusted-context discussion. ConductorOne has a working codec prototype in ConductorOne#1. That covers the wire format; AWS signing, credentials, and transport are still separate work.