feat(discovery): add InferencePool pod-to-worker projection #9954
All Vouch review confidence checks passed
Residual risk 0.31 = Change Risk (0.45) × (1 − Review Confidence (0.31)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 455 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 55% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.366
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #9954"
general
weight: 0.35
claude[bot]
Description
Stacked on #9949 (
feat/k8s-label-selector, base branch) and #9941 (feat/inference-pool-key, cherry-picked into this branch until both land onmain).Problem
SMG's Native Kubernetes Gateway API &
InferencePoolmode needs a deterministic projection from activeInferencePoolspecs and watched KubernetesPods into pool-scoped worker endpoints ready for reconciliation, enforcing namespace isolation, Pod readiness, pool-levelappProtocol(kubernetes.io/h2cvs HTTP), and IPv4/IPv6 URL formatting.Solution
Add an isolated
inference_poolmodule behind the existingkubernetesfeature insmg-service-discoveryprovidingInferencePoolTargetvalidation,project_inference_pool_endpoints, and crate-internalinference_pool_workersproducingDiscoveredWorkerrecords compatible withreconciler::DesiredStatewithout touching the existing Kubernetes provider or reconciler.Changes
crates/service_discovery/src/inference_pool.rs:-
H2C_APP_PROTOCOL(kubernetes.io/h2c),HTTP_APP_PROTOCOL(http),InferencePoolTargetError-
InferencePoolTarget(new,from_matcher,key,selector,target_ports,connection_mode,selects): validates non-emptyLabelSelectorMatcher, deduplicates non-zerotarget_ports, maps pool-levelapp_protocolfail-closed (Some("kubernetes.io/h2c")->ConnectionMode::Grpc,None | Some("http")->ConnectionMode::Http, anything else ->UnsupportedAppProtocol), and enforces strict same-namespace Pod selection-
InferencePoolEndpoint(url(),discovery_id()) andproject_inference_pool_endpoints: filters Ready, Running, non-terminating Pods with valid IPv4/IPv6 addresses, formats bracketed IPv6 URLs (http://[...]:port/grpc://[...]:port), and sorts pools deterministically byInferencePoolKey- Crate-internal
inference_pool_workers: stampssmg.ai/inference-pool,smg.ai/pod-name, andsmg.ai/pod-uidlabels with distinct{pool}:{uid}:{port}discovery IDs so pool reassignment replaces the worker cleanly and overlapping pools deterministically keep the lowestInferencePoolKeyinDesiredStatecrates/service_discovery/tests/unit/inference_pool/tests.rscovering multi-port projection, readiness/phase/termination/namespace filtering, HTTP vskubernetes.io/h2cgRPC + IPv6 bracketing,LeaderWorkerSetleader filtering, multi-pool isolation, deterministic overlap resolution, label stamping, and fail-closed spec validation#[cfg(feature = "kubernetes")] pub mod inference_pool;+ crate-root re-exports incrates/service_discovery/src/lib.rsRefs: #8616
Test Plan
cargo +nightly fmt --all -- --check: passed (exit 0)python3 scripts/check_unit_test_layout.py&./scripts/branch-name-check.sh: passed (exit 0)cargo clippy -p smg-service-discovery --all-targets -- -D warningsandcargo clippy -p smg-service-discovery --all-targets --all-features -- -D warnings: passed (0 errors, 0 crate warnings)cargo test -p smg-service-discovery --all-features:237 passed; 0 failed(including allinference_pool::tests::*cases)cargo check -p smg: passed (exit 0)Release note
none (internal
smg-service-discoveryprimitive behind thekubernetesfeature for upcoming Gateway APIInferencePoolworker discovery)<details>
<summary>Checklist</summary>
cargo +nightly fmtpassescargo clippy --all-targets --all-features -- -D warningspasses</details>