Skip to content

Split routing controller into stage, classification, and observation modules - #11908

Merged
lpcox merged 5 commits into
mainfrom
copilot/refactor-split-creatoroutingcontroller-execute
Nov 21, 2026
Merged

lpcox merged 5 commits into
mainfrom
copilot/refactor-split-creatoroutingcontroller-execute

Conversation

@lpcox

@lpcox lpcox commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

execute() combines bounded preparation, classifier retries, route selection, and observation construction. This refactor separates those concerns while preserving routing behavior.

  • Stages: Extract health, capabilities, candidate discovery, and immutable conversation loading into routing-stages.js.
  • Classification: Move request construction, capacity preflight, retries, and output validation into routing-classify.js.
  • Observations: Centralize attempt, selection, and failure records in routing-observation-records.js, preserving fields and observer-failure isolation.
  • Integration: Retain controller sequencing, selection logic, signature, and exported constants; add extracted modules to Docker packaging.

@lpcox lpcox changed the title [WIP] Refactor createRoutingController execute() into stage and observation modules Split routing controller into stage, classification, and observation modules Nov 21, 2026
@lpcox
lpcox marked this pull request as ready for review November 21, 2026 16:38
Copilot AI adaptive review requested due to automatic review settings November 21, 2026 16:38

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.

🔵 Needs a closer look

The asynchronous routing refactor requires integration-level review of how classifier retries interact with shared deadlines, cancellation, pinned eligibility, final guards, and observation behavior across provider paths.

No open issues 🎉

What changed in this PR

This PR separates the API proxy’s routing workflow into focused modules, leaving sequencing and route selection in the controller while preserving its public interface.

Changes:

  • Extracts bounded preparation stages and classifier execution logic.
  • Centralizes classification-attempt, selection, and failure records.
  • Adds focused unit tests and packages the new modules in the Docker image.
File Description
containers/​api-proxy/​routing-stages.test.js Tests preparation, validation, deadlines, and cancellation.
containers/​api-proxy/​routing-stages.js Extracts health, capabilities, candidates, and immutable conversation loading.
containers/​api-proxy/​routing-observation-records.test.js Tests record fields and observer-failure isolation.
containers/​api-proxy/​routing-observation-records.js Centralizes attempt, selection, and failure records.
containers/​api-proxy/​routing-controller.js Delegates extracted logic while retaining sequencing, selection, and constants.
containers/​api-proxy/​routing-classify.test.js Tests classifier requests, capacity checks, retries, and terminal failures.
containers/​api-proxy/​routing-classify.js Extracts classifier planning, execution, and output validation.
containers/​api-proxy/​Dockerfile Includes the extracted modules in the container image.

Review effort: Max (adaptive)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@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.

conversation, pool, planner, executor, observer, eligibilityRequest,
callPlanner, signal, deadline, clock, attemptTimeoutMs, maxAttempts, purpose,
}) {
const sanitizedConversation = sanitizeConversationPayload(conversation);
@lpcox

lpcox commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot merge main, resolve conflicts, and address review feedback

lpcox and others added 2 commits November 21, 2026 17:45
…t-creatoroutingcontroller-execute

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

@copilot merge main, resolve conflicts, and address review feedback

Merged main in 2d8eb93 and addressed the review in 24d50dd. Targeted routing tests pass; the full suite encountered missing local packaging dependencies. CodeQL skipped JavaScript analysis due to database size.

@lpcox
lpcox merged commit e0635dd into main Nov 21, 2026
37 of 39 checks passed
@lpcox
lpcox deleted the copilot/refactor-split-creatoroutingcontroller-execute branch November 21, 2026 18:11
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 createRoutingController execute() in routing-controller.js into stage and observation modules

4 participants