Skip to content

refactor(types): arrange asap-types modules by #511 section (#572 B1) - #578

Draft
zzylol wants to merge 1 commit into
stack/509-c4-example1-acceptancefrom
stack/572-b1-types-modules
Draft

zzylol wants to merge 1 commit into
stack/509-c4-example1-acceptancefrom
stack/572-b1-types-modules

Conversation

@zzylol

@zzylol zzylol commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Step B1 of Phase B of #572 (tracker #528): arrange asap-types by #511 section instead of the pre-ASAP / post-ASAP split.

Why

pre_asap and post_asap no longer describe their contents. There is one operator DAG (#511), pre_asap::schema is the schema of every DAG, and post_asap::sketch is shared vocabulary that the logical stage uses. The later Phase B crates (logical-optimizer, physical-optimizer, plan-selection, executor) should import types by what they are, not by a stage name that no longer exists.

What

Before this PR

crates/types/src/
  ir/          node, non_asap, asap, operator_properties, scalar, aggregate_schema, error,
               timing, summary_coverage, export, physical_export, wire, cse, canonicalize,
               query, schema_support
  pre_asap/    agg_intent, expr_ir, schema, scalar_type_rules, column_resolution
  post_asap/   sketch, guarantee, execution_data_state, maintained_population,
               summary_window, query_time/
  workload.rs, parsed_workload.rs, resources.rs + resources/
  cost.rs, dag_export.rs, serde_f64.rs, types.rs

After this PR

crates/types/src/
  ir/
    operator/    node, non_asap, asap, operator_properties, agg_intent, maintained_population
    scalar/      ScalarExpr (mod.rs), expr_ir items, scalar_type_rules, column_resolution
    schema/      Schema/Field/FieldDataType/DataType (mod.rs), aggregate_schema, error,
                 state_type (was post_asap::sketch)
    properties/  guarantee, timing, summary_coverage,
                 execution (ExecutionTiming / DataPrimitive / ExecutionDataState / ExecutionDataStateError)
    export, physical_export, wire, cse, canonicalize, query, schema_support
  workload/      workload (mod.rs), parsed_workload, resources/
  physical/      execution_data_state (lift_plain, ExactOperationSchemaError), summary_window
  cost.rs, dag_export.rs, serde_f64.rs, types.rs   (unchanged)
  • Public type names do not change. Only module paths change.
  • post_asap::query_time had no callers and is deleted, along with its 20 unit tests.
  • No compatibility re-exports from the old paths. Each section's mod.rs re-exports the vocabulary that pre_asap / post_asap used to re-export, so pre_asap::AggIntent becomes ir::operator::AggIntent, post_asap::SketchAlgorithm becomes ir::schema::SketchAlgorithm, and so on. The ir root keeps its existing re-exports (OperatorNode, ASAPOp, the timing functions, …).
  • lib.rs crate docs and the docs that cite module or file paths are updated.

How

  • git mv for every file, so history follows the moves. Similarity is 88–100 %.
  • A script parses every use tree rooted at asap_types, planner_types / planner (the alias in asap-physical-operators) or crate (inside asap-types), maps each leaf path to its new module, and regroups the result. It does the same for inline qualified paths. Then cargo check iteration and cargo fmt.
  • Measured volume: 217 files changed (204 .rs). About 580 use statements rewritten, plus about 345 inline qualified paths.
  • Behavior-preserving. #[test] count goes from 1793 to 1773, and the 20 removed are exactly the deleted query_time tests. No other test is changed beyond its import paths.

Gate at this tip: cargo fmt --all --check, cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo test --workspace (1518 passed, 0 failed, 12 ignored) and python3 -m unittest discover -s tools/dag-viewer -p test_render.py (29 run, OK, 6 skipped) all pass.

Deviations from #572, for review

  • ExecutionDataStateError and DataPrimitive go to ir::properties together with ExecutionTiming / ExecutionDataState, not to physical. The reason is the one Reorganize crates and modules by #509 stages and the #511 unified IR #572's update gives for the split: ir/timing and ir/physical_export use them. What stays in physical::execution_data_state is lift_plain and ExactOperationSchemaError. Their only callers today are Stage 1 (exact_composition), so physical may not be their final home.
  • expr_ir.rs is now a private file of ir::scalar, and its four items are re-exported there. This avoids an ir::scalar::expr_ir path that keeps the legacy name.
  • Not listed in Reorganize crates and modules by #509 stages and the #511 unified IR #572, so left in place: ir::schema_support (PromQL series-identity realization) stays at the ir root, and cost, dag_export, serde_f64, types stay at the crate root.
  • tools/dag-viewer/post_asap_fixture.json still exists but nothing references it, so it is not renamed. PostAsapDAG / pre_asap_sub_dag are gone from code. PostAsapDAG is still mentioned in prose in docs/design_docs/concepts/post-asap-ir.md, docs/design_docs/physical-planning-and-deployment.md and docs/develop_docs/library-api.md, which this PR leaves alone.
  • Migration tables in docs/develop_docs/*-migration.md keep their historical pre_asap:: paths.
  • Step B0 (moving the CostModel trait and recurrence types into asap-types) is not in this stack, and this PR is based directly on test: #509 Example 1 acceptance spec and end-to-end tests #577. B0 cannot be done as a types-only move:
    • The trait's signature needs Stage 1 types that carry behavior: ReplacementSubDAG, TargetSubDAG, Replacement, Realization, ExactComposition, ExactOperation and OperationPlacement. For example, ExactComposition::compose_with_accuracy uses AccuracyModel, and OperationPlacement::provenance returns ReplacementProvenance.
    • Two default method bodies call behavior: size_params calls accuracy::estimators::size_params, and cse_share_decision_with_recurrence calls recurrence::decide.
    • B0 needs a decision before it can proceed.

Refs #572 · #528

🤖 Generated with Claude Code

Replace the pre_asap/post_asap split with modules named for what they hold:

- ir::operator: node, non_asap, asap, operator_properties, agg_intent,
  maintained_population
- ir::scalar: scalar expressions, expr_ir items, scalar_type_rules,
  column_resolution
- ir::schema: Schema/Field/DataType, aggregate_schema, error, and the
  summary state types (state_type, formerly post_asap::sketch)
- ir::properties: guarantee, timing, summary_coverage, and the execution
  timing/data-state types split out of execution_data_state
- workload: workload, parsed_workload, resources
- physical: the rest of execution_data_state, and summary_window

post_asap::query_time had no callers and is deleted. Public type names are
unchanged; every import across the workspace is rewritten, with no
compatibility re-exports from the old paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant