Forward executor network policy decisions for auditing (#38670)

## What changed

- Add a best-effort `network/policyDecision` notification for final domain and non-domain policy decisions made by executor-local proxies.
- Validate notifications against the active process on the controller and emit audit events with controller-trusted session and execution metadata.
- Reserve outbound RPC capacity so audit notifications cannot block control messages, and expose valid `chatgpt-account-id` header values for audit attribution.

## Testing

- Cover notification serialization, proxy decision capture, executor-to-controller delivery, trusted metadata handling, and reserved RPC capacity.

GitOrigin-RevId: a39f96a6b3d9401c03d54eaef5b9a6d3fe0da78b
This commit is contained in:
viyatb-oai authored and copyberry committed 2026-08-14 23:42:40 +00:00
1 parent a186f5484d
commit 15fde8c1f2
15 files changed
+655 -19

No files matched your search

+25
View File
@@ -33,6 +33,31 @@ const WORKSPACE_ID_ALLOWED: &str = "123e4567-e89b-42d3-a456-426614174000";
const WORKSPACE_ID_SECOND_ALLOWED: &str = "123e4567-e89b-42d3-a456-426614174001";
const WORKSPACE_ID_DISALLOWED: &str = "123e4567-e89b-42d3-a456-426614174002";
#[test]
fn header_auth_exposes_a_valid_chatgpt_account_id() {
for (account_id_header, expected_account_id) in [
(
Some(WORKSPACE_ID_ALLOWED.as_bytes()),
Some(WORKSPACE_ID_ALLOWED),
),
(None, None),
(Some(b""), None),
(Some(b" account "), None),
(Some(&[0xff]), None),
] {
let mut headers = http::HeaderMap::new();
if let Some(account_id_header) = account_id_header {
headers.insert(
"chatgpt-account-id",
http::HeaderValue::from_bytes(account_id_header).expect("valid header bytes"),
);
}
let auth = CodexAuth::Headers(AuthHeaders::new(headers));
assert_eq!(auth.get_account_id().as_deref(), expected_account_id);
}
}
#[tokio::test]
async fn refresh_without_id_token() {
let codex_home = tempdir().unwrap();
+6 -1
View File
@@ -566,7 +566,12 @@ impl CodexAuth {
/// Returns `None` if Codex backend auth does not expose an account id.
pub fn get_account_id(&self) -> Option<String> {
match self {
Self::Headers(_) => None,
Self::Headers(headers) => headers
.headers()
.get("chatgpt-account-id")
.and_then(|value| value.to_str().ok())
.filter(|account_id| !account_id.is_empty() && account_id.trim() == *account_id)
.map(ToOwned::to_owned),
Self::AgentIdentity(auth) => Some(auth.account_id().to_string()),
Self::PersonalAccessToken(auth) => Some(auth.account_id().to_string()),
_ => self.get_current_token_data().and_then(|t| t.account_id),