Skip to content

refactor!: clarify planner realization, schema, and handoff APIs - #448

Open
zzylol wants to merge 1 commit into
mainfrom
refactor/427-planner-vocabulary
Open

zzylol wants to merge 1 commit into
mainfrom
refactor/427-planner-vocabulary

Conversation

@zzylol

@zzylol zzylol commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Why

Closes #427. Planner APIs reused “implementation,” “bind,” and “boundary” for unrelated concepts, making candidate construction, schema resolution, window coverage, and physical transfers hard to distinguish.

What

Rename the concepts and their callers consistently:

  • Realization, RealizationError, and SummaryRealization identify candidate physical forms; internal enumeration becomes realizations_for_intent.
  • SchemaResolver::resolve_schema and resolve_schema_with_inherited replace the schema binder family.
  • PaneLayout and WindowEdgeCoverage::ExactWindowEdgeResidual describe window coverage.
  • physical_handoff_cost, PhysicalHandoffKind, PhysicalHandoffBytes, and the related evidence/profile/estimate types describe transfers and materialization.
  • Internal CandidatePlanningInputs and new_with_planning_inputs* constructors name injected cost, accuracy, allocation, and evidence dependencies.

Update documentation to use “comparison scope” and “planner-runtime contract,” including document paths and incoming links. Ordinary fluent builders and SQL/PromQL syntax retain their names.

How

This is a source API refactor with no new planning abstraction or algorithm. All workspace consumers use the new vocabulary. Explicit Serde names preserve deployed JSON keys and variants; model-version strings and exported resource labels remain stable.

Before this PR

A caller used Binder::new().bind(&tree), cost-model extensions returned Implementation, and a physical transfer used BoundaryKind even though pane coverage also used “boundary.”

After this PR

The same caller uses SchemaResolver::new().resolve_schema(&tree), returns Realization, and declares a PhysicalHandoffKind. Window edges use WindowEdgeCoverage. The same queries and physical evidence produce the same plans and resource arithmetic.

See the migration guide for the complete source-name mapping.

Evidence

  • Full workspace run: 1,166 passed, 0 failed, 0 ignored across 66 test/doc-test suites.
  • New external-style API tests exercise schema resolution and physical handoff imports, and preserve existing window-edge wire values.
  • Handoff evidence/estimate tests preserve boundaries and per_boundary JSON keys and the expected 240-byte network estimate.
  • The existing planner-cost export test now also checks the original nested boundaries keys before parsing and selecting a physical plan.
  • Screenshots, performance measurements, and architecture diagrams: not applicable to this naming refactor.

Verification

  • cargo test --workspace --locked: passed.
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed.
  • cargo fmt --all --check and git diff --check: passed.
  • bash tools/verify_metricsql_external_consumer.sh: passed on stable Rust.
  • python3 tools/verify_metricsql_vendored_baseline.py: passed; preserved the 21 library and 3 documentation upstream failures recorded by that baseline checker.
  • Rustdoc for asap-types and asap-aware-mapping: built successfully; existing documentation warnings remain. Relative links in changed Markdown documents resolve.

Architectural decisions

Use one Rust naming family per concept rather than retain old aliases alongside it. Migration notes cover the source break. Preserve wire names through Serde so downstream evidence files and exported contracts require no JSON migration.

Limitations and follow-up

This breaks Rust source imports and call sites using the old names; downstream crates must apply the migration table. Historical archived documentation is unchanged. This is implementation and verification by the same agent, not an independent review.

Human review — do not complete with an agent

  • The MVP boundary is correct.
  • New conceptual layers or public interfaces are necessary.
  • The before/after description matches the intended product behavior.
  • Human reviewer:
  • Decision and rationale:

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.

[Refactor] Rename data structures and functions to be clearer

1 participant