Skip to content

docs(sketch): L4 — planning-time vs. serving-time design writeup - #156

Merged
zzylol merged 6 commits into
feat/summary-executor-interfacefrom
docs/l4node-execution-model
Jul 22, 2026
Merged

zzylol merged 6 commits into
feat/summary-executor-interfacefrom
docs/l4node-execution-model

Conversation

@zzylol

@zzylol zzylol commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Stacked on #155. Design writeup for the split #155 adds:

Covers the SummaryExecutor trait's split of responsibility, the nested-composition rules (what can be a SummaryMerge child, merge-of-merges transitivity, the deliberately-open SummaryAgg-over-SummaryEstimate question), what's out of scope (L5 placement, SummaryJoin/SummarySubtract/SummaryDelete), and the planned data_plane consumer.

Test plan

N/A — docs only, no code changes (module doc comments already changed in #155).

🤖 Generated with Claude Code

zzylol and others added 4 commits July 22, 2026 11:53
Explains the split ASAPController#155 (SummaryExecutor/execute) adds:
planning-time L4 (asap_plan::bind, QueryExpr -> L4Node, a decision made
symbolically once per query shape) vs. serving-time L4 (this module,
L4Node -> Value, a lookup done on every query against whatever's
actually materialized). Covers the trait split of responsibility, the
nested-composition rules, what's out of scope, and the planned
data_plane consumer.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…uplicating it

The trait signature, nested-composition rules, and out-of-scope notes
were already verbatim in crates/sketch/src/exec.rs's module doc comments
-- this doc now just frames planning-time vs. serving-time L4 and points
there instead of keeping a second copy in sync.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ecution-model.md

design.md's "asap-sketch -- Layer 4 IR" section carried the SketchExpr
struct definition (the pre-shipped placeholder name), the per-node
schema table, and the two type-system invariants -- all planning-time
L4 content that belongs with the rest of the L4 story now that
l4node-execution-model.md exists. Moves it there, rewritten against the
actual shipped names (SummaryExpr/L4Node/L4Schema/L4DataType, real
crates/sketch/src/expr.rs field shapes) instead of the old SketchExpr/
SketchKind/GroupKey placeholders and their translation footnote.
design.md keeps a short pointer plus the two Source/data-model notes
that aren't really about the IR shape itself.

Doesn't chase every other SketchExpr mention elsewhere in design.md
(the layer table, the glossary, the worked example) -- scoped to the
one section that duplicated the actual struct definitions; broader
terminology consistency is a separate cleanup.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zzylol
zzylol force-pushed the docs/l4node-execution-model branch from c840518 to 48780ab Compare July 22, 2026 17:55
zzylol and others added 2 commits July 22, 2026 12:19
SummaryMerge/SummaryJoin/SummarySubtract/SummaryDelete are real types
exec.rs (mostly) knows how to run, but nothing produces them yet --
worth being explicit about which half of "defined" vs "actually
happens" each is in, rather than leaving it implicit across the doc.
Same for SummaryKind: all 14 variants are wired into
boundary::implementation_for, split into DefaultCostModel's pick vs.
what only a custom CostModel reaches.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zzylol

zzylol commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@milindsrivastava1997 I will merge this, and solve the doc restructure issue in #157 for all 5 layers.

@zzylol
zzylol merged commit 42b82eb into feat/summary-executor-interface Jul 22, 2026
@zzylol
zzylol deleted the docs/l4node-execution-model branch July 22, 2026 21:14
zzylol added a commit that referenced this pull request Jul 22, 2026
Same move as l4node-execution-model.md (#155/#156) for L4: each layer
gets its own doc instead of living as a subsection of the 1500+ line
design.md, which design.md now links to instead of duplicating.

- l1-query-language.md, l2-logical-plan.md: short, these layers barely
  have design content beyond "here's the parser."
- l3-intent-algebra.md: the real content -- QueryExpr/AggIntent design
  rules, schema flow, the three-metadata-sources table. Rewritten
  against a pointer to the real source files instead of reproducing
  the full struct definitions inline, since the old inline copy here
  had already drifted stale (stale AggIntent::TopK/Rate/Increase field
  shapes, same kind of drift l4node-execution-model.md's L4 section
  had before this round of cleanup) -- points at
  crates/ir/src/intent_algebra/*.rs as the source of truth instead of
  re-copying it, so it can't drift the same way again.
- l5-physical-plan.md: moved close to verbatim -- already correctly
  labeled "planned, not yet built" from an earlier reconciliation
  pass, no staleness to fix, just relocated.

design.md keeps a two-line pointer per layer. Section 6's intro no
longer claims "(layers 1-3 + driver)" now that the layer IRs
themselves live elsewhere -- points to all five layer docs instead.
Doesn't chase every remaining cross-reference to the old section
numbers/content scattered elsewhere in design.md (glossary, worked
examples, open-questions) -- those still resolve (the §6 subsection
headers stay, now as pointers), just not rewritten in place.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Jul 22, 2026
…de (#155)

* feat(sketch): SummaryExecutor -- serving-time execution model for L4Node

asap-sketch defines the L4 tree shape and asap-plan defines how to build
one from L3, but nothing said what it means to *run* one against
already-materialized state at query time -- every deployment answering
queries would otherwise reinvent the same recursive walk and merge
preconditions independently.

Adds SummaryExecutor (the trait a deployment implements to plug in its
own storage/lookup/sketch-math/readout) and execute() (the generic
recursive walk over L4Node that calls into it). asap-sketch owns the
structural rules -- which nestings are valid, that a SummaryMerge's
children must agree on (SummaryKind, SummaryParams), propagated through
arbitrary nesting depth via ExecOutcome::State rather than re-derived
per node. The deployment owns everything requiring actual sketch math
(this crate has none) or actual storage.

9 tests cover single-leaf readout, multi-candidate merge, nested
SummaryAgg (quantile-of-sum shape), merge-of-merges, and the three
structural error cases (empty merge, a Value-producing merge child,
mismatched kind/params across merge children).

Design writeup in a stacked follow-up PR (docs/l4node-execution-model.md);
this module's own doc comments are the authoritative detail.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(sketch): trim exec.rs's comments -- covered by l4node-execution-model.md

The design rationale (planning vs. serving L4, nested-composition rules,
why each error variant exists) now lives in the stacked doc PR, not
duplicated in-line. Keeps short, standard API docs; points to
docs/l4node-execution-model.md for the reasoning instead of restating it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(sketch): L4 — planning-time vs. serving-time design writeup (#156)

* docs(sketch): L4 -- planning-time vs. serving-time design writeup

Explains the split ASAPController#155 (SummaryExecutor/execute) adds:
planning-time L4 (asap_plan::bind, QueryExpr -> L4Node, a decision made
symbolically once per query shape) vs. serving-time L4 (this module,
L4Node -> Value, a lookup done on every query against whatever's
actually materialized). Covers the trait split of responsibility, the
nested-composition rules, what's out of scope, and the planned
data_plane consumer.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(sketch): point l4node-execution-model.md at exec.rs instead of duplicating it

The trait signature, nested-composition rules, and out-of-scope notes
were already verbatim in crates/sketch/src/exec.rs's module doc comments
-- this doc now just frames planning-time vs. serving-time L4 and points
there instead of keeping a second copy in sync.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Revert "docs(sketch): point l4node-execution-model.md at exec.rs instead of duplicating it"

This reverts commit d434e20.

* docs: move the L4 IR struct definitions from design.md into l4node-execution-model.md

design.md's "asap-sketch -- Layer 4 IR" section carried the SketchExpr
struct definition (the pre-shipped placeholder name), the per-node
schema table, and the two type-system invariants -- all planning-time
L4 content that belongs with the rest of the L4 story now that
l4node-execution-model.md exists. Moves it there, rewritten against the
actual shipped names (SummaryExpr/L4Node/L4Schema/L4DataType, real
crates/sketch/src/expr.rs field shapes) instead of the old SketchExpr/
SketchKind/GroupKey placeholders and their translation footnote.
design.md keeps a short pointer plus the two Source/data-model notes
that aren't really about the IR shape itself.

Doesn't chase every other SketchExpr mention elsewhere in design.md
(the layer table, the glossary, the worked example) -- scoped to the
one section that duplicated the actual struct definitions; broader
terminology consistency is a separate cleanup.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(sketch): list currently-supported L4 operators and SummaryKinds

SummaryMerge/SummaryJoin/SummarySubtract/SummaryDelete are real types
exec.rs (mostly) knows how to run, but nothing produces them yet --
worth being explicit about which half of "defined" vs "actually
happens" each is in, rather than leaving it implicit across the doc.
Same for SummaryKind: all 14 variants are wired into
boundary::implementation_for, split into DefaultCostModel's pick vs.
what only a custom CostModel reaches.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(sketch): rename section to "Supported operators"

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Jul 22, 2026
Same move as l4node-execution-model.md (#155/#156) for L4: each layer
gets its own doc instead of living as a subsection of the 1500+ line
design.md, which design.md now links to instead of duplicating.

- l1-query-language.md, l2-logical-plan.md: short, these layers barely
  have design content beyond "here's the parser."
- l3-intent-algebra.md: the real content -- QueryExpr/AggIntent design
  rules, schema flow, the three-metadata-sources table. Rewritten
  against a pointer to the real source files instead of reproducing
  the full struct definitions inline, since the old inline copy here
  had already drifted stale (stale AggIntent::TopK/Rate/Increase field
  shapes, same kind of drift l4node-execution-model.md's L4 section
  had before this round of cleanup) -- points at
  crates/ir/src/intent_algebra/*.rs as the source of truth instead of
  re-copying it, so it can't drift the same way again.
- l5-physical-plan.md: moved close to verbatim -- already correctly
  labeled "planned, not yet built" from an earlier reconciliation
  pass, no staleness to fix, just relocated.

design.md keeps a two-line pointer per layer. Section 6's intro no
longer claims "(layers 1-3 + driver)" now that the layer IRs
themselves live elsewhere -- points to all five layer docs instead.
Doesn't chase every remaining cross-reference to the old section
numbers/content scattered elsewhere in design.md (glossary, worked
examples, open-questions) -- those still resolve (the §6 subsection
headers stay, now as pointers), just not rewritten in place.

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.

2 participants