feat: add autonomous fiscal completion v1
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
from central.app.ai.budget_ledger import BudgetLedger, BudgetLimits
|
||||
|
||||
|
||||
def test_budget_rejects_before_provider_when_daily_limit_is_exceeded():
|
||||
ledger = BudgetLedger(BudgetLimits(max_run_cost_usd=2.0, max_daily_cost_usd=1.0))
|
||||
assert ledger.check_and_reserve("r1", "t1", 0.75, 1, 0).allowed is True
|
||||
decision = ledger.check_and_reserve("r2", "t1", 0.30, 1, 0)
|
||||
|
||||
assert decision.allowed is False
|
||||
assert decision.reason == "AI_BUDGET_EXHAUSTED"
|
||||
|
||||
|
||||
def test_budget_allows_exact_limit_and_counts_new_products():
|
||||
ledger = BudgetLedger(BudgetLimits(max_run_cost_usd=1.0, max_new_products_per_run=2))
|
||||
assert ledger.check_and_reserve("r1", "t1", 1.0, 1, 2).allowed is True
|
||||
assert ledger.check_and_reserve("r1", "t1", 0.0, 0, 1).allowed is False
|
||||
Reference in New Issue
Block a user