Skip to content

feat(asap-aware-mapping): wire AvgToSumOverCountStrategy into default_strategies - #282

Merged
zzylol merged 2 commits into
mainfrom
feat/wire-avg-to-sum-default-strategy
Aug 26, 2026
Merged

zzylol merged 2 commits into
mainfrom
feat/wire-avg-to-sum-default-strategy

Conversation

@zzylol

@zzylol zzylol commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What

AvgToSumOverCountStrategy (issue #253) has existed as a full ReplacementStrategy implementation since rewrite.rs was added, but was never included in default_strategies()/default_strategies_with() — so search_workload (and everything built on it: explain_replacements, dag_export, sketch_coverage) never actually ran it.

Why

A bare avg node has no summary realization of its own (Implementation::PassThrough) and can't be a SharedSubtreeStrategy target either (no mergeable accumulator to share). Without this rewrite running first, avg aggregates were invisible to every sketch/CSE strategy downstream — rewriting avg(x) into sum(x)/count(*) is exactly what lets those strategies see something to work with.

It's context-free (matches/replacements need nothing beyond the target itself, same as SharedSubtreeStrategy) rather than workload-dependent like RollupStrategy (which is already auto-added per-workload inside search_workload_with), so it belongs in the static default_strategies() list.

Also corrected a stale doc-comment table row in explanation.rs that predated this change and already contradicted the code (it claimed no ReplacementStrategy implementation existed for this at all).

Verification

  • cargo test -p asap-aware-mapping — 142 tests, all pass unchanged
  • cargo test -p asap-devtools — all pass unchanged
  • cargo check --workspace — clean
  • cargo fmt --all -- --check / cargo clippy --workspace --all-targets --all-features --locked -- -D warnings — clean
  • Manually confirmed dag_export on an AVG query produces no new stderr warnings (no explanation ends up unmatched against the originally-exported graph)

🤖 Generated with Claude Code

zzylol and others added 2 commits August 25, 2026 19:46
…_strategies

AvgToSumOverCountStrategy (issue #253) has existed as a full
ReplacementStrategy impl since rewrite.rs was added, but was never
included in default_strategies()/default_strategies_with() — so
search_workload (and everything built on it: explain_replacements,
dag_export, sketch_coverage) never actually ran it. A bare avg node
has no summary realization of its own (PassThrough) and can't be a
SharedSubtreeStrategy target either, so without this rewrite running
first, avg aggregates were invisible to every sketch/CSE strategy
downstream.

It's context-free (matches()/replacements() need nothing beyond the
target itself, same as SharedSubtreeStrategy) rather than
workload-dependent like RollupStrategy, so it belongs in the static
default_strategies() list rather than being derived per-workload.

Verified: full asap-aware-mapping (142 tests) and asap-devtools test
suites pass unchanged; cargo check --workspace is clean; manually
confirmed dag_export on an AVG query produces no new stderr warnings
(no explanation ends up unmatched against the original exported
graph). Also corrected a stale doc-comment table row in
explanation.rs that predated this change and already contradicted
the code (claimed no ReplacementStrategy impl existed at all).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zzylol
zzylol merged commit 079410d into main Aug 26, 2026
3 checks passed
@zzylol
zzylol deleted the feat/wire-avg-to-sum-default-strategy branch August 26, 2026 02:11
zzylol added a commit that referenced this pull request Aug 26, 2026
default_strategies() already includes it as of #282 — this binary no
longer needs its own custom strategy list, just plain
search_workload(). Also reworded the 'unmatched winner' diagnostic:
with AvgToSumOverCountStrategy now running by default, its rewrite
output routinely exposes new sum/count descendants that the same
search pass independently sketch-ranks — real winners, but ones with
no node in any query's original pre-rewrite graph to attach a flat
replacements[] entry to (expected, not a bug: still fully represented
in that query's post_graph). The old wording read like an error for
what is normally an expected case.

Verified: cargo test --workspace, fmt, and clippy all clean; manually
re-ran --post-asap on an AVG query and confirmed the JSON output is
identical (only the diagnostic wording changed).
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