Repository navigation
feat(match): add contains, datetime-hours and geo-radius comparators (#795) - #852
Merged
Merged
Conversation
…795) - contains: bidirectional substring, blank-guarded (contains(x,'') is true for every x in DuckDB) - datetime_within_hours:<n>: elapsed-time tolerance via epoch seconds, not date_diff('hour') which counts boundaries - geo_within_km:<km>: Haversine over a "lat,lng" text column; malformed points deny via try_cast guards, the numeric_within contract - all three named in UnknownLevel and the group-capable token list - behavioral DuckDB probes for each (the geo probe caught a paren bug before first pass); bad-parameter paths covered in both tiers - er-matching config-to-model token table extended - 65% default similarity decided against on the issue: explicit per-level thresholds stay
pr-review surfaced it: 'NaN'.parse::<f64>() succeeds and NaN <= 0.0 is false in Rust, so a bare sign guard passes NaN through — and in DuckDB NaN sorts above every number, so distance <= NaN is TRUE for every pair: the level that matches everything. Guard is now is_finite && > 0, with NaN/inf unit tests. Also uniform skip notices across the three new behavioral probes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #795
What
Adds the three missing Classic comparators to
er-compile::resolve_level_pair:contains(bidirectional substring, blank-guarded),datetime_within_hours:<n>(elapsed-time via epoch seconds), andgeo_within_km:<km>(Haversine over a"lat,lng"text column, malformed values deny). All three join theUnknownLevelknown-comparator list and the group-capable token list.Why
Spec unit 1.6 (#795, parent #513): the comparison-operator pillar has three gaps — substring containment, hour-granular datetime tolerance, and geolocation radius. The spec's 65% default-similarity bullet is decided not to build; rationale on the issue.
Proof
make checkin the worktree (result recorded below once green). Behavioral coverage:comparator_sql_behaviour.rsgains three DuckDB-evaluated probes —containsboth directions plus the blank-guard case, datetime across an hour boundary (the casedate_diff('hour')gets wrong), Haversine at known distances plus malformed-point denial — run withDEDUPE_E2E_EXTENSIONS=1 cargo test -p er-compile --test main(26 passed). The boundary case failed againstdate_diffsemantics by construction and passes against epoch arithmetic.Risk & rollback
Purely additive: three new tokens; no existing token's emitted SQL changes, so
COMPARATOR_ALGORITHM_VERSIONstays at 1 per its own doc comment (bump on semantics change, never on addition). Rollback:git revert <merge-sha>— compiled models are untouched because none can reference tokens that did not exist.Post-merge ledger
Closed by: agent · session
01a1b892-4cde-7a53-bb3e-9ed2e764acdconMac· 2026-11-08T13:00:00Zmainis green with this change on it — merge SHA79121d80(confirmedon
origin/main);rust,frontend,infra,devcontainerallsuccesson that exact SHA (push-triggered runs).
images—successon79121d80(Rust sources changed, so the engineand control-plane images rebuilt).
deployconverged — run 42481744391:deployment "web-api-green" successfully rolled out, then cut-overRelease "er-platform" has been upgraded. STATUS: deployed(2026-11-08T12:48:43Z).deploygreen above;driftscheduled daily, last run 2026-11-08T06:02Zsuccessonb4b0b0fb(this diff adds no terraform/helm, nothing for drift to find);
kindnightlyleg last ran 2026-11-08T06:44Z
success.Closes #795reference;card read back at
Doneafter the close (project build(deps): bump actions/checkout from 4.2.2 to 7.0.1 #2 item-list).a decision, not work: answered on feat(match): add the three missing Classic comparators — contains, datetime tolerance, geo radius #795 (keep explicit per-level thresholds).
.claude/skills/er-matching/references/config-to-model.mdgained the threerows in this PR; the DuckDB NaN-sorts-above-everything hazard is recorded in
the
geo_within_kmguard comment iner-compile/src/lib.rsand pinned byunit tests.
Specific to this change
Context — plan, discoveries, measurements, files
Plan
numeric_withinguards,parameterhelper, group-capable list).rust/crates/er-compile/src/lib.rs.UnknownLevelmessage names the new tokens.comparator_sql_behaviour.rs(observed failing first: the geo probe caught a real paren bug in the Haversine SQL before it ever passed).make check.Discoveries
entities/) is answered by the encoding: the token compares a single"lat,lng"text column viasplit_part+try_cast, so no schema or standardize change is required and any source that can produce text can carry a point. Malformed values deny rather than error — the contractnumeric_withinalready keeps.contains(x, '')is true for every x — the empty-string guard is load-bearing, not defensive.date_diff('hour', …)counts hour boundaries: 00:59 vs 01:00 reads as an hour apart. The datetime token is epoch-seconds arithmetic instead; the behavioral probe asserts the boundary case.COMPARATOR_ALGORITHM_VERSIONdeliberately not bumped: its doc comment scopes bumps to semantics changes of existing tokens; additions leave every compiled model's frozen SQL valid..claude/skills/er-matching/references/config-to-model.mdcarries a hand-maintained token table — extended with the three rows (the drift risk the table's intro warns about).Measurements
Files
rust/crates/er-compile/src/lib.rs— the three comparator arms, both error-message lists, unit tests.rust/crates/er-compile/tests/comparator_sql_behaviour.rs— three behavioral probes + bad-parameter tokens..claude/skills/er-matching/references/config-to-model.md— token table rows.