Skip to content

rqe-optimizer: split SumOrCount and TopK; deny unknown AtomicCostEntry fields - #163

Merged
milindsrivastava1997 merged 3 commits into
mainfrom
161-rqe-optimizer-split-sumorcount-into-sum-and-count-deny-unknown-atomiccostentry-fields
Oct 7, 2026
Merged

milindsrivastava1997 merged 3 commits into
mainfrom
161-rqe-optimizer-split-sumorcount-into-sum-and-count-deny-unknown-atomiccostentry-fields

Conversation

@milindsrivastava1997

@milindsrivastava1997 milindsrivastava1997 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #161 (§1–§3).

Changes

  • rqe-optimizer: Capability::SumOrCount → Sum and Count, both with family exact-sum. Since a Deployment is keyed by capability, a sum and a count query (ASAPQuery's avg rewrite) can no longer share one accumulator.
  • rqe-optimizer: Capability::TopK → TopKByValue (topk(k, sum_over_time(...))) and TopKByCount (topk(k, count_over_time(...))), both with the same three top-k families. ASAPQuery deploys them with different count_events, so they must not share a deployment.
  • aqpbm-core: #[serde(deny_unknown_fields)] on AtomicCostEntry and MeasuredAt.
  • aqpbm-datagen: the same on ZipfParameter, UniformParameter, NormalParameter, ParetoParameter (nested in MeasuredAt via DataDistribution). merged_record.schema.json regenerated (additionalProperties: false on each).

Tests

  • plan_never_serves_paired_capabilities_from_one_deployment: builds candidates from one cost row and solves the MILP. Control: two identical queries share one deployment (sharing halves ingest, so the MILP shares whenever it may). Then (Sum, Count) and (TopKByValue, TopKByCount) must each use two. Verified it fails when the capability check in is_eligible is removed.
  • a_row_with_an_unknown_field_is_rejected (merge_acuracy), measured_at_with_an_unknown_field_is_rejected (value_rnage), a_distribution_with_an_unknown_field_is_rejected (skewnes).

Design decisions (please approve)

  1. Sum and Count both keep exact-sum as their only family; they just never share a deployment.
  2. RateOrIncrease stays merged: rate is increase / window, so one exact-increase accumulator serves both correctly, and splitting would double cost when both are queried.
  3. sketch-bench's own Capability::SumOrCount (registry row, sum-or-count comparator, export script) is unchanged: it labels a measurement, not deployment sharing, and one exact-sum measurement prices both.
  4. deny_unknown_fields also goes on the nested MeasuredAt, since serde's attribute doesn't propagate and a misspelled value_range would otherwise load as None.
  5. The distribution parameter structs also get deny_unknown_fields, closing the last nested gap. They are datagen config types too, so datagen YAML gets stricter; all 33 checked-in distribution blocks still parse. (Internally tagged: serde strips kind before the inner struct sees it.)
  6. Top-k is split as two capabilities rather than a count_events field on Raqe: eligibility and pruning already compare capability, whereas a field would also have to go on Deployment and into every comparison.
  7. Names TopKByValue / TopKByCount (the issue's suggestion); both keep the current top-k families and the same output-size estimate.
  8. The sharing test checks the solved plan rather than candidate eligibility, which only restated is_eligible's capability comparison.

🤖 Generated with Claude Code

…icCostEntry fields

Sum and count shared one capability, so the MILP could serve both items of
ASAPQuery's avg rewrite from one exact-sum accumulator, undercounting ingest
and memory ~2x. They are now separate capabilities on the same family.

AtomicCostEntry and MeasuredAt now reject unknown fields, so a misspelled or
newer field fails to load instead of dropping its data.

Closes #161

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Value-weighted and count-weighted top-k queries at the same cadence became
identical Raqes, so the MILP could serve both from one CMS-heap that
ASAPQuery deploys as two (different count_events). Separate capabilities
on the same families keep them apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milindsrivastava1997 milindsrivastava1997 changed the title rqe-optimizer: split SumOrCount into Sum and Count; deny unknown AtomicCostEntry fields rqe-optimizer: split SumOrCount and TopK; deny unknown AtomicCostEntry fields Oct 7, 2026
The distribution parameter structs nested in MeasuredAt now deny unknown
fields too, so a typo like `skewnes` fails instead of being dropped. All
checked-in distribution blocks still parse; the schema snapshot is
regenerated.

The sharing test now solves the MILP from a cost row: two identical queries
must share one deployment (sharing halves ingest), and paired capabilities
must not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milindsrivastava1997
milindsrivastava1997 merged commit f8c845f into main Oct 7, 2026
2 checks passed
@milindsrivastava1997
milindsrivastava1997 deleted the 161-rqe-optimizer-split-sumorcount-into-sum-and-count-deny-unknown-atomiccostentry-fields branch October 7, 2026 02:36
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.

rqe-optimizer: split SumOrCount and TopK by kind; deny unknown AtomicCostEntry fields

1 participant