Skip to content

feat(proxy): repair account-bound egress routing - #875

Merged
Soju06 merged 72 commits into
Soju06:mainfrom
Komzpa:repair/pr-873-egress-proxy-main
Jun 26, 2026
Merged

Soju06 merged 72 commits into
Soju06:mainfrom
Komzpa:repair/pr-873-egress-proxy-main

Conversation

@Komzpa

@Komzpa Komzpa commented Jun 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • replaces feat(proxy): add account-bound Codex upstream routing #873 because its source branch is Soju06:repair/pr-869-proxy-pool-egress with maintainerCanModify=false
  • folds the original feat(proxy): add account-bound Codex upstream routing #869 account-bound egress repair scope into a current main branch
  • keeps local codex-lb account slots separate from raw upstream ChatGPT account IDs across HTTP, compact, websocket, transcribe, file, model, and usage validation paths
  • uses account-scoped HTTP leases and account-local cache invalidation for account-bound egress, without sending local account IDs as upstream chatgpt-account-id
  • adds server-owned per-account Codex installation IDs and strips client-supplied installation metadata from account-bound upstream requests
  • adds settings API/UI support for upstream proxy endpoints, pools, account bindings, endpoint tests, and default-pool routing
  • treats 407 Proxy Authentication Required as a failed endpoint test so bad proxy credentials are not reported as connected
  • pauses proxy-required auth.json imports until an active account binding exists, then reactivates the imported account when that binding is saved
  • reactivates proxy_unreachable deactivated accounts when an active binding is saved, while leaving session-ended/reauth accounts deactivated
  • folds owner-quota full-resend replay, stale WebSocket anchor replay hardening, duplicate stale-anchor replay prevention, selected bridge-restart continuity anchors, HTTP bridge WebSocket header / 1011 affinity hardening, SSE CR/LF-only line boundary parsing, and HTTP bridge admission/startup/stream-contract handling
  • keeps fix(proxy): replay retry-safe stale websocket anchors #991's newer compact-timeout/budget path instead of fix(proxy): preserve bridge restart continuity anchors #993's older local compact fallback tail
  • credits SHAREN, rupebac, and folded contributor authors in the branch history / contributor metadata where applicable

Folded PRs and Follow-ups

Deliberately Not Claimed Here

OpenSpec

  • openspec/changes/mitigate-account-token-invalidation/
  • openspec/changes/retry-injected-websocket-stale-anchor/
  • openspec/changes/harden-http-bridge-hard-affinity-1011/
  • openspec/changes/fix-sse-crlf-line-boundaries/
  • openspec/changes/bound-http-bridge-gate-waits/
  • openspec/changes/finalize-unterminated-response-streams/
  • openspec/changes/preserve-http-stream-error-shape/
  • openspec/changes/fix-startup-probe-task-exceptions/
  • openspec/changes/bridge-codex-compaction-trigger/
  • existing related upstream proxy / account-routing specs updated in this branch

Latest Local Validation

git diff --check origin/main...HEAD
uv run openspec validate --specs
uv run openspec validate fix-sse-crlf-line-boundaries --strict
uv run openspec validate bound-http-bridge-gate-waits --strict
uv run openspec validate finalize-unterminated-response-streams --strict
uv run openspec validate preserve-http-stream-error-shape --strict
uv run openspec validate fix-startup-probe-task-exceptions --strict
uv run openspec validate bridge-codex-compaction-trigger --strict
make lint
uv run ruff check app/core/clients/proxy.py app/core/clients/proxy_websocket.py app/core/openai/requests.py app/modules/proxy tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py tests/unit/test_proxy_websocket_client.py tests/integration/test_proxy_websocket_responses.py tests/integration/test_proxy_compact.py tests/integration/test_proxy_warmup.py tests/integration/test_settings_api.py
uv run ty check app tests
make migration-check
uv run pytest tests/integration/test_migrations.py tests/unit/test_db_migrate.py -q
uv run pytest tests/integration/test_settings_api.py::test_account_proxy_binding_closes_existing_bridge_sessions tests/integration/test_settings_api.py::test_account_proxy_binding_disable_closes_existing_bridge_sessions tests/unit/test_proxy_http_bridge.py::test_close_http_bridge_sessions_for_account_detaches_matching_sessions -q
uv run pytest tests/unit/test_sse.py tests/unit/test_proxy_utils.py -q
uv run pytest tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py tests/unit/test_http_bridge_cancel_drain.py tests/unit/test_proxy_api_responses_contract.py tests/unit/test_db_session.py tests/integration/test_proxy_api_extended.py tests/integration/test_proxy_compact.py tests/integration/test_proxy_responses.py -q
uv run pytest tests/integration/test_http_responses_bridge.py -q
uv run pytest tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py tests/unit/test_proxy_websocket_client.py tests/unit/test_openai_requests.py tests/unit/test_accounts_service_probe.py tests/unit/test_usage_updater.py tests/integration/test_proxy_websocket_responses.py tests/integration/test_proxy_compact.py tests/integration/test_proxy_warmup.py tests/integration/test_settings_api.py tests/integration/test_accounts_api_extended.py -q
bun run test -- src/features/settings/components/upstream-proxy-settings.test.tsx src/features/settings/schemas.test.ts src/test/mocks/handler-coverage.test.ts
bun run lint -- src/features/settings/components/upstream-proxy-settings.tsx src/features/settings/components/upstream-proxy-settings.test.tsx src/features/settings/schemas.ts src/features/settings/api.ts src/features/settings/hooks/use-settings.ts src/test/mocks/handlers.ts src/test/mocks/handler-coverage.test.ts

