feat(accuracy): propagate end-to-end guarantees for nested summaries (#172) - #303
Merged
Conversation
…y-guarantee-propagation-172"" This reverts commit 5c6489b.
22 tasks
This was referenced Aug 28, 2026
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
Approximate summaries need one caller-visible proof. Sizing each sketch independently can exceed the requested error budget, mix incompatible metrics, or let cost ranking select an unprovable result. This applies to single and nested summaries. Refs #172.
What
AccuracyTargetbefore costing.How
AccuracyModelis the correctness boundary;AccuracyBudgetAllocatorproposes per-layer budgets;AccuracyEvidenceProvidersupplies typed planning-time observations;CostModelsees only candidates that pass propagation and target checking.NoAccuracyEvidenceis the default, so unknown statistics and unsupported metric/operator combinations fail closed.Key built-in contracts include:
2.296 / k^0.9723, inverted for sizing and identified with a pinned Apache DataSketches contract.1.04 / sqrt(2^p)RSE magnitude with unknown failure probability; it can satisfyEpsilon, but notEpsilonDelta.sqrt(3 / width) * ||f||_2with odd median depth and a Hoeffding failure bound.B_inner + B_shared_grid, with failure probabilities union-bounded.Before this PR
Each layer could be sized locally, but the finalized plan had no machine-readable end-to-end proof. TopK and Hydra formulas had no production evidence path, and HLL incorrectly converted its RSE into a claimed 99% confidence bound despite having no confidence parameter.
After this PR
A default ε=0.01 KLL quantile is sized to
k=269under the documented single-sided 99% fit. TopK and Hydra can consume supplied evidence through candidate construction; absent evidence retains the exact/pre-ASAP fallback. Generic HLL no longer claims a failure probability that its parameters cannot prove.Design decisions
AccuracyTargetauthoritative but extensible; a request and its proof are separate types.Design document: End-to-end accuracy guarantees
Developer guide: Accuracy guarantees developer guide
Verification
cargo fmt --allcargo test --workspacecargo clippy --workspace --all-targets -- -D warningsgit diff --checkAll pass locally. The mapping crate contains 215 passing unit tests, including candidate-construction regressions for accepted TopK and Hydra evidence, plus SQL and PromQL end-to-end coverage.
Independent-review note: this final review was performed by the implementing agent, not an independent reviewer.
Limitations and follow-up
EpsilonDelta; adding one requires a new, explicit estimator/parameter contract.