chore: upgrade `@altimateai/altimate-core` to 0.7.0 and sync consumer contracts
Issue for this PR
Closes #1089
Type of change
- Bug fix
- Refactor / code improvement
What does this PR do?
Upgrades @altimateai/altimate-core 0.5.1 → 0.7.0 and syncs every consumer to the real engine output shapes.
The 0.6.0/0.7.0 releases are correctness releases: more lineage edges (derived tables, CTE chains, CTAS/INSERT…SELECT), more PII exposures, stricter migration verdicts, a new unbalanced_quote injection rule, and validate/transpile/equivalence fixes. The only type-surface change is a new required PiiColumnAccess.query_targets: string[] (the SELECT-list aliases exposing a PII column).
Integrating the new engine surfaced consumers still reading legacy (pre-native-core) shapes, all fixed here:
- Migration tool falsely reported SAFE (worst one): it read
data.risks, which the engine never returns (findings/safe/overall_risk), so evenALTER TABLE … DROP COLUMNrendered "Migration: SAFE". An empty dialect string also crashedSchema.fromDdland still rendered SAFE. Now reads the realMigrationResultshape, coerces"" → undefined(same pattern as the equivalence handler), and never renders SAFE on an engine error. altimate check --checks safetyignoreddata.threats, collapsing realThreatFindings into one generic warning;normalizeSeverityalso degradedhigh/mediumtoinfo, so--fail-on warningsilently passed high-risk injections. Now mapsrule/message/detailandhigh → error,medium → warning.altimate check --checks piireadcolumn_name/pii_type(emitting "PII detected: unknown") and stuffed the column name into the numeric column-position field. Now mapsPiiColumnAccess, reports the exposing alias fromquery_targets, and stringifies{ Custom: string }classifications (the query-pii tool renderer printed[object Object]for those).- Track-lineage tool always reported "0 edges": it read flat
data.edgesbut the engine returnsqueries[].edges+impact_map. Also renders ERROR instead of "0 edges" when the engine call fails. - Two tests locked to 0.5.1 parser quirks: the dialect-forwarding fixture used
payload:f, which 0.7.0's default dialect now parses, so it stopped discriminating — switched to Snowflake time-travelAT(OFFSET => -60), which still does. The grade star-vs-explicit comparison compared different queries (WHERE + different tables); made projection-only.
Why these work: every mapping was written against the installed engine's .d.ts and verified by executing the real napi binary (not mocks) in the new tests.
How did you verify your code works?
bun run typecheckclean;bun test test/altimate test/cli: 4750 pass / 0 fail (includes ~4700 real-engine tests).- New real-engine regression tests:
query_targetscontract + rendering, migration destructive/safe/empty-dialect/engine-error + tool-title, track-lineage edge surfacing + error rendering, check CLIThreatFinding+PiiColumnAccessshapes (incl.{ Custom }andhigh → errornormalization). Previously vacuous migration e2e assertions (toBeDefined()) strengthened. - Full suite run twice: the only failures (MCP headers/HttpApi, TUI sound decode, run-subprocess) were reproduced identically with 0.5.1 pinned or shown run-to-run flaky with zero engine coupling — pre-existing, not from this PR.
- Real-binary smoke:
altimate checkon a SQL file against the 0.7.0 engine; injection-breakout payload now flagged byisSafe; BigQuery equivalence decidable. - Marker check:
analyze.ts --markers --base main --strict— no upstream-shared files modified. - Codex reviewed twice: first pass found the legacy-shape consumers (fixed here); second pass verified each fix against the installed engine and confirmed the tests are non-tautological.
- Not verified: Windows/Linux native binaries (darwin-arm64 only locally; CI covers the rest).
Screenshots / recordings
Not a UI change.
Round 2 — consensus-review fixes (00d0a02467)
A 4-model consensus review of this PR found the contract sync incomplete: the same legacy-shape bug class survived in consumers this PR had not touched — including two silently-dead CI gates (check --checks validate passed every invalid file; check --checks semantic and the semantics tool hid findings behind the valid flag, which means "plannable", not "clean"), a dead grade check reading fields evaluate() never returns, schema-level PII detection reading findings where the engine returns columns (zero findings ever), a compare tool that rendered IDENTICAL for different queries, a policy tool that always rendered VIOLATIONS FOUND, four tools crashing on unknown dialect '' when dialect was omitted, and { Custom } PII classifications rendering [object Object] (including in the signed review verdict). All are latent since the Python-engine elimination — the 0.5.1↔0.7.0 type contracts are byte-identical except query_targets (verified by diffing both npm tarballs). All fixed in 00d0a02467 with shared dialectHint/classificationToString helpers, fail-closed gates, and ~25 new real-engine + CLI-shape regression tests. Codex verified each fix against the installed binary; its five review findings (parse_error abstention, grade fail-closed, [byteOffset, byteLength] location semantics, contradictory failure outputs, untracked files) are addressed. Upstream issue filed for the stale SafetyRule union: altimate-core-internal#764.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
🤖 Generated with Claude Code
[!NOTE]
Medium Risk
Touches CI gates (validate, safety, PII, semantic, grade) and PR review check composition; incorrect mapping could still false-pass or over-fail, but changes are heavily regression-tested against the real engine.
Overview
Upgrades @altimateai/altimate-core from 0.5.1 to 0.7.0 and aligns CLI, tools, review runner, and native handlers with the engine’s real JSON shapes so checks and UIs stop false-passing or mislabeling results.
Introduces engine-coerce (dialectHint, PII classification stringification, confidence bands, piiColumnsFromReport) and applies dialectHint everywhere dialect is optional so "" means auto-detect instead of crashing. altimate_core.check now wires PII via checkQueryPii, diff-scopes safety threats and PII against base_sql (validation stays full-scan), and normalizes flat schema_context for lintDiff.
Tools read the correct fields (allowed/violations/warnings, diffs/identical, findings vs valid, queries[].edges, pii_columns/query_targets) and use ERROR titles when the engine fails or abstains (parse_error), not SAFE/IDENTICAL/CLEAN. Schema PII detection uses columns from PiiReport and fails closed on scan errors.
altimate check fixes dead gates: validate on data.valid, semantic on findings not valid, safety on threats with high→error severity, PII/grade/policy mappings, per-file grades, and fail-closed envelopes. Review runner folds validation/safety into check issues, maps PII via query_targets, and uses shared coercions.
Large regression test additions lock these contracts against the live NAPI binary.
Reviewed by Cursor Bugbot for commit b35057fbdbeee00e83a7aeb90a5f1b23fe6cd96f. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Upgrades @altimateai/altimate-core to 0.7.0 and realigns CLI/tools/review to the engine’s JSON contracts so checks stop false‑passing and titles/severities match results. Safety and PII are now diff‑scoped; validation stays non‑diff‑scoped to avoid hiding new breakage.
- Alias‑aware PII scoping: multiset subtraction on (table, column, sorted
query_targets); recomputerisk_level/risk_scorewhen exposures are pre‑existing or partially filtered; stringify{ Custom }; drop nullsuggested_masking; detector fails closed and reportssuccess:falseon partial column errors. - Safety scoping: multiset subtraction on (rule, matched_pattern) against
base_sql; recomputesafe/risk_score;high|critical → error,medium → warning; envelope failures append an error finding even when partial threats exist. - Contract sync: compare uses
diffs/identical; policy usesallowedand surfaces advisorywarnings; grade usesoverall_gradeand aggregates nested validation/safety/lint findings with locations/suggestions; semantics readsfindings(notvalid); validation gates ondata.valid; lineage readsqueries[].edges. - Abstentions/errors: never render SAFE/IDENTICAL/CLEAN on engine errors; PII
parse_errormarksmetadata.success:falseand renders “check skipped”; semantics abstentions are error‑severity with a schema, warning when schema‑less. - Dialect coercion:
""means auto‑detect via sharedEngineCoerce.dialectHintacross all dialect‑taking handlers; composite diff path fixes flatschema_contextviaSchemaResolver.normalizeSchemaContext. - Review lane: only surfaces validation with a real schema; normalizes safety threat severities; PII issues prefer output aliases from
query_targetsand avoid duplicating source columns; CLI renders byte‑range locations.
Summary by CodeRabbit
-
New Features
- Enhanced migration results with risk levels, findings, mitigations, rollback SQL, and clearer safe, risky, and error outcomes.
- Improved lineage displays with query relationships, transformations, impact maps, and clearer engine error reporting.
- Expanded PII details with classifications, exposed query targets, masking suggestions, and improved column detection.
- Improved safety checks with clearer threat labels, severity handling, and recommendations.
- Improved validation, semantic, policy, comparison, and grade check results.
-
Bug Fixes
- Improved handling of dialects, qualified column names, backend response formats, parse errors, and safe informational findings.