Monthly spend cap per workspace and job

Open
#83 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

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
Active
Tech stack
django, python

Research direction

Start by reading the run-cost display and token-limit implementation, then trace how jobs are started and scheduled. The issue does not name files or tests, so first locate those entry points and check how recent run costs are stored. Done means showing a pre-run estimate and enforcing a weekly or monthly workspace or job spend cap with a clear reason when a run is stopped or skipped.

Written by the indexing model from the issue text.

Description

area: dashboard area: runs enhancement

Problem

Model spend shows only after runs finish. Run limits cap tokens per run, but nothing caps total spend over time. Testers asked how to stop a job from spending more than a set amount.

The cost estimate part of the original idea moved to #156.

Proposal

  • Levels: an owner can set a monthly cap on the workspace and on each job. Both apply. A run must fit under every cap that is set.
  • Period: the calendar month in UTC. Spend is the sum of cost_usd of runs created in that month.
  • Enforcement: checked when a run would start. A run over a cap does not start. It ends with a clear reason, for example "This job reached its $20 monthly spend cap." Scheduled and manual runs are treated the same.
  • Runs in progress: they are not stopped. The per-run token budget already bounds them, so spend can pass the cap by at most one run per job.
  • Unpriced runs: runs without a known cost count as zero. The cap screen says when some runs this month are unpriced.
  • Editing: follows Action.CHANGE_RUN_LIMITS, like other run limits. No cap is set by default.
  • Display: the limits screen shows the cap, this month's spend, and when the period resets.

Out of scope

  • Cost estimates (#156).
  • Weekly or rolling periods.
  • Alerts before reaching the cap.
  • Server-wide caps.

Acceptance criteria

  • A run that would start over the workspace or job cap does not start, and the run shows why.
  • Spend resets at the start of each UTC month.
  • Runs already running are not stopped when the cap is reached.
  • Unpriced runs count as zero and are called out on the cap screen.
  • .secondshift.yaml cannot set or raise a cap.
  • Only users allowed to change run limits can change caps.
Dominant language
Python
Stars
1
Forks
1
Avg merge
1h 9m
Merged PRs (30d)
322

Getting set up

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 piotrekno1/second-shift

All issues in piotrekno1/second-shift

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.