feat(v3): float4/float8 encrypted-domain types#299
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/codegen/reference/float4/float4_ord_ore_operators.sql (1)
118-146: Add COMMUTATOR declarations to containment operators.The
@>and<@operators are logical commutators—they express reciprocal containment relationships—but these operator overloads omit theCOMMUTATORmetadata. This prevents the planner from inferring symmetry optimizations.Suggested fix
CREATE OPERATOR @> ( FUNCTION = eql_v3.contains, - LEFTARG = eql_v3.float4_ord_ore, RIGHTARG = eql_v3.float4_ord_ore + LEFTARG = eql_v3.float4_ord_ore, RIGHTARG = eql_v3.float4_ord_ore, + COMMUTATOR = <@ ); CREATE OPERATOR <@ ( FUNCTION = eql_v3.contained_by, - LEFTARG = eql_v3.float4_ord_ore, RIGHTARG = eql_v3.float4_ord_ore + LEFTARG = eql_v3.float4_ord_ore, RIGHTARG = eql_v3.float4_ord_ore, + COMMUTATOR = @> );Note: This issue exists across all float operator baselines (float4/float8, all variants). Apply the same fix pattern consistently.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/codegen/reference/float4/float4_ord_ore_operators.sql` around lines 118 - 146, The CREATE OPERATOR statements for @> and <@ operators are missing COMMUTATOR declarations that define their reciprocal relationships. Add COMMUTATOR metadata to each operator: for the @> operator with LEFTARG = eql_v3.float4_ord_ore and RIGHTARG = eql_v3.float4_ord_ore, add COMMUTATOR = <@, and for the corresponding <@ operator add COMMUTATOR = @>. For the mixed-type overloads (eql_v3.float4_ord_ore with jsonb), the @> operator with LEFTARG = eql_v3.float4_ord_ore and RIGHTARG = jsonb should reference the <@ operator with swapped argument types, and vice versa using the appropriate operator syntax to specify argument type order. Apply this pattern consistently across all three pairs of operator definitions in the diff.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/sqlx/src/scalar_domains.rs`:
- Around line 802-815: The F4 struct (and F8 at lines 833-846) derives standard
IEEE PartialEq while implementing Ord using total_cmp, which violates Rust trait
invariants. Remove PartialEq from the derive macro for both F4 and F8 structs,
then implement a custom PartialEq for each that is consistent with their Ord
implementations by using total_cmp for equality comparisons instead of the
default IEEE semantics.
---
Nitpick comments:
In `@tests/codegen/reference/float4/float4_ord_ore_operators.sql`:
- Around line 118-146: The CREATE OPERATOR statements for @> and <@ operators
are missing COMMUTATOR declarations that define their reciprocal relationships.
Add COMMUTATOR metadata to each operator: for the @> operator with LEFTARG =
eql_v3.float4_ord_ore and RIGHTARG = eql_v3.float4_ord_ore, add COMMUTATOR = <@,
and for the corresponding <@ operator add COMMUTATOR = @>. For the mixed-type
overloads (eql_v3.float4_ord_ore with jsonb), the @> operator with LEFTARG =
eql_v3.float4_ord_ore and RIGHTARG = jsonb should reference the <@ operator with
swapped argument types, and vice versa using the appropriate operator syntax to
specify argument type order. Apply this pattern consistently across all three
pairs of operator definitions in the diff.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 890727e5-db03-4ac5-bd71-2e15200e77c0
📒 Files selected for processing (61)
CHANGELOG.mdcrates/eql-scalars/src/fixture.rscrates/eql-scalars/src/kind.rscrates/eql-scalars/src/lib.rscrates/eql-scalars/src/proptest_invariants.rscrates/eql-scalars/src/tests.rscrates/eql-tests-macros/src/lib.rscrates/eql-types/bindings/v3/Float4.tscrates/eql-types/bindings/v3/Float4Eq.tscrates/eql-types/bindings/v3/Float4Ord.tscrates/eql-types/bindings/v3/Float4OrdOre.tscrates/eql-types/bindings/v3/Float8.tscrates/eql-types/bindings/v3/Float8Eq.tscrates/eql-types/bindings/v3/Float8Ord.tscrates/eql-types/bindings/v3/Float8OrdOre.tscrates/eql-types/schema/v3/float4.jsoncrates/eql-types/schema/v3/float4_eq.jsoncrates/eql-types/schema/v3/float4_ord.jsoncrates/eql-types/schema/v3/float4_ord_ore.jsoncrates/eql-types/schema/v3/float8.jsoncrates/eql-types/schema/v3/float8_eq.jsoncrates/eql-types/schema/v3/float8_ord.jsoncrates/eql-types/schema/v3/float8_ord_ore.jsoncrates/eql-types/src/v3/float4.rscrates/eql-types/src/v3/float8.rscrates/eql-types/src/v3/mod.rsdocs/plans/2026-06-19-float-encrypted-domain-plan.mddocs/upgrading/v2.4.mdtests/codegen/reference/float4/float4_eq_functions.sqltests/codegen/reference/float4/float4_eq_operators.sqltests/codegen/reference/float4/float4_functions.sqltests/codegen/reference/float4/float4_operators.sqltests/codegen/reference/float4/float4_ord_aggregates.sqltests/codegen/reference/float4/float4_ord_functions.sqltests/codegen/reference/float4/float4_ord_operators.sqltests/codegen/reference/float4/float4_ord_ore_aggregates.sqltests/codegen/reference/float4/float4_ord_ore_functions.sqltests/codegen/reference/float4/float4_ord_ore_operators.sqltests/codegen/reference/float4/float4_types.sqltests/codegen/reference/float8/float8_eq_functions.sqltests/codegen/reference/float8/float8_eq_operators.sqltests/codegen/reference/float8/float8_functions.sqltests/codegen/reference/float8/float8_operators.sqltests/codegen/reference/float8/float8_ord_aggregates.sqltests/codegen/reference/float8/float8_ord_functions.sqltests/codegen/reference/float8/float8_ord_operators.sqltests/codegen/reference/float8/float8_ord_ore_aggregates.sqltests/codegen/reference/float8/float8_ord_ore_functions.sqltests/codegen/reference/float8/float8_ord_ore_operators.sqltests/codegen/reference/float8/float8_types.sqltests/sqlx/snapshots/matrix_tests_storage_only.txttests/sqlx/src/fixtures/eql_plaintext.rstests/sqlx/src/fixtures/scalar_fixture.rstests/sqlx/src/lib.rstests/sqlx/src/scalar_domains.rstests/sqlx/src/scalar_types.rstests/sqlx/tests/encrypted_domain.rstests/sqlx/tests/encrypted_domain/float_special.rstests/sqlx/tests/encrypted_domain/property/e2e_oracle.rstests/sqlx/tests/encrypted_domain/property/fixture_oracle.rstests/sqlx/tests/encrypted_domain/signed.rs
float4/float8 ScalarSpec rows (Float kind/fixture) in eql-scalars::CATALOG and the committed codegen reference baselines the generator parity gate checks against.
float4/float8 v3 domain payload types in eql-types, with the generated TypeScript bindings and JSON Schemas for each domain variant.
Fixture routing in the matrix proc-macro plus the float4/float8 arms of the fixture/e2e oracle suites, the sign-boundary monotonicity sweep, the float_special NaN/+/-0/+/-Inf regression suite, and the storage-only matrix snapshot.
CHANGELOG Added entry for the float4/float8 families, with the IEEE-754 caveats (NaN ordering, +/-0 equality, f64 widening) folded inline. No docs/upgrading/ note: this is additive eql_v3, not an eql_v2 release.
c20b8a4 to
f299ecd
Compare
…N caveat, order tripwire - eql-scalars: correct the FLOAT4_FIXTURES comment — the values are dyadic rationals (n/2^k), not 'powers of two and halves'; add a keep-it-dyadic warning so a non-f32-exact fixture (e.g. 0.1) can't silently desync the oracle. - eql-types: document NaN/-0.0/+-Inf special-value behaviour on the float8 module (and point float4 at it) — NaN is never rejected server-side, so the caller-facing 'reject NaN client-side' guidance lives next to the types. - float_special: add nan_order_position_is_deterministic_and_total, a tripwire locking the total+deterministic order the Block-ORE index relies on (without pinning NaN's unspecified direction). - Drop the dangling reference to the removed U-001 upgrade note.
Derived IEEE PartialEq (NaN != NaN, +0.0 == -0.0) was inconsistent with the manual Eq/Ord impls built on total_cmp (NaN == NaN, +0.0 != -0.0), breaking Eq's reflexivity contract and Ord/PartialEq equality agreement.
feat(v3): float4/float8 encrypted-domain types
Summary
Adds IEEE-754 binary-float encrypted-domain coverage (
real/float4anddouble precision/float8) to theeql_v3scalar surface, fully wired through codegen, the SQLx matrix oracle, and an edge-case regression suite. Implements the committed plan (docs/plans/2026-06-19-float-encrypted-domain-plan.md).Both widths are ordered scalars reusing the existing four-domain shape, and both encrypt through a single f64 crypto path (
Plaintext::Float(Some(x as f64))) —float4vsfloat8is purely a Postgres-surface distinction; the ciphertext/ORE term are byte-identical. Float is a newScalarKind(F32/F64); the kind-agnostic codegen renderers generate the SQL with no codegen change (the flagged primary risk — confirmed a false alarm).What's in here (one commit per task)
ScalarKind::F32/F64,Fixture::Float,FLOAT4/FLOAT8specs + invariant tests.F4(f32)/F8(f64)newtypes (Ordviatotal_cmp,#[sqlx(transparent)]), value accessors via the sharedlazy_values!macro, hand-writtenScalarType/OrderedScalar/SignedScalar, guards (incl. an f32→f64 widening-monotonicity guard).EqlPlaintextforF4/F8→Plaintext::Float;Cast::REAL/DOUBLE,PlaintextSqlType::REAL/DOUBLE_PRECISION.is_float_token+floatfixture discriminator,scalar_fixture!float arm, matrix dispatch lines.F4(x)andF8(x as f64)sharehm/ob), and afloat_specialsuite (NaN / ±0 / ±Inf) that encrypts fresh so NaN never enters the shared fixture table.tests/codegen/reference/{float4,float8}/baselines, CHANGELOG entry,docs/upgrading/v2.4.md(U-001).Verified locally (no DB required)
cargo test -p eql-scalars(71),cargo test -p eql-tests-macros(22, incl. 2 float tests)cargo test -p eql_tests --libfloat guards +EqlPlaintextfloat tests (11) + fixture-module spec testsmise run test:matrix:inventory— float4 → ordered, float8 → ordered, catalog reconciledmise run codegen:parity,mise run test:codegen(71),mise run clean && mise run build,mise run test:self_contained_v3encrypted_domainbinary compiles under--features proptest-e2eeql_v2_float4.sql/eql_v2_float8.sql, 13 rows each)Deferred to CI (needs Postgres + ZeroKMS, unavailable locally)
The DB-backed runs — fixture/e2e oracles, sign-boundary,
float_special, and the full matrix — run in CI. (Local Docker was unusable this session.)Note: included one pre-existing fix
1f605a1fsyncsmatrix_tests_storage_only.txtwith thestorage_count_distinct_extractorarm thattests/sqlx/src/matrix.rsalready emits — pre-existing drift oneql_v3that blockedtest:matrix:inventoryonbool(unrelated to float). Regenerated via the documented command.Summary by CodeRabbit
eql_v3.float4andeql_v3.float8ordered encrypted-domain types.<,<=,>,>=) on encrypted float columns.