# `Rho.Budget`
[🔗](https://github.com/GenericJam/rho/blob/v0.1.0/lib/rho/budget.ex#L1)

The per-day cost cap: what the model calls cost today, priced by
req_llm from each reply's usage (notional on a Claude or ChatGPT
subscription), against the host's `Rho.Settings.daily_cap/1`.

The ledger is `spend.json` in the data dir, `{"YYYY-MM-DD" => dollars}`
by the device's local date, the last 31 days kept. The loop checks
`check/1` before every model call and `record/2`s every reply, across
all sessions. A reply that runs past the cap still finishes (its cost
is only known at the end); the next call is refused.

# `check`

```elixir
@spec check(Path.t(), Date.t()) :: :ok | {:over, float(), float()}
```

`:ok`, or `{:over, spent_today, cap}` once today's spend reached the cap.

# `record`

```elixir
@spec record(Path.t(), number(), Date.t()) :: :ok
```

Adds `cost` dollars to the day's spend (non-positive costs are ignored).

# `spent`

```elixir
@spec spent(Path.t(), Date.t()) :: float()
```

Today's spend in dollars.

# `today`

```elixir
@spec today() :: Date.t()
```

The phone's local date.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
