Connect app-server workspace discovery to model request routing (#46281)

## Why

Model requests need the selected workspace's routing constraints before sending content. A missing cached route cannot establish that a custom ChatGPT-auth destination is independent of the workspace.

## What changed

- Register the account processor as the workspace routing resolver for Responses HTTP, compaction, and WebSockets, enabling origin selection and routing headers while preserving API paths and rejecting routed HTTP redirects.
- Share concurrent discovery by auth generation, workspace, and backend configuration. Recover from discovery-time `401` responses while allowing token refreshes for the same auth owner.
- Require successful discovery before classifying custom destinations as independent, and require a new thread when a workspace-bound session's bootstrap origin changes.
- Refresh managed requirements using retained session configuration without fetching thread configuration again. Return typed routing errors without account or backend details.

## Testing

Extend coverage for discovery-time token refresh, retained provider definitions under managed requirements, and specific invalid-routing error categories.

GitOrigin-RevId: 090cda70daa91ee8acfbc973699d028111e54125
This commit is contained in:
acrognale-oai authored and copyberry committed 2026-09-17 19:12:42 +00:00
1 parent d7f8e48d7d
commit 0a5b999169
21 files changed
+505 -200

No files matched your search

@@ -16,6 +16,12 @@ async fn cyber_refusal_reads_eligibility_without_changing_the_model() -> Result<
let (mut app, mut events, _ops) = make_test_app_with_channels().await;
let backend = wiremock::MockServer::start().await;
app.config.chatgpt_base_url = backend.uri();
// Embedded account discovery reloads the bootstrap URL from disk.
std::fs::write(
app.config.codex_home.join("config.toml"),
format!("chatgpt_base_url = {:?}\n", backend.uri()),
)?;
app_test_support::mount_workspace_routing(&backend).await;
app.config.cli_auth_credentials_store_mode = AuthCredentialsStoreMode::File;
write_chatgpt_auth(
&app.config.codex_home,
@@ -43,6 +49,7 @@ async fn cyber_refusal_reads_eligibility_without_changing_the_model() -> Result<
(200, false, "gpt-5.6-sol", true, Notice::Limited),
] {
backend.reset().await;
app_test_support::mount_workspace_routing(&backend).await;
let codex_home = app.config.codex_home.clone();
let response = wiremock::ResponseTemplate::new(status)
.set_delay(if model == "gpt-5.6-sol" && enrolled { Duration::from_secs(1) } else { Duration::ZERO })