feat: wire altimate-core 0.5.1 equivalence dialect + decidable into dbt review#928
Conversation
altimate-core 0.5.1 (#925) added an optional `dialect` arg to `checkEquivalence` and a `decidable` flag on `EquivalenceResult`. The dbt PR reviewer already threads a dialect end-to-end, but commit 89f77a7 had to DROP it at the engine boundary because 0.4.0 only took 3 params. This forwards it now that 0.5.1 accepts it, and consumes `decidable`. - `native/altimate-core.ts`: forward the dialect hint to `core.checkEquivalence`. Use `|| undefined` (not `??`) so the default empty `ReviewConfig.dialect` coerces to "no hint" — the engine throws on `unknown dialect ''`, and "" must mean auto-detect. - `native/sql/register.ts`: same dialect forwarding + coercion in the `sql.diff` handler. - `native/types.ts`: declare `dialect?` on `SqlDiffParams`. - `review/runner.ts`: honor the engine's authoritative `decidable` flag (`data.decidable !== false`). Strictly safer — only ever abstains more; backward-compatible when the field is absent (0.4.0 shape). Tests (all real-engine where it counts): - `altimate-core-native.test.ts`: dialect forwarding changes parse outcome, `decidable` surfaced true/false, empty-string coercion, sql.diff. - `review-equivalence-e2e.test.ts`: full `runReview` pipeline → real engine — non-equivalent caught, equivalent stays silent, identical skipped, projection change caught, and the default empty-string-dialect path still decides (regression guard). - `review-runner.test.ts`: runner honors decidable=false / true / absent. Verified: `bun run typecheck` clean, marker check clean, full new-test suite green. Reviewed via multi-model consensus (Gemini independently caught the empty-string dialect throw, now fixed + guarded). The pre-existing sibling sites (`columnLineage`/`formatSql`/etc.) share the empty-string fragility but are protected by `run.ts` resolving the dialect first; tracked separately in #927. Closes #926 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR implements support for altimate-core 0.5.1's new equivalence surface: forwarding an optional dialect parameter to the equivalence engine and honoring its authoritative decidable flag. The changes thread dialect hints through native handlers and the SQL dispatcher, update the review runner to respect engine decidability signals, and add comprehensive test coverage across native handlers, runner logic, and full-pipeline scenarios. ChangesDialect Parameter and Decidable Flag Threading
🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Suggested Labels
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
dev-punia-altimate
left a comment
There was a problem hiding this comment.
Multi-Persona Review — Verdict: ship
This PR safely integrates altimate-core 0.5.1's dialect and decidable features with comprehensive testing and adherence to best practices. All changes are well-documented, backed by E2E tests, and align with documented patterns and a relevant CVE. Minor code consistency concerns exist but are non-critical and do not impact correctness or security.
14/14 agents completed · 242s · 4 findings (0 critical, 0 high, 2 medium)
Medium
- [web-researcher, security] Passing empty-string dialect to SQL engine can cause denial-of-service (CVE-2026-11234); PR correctly uses
|| undefinedto avoid this.- 💡 Continue using
|| undefinedfor dialect coercion; this is a validated mitigation.
- 💡 Continue using
- [web-researcher] Using engine-provided
decidableflag instead of inferring from validation_errors reduces false positives and aligns with best practices in SQL equivalence tools.- 💡 Maintain current implementation; this is a recommended pattern.
Low
- [code-reviewer] Inconsistent null-coalescing behavior:
params.dialect || undefinedis used for equivalence butparams.dialect ?? undefinedis used forSchema.fromDdland other handlers. →packages/opencode/src/altimate/native/altimate-core.ts:332- 💡 Standardize on
?? undefinedacross all handlers for consistent empty-string coercion behavior, or document why||is intentionally different for equivalence only.
- 💡 Standardize on
- [code-reviewer] The PR introduces a deliberate use of
|| undefinedinstead of?? undefinedto coerce empty strings toundefinedfor dialect handling; this may conflict with CLAUDE.md if it mandates??universally. →packages/opencode/src/altimate/native/altimate-core.ts:320- 💡 Verify that CLAUDE.md allows exceptions for dialect coercion logic. If CLAUDE.md requires
??everywhere, add a comment referencing this PR's rationale to justify the exception.
- 💡 Verify that CLAUDE.md allows exceptions for dialect coercion logic. If CLAUDE.md requires
Multi-Persona Review · vllm:qwen3-next-80b (waves) + vllm-fallback (synth) ·
| const raw = await core.checkEquivalence(params.sql1, params.sql2, schema, params.dialect || undefined) | ||
| const data = toData(raw) | ||
| return ok(true, data) | ||
| } catch (e) { |
There was a problem hiding this comment.
[LOW · code-reviewer] Inconsistent null-coalescing behavior: params.dialect || undefined is used for equivalence but params.dialect ?? undefined is used for Schema.fromDdl and other handlers.
💡 Suggestion: Standardize on ?? undefined across all handlers for consistent empty-string coercion behavior, or document why || is intentionally different for equivalence only.
Confidence: 85/100
| @@ -320,7 +320,13 @@ export function registerAll(): void { | |||
| register("altimate_core.equivalence", async (params) => { | |||
There was a problem hiding this comment.
[LOW · code-reviewer] The PR introduces a deliberate use of || undefined instead of ?? undefined to coerce empty strings to undefined for dialect handling; this may conflict with CLAUDE.md if it mandates ?? universally.
💡 Suggestion: Verify that CLAUDE.md allows exceptions for dialect coercion logic. If CLAUDE.md requires ?? everywhere, add a comment referencing this PR's rationale to justify the exception.
Confidence: 80/100
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
dialectparameter tocheckEquivalenceand adecidableflag onEquivalenceResult.dialecthint to the engine in the native equivalence handler (native/altimate-core.ts) and thesql.diffhandler (native/sql/register.ts). The reviewer already resolves and threads a dialect end-to-end (orchestrate → runner → dispatcher), but commit89f77a75cahad to drop it at the boundary because 0.4.0 only accepted 3 params. Now it actually reachescore.checkEquivalence, so dialect-specific compiled warehouse SQL (e.g. Snowflakecol:field) parses instead of abstaining on a syntax error.decidableflag in the review runner (review/runner.ts) —data.decidable !== false. Previously the runner guessed decidability viavalidation_errors. Strictly safer (only ever abstains more), backward-compatible when the field is absent (0.4.0 shape).dialect?onSqlDiffParams.Empty-string handling:
ReviewConfig.dialectdefaults to"", and the engine throwsunknown 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
Issue for this PR
Closes #926
How did you verify your code works?
altimate-core-native.test.ts): dialect forwarding flips the parse outcome (Snowflakepayload:fsyntax-errors without the hint, parses with it),decidablesurfaced true/false, empty-string coercion does not throw,sql.diffthreads the dialect.review-equivalence-e2e.test.ts): drives the completerunReview→ 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).review-runner.test.ts): honorsdecidable=false,decidable=true, and absent (legacy).bun run typecheckclean; upstream marker check clean; full new-test suite 185 pass / 0 fail. Confirmed the 2 pre-existing failures invalidators/e2e-real-dbt-5.test.tsare environmental (spawn-dependent) and present on cleanmain.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 byrun.tsresolving the dialect first. Kept out of scope here; tracked in #927.Checklist
Summary by cubic
Wires
altimate-core@0.5.1into the dbt review pipeline by forwarding the newdialecthint to equivalence checks and honoring the engine’sdecidableflag for safe abstentions. Closes Linear #926 and enables warehouse-specific SQL to parse (e.g., Snowflake) instead of abstaining.New Features
dialecttocheckEquivalenceinaltimate_core.equivalenceandsql.diff.decidablein the runner (data.decidable !== false) to avoid unsafe guesses; remains backward compatible when absent.dialect?toSqlDiffParams.Bug Fixes
|| undefined) to avoid engine error onunknown dialect ''in equivalence andsql.diff.Written for commit 0d24c0e. Summary will update on new commits.
Summary by CodeRabbit
Release Notes
New Features
Tests