Skip to content

fix(proxy): repair request failure metadata migration - #870

Merged
Soju06 merged 69 commits into
Soju06:mainfrom
Komzpa:repair/pr-821-request-log-failure-metadata
Jun 2, 2026
Merged

Soju06 merged 69 commits into
Soju06:mainfrom
Komzpa:repair/pr-821-request-log-failure-metadata

Conversation

@Komzpa

@Komzpa Komzpa commented Jun 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Folded PRs

Validation

  • uv run pytest tests/unit/test_proxy_utils.py::test_thread_goal_failover_401_force_refreshes_fallback_account tests/unit/test_proxy_utils.py::test_thread_goal_upstream_connection_reset_fails_over_after_freshness -q
  • uv run ruff check app/modules/proxy/service.py tests/unit/test_proxy_utils.py
  • uv run ruff format --check app/modules/proxy/service.py tests/unit/test_proxy_utils.py
  • uv run ty check app/modules/proxy/service.py tests/unit/test_proxy_utils.py
  • make test-integration-bridge (126 passed)

@github-actions github-actions Bot added the db migration PR changes Alembic database migrations; maintainer must coordinate merge order label Jun 1, 2026
@Komzpa
Komzpa force-pushed the repair/pr-821-request-log-failure-metadata branch from f079941 to bacadb7 Compare June 1, 2026 11:06

@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: f079941a92

ℹ️ 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
@Soju06 Soju06 added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: needs work [@codex review] raised an issue labels Jun 1, 2026
@Soju06

Soju06 commented Jun 1, 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: 29ec46fcc2

ℹ️ 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 added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: needs work [@codex review] raised an issue labels Jun 1, 2026
@Soju06

Soju06 commented Jun 1, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ 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 added the 🤖 codex: ok [@codex review] says no issues found. label Jun 1, 2026
@Soju06 Soju06 removed the 🤖 codex: ok [@codex review] says no issues found. label Jun 1, 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: 2586d53589

ℹ️ 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
@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
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@codex review

1 similar comment
@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: 7b836e5098

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

@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: 3b16f92bec

ℹ️ 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 repair/pr-821-request-log-failure-metadata branch from 3b16f92 to 01d5d62 Compare June 2, 2026 03:28
@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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ 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 Jun 2, 2026

Copy link
Copy Markdown
Owner

Hermes owner-review found a few current-head blockers despite green CI/Codex:

  1. finalize_file() can still send a pinned file finalize to a different account during the initial account selection. It resolves the file pin (app/modules/proxy/service.py:3803) and passes it only as preferred_account_id (:3858-3867), while _select_account_with_budget() defaults fallback_on_preferred_account_unavailable=True (:12803). The later strict-account retry guards do not protect this first selection. File-owned upstream artifacts should fail closed when the pinned account is unavailable, not fall back across accounts.

  2. Local continuity errors can still be recorded as upstream metadata. _request_log_failure_metadata() infers upstream_status_code = exc.status_code for unknown non-local codes (app/modules/proxy/service.py:14173-14195), but local previous_response_owner_unavailable is synthesized in-process (:7281-7288) and is not in _LOCAL_PROXY_ERROR_CODES (:14154-14170). Repro on this head prints previous_response_owner_unavailable upstream_status_code=502; no upstream HTTP status was observed.

  3. Warmup rows still leak into one API-key aggregate path. usage_7d_by_account() filters only key/time (app/modules/api_keys/repository.py:777-798) and omits _exclude_warmup_clause(), while sibling aggregate paths apply it. This contradicts the warmup delta requiring warmup rows to be excluded from API-key usage summaries/trends (openspec/changes/add-v1-warmup-endpoint/specs/proxy-warmup/spec.md:83-92).

  4. The warmup OpenSpec artifacts contradict the public mode names. Proposal/design/tasks still say default, all-or-none, force-update (openspec/changes/add-v1-warmup-endpoint/proposal.md:7-11, design.md:9-14, tasks.md:13-14), while the parsed spec/API implement normal, strict, force (app/modules/proxy/api.py:251, :707-710). For a new public endpoint this needs to be made SSOT-consistent before merge.

