feat: wire altimate-core 0.5.1 equivalence dialect + decidable into dbt review

Merged
AN
5mo ago
+339-10

What does this PR do?

Wires altimate-core 0.5.1's net-new equivalence surface into the dbt PR review pipeline. 0.5.1 (#925) added an optional dialect parameter to checkEquivalence and a decidable flag on EquivalenceResult.

  • Forward the dialect hint to the engine in the native equivalence handler (native/altimate-core.ts) and the sql.diff handler (native/sql/register.ts). The reviewer already resolves and threads a dialect end-to-end (orchestrate → runner → dispatcher), but commit 89f77a75ca had to drop it at the boundary because 0.4.0 only accepted 3 params. Now it actually reaches core.checkEquivalence, so dialect-specific compiled warehouse SQL (e.g. Snowflake col:field) parses instead of abstaining on a syntax error.
  • Honor the engine's authoritative decidable flag in the review runner (review/runner.ts) — data.decidable !== false. Previously the runner guessed decidability via validation_errors. Strictly safer (only ever abstains more), backward-compatible when the field is absent (0.4.0 shape).
  • Declare dialect? on SqlDiffParams.

Empty-string handling: ReviewConfig.dialect defaults to "", and the engine throws unknown dialect ''. The handlers use || undefined (not ??) so the default empty string coerces to "no hint" — caught by a regression test (fails on ??, passes on ||).

Type of change

  • New feature / wiring (non-breaking)

Issue for this PR

Closes #926

How did you verify your code works?

  • Real-engine native tests (altimate-core-native.test.ts): dialect forwarding flips the parse outcome (Snowflake payload:f syntax-errors without the hint, parses with it), decidable surfaced true/false, empty-string coercion does not throw, sql.diff threads the dialect.
  • Full-pipeline E2E (review-equivalence-e2e.test.ts): drives the complete runReview → real engine path (no mocks) with a real dbt manifest — a non-equivalent rewrite is caught, an equivalent refactor stays silent (no false positive), identical SQL is skipped, a column-drop is decided non-equivalent, and the default empty-string dialect path still decides (regression guard).
  • Runner unit tests (review-runner.test.ts): honors decidable=false, decidable=true, and absent (legacy).
  • bun run typecheck clean; upstream marker check clean; full new-test suite 185 pass / 0 fail. Confirmed the 2 pre-existing failures in validators/e2e-real-dbt-5.test.ts are environmental (spawn-dependent) and present on clean main.
  • Multi-model consensus review (Claude + Gemini + GLM-5): GLM-5 → READY TO MERGE; Gemini independently reproduced the empty-string dialect throw (now fixed + guarded).

Notes / follow-up

The pre-existing sibling handlers (columnLineage, formatSql, extractMetadata, compareQueries, importDdl, Schema.fromDdl) share the same empty-string-dialect fragility but are protected in production by run.ts resolving the dialect first. Kept out of scope here; tracked in #927.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix/feature works
  • New and existing unit tests pass locally

Summary by cubic

Wires altimate-core@0.5.1 into the dbt review pipeline by forwarding the new dialect hint to equivalence checks and honoring the engine’s decidable flag for safe abstentions. Closes Linear #926 and enables warehouse-specific SQL to parse (e.g., Snowflake) instead of abstaining.

  • New Features

    • Forward dialect to checkEquivalence in altimate_core.equivalence and sql.diff.
    • Honor decidable in the runner (data.decidable !== false) to avoid unsafe guesses; remains backward compatible when absent.
    • Add dialect? to SqlDiffParams.
  • Bug Fixes

    • Coerce empty-string dialect to no hint (|| undefined) to avoid engine error on unknown dialect '' in equivalence and sql.diff.

Summary by CodeRabbit

Release Notes

  • New Features

    • SQL dialect parameter now supported across equivalence checking, migration analysis, and formatting operations
    • Equivalence engine now signals whether comparisons are definitive or undecidable
  • Tests

    • Added test coverage for dialect parameter handling and edge cases
    • Added end-to-end tests validating equivalence engine decidability behavior