Budget: the monthly cap counts out-of-pocket money; credit is limited by its pool #193

Merged
teahubxyz merged 4 commits from monthly-cap-out-of-pocket into main 2026-10-19 16:03:09 +00:00
Owner

The owner, this morning: the budget should factor in the usage pool.

Daily pacing already follows anthropic-credits ($161.49 as of 10-19, lapses 11-08, about $8.07/day). But the $100 monthly cap counted every dollar, including what the credit pays. At $43 now and about $8/day it would trip around Oct 26, flip TIME_MODE to dry-run and stop the factory for five days, with credit left to lapse.

  • time.py
    • New credit_covered(month): per expiring pool, what its routes booked from as_of until resets_at within the month, capped at the balance it still had at the month's start.
    • budget()'s month is now spend minus that, so the monthly cap guards the owner's own money.
    • Not covered: spend before as_of (the balance was read after it), spend past the balance or after the lapse, and routes without a pool. Those count as before. With no pools, nothing changes.
    • The refusal message, andon title and doctor row say "out of pocket".
  • astra.py: the seat's spend line says "out of pocket (credit-paid spend excluded)".
  • Tests (82):
    • credit-paid spend is left out and a no-pool route isn't;
    • past the balance, spend is the owner's money again and the cap refuses;
    • spend from before as_of isn't covered;
    • lapsed credit covers nothing;
    • window and balance pools aren't prepaid;
    • no pools behaves as before.
    • The run-cap test (55) matches the new wording.

Against the real ledger: October $42.99 booked, $4.49 credit-covered since 10-19, out-of-pocket $38.51. The $38.51 before as_of is counted conservatively, though the grant probably paid it too. That leaves $61.49 of headroom, so the pool's own pacing governs.

Risk: if the ledger's estimates run below Anthropic's real billing, the credit runs out sooner than the ledger thinks, and some spend would go uncounted until the operator refreshes balance_usd / as_of in time/pools.json. The gap is bounded by how far the estimates are off.

test_time.py all green locally on current main (24 sections).

🤖 Generated with Claude Code

https://claude.ai/code/session_017K4vyY3yUD3GsvoZaAtKkD

The owner, this morning: the budget should factor in the usage pool. Daily pacing already follows `anthropic-credits` ($161.49 as of 10-19, lapses 11-08, about $8.07/day). But the $100 monthly cap counted every dollar, including what the credit pays. At $43 now and about $8/day it would trip around Oct 26, flip `TIME_MODE` to dry-run and stop the factory for five days, with credit left to lapse. - `time.py` - New `credit_covered(month)`: per `expiring` pool, what its routes booked from `as_of` until `resets_at` within the month, capped at the balance it still had at the month's start. - `budget()`'s month is now spend minus that, so the monthly cap guards the owner's own money. - Not covered: spend before `as_of` (the balance was read after it), spend past the balance or after the lapse, and routes without a pool. Those count as before. With no pools, nothing changes. - The refusal message, andon title and `doctor` row say "out of pocket". - `astra.py`: the seat's spend line says "out of pocket (credit-paid spend excluded)". - Tests (82): - credit-paid spend is left out and a no-pool route isn't; - past the balance, spend is the owner's money again and the cap refuses; - spend from before `as_of` isn't covered; - lapsed credit covers nothing; - window and `balance` pools aren't prepaid; - no pools behaves as before. - The run-cap test (55) matches the new wording. Against the real ledger: October $42.99 booked, $4.49 credit-covered since 10-19, out-of-pocket $38.51. The $38.51 before `as_of` is counted conservatively, though the grant probably paid it too. That leaves $61.49 of headroom, so the pool's own pacing governs. Risk: if the ledger's estimates run below Anthropic's real billing, the credit runs out sooner than the ledger thinks, and some spend would go uncounted until the operator refreshes `balance_usd` / `as_of` in `time/pools.json`. The gap is bounded by how far the estimates are off. `test_time.py` all green locally on current main (24 sections). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017K4vyY3yUD3GsvoZaAtKkD
teahubxyz added 4 commits 2026-10-19 16:02:30 +00:00
teahubxyz merged commit 7e7d2d569d into main 2026-10-19 16:03:09 +00:00
Sign in to join this conversation.