feat(plan): add Implementation::is_satisfied_by (materialized-view-style matching) - #140
Merged
Merged
Conversation
…yle matching) Resolves the crate doc's previously-open question about whether asap-plan should own a matching predicate alongside implementation_for's "how would I build this from scratch" decision. It should: Implementation:: is_satisfied_by(&self, available: &Implementation) -> bool answers "does an already-available Implementation satisfy a required one" -- the query-optimization "materialized view matching" question, narrowed to this crate's own SummaryKind vocabulary. Rules: PassThrough required is vacuously satisfied (nothing to match); ExactAccumulator requires the exact same SummaryKind (accumulators carry no family/subsumption concept -- SummaryKind doesn't encode grouping, so single-vs-multi-population re-aggregation stays entirely a downstream deployment's own concern); Sketch is satisfied by the same SummaryFamily (Quantile: Kll/DDSketch; Cardinality: Hll/Theta/Kmv; Frequency: Cms/ CountSketch), with the one asymmetric case being a heap-bearing top-k sketch (CmsWithHeap/CountSketchWithHeap) also satisfying a bare frequency requirement (the heap is additional info on the same underlying matrix), never the reverse. What this deliberately does NOT do: track an inventory of what's actually been materialized anywhere -- that stays entirely a downstream deployment's job (e.g. control_plane's own sketch_algebra::capability:: Capability/is_satisfied_by, which layers deployment-specific index- matching semantics on top). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…helpers
sketch()/accumulator() previously hardcoded SummaryParams::Kll{k:200} and
SummaryParams::Sum respectively regardless of which SummaryKind was
passed in -- e.g. sketch(SummaryKind::Hll) produced an Hll kind paired
with Kll's params, a combination real code can never construct.
is_satisfied_by only ever matches on kind, never params, so this didn't
affect what the tests actually verified, but it's still misleading test
data. Added params_for(kind) to build the real, constructible params
shape for each SummaryKind instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
zzylol
added a commit
to ProjectASAP/ASAPQuery-backend
that referenced
this pull request
Jul 20, 2026
…ion::is_satisfied_by) Picks up ProjectASAP/ASAPPlanner#140: asap-plan's Implementation:: is_satisfied_by (materialized-view-style matching over the SummaryKind vocabulary -- distinct from and not yet consumed by this repo's own Capability::is_satisfied_by, which stays the deployment-specific index-matching layer; see PR discussion for why these are two separate types, not one delegating to the other). No source changes needed here -- nothing in control_plane calls is_satisfied_by from asap-plan yet. cargo build/test -p control_plane clean (772 passed, 1 known pre-existing unrelated failure). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
Resolves the crate doc's previously-open question about whether
asap-planshould own a matching predicate alongsideimplementation_for's "how would I build this from scratch" decision. It should:Implementation::is_satisfied_by(&self, available: &Implementation) -> boolanswers "does an already-availableImplementationsatisfy a required one" — the query-optimization "materialized view matching" / "answering queries using views" question, narrowed to this crate's ownSummaryKindvocabulary.PassThroughrequired is vacuously satisfied — nothing to match.ExactAccumulatorrequires the exact sameSummaryKind— accumulators carry no family/subsumption concept.SummaryKinddoesn't encode grouping at all (that lives on the L4 node'sby), so single-vs-multi-population re-aggregation (e.g. "aMultipleSumpolicy can serve aSumquery") stays entirely a downstream deployment's own concern, not something this crate models.Sketchis satisfied by the sameSummaryFamily(Quantile: Kll/DDSketch; Cardinality: Hll/Theta/Kmv; Frequency: Cms/CountSketch), with one asymmetric case: a heap-bearing top-k sketch (CmsWithHeap/CountSketchWithHeap) also satisfies a bare frequency requirement (the heap is additional info layered on the same underlying matrix) — never the reverse (a heap-less sketch never tracked the heap, can't enumerate top-k items).What this deliberately does not do: track an inventory of what's actually been materialized anywhere — that stays entirely a downstream deployment's job (e.g.
control_plane's ownsketch_algebra::capability::Capability/is_satisfied_by, which layers deployment-specific index-matching semantics on top of this crate's plain family-compatibility answer).Test plan
cargo build --workspace --all-targets— cleancargo test -p asap-plan— 34 passed (10 newis_satisfied_bytests covering same-kind, same-family-alternate-kind, cross-family rejection, heap-bearing-satisfies-bare-frequency (and not the reverse), exact-accumulator-exact-match, sketch-vs-accumulator never cross-satisfy, and bothPassThroughdirections)cargo clippy -p asap-plan --all-targets— cleancargo fmtapplied🤖 Generated with Claude Code