Local verification I ran:

  • uv run pytest tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py tests/unit/test_bridge_context_blowup.py tests/e2e/test_responses_cancel_drain_demux.py tests/integration/test_proxy_warmup.py tests/integration/test_warmup_accounting_exclusions.py tests/integration/test_settings_api.py -q -> 589 passed
  • Focused frontend tests + typecheck with pinned [email protected] -> 45 passed, tsc -b passed
  • OpenSpec strict validations and migration policy/fresh upgrade pass, so these are semantic/coverage/spec-consistency blockers rather than broad test failures

@Soju06 Soju06 added the hermes: needs-followup Hermes left a blocker/comment that needs follow-up observation label Jun 2, 2026
- fail closed for pinned file finalize initial account selection
- keep local continuity errors out of upstream status metadata
- exclude warmup rows from per-account API-key cost aggregates
- align warmup OpenSpec artifact mode names and completed tasks
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

@codex review

@Soju06 Soju06 removed the 🤖 codex: ok [@codex review] says no issues found. label Jun 2, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ 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 added 🤖 codex: ok [@codex review] says no issues found. and removed hermes: needs-followup Hermes left a blocker/comment that needs follow-up observation labels Jun 2, 2026
@Soju06

Soju06 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Follow-up fixes pushed in cb7b48d39b7a656a23458f7a9e759f656b6a001b and the blocker comment above is addressed:

  • finalize_file() now treats a resolved file pin as strict at the initial account selection step, so pinned file finalization fails closed instead of falling back to another account
  • local preferred_account_unavailable / previous_response_owner_unavailable errors are classified as local proxy errors and no longer infer upstream_status_code
  • ApiKeysRepository.usage_7d_by_account() now excludes warmup rows like the sibling API-key aggregate paths
  • warmup OpenSpec proposal/design/tasks now use the public normal / strict / force mode names consistently, and request-log metadata tasks are checked off

Local verification:

  • uv run pytest tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py tests/unit/test_bridge_context_blowup.py tests/e2e/test_responses_cancel_drain_demux.py tests/integration/test_proxy_warmup.py tests/integration/test_warmup_accounting_exclusions.py tests/integration/test_settings_api.py -q -> 591 passed
  • uv run ruff check app/modules/proxy/service.py app/modules/api_keys/repository.py tests/unit/test_proxy_utils.py tests/integration/test_warmup_accounting_exclusions.py -> passed
  • uv run ruff format --check ... -> passed
  • uv run ty check ... -> passed
  • uv run openspec validate add-v1-warmup-endpoint --strict, fix-request-log-failure-metadata --strict, and --specs --strict -> passed
  • Alembic head/policy and fresh SQLite upgrade/check -> passed

Live gates on current head are now clean: CI has no pending/failing checks, GitHub reports CLEAN/MERGEABLE, and the fresh Codex review at 2026-06-02T05:08:43Z says no major issues with zero unresolved non-outdated review threads

@Soju06
Soju06 merged commit 0e584fa into Soju06:main Jun 2, 2026
22 checks passed
vitalNohj pushed a commit to vitalNohj/codex-lb that referenced this pull request Jul 17, 2026
Fold proxy-runtime repair work into the current mainline branch:

- persist and expose request failure metadata without misclassifying local proxy failures as upstream statuses
- linearize request-log and warmup migrations on the current Alembic head chain
- harden HTTP bridge stale/replaced-session retry and previous-response continuity behavior
- keep pinned file finalization on the owning account and fail closed when the owner is unavailable
- add `/v1/warmup` settings, request-log visibility, and accounting exclusions with consistent OpenSpec artifacts

Validation:
- CI required checks green
- Codex review clean on current head
- migration policy and fresh upgrade checks green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 codex: ok [@codex review] says no issues found. db migration PR changes Alembic database migrations; maintainer must coordinate merge order

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants