Repository navigation
Split upstream attempt recovery into focused modules - #12005
Conversation
…modules Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The workflow’s push path filter omits both extracted modules, so changes confined to them would skip the post-merge routing smoke test.
1 open issue
What changed in this PR
Refactors the API proxy’s upstream attempt recovery into focused modules, addressing #11998 while retaining the existing facade contract and routing behavior.
Changes:
- Extract origin snapshots, candidate selection, and bounded automatic-recovery expansion.
- Keep dispatch, observations, and mutable recovery state in the facade.
- Package the new modules and add focused regression coverage.
| File | Description |
|---|---|
containers/api-proxy/upstream-attempt-recovery.js |
Delegates snapshot and selection logic to the new modules. |
containers/api-proxy/protocol-compatibility.packaging.test.js |
Checks that both modules are packaged. |
containers/api-proxy/fallback-origin.test.js |
Tests snapshot preservation and source/model precedence. |
containers/api-proxy/fallback-origin.js |
Extracts fallback origin snapshot construction. |
containers/api-proxy/fallback-candidate-selection.test.js |
Tests admission checks, ordering, and recovery limits. |
containers/api-proxy/fallback-candidate-selection.js |
Extracts route rejection, selection, and recovery expansion. |
containers/api-proxy/Dockerfile |
Includes both modules in the container image. |
Review effort: Max (adaptive)
| const { buildFallbackOrigin } = require('./fallback-origin'); | ||
| const { selectFallbackCandidate, buildFallbackCandidates } = require('./fallback-candidate-selection'); |
|
@copilot address review feedback |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Added both extracted modules to the routing workflow push path filter. Commit: |
|
✅ Copilot review passed with no inline comments. @lpcox Add the |
|
@copilot merge main and resolve conflicts |
…t-upstream-recovery # Conflicts: # containers/api-proxy/Dockerfile # containers/api-proxy/protocol-compatibility.packaging.test.js Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Merged |

Attempt recovery combined origin capture, security-sensitive candidate selection, observation, and dispatch in one large closure. This refactor separates the data and selection logic while preserving the facade contract and routing behavior.
buildFallbackOrigin, preserving pre-budget body capture and source/model precedence.exclude/lastDecisionstate increateAttemptRecovery.