[FEATURE]: Pre-execution cost firewall for warehouse queries

Open
#906 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
google-cloud, sql, typescript

Research direction

Start at the sql_execute entry point and review the existing governance configuration and sql_optimize tool. Check BigQuery's dry-run estimation behavior and determine how the proposed budget fields and confirmation flow should fit the default-off requirement; done means over-budget queries are guarded while unsupported warehouses remain unaffected.

Written by the indexing model from the issue text.

Description

Feature hasn't been suggested before.
  • I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem

The agent can run an analytical query that scans terabytes. e.g. SELECT * FROM events and incur a large warehouse bill before anyone realizes. Today there is no pre-execution cost estimate or budget guardrail in sql_execute. The FinOps tooling that exists is all historical (analyzing spend after the fact), not preventive.

Proposed enhancement

An opt-in cost firewall that estimates a query's scan cost before it runs and asks for confirmation when it exceeds a configured budget:

  • Estimate via warehouse-native dry-run where available (BigQuery dryRun returns exact bytes processed for free; no execution, no cost).
  • New governance config: max_query_cost_usd, max_bytes_scanned, cost_per_tib_usd.
  • When a query is over budget, prompt the user (with a hint to try sql_optimize first).
  • Disabled by default; warehouses without estimation support are unaffected (the guard fails open).
Benefits

Cost control is core to the data-engineering workflow. A pre-flight guardrail turns a surprise $40 query into approve, or optimize first without changing behavior for anyone who doesn't set a budget.

Notes

I have an implementation ready (BigQuery estimator + the default-off guard framework) and can open a PR referencing this issue. The estimator is designed to extend to other warehouses (Snowflake via EXPLAIN, etc.).

Dominant language
TypeScript
Stars
813
Forks
134
Avg merge
2d 5h
Merged PRs (30d)
62

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AltimateAI/altimate-code

All issues in AltimateAI/altimate-code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.