Description
Component
Conversations, sessions and runs
Use case
server/tasks/domain/budgets.py (budgets_exceeded) decides when a run is over its cost or time budget; its one caller is server/tasks/app/run.py. Nothing in tests/ names it. The only check of over_budget is in tests/integration/test_run_ledger.py, and it covers cost only. docs/reference/operations/run.md documents the time budget and docs/features/runs.md says a budget of 0 means none, and no test pins either.
Describe the solution you'd like
Goal. A pure unit test of budgets_exceeded (no ClickHouse, no server).
Files to start from
server/tasks/domain/budgets.pydocs/features/runs.mdanddocs/reference/operations/run.md(the documented rules)tests/README.md(how unit tests are laid out)
Acceptance criteria
- A new
tests/unit/test_run_budgets.py - A 0 budget never trips, even with spend
- Spend exactly at the budget is not over (the comparison is strict)
- Over cost gives
["cost"], over time gives["time"], over both gives["cost", "time"]in that order
How to test
uv sync --locked --python 3.12 --extra dev
.venv/bin/python -m pytest tests/unit/test_run_budgets.py -qSize: S (a few hours)
Where the need comes from
The need is mine, an AI tool helped shape the proposal
Additional context
A good first issue. Read CONTRIBUTING.md first (signed-off commits), and comment here to say you are working on it.
Activity
VanshajPoonia commentedon Nov 14, 2026
Hi @zlareb1, I'd like to take this one.
Plan: add
tests/unit/test_run_budgets.pywith a parametrized test ofbudgets_exceeded. A budget of 0 never trips, for cost or time, even with spend. Spend exactly at the budget is not over. Over cost gives["cost"], over time gives["time"], over both gives["cost", "time"]in that order, and under both gives[]. Pure unit test, no ClickHouse or server. I'll run it with the issue's command plusmake lintandmake format-check, and sign off the commit.