From d3b7a83544ca80599e1a02093f2f07898b69932f Mon Sep 17 00:00:00 2001 From: zz_y Date: Sat, 18 Jul 2026 11:05:17 -0600 Subject: [PATCH] feat(control_plane): Phase 2 step 2 -- add expr_ir.rs (unused until next step) New file, re-exported from asap_ir::intent_algebra::expr_ir. Per the D2 decision in ASAPController's intent-algebra-reconciliation.md: one generic Expr scalar IR shared across L2 (Expr) and L3 (Expr), replacing control_plane's separate ad hoc Predicate (query_expr.rs) and ScalarExpr (relational.rs) types. Deliberately not re-exported into the crate::intent_algebra::* top-level surface yet -- query_expr::ColumnRef already claims that name, and nothing constructs Expr until the query_expr.rs/relational.rs merge (next step) retargets Predicate/ScalarExpr onto L3Expr/L2Expr. This step only makes the type available; verified inert (cargo build clean, full test suite unchanged, 820 passed). --- control_plane/src/intent_algebra/expr_ir.rs | 36 +++++++++++++++++++++ control_plane/src/intent_algebra/mod.rs | 6 ++++ 2 files changed, 42 insertions(+) create mode 100644 control_plane/src/intent_algebra/expr_ir.rs diff --git a/control_plane/src/intent_algebra/expr_ir.rs b/control_plane/src/intent_algebra/expr_ir.rs new file mode 100644 index 00000000..41736d68 --- /dev/null +++ b/control_plane/src/intent_algebra/expr_ir.rs @@ -0,0 +1,36 @@ +//! Language-independent scalar expression IR. +//! +//! ## Phase 2 step 2 (docs/migration-plan-backend-plan.md) +//! +//! New file, re-exported from ASAPController's `asap-ir` crate. This is +//! the D2 decision from `ASAPController/docs/intent-algebra-reconciliation.md` +//! (already validated by ASAPController's own evolution — control_plane +//! had no equivalent generic-over-column-type scalar IR before this): +//! `Predicate` and `HavingPredicate` in `query_expr.rs` are currently ad +//! hoc, control_plane-only types; `relational.rs`'s `ScalarExpr` is a +//! separate, L2-only scalar type. Once `query_expr.rs`/`relational.rs` +//! are merged (next Phase 2 step), both collapse onto this one +//! `Expr` — `L2Expr = Expr` for the front-end-emitted L2 +//! tree, `L3Expr = Expr` for the canonical positional L3 tree. +//! Nothing in this repo constructs `Expr` yet — that lands with the +//! `query_expr.rs`/`relational.rs` merge, not here. This step only makes +//! the type available. +//! +//! One generic [`Expr`] spans the lowering boundary; the two layers are +//! aliases that differ only in the column-reference type `C`: +//! +//! - [`L2Expr`] = `Expr` — name-based. The per-language front ends +//! emit it (PromQL label matchers, SQL `WHERE` / projection / sort-key +//! expressions) on the Layer-2 `relational` tree. +//! - [`L3Expr`] = `Expr` — **positional**. The canonical L3 +//! `query_expr` tree carries it; the converter resolves every `ColumnRef` +//! against the in-scope schema to produce it, so L3 column identity is +//! unambiguous (no name collisions across a join). +//! +//! `Expr` shares the scalar/operator vocabulary +//! ([`L3Scalar`], [`CompareOp`], [`ArithOp`]) — the **union** of what the two +//! front ends need: PromQL contributes `Regex` / `NotRegex` (`=~` / `!~`); SQL +//! contributes arithmetic, `CASE`, `IN`, `CAST`, `IS [NOT] NULL`, scalar +//! function calls, and the `LIKE` / `ILIKE` comparison family. + +pub use asap_ir::intent_algebra::{ArithOp, ColumnRef, CompareOp, Expr, L2Expr, L3Expr, L3Scalar}; diff --git a/control_plane/src/intent_algebra/mod.rs b/control_plane/src/intent_algebra/mod.rs index 533c2df5..c3c675a9 100644 --- a/control_plane/src/intent_algebra/mod.rs +++ b/control_plane/src/intent_algebra/mod.rs @@ -73,6 +73,12 @@ pub mod agg_intent; pub mod cse; +// Not yet re-exported into the crate::intent_algebra::* top-level surface +// below -- `query_expr::ColumnRef` already claims that name, and this +// module is unused until the query_expr.rs/relational.rs merge (next +// Phase 2 step) retargets `Predicate`/`ScalarExpr` onto `L3Expr`/`L2Expr`. +// Reachable today only via the full `intent_algebra::expr_ir::` path. +pub mod expr_ir; pub mod query_expr; pub mod schema;