Skip to content

feat(plan): add Implementation::is_satisfied_by (materialized-view-style matching) - #140

Merged
zzylol merged 2 commits into
mainfrom
feat/implementation-is-satisfied-by
Jul 20, 2026
Merged

zzylol merged 2 commits into
mainfrom
feat/implementation-is-satisfied-by

Conversation

@zzylol

@zzylol zzylol commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

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" / "answering queries using views" question, narrowed to this crate's own SummaryKind vocabulary.
  • 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 at all (that lives on the L4 node's by), so single-vs-multi-population re-aggregation (e.g. "a MultipleSum policy can serve a Sum query") stays entirely a downstream deployment's own concern, not something this crate models.
  • Sketch is satisfied by the same SummaryFamily (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 own sketch_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 — clean
  • cargo test -p asap-plan — 34 passed (10 new is_satisfied_by tests 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 both PassThrough directions)
  • cargo clippy -p asap-plan --all-targets — clean
  • cargo fmt applied

🤖 Generated with Claude Code

zzylol and others added 2 commits July 20, 2026 06:44
…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
zzylol merged commit 2c1b264 into main Jul 20, 2026
1 check passed
@zzylol
zzylol deleted the feat/implementation-is-satisfied-by branch July 20, 2026 13:54
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>
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