Skip to content

feat(intent_algebra): thread the actual item filter value into Frequency (Phase 3a) - #415

Merged
zzylol merged 1 commit into
mainfrom
feat/thread-frequency-item-filter-value
Jul 27, 2026
Merged

zzylol merged 1 commit into
mainfrom
feat/thread-frequency-item-filter-value

Conversation

@zzylol

@zzylol zzylol commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Phase 3 (of 5) of the named-key SketchQuery::PointCount gap — workload-driven half only. Based directly on main (#162/#413/#414 already merged).

Split from the original Phase 3 scope after investigation: the PromQL-string-driven half (recognizing a bare count(metric{item="x"}) and resolving item against a metric's configured item-label at parse time) needs a new metric→item_label lookup threaded through parse_query_expr_canonical (18 call sites) and QueryWorkload (31 struct-literal sites, no Default) — a genuinely larger, separate task, still deferred. This PR does the achievable, low-risk half.

  • frequency(accuracy, item: Option<(String, String)>) now embeds item_label/item_value into the Extension payload when a specific item is being filtered on. ControlPlaneCostModel::readout_extension (from feat(sketch_algebra): realize Frequency (AggIntent::Extension) as a real Cms sketch #413) already reads these exact keys back out — this closes the other half of that wiring, not a new payload shape.
  • default_frequency() stays 0-arg (passes None), so the two PromQL-driven lower.rs call sites (agg_func_to_intents) are untouched — only the 4 other direct frequency() callers (3 tests + 1 real) needed updating for the new parameter.
  • bind_workload_typed gains a sibling, bind_workload_typed_with_item_filter, rather than adding an item_label field to QueryWorkload itself (which would break all 30+ struct-literal construction sites, no Default impl to fall back on).
  • Wired at the one real call site that already has everything needed in scope with zero new lookups: emit::collect_metric_to_family's loop already walks WorkloadEntry (has item_label) and QueryWorkload (has label_filters) together.

Test plan

  • cargo test -p control_plane --lib — 766 passed, 1 failed (the same single pre-existing, unrelated failure present on unmodified main).
  • New test bind_workload_typed_with_item_filter_threads_the_actual_value — proves both directions: no filter still reads out as the bare bucket total (PointCount{key: SampleValue, value: None}, unchanged), and a real (label, value) filter reads out as PointCount{key: Named(label), value: Some(value)}.
  • cargo build --workspace — clean.
  • cargo clippy -p control_plane --lib --tests — verified every warning falls outside this diff's touched line ranges (all pre-existing).
  • rustfmt scoped to touched files only.

Remaining deferred: the PromQL-string bare-count() recognition half, and the overarching goal (wiring SummaryExecutor into the live serving path, retiring sketch_reducer.rs).

🤖 Generated with Claude Code

Phase 3a of the named-key PointCount gap (workload-driven half only --
the PromQL-string bare-count() recognition half needs a new
metric->item_label lookup mechanism threaded through
parse_query_expr_canonical's 18 call sites and is deferred separately).

frequency(accuracy, item: Option<(String, String)>) now embeds
item_label/item_value into the Extension payload when a specific item is
being filtered on -- ControlPlaneCostModel::readout_extension (added in
the Frequency-realization PR) already reads these same keys back out, so
this is the missing half of that wiring, not new payload shape.
default_frequency() stays 0-arg (passes None), so the two PromQL-driven
lower.rs call sites are unaffected -- only the 4 other direct frequency()
callers (3 tests, 1 real) needed updating for the new parameter.

bind_workload_typed gains a sibling, bind_workload_typed_with_item_filter,
rather than adding an item_label field to QueryWorkload (which would
break its 30+ struct-literal construction sites with no Default impl).
Wired at the one real call site that already has both pieces needed in
scope without any new lookup: emit::collect_metric_to_family's loop
already walks WorkloadEntry (item_label) and QueryWorkload
(label_filters) together.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zzylol
zzylol merged commit 4d12cfe into main Jul 27, 2026
@zzylol
zzylol deleted the feat/thread-frequency-item-filter-value branch September 12, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant