mvp v7: dual-routing + freshness pattern registration - #91
Merged
Merged
Conversation
Closes the v6.1 architectural gap that forced criteria ④ vs ⑤ to be exclusive — one metric, one engine. v7 introduces two backend changes: (A) Dual-routing per metric (asap-query-engine): - BackendStorageRouting now holds Vec<RoutingTarget> per metric, with optional applies_to_query_shape filter on each target. - New QueryShape taxonomy (Count/Topk/RatePostHoc/Quantile/Sum/ LastOverTime/Other) extracted from the parsed PromQL AST in classify_query_shape(). - lookup_with_shape() walks targets in two passes: explicit shape-match first, then default-slot fallback. - Backwards-compatible YAML loader: existing single-target `metrics:` map entries decode to single-element target lists; new `routes:` list lets one metric fan out to multiple targets. - http.rs::resolve_metric_storage now classifies the parsed AST and passes the shape to lookup_with_shape, so http_requests_total can serve quantile_over_time from the warm tier AND count(...)/topk(...)/rate(...) from the cold archive. (B) Freshness pattern (asap-query-engine GorillaQueryEngine): - Add LastOverTime to QueryStatistic + AdditiveOp::Last on the streaming-additive accumulator (the existing AdditiveAccumulator already tracks (last_ts, last_value); finaliser just returns last_value). - Planner accepts last_over_time(<metric>[<range>]) and routes it through the streaming-additive path. Issue #46 ⑥ freshness probes encode unix_ts_ms in the cumulative counter value, so this gives the replay client a usable observed_value to subtract. Tests: - 11 routing-table unit tests (single-target preserved, multi-target shape selection, mixed metrics+routes, classify_query_shape over all the canonical v6 demo PromQL shapes). - 2 production-path HTTP integration tests (http_v7_dual_routing_count_lands_on_archive, http_v7_dual_routing_quantile_stays_on_warm_tier) mirror the existing http_routes_archive_metric_to_gorilla_engine test. - 2 GorillaQueryEngine tests for last_over_time (basic + unordered-samples-pick-largest-ts). Pre-existing 34 backend test failures unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 7, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the v6.1 architectural gap that forced issue #46 criteria ④ (warm-tier accuracy) and ⑤ (cold-fallback) to be exclusive — under v6.1 every metric had to pick one engine, so quantile-on-warm and
count(...{service=\"payments\"})-on-archive could not both succeed for the same metric.Two backend changes land together:
(A) Dual-routing per metric
BackendStorageRoutingnow holdsVec<RoutingTarget>per metric, with an optionalapplies_to_query_shape: [count, topk, rate_post_hoc, quantile, sum, last_over_time, other]filter on each target.QueryShapetaxonomy +classify_query_shape(parsed_ast)extracts a coarse-grained shape from the parsed PromQL.lookup_with_shape(metric, shape)walks targets in two passes: explicit shape-match first, then default-slot fallback.metrics:map entries decode to single-element target lists; newroutes:list lets one metric fan out to multiple targets. A metric in BOTH wins fromroutes:.http.rs::resolve_metric_storagenow classifies the parsed AST and passes the shape tolookup_with_shape, sohttp_requests_totalcan servequantile_over_time(...)from the warm tier ANDcount(...)/topk(...)/rate(...)from the cold archive.(B) Freshness pattern registration (GorillaQueryEngine)
LastOverTimetoQueryStatistic+AdditiveOp::Laston the streaming-additive accumulator. The existingAdditiveAccumulatoralready tracks(last_ts, last_value); the finaliser just returnslast_value.last_over_time(<metric>[<range>])and routes it through the streaming-additive path.unix_ts_ms_of_emissionin the cumulative counter value; this gives the replay client a usableobserved_valueto subtract.(B) is option (b) from the v7 spec — hard-coded support in the existing engine — chosen because it's <100 LOC and the existing
AdditiveAccumulatoralready tracks the right state.Tests
metrics:+routes:,classify_query_shapeover the canonical v6 demo PromQL shapes).http_v7_dual_routing_count_lands_on_archive,http_v7_dual_routing_quantile_stays_on_warm_tier) mirror the existinghttp_routes_archive_metric_to_gorilla_enginetest.last_over_time(basic + unordered-samples-pick-largest-ts).Test plan
cargo build -p query_engine_rust— passescargo test -p query_engine_rust --lib backend_storage_routing— 20/20 passcargo test -p query_engine_rust --lib http_v7_dual— 2/2 passcargo test -p query_engine_rust --lib gorilla_engine— 27/27 pass (incl. 2 newlast_over_time)🤖 Generated with Claude Code