Repository navigation
feat: finops_snowflake_savings: read-only Snowflake warehouse savings check - #1786
Conversation
…tays off cloud metadata in assessment mode - Past the deadline, or when the signal aborts, the statement is cancelled on Snowflake. One still waiting on a reconnect is never sent. Calls without `cancelAfterMs` run as before. - When it loads, snowflake-sdk probes the AWS, Azure and GCP metadata and identity services. A run that promises to contact only the warehouse now turns that off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measures warehouse usage from `SHOW WAREHOUSES` and `ACCOUNT_USAGE`, read-only, and hands the facts and the price of a credit to altimate-core. It runs only with `confirm: true` and stops after 9 minutes. Assessment mode and the zero-egress suite cover it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also: the rate query takes one price above zero, a stop cancels every statement sent, unused warehouses get ids that cannot collide, account names stay on one line, and the driver egress test no longer needs the core rules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Code Review SummaryStatus: 4 Issues Found | Recommendation: Address in a follow-up (PR merged) Reviewed incrementally from Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (7 files)Incremental diff:
Carried forward after targeted re-check of current code:
Incremental notes
Fix these issues in Kilo Cloud Previous Review Summary (commit ade5a6b)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit ade5a6b)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
The inline comment at Files Reviewed (15 files)
The SQL windows ( Reviewed by deepseek-v4.1-flash-1017 · Input: 88.7K · Output: 17.4K · Cached: 2.3M Review guidance: REVIEW.md from base branch |
…cked `workspaces_checked` counts the distinct workspaces across every warehouse, cluster and job row checked, including workspaces with no finding or no SQL warehouse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Combined into #1762 at the owner's request; its commits are now on that branch. GitHub shows this PR as merged because its head was fast-forwarded onto its base branch (feat/databricks-savings-tool); nothing was merged into main. |
| window, | ||
| warehouse: resolved.warehouse, | ||
| ran_on: runsOn, | ||
| workspaces_checked: workspaces.size, |
There was a problem hiding this comment.
SUGGESTION: The new count never reaches the output the user or the agent reads
workspaces_checked is set here and copied into the tool metadata, but formatSavings (finops-databricks-savings.ts:90-95) still prints only warehouses, clusters and jobs, and the shipped surfaces forward output, not metadata: the default tool view renders output, and the MCP adapter (mcp-server/adapter.ts) and altimate tool run (non---json) return only output to the model. So the number this commit adds is invisible in the Claude Code//savings path it was meant for; only --json and session export expose it.
Either add it to the counted line in formatSavings (e.g. 1 SQL warehouses, 2 all-purpose clusters, 2 jobs checked across 3 workspaces) or drop the field and its test.
Summary (for people)
/savings, without sending usage data to Altimate.finops_snowflake_savingsreads seven days of the account's usage. It returns each saving with a monthly dollar range and its evidence. The checks cover warehouses that sit idle, could run one size smaller, keep an unneeded extra cluster, or restart so often that a billed minute is paid twice.confirm: true, and the agent asks first, because a run can resume a suspended warehouse that then bills. Other Snowflake queries are unchanged: the new cancel path is opt-in.feat/databricks-savings-tool), which merges first.snowflakeSavings(core #788), plus a pin bump. Until then, a confirmed run says this build has no Snowflake rules, before any warehouse query.Details (for agents/reviewers)
Issue for this PR
None.
Type of change
What does this PR do?
SHOW WAREHOUSES. To report on seven days, it reads up to eleven days ofSNOWFLAKE.ACCOUNT_USAGE. Days are UTC, and the window ends at least six hours ago, past the views' latency.snowflakeSavingsdecides what qualifies and what it saves. It returns the same report shape as the Databricks tool.confirm: truenothing runs. With it, the check stops after 9 minutes, connecting included, or sooner at the run's time budget.cancelAfterMs. Past the limit, or when the session stops, the statement is cancelled on Snowflake. A statement still waiting on a reconnect is never sent.SNOWFLAKE_DISABLE_PLATFORM_DETECTIONfirst, so the SDK skips them.finops_databricks_savingsis. Docs are on the FinOps tools page.How did you verify your code works?
At head ade5a6b, rebased onto #1762's current head:
tsgo --noEmit:packages/opencodeandpackages/driversboth clean.databricks-deadlineandsnowflake-deadline: 26 pass.assessment-zero-egress: 23 pass. That includes the Snowflake case with the real driver loaded: without assessment mode the proxy sees the metadata probes, and with it only the account.confirmcontacted nothing.Cost side effects
Yes, warehouse queries. A confirmed run sends six statements:
SHOW WAREHOUSES, which needs no warehouse;The usage queries scan up to eleven days of
ACCOUNT_USAGE, so their work grows with query history. They are capped by the explicitconfirm, one 9-minute limit for the whole run with server-side cancel, and a row limit per query. No model calls.Screenshots / recordings
Not a UI change.
Checklist
🤖 Generated with Claude Code
Summary by cubic
Adds the
finops_snowflake_savingscheck, the Snowflake counterpart to the Databricks savings tool. Users can check their own account for warehouse savings from their machine or the/savingstool, without sending usage data to Altimate.How it works
SHOW WAREHOUSESandSNOWFLAKE.ACCOUNT_USAGE, returning each saving with a monthly dollar range and evidence.confirm: trueand stops after 9 minutes, because a run can resume a suspended warehouse that then bills.workspaces_checked, counting distinct workspaces across every checked row, with or without a finding or SQL warehouse.Driver changes
cancelAfterMs, cancelling statements server-side past the limit or when the run stops.SNOWFLAKE_DISABLE_PLATFORM_DETECTIONso the SDK skips its cloud metadata probes.Depends on the Databricks savings PR (#1762) merging first, plus an altimate-core release that exports
snowflakeSavingsand a pin bump.Written for commit 89567af. Summary will update on new commits.