Skip to content

PAC 4 - Add macOS system proxy resolver - #26709

Merged
canvrno-oai merged 3 commits into
mainfrom
canvnro/codex-pac-pr4-mac
Jun 23, 2026
Merged

PAC 4 - Add macOS system proxy resolver#26709
canvrno-oai merged 3 commits into
mainfrom
canvnro/codex-pac-pr4-mac

Conversation

@canvrno-oai

@canvrno-oai canvrno-oai commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Stacked on #26708.

Adds the macOS implementation of the shared system-proxy contract. This allows Codex-owned auth clients to use the route macOS selects for each auth URL through SystemConfiguration and CFNetwork, including PAC and WPAD results.

The respect_system_proxy feature is disabled by default, so existing client behavior remains unchanged unless explicitly enabled.

Implementation

  • Adds the macOS-only system-configuration dependency to codex-client.
  • Dispatches system-proxy resolution to outbound_proxy/macos.rs on macOS.
  • Reads system proxy settings from SCDynamicStore and resolves the target URL with CFNetworkCopyProxiesForURL.
  • Executes PAC URLs and inline PAC JavaScript through a bounded run loop with a five-second timeout.
  • Handles DIRECT, HTTP proxies, and CFNetwork HTTPS entries using HTTP CONNECT; unsupported SOCKS entries map to UnsupportedProxyScheme.
  • Builds concrete proxy URLs from host and port entries, including IPv6 host bracketing.
  • Maps results into the shared SystemProxyDecision::{Direct, Proxy, Unavailable} contract.
  • Hashes URL-specific cache keys so PAC decisions remain distinct without retaining raw request URLs or query strings.

End-user behavior

  • Disabled/default: existing client behavior is unchanged.
  • Enabled with [features.respect_system_proxy]:
    • macOS auth clients honor system proxy configuration, PAC, and WPAD;
    • valid OS/PAC DIRECT decisions use a direct connection;
    • unavailable system resolution falls back to explicit environment proxy variables, then DIRECT, through the shared contract from PAC 2 - Add shared auth system proxy contract #26707.
  • Unsupported proxy schemes are not silently translated into another route.
  • Custom CA handling remains separate from proxy selection.
  • Known limitation: only the first supported system/PAC candidate is used. Subsequent proxy or DIRECT candidates are not attempted after a connection failure. This matches the current Windows behavior and leaves room for future ordered-fallback support.

Tests

  • just test -p codex-client — 34 tests passed.
  • just clippy -p codex-client
  • just fmt
  • just bazel-lock-check
@canvrno-oai canvrno-oai changed the title [codex] Add macOS system proxy resolver PAC - Add macOS system proxy resolver Jun 6, 2026
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 4cc962b to a55b700 Compare June 8, 2026 17:44
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from b532a82 to 87bccd3 Compare June 8, 2026 17:44
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from a55b700 to 16ce90d Compare June 8, 2026 18:38
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from 87bccd3 to 9f5909a Compare June 8, 2026 18:39
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 16ce90d to 216cb3f Compare June 8, 2026 18:59
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from 9f5909a to 70b25b2 Compare June 8, 2026 19:00
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 216cb3f to 2777480 Compare June 8, 2026 19:23
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch 2 times, most recently from dd4a06d to ea60fce Compare June 8, 2026 19:34
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from c02c09b to 847b03a Compare June 8, 2026 20:40
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from ea60fce to b9e4832 Compare June 8, 2026 20:40
@canvrno-oai canvrno-oai changed the title PAC - Add macOS system proxy resolver PAC 4 - Add macOS system proxy resolver Jun 9, 2026
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 847b03a to da0445f Compare June 10, 2026 18:23
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch 2 times, most recently from 6158992 to e4b8b92 Compare June 10, 2026 20:42
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 5c46f30 to 47a7061 Compare June 11, 2026 19:14
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch 2 times, most recently from 93e4e84 to c91497e Compare June 11, 2026 20:13

@viyatb-oai viyatb-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One routing issue to address in the macOS resolver.

Comment thread codex-rs/codex-client/src/outbound_proxy/macos.rs
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from d1af2f3 to 30866d1 Compare June 16, 2026 05:57
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from 5dd8971 to bc39031 Compare June 16, 2026 06:57
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 30866d1 to 048ff60 Compare June 16, 2026 16:40
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from bc39031 to ab61237 Compare June 16, 2026 16:44
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 5497d3d to 354094e Compare June 16, 2026 20:28
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from 7354130 to 19ccecb Compare June 16, 2026 20:30
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from d44ee4e to 5dd5bac Compare June 17, 2026 00:59
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from ac90f94 to bf35429 Compare June 17, 2026 01:00
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 5dd5bac to 2243326 Compare June 17, 2026 18:52
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from bf35429 to ac0677a Compare June 17, 2026 18:52
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 2243326 to 0743880 Compare June 17, 2026 20:19
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from ac0677a to 9fb47f7 Compare June 17, 2026 20:20
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 272021e to d824f00 Compare June 22, 2026 17:35
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from 7f0b9ee to a008e4b Compare June 22, 2026 18:23
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from 2e71f40 to c590f10 Compare June 22, 2026 18:46
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from a008e4b to 425162e Compare June 22, 2026 18:49
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr3-win branch from c590f10 to 13cc356 Compare June 22, 2026 20:09
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from 425162e to 5b73387 Compare June 22, 2026 20:17
Base automatically changed from canvnro/codex-pac-pr3-win to main June 22, 2026 21:38
@canvrno-oai
canvrno-oai force-pushed the canvnro/codex-pac-pr4-mac branch from 5b73387 to 4627c3e Compare June 22, 2026 21:48
@canvrno-oai
canvrno-oai requested a review from viyatb-oai June 22, 2026 21:55
@canvrno-oai
canvrno-oai marked this pull request as ready for review June 22, 2026 21:55
Comment thread codex-rs/codex-client/src/outbound_proxy/macos.rs Outdated

@viyatb-oai viyatb-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with one comment to remove a redundant function.

@canvrno-oai
canvrno-oai merged commit b16d285 into main Jun 23, 2026
57 of 61 checks passed
@canvrno-oai
canvrno-oai deleted the canvnro/codex-pac-pr4-mac branch June 23, 2026 00:56
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

2 participants