You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mod.rs:1904 — A missing/unparseable k kwarg silently skips ranking/truncation but still runs formatting, returning the full unranked result set as if it were valid topk output. Under normal PromQL context construction this should be unreachable because k extraction is fallible upstream, but it remains an internal invariant/defensive-programming gap.
mod.rs:1891 — (enable_topk_limiting=false, enable_topk_formatting=true) does not run range ranking/truncation. This is not currently observable: range results have no meaningful outer ordering, and all current call sites pass both flags together. The flags' contract should be clarified or simplified to prevent a future caller from assuming instant-query-like semantics.
stage_e_instant_range_equivalence_tests.rs:623 — Stale comment: it claims the topk sort has “no tiebreak,” but mod.rs:1939-1942 already implements the deterministic label-value tiebreak described by the test. Update the comment.
mod.rs:1890 — apply_range_topk's bool params are ordered (formatting, limiting), opposite the (limiting, formatting) convention used by sibling functions in the same file.
mod.rs:1904 — The k-kwarg parsing expression is duplicated verbatim between apply_range_topk and execute_query_pipeline instead of a shared helper.
mod.rs:1972 — The metric-name-prepend rewrite for topk labels is duplicated in intent between apply_range_topk and format_final_results; a shared helper would prevent the two output paths drifting.
mod.rs:1939 — Candidate list is fully sorted (O(G log G)) per timestamp before truncating to k; select_nth_unstable_by would suffice in expected O(G).
mod.rs:1953 — results.retain and the following values_mut() loop are two separate full passes over the map that could be fused into one.
Already covered by existing tests.topk_range_step_major_ranking_differs_per_step uses the self-keyed fixture with three candidates and topk(2), so it exercises self-keyed expansion together with real truncation. The separately named fix(query-engine): range queries expand keys_query per output step #595 regression uses topk(5) and does not truncate, but this is not a coverage gap.
Findings from a code review of PR #629 (computed top-k for range PromQL queries).
topk()(for example,topk(k,a)+b) have two pre-existing metric-name/label-matching failures. topk(...) as a binary-expr arm: __name__ label mismatch (pre-existing) and metric-name-in-join corruption (#629 Finding 1) #631 contains the reproductions and is the correct issue for the functional fix.mod.rs:1904— A missing/unparseablekkwarg silently skips ranking/truncation but still runs formatting, returning the full unranked result set as if it were valid topk output. Under normal PromQL context construction this should be unreachable becausekextraction is fallible upstream, but it remains an internal invariant/defensive-programming gap.mod.rs:1891—(enable_topk_limiting=false, enable_topk_formatting=true)does not run range ranking/truncation. This is not currently observable: range results have no meaningful outer ordering, and all current call sites pass both flags together. The flags' contract should be clarified or simplified to prevent a future caller from assuming instant-query-like semantics.stage_e_instant_range_equivalence_tests.rs:623— Stale comment: it claims the topk sort has “no tiebreak,” butmod.rs:1939-1942already implements the deterministic label-value tiebreak described by the test. Update the comment.mod.rs:1890—apply_range_topk's bool params are ordered(formatting, limiting), opposite the(limiting, formatting)convention used by sibling functions in the same file.mod.rs:1904— Thek-kwarg parsing expression is duplicated verbatim betweenapply_range_topkandexecute_query_pipelineinstead of a shared helper.mod.rs:1972— The metric-name-prepend rewrite for topk labels is duplicated in intent betweenapply_range_topkandformat_final_results; a shared helper would prevent the two output paths drifting.mod.rs:1939— Candidate list is fully sorted (O(G log G)) per timestamp before truncating to k;select_nth_unstable_bywould suffice in expected O(G).mod.rs:1953—results.retainand the followingvalues_mut()loop are two separate full passes over the map that could be fused into one.topk_range_step_major_ranking_differs_per_stepuses the self-keyed fixture with three candidates andtopk(2), so it exercises self-keyed expansion together with real truncation. The separately named fix(query-engine): range queries expand keys_query per output step #595 regression usestopk(5)and does not truncate, but this is not a coverage gap.🤖 Generated with Claude Code