-
Notifications
You must be signed in to change notification settings - Fork 409
fix(proxy): keep file-pin owner on soft 1011 reconnect #1761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Komzpa
merged 8 commits into
Soju06:main
from
mastertyko:fix/soft-file-pin-1011-reconnect
Aug 15, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
117a475
fix(proxy): keep file-pin owner on soft 1011 reconnect
mastertyko 3a7b04f
fix(proxy): stay under http-bridge mixin line ratchet
mastertyko 6234fb9
fix(proxy): surface file-pin owner-unavailable on soft reconnect
mastertyko 65a634d
fix(proxy): map required-owner reconnect miss to owner-unavailable
mastertyko 6230c97
test(proxy): expect owner-unavailable on file-owner reconnect miss
mastertyko 9eaac24
fix(proxy): map required-owner connect miss to owner-unavailable
mastertyko bca9ba7
fix(proxy): map required-owner transport miss to owner-unavailable
mastertyko 9e85128
fix(proxy): map required-owner refresh miss to owner-unavailable
mastertyko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
openspec/changes/keep-file-pin-owner-on-soft-1011-reconnect/.openspec.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| schema: spec-driven | ||
| created: 2026-08-14 |
29 changes: 29 additions & 0 deletions
29
openspec/changes/keep-file-pin-owner-on-soft-1011-reconnect/context.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Keep file-pin owner on soft 1011 reconnect | ||
|
|
||
| ## Purpose | ||
|
|
||
| Close the HTTP-bridge reconnect hole where a live `input_file.file_id` pin is | ||
| treated as skippable prompt-cache locality after upstream close `1011`. | ||
|
|
||
| ## Decision | ||
|
|
||
| Honor `file_required_preferred_account` in reconnect owner resolution, and | ||
| pass it from submit-on-closed fresh-upstream retry. Do not persist pins | ||
| across replicas here. | ||
|
|
||
| ## Constraints | ||
|
|
||
| File pins are hard ownership. Soft `1011` skip-same-account stays valid only | ||
| when no live file pin (and no other required owner) is present. | ||
|
|
||
| ## Failure mode | ||
|
|
||
| If the pin account is excluded or cannot reconnect, fail closed with the | ||
| existing required-owner unavailable error. Do not fall back to another | ||
| account and forward the `file_id`. | ||
|
|
||
| ## Example | ||
|
|
||
| Upload `file_xyz` on account A, then send `/v1/responses` with that | ||
| `input_file` on a soft prompt-cache bridge session. Upstream closes `1011` | ||
| before the next turn is accepted. Reconnect must keep account A required. |
51 changes: 51 additions & 0 deletions
51
openspec/changes/keep-file-pin-owner-on-soft-1011-reconnect/design.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| ## Context | ||
|
|
||
| `_reconnect_http_bridge_session` promotes `request_state.preferred_account_id` | ||
| to a required owner only when the caller sets `require_preferred_account` or | ||
| the session is account-neutral. Submit-on-closed recovery calls | ||
| `_retry_http_bridge_request_on_fresh_upstream`, which passes | ||
| `require_same_account` only for hard keys and never passes | ||
| `require_preferred_account`. After upstream `1011`, a soft `prompt_cache` | ||
| session therefore sets `skip_same_account`, excludes the file owner, and | ||
| allows fallback. The later precreated-recovery path already pins files. | ||
|
|
||
| The existing file-pin requirement already says a live pin MUST override | ||
| prompt-cache locality. This change closes the reconnect hole rather than | ||
| inventing a new ownership model. | ||
|
|
||
| ## Goals / Non-Goals | ||
|
|
||
| **Goals:** | ||
|
|
||
| - Soft `1011` reconnect of a file-pinned request keeps the pin account | ||
| required, or fail-closes if that account is excluded or unavailable. | ||
| - Movable soft `1011` reconnects without a live file pin still skip the | ||
| closed account. | ||
|
|
||
| **Non-Goals:** | ||
|
|
||
| - Durable cross-replica pin persistence (open `#1521`). | ||
| - Changing hard-session `1011` keep-owner behavior. | ||
| - Changing compact or native WebSocket file routing. | ||
|
|
||
| ## Decisions | ||
|
|
||
| - Honor `file_required_preferred_account` inside reconnect owner resolution | ||
| so every reconnect caller is covered, not only submit-on-closed. | ||
| - Also pass `require_preferred_account` from | ||
| `_retry_http_bridge_request_on_fresh_upstream` so that path matches the | ||
| already-correct precreated recovery call. | ||
| - If the file-required flag is set but `preferred_account_id` is missing, | ||
| use the current session account (the session was already on the pin owner). | ||
|
|
||
| **Alternative considered:** only change the one call site. Rejected because | ||
| reconnect still ignores `file_required_preferred_account`, so a future | ||
| caller can reopen the hole. | ||
|
|
||
| ## Risks / Trade-offs | ||
|
|
||
| - [Risk] A file-pinned request can no longer leave a `1011`-closed soft | ||
| session's account. → Mitigation: that is the required contract; fail closed | ||
| instead of sending the file to another account. | ||
| - [Risk] Existing unit tests assert the fresh-upstream retry call shape. | ||
| → Mitigation: update the no-file assertion and add a file-pin assertion. |
33 changes: 33 additions & 0 deletions
33
openspec/changes/keep-file-pin-owner-on-soft-1011-reconnect/proposal.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ## Why | ||
|
|
||
| A live `input_file.file_id` pin is hard ownership and must stay on the | ||
| uploading account. Soft HTTP-bridge reconnect after upstream `1011` currently | ||
| treats that owner as skippable prompt-cache locality, so submit-on-closed | ||
| recovery can send the file to another account. | ||
|
|
||
| ## What Changes | ||
|
|
||
| - Treat `file_required_preferred_account` as a required reconnect owner, even | ||
| when the session key is soft and the close code is `1011`. | ||
| - Pass that requirement from submit-on-closed fresh-upstream retry so it | ||
| cannot drop the pin. | ||
| - Keep `1011` skip-same-account for movable soft sessions that have no live | ||
| file pin. | ||
|
|
||
| ## Capabilities | ||
|
|
||
| ### New Capabilities | ||
|
|
||
| - None. | ||
|
|
||
| ### Modified Capabilities | ||
|
|
||
| - `responses-api-compat`: HTTP-bridge reconnect after `1011` must keep a live | ||
| file-pin owner required, or fail closed. | ||
|
|
||
| ## Impact | ||
|
|
||
| - `app/modules/proxy/_service/http_bridge/mixin.py` reconnect owner resolution. | ||
| - `app/modules/proxy/_service/http_bridge/request_submit.py` fresh-upstream retry. | ||
| - Unit coverage next to the existing hard-`1011` reconnect tests. | ||
| - No API, schema, dashboard, or settings changes. |
53 changes: 53 additions & 0 deletions
53
...s/keep-file-pin-owner-on-soft-1011-reconnect/specs/responses-api-compat/spec.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| ## ADDED Requirements | ||
|
|
||
| ### Requirement: Soft HTTP-bridge 1011 reconnect keeps a live file-pin owner | ||
|
|
||
| A still-unsubmitted HTTP-bridge reconnect MUST keep a live `input_file.file_id` | ||
| pin as a required owner after a soft session closes with `1011`. | ||
| When an HTTP-bridge session is soft (prompt-cache or request locality) and | ||
| upstream closed it with `1011`, a still-unsubmitted request that carries a | ||
| live `input_file.file_id` pin MUST keep that pin account as a required | ||
| reconnect owner. The proxy MUST NOT exclude that account solely because the | ||
| close code was `1011`, and MUST NOT fall back to another account while the | ||
| pin is live. If the required pin account is already excluded or cannot be | ||
| reconnected, the proxy MUST fail closed with the existing required-owner | ||
| unavailable error. A soft `1011` reconnect that has no live file pin and no | ||
| other required owner MAY still skip the closed account. | ||
|
|
||
| #### Scenario: Soft 1011 reconnect keeps the file-pin account required | ||
|
|
||
| - **GIVEN** a live in-memory pin `file_xyz -> account_a` | ||
| - **AND** a soft prompt-cache HTTP-bridge session on `account_a` closed with `1011` | ||
| - **AND** the next still-unsubmitted `/v1/responses` request references `file_xyz` | ||
| - **WHEN** the proxy reconnects that session | ||
| - **THEN** account selection MUST treat `account_a` as the required owner | ||
| - **AND** it MUST NOT add `account_a` to the excluded-account set solely because of `1011` | ||
| - **AND** it MUST NOT enable preferred-account fallback to another account | ||
|
|
||
| #### Scenario: Soft 1011 reconnect without a file pin may skip the closed account | ||
|
|
||
| - **GIVEN** a soft prompt-cache HTTP-bridge session on `account_a` closed with `1011` | ||
| - **AND** the still-unsubmitted request has no live file pin and no other required owner | ||
| - **WHEN** the proxy reconnects that session | ||
| - **THEN** account selection MAY exclude `account_a` and choose another eligible account | ||
|
|
||
| #### Scenario: Soft 1011 file-pin reconnect fails closed when the required owner cannot be selected | ||
|
|
||
| - **GIVEN** a live in-memory pin `file_xyz -> account_a` | ||
| - **AND** a soft prompt-cache HTTP-bridge session on `account_a` closed with `1011` | ||
| - **AND** the next still-unsubmitted `/v1/responses` request references `file_xyz` | ||
| - **AND** account selection cannot return `account_a` | ||
| - **WHEN** the proxy reconnects that session | ||
| - **THEN** the proxy MUST fail closed with the existing required-owner unavailable error | ||
| - **AND** it MUST NOT replace that envelope with a generic selection failure | ||
|
|
||
| #### Scenario: Soft 1011 file-pin reconnect fails closed when the required owner cannot be connected | ||
|
|
||
| - **GIVEN** a live in-memory pin `file_xyz -> account_a` | ||
| - **AND** a soft prompt-cache HTTP-bridge session on `account_a` closed with `1011` | ||
| - **AND** the next still-unsubmitted `/v1/responses` request references `file_xyz` | ||
| - **AND** account selection returns `account_a` | ||
| - **AND** opening a replacement upstream for `account_a` fails | ||
| - **WHEN** the proxy reconnects that session on submit | ||
| - **THEN** the client-visible error MUST be the existing required-owner unavailable error | ||
| - **AND** it MUST NOT be replaced with a generic `upstream_unavailable` envelope |
25 changes: 25 additions & 0 deletions
25
openspec/changes/keep-file-pin-owner-on-soft-1011-reconnect/tasks.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ## 1. Implementation | ||
|
|
||
| - [x] 1.1 Treat `file_required_preferred_account` as a required owner in | ||
| `_reconnect_http_bridge_session`. | ||
| - [x] 1.2 Pass `require_preferred_account` from | ||
| `_retry_http_bridge_request_on_fresh_upstream` when a live file pin is | ||
| present. | ||
|
|
||
| ## 2. Regression coverage | ||
|
|
||
| - [x] 2.1 Assert soft `1011` reconnect with a live file pin keeps the owner | ||
| required and does not exclude it. | ||
| - [x] 2.2 Assert soft `1011` reconnect without a file pin may still skip the | ||
| closed account. | ||
| - [x] 2.3 Update the fresh-upstream retry call-shape assertion for the new | ||
| `require_preferred_account` argument. | ||
| - [x] 2.4 Assert soft `1011` file-pin reconnect fails closed with the | ||
| required-owner envelope when selection cannot return the pin account. | ||
| - [x] 2.5 Assert submit-on-closed emits the required-owner envelope when | ||
| the pin account is selected but the replacement socket cannot be opened. | ||
|
|
||
| ## 3. Validation | ||
|
|
||
| - [x] 3.1 Run the focused HTTP-bridge reconnect unit tests. | ||
| - [x] 3.2 Run strict OpenSpec validation for this change. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.