Skip to content

Derive query accuracy (Exact vs Approximate) to activate the Exact→archive routing gate #348

Closed

Description

@zzylol

Context

#347 centralized query routing in EngineRouter and added an ASAP-first failover with an accuracy gate in compatible_storage_backends (crates/asap_types/src/capability_matching.rs):

  • Exact → [GorillaObjectStore] (archive only — warm sketches are ε/δ-bounded)
  • Approximate → [SketchStore, GorillaObjectStore] (ASAP-first, archive fallback)

The gate is correct but dormant — both live query paths hardcode the input, so every real query is treated as Approximate and the Exact → archive branch only runs in tests.

Current state (as of #347 / a1a2df7)

  • data_plane/src/drivers/query/servers/http.rs:
    • instant (process_via_router): let stat = Statistic::Sum; let accuracy = AccuracyTarget::Approximate; (~L1217–1218)
    • range (process_range_query_request): same, with a TODO (~L1686–1691)
    • stub acknowledged in the comment ~L1172–1180
  • The only place accuracy is read from input today is the precompute-job POST body (~L3411), not /api/v1/query(_range).
  • The ASAP engine's analyzer (analyze_promql_for_asap_tier) keys on query shape only, not accuracy — so "exact must use the archive" can only be enforced at the router, with a real accuracy input.

Why it matters

Until this lands, a query that needs exact values is silently answered from the ε/δ-bounded sketch tier (an approximate result presented as exact), with no way for the caller to demand the archive.

Task

Derive accuracy from the query request and thread it into query_router.execute / execute_range, replacing the hardcoded AccuracyTarget::Approximate at the two sites above. Routing logic is already complete — this is input derivation + plumbing only.

Signal to choose (decision needed):

  • HTTP signal — ?accuracy=exact query param or X-ASAP-Accuracy: exact header on /api/v1/query(_range) (explicit, caller-driven)
  • Per-metric / plan config — resolve an AccuracyTarget per metric (alongside resolve_metric_storage), e.g. from the control-plane plan's accuracy SLA
  • PromQL-shape derivation — map shapes that can't tolerate approximation to Exact

Sibling stub: stat = Statistic::Sum is also hardcoded, but the policy currently ignores it (_stat) — lower priority; address only if a future policy keys on Statistic.

Verify

cargo check -p data_plane + routing/http tests; add a test asserting an Exact query routes to the archive while Approximate stays ASAP-first.

Follow-up to #347.

Activity

  1. self-assigned this
    on May 26, 2026
  2. added
    enhancementNew feature or request
    area: data planeRuntime ingestion, storage, and query-serving data paths
    area: query enginePromQL lowering, execution, result shaping, and fallback behavior
    feature: PromQLPromQL compatibility and execution semantics
    feature: warm summariesASAP warm-tier materialization, readiness, and serving
    quality: accuracyExact and approximate accuracy contracts, error bounds, and routing
    on Sep 4, 2026
  3. zzylol commented on Sep 4, 2026

    @zzylol
    ContributorAuthor

    Fix is now open in #507. It adds the explicit X-ASAP-Accuracy: exact|approximate contract for both instant and range endpoints, routes exact requests archive-only even from a SketchStore-configured metric, rejects invalid hints, and reports the actual answering engine. Four focused tests pass. Leaving this issue open until the PR is merged, per the requested workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: data planeRuntime ingestion, storage, and query-serving data pathsarea: query enginePromQL lowering, execution, result shaping, and fallback behaviorenhancementNew feature or requestfeature: PromQLPromQL compatibility and execution semanticsfeature: warm summariesASAP warm-tier materialization, readiness, and servingquality: accuracyExact and approximate accuracy contracts, error bounds, and routing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions