Skip to content

chore(sketch_algebra): re-layer three cost/planning modules out of L4 IR - #398

Merged
zzylol merged 1 commit into
mainfrom
chore/sketch-algebra-cleanup-stage4
Jul 20, 2026
Merged

zzylol merged 1 commit into
mainfrom
chore/sketch-algebra-cleanup-stage4

Conversation

@zzylol

@zzylol zzylol commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Stage 4 of the sketch_algebra re-layering (Stage 1: ASAPController#141, Stage 2: #396, Stage 3: #397) — scoped down after a fresh audit found two of the originally-planned four items rested on a stale premise:

  • sketch_params.rs has 14 real production consumers (optimizer/cost/wire.rs, optimizer/engine.rs, optimizer/rules/mod.rs, replan.rs, all of emit/*.rs, all of physical/colored_dag/*.rs), not "one real consumer" as the design doc claimed.
  • PhysicalExpr::RawAtEdgeSketchAtBackend/RawAtEdgePrometheusArchive are actively constructed and matched across optimizer/rules/mod.rs, emit/{mod,telegraf,otap,stage_config}.rs, physical/colored_dag/{emitter,allocator}.rs, and referenced from data_plane/asap_types — not dead code. The "duplicate dead BindMode" claim was also wrong: optimizer::cost::wire::BindMode is a single, real, heavily-tested enum that deliberately mirrors PhysicalExpr's variant names.

Both dropped from this stage; a proper investigation into replacing sketch_params.rs with asap_sketch::SummaryKind/SummaryParams is separate future work given its real blast radius.

Three items whose premises held up:

  1. Deleted sketch_algebra/schema.rs. SketchStateSchema/SketchStateMetadata had zero real callers — every hit was a stale doc-comment cross-reference.
  2. Moved SketchCapability/SupportedIntent/default_capability_table/load_capability_overrides from sketch_algebra::capability into optimizer::cost::sketch_capability — this is the perf/cost-model half of the "four overlapping capability tables" Step 2a originally consolidated, read by the optimizer/physical planner, not L4 IR. sketch_algebra::capability keeps the query-side Capability/SketchKindHandle tag and capability_for, which are genuinely L4-adjacent.
  3. Moved sketch_selection.rs to a top-level control_plane::sketch_selection module — its one external caller is query_planning.rs; naming candidate sketch families for a Capability is a query-planning concern, not L4 IR.

No behavior change — all three moves are verbatim relocations with updated doc comments and import paths.

Test plan

  • cargo build --workspace — clean
  • cargo test -p control_plane — 824 passed, 1 pre-existing unrelated failure (invalid_sketch_type_override_falls_back_to_default)

🤖 Generated with Claude Code

Stage 4 of the sketch_algebra re-layering, scoped down after a fresh
audit found two of the originally-planned four items were based on a
stale premise (sketch_params.rs has 14 real production consumers, not
"one"; PhysicalExpr::RawAtEdgeSketchAtBackend/RawAtEdgePrometheusArchive
are actively constructed across optimizer/rules, emit/*, and
physical/colored_dag/*, not dead) — both dropped from this stage
pending a separate, properly-scoped investigation.

Three confirmed-safe moves:

- Deleted sketch_algebra/schema.rs. SketchStateSchema/SketchStateMetadata
  had zero real callers — every hit was a stale doc-comment
  cross-reference, never constructed or consumed anywhere.

- Moved SketchCapability/SupportedIntent/default_capability_table/
  load_capability_overrides from sketch_algebra::capability into
  optimizer::cost::sketch_capability. This is the perf/cost-model half
  of the "four overlapping capability tables" Step 2a originally
  consolidated — read by the optimizer and physical planner for
  cost-based plan rewriting, not L4 IR. sketch_algebra::capability
  keeps the query-side Capability/SketchKindHandle tag and the
  capability_for semantic bridge, which are genuinely L4-adjacent.

- Moved sketch_selection.rs to a top-level control_plane::sketch_selection
  module. Its one external caller is query_planning.rs; naming the
  concrete sketch families that satisfy a Capability is a
  query-planning concern, not L4 IR.

No behavior change — all three moves are verbatim relocations with
updated doc comments and import paths.

- cargo build --workspace: clean
- cargo test -p control_plane: 824 passed, 1 pre-existing unrelated
  failure (invalid_sketch_type_override_falls_back_to_default)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zzylol
zzylol merged commit 5d47ef2 into main Jul 20, 2026
@zzylol
zzylol deleted the chore/sketch-algebra-cleanup-stage4 branch July 20, 2026 18:08
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