Focused pytest result: 1035 passed in 50.62s; SSE/proxy utility slice after folding #1011: 512 passed in 18.51s; #892 bridge/proxy compact slice after folding #892: 892 passed in 41.80s; HTTP bridge integration slice: 77 passed in 8.62s.

Migration check result: current_revision=20260613_010000_merge_installation_id_and_dashboard_weekly_heads, migration_policy=ok, schema_drift=none; migration tests 51 passed, 3 skipped.

Architecture/lint result: proxy architecture checks passed, ruff check passed, 637 files already formatted.

Focused frontend result: 3 passed (3 files), 21 passed (21 tests).

@Komzpa
Komzpa requested a review from Soju06 as a code owner June 2, 2026 00:55
@github-actions github-actions Bot added the db migration PR changes Alembic database migrations; maintainer must coordinate merge order label Jun 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 072e29cb78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/core/clients/files.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 2, 2026
@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 2, 2026
@Komzpa

Komzpa commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b69f018134

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/usage/updater.py Resolved
Comment thread app/core/clients/model_fetcher.py Resolved
@Soju06 Soju06 added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: needs work [@codex review] raised an issue labels Jun 2, 2026
@Komzpa
Komzpa force-pushed the repair/pr-873-egress-proxy-main branch from 6e9db95 to 8725120 Compare June 2, 2026 03:41
@Komzpa

Komzpa commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 872512008f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/oauth/service.py Resolved
@Soju06 Soju06 added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: needs work [@codex review] raised an issue labels Jun 2, 2026
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cec9f6aa16

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/accounts/auth_manager.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 2, 2026
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@codex review

@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c14eafd3cb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/core/auth/dependencies.py Resolved
Comment thread app/core/upstream_proxy/types.py Resolved
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label Jun 2, 2026
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 2, 2026
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 215e3d5872

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/core/clients/proxy_websocket.py Resolved
Comment thread app/core/clients/oauth.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 2, 2026
@Komzpa
Komzpa force-pushed the repair/pr-873-egress-proxy-main branch 2 times, most recently from a0c6bb6 to fbfcd0e Compare June 2, 2026 05:36
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 2, 2026
@Komzpa
Komzpa force-pushed the repair/pr-873-egress-proxy-main branch from fbfcd0e to 52c97a4 Compare June 2, 2026 05:42
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@codex review

Komzpa and others added 8 commits June 16, 2026 03:22
Normalize the Codex-session compact JSON response so Desktop sees the single compaction output item it requires while leaving non-Codex compact responses unchanged.

Constraint: Codex Desktop remote compaction v2 requires exactly one compaction output item.

Rejected: Forwarding upstream compact output verbatim | Desktop counts legacy compaction_summary output as zero compaction items.

Confidence: high

Scope-risk: narrow

Directive: Keep compact response normalization scoped to Codex session affinity unless another client contract is verified.

Tested: python -m pytest tests/integration/test_proxy_compact.py tests/integration/test_http_responses_bridge.py -q (93 passed); python -m ruff check app/modules/proxy/api.py tests/integration/test_proxy_compact.py.

Not-tested: Full Docker Compose deployment; live upstream release compaction through GitHub issue reporter's environment.
(cherry picked from commit d83e7f7)
(cherry picked from commit 2b4b264)
@Komzpa

Komzpa commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7c2ea36de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/settings/api.py Resolved
@Komzpa

Komzpa commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: eb14441ee7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Komzpa

Komzpa commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

@Soju06 need your merge here

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has had no activity for 7 days.

It will be closed in 23 more days unless there is new activity.

If this is still relevant, please:

  • Rebase or push an update if the branch drifted
  • Address pending review feedback if there is any
  • Leave a short comment confirming it is still being worked on

Thanks for the contribution 🙏

@Soju06

Soju06 commented Jun 26, 2026

Copy link
Copy Markdown
Owner

@codex review

@Soju06

Soju06 commented Jun 26, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: b4028422d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

🤖 codex: needs work [@codex review] raised an issue db migration PR changes Alembic database migrations; maintainer must coordinate merge order stale No response from reporter; scheduled for close

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants