Skip to content

Reuse Planner accuracy guarantees and remove disconnected cost summaries - #710

Merged
zzylol merged 2 commits into
mainfrom
refactor/planner-accuracy-and-cost-cleanup
Sep 13, 2026
Merged

zzylol merged 2 commits into
mainfrom
refactor/planner-accuracy-and-cost-cleanup

Conversation

@zzylol

@zzylol zzylol commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Why

Accuracy metadata duplicated formulas that disagreed with ASAPPlanner, and /api/v1/plan reported cost-summary placement decisions that did not drive emitted deployment configs.

Closes #707 using the agreed Planner-owned formula boundary. Addresses item 1 and stale module documentation in #703; the broader cleanup remains open.

What

  • Remove the disconnected allocator/planner chain and plan_summary; retain transmission_costs and the actual deployment path.
  • Derive CMS, HLL, KLL/HydraKLL, and DDSketch metadata from ASAPPlanner. Preserve backend-only CountSketch, heap retention, GOS, and uncalibrated UnivMon behavior.
  • Represent unknown failure probability as delta: null and preserve it through multi-segment envelopes.

How

Source adapters normalize their parameters to Planner SketchParams. The shared wire adapter projects DefaultAccuracyModel::sketch_guarantee; no family formula is copied into the backend. Existing derivation traits remain available. Installed config fields and fingerprints are unchanged.

Before this PR

CMS reported 2^-depth, KLL used 2.296/sqrt(k), and HLL reported delta: 0. A separate legacy allocator produced plan_summary even though deployment configs came from another path.

After this PR

CMS and KLL follow Planner's exp(-depth) and empirical 99th-percentile rank-error contract. HLL reports relative standard error with unknown confidence. The plan API no longer exposes the disconnected estimate.

Evidence

For HLL precision 14, metadata changes from { "epsilon": 0.008125, "delta": 0, "kind": "relative_cardinality" } to the same record with "delta": null; the text summary says δ=unknown.

Screenshots and performance measurements are not applicable to this backend refactor.

Verification

Validated on the clean PR branch based on b1a58ca8 with Rust 1.98:

  • cargo check --workspace --all-targets: passed.
  • cargo test -p control_plane --lib: 742 passed, including physical compilation and publication coverage.
  • cargo test -p data_plane --lib accuracy: 53 passed.
  • cargo test -p data_plane --lib query_engines::asap_query_engine: 127 passed.
  • cargo test -p control_plane --bin control_plane api_tests::plan_: 4 passed.
  • cargo test -p data_plane --test e2e_controller_plans_and_backend_serves: 12 passed.
  • Changed-file rustfmt and git diff --check: passed.

New tests compare control-plane and backend profiles for representative parameters across all four shared families, preserve GOS confidence, retain uncalibrated UnivMon, and check that unknown confidence survives segment merging and HTTP serialization. The plan API test verifies removal of plan_summary while retaining transmission costs.

Architectural decisions

Reuse the existing authoritative Planner model rather than introducing another formula module or moving the old approximations. asap_types owns only the wire representation and projection. Parameter extraction remains source-specific because accumulator construction has different normalization rules.

Limitations and follow-up

Consumers must handle nullable delta and removal of plan_summary. Formula-derived metadata changes intentionally. Resource-budget-aware placement and deployment-derived cost explanations remain separate v2 work; deleting the old summary chain does not implement them. Other #703 cleanup items are outside this PR.

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] Centralize planner and backend accuracy formulas

1 participant