Repository navigation
refactor(planner): replace the summary lifecycle with #509 materialization options - #667
Merged
Merged
Conversation
3 tasks
zzylol
force-pushed
the
stack/528-08-cleanup
branch
from
October 12, 2026 22:55
5bf690c to
54e9c17
Compare
zzylol
force-pushed
the
stack/528-08b-query-time-default
branch
from
October 12, 2026 22:55
ad0a866 to
6a79e94
Compare
This was referenced Oct 12, 2026
zzylol
force-pushed
the
stack/528-08-cleanup
branch
from
October 13, 2026 01:43
54e9c17 to
439f71b
Compare
zzylol
force-pushed
the
stack/528-08b-query-time-default
branch
from
October 13, 2026 01:43
6a79e94 to
4411a62
Compare
zzylol
force-pushed
the
stack/528-08-cleanup
branch
from
October 13, 2026 01:54
439f71b to
940cf7f
Compare
zzylol
force-pushed
the
stack/528-08b-query-time-default
branch
from
October 13, 2026 01:54
4411a62 to
a7dc2c2
Compare
zzylol
force-pushed
the
stack/528-08-cleanup
branch
from
October 13, 2026 02:12
940cf7f to
166e116
Compare
Stage 2 materialization (#509) will decide per sub-DAG whether and when to materialize, so the Planner no longer chooses a maintenance lifecycle. - MajorPass now runs search_workload_with_targets -> global_selection -> assemble_selected_dag per root -> share_common_sub_dags. - QueryLifecyclePlan becomes QueryPlan { entry_index, root }; PlanOutput's execution_timed_dag times the roots directly. LifecycleInput, the lifecycle errors and UserInput's `lifecycle` field are gone (public API break). - Delete summary_maintenance_lifecycle, summary_maintenance_cost, summary_maintenance_dag_export, post_asap::{summary_maintenance, summary_maintenance_lifecycle} and SummaryWindowFramework (the pane primitives stay), the lifecycle CostModel hooks, CandidateCostOverrides and EmpiricalEvidenceProvider::lifecycle_cost_inputs. - Delete the lifecycle e2e test and the viewer's lifecycle-plan UI; rewire e2e_plan, summary_sharing, operator_design_examples and weighted_topk_binding to the new pipeline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rename LifecycleAssignment to MaterializationAssignment and apply_lifecycle_timings to apply_materialization_timings. The default assignment is now all_query_time(): nothing is materialized until Stage 2 materialization (#509) decides per sub-DAG. all_ingestion_time() and set() assign maintenance explicitly. - validate_default becomes validate_maintained: candidate legality is still checked with every summary maintained, so candidate generation is unchanged. planned_data_state and fixed_window_rate_candidates use the same maintained assumption, and the maintained precompute compilers in promql_rows assign ingestion time explicitly. - PlanOutput::execution_timed_dag, show_post_asap_ir and the default test helpers now emit query-time summaries. - forces_query_time (#541) treats a SummaryAgg as query time when the assignment, including its default, puts it there. - Tests that exercise maintenance assign it explicitly (new `maintained` helpers); a new unit test pins the query-time default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ime default Remove the lifecycle APIs, recipes and viewer section from the docs, delete the workload-demand-and-summary-lifecycle proposal, and point materialization questions to Stage 2 (#509). Rename LifecycleAssignment/apply_lifecycle_timings/ validate_default to their new names and describe the all-query-time default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow #537: the remaining tests read Operator<NodeId> payloads from the physical DAG, and docs name ir::flat / ir::physical_export instead of the removed ir::export. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on, MatAtQuery
options. Replace the two-way timing assignment with them:
- New Materialization { NotMaterialized, MatAtIngestion(Medium),
MatAtQuery(Medium) } and Medium { Memory, Disk }; only MatAtIngestion
runs at ingestion time.
- MaterializationAssignment maps a SummaryAgg or MaintainPopulation to its
option (set); Default is NotMaterialized everywhere, and with_default
gives unassigned sub-DAGs an option where the DAG allows it
(validate_maintained, planned_data_state and the maintained precompute
compilers use MatAtIngestion). all_query_time, all_ingestion_time and
summary_timing are gone.
- MaintainPopulation follows its assignment like SummaryAgg instead of
always running at ingestion time.
- An explicit MatAtIngestion over something that only exists at query
time fails with UpstreamNotAtIngestion ("upstream of ingestion-time node
not at ingestion time") instead of silently moving to query time.
- OperatorNode and PhysicalASAPDAGNode carry their Materialization;
PhysicalASAPDAG validation rejects a materialization inconsistent with
the node's timing.
- Remove PhysicalASAPDAG::with_execution_phases (#509 Assumption 8: the
deployment executes the plan as given). Tests place summaries through
the assignment instead.
Retention and choosing the option per sub-DAG stay with Stage 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
Per #509 ("Materialization decides, for each sub-DAG, whether its output is stored"; Example 4 stores panes), `MaterializationAssignment::set` accepts any node. `MatAtIngestion` puts it at ingestion time, or fails with `UpstreamNotAtIngestion` when something below can only run at query time, and a query-time consumer reads its stored output. An ingestion-pinned node (e.g. a fixed-window rate finalize) over a query-time state now fails the same way instead of with `IllegalChildDataState`. `split_shared_by_phase` returns the assignment remapped onto the rebuilt nodes, so an explicit `MatAtIngestion` is no longer silently lost, and the assignment holds `Rc` clones of its keys so a reused address cannot match a stale entry. Renames the remaining "maintained" names to the docs' vocabulary (`validate_at_ingestion`, `at_ingestion` test helpers), notes that `frontier_from_timing` does not store `MatAtQuery` outputs yet (Stage 2), and bumps PHYSICAL_ASAP_DAG_WIRE_VERSION to 10. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
Ports the four execution tests removed with the summary-maintenance lifecycle to MaterializationAssignment: NotMaterialized and MatAtIngestion placements of the KLL quantile, the current-series population, and sum_over_time arithmetic over one and over different selectors execute to the same results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
…stored roots A node whose timing its candidate fixed keeps an agreeing explicit assignment and rejects a conflicting one (MaterializationConflictsWithFixedTiming) instead of dropping it. A root assigned MatAtIngestion is valid; only an ingestion-time root of rows that is not stored there errors (UnstoredIngestionRoot, was MaintenanceRowsAtRoot). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
zzylol
force-pushed
the
stack/528-08b-query-time-default
branch
from
October 13, 2026 02:36
88650a0 to
0b4173d
Compare
2 tasks done
zzylol
added a commit
that referenced
this pull request
Oct 13, 2026
…#667 materialization Stage 2 takes query roots, scalar ones included (#542), times every sub-DAG with Materialization::NotMaterialized (#667) and keeps the guarantee Stage 1 composed on every node it implements; a MaintainPopulation is no longer rejected, since it now runs at query time when not materialized. Stage 3 accepts a query's output when its root guarantee meets the target, or when the deployment's accuracy model shows this candidate's output does (AccuracyModel::output_guarantee, none by default). A certified estimate inside the plan is not enough: a difference of two quantile estimates stays listed as invalid, with a reason, under the built-in models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
3 tasks
zzylol
added a commit
that referenced
this pull request
Oct 13, 2026
…#667 materialization Stage 2 takes query roots, scalar ones included (#542), times every sub-DAG with Materialization::NotMaterialized (#667) and keeps the guarantee Stage 1 composed on every node it implements; a MaintainPopulation is no longer rejected, since it now runs at query time when not materialized. Stage 3 accepts a query's output when its root guarantee meets the target, or when the deployment's accuracy model shows this candidate's output does (AccuracyModel::output_guarantee, none by default). A certified estimate inside the plan is not enough: a difference of two quantile estimates stays listed as invalid, with a reason, under the built-in models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
zzylol
added a commit
that referenced
this pull request
Oct 13, 2026
…#667 materialization Stage 2 takes query roots, scalar ones included (#542), times every sub-DAG with Materialization::NotMaterialized (#667) and keeps the guarantee Stage 1 composed on every node it implements; a MaintainPopulation is no longer rejected, since it now runs at query time when not materialized. Stage 3 accepts a query's output when its root guarantee meets the target, or when the deployment's accuracy model shows this candidate's output does (AccuracyModel::output_guarantee, none by default). A certified estimate inside the plan is not enough: a difference of two quantile estimates stays listed as invalid, with a reason, under the built-in models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
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
#509 Stage 2 (Physical ASAP-aware optimization) decides, per sub-DAG, whether its output is materialized and whether that happens at ingestion or at query time. The Planner's summary maintenance lifecycle made this choice with its own cost model, so Stage 2 and the lifecycle would both own the same decision.
What
Behavior change: planner output no longer materializes anything. Every
SummaryAggandMaintainPopulationisNotMaterializeduntil Stage 2 materialization (#604) picks an option.summary_maintenance_lifecycle,summary_maintenance_cost/,summary_maintenance_dag_export,post_asap::{summary_maintenance, summary_maintenance_lifecycle},SummaryWindowFramework, the lifecycleCostModelhooks,CandidateCostOverrides,EmpiricalEvidenceProvider::lifecycle_cost_inputs,LifecycleInputand its planning horizon, the lifecycle errors, the lifecycle e2e test, theworkload-demand-and-summary-lifecycle.mdproposal and the viewer's lifecycle-plan UI.MajorPassis now: candidate search → cost-basedglobal_selection→assemble_selected_queryper root →share_common_sub_dags. Each plan is aQueryPlan { entry_index, root }.Materialization { NotMaterialized, MatAtIngestion(Medium), MatAtQuery(Medium) }andMedium { Memory, Disk }. OnlyMatAtIngestionruns at ingestion time.MaterializationAssignment::setaccepts any node: per docs: propose workload-wide planning, summary sharing, and materialization #509 every sub-DAG output can be materialized ("Materialization decides, for each sub-DAG, whether its output is stored"; Example 4 stores panes).MatAtIngestionputs the node and everything upstream of it at ingestion time, and a query-time consumer reads its stored output.DefaultisNotMaterializedeverywhere.with_defaultgives unassignedSummaryAggandMaintainPopulationnodes a default option where the DAG allows one, and leaves themNotMaterializedwhere it does not.Rcclones of its keys, so a reused address cannot match a stale entry.split_shared_by_phasereturns the assignment remapped onto the rebuilt nodes, so explicit assignments survive the split.MaintainPopulationfollows its assignment, asSummaryAggdoes; it no longer always runs at ingestion time.EvaluatePopulationreads a timedMaintainPopulation.ir::timing). Nothing is silently moved to the other timing; an infeasible assignment is an error:UpstreamNotAtIngestion. This covers an explicitMatAtIngestionand nodes a candidate builder fixed at ingestion time (e.g. a fixed-window rate finalize), which previously failed withIllegalChildDataState.FinalizeExactAccumulatorread boundary) keeps that timing. An explicit assignment that agrees is kept; one that needs the other timing fails withMaterializationConflictsWithFixedTiming.MatAtIngestion; the query reads its stored output. A row-producing root that runs at ingestion time without being stored there fails withUnstoredIngestionRoot, which replacesMaintenanceRowsAtRoot.OperatorNode,FlatNodeandPhysicalASAPDAGNodecarry theirMaterialization.PhysicalASAPDAGvalidation rejects a materialization that contradicts the node's timing (MaterializationTimingMismatch). Wire version 10.PhysicalASAPDAG::with_execution_phasesis removed (docs: propose workload-wide planning, summary sharing, and materialization #509 Assumption 8: the deployment executes the plan as given).PlanOutput::execution_timed_dag(feat(planner): export a planned workload as one physical ASAP DAG #666) now times the operator roots and the scalar roots' references withapply_materialization_timingsunder the default assignment and one shared memo, and returnsExecutionDataStateErrorinstead of the lifecycle timing error.MajorPassassembles each root withassemble_selected_query(beforeshare_common_sub_dags), so an exact-state root is read throughFinalizeExactAccumulator, as in refactor(planner): plan the workload on the unified operator IR #542.frontier_from_timingreads only ingestion timing and documents thatMatAtQuerystorage is not reflected yet (Stage 2 adds it). The maintained precompute compilers inpromql_rowsassignMatAtIngestionexplicitly.Operator<NodeId>payloads.How
The PR removes the lifecycle and replaces the two-way timing assignment with the three #509 options. Candidate legality in Pass 1 is still checked as if every summary were
MatAtIngestionwhere the DAG allows it (validate_at_ingestion, formerlyvalidate_default), so a candidate stays executable if Stage 2 later materializes it at ingestion; candidate generation is unchanged.planned_data_stateuses the same assumption. Tests that exercise ingestion-time execution assign it explicitly (at_ingestionhelpers). The four execution tests removed with the lifecycle are ported tocrates/integration-tests/tests/materialization_e2e.rsand check thatNotMaterializedandMatAtIngestiongive the same answers.Before this PR
MajorPasschose a lifecycle per summary state (maintain at ingestion, or recompute at query time) using lifecycle costing, and timed plans with that choice.MaintainPopulationalways ran at ingestion time, and a candidate-fixed timing that conflicted with its upstream failed with a genericIllegalChildDataState.After this PR
MajorPassselects candidates by cost and assembles them. Nothing is materialized unless a caller assigns an option; choosing options is Stage 2's job (#604).API changes:
UserInput::new/OptimizationInput::newdrop the lifecycle argument;LifecycleInput,OptimizationInputError::InvalidHorizonandOptimizeError::{LifecycleSelection, LifecycleAssembly}are removed (assembly errors areOptimizeError::Realization).QueryLifecyclePlanbecomesQueryPlan { entry_index, root }.LifecycleAssignment/apply_lifecycle_timings/validate_defaultbecomeMaterializationAssignment/apply_materialization_timings/validate_at_ingestion.MaterializationAssignment::settakes any node;split_shared_by_phasereturns the remapped assignment.ExecutionDataStateErrorgainsUpstreamNotAtIngestion,MaterializationConflictsWithFixedTimingandUnstoredIngestionRoot(replacingMaintenanceRowsAtRoot);PhysicalASAPDAGValidationErrorgainsMaterializationTimingMismatch.PlanOutput::execution_timed_dagreturnsExecutionDataStateError.PhysicalASAPDAG::with_execution_phasesis removed;PHYSICAL_ASAP_DAG_WIRE_VERSIONis 10.Evidence
e2e_plan,summary_sharing,operator_design_examplesandweighted_topk_bindingtests.ir::timingunit tests cover each rule:ingestion_time_node_over_query_time_upstream_is_rejected,ingestion_pinned_finalize_over_query_time_state_is_upstream_not_at_ingestion,fixed_timing_keeps_an_agreeing_assignment_and_rejects_a_conflict,a_root_may_be_stored_at_ingestion_time,any_node_may_be_materialized,split_keeps_explicit_assignments.promql_to_post_asapcoversUpstreamNotAtIngestionthrough a frontend.materialization_e2e.rsexecutes the KLL quantile, the current-series population, andsum_over_timearithmetic over one and over different selectors withNotMaterializedand withMatAtIngestion, and gets the same results.types/tests/physical_export.rscoversMaterializationTimingMismatch(materialization_inconsistent_with_timing_is_rejected), including on a scalar-only DAG.Verification
materialization_e2e.rs:materialization_decides_precompute_contents,population_materialization_decides_precompute_contents,arithmetic_over_one_selector_executes,arithmetic_over_different_selectors_matches_prometheus.test_render(29 passed; the lifecycle-plan UI tests are removed).cargo fmt --check; workspace all-target Clippy with-D warnings;cargo test --workspace(1,540 passed, 0 failed, 2 ignored);tools/verify_metricsql_external_consumer.shOK. The test count is lower than refactor(ir): remove the legacy QueryExpr and SummaryExpr IRs; move docs and DAG viewer to the unified IR #543's 1,635 because the lifecycle tests are deleted with the lifecycle.Architectural decisions
NotMaterialized/MatAtIngestion/MatAtQuery. The medium is part of the option, soMaintainPopulationgets the same three options.with_defaultonly supplies defaults forSummaryAgg/MaintainPopulation; Stage 2 chooses the rest.Limitations and follow-up
frontier_from_timingreflectMatAtQuerystorage. Timing: a node shared across batch queries with different timings fails with ConflictingTiming #654 covers batch timing conflicts.Stack: tracker #528 · main → #542 → #665 → #666 → #543 → #667 → #561.
Human review — do not complete with an agent
🤖 Generated with Claude Code
https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW