Skip to content

fix(sid): revert count_over_time → ExactAgg(Sum) mis-routing - #212

Merged
zzylol merged 1 commit into
mainfrom
fix/revert-count-over-time-misrouting
May 14, 2026
Merged

zzylol merged 1 commit into
mainfrom
fix/revert-count-over-time-misrouting

Conversation

@zzylol

@zzylol zzylol commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

count_over_time was routed to the warm-tier ExactAgg path by PRs #200/#201 on the theory "count = sum-of-1s". But the data plane has no count accumulatorSumAccumulator only tracks sum: f64 and its query returns that sum for both Statistic::Sum and Statistic::Count. So count_over_time(m[5m]) matched against an m Sum policy returned the sum of sample values, not the sample count. Silently wrong.

This is a regression my own PRs #200/#201 introduced. Before them, capability_for(Count{Exact}) returned None → archive engine → correct count.

Changes

  • capability_for(Count{Exact})None (archive routing)
  • bind_exact_aggCount{Exact} arm removed
  • 4 tests updated

Count{Epsilon} (the count by (...) distinct-count idiom → CardinalityApprox) is unchanged.

Follow-up

The real fix — a SumCountAccumulator answering Sum/Count/Avg — lands with the temporal/spatial-split work.

Test plan

  • cargo check --workspace clean
  • cargo test --workspace --lib --bins green

🤖 Generated with Claude Code

`count_over_time` was routed to the warm-tier ExactAgg path by PRs
#200 (capability_for) and #201 (bind_exact_agg) on the theory
"count = sum-of-1s". But the data plane has no count accumulator:

  struct SumAccumulator { sum: f64 }   // no count field

  fn query(&self, statistic, ..) {
      match statistic {
          Statistic::Sum | Statistic::Count => Ok(self.sum),  // ← both!
          ...
      }
  }

`SumAccumulatorUpdater::update_single` does `self.sum += value` — no
projection-to-1 anywhere. So a `count_over_time(m[5m])` query matched
against an `m` Sum policy returned the **sum of the sample values**,
not the count of samples. Silently wrong.

This regression was introduced by my PRs #200/#201 — before them
`capability_for(Count{Exact})` returned `None` and the query went to
the archive engine, which counts correctly.

## Changes

- `capability_for(AggIntent::Count { accuracy: Exact })` →  `None`
  (was `Some(ExactAgg(Sum))`). `count_over_time` routes to archive.
- `bind_exact_agg` — `Count{Exact}` arm removed; the rule no longer
  emits `ExactAgg(Sum)` / `ExactAgg(MultipleSum)` for count.
- Tests updated: `capability_for_count_exact_routes_to_archive`,
  `exact_agg_routing_covers_sum_rate_increase_only`,
  `does_not_bind_count_exact`, `keyed_count_exact_does_not_bind`.

`AggIntent::Count { accuracy: Epsilon/EpsilonDelta }` is unchanged —
the approximate-count (`count by (...) (count_over_time(...))`
distinct-count idiom) still routes to `CardinalityApprox`.

## Follow-up

The correct fix — a real `SumCountAccumulator { sum, count }` that
answers Sum / Count / Avg — lands with the temporal/spatial-split
work. Until then, `count_over_time` and `avg_over_time` are
archive-served (correct, just not warm-tier-accelerated).

## Test plan

- [x] `cargo check --workspace` clean
- [x] `cargo test --workspace --lib --bins` green

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 76c6df9 into main May 14, 2026
@zzylol
zzylol deleted the fix/revert-count-over-time-misrouting branch July 17, 2026 20:05
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