Skip to content

rs-drive: GroupByIn + range no-proof folds In branches #3716

@thepastaclaw

Description

@thepastaclaw

GroupByIn range no-proof folds In branches

Summary

AverageMode::GroupByIn promises one aggregate entry per In value, but the
no-proof range path folds all In branches into a single aggregate entry with
in_key: None / empty key. The prove path preserves per-In branches, so
prove and no-proof behavior diverge for the same query shape.

Found while reviewing #3603, but this is pre-existing query-layer behavior, not
a regression from that shielded-spend PR.

Details

Relevant path:

  • packages/rs-drive/src/query/drive_document_count_and_sum_query/drive_dispatcher.rs

When AverageMode::GroupByIn is combined with a range clause, the no-proof
branch unwraps the joint executor's folded Aggregate { count, sum } and
rewraps it as a single AverageEntry. That loses the In axis entirely, so
callers cannot distinguish which In value contributed what.

This conflicts with:

  • AverageMode::GroupByIn docs in drive_document_average_query/mod.rs, which
    describe one entry per In value.
  • The prove path in drive_document_average_query/drive_dispatcher.rs, which
    preserves per-In branches for GroupByIn + range.

Expected resolution

Either:

  1. Preserve per-In (count, sum) entries on the no-proof path, matching the
    documented GroupByIn contract and the prove path, or
  2. Update the public AverageMode::GroupByIn documentation to explicitly state
    that GroupByIn + range no-proof queries fold across In values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions