Skip to content

Split upstream attempt recovery into focused modules - #12005

Merged
lpcox merged 4 commits into
mainfrom
copilot/refactor-split-upstream-recovery
Nov 23, 2026
Merged

lpcox merged 4 commits into
mainfrom
copilot/refactor-split-upstream-recovery

Conversation

@lpcox

@lpcox lpcox commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

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.

  • Origin snapshot: Extract buildFallbackOrigin, preserving pre-budget body capture and source/model precedence.
  • Candidate selection: Extract cross-provider route rejection, ordered selection, and bounded automatic-recovery expansion.
  • Facade: Keep dispatch, skip/exhaustion observations, and mutable exclude/lastDecision state in createAttemptRecovery.
  • Packaging and coverage: Add both modules to Docker COPY entries and packaging assertions; add focused snapshot, admission, ordering, and recovery-limit tests.

@lpcox lpcox changed the title [WIP] Refactor upstream attempt recovery into focused modules Split upstream attempt recovery into focused modules Nov 23, 2026
@lpcox
lpcox marked this pull request as ready for review November 23, 2026 16:14
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 16:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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)

Comment on lines +3 to +4
const { buildFallbackOrigin } = require('./fallback-origin');
const { selectFallbackCandidate, buildFallbackCandidates } = require('./fallback-candidate-selection');
@lpcox

lpcox commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Copilot AI commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Added both extracted modules to the routing workflow push path filter. Commit: f8a49e7.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@lpcox Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox

lpcox commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

@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]>

Copilot AI commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@copilot merge main and resolve conflicts

Merged main and resolved the Dockerfile and packaging-test conflicts. Merge commit: 57acc72.

@lpcox
lpcox merged commit 14ddb65 into main Nov 23, 2026
37 of 39 checks passed
@lpcox
lpcox deleted the copilot/refactor-split-upstream-recovery branch November 23, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactoring] Split containers/api-proxy/upstream-attempt-recovery.js into focused modules

3 participants