Expand description
Versioned mode detection for the sum-query dispatcher.
detect_sum_mode classifies a DocumentSumRequest into one of
the DocumentSumMode variants by inspecting the
(where × SumMode × prove) triple. The result picks the
executor the dispatcher routes to.
Versioned because the routing table is a consensus-relevant contract on the query surface — a future protocol version that adds or relaxes shapes (e.g. a new “GroupByRange + In + prove” mapping) has to land behind a method-version bump so older nodes replaying historical traffic keep dispatching the way the chain originally saw.
Two public surfaces, both routed through the same method-version slot to guarantee server + SDK pick the same executor:
-
detect_sum_mode(server-side) — takes a fullDocumentSumRequestand additionally cross-validates the request’ssum_propertyagainst the doctype’sdocuments_summable. Server-only becauseDocumentSumRequestis#[cfg(feature = "server")]. -
detect_sum_mode_from_inputs— takes the minimal(where_clauses, mode, prove)tuple the routing table actually needs, callable from both server and SDK (serverORverifyfeatures). Mirrors count’scrate::query::drive_document_count_query::DriveDocumentCountQuery::detect_mode_versionedso the SDK’s verify path picks the same executor the prover used — without this, the SDK had to reconstruct routing from ad-hoc(has_range, has_in, distinct_mode)booleans, which could disagree with the v0 routing table on edge cases (e.g.group_by = [in_field]with a co-present range clause routes to the carrier shape server-side but the heuristic would have sent it to an aggregate verifier).
Functions§
- detect_
sum_ mode - Server-side wrapper around
detect_sum_mode_from_inputsthat adds the doctype cross-validation (sum_propertymust agree with the doctype’sdocuments_summable). Server-only becauseDocumentSumRequestis gated behind theserverfeature. - detect_
sum_ mode_ from_ inputs - Same routing decision as
detect_sum_modebut takes the minimal(where_clauses, mode, prove)tuple — callable from SDK verify paths that don’t have aDocumentSumRequest.