Skip to content

budgets_exceeded has no unit test; the time budget and the zero-means-none rule are untested #629

Closed

Description

@zlareb1

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.py
  • docs/features/runs.md and docs/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 -q

Size: 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

  1. added
    enhancement
    good first issue
    help wanted
    on Nov 13, 2026
  2. VanshajPoonia commented on Nov 14, 2026

    @VanshajPoonia
    Contributor

    Hi @zlareb1, I'd like to take this one.

    Plan: add tests/unit/test_run_budgets.py with a parametrized test of budgets_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 plus make lint and make format-check, and sign off the commit.

  3. added
    up-for-grabs
    on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementgood first issuehelp wantedup-for-grabs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions