fix: bump @altimateai/altimate-core to 0.9.0 and fail closed on skipped policy/semantic analysis
Issue for this PR
Closes #1554
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Bumps @altimateai/altimate-core from 0.8.0 to 0.9.0 and makes the policy and semantic consumers fail closed on the one 0.9.0 output change that would otherwise loosen them.
Why: 0.9.0 removes validator false positives that make the SQL tools flag valid queries: DuckDB and SQLite identifier case folding, boolean SUM, PostgreSQL LIKE ANY, and table-valued functions (TVFs) in FROM / JOIN.
Behavior delta (verified by calling the 0.9.0 binding on SELECT * FROM TABLE(my_fn()), ... LATERAL FLATTEN(...) and SELECT * FROM read_csv('x')):
| Surface | Was (0.8.0) | Now (0.9.0, before this PR's fix) | Now (this PR) |
|---|---|---|---|
validate | TVF statement reported invalid (E001) | valid: true, plan_status: unavailable_table_valued_function, PLAN_UNAVAILABLE warning | same (intended: false positives gone) |
policy (check --checks policy, agent policy tool) | rejected | allowed: true, policies_evaluated: 0, plan_unavailable warning, i.e. passed unchecked | allowed: false, policy_skipped: true, policy_not_evaluated error violation ("policy could not be evaluated for this statement (table-valued function, no plan available); treated as blocked") |
semantics (check --checks semantic, agent semantics tool, sql.analyze) | rejected | no findings, "plan-based analysis was skipped" note, i.e. looked clean | skipped: true; check reports a finding (error with a schema, warning without), the tool reports Semantics: SKIPPED; sql.analyze adds a warning, drops semantics from confidence_factors and lowers confidence to medium |
Fix location: the altimate_core.policy and altimate_core.semantics native handlers (src/altimate/native/altimate-core.ts), so the CLI, the agent tools and any other dispatcher consumer inherit it. altimate-core-semantics.ts, check.ts and sql/register.ts (sql.analyze called core directly) surface the skip. Queries with a plan are unchanged.
Other 0.9.0 output changes: nothing in packages/opencode/src consumes POLICY_SKIPPED or plan_status; explain returning explanation: null has no consumer either.
Tenant/user impact: SQL that uses table-valued functions now validates instead of being rejected. Policy gating on such SQL stays blocked, as in 0.8.0, but with an accurate reason. Semantic checks on such SQL now say they were skipped.
bun.lock covers the core package and its five platform bindings, with integrity hashes from the npm registry; bun install --frozen-lockfile installs the 0.9.0 darwin-arm64 binding. Also updates the pin mentioned in docs/internal/deterministic-checks-engine-split.md.
How did you verify your code works?
From packages/opencode:
- Baseline (origin/main, core 0.8.0): 131 test files touching altimate-core, the native wrapper and the SQL tools, 5156 pass / 111 skip / 0 fail
- Same files on core 0.9.0 before the fix (local build of core
main91cdf94b, then the published npm package): 5156 pass / 0 fail. The existing suites did not catch the policy change, which is why the new tests exist. - This head: 134 files (adds
test/altimate/core-plan-skip-fail-closed.test.tsand the policy/semantics tool tests): 5168 pass / 111 skip / 0 fail - New tests call the real 0.9.0 binding: three TVF shapes give
allowed: falsefor policy andskipped: truefor semantics, and a normal query is unaffected.check-e2egains a policy-skipped and a semantic-skipped case. - Local read-only Codex review of the diff found one P1 (
sql.analyzecrediting skipped semantics), fixed in the head below.bun run typecheckpasses;script/upstream/analyze.ts --markers --base main --strictis clean.
Screenshots / recordings
Not a UI change.
Cost side effects
None. No new LLM calls, automatic queries, warehouse spend or background work.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
🤖 Generated with Claude Code
[!NOTE]
Medium Risk
Changes enforcement semantics for policy and semantic checks on unplannable SQL; behavior is intentional fail-closed but affects CI gates and agent tooling that relied on 0.9.0’s permissive skip signals.
Overview
Upgrades @altimateai/altimate-core from 0.8.0 to 0.9.0 (lockfile, packages/opencode/package.json, internal docs pin).
Core 0.9.0 can return policy allowed / semantics valid with no findings when plan-based analysis is skipped (e.g. table-valued functions). This PR treats that as not evaluated, not clean: native handlers add applyPolicySkipGuard and applySemanticsSkipGuard on altimate_core.policy and altimate_core.semantics, blocking policy with a policy_not_evaluated violation and marking semantics with skipped / skip_reason.
sql.analyze, the check CLI semantic path, and the semantics agent tool surface skips (lower confidence, explicit issues/titles) so TVF SQL no longer passes policy or looks semantically clean by accident. Integration and e2e tests cover TVF shapes and unchanged normal queries.
Reviewed by Cursor Bugbot for commit fb1d6f97d27ecacb8c683e7eb5a73a48e2da2583. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
- Bug Fixes
- SQL analyses now clearly report when policy or semantic checks were skipped, rather than treating unevaluated checks as successful. Skipped policy checks block the query; skipped semantic checks appear as findings, with confidence adjusted to reflect the missing evaluation.
- The CLI reports skipped checks as findings, with severity based on whether a schema path was supplied.
- Chores
- Updated the Altimate Core dependency.