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
zzylol
added a commit
that referenced
this pull request
Oct 13, 2026
The specs and tests from #590 run the current stages through the shared planner_layering_common pipeline (Pass 1 and composition, optimize_physical_asap, select_plan); tests are named after the stages. Materialization is read from the physical DAG (#667); window forms and retention stay pending adapters. Behavior that works passes (29 tests); every expectation that needs a feature not in this stack is ignored with the PR that delivers it (29 tests): Pass 2 sharing (#588, #595, #596), window composition (#601, #628, #634), materialization enumeration and MatAtQuery (#604, #625), UnivMon sizing and accuracy (#621), SQL recognition and COUNT(*) composition (#598, #603) and plan selection row estimates (#632). Each spec's "Today" column states the current output. 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
…r candidate logical ASAP DAGs (#576) * feat(planner): #509 Stage 2 physical candidates and Stage 3 plan selection (MVP) Stage 2 implements one logical candidate physically: exact Aggregate{[TopK]} becomes Limit(Sort) per group, summaries stay build -> estimate, every node runs at query time, and the timed roots export as one PhysicalASAPDAG. Stage 3 is the only stage that computes cost. It rejects candidates whose summary misses its query's accuracy target (accuracy model, analytical guarantee) or uses Count-Min over weights not proven non-negative, prices every valid candidate node by node with analytical_cost (illustrative statistics), selects the cheapest and reports the rest as costlier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(devtools): stage_pipeline emits all four stages for Example 1 Add stage2_physical_asap (no cost) and stage3_selection (costs, selected, every other candidate rejected as invalid or costlier) per the v2 contract. PromQL rows carry the series identity from Stage 0, as runtime state needs. Regenerate tools/dag-viewer/examples/planner-layering-example1.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(planner): read Operator<NodeId> payloads in Stage 2/3 after the export removal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(planner): Stage 2/3 on #575's composed candidates, query roots and #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 * test(devtools): regenerate the four-stage Example 1 fixture on the new #575 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * docs(planner): name Stage 2/3 by the planner-layering stage terms Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(devtools): prune a logical candidate Stage 2 cannot implement, with its reason A Stage 2 error no longer fails the whole candidate set: stage_pipeline lists that candidate under stage2_physical_asap.pruned and plans the rest. Full materialization enumeration is left to #604. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(planner): read empirical output accuracy from deployment evidence in Stage 3 The output-level hook moves from AccuracyModel to AccuracyEvidenceProvider: AccuracyModel stays theoretical, Stage 1 composes root guarantees with the built-in model, and deployment evidence enters only in Stage 3. A scalar root that is exactly scalar(v) inherits v's guarantee; any other scalar expression over an approximate operand has none until #669. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * refactor(planner): name Stage 2/3 code and pipeline keys after the stage names physical_candidates -> physical_asap_optimization (stage2_physical -> optimize_physical_asap, Stage2Error -> PhysicalASAPOptimizationError), stage3_select -> select_plan, and the stage_pipeline keys stage2_physical_asap -> physical_asap_optimization and stage3_selection -> plan_selection. The fixture is regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test(planner): plan selection tests after Top-K estimates lost their bound #575 gives Top-K and signed Count-Min estimates guarantee None, so the CountSketch+heap candidate of the top-k fixture no longer carries an analytical guarantee: plan selection rejects it for missing evidence rather than for missing the target. The "misses target" case now uses a quantile summary planned at a looser target, and the per-node cost test admits the CountSketch+heap candidate through deployment evidence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(planner): exact top-k sorts by the ranked measure in physical optimization Rank a one-measure grouped child by its measure (the SQL heavy-hitter and PromQL `topk(k, sum by ..)` shapes) and per-series rows by the sample value, instead of looking up a `value` column. A node reading the top-k gets a Project restoring the logical [keys.., topk_k] columns over the rows. An Aggregate{[TopK]} with other measures, a filter or HAVING now fails, so its candidate is pruned with the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(devtools): stage_pipeline emits plan_selection when selection fails With no valid candidate the document lists the rejections with a null `selected` (and the Stage 2 pruned list as before); any other selection error is reported under `error`, instead of failing the run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * docs(planner): plan selection checks Count-Min only under a target; note MVP costing limits Reword the Count-Min test to the decided behavior and test that a query without a target admits the Count-Min candidate. Document that a cost error aborts selection (only from bad declared rates) and that binary, join and concat nodes are priced from their first input only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(planner): exact top-k ranks by the measure of a composed Stage 1 child After Pass 1 composition a top-k reads its one-measure aggregate as Project(FinalizeExactAccumulator(SummaryAgg)) or Project(SummaryEstimate(..)), not as an Aggregate, so ranking fell back to the sample value: a key named `value` was sorted on, and an integer or multi-column key pruned the candidate. Look through renaming Projects, Filters, finalize and estimate to the SummaryAgg or Aggregate; a grouped one ranks by its last column. The SQL test now composes every Pass 1 choice under exact and approximate targets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(planner): exact top-k roots output the logical [keys.., topk_k] columns An exact top-k root returned its child's raw rows (Example 1's P1 leaked `ts`, `value` and `$promql_series_identity`), while summary candidates and the frontend give `[keys.., topk_k]`. The restoring Project now sits over the Limit at a root too, so one implementation serves roots and consumers. `topk_k` carries the ranked value's type and nullability, not the frontend's Utf8 placeholder. Regenerate the Example 1 fixture: P1 gains the root Project (node 12). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(planner): charge a NotMaterialized shared node once per consuming query Plan selection prices each node once per computation: a materialized node once, a NotMaterialized node once per query (or materialized node) that reaches it, not counting through a materialized ancestor. Per-node costs carry the multiplier. Also list the per-entity case among the exact top-k shapes Stage 2 cannot rewrite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * docs(planner): nodes below a materialized node are charged once for it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
added a commit
that referenced
this pull request
Oct 13, 2026
The specs and tests from #590 run the current stages through the shared planner_layering_common pipeline (Pass 1 and composition, optimize_physical_asap, select_plan); tests are named after the stages. Materialization is read from the physical DAG (#667); window forms and retention stay pending adapters. Behavior that works passes (29 tests); every expectation that needs a feature not in this stack is ignored with the PR that delivers it (29 tests): Pass 2 sharing (#588, #595, #596), window composition (#601, #628, #634), materialization enumeration and MatAtQuery (#604, #625), UnivMon sizing and accuracy (#621), SQL recognition and COUNT(*) composition (#598, #603) and plan selection row estimates (#632). Each spec's "Today" column states the current output. 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
…stages (#577) * test: acceptance spec and pending tests for planner-layering Example 1 Define MVP acceptance for #509 Example 1 before the Phase C stage APIs exist: 1 -> 6 -> 6 -> 1 candidates (Pass 1 x identical-expression sharing; physical operator implementation only, no materialization). - Spec with per-stage candidate tables, invariants and doc ambiguities. - Integration tests against todo!() stage stubs, ignored until the stages land; workload and Stage 0 frontend-shape tests run now. - Expected-only asap-stage-pipeline/v1 fixture for the DAG viewer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: run the Example 1 acceptance tests against the real stages Replace the todo!() stubs with adapters over Stage 0-3, un-ignore the 11 tests that pass, and give each still-ignored test the precise difference between the implementation and the spec. Add runtime capability checks: the selected plan compiles in the physical planner; compiling every candidate stays ignored with the two runtime gaps it finds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: read Example 1 logical stages as flat DAGs after the export removal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test: Example 1 acceptance on the composed stages (1 -> 3 -> 3 -> 1) The tests run Pass 1 and composition, optimize_physical_asap and select_plan through a shared tests/planner_layering_common pipeline, and follow the decided behavior: three Pass 1 candidates (Q2 exact, CMS+heap, CountSketch+heap), every sub-DAG NotMaterialized, P1 selected, CMS+heap invalid (weights not proven non-negative) and CountSketch+heap invalid (a Top-K output has no guarantee and no deployment evidence). Hydra (#605), Pass 2 sharing (#588) and the two runtime gaps (#593, #579) stay ignored with the PR that delivers them. Tests are named after the stages; the compile check no longer uses the PromQL fallback. The spec lists where the doc and the planner differ. The expected-only viewer fixture is removed: the generated four-stage fixture replaces it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test: port #590's Example 2-4 acceptance specs and tests The specs and tests from #590 run the current stages through the shared planner_layering_common pipeline (Pass 1 and composition, optimize_physical_asap, select_plan); tests are named after the stages. Materialization is read from the physical DAG (#667); window forms and retention stay pending adapters. Behavior that works passes (29 tests); every expectation that needs a feature not in this stack is ignored with the PR that delivers it (29 tests): Pass 2 sharing (#588, #595, #596), window composition (#601, #628, #634), materialization enumeration and MatAtQuery (#604, #625), UnivMon sizing and accuracy (#621), SQL recognition and COUNT(*) composition (#598, #603) and plan selection row estimates (#632). Each spec's "Today" column states the current output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * feat(devtools): stage_pipeline examples for #509 Example 3 Ported from #590: --example planner-layering-3a (Pattern A, ad hoc batch of five p99 reports) and planner-layering-3b (Pattern B, repeating 5-min p99), the Example 3 acceptance tests' workloads. Example 1's output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test: follow #576's per-consumer charging and exact top-k columns Plan selection charges a NotMaterialized node once per consuming query, so the charging helper checks NodeCost.multiplier and the Example 4 A3 ambiguity is recorded as decided. Example 1 checks that exact Q2 sorts by the ranked value and returns [job, topk_10]. The stage viewer guide's tab 1 row now describes the actual all-exact result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * refactor(devtools): one planning pipeline for stage_pipeline and the acceptance tests run_planning_stages and the #509 example workloads move into the asap-devtools library; stage_pipeline serializes the run and the planner-layering tests adapt it. The shared data workload drops ingestion_rate for data at rest, which validate() requires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(devtools): select over every candidate; --max-displayed limits only the document stage_pipeline capped enumeration at 64, so Example 3a (243 candidates) selected P41 instead of the cheapest P122 (KLL for all five queries). The pipeline now enumerates, optimizes and prices every candidate; the document shows the first --max-displayed (default 64) plus the selected one, with `combinations` and `capped`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * docs: Example 2's SQL candidates compose; the SQL test waits only on #598 Running the ignored SQL test composes every candidate and fails only on Q2's options (per-source counts until #598), so #603 is not a blocker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test: name stages by number and name; say query-language frontends The frontends' Run field, id and locals become stage0_query_language_frontends, and test names carry stage0..stage3 with the stage name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test: charging helper follows plan selection's per-consumer rule With a materialized node the helper accepted any multiplier >= 1. It now computes each node's computations as plan selection does (walks from query roots and materialized nodes' inputs, stopping at materialized nodes), checked on a hand-built candidate with a materialized node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test: Example 1 picks Q2 candidates by (option, no shared input) physical_with and the invalid-candidate check no longer assume one candidate per Q2 option, so #588's shared-input variants need no change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * docs: Example 3 Pattern B charges each node once per consuming query Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * docs(stage-viewer): rows 2, 3a and 3b describe the planner's current output Read from uncapped runs: Example 2's sketch plans are rejected for having no (ε, δ) guarantee, 3a selects P122 (first of 108 tied cheapest plans, nothing shared yet) and 3b selects query-time KLL; panes and the latency check come with the window-summary PRs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * docs(stage-viewer): row 2 from the SQL run; 3a ties 32 plans, not 108 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test: Example 1 counts only unshared candidates; stage3_ charging-helper names The 3-logical and 3-physical counts now hold when #588 adds shared-input variants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * refactor(devtools): PlanningStagesRun fields carry stage number and name Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test(devtools): unique temp file per stage_pipeline run cargo test runs the tests as threads of one process, so two runs of the same example shared a file name and one deleted the other's output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.QueryPlan { entry_index, root }. (In this PR the planner of that time, the legacy search, selected candidates by cost and assembled them; since feat(planner): run the planning stages as the planner pipeline; retire MajorPass #674 the planner isrun_stage1_to_stage3/Stage1ToStage3Pass, refactor(planner): name the planner pipeline Stage 1 to Stage 3 and its fields by stage #675 names, which outputs Stage 3 plan selection's choice.)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.FinalizeExactAccumulatorwithout it, as in refactor(planner): plan the workload on the unified operator IR #542. On main, Stage 1 composition (feat(planner): compose candidate logical ASAP DAGs from Pass 1 per-computation candidates #575) builds the finalize into every exact-accumulator candidate.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
The planner chose 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
Nothing is materialized unless a caller assigns an option; choosing options is Stage 2's job (#604). On main, Stage 2 physical ASAP-aware optimization (#576) assigns
NotMaterializedto every sub-DAG, and Stage 3 plan selection picks the plan.API changes:
UserInput::new/OptimizationInput::newdrop the lifecycle argument;LifecycleInput,OptimizationInputError::InvalidHorizonandOptimizeError::{LifecycleSelection, LifecycleAssembly}are removed (assembly errors becameOptimizeError::Realization, which feat(planner): run the planning stages as the planner pipeline; retire MajorPass #674 removed with the legacy search).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_sharingandoperator_design_examples.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.Later changes: #674 retired the legacy search (
MajorPass) as the planner; the planner isrun_stage1_to_stage3/Stage1ToStage3Pass(#675 names), Stage 2 assignsNotMaterializedeverywhere until #604, and identical producers are not merged until Pass 2 (#580).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