feat: dbt_cost_estimate tool for BigQuery dry-run scan estimates

HK
1d ago
+938-0

Issue for this PR

None

Type of change

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

What does this PR do?

Adds the dbt_cost_estimate tool. It compiles the selected dbt models, runs a BigQuery dry run for each, and reports the bytes each would scan, with format_bytes-style parsing of limits. It never executes the query.

This branch includes the shared foundation for the dbt Power User tools (local branch feat/pu-mods-foundation). The foundation commits will drop out of the diff once that branch lands in main.

Changelog:

  • New dbt_cost_estimate tool: estimate BigQuery scan bytes for dbt models before running them.

How did you verify your code works?

bun test test/altimate/dbt-cost-estimate.test.ts test/altimate/dbt-adapter-access.test.ts passes (mock adapter, no warehouse). bun run typecheck is clean. The placeholder test no longer treats dbt_cost_estimate as a placeholder.

Cost side effects

BigQuery dry runs only. A dry run scans no data and bills nothing. Each model costs one dry-run API call, so calls grow with the number of selected models; the tool never runs the real query.

Screenshots / recordings

Demo video: /Users/harish/.quikim/artifacts/pu-mods/videos/P-05.mp4 (local file, also P-05.cast). It shows the branch-built altimate tool run dbt_cost_estimate (read-only refusal, then the DuckDB "no dry run" answer on a real dbt project), the tool tests with a mock BigQuery adapter, and the plugin mod tests for the hold and /allow-scan. There are no BigQuery credentials here, so the over-limit dry-run path is shown against the mock adapter only, not a real BigQuery project.

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 dbt_cost_estimate tool, which compiles a dbt model (or raw SQL) and reports the bytes a BigQuery dry run would scan, without ever running the query. The estimate includes an upper bound that accounts for rounding in dbt's formatted bytes, and compilation is cancelled when the call is: a call cancelled before its compile starts compiles nothing, including when the signal flips between the initial check and the work actually running.

The branch also lands the shared foundation for the dbt Power User tools: dbtAdapterFor (the gate every adapter-backed tool goes through, refusing read-only calls and sessions in a dbt project the adapter isn't set up for), an exported AltimateApi.apiRequest helper, and eight placeholder tool stubs (dbt_cte_profile, dbt_defer_state, dbt_docs_coverage, dbt_health, dbt_map_relations, dbt_run_results, dbt_sql_graph, docs_share_comments) that currently answer "not implemented".

Notes

  • Only BigQuery supports dry runs; on any other warehouse the tool answers supported: false without compiling anything.
  • The tool requires write permission (--allow-write on tool run) because starting the adapter runs dbt deps and writes target/.
  • Cost side effect: one dry-run API call per model; dry runs scan no data and bill nothing.

Summary by CodeRabbit

  • New Features
    • Added a dbt cost-estimation tool for supported BigQuery models and SQL queries.
    • Added access to additional dbt and documentation tools. Several are listed but not yet available in this build.
    • Added API request support with clearer sign-in and credential error messages.