Skip to content

Refactor upstream dispatch into focused guard and transport modules - #12003

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

lpcox merged 4 commits into
mainfrom
copilot/refactor-upstream-dispatch-into-modules

Conversation

@lpcox

@lpcox lpcox commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

dispatchUpstreamRequest mixed security gates, credential signing, transport setup, and response recovery in one large closure. This split narrows those responsibilities without changing the factory API.

  • Guards: Extract reasoning-effort validation and enclave budget rejection, retaining error responses, metrics, and diagnostic events.
  • Transport: Extract signing, credential tracking, signing-failure handling, and HTTP/HTTPS request options.
  • Orchestration: Keep cancellation, body rewriting, recovery, and response wiring in the dispatcher.
  • Packaging: Add both modules to Docker’s explicit COPY list and packaging assertions.
  • Coverage: Add dedicated regression tests for rejection paths, budget-rewritten signing, credential masking, cancellation, and transport options.

@lpcox lpcox changed the title [WIP] Refactor upstream dispatch into focused modules Refactor upstream dispatch into focused guard and transport 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 path filter omits both extracted modules, so changes confined to them will skip the main-branch live routing and reasoning-effort smoke tests.

1 open issue
What changed in this PR

Refactors AWF’s API-proxy upstream dispatcher into focused guard and transport modules, addressing #11996 while preserving the factory API.

Changes:

  • Extracts reasoning-effort validation and enclave budget rejection into dedicated guards.
  • Separates signing, credential tracking, and transport options from request orchestration and response handling.
  • Adds regression coverage and updates container packaging for the new modules.
File Description
containers/​api-proxy/​upstream-dispatch.test.js Adds regression tests for guards, signing, credential masking, cancellation, and transport options.
containers/​api-proxy/​upstream-dispatch.js Delegates guard and transport responsibilities while retaining orchestration.
containers/​api-proxy/​upstream-dispatch-transport.js Implements signing, credential tracking, signing-failure handling, and request options.
containers/​api-proxy/​upstream-dispatch-guards.js Implements validation and budget rejection with existing responses and diagnostics.
containers/​api-proxy/​protocol-compatibility.packaging.test.js Checks that both extracted modules are packaged.
containers/​api-proxy/​Dockerfile Adds both modules to the explicit container copy list.

Review effort: Max (adaptive)

Comment on lines +6 to +7
const { rejectInvalidReasoningEffort, rejectEnclaveBudgetAttempt } = require('./upstream-dispatch-guards');
const { signOutboundRequest, buildUpstreamRequestOptions } = require('./upstream-dispatch-transport');
@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 model-routing workflow path filter in commit f0daa6b.

@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 merged commit 0229cff into main Nov 23, 2026
37 of 39 checks passed
@lpcox
lpcox deleted the copilot/refactor-upstream-dispatch-into-modules branch November 23, 2026 16:47
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-dispatch.js into focused modules

3 participants