Skip to content

refactor(router): cut the selection core's last ties to the composed router - #142

Closed
ishandhanani wants to merge 1 commit into
idhanani/dyn-179-scheduler-cratefrom
idhanani/dyn-179-selection-boundary
Closed

ishandhanani wants to merge 1 commit into
idhanani/dyn-179-scheduler-cratefrom
idhanani/dyn-179-selection-boundary

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Step 6-4a of the router split v2 (DYNO-179). Stacked on #141. Behavior-preserving boundary changes inside today's crates, so that 6-4b can move the selection core into the kernel as a pure move.

Summary

  • Overlap summary to the kernel. MooncakeOverlapSummary, build_mooncake_overlap_summaries, and their tests move from kv-router services/overlap.rs to dynamo_scheduler::overlap_summary (built from the kernel's SelectedWorkerTierSnapshot and kv-indexer's match details; the kernel re-exports the type at its root). from_selected_worker_tiers loses its standalone-selection gate and both functions become pub; kv-router's services::overlap re-exports them for the indexer HTTP server.
  • Policy-factory hook to the kernel. WorkerSelectionPolicyFactory (Arc<dyn Fn(&SelectionConfig, WorkerType, RoutingPartitionRef) -> WorkerSelectionPolicy>) is dynamo_scheduler::types::WorkerSelectionPolicyFactory; plugins::worker_selection re-exports it, so plugin authors' path is unchanged.
  • Builder config to the builder. SelectionServiceConfig (the CLI's and the Python bindings' struct, carrying the flat KvRouterConfig) moves from core/mod.rs to service.rs next to its service_builder; services::selection::SelectionServiceConfig still resolves.
  • Constructors. SelectionCore::new_inner becomes the public SelectionCore::new (every input a resolved slice or a host hook). try_new_local / try_new_local_with_host (apply the policy file, validate, resolve the tracking hash and indexer policy, then new) leave the core as kv-router free functions local_selection_core / local_selection_core_with_host, exported from services::selection; the bench-only bench_try_new_local_with_host is subsumed. Callers updated: kv-router benches/selection_core.rs, the builtin bench and tests, membership.rs tests, core/tests.rs, new_local_for_test, and lib/llm's router_policy.rs test fixture.

With this, nothing in services/selection/{core, catalog, input, membership, pending, types, error} names KvRouterConfig, the plugin registry, or a transport; 6-4b moves those files and services/common/replication.rs into lib/router/scheduler/src/selection/ and adds the host list (inventory split-v2/inventory-scheduler.md §8).

Validation

  • cargo test -p dynamo-scheduler --features testing: 174 (the three overlap-summary tests joined the kernel's 171); cargo clippy --all-targets -- -D warnings on the kernel under testing and --all-features: clean.
  • cargo test -p dynamo-kv-router: 358 lib + 2 plugin-API + 7 standalone-HTTP under the full service feature set (358 + the 3 moved = the pre-change 361); 133 lib with default features; 161 lib with standalone-slot-tracker alone.
  • cargo clippy --all-targets -- -D warnings: kv-router under the full, default, slot-tracker-only, indexer-only, and selection-only feature sets; downstream dynamo-llm, dynamo-mocker, dynamo-ext-proc, dynamo-sglang-sidecar, dynamo-custom-policy-builtin (tests and benches), dynamo-bench --tests; the five example policy crates check: clean.
  • Builtin policy tests 56+5+1+3+20+3+4; cargo test -p dynamo-llm kv_router 485, --lib router_policy 3 (the fixture now calls local_selection_core), --lib watcher 36; cargo test -p dynamo-mocker --lib 304.
  • scripts/router_layering_check.sh: 26 checks, 0 failures. CODEOWNERS --strict clean. cargo fmt --all -- --check clean.
  • scripts/router_move_diff.py 7179215b31 WORKTREE over the touched files (+ overlap_summary.rs on the head side): common=7460 new=30 dropped=43; every new line is SelectionCore::new / local_selection_core* replacing new_inner / try_new_local* (and the removed bench_try_new_local_with_host wrapper), the factory alias with path-qualified stage types, pub on the two overlap functions and ReplicaSyncConfig (now named by a public constructor), and the callers' new names. No logic line changed (artifact s6-4a-move-diff.txt).

…router

Step 6-4a of the router split (DYNO-179): the boundary changes the
selection core needs before it moves into the kernel crate, each inside
today's crates.

The Mooncake overlap summary (MooncakeOverlapSummary,
build_mooncake_overlap_summaries) is kernel output vocabulary built from
the kernel's SelectedWorkerTierSnapshot and kv-indexer's match details;
it moves to dynamo_scheduler::overlap_summary, and kv-router's
services::overlap re-exports it for the indexer HTTP server.

WorkerSelectionPolicyFactory, the hook that builds a partition's policy
from the selection slice, the worker type, and the partition, is built
from stage and protocol types only; it moves to dynamo_scheduler::types
and plugins::worker_selection re-exports it.

SelectionServiceConfig carries the flat KvRouterConfig for the CLI and
the Python bindings; it belongs to the builder and moves to service.rs
beside its service_builder impl, exported at the same path.

SelectionCore::new_inner becomes the public SelectionCore::new: every
input is a resolved slice or a host-owned hook, and the builder calls
it. The flat-config conveniences try_new_local and
try_new_local_with_host leave the core, where they could not stay once
the type is foreign, and become local_selection_core and
local_selection_core_with_host in kv-router's selection service; their
callers (the kv-router and builtin benches, the builtin and membership
tests, lib/llm's router-policy test fixture, the core tests) call the
free functions.

Validation: move-diff vs 7179215 common=7460 new=30 dropped=43 (the
renamed constructors and callers, the path-qualified factory alias, and
visibility; no logic line changed); cargo test -p dynamo-scheduler --features
testing (174: the three overlap-summary tests joined the kernel) and
clippy -D warnings on it under testing and all features; cargo test -p
dynamo-kv-router under the full service feature set (358 lib + 2
plugin-API + 7 standalone HTTP; 358 + 3 = the pre-change 361), with
default features (133), and under standalone-slot-tracker alone (161);
clippy -D warnings all targets on kv-router under five feature sets, on
dynamo-llm, dynamo-mocker, dynamo-ext-proc, dynamo-sglang-sidecar,
dynamo-custom-policy-builtin (tests and benches), dynamo-bench, and the
five example policy crates; builtin tests 56+5+1+3+20+3+4; cargo test -p
dynamo-llm kv_router (485), --lib router_policy (3), --lib watcher
(36); dynamo-mocker --lib 304; router layering gate 26 checks, 0 failures;
CODEOWNERS strict clean; cargo fmt --check clean.

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
@ishandhanani

Copy link
Copy Markdown
Owner Author

Landed upstream as ai-dynamo#18055 (squash commit 79692cf on main, 2026-11-11). Closing this fork review unit.

This branch had an error being deployed

1 failed deployment
external_collaborator — a40709a1 Deployed Nov 2, 2026 by ishandhanani via ok-to-test #487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant