Repository navigation
Conversation
…propagation (#1207 PR 4) local_guarantee reads the candidate's parameters (LogicalProperties::parameters) and is public: Pass 2 derives each listed θ's error from it. Node trees carry no θ since PR 0, so a node's guarantee cannot be composed any more: the node-tree propagation (propagation.rs with bind_guarantees and raw_data_samples_of_metric), its operator rules (composition.rs, function_rules.rs), the budget split (budget.rs) and PropagationStats are deleted. Error propagation is per edge through each consumer's error contract (LogicalRequirements::error_propagation).
…ts (#1207 PR 4) LogicalRequirements::error_propagation(consumer, metric) gives g_c's linear bound (beta and validity cap per input) for errors in one metric, or None when the consumer has no contract for it (the metric rule). The ratio's denominator validity cap is RATIO_DENOMINATOR_VALIDITY_CAP. Memo::set_input_requirements lets Pass 2 tighten each input's parameter floor after the rules.
…le, caps (#1207 PR 4) Rules over memo groups: 1 tumbling layouts as candidates of the state group (gcd closure of the evaluation grids, dividing the window); 2 scan widening (widened scan and label-passing images, Project candidates in the original groups); 4 top-k reuse (TopK over the largest top-k group); 5 finer aggregate; 6 rollup (SummaryMerge with group_by over the finer state). Rule 3 is Pass 1's (every input is a group) and rule 7 is rule 6 over windowed builds: both deleted. After the rules: error caps per group (query targets passed down through each consumer's error contract, min with validity caps), parameter floors from the caps for every readout or merge of a sketch state, each candidate's possible output errors, and the logical edges with alpha^log (floor and metric rule).
…capped; tests (#1207 PR 4) A merge of sketch states takes the weakest floor of the consumers reading its group (the merged state has its inputs' θ), which also carries a top-k's heap size; caps no longer track statistics. A scalar root's operands get no cap (its expression is not read). Scan widening keeps each mirrored build's input requirements and skips fused builds. planner-layering.md: Pass 2's rules and edges.
…rantees wait for PR 8 (#1207 PR 4)
…ollup filters over one child, states without an error model (#1207 PR 4) A count's factor 0 makes an approximate input exact before the all-exact check. Rule 6 compares two states' filters only over one child (filter columns are positional). A readout of a sample, wavelet or model state has no guarantee. Shared produces_state, merge_keeps_guarantee and weakest_of; measures compared with ==; RATIO_DENOMINATOR_VALIDITY_CAP -> RELATIVE_OPERAND_VALIDITY_CAP; rule 7 wording: a longer range from a shorter range's windows is not offered.
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.
Why
#1207's Order, row "4. Pass 2": rules 1–7 over memo groups (with #1160's tumbling layouts), the logical edges$(u,c,i)$ with $\alpha^{\log}$ (#1201), the metric rule, and validity and pruning caps (concepts doc §3 "Stage 1, Pass 2", §4). The user decided on 2026-11-06 that the validity-cap floor, the metric rule and the θ pruning cap belong here. Node trees carry no θ since PR 0, so node-tree guarantee propagation is replaced by per-edge error propagation (
ErrorPropagation), as agreed.What
crates/stage1-pass2-reuse-candidates/src/memo/). Each rule adds groups (find_or_add_group) or candidates (add_candidate). No rule copies a consumer: every consumer of a group sees what a rule adds.window_candidates.rs, Pass 2: tumbling-window builds as candidates of the state group, and merge-then-aggregate over raw tumbling windows (window-specific; memo representation is #1203) #1160). A mergeable summary state overTimeRange(W)gets, for each of its builds (each listed θ), the same build with@anchor or for a family without a merge (an instant rate).rules/scan_labels.rs). Scans of one metric that list different labels get the union scan. Every group above that passes labels on (time range, time shift, a per-series build without a filter, a readout, a finalize, a merge) gets a widened image, with the original's builds (θ, ω and input requirements). Each original non-state group getsProject(widened image). Two quantiles overm{job}andm{host,job}then read one widened KLL build.rules/topk.rs). A top-k readsTopK(k)over the largest top-k group of the same input and partition. A top-k has no error contract, so only an exact producer gives it an edge: this is the doc's "exact-input requirement".rules/finer_aggregate.rs). A SQL aggregate reads a finer aggregate's result through a compensatingFiltergroup, with each measure's rollup (sum→sum, count→sum, min, max;minwhen each query group is one finer row).rules/rollup.rs). A grouped state (exact accumulator or sketch) whose family merges across groups readsSummaryMerge(group_by = its keys)over a finer state of the same family, update and filter, over the same rows. The finer group's windowed builds serve the coarse state through it.logical_edges.rs,parameter_floors.rs), after the last rule:heap_size ≥ k). A merge of states gets the weakest floor of the consumers reading its group. Stored withMemo::set_input_requirements.Exact,Bound(metric)orWithoutGuarantee. A sketch read has the guarantee of its θ (local_guarantee); a windowed read keeps it only where the family's merged error is exact or as if built over the union (merged_tumbling_windows_guarantee).types):LogicalRequirements::error_propagation(consumer, metric) -> Option<ErrorPropagation>.local_guarantee(family, parameters, statistic)reads θ and is public. The node-tree guarantee propagation is deleted (table below).Deleted
asap_accuracy::propagation(whole module:bind_guarantees,raw_data_samples_of_metric,composed_guarantee,root_guarantee,recompose_guarantees,with_guarantees,approximate_inputs,distinct_bound_source,merged_tumbling_windows_guarantee(node version),source_distinct_guarantee,fold_stats,estimates_raw_data_samples_of,stream_norm,scalar_guarantee,project_column_guarantee,operand_of,operand_guarantee,operand_domain_statistic,split_and,pinned_column, …)local_guarantee(θ)+ per-edgeerror_propagation.asap_accuracy::composition(propagateand its operator rules, statistic constants,StreamNorm, sign/norm statistic helpers),function_rulesasap_accuracy::budget(per_input_target)PropagationStatsasap_accuracy::test_support::{composed_guarantee, scalar_guarantee, stream_norm, fold_stats, estimates_raw_data_samples_of, source_distinct_guarantee, PropagationStats, QUOTIENT_OPERAND_DOMAINS, STREAM_ROW_COUNT, source_norm_statistic, raw_data_samples_sign_statistic, sign_statistic}asap-accuracy(propagation, composition, budget);promql_numeric_regressions::ddsketch_interpolation_requires_a_nonnegative_domainand thebind_guaranteesblock ofchecked_ratio_must_not_certify_cross_zero_interpolationstage1-pass2rules/summary_inputs.rs(factor_summary_inputs, rule 3);add_window_rollup_candidates(rule 7)Pass2RuleError::{InvalidGroupReference, TooManyGroups}LogicalProperties(a rule bug).New abstractions not in #1207 or the doc (pending approval)
error_propagation(consumer, metric: AccuracyMetric) -> Option<ErrorPropagation>(doc:(consumer) -> ErrorPropagation)types/src/stages/candidates.rsNone. Every contract keeps the metric.pub const RELATIVE_OPERAND_VALIDITY_CAP: f64 = 0.1(Memo::set_input_requirements(id, Vec<LogicalRequirements>)types/src/stages/candidates.rsMemohas no other mutable access to a candidate.asap_accuracy::estimators::local_guaranteemadepub, with aparameters: Option<&SketchParams>argumentaccuracy/src/estimators/mod.rsLogicalProperties::parameters(the PR 0todo!).pass2_after_local_window_composition(memo, entries)gainsentriesstage1-pass2/src/logical_memo_candidates.rsOutputError {Exact, Bound(AccuracyMetric), WithoutGuarantee},ErrorCap {query, cap},logical_edges_with_capped_floors,error_caps,passed_cap,set_floors,readout_floor,weakest_floor_of_consumers,output_errors,candidate_errors,read_errors,merged_tumbling_windows_guarantee,merge_keeps_guarantee,carries,value_preserving;floor_for_cap,weakest,strongest,weakest_of;add_candidate,expression,produces_state;tumbling_window_widths,splittable_window_ms;union_schemas,passes_labels_on,narrowed;match_finer,Rows,value_rollup,pinned_column,split_and;grouped_state,rollup_keys,same_rowsstage1-pass2-reuse-candidatesOutputErroris a concept not in the formulation: the possible output error of a candidate, which the metric rule reads.stage1-pass2/src/tests.rsMemomethods.Spec questions (conservative choice taken)
sum, functions and comparisons over approximate values have no contract here (the old node rules used symbolic row counts and sign statistics, which a constant β cannot hold). Their approximate edges are flagged, not removed. Stage 3 (PR 6/8) decides whatIgnoreAccuracyGuaranteesdoes with[1h]from[5m]windows, the old shared nested chains) needs a window requirement on the input (LogicalRequirementshas only the parameter floor) or chain groups. It is not offered.TimeShiftoffset is not folded into the gcd.filtered_finer: a compensatingFilterover finer states), and the exact rollup that read the finer query's finalized result (rule 6 merges states instead). Shall I file issues?How
generate_logical_asap_memo_candidates(pass1, entries)runs rule 1, then rules 2, 4, 5, 6, thenlogical_edges_with_capped_floors(above). The memo's own checks (add_candidate: node rules and the group's output) end a rule's shape match: a rejected candidate is skipped.Key code interfaces added / modified
types/src/stages/candidates.rsaccuracy/src/estimators/mod.rsstage1-pass2-reuse-candidates/src/logical_memo_candidates.rs,memo/rules.rsUsage (the doc's running example, checked by
a_ratio_reads_no_rank_erroranda_ratio_divides_its_target_by_its_propagation_factor):End-to-end planning stops at Stage 2 (PR 5), so the selected plan is not shown yet.
Major algorithm changes
Pass 2 rules. Problem: the old rules rewrote whole node trees per candidate (private chains, shared-build copies, per-size groups); PR 0 removed that representation. Before: node-tree rewrites, then$O(G_a^2)$ ; edges are $O(\sum_c \sum_i |G_{c,i}|)$ . Limits: see the spec questions.
add_shared_summary_state_groups. After: rules over group expressions (above), with sharing only by hash-consing. Correctness: every candidate passesMemo::add_candidate(the node rules and the group's exact output); tests per rule. Complexity: rules 5 and 6 compare pairs of aggregate or state groups,Pruning caps and the metric rule. Problem: the old Pass 1 sized each summary for an equal share of its query's error budget. With predefined θ lists, nothing removed hopeless θ or rank-error inputs into relative-error consumers. After: caps, floors and$\alpha^{\log}$ (What, 1–4). Correctness (safety): a cap is a maximum over paths of the per-path minimum of $b$ and $\varepsilon_q/\prod\beta$ , so a producer with $\varepsilon$ under the cap is never excluded. A floor is the per-parameter minimum over the listed θ that meet the cap, so it admits all of them. A target in another metric than the read gives no floor. Merge floors are the weakest of their consumers'. Tests:
a_query_target_caps_the_readout_input_with_a_parameter_floor,the_loosest_query_sets_a_shared_inputs_cap,a_target_in_another_metric_sets_no_floor,a_rollup_merge_takes_its_readouts_floor,a_count_of_approximate_values_is_exact. Complexity: linear in groups × candidates × queries reaching them.Before / After
todo!()(rule 1). Accuracy guarantees were composed on node trees, whose sketch guarantees weretodo!()(no θ on nodes).LogicalASAPMemoCandidates { memo, edges }, with floors andRepresentation, rules, enumeration
WindowLayout::Tumbling { width_ms }on rule 1's buildsLogicalRequirements::error_propagation(c, metric)→ErrorPropagationpassed_cap/ErrorCap(private, per group and query)LogicalRequirements::parameter_floor_for_required_accuracy, set byset_floors/floor_for_capLogicalEdge::satisfies_logical_requirementLogicalASAPMemoCandidates::edgesVerification
cargo test -p asap-stage1-pass2-reuse-candidates: 20 passed. Coverage: rule 1 (widths; windowed builds per θ; none without a merge or at@), rule 2 (union scan; shared widened build), rule 4, rule 5 (rollup; compensating filter), rule 6 (merge; finer windowed builds serve the coarse state; merge floor), edges, metric rule, caps, floors, the count factor, merged-window guarantees.asap-types:error_propagation_follows_each_operators_error_contract.asap-accuracy:local_guarantee_needs_a_statistic_the_family_answers_and_its_parameters.cargo fmt --check;cargo clippy --workspace --all-targets --all-features -D warnings: clean.crate_graph: passes.Test status
cargo test -p <crate> --all-features --no-fail-fast, per crate, passed / failed / ignored. PR 3 is #1232 at d4bde07; PR 4 is this PR (all crates at e9630ad; types, accuracy and Pass 2 re-run at 72a4037).asap_plannersubprocesses), 10 at PR 9materialized_views). −1 test (deleted withbind_guarantees)