Repository navigation
refactor(kv-router): one Indexer type, partition-owned index, KvEventIngress - #41
Closed
ishandhanani wants to merge 3 commits into
Closed
ishandhanani wants to merge 3 commits into
ishandhanani wants to merge 3 commits into
Conversation
…ion service lib/llm and lib/kv-router each carried an Indexer enum with the same Single/Concurrent/Remote shape (primary, lower tiers, predict-on-route side overlay, primary_records_routing_decisions) and diverging method sets. Fold the frontend's richer implementation into dynamo_kv_router::services::indexer: - lookup.rs: the borrowed/owned HashInput lookup pipeline (primary, lower tiers seeded from confirmed primary matches, side overlay merged by per-worker max), find_matches_by_tier[_ref][_with_options], find_primary_*. - recording.rs: routing-decision recording targets (side overlay, approximate primary, remote primary) and the per-request ApproximateRequestLease. - backend.rs: the merged enum gains None, residency projection setters, try_apply_event (the backpressure-aware admit with a completion barrier on Cleared that recovery relies on), reset_worker_dp_rank_and_wait, and the approximate-LRU capacity and stats API. apply_event_routed and remove_worker[_dp_rank] stay as the standalone listener's path. Remote primaries go behind RemotePrimary so the HTTP standalone client here and the request-plane RemoteIndexer in lib/llm plug into the same enum. dump_events returns KvRouterError like the rest of the surface. - The frontend keeps only construction (indexer::build from KvRouterConfig with component metrics and the request-plane remote), the served-indexer service, and recovery. Its 16 indexer tests move with the code. No behavior change: both hosts run the exact code they ran before for their own paths; TieredMatchProvider keeps the capability-gated variant. Signed-off-by: Ishan Dhanani <[email protected]>
KvIndexSource::External { refresh } gave the core only a refresh handle onto
an index the host kept elsewhere. Replace it with Provided(Arc<Indexer>): the
host builds and feeds the index, and the core holds it as every partition's
index, reading it for selection and dequeue-time refresh (when the index
supports refresh) and never writing to it. The frontend's embedded partition
now shares the KvRouter's Indexer object instead of a TieredMatchProvider
view of it. RefreshProvider loses its External variant.
Signed-off-by: Ishan Dhanani <[email protected]>
KvIndexSource::Owned carries the ingress that feeds the core-built index. The trait decides what metadata a worker needs to be schedulable, attaches its ranks when the worker becomes schedulable, and detaches them when it leaves. ZmqDirectIngress is the existing standalone behavior moved out of SelectionCore: endpoint validation, one ZMQ listener per rank on the registry, replay endpoint, deregistration on delete. The core keeps the lifecycle decisions (when to attach, how to mark Incomplete) and no longer knows about ZMQ endpoints. Signed-off-by: Ishan Dhanani <[email protected]>
ishandhanani
had a problem deploying
to
external_collaborator
September 4, 2026 00:03 — with
GitHub Actions
Failure
Owner
Author
Group C exit gate: router e2e with mockers (this head,
|
This was referenced Sep 4, 2026
Closed
Owner
Author
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack 1, group C (KV index and ingress), second slice. Stacked on #39. DEP #33, "Stack 1 DEP r2" comment.
Summary
Three logical commits:
refactor(kv-router): one Indexer type for the frontend and the selection service—lib/llmandlib/kv-routereach had anIndexerenum with the sameSingle/Concurrent/Remoteshape and diverging method sets. The frontend's richer implementation moves intodynamo_kv_router::services::indexer(lookup.rs: borrowed/owned lookup pipeline;recording.rs: routing-decision recording targets andApproximateRequestLease;backend.rs: merged enum withNone, residency setters,try_apply_event,reset_worker_dp_rank_and_wait, approximate-LRU API). Remote primaries sit behindRemotePrimary, implemented by the HTTP standalone client in kv-router and by the request-planeRemoteIndexerinlib/llm. The frontend keeps construction (indexer::build, component metrics, request-plane remote), the served-indexer service, and recovery. Its 16 indexer tests move with the code. Net forlib/llm: -1,200 lines.refactor(kv-router): the frontend's index is the partition's index—KvIndexSource::External { refresh }becomesProvided(Arc<Indexer>): the host builds and feeds the index, the core holds it as every partition's index, reads it for selection and dequeue-time refresh, and never writes to it. The frontend's embedded partition now shares theKvRouter'sIndexerobject.RefreshProviderloses itsExternalvariant.feat(kv-router): KvEventIngress feeds core-owned indexes—KvIndexSource::Owned(Arc<dyn KvEventIngress>). The trait decides what metadata a worker needs, attaches its ranks when it becomes schedulable, detaches on delete.ZmqDirectIngressis the previous in-core listener code moved out ofSelectionCore, which no longer knows about ZMQ endpoints.lib/kv-routerstill never importsdynamo-runtime.No behavior change
try_apply_eventviaRecoveryTarget), same lookups (find_matches_by_tier*), same metrics type (KvIndexerMetrics::from_componentwas already the kv-router type).apply_eventon the shared enum is the standalone device-only apply; the frontend's test-onlyapply_eventshim is gone and its tests calltry_apply_event.kv_events endpoint is required for dp_rank N), sameapply_event_routedandremove_workerpaths.TieredMatchProvider for Indexerkeeps the capability-gated retention variant, which is what both hosts relied on.What remains in group C
RuntimeIngress: the frontend still feeds its index fromKvRouter::new(subscriber, worker-query recovery, state agent, source health, served indexer, approximate-LRU reconciler). Making that anOwned(RuntimeIngress)requires the core to build the frontend's index shape (component metrics, request-plane remote, LRU retention with lease fencing) or the ingress to build it, and moving the recovery state machine into the core means abstracting the event subscriber and worker-query transport (WorkerQueryTransportexists;EventSubscriberdoes not). ~11k transport-bound lines; the deletion gate from the DEP (replay parity, e2e) applies.Providedis the boundary until then, and peer/dumprecovery stays for the standalone service because its cold start has no engine-authoritative full dump yet.Validation
cargo test -p dynamo-kv-router --features standalone-selection --lib: 1088 passed (16 moved indexer tests included).cargo test -p dynamo-llm --lib: 2537 passed after commit 1;kv_router::309 passed at the tip.cargo test -p dynamo-ext-proc: 141 passed.cargo clippyfordynamo-kv-router(featurestandalone-selection),dynamo-llm,dynamo-ext-proc(tests): clean. Bindingscargo check: clean.Review notes (graham-code-review pass)
Provided(Arc<Indexer>)rather thanProvided(Indexer): clippy flagged the variant size, andRefreshProvideralready holds anArc<Indexer>.Providedindex (cleanup_indexer_registrationreturns early): the frontend's recovery machinery owns rank resets, and letting the core callremove_workeron catalog delete would have been a behavior change.KvEventIngress::attach/detachtake theWorkerRegistrybecause the registry holds the per-rank listener lifecycle alongside the indexes today; splitting the registry is not this PR's job.SideIndexer::newgained the cancellation token the frontend always passed; the registry passes a fresh token as before.