Skip to content

refactor(router): move the selection core into the scheduler kernel - #143

Closed
ishandhanani wants to merge 1 commit into
idhanani/dyn-179-selection-boundaryfrom
idhanani/dyn-179-selection-core-move
Closed

ishandhanani wants to merge 1 commit into
idhanani/dyn-179-selection-boundaryfrom
idhanani/dyn-179-selection-core-move

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Step 6-4b of the router split v2 (DYNO-179). Stacked on #142. The last move of step 6: the selection core and the replica-sync channel plumbing leave lib/kv-router for lib/router/scheduler; kv-router keeps the HTTP server, the service builder, the ZMQ ingress, and shim submodules.

Summary

  • Moved (git mv): services/selection/{core/*, catalog, input, membership, pending, types, error, ingress}.rs -> dynamo_scheduler::selection::{..}; services/common/replication.rs -> dynamo_scheduler::replication (its standalone-selection gates dropped, its items pub; the slot-tracker service and the ZMQ mesh import it from the kernel). The kernel's selection module re-exports what kv-router's did; a new host module lists the kernel-facing surface a host implements or calls (hosts inventory section 3.6).
  • Import flip: crate::services::common::replication -> crate::replication; crate::services::indexer::{backend, registry} -> dynamo_kv_indexer::{backend, registry}; crate::services::overlap -> crate::overlap_summary; crate::scheduling::{queue, config, selector, router_config} -> crate::{queue, config, selector, config}; crate::sequences -> dynamo_slot_tracker; crate::indexer -> dynamo_kv_indexer; crate::WorkerSelectionPolicyFactory -> crate::types::..; super::affinity -> dynamo_session_affinity; default_routing_group joins the kernel's identity module.
  • kv-router: services/selection/mod.rs keeps server, service, zmq_ingress, tests, and the affinity alias, with private shim submodules core, error, ingress, input, pending, types over the kernel so every super:: path resolves, and re-exports every public name at its current path; services/common/mod.rs drops replication.
  • Tests: the core's white-box suite (4k lines, reaching 15 non-public members and three cfg(test) hooks) moves with the core on a kernel-native fixture in dynamo_scheduler::test_utils (test_router_config(use_kv_events, queue_threshold), local_test_core, test_core_with, reference_policy_factory); its flat-config footprint was one helper and three literals, now RouterConfig and its selection/conditional_disagg slices. The kernel fixture builds the indexer policy from use_kv_events (an approximate primary when events are off), as the flat conversion did. Six tests that need the ZMQ ingress, the service builder, or the flat configuration move to kv-router as services/selection/core_host_tests.rs over the public API (reupsert_recreates_a_listener_lost_to_a_cancelled_update reads the partition through core.partition() instead of the private entry; rejoined_worker_feeds_partition_index asserts the ZMQ ingress's detach, which the kernel's passive ingress does not do, and reads the index through the ingress's registry). The membership tests use the kernel fixture. What kv-router's server, service, ZMQ ingress, and HTTP tests reach became public: WorkerCatalogRecord::{key, dp_size, ensure_running, listener_endpoints}, PromptView::{normalize_for_selection, normalize_for_reservation}, TrackingHashInput, NormalizedPrompt and NormalizedReservation with their fields (the service tests drive normalization directly; moving those tests into the kernel is a follow-up), REQUEST_BODY_LIMIT_BYTES, SelectionCore::{with_session_binding_publisher, signal_indexer_ready, dispatch_replica_event, dispatch_affinity_event}, and a testing-gated SelectionCore::cancel_token().

Validation

  • cargo test -p dynamo-scheduler --features testing and --all-features: 291 passed, 1 ignored (174 before + the 117 moved core tests). cargo tree -p dynamo-scheduler -e normal stays free of dynamo-runtime, dynamo-kv-router, dynamo-zmq, axum, hyper, reqwest, zmq, prometheus.
  • cargo test -p dynamo-kv-router with standalone-selection,standalone-slot-tracker,metrics,testing: 241 + 2 + 7 (358 before; 358 - 117 = 241); default 133; standalone-slot-tracker only 155 (161 before: the six replication.rs tests moved with the module and run in the kernel).
  • cargo clippy -D warnings --all-targets: kernel (testing, --all-features), kv-router (full, default, slot-tracker only, indexer only, selection only), dynamo-llm -p dynamo-mocker -p dynamo-ext-proc -p dynamo-sglang-sidecar -p dynamo-custom-policy-builtin --tests --benches, dynamo-bench --tests; cargo check on the five custom-policy example crates.
  • cargo test -p dynamo-custom-policy-builtin all green; cargo test -p dynamo-llm kv_router 485, --lib router_policy 3, --lib watcher 36; cargo test -p dynamo-mocker --lib 304.
  • scripts/router_layering_check.sh: 26 checks, 0 failures. build_codeowners.py --strict ok. cargo fmt --all -- --check clean.
  • Move-diff (scripts/router_move_diff.py 1eca463e73 WORKTREE, kv-router services/selection/*, services/common/{replication,mod,replica_sync}.rs, services/slot_tracker/registry.rs, scheduling/mod.rs, kernel lib.rs/identity.rs/test_utils.rs/Cargo.toml -> kernel selection/, replication.rs, host.rs, those four, kv-router shims + core_host_tests.rs): common 10569 / new 290 / dropped 131. New and dropped lines are the visibility widening listed above, the crate::/super:: path rewrites to the owners, the kernel-native fixtures and the relocated tests' helpers, the shim submodules, the host list, default_routing_group, and the two kernel deps (uuid, once_cell).

Step 6-4b of the router split (DYNO-179), the last move of step 6. The
selection core (SelectionCore, its partitions, operations, reservations,
hints, queries, worker catalog, membership reconciler, request and
response DTOs, the selection cache, the error type, and the KvEventIngress
trait with its passive default) leaves lib/kv-router/src/services/
selection for dynamo_scheduler::selection, and the replica-sync channel
plumbing (services/common/replication.rs) becomes
dynamo_scheduler::replication, which the slot-tracker service and the ZMQ
mesh import from the kernel.

Imports flip from kv-router's shims to the owners (kv-indexer for the
backend and the index registry, slot-tracker for sequences,
worker-selection for the policy types, session-affinity for the affinity
table, the kernel's own modules for queue, config, selector, overlap
summary, tracking hash, and replication). The kernel gains a host module
listing the surface a host implements or calls.

kv-router keeps server.rs, service.rs, zmq_ingress.rs, the HTTP tests,
and the affinity alias, with shim submodules so every super:: path and
every public services::selection name still resolves; lib/llm, the
mocker, and the bindings compile unchanged until step 8.

Tests: the core's white-box suite moves with the core on a kernel-native
RouterConfig fixture (its flat-config footprint was one helper and three
literals; the fixture builds the indexer policy from use_kv_events as the
flat conversion did); the six tests that need the ZMQ ingress, the
service builder, or the flat configuration move to kv-router over the
public API.

Validation: cargo test -p dynamo-scheduler --features testing and
--all-features (291 passed, 1 ignored: 174 + the 117 moved core tests);
kv-router 241 + 2 + 7 under the full feature set (358 - 117), 133
default, 155 slot-tracker only (the replication tests run in the kernel
now); clippy -D warnings on the kernel (both feature sets), kv-router
(five feature sets), dynamo-llm, mocker, ext-proc, sglang-sidecar,
builtin (tests and benches), dynamo-bench, the five example crates;
builtin tests; lib/llm kv_router 485, router_policy 3, watcher 36;
mocker 304; router layering gate 26 checks; cargo tree on the kernel
free of dynamo-runtime, kv-router, zmq, axum, hyper, reqwest,
prometheus; codeowners strict; fmt. Move-diff against 1eca463:
common 10569 / new 290 / dropped 131 (visibility, path rewrites, the
fixtures, the shim submodules, the host list, two kernel deps).

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 — b31d493a Deployed Nov 2, 2026 by ishandhanani via ok-to-test #522
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant