Repository navigation
test: planner-layering Examples 1–4 acceptance specs on the planning stages - #577
Merged
Merged
Conversation
This was referenced Oct 3, 2026
Merged
zzylol
force-pushed
the
stack/509-c4-example1-acceptance
branch
from
October 5, 2026 06:21
0afc939 to
f620555
Compare
zzylol
force-pushed
the
stack/509-c3-stage2-3
branch
from
October 8, 2026 16:47
6b7d8a8 to
d613b0f
Compare
zzylol
force-pushed
the
stack/509-c4-example1-acceptance
branch
from
October 8, 2026 16:47
f620555 to
b8ad78c
Compare
zzylol
force-pushed
the
stack/509-c3-stage2-3
branch
from
October 10, 2026 14:32
d613b0f to
243c791
Compare
zzylol
force-pushed
the
stack/509-c4-example1-acceptance
branch
from
October 10, 2026 14:32
b8ad78c to
0541f9a
Compare
zzylol
force-pushed
the
stack/509-c3-stage2-3
branch
from
October 11, 2026 17:11
243c791 to
bd70f05
Compare
zzylol
force-pushed
the
stack/509-c4-example1-acceptance
branch
from
October 11, 2026 17:11
0541f9a to
4f6e4ba
Compare
zzylol
force-pushed
the
stack/509-c3-stage2-3
branch
3 times, most recently
from
October 13, 2026 15:02
99a1b3c to
60197da
Compare
zzylol
force-pushed
the
stack/509-c4-example1-acceptance
branch
from
October 13, 2026 15:32
4f6e4ba to
d360107
Compare
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>
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>
…oval Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
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
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
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
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
zzylol
force-pushed
the
stack/509-c4-example1-acceptance
branch
from
October 13, 2026 15:34
d360107 to
074c51a
Compare
…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
…ly 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
…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
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
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
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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
…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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
…per 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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW
zzylol
marked this pull request as ready for review
October 13, 2026 16:17
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
This was referenced Oct 13, 2026
zzylol
added a commit
that referenced
this pull request
Oct 13, 2026
…e MajorPass (#674) * feat(planner): run the planning stages as the planner pipeline; retire MajorPass plan_stages runs logical ASAP-aware optimization (Pass 1 and composition of every combination, capped), physical ASAP-aware optimization and plan selection over the frontends' roots, and returns every stage's output. StagePipeline runs it behind OptimizationPass and is the facade default; the stage_pipeline devtool uses it (its fixture is unchanged). The combination count saturates instead of overflowing. summary_sharing: sharing tests are ignored until Pass 2 (#580); the UnivMon legacy-search test is deleted; scalar and combined-quantile tests run on plan_stages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test(planner): logical and physical ASAP-aware optimization import no cost model From #582: only plan selection prices plans, so the Pass 1 / composition and physical ASAP-aware optimization modules may not import cost_model, recurrence, analytical_cost, physical_operator_statistics or plan_selection (paths or re-exported names) outside tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * fix(planner): compose a per-series avg over rows that carry the series identity The per-series sum keeps the input's labels, so with $promql_series_identity after the sample value its last column is the identity, and composition rejected the only exact option ("non-Float64 per-series avg"). The planner pipeline then had no candidate for avg_over_time. Read the summed value by its role instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test(executor): take plans and candidates from the planner pipeline From #629/#633: executor tests take the plan plan_stages selects (selected_dag) or its composed logical candidates (logical_candidates) instead of the legacy search and global selection. - deployment_computation, precompute_candidates, the candidates.rs fixture: ported. - planspace_series_identity_heap: keeps the selection check; the four tests of the legacy whole-root proposals are deleted. - weighted_topk_binding: ported to Pass 1 heap candidates (Count Sketch only over rates: no sign proof). The tests of legacy-only candidate generation are deleted. Ignored, with reasons: the grouped weighted binding (whole-expression heap, #589) and the two rate-heap executions (top-k output schema, #672). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test(frontend-promql): take plans and candidates from the planner pipeline From #629/#633, on support helpers over plan_stages (plan_stages, selected_dag, logical_candidates, logical_plan): - count_planning: exact counts select a Count accumulator; count updates are read from the composed Count-Min / Count Sketch candidates. The Hydra test is ported and ignored: Pass 1 offers no Hydra for a grouped count yet (#605). - univmon_candidates: the synthetic accuracy model is gone; UnivMon candidates come from Pass 1 (the shared count at an approximate target), the uncalibrated ones carry no guarantee and plan selection does not select them. - promql_corpus, metrics_observability: totality over Pass 1 and composition (logical_plan) instead of the legacy strategies; the metrics corpus reports composition errors under METRICS_OBSERVABILITY_REPORT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test(frontend-sql): take corr's exact plan from the planner pipeline From #633: the plan plan_stages selects replaces retain_exact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test(planner): the batch SUM example reads one exact accumulator per query Under the planner pipeline each query's SUM is replaced by its exact accumulator state; sharing identical producers is Pass 2 (#580). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * refactor(planner): stage identifiers carry number and name; enumerate every candidate User decisions (2026-10-13): - stage modules stage2_physical_asap_optimization and stage3_plan_selection; tests stage1_logical_asap_optimization.rs and stage2_physical_asap_optimization_sql.rs; stage_pipeline keys stage0_query_language_frontends, stage1_logical_asap_optimization, stage2_physical_asap_optimization, stage3_plan_selection (fixture regenerated: only the keys change); - enumeration and selection are never capped: plan_stages enumerates every combination; the devtool's --max-displayed (was --max-candidates) caps only the listing; - code docs say "query-language frontends". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test(integration): take plans and candidates from the planner pipeline From #629/#633, on asap_integration_tests::planning (plan_stages, selected_dag, logical_candidates): - sql_to_physical, operator_sharing, materialization_e2e, precompute_raw_samples, summary_coverage_e2e, promql_numeric_regressions: ported. - cse.rs: deleted; it pinned the legacy search's memo groups (sharing identical sub-DAGs is Pass 2, #580). - Ignored, with reasons: the UNION ALL summary test (plan selection picks the exact plan until materialization, #604), arithmetic over one selector (#580), the unit-weight heap over raw samples (#589). - precompute_raw_samples no longer requires a Count Sketch heap over raw samples (#589); materialization_e2e takes the quantile's sketch candidate, since plan selection picks the exact plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * refactor(devtools): sketch_coverage reports Pass 1's summary candidates From #633: per lowered query, the summary candidates Pass 1 offers, instead of the legacy explain_replacements. The CSE-shareable metric is dropped (sharing is Pass 2). Over every corpus at epsilon 0.01 and a 1 s ingestion interval: 145/2183 lowered queries get a summary candidate, and Pass 1 rejects none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * test(frontend-promql): the Kubernetes mixin aggregates over topk compose (ignored, #672) Both corpus queries that do not compose aggregate over a topk output, which the frontend declares as [keys.., topk_k] with a Utf8 placeholder and no value column; the outer sum's accumulator has no value to read. They compose once the top-k output carries the ranked value (#672). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW * refactor(devtools): run_planning_stages runs the library's plan_stages One pipeline implementation: the devtool's run_planning_stages (#577) validates the frontends' roots and every composed candidate, and otherwise is plan_stages with the built-in models. Its candidate types are the library's. The Example 1 fixture is unchanged. 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
planner-layering.md walks four examples through query-language frontends, logical ASAP-aware optimization, physical ASAP-aware optimization and plan selection. Nothing checked the stages against those examples, so a stage could change its candidates or its selection without a test failing. Acceptance specs written by a test designer, run against the real stages, measure the stages against the doc and record every place where they still differ.
What
docs/design_docs/proposals/:planner-layering-example1-acceptance.md(MVP: counts 1 → 3 → 3 → 1).planner-layering-example2-acceptance.md,-example3-acceptance.md,-example4-acceptance.md, ported from test: #509 Examples 2–4 acceptance specs and end-to-end tests #590 (which will be closed).crates/integration-tests/tests/:planner_layering_example{1,2,3,4}.rsover adapters inplanner_layering_common/. A test whose feature is missing is#[ignore]d with the PR or issue that delivers it. Test names carry the stage number and name (stage0_query_language_frontends_…,stage1_logical_asap_optimization_…,stage2_physical_asap_optimization_…,stage3_plan_selection_…).asap-devtoolslibrary:planning_stages::run_planning_stages(workload, roots)returns aPlanningStagesRun(stage0_query_language_frontends,stage1_logical_asap_optimization,stage2_physical_asap_optimization,stage2_pruned,stage3_plan_selection) and runs logical ASAP-aware optimization (Pass 1 and composition, recording per-candidate composition errors), physical ASAP-aware optimization and plan selection over every candidate;planner_layering_examplesholds the Example 1, 3 and 4 workloads.stage_pipelineserializes the run and the tests adapt it, so both see the same candidates, ids and selection.stage_pipeline --example planner-layering-3a | planner-layering-3b: Example 3's Pattern A batch and Pattern B panel in the devtool. Every candidate is optimized and priced;--max-displayed <n>(default 64; replaces--max-candidates) limits only how many the document shows, plus the selected one.docs/user_guide_docs/stage-viewer.md: the "What to look for" cells of tabs 1, 2, 3a and 3b describe the planner's current output, and the--max-displayedoption.How
The Example 1 spec and tests were written first against
todo!()stubs, then the stubs were replaced by thin adapters over the stages from #575 and #576. Tests identify candidates by structure (which summary each query reads, which nodes queries share), never by id. Rebased on the final #576 (1ad70f9), the tests follow its behavior:Projectrestoring[job, topk_10].NotMaterializednode once per consuming query and a materialized node once (NodeCost::multiplier). The shared charging helper now checks that rule instead of "each node once".The viewer fixture
tools/dag-viewer/examples/planner-layering-example1.jsonwas regenerated withstage_pipeline --example planner-layering-1and is byte-identical to #576's.planner-layering-3aprices all 243 candidates and selects P122 (KLL for all five queries), the first of 32 plans tied at the lowest cost, 78209376.4 (KLL or DDSketch per query, 2⁵; exact on an offset interval costs 2 more, e.g. P121 = 78209378.4);3bselects P2 (KLL). Runs are uncapped: before, enumeration stopped at 64 candidates and 3a selected P41.The shared data workload has no
ingestion_ratewhen data is at rest:DataWorkload::validaterejects a positive rate there, and planner-layering.md's at-rest variant has no ingestion. The devtool always set it; the tests dropped it, and the shared definition now follows the tests.Before
No test runs the planning stages on the doc's examples. Example 4's spec left open whether plan selection charges a non-materialized shared node once per consumer or physical ASAP-aware optimization duplicates it.
After
cargo nextest run -p asap-integration-tests -E 'binary(/planner_layering/)': 85 tests, 52 pass, 33 ignored.Example 1 (1 → 3 → 3 → 1; the doc's full set is 1 → 54 → 156 → 1):
Project [job, topk_10]sum_over_timeweights are not proven non-negativeQ1 is exact in all three. Every node is
NotMaterialized.MatAtQuery(#625) ×6; Pattern B: tumbling windows (#601), #604, #625 ×5; sliding windows (no PR) ×1Example 4's charging question is now decided: a shared
NotMaterializednode is charged once per consuming query, so A3 costs five EH builds and A1 one. No Example 4 test became runnable from it, since the shared EH and its materialization options do not exist yet. Example 2's shared-UnivMon dominance test now also names #604: unmaterialized, the shared UnivMon is charged three times.Evidence
stage2_physical_asap_optimization_exact_topk_returns_job_and_topk_10: Q2's root isProject→Limit 10→Sort(one descending key onvalue, partitioned by job), with root columns[job, topk_10].assert_each_node_charged_per_consuming_querymirrors plan selection's computation count: walks from each operator root, scalar root and materialized node's inputs, stopping at materialized nodes; a materialized node counts 1.stage3_plan_selection_charging_helper_*check it on a hand-built candidate with aMatAtQuerynode read by two queries.example3a_selects_the_cheapest_of_all_candidates:stage_pipeline --example planner-layering-3aselects whatrun_planning_stagesselects over all candidates (P122).planner-layering-example1.json: identical to feat(planner): physical ASAP-aware optimization and plan selection for candidate logical ASAP DAGs #576's.Verification
At e2afcd0:
cargo fmt --all -- --check: clean.cargo clippy --workspace --all-targets -- -D warnings: clean.cargo nextest run --workspace: 1654 passed, 0 failed, 35 skipped (33 are the planner-layering ignores).python3 tools/dag-viewer/test_render.py: 29 tests OK.bash tools/verify_metricsql_external_consumer.sh: passes.Architectural decisions
asap-devtoolslibrary modules (planning_stages,planner_layering_examples) so the devtool and the tests run one pipeline over the same workloads.planner_layering_commonare the only place that reads stage output, so a stage change touches one file.NotMaterialized, once for materialized. Physical ASAP-aware optimization does not duplicate shared nodes.Limitations and follow-up
Where the planner differs from planner-layering.md Example 1 (listed in the spec, not fixed in the doc):
NotMaterializedshared input is charged per consuming query, so sharing saves nothing until it is materialized.Examples 2–4 list their own differences in their specs. No
planner-layering-2or-4devtool example yet; the specs say what each needs.Stack: tracker #528 · main → #577 → #578 → …
Human review — do not complete with an agent
🤖 Generated with Claude Code
https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW