Skip to content

[feature] Decide where trusted request context should live #583

Open

Description

@afourniernv

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::Extensions directly?
  • 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::Extensions from the protocol crate.
  • Use existing string metadata. This is less suitable for trusted typed values and makes ownership less clear.

Scope notes

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

  1. added
    enhancement
    on Aug 31, 2026
  2. ilexpoon commented on Sep 1, 2026

    @ilexpoon
    Contributor

    I validated the embedding requirement against the consuming gateway. The trusted context must:

    1. be created during server ingress before the request body is buffered;
    2. survive conversion into the provider-neutral Request and any request clones;
    3. remain available after algorithm routing;
    4. be readable by the selected RoutedLlmClient;
    5. remain available to response presentation; and
    6. never enter client-controlled headers, provider payloads, or normal logs.

    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/get methods rather than exposing http::Extensions directly. Because adding the field is source-breaking, this should ship in the next breaking protocol release; that release could also make Metadata non-exhaustive to avoid repeating this problem.

    I will keep #578 in draft until the team agrees on this boundary.

  3. ljefford2-cmyk commented on Sep 5, 2026

    @ljefford2-cmyk

    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.

  4. Ilexpwh commented on Sep 10, 2026

    @Ilexpwh

    will there be a native bedrock adapter? Curerntly i need to use litellm service to translate the requests.

  5. afourniernv commented on Sep 28, 2026

    @afourniernv
    ContributorAuthor

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions