feat: finops_databricks_savings and finops_snowflake_savings: read-only warehouse savings checks
SH
2h ago+4939+4939+0123456789012345678901234567890123456789-43-43-01234567890123456789
Summary (for people)
- Why: users can run Altimate's Databricks and Snowflake savings checks on their own machine (or through /savings in Claude Code), and no usage data goes to Altimate.
- Before → after: before, the CLI had neither check. After, two tools each read seven days of usage and return every saving with a monthly dollar range and its evidence.
- Who: Databricks and Snowflake users, once this ships. A run needs the user's go-ahead, because it can start a stopped warehouse. It stops after 9 minutes and cancels its queries on the warehouse.
- Also changes for every Databricks and Snowflake query: stopping one (Ctrl-C or a stopped session) now cancels it on the warehouse. Before, it kept running, and billing, until it finished. A query that passes its time limit is still only abandoned, as before, so a long write still finishes.
- Before merge: this needs an altimate-core release that exports both rule sets (core 785, Databricks and Snowflake), then a pin bump here. Until then, each tool refuses before running any query.
Issue for this PR
None.
Type of change
- New feature
- Documentation
What does this PR do?
- Databricks: four checks, covering every workspace the connection's system tables show:
- Classic or Pro warehouses that would be cheaper as serverless;
- over-sized warehouses;
- idle all-purpose clusters;
- scheduled or continuous jobs on all-purpose clusters.
- Snowflake: warehouses that sit idle, could be one size smaller, keep an unneeded extra cluster, or restart within a billed minute.
- Snowflake active periods: a period runs from a resume to the next event, must overlap at least one query, and counts in full on the day it started. This is the core spec's definition, which matches the hosted product. So a warehouse that never suspended, or a period with no query, gets no idle finding. A warehouse name reused after a drop is checked for its current warehouse only, and the result says so.
- Rules: altimate-core decides what qualifies.
- Drivers: both drivers cancel a statement on the warehouse when a caller-set deadline passes or the caller stops it.
- Assessment mode: a savings check contacts only the warehouse. Workspace skills and rules already on disk stay as they are. The claim covers the two savings tools, not the rest of the CLI.
How did you verify your code works?
- Typecheck is clean.
- Focused suites at this head: drivers 44 pass; the savings checks, workspace routes and commands, and the assessment-mode callers (skills, rules, plugins, sign-out) 347 pass. Each new guard was removed once to confirm its test fails. The full unit suite runs in CI: locally, suites that need the DuckDB driver cannot run in this checkout.
- The zero-egress suite, through a refusing proxy, builds the CLI, so it runs in CI here rather than locally.
- Live, on Altimate's own accounts, at this head (packaged CLI, core 785's head built in):
- Databricks: 2 findings, $109–$137 a month, in 69 s.
- Snowflake: 9 findings on 7 warehouses, $346–$494 a month, in 47 s.
- Through a logging proxy, the only hosts contacted were the Snowflake account and the Databricks workspace; the CLI opened no other connection.
- For a past week, Snowflake credits match the hosted product's on all nine active warehouses.
Cost side effects
- Read-only queries only, run after confirm: true: 3 on Databricks, up to 6 on Snowflake.
- Capped at 9 minutes, with the queries cancelled on the warehouse.
- They scan 7 to 11 days of usage history.
- No model calls.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
- I checked for cost side effects and described them
🤖 Generated with Claude Code
Summary by cubic
Adds finops_databricks_savings and finops_snowflake_savings, read-only savings checks that scan every workspace visible in a connection's system tables and report findings with evidence and estimated monthly savings.
- Both tools run only with
confirm: trueand stop at the earlier of 9 minutes and analtimate run --time-budgetcutoff. Connecting counts toward that limit; once time is up or the session is stopped, no query starts. - Every query has a client-side timeout that abandons the statement (it may keep running, so a long write past the timeout still finishes); stopping the session, or
cancelAfterMs, cancels the query on the warehouse. - Databricks measures seven days of system tables for warehouse, idle-cluster, and job-on-all-purpose-compute checks; cluster and job checks are optional and reported as skipped if their tables are unavailable.
- The Databricks job check matches jobs through the compute their task runs used, since Databricks leaves the job id empty on all-purpose billing; deleted jobs are left out and each job counts once.
- Snowflake measures warehouses from
SHOW WAREHOUSESandACCOUNT_USAGEwith a per-credit list price, counting restart gaps in whole elapsed seconds. The optional rate sheet is read after the usage queries, so a slow lookup cannot eat a required query's time. - Both report
workspaces_checked(Databricks) and count each resource once, and say when a check was skipped or capped at the row limit. - Returns an update message when
@altimateai/altimate-corehas no savings rules.
Assessment mode
ALTIMATE_ASSESSMENT_MODE=truekeeps the two savings checks from contacting anything but the customer's warehouse: telemetry, Altimate lookups, remote config fetches, model-catalog and ripgrep downloads, npm plugin installs, and cloud-metadata probes from the Snowflake SDK are disabled; core telemetry is silenced viainitSdkfor every command, includingmcp serve. Other tools that call the Altimate API directly are unaffected.- Signing out still removes local credentials, well-known tokens stay available for substitution, workspace skills and pulled rules stay in place with rules sync off, and daemons started without the mode are not reused; the daemon's identity also tracks the Python environment from main.
- Update checks and language-server downloads are not covered; core's compiled analysis beyond its silenced telemetry is not audited.
Drivers
- Both Databricks and Snowflake drivers gain an opt-in
cancelAfterMs, and an abortedsignalcancels the statement even without one; only a client-sideQueryTimeoutErroris treated as an abandon. The Databricks cancel waits at most 30 s, and a failed or slow close never fails a query that returned rows.