Skip to content

feat(proxy): route cyber-flagged work to authorized accounts - #572

Closed
Komzpa wants to merge 36 commits into
Soju06:mainfrom
Komzpa:feature/security-work-authorized-accounts
Closed

Komzpa wants to merge 36 commits into
Soju06:mainfrom
Komzpa:feature/security-work-authorized-accounts

Conversation

@Komzpa

@Komzpa Komzpa commented May 9, 2026 •

Copy link
Copy Markdown
Collaborator

Draft stacked split from #567/#572 cleanup.

Purpose

  • Add a persistent account flag for Trusted Access for Cyber / security-work authorization, with dashboard toggle support.
  • Filter account selection to security-authorized accounts when retrying a cyber-flagged upstream response.
  • Detect the upstream cyber warning before surfacing it to clients and retry once on the authorized pool.
  • Keep no_security_work_authorized_accounts advisory: when the authorized pool is empty, fall back to normal account selection instead of surfacing it as a terminal proxy error.
  • Preserve sticky failover behavior after a retryable upstream rate-limit response by excluding the failed account from the next stream attempt.
  • Add Alembic migration, backend/frontend schemas, and focused regression tests.

Validation

  • Head: 142142a0328a2b64a09fbd27babcd2bb2f5ae32c.
  • Exact-head GitHub CI is green.
  • Current-head @codex review has been requested after the rebuild and is pending.
  • uv run codex-lb-db --db-url sqlite:////tmp/codex-lb-pr572-check.db upgrade head && uv run codex-lb-db --db-url sqlite:////tmp/codex-lb-pr572-check.db check
  • uv run pytest tests/unit/test_proxy_utils.py tests/unit/test_proxy_load_balancer_refresh.py tests/unit/test_load_balancer.py tests/integration/test_proxy_websocket_responses.py (397 passed, 3 skipped)
  • uv run ruff check app/modules/proxy app/modules/accounts app/modules/config app/db tests/unit/test_proxy_utils.py tests/unit/test_proxy_load_balancer_refresh.py tests/unit/test_load_balancer.py tests/integration/test_proxy_websocket_responses.py
  • uv run ty check app/modules/proxy app/modules/accounts app/modules/config app/db tests/unit/test_proxy_utils.py tests/unit/test_proxy_load_balancer_refresh.py tests/unit/test_load_balancer.py tests/integration/test_proxy_websocket_responses.py

Relationship

  • Rebuilt directly on current main after the prerequisite stack slices were merged.
  • feat(proxy): add opportunistic traffic class #567 remains Draft and should not be merged as one large PR.
  • This branch carries only the security-work authorization slice and the retry failover repair needed by that slice.

@Komzpa
Komzpa force-pushed the feature/security-work-authorized-accounts branch 8 times, most recently from 846d917 to 7a1ca86 Compare May 10, 2026 10:43
@Soju06

Soju06 commented May 11, 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!

ℹ️ 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".

@Soju06

Soju06 commented May 12, 2026

Copy link
Copy Markdown
Owner

Thanks @Komzpa -- the cyber-flagged routing design is exactly the shape we want, and codex review came back clean. But before we can merge, we need to split this PR down to just the cyber routing change.

Why

This branch is currently the tip of your full stack (pr-516 -> pr-555 -> pr-519 -> pr-567 -> pr-534 -> pr-572), so merging #572 as-is would pull in 60+ unrelated commits across:

Each of those is its own scoped PR with its own review surface, and we want to merge them independently (some of them are still in review). Letting all of them land through #572 would also make changelog/release-notes attribution incorrect and would short-circuit the per-PR @codex review we already ran on the predecessors.

What we need

A version of #572 rebased directly onto origin/main with only the cyber-routing scope, i.e. the changes that were in your 7a1ca86 revision:

  • accounts.security_work_authorized boolean column + Alembic migration
  • accounts module (api / mappers / repository / schemas / service) wiring for the flag
  • frontend accounts UI: toggle, schemas, mocks, page test
  • proxy service.py / load_balancer.py cyber-warning detection + retry on authorized pool + no_security_work_authorized_accounts advisory fallback
  • the focused tests under tests/unit/test_proxy_utils.py, tests/unit/test_proxy_load_balancer_refresh.py, tests/integration/test_proxy_websocket_responses.py, and the frontend accounts-page.test.tsx

Concretely:

git fetch origin
git checkout feature/security-work-authorized-accounts
git reset --hard 7a1ca86      # the revision we already reviewed
git rebase origin/main
# resolve any conflicts from the predecessor PRs we've since merged
git push --force-with-lease

If 7a1ca86 no longer rebases cleanly on main because #559/#561/etc. moved things around, please rebuild the cyber-routing diff on top of main instead of pulling the full stack back in.

After the rebase

Drop a quick comment when the branch is ready and I'll re-run @codex review against the trimmed branch and then queue it for merge. The other stack PRs (#516, #555, #553, #567, #534, #519) can keep moving on their own threads -- no need to fold them into this PR.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@Komzpa
Komzpa force-pushed the feature/security-work-authorized-accounts branch 8 times, most recently from 9a9284b to aa89072 Compare May 15, 2026 08:41
@Komzpa
Komzpa requested a review from Soju06 as a code owner May 15, 2026 08:41
@Komzpa
Komzpa force-pushed the feature/security-work-authorized-accounts branch 2 times, most recently from d12c5df to 57e6589 Compare May 15, 2026 10:43
@Komzpa

Komzpa commented May 15, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ 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 force-pushed the feature/security-work-authorized-accounts branch from f334347 to 51bfea1 Compare May 15, 2026 12:16
@Komzpa

Komzpa commented May 15, 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: 51bfea10fb

ℹ️ 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/proxy/service.py Resolved
@Komzpa
Komzpa force-pushed the feature/security-work-authorized-accounts branch from 5b19240 to a9a9a2c Compare May 20, 2026 15:50
@Komzpa
Komzpa force-pushed the feature/security-work-authorized-accounts branch from a9a9a2c to 1f77351 Compare May 20, 2026 16:17
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 21, 2026
@Soju06

Soju06 commented May 21, 2026

Copy link
Copy Markdown
Owner

Maintainer cleanup: closing this as stale / no longer merge-ready against the current main.

This PR has been open across substantial main-branch churn and is currently carrying at least one stale signal (conflicts/blocked or failing checks, outstanding codex: needs work, draft/old branch state, or overlap with newer/current implementation). Keeping it open is making the PR queue harder to reason about.

If the change is still needed, please open a fresh, focused PR rebased on current main with green CI and a clean Codex review.

@Soju06 Soju06 closed this May 21, 2026
@Komzpa Komzpa added needs rebase Needs rebase or conflict repair against current main stale No response from reporter; scheduled for close labels May 21, 2026
@Komzpa

Komzpa commented May 21, 2026

Copy link
Copy Markdown
Collaborator Author

Revived on a maintainer-owned branch as #762 because this PR head has maintainerCanModify=false and cannot be updated here. Keeping credit to the original implementation in the replacement PR.

@Komzpa Komzpa added superseded Replaced by another PR, issue track, or merged implementation and removed 🤖 codex: needs work [@codex review] raised an issue needs rebase Needs rebase or conflict repair against current main labels May 21, 2026
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 21, 2026
@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No response from reporter; scheduled for close superseded Replaced by another PR, issue track, or merged implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants