Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6453d20
refactor(types): unify pre- and post-ASAP schemas into Schema/Field/F…
Selvomega Oct 2, 2026
0970f46
feat(ir): canonicalize, CSE, wire-6 export and lifecycle timing over …
Selvomega Oct 2, 2026
8227061
refactor(types): port dag_export (viewer graph) to the unified IR
Selvomega Oct 2, 2026
2d5ad63
feat(ir): lower EXISTS / IN / scalar subqueries to joins in canonicalize
Selvomega Oct 2, 2026
e905008
viewer: node kind categories follow the unified IR
Selvomega Oct 2, 2026
2f70028
refactor(frontends): emit the unified IR through asap-frontend-common
Selvomega Oct 2, 2026
f07ff20
refactor(mapping): plan search, assembly, costing and lifecycle on th…
Selvomega Oct 2, 2026
78332fe
refactor(devtools): port binaries and tests to the unified IR; keep a…
Selvomega Oct 2, 2026
e258e17
docs: describe the unified operator IR
Selvomega Oct 2, 2026
f607310
test: migrate every test suite to the unified IR; fix four planner re…
Selvomega Oct 2, 2026
09373ef
refactor!: delete the old pre-/post-ASAP IR
Selvomega Oct 2, 2026
477decd
fix: resolve main merge and complete scalar IR migration
zzylol Oct 2, 2026
36e8838
fix(ir): complete scalar lowering and preserve language semantics
zzylol Oct 2, 2026
fca91f5
fix(ir): validate unified state and readout contracts
zzylol Oct 2, 2026
bea0e41
docs: record operator design acceptance and update DAG viewer
zzylol Oct 2, 2026
8630bd6
fix: satisfy Rust 1.99 lint checks
zzylol Oct 2, 2026
1e0d4ee
refactor: clarify workload DAG and summary evaluation contracts
zzylol Oct 2, 2026
c036a14
fix: prevent retained evidence from hiding summary work
zzylol Oct 2, 2026
f85ef87
docs: clarify retained DAG cost boundaries
zzylol Oct 2, 2026
b68b231
fix: generalize summary cost evidence across arrival modes
zzylol Oct 2, 2026
aea7f13
merge: integrate general cost evidence with unified operators
zzylol Oct 2, 2026
c3a5af9
merge: record main after equivalent #532 squash integration
zzylol Oct 2, 2026
fc328b1
refactor: name ASAP family strategies and clarify IR modules
zzylol Oct 2, 2026
150735f
refactor: rename legacy QueryExprError to SchemaDerivationError
zzylol Oct 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"crates/frontend-promql",
"crates/frontend-metricsql",
"crates/metricsql-common-parser-support",
"crates/frontend-common",
"crates/frontend-sql",
"crates/planner",
"crates/devtools",
Expand Down
2 changes: 1 addition & 1 deletion crates/asap-aware-mapping/src/accuracy/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct AccuracyAllocation {

impl AccuracyAllocation {
/// The end-to-end budget left for everything below `layers[0]` — what
/// the inner subtree must satisfy as a whole (it re-splits internally).
/// the inner sub-DAG must satisfy as a whole (it re-splits internally).
/// `None` for a single-layer allocation.
pub fn inner_target(&self, shape: &CompositionShape) -> Option<AccuracyTarget> {
let inner = &self.layers[1..];
Expand Down
6 changes: 2 additions & 4 deletions crates/asap-aware-mapping/src/accuracy/composition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,7 @@ fn composed_provenance(
}

pub(super) fn exact_operation_rule(operation: &ExactOperation) -> Option<CompositionOperator> {
let ExactOperation::Aggregate { measures, .. } = operation else {
return None;
};
let ExactOperation::Aggregate { measures, .. } = operation;
match measures.as_slice() {
[intent] => crate::function_rules::function_rules(intent).map(|rules| rules.accuracy),
// The remaining functions are exact over exact samples, but have
Expand Down Expand Up @@ -1035,8 +1033,8 @@ mod tests {
reduction: asap_types::pre_asap::Reduction::PerEntity,
measures: vec![intent],
output_names: vec![],
having: None,
filters: vec![],
having: None,
};
assert_eq!(
DefaultAccuracyModel.exact_operation_rule(&operation(AggIntent::Rate)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;
pub(super) fn guarantee(
algorithm: &SketchAlgorithm,
params: &SketchParams,
query: &SketchQuery,
query: &SketchStatistic,
) -> Option<ResultGuarantee> {
let (SketchParams::Kmv { k } | SketchParams::Theta { k }) = params else {
return None;
Expand Down
12 changes: 6 additions & 6 deletions crates/asap-aware-mapping/src/accuracy/estimators/cms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;
pub(super) fn guarantee(
algorithm: &SketchAlgorithm,
params: &SketchParams,
query: &SketchQuery,
query: &SketchStatistic,
) -> Option<ResultGuarantee> {
let (SketchParams::Cms { width, depth } | SketchParams::CmsWithHeap { width, depth, .. }) =
params
Expand Down Expand Up @@ -47,11 +47,11 @@ mod tests {
let params = default_size_params(SketchAlgorithm::Cms, &c, 0.01, 0.001);
let g = DefaultAccuracyModel
.local_guarantee(
&SummaryFamilyType::Sketch(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::Cms, params),
GroupingStrategy::default(),
),
&SketchQuery::Cardinality,
&SketchStatistic::Cardinality,
)
.unwrap();
assert_eq!(g.metric, ErrorMetric::Frequency);
Expand All @@ -65,7 +65,7 @@ mod tests {
}

#[test]
fn heap_readout_retains_frequency_metric() {
fn heap_evaluation_retains_frequency_metric() {
use asap_types::post_asap::{GroupingStrategy, SketchKind};
let cms_heap = SketchParams::CmsWithHeap {
width: 272,
Expand All @@ -74,11 +74,11 @@ mod tests {
};
let topk_frequency = DefaultAccuracyModel
.local_guarantee(
&SummaryFamilyType::Sketch(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::CmsWithHeap, cms_heap),
GroupingStrategy::default(),
),
&SketchQuery::TopK { k: 10 },
&SketchStatistic::TopK { k: 10 },
)
.expect("heap sketch still provides per-key frequency intervals");
assert_eq!(topk_frequency.metric, ErrorMetric::Frequency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;
pub(super) fn guarantee(
algorithm: &SketchAlgorithm,
params: &SketchParams,
query: &SketchQuery,
query: &SketchStatistic,
) -> Option<ResultGuarantee> {
let (SketchParams::CountSketch { width, depth }
| SketchParams::CountSketchWithHeap { width, depth, .. }) = params
Expand Down Expand Up @@ -62,11 +62,11 @@ mod tests {
let count_sketch = default_size_params(SketchAlgorithm::CountSketch, &intent, 0.01, 0.01);
let guarantee = DefaultAccuracyModel
.local_guarantee(
&SummaryFamilyType::Sketch(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::CountSketch, count_sketch),
GroupingStrategy::default(),
),
&SketchQuery::PointCount {
&SketchStatistic::PointCount {
key: asap_types::pre_asap::expr_ir::ColumnRef::SampleValue,
value: None,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;
pub(super) fn guarantee(
algorithm: &SketchAlgorithm,
params: &SketchParams,
query: &SketchQuery,
query: &SketchStatistic,
) -> Option<ResultGuarantee> {
let SketchParams::DDSketch { alpha } = params else {
return None;
Expand Down
14 changes: 7 additions & 7 deletions crates/asap-aware-mapping/src/accuracy/estimators/hll.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! Estimator-specific confidence for classic HLL's linear-counting branch.
//!
//! This is conditional on independent uniform bucket hashes and an enforced
//! upper bound on distinct items in the complete readout population (including
//! upper bound on distinct items in the complete evaluation population (including
//! all merged panes). It is not an RSE-to-normal conversion or an ERP fit.

use super::*;

pub(super) fn generic_guarantee(
algorithm: &SketchAlgorithm,
params: &SketchParams,
query: &SketchQuery,
query: &SketchStatistic,
) -> Option<ResultGuarantee> {
let SketchParams::Hll { precision } = params else {
return None;
Expand Down Expand Up @@ -56,13 +56,13 @@ impl ClassicHllConfidence {
value: self.relative_error,
},
failure_probability: ProbabilityExpr::Constant { value: delta },
provenance: vec![GuaranteeSource::SketchReadout {
provenance: vec![GuaranteeSource::SketchEvaluation {
algorithm: "Hll".into(),
contract: "classic_hll_linear_counting_collision_bound_v1".into(),
params: serde_json::json!({"precision": precision,
"max_distinct": self.max_distinct, "relative_error": self.relative_error,
"hash_assumption": "independent_uniform_buckets",
"population_scope": "complete_readout_including_merged_panes"}),
"population_scope": "complete_evaluation_including_merged_panes"}),
query: "Cardinality".into(),
}],
})
Expand Down Expand Up @@ -187,7 +187,7 @@ mod tests {
}
}
}
/// The model's readout formula matches the actual classic estimator after merge.
/// The model's evaluation formula matches the actual classic estimator after merge.
#[test]
fn native_classic_estimator_and_merged_registers_use_the_same_contract() {
use asap_sketchlib::sketches::hll::{Classic, HyperLogLogP16};
Expand Down Expand Up @@ -237,11 +237,11 @@ mod tests {
let params = default_size_params(SketchAlgorithm::Hll, &c, 0.01, 0.01);
let g = DefaultAccuracyModel
.local_guarantee(
&SummaryFamilyType::Sketch(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::Hll, params),
GroupingStrategy::default(),
),
&SketchQuery::Cardinality,
&SketchStatistic::Cardinality,
)
.unwrap();
assert_eq!(g.metric, ErrorMetric::Cardinality);
Expand Down
8 changes: 4 additions & 4 deletions crates/asap-aware-mapping/src/accuracy/estimators/kll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;
pub(super) fn guarantee(
algorithm: &SketchAlgorithm,
params: &SketchParams,
query: &SketchQuery,
query: &SketchStatistic,
) -> Option<ResultGuarantee> {
let SketchParams::Kll { k } = params else {
return None;
Expand Down Expand Up @@ -49,11 +49,11 @@ mod tests {
let params = default_size_params(SketchAlgorithm::Kll, &q, 0.01, 0.01);
let g = DefaultAccuracyModel
.local_guarantee(
&SummaryFamilyType::Sketch(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::Kll, params),
GroupingStrategy::default(),
),
&SketchQuery::Quantile { q: 0.99 },
&SketchStatistic::Quantile { q: 0.99 },
)
.unwrap();
assert_eq!(g.metric, ErrorMetric::Rank);
Expand All @@ -69,7 +69,7 @@ mod tests {
assert_eq!(g.approximate_layer_count(), 1);
assert!(g.provenance.iter().any(|source| matches!(
source,
GuaranteeSource::SketchReadout { contract, .. }
GuaranteeSource::SketchEvaluation { contract, .. }
if contract == "apache_datasketches_kll_empirical_99_a9b42755072b"
)));
}
Expand Down
34 changes: 16 additions & 18 deletions crates/asap-aware-mapping/src/accuracy/estimators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod univmon;
pub(super) fn sketch_guarantee(
algorithm: &SketchAlgorithm,
params: &SketchParams,
query: &SketchQuery,
query: &SketchStatistic,
) -> Option<ResultGuarantee> {
match params {
SketchParams::Kll { .. } => kll::guarantee(algorithm, params, query),
Expand All @@ -36,7 +36,7 @@ pub(super) fn sketch_guarantee(
fn bounded_guarantee(
algorithm: &SketchAlgorithm,
params: &SketchParams,
query: &SketchQuery,
query: &SketchStatistic,
metric: ErrorMetric,
bound: f64,
delta: ProbabilityExpr,
Expand All @@ -46,7 +46,7 @@ fn bounded_guarantee(
metric,
bound: BoundExpr::Constant { value: bound },
failure_probability: delta,
provenance: vec![GuaranteeSource::SketchReadout {
provenance: vec![GuaranteeSource::SketchEvaluation {
algorithm: format!("{algorithm:?}"),
contract: contract.into(),
params: serde_json::to_value(params).unwrap_or(serde_json::Value::Null),
Expand All @@ -56,21 +56,19 @@ fn bounded_guarantee(
}

pub(super) fn local_guarantee(
family: &SummaryFamilyType,
query: &SketchQuery,
family: &FieldDataType,
query: &SketchStatistic,
) -> Option<ResultGuarantee> {
match family {
SummaryFamilyType::Plain(_) => Some(ResultGuarantee::exact("Plain value")),
SummaryFamilyType::ExactAggregate(kind, _) => {
FieldDataType::Plain(_) => Some(ResultGuarantee::exact("Plain value")),
FieldDataType::ExactAggregate(kind, _) => {
Some(ResultGuarantee::exact(format!("ExactAggregate({kind:?})")))
}
SummaryFamilyType::Sketch(kind, _) => {
sketch_guarantee(kind.algorithm(), kind.params(), query)
}
FieldDataType::Sketch(kind, _) => sketch_guarantee(kind.algorithm(), kind.params(), query),
// No error model is registered for these families.
SummaryFamilyType::Sample(..)
| SummaryFamilyType::Wavelet(..)
| SummaryFamilyType::StatModel(..) => None,
FieldDataType::Sample(..) | FieldDataType::Wavelet(..) | FieldDataType::StatModel(..) => {
None
}
}
}
pub(crate) fn size_params(
Expand Down Expand Up @@ -171,9 +169,9 @@ impl<'a> EstimatorAccuracy<'a> {

fn hll(&self) -> Option<hll::ClassicHllConfidence> {
let EstimatorContract::ClassicHll {
max_distinct_per_readout,
max_distinct_per_evaluation,
} = self.contract?;
hll::ClassicHllConfidence::new(max_distinct_per_readout, self.epsilon)
hll::ClassicHllConfidence::new(max_distinct_per_evaluation, self.epsilon)
}

pub(crate) fn size_params(&self, algorithm: &SketchAlgorithm) -> Option<SketchParams> {
Expand All @@ -197,10 +195,10 @@ impl AccuracyModel for EstimatorAccuracy<'_> {
}
fn local_guarantee(
&self,
family: &SummaryFamilyType,
query: &SketchQuery,
family: &FieldDataType,
query: &SketchStatistic,
) -> Option<ResultGuarantee> {
if let (Some(_), SummaryFamilyType::Sketch(kind, grouping), SketchQuery::Cardinality) =
if let (Some(_), FieldDataType::Sketch(kind, grouping), SketchStatistic::Cardinality) =
(self.contract, family, query)
{
if let (SketchAlgorithm::Hll, SketchParams::Hll { precision }) =
Expand Down
6 changes: 3 additions & 3 deletions crates/asap-aware-mapping/src/accuracy/estimators/univmon.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! UnivMon currently certifies only its exact unit-update total readout.
//! UnivMon currently certifies only its exact unit-update total evaluation.
use super::*;

pub(super) fn guarantee(query: &SketchQuery) -> Option<ResultGuarantee> {
matches!(query, SketchQuery::PointCount { value: None, .. })
pub(super) fn guarantee(query: &SketchStatistic) -> Option<ResultGuarantee> {
matches!(query, SketchStatistic::PointCount { value: None, .. })
.then(|| ResultGuarantee::exact("univmon_unit_update_total"))
}

Expand Down
Loading