Skip to content

refactor: narrow asap-types test-only fields and frontend visibility (#1054 step 8b, part 2) - #1099

Merged
zzylol merged 1 commit into
refactor/stage-boundariesfrom
refactor/1054-8b-visibility-part2
Oct 30, 2026
Merged

zzylol merged 1 commit into
refactor/stage-boundariesfrom
refactor/1054-8b-visibility-part2

Conversation

@zzylol

@zzylol zzylol commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Part of #1054 (step 8b, part 2). Merges into the integration branch refactor/stage-boundaries. Tests run for the whole branch before it merges to main.

Why

#1054's rule: an item is pub only if another crate's non-test code uses it. #1094 applied it to physical, cost, accuracy and part of asap-types. This PR applies it to the rest of asap-types, the four frontend crates and asap-planner.

What

Visibility, accessors, test-only paths and two deletions. There are no behavior changes.

Item Change Users
SummaryCoverage.{definition, selection}, SelectionBox, ColumnIdentity, MaterializedView.{refresh, coverage, retention_ms}, ViewCoverage, MaterializedViewInputs.raw_data_windows, RawDataWindow, RawDataRetention, PhysicalASAPDAGEdge fields, FamilyCapability.readouts fields pub(crate); added new and accessors only tests outside the crate. JSON is unchanged, so the DAG viewer reads the same keys
output_schema, validate_inputs, matches_node, NodeToTimedNodeCache::timed, RawDataWindow::lookback_ms, Materialization::is_materialized_view pub(crate); tests call them through wrappers in asap_types::test_support the crate itself, plus tests
NonASAPOp/ASAPOp children, map_children, kind_name pub(crate) tests use the Operator / OperatorNode versions
Schema::has_unique_key, compile_physical_asap_dag behind test-support tests only
frontend-common resolver items (SchemaResolver, SchemaCatalog, UsageDerivedCatalog, resolve_expr, UnresolvedScalar helpers) pub(crate), no root re-export only used inside the crate
frontend modules error, histogram, promql, sql, frequency, resolve, schema_resolver, unresolved private one public path per item
SqlLowerer; metricsql parse_metricsql, canonical_metricsql, lower_metricsql* pub(crate); reached through each crate's test_support tests only
asap-planner unchanged everything still pub is entry API that the backend uses

Deleted: HistogramCatalog::is_empty and UnresolvedOp::scalar_exprs; neither has users.

Deferred (only logical or plan-selection src/ tests read these; they are handled in P7 or #1095):

  • DemandEstimate.{observed_at, valid_for}
  • SupplierStorageMetrics.logical_connections
  • MaintainedPopulation.{max_k, quantiles}
  • CurrentSeriesInput.{metric, matchers}
  • LabelSetDistinctValues fields
  • Schema::lifted
  • PhysicalMemoCandidates::implementation_roots

How

  1. Every pub field and method in the target crates was set to pub(crate).
  2. Production code was rebuilt, excluding integration-tests, and pub was restored on each item whose removal broke the build. In asap-types, 47 items survived.
  3. Tests switched to accessors, ::new constructors and test_support:: paths.
  4. Feature changes:
    • frontend-sql and frontend-metricsql gain test-support;
    • executor's test-support enables asap-types/test-support;
    • integration-tests enables asap-types/test-support.

Key code interfaces added / modified

The new test-only modules asap_frontend_sql::test_support and asap_frontend_metricsql::test_support, plus more wrappers in asap_types::test_support.

Usage: a test that needs lower_metricsql enables asap-frontend-metricsql/test-support in its dev-dependencies and calls asap_frontend_metricsql::test_support::lower_metricsql(..).

The private corpus's shared frontend-promql/tests/support.rs still compiles with only asap-types/test-support.

Major algorithm changes

None.

Before / After

  • Before: about 390 public fields and methods in asap-types, many of them used only by tests.
  • After: 47 of them are public in asap-types, because another crate's production code uses them.

Verification

At 87d769181 (on refactor/stage-boundaries after #1098):

  • fmt and cargo clippy --workspace --all-targets -D warnings are clean.
  • cargo build -p asap-devtools --bins and cargo check --workspace --exclude asap-integration-tests --lib --bins build with no test-support feature.
  • cargo doc: no new warnings.
  • Tests are not run yet. They run for the integration branch as a whole.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K1M6bqhAk7WA4MZcfbAoMw

…step 8b, part 2)

asap-types: fields and methods that only tests read outside the crate
become pub(crate). Tests reach them through accessors and constructors
under `test-support` (SummaryCoverage, SelectionBox, ColumnIdentity,
MaterializedView, ViewCoverage, MaterializedViewInputs, RawDataWindow,
RawDataRetention, PhysicalASAPDAGEdge, FamilyCapability) or through
`asap_types::test_support` wrappers for methods the crate itself uses
(output_schema, validate_inputs, matches_node, timed, lookback_ms,
is_materialized_view). `Schema::has_unique_key` and
`compile_physical_asap_dag` are test-only and go under `test-support`.

Frontends: the `error`, `histogram`, `promql`, `sql`, `frequency`,
`resolve`, `schema_resolver` and `unresolved` modules become private
(one public path per item). `SqlLowerer`, `SchemaResolver`,
`SchemaCatalog`, `UsageDerivedCatalog` and `resolve_expr` become
pub(crate). Single-query MetricsQL entry points and the SQL unresolved
lowering move to new `test_support` modules behind `test-support`.
Deleted: `HistogramCatalog::is_empty`, `UnresolvedOp::scalar_exprs`.

The executor's and integration-tests' fixture code enable
`asap-types/test-support` for the test-only DAG helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bqhAk7WA4MZcfbAoMw
@zzylol
zzylol merged commit de088dc into refactor/stage-boundaries Oct 30, 2026
zzylol added a commit that referenced this pull request Oct 30, 2026
…cal, executor) (#1109)

* test(executor): set the semijoin edges' timing through data_state_mut

#1099 rewrote `edge.data_state.timing = phase` as `edge.data_state().timing = phase`,
which assigns to a copy: the edges kept QueryTime while the nodes moved to
IngestionTime, and bind rejected the DAG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bqhAk7WA4MZcfbAoMw

* test(logical): update Pass 1 expectations for memo-group targets (P3c)

#1106 (P3c) walks memo groups: structurally equal aggregates and HAVING
filters are one group, with one target per (group, measure) and HAVING
placed per group; roots are named by workload index, and an inventory
matches any DAG built from structurally equal roots.

- having_on_one_consumer_of_a_shared_aggregate_stays_above: two equal
  HAVING filters are one group, so one entry.
- memo_cached_rules_preserve_occurrence_specific_having: the two equal
  aggregates are one target; its HAVING stays above the output because
  an unfiltered consumer reads the group.
- assigned_physical_annotation_asap_input_and_invalid_accuracy_are_rejected:
  InvalidAccuracy names the root by workload index ("0"); doc comment updated.
- population_rejects_an_inventory_from_other_roots: the other roots now
  differ structurally (the same query text is the same DAG).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bqhAk7WA4MZcfbAoMw

* test(frontend-promql): move planner-facade helpers out of support.rs

support.rs is also compiled by the private corpus, which does not depend
on asap-planner. run_stage1_to_stage3 and selected_dag (asap-planner since
#1107) move to planner_support.rs, used only by this crate's test binary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bqhAk7WA4MZcfbAoMw

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Oct 30, 2026
…ay public API (#1114)

tools/verify_metricsql_external_consumer.sh (CI) treats them as a stable
external dependency; #1099 had moved them behind test-support.


Claude-Session: https://claude.ai/code/session_01K1M6bqhAk7WA4MZcfbAoMw

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol
zzylol deleted the refactor/1054-8b-visibility-part2 branch November 3, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant