feat: finops_snowflake_savings: read-only Snowflake warehouse savings check

Merged
SH
7h ago
+2061-15

Summary (for people)

  • Why: this does for Snowflake what #1762 does for Databricks. A user can check their own Snowflake account for warehouse savings from their machine, or from Claude Code's /savings, without sending usage data to Altimate.
  • Before → after: Before, altimate-code had no Snowflake savings check. After, finops_snowflake_savings reads 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.
  • Who is affected: Users with a Snowflake connection, once this ships. The check runs only with 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.
  • Before it can merge:
    • The base. This is stacked on #1762 (base feat/databricks-savings-tool), which merges first.
    • The core release. It needs an altimate-core release that exports 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

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  • Facts. The tool lists warehouses with SHOW WAREHOUSES. To report on seven days, it reads up to eleven days of SNOWFLAKE.ACCOUNT_USAGE. Days are UTC, and the window ends at least six hours ago, past the views' latency.
  • Rules. altimate-core's snowflakeSavings decides what qualifies and what it saves. It returns the same report shape as the Databricks tool.
  • Price. A credit is priced from the account's rate sheet when it can be read in dollars, otherwise at a stated $3.00.
  • Asks first. Without confirm: true nothing runs. With it, the check stops after 9 minutes, connecting included, or sooner at the run's time budget.
  • Stopping for real. The Snowflake driver gains the opt-in 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.
  • Assessment mode. When it loads, snowflake-sdk probes the AWS, Azure and GCP metadata services. In this mode the driver sets SNOWFLAKE_DISABLE_PLATFORM_DETECTION first, so the SDK skips them.
  • Limits, as the hosted product has them. An active period starts at a resume, ends at the next event, and must overlap at least one query, as the core rules' spec defines it. So a warehouse that never suspended in the window, or a period with no query, gets no idle finding. A bounce counts within one UTC day.
  • Wiring and docs. The tool is registered where finops_databricks_savings is. Docs are on the FinOps tools page.

How did you verify your code works?

At head ade5a6b5e6, rebased onto #1762's current head:

  • tsgo --noEmit: packages/opencode and packages/drivers both clean.
  • Drivers, databricks-deadline and snowflake-deadline: 26 pass.
  • The Snowflake and Databricks savings suites, plus the analyst, workspace and telemetry suites: 1,853 pass in 61 files.
  • 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.
  • Live, on Altimate's own Snowflake account, with the packaged CLI, a throwaway home and a read-only role: 9 findings in 43 s. The only hosts contacted were the Snowflake account and the Databricks workspace. The call without confirm contacted nothing.
  • Against stored data. For a past week, the measured credits equal the hosted product's on all nine active warehouses, and all 1,275 stored active periods match.
  • Certificate revocation. The SDK's revocation requests use an HTTPS agent that Bun does not use, so the packaged CLI makes none.
  • Large results. A result big enough for Snowflake to serve from its cloud storage would add that host. The live run did not need it, and the docs say so.
  • Not covered: cancellation at the limit was not exercised live. The driver tests cover it with a fake SDK. The live run is repeated on the final head before merge.

Cost side effects

Yes, warehouse queries. A confirmed run sends six statements:

  • SHOW WAREHOUSES, which needs no warehouse;
  • five queries on the connection's warehouse, which Snowflake resumes if it is suspended and auto-resume is on.

The usage queries scan up to eleven days of ACCOUNT_USAGE, so their work grows with query history. They are capped by the explicit confirm, 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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

šŸ¤– Generated with Claude Code


Summary by cubic

Adds the finops_snowflake_savings check, the Snowflake counterpart to the Databricks savings tool. Users can check their own account for warehouse savings from their machine or the /savings tool, without sending usage data to Altimate.

How it works

  • Reads seven days of usage from SHOW WAREHOUSES and SNOWFLAKE.ACCOUNT_USAGE, returning each saving with a monthly dollar range and evidence.
  • Catches idle warehouses, warehouses that could run one size smaller, unneeded extra clusters, and frequent restarts that double-bill a minute.
  • Runs only with confirm: true and stops after 9 minutes, because a run can resume a suspended warehouse that then bills.
  • Prices a credit from the account's rate sheet when available, otherwise at $3.00.
  • The Databricks savings check now also reports workspaces_checked, counting distinct workspaces across every checked row, with or without a finding or SQL warehouse.

Driver changes

  • The Snowflake driver gains opt-in cancelAfterMs, cancelling statements server-side past the limit or when the run stops.
  • In assessment mode, the driver sets SNOWFLAKE_DISABLE_PLATFORM_DETECTION so the SDK skips its cloud metadata probes.

Depends on the Databricks savings PR (#1762) merging first, plus an altimate-core release that exports snowflakeSavings and a pin bump.