[TENT] Bind transport policies to intent type#2848
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces business-intent-based policy binding (intent_type) to the transport selector, allowing requests to match specific QoS and transport policies (such as foreground_get or checkpoint). It also adds command-line benchmark support and comprehensive unit tests. The review feedback highlights a critical issue where request merging does not group by intent_type, potentially causing QoS leakage. Additionally, the reviewer suggests making command-line intent parsing case-insensitive to prevent crashes and explicitly handling null JSON values for intent_type to avoid unexpectedly skipping catch-all policies.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| ctx.priority_level = | ||
| request.priority; // Use request priority for selection | ||
| ctx.policy_name = request.policy_name; // Optional: bind to specific policy | ||
| ctx.intent_type = request.intent_type; // Business intent policy filter |
There was a problem hiding this comment.
While intent_type is successfully propagated to the selection context here, the request merging logic in mergeRequests (and its helper can_merge) in this file does not check or sort by intent_type. Consequently, requests with different business intents (e.g., foreground_get and background_prefetch) can be merged into a single transfer task, causing one of the intents to be discarded and routed under the other's policy. To prevent this QoS/intent leakage, mergeRequests should be updated to group and merge requests by intent_type as well.
| auto it = kIntentTypes.find(intent_type); | ||
| LOG_ASSERT(it != kIntentTypes.end()) | ||
| << "Invalid --tent_intent_type=" << intent_type; | ||
| return it->second; |
There was a problem hiding this comment.
The lookup in kIntentTypes is case-sensitive. If a user passes --tent_intent_type with mixed or uppercase characters (e.g., Foreground_Get), the lookup will fail and trigger a crash via LOG_ASSERT. Converting the input string to lowercase before performing the lookup makes the command-line interface more robust and user-friendly.
| auto it = kIntentTypes.find(intent_type); | |
| LOG_ASSERT(it != kIntentTypes.end()) | |
| << "Invalid --tent_intent_type=" << intent_type; | |
| return it->second; | |
| std::string lower_intent = intent_type; | |
| std::transform(lower_intent.begin(), lower_intent.end(), lower_intent.begin(), | |
| [](unsigned char c) { return std::tolower(c); }); | |
| auto it = kIntentTypes.find(lower_intent); | |
| LOG_ASSERT(it != kIntentTypes.end()) | |
| << "Invalid --tent_intent_type=" << intent_type; | |
| return it->second; |
| if (policy_json.contains("intent_type")) { | ||
| auto intent = parseIntentType(policy_json["intent_type"]); | ||
| if (!intent.has_value()) { | ||
| LOG(WARNING) | ||
| << "Skip policy " << policy.name << ": invalid intent_type"; | ||
| continue; | ||
| } | ||
| policy.intent_type = *intent; | ||
| } |
There was a problem hiding this comment.
If a user explicitly configures "intent_type": null in the JSON policy, parseIntentType will return std::nullopt and cause the entire policy to be skipped with a warning. Explicitly handling null values as std::nullopt (which represents a catch-all/no-filter intent) is more robust and prevents unexpected policy skipping.
if (policy_json.contains("intent_type")) {
const auto& val = policy_json["intent_type"];
if (val.is_null()) {
policy.intent_type = std::nullopt;
} else {
auto intent = parseIntentType(val);
if (!intent.has_value()) {
LOG(WARNING)
<< "Skip policy " << policy.name << ": invalid intent_type";
continue;
}
policy.intent_type = *intent;
}
}|
Superseded by ; the final source branch is intent-policy-binding, with the same commit 194ea22. |
Summary
Request::intent_typeinto transport policy selectionintent_typefilter in configured TENT policiespolicy_nameoverridesCompatibility
Policies without
intent_typematch every intent exactly as before. Requestswith
INTENT_UNSPECtherefore retain the existing selection behavior unless anoperator explicitly configures an
intent_unspecrule.Test plan
tent_transport_selector_testandtent_intent_type_testServer validation used commit
964a590d, fetched directly from GitHub. Theupstream GitHub Actions matrix is still running; this PR remains Draft until
the TENT CUDA-on/off jobs complete.