Enforce managed residency for model providers (#39645)

## Why

Model provider configuration could override the residency header required by
`enforce_residency`, so provider-backed requests did not reliably honor the
managed setting.

## What changed

- Apply the managed residency header after building a provider, making it
  authoritative for model requests and model discovery.
- Warn when a provider configures the residency header through
  `http_headers` or `env_http_headers`, while preserving the original provider
  configuration and unrelated headers.
- Cover HTTP and WebSocket requests, model discovery, and case-insensitive
  header detection with targeted tests.

GitOrigin-RevId: 461ef8989d5bd06ffdea694aee4265e392e07590
This commit is contained in:
Anton Panasenko authored and copyberry committed 2026-08-20 07:33:27 +00:00
1 parent 663da53823
commit af0e82c562
7 files changed
+371 -3

No files matched your search

@@ -104,6 +104,11 @@ pub fn set_default_client_residency_requirement(enforce_residency: Option<Reside
*guard = enforce_residency;
}
/// Returns the current process-wide residency requirement.
pub fn read_default_client_residency_requirement() -> Option<ResidencyRequirement> {
REQUIREMENTS_RESIDENCY.read().ok().and_then(|guard| *guard)
}
pub fn originator() -> Originator {
if let Ok(guard) = ORIGINATOR.read()
&& let Some(originator) = guard.as_ref()