Skip to content

refactor(legacy_expr): step γ5 — histogram_quantile is parser-level substitution - #144

Merged
zzylol merged 1 commit into
mainfrom
refactor/legacy-expr-step-gamma5-histogram-quantile
May 12, 2026
Merged

zzylol merged 1 commit into
mainfrom
refactor/legacy-expr-step-gamma5-histogram-quantile

Conversation

@zzylol

@zzylol zzylol commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Final piece of the γ batch: retires legacy_expr::QueryExpr::HistogramQuantile and optimizer rule R6 (HistogramQuantileFusion). histogram_quantile(phi, m) now substitutes to canonical AggIntent::Quantile { q: phi } at the parser site, so the wrapper variant never enters L3 at all.

Invariant held

AggIntent::HistogramQuantile does not exist in canonical L3 (PR #133 removed it). The downstream fusion rule R6 only matched on a wrapper that the parser had already stopped emitting after PR #133, making it vestigial. All remaining references to "HistogramQuantile" in the diff are:

  • Doc-comments noting the retirement
  • QueryShape::HistogramQuantile in asap-query-engine/src/routing/backend_storage_routing.rs — a routing-table classifier, orthogonal to AggIntent

What's in

  • controller/src/query_parser/promql.rs (+74) — parser substitution: histogram_quantile(q, bucket_metric)Quantile { q, accuracy }
  • controller/src/optimizer/engine.rs (-142) — retire R6 + dead match arms
  • controller/src/intent_algebra/{legacy_expr,legacy_lower,agg_intent}.rs — remove the HistogramQuantile variant
  • controller/src/physical/{allocator,planner,stage_split}.rs (-136 net) — drop the now-unreachable wrapper handling
  • controller/src/sketch_algebra/{rules/bind_archive_only,tests}.rs (-10) — drop the now-vestigial wrapper expectations
  • controller/src/{deployment_model,language_logical_plan/plan,optimizer/trait_def,warm_tier_analysis}.rs — corresponding consumer cleanups
  • asap-query-engine/src/drivers/query/servers/http.rs (+3 / -1) — caller adjustment

Net effect: −163 lines across 17 files.

Test plan

  • cargo build --release -p controller clean (4 pre-existing warnings)
  • cargo test --release -p controller --lib — 710 passed (683 γ5-baseline + 8 γ2 + 12 γ3 + 7 γ4 sibling tests after rebase)
  • cargo test --release -p controller --bins — 27 passed
  • cargo build --release -p query_engine_rust clean; lib-test binary builds and lists 816 tests
  • Local cargo test -p query_engine_rust --lib hung on a futex in this worktree (unrelated to γ5 — same hang reproducible on main; CI will exercise it)

🤖 Generated with Claude Code

…ubstitution

Retires `legacy_expr::QueryExpr::HistogramQuantile` and optimizer rule R6
(`HistogramQuantileFusion`). `histogram_quantile(phi, m)` is now resolved
at the parser site (`query_parser/promql.rs`) into a canonical
`AggIntent::Quantile { q: phi }` — bucket-aware reduction is a physical-
planner concern, not an L3 intent.

Per the design invariant: `AggIntent::HistogramQuantile` does NOT exist
in canonical L3 (PR #133 removed it). The optimizer's downstream
fusion rule R6 was therefore vestigial — it matched on a wrapper that
the parser no longer emits. Removing the rule + the legacy variant
removes ~163 lines of dead surface across 17 files (optimizer/engine.rs
-142 alone).

Net effect:
- Parser-side substitution maps `histogram_quantile(q, bucket_metric)`
  → `Quantile { q, accuracy }` at parse time.
- `QueryShape::HistogramQuantile` in asap-query-engine's
  backend_storage_routing remains (it's a routing-table classifier,
  not an AggIntent — orthogonal concept).
- Demo wires in `physical/{allocator, stage_split, planner}` and
  `sketch_algebra/{rules/bind_archive_only, tests}` simplified along
  with the rule retirement.

cargo build --release -p controller clean; controller --lib 683/683.
asap-query-engine builds clean (816 tests listable); local lib test run
hangs on a futex unrelated to γ5 — CI will surface any γ5-attributable
regression.
@zzylol
zzylol merged commit 96d555c into main May 12, 2026
@zzylol
zzylol deleted the refactor/legacy-expr-step-gamma5-histogram-quantile branch July 17, 2026 20:06
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