card #82: kept .github/time/test_time.py (generated)
time/worker-run python3 - <<'EOF' p="CHANGELOG.md"; s=open(p).read() line="- Adaptive budget: spend is paced to each

This commit is contained in:
time committed 2026-10-19 00:10:14 +00:00
1 parent ca5bb73319
commit f6a83c5a31
1 file changed
+3 -5
+3 -5
View File
@@ -1047,15 +1047,14 @@ fresh82()
assert tm.allowance(credit, NOW) == 3.0, "$30 over 10 days"
fresh82(spent_row(1), spent_row(1)); assert not refused("anthropic")
fresh82(spent_row(1), spent_row(1), spent_row(1)); assert refused("anthropic"), "the fourth dollar"
assert "pool credits has spent $3.00 of its $3.00 allowance" in str(__import__("contextlib").suppress) or True
nxt = NOW + dt.timedelta(days=1)
fresh82(spent_row(3)) # a day passes: yesterday's $3 is spent, $27 over 9 days
assert tm.allowance(credit, nxt) == 3.0 and not refused("anthropic", nxt)
fresh82(); assert tm.allowance(credit, nxt) == 30 / 9 > 3, "a quiet day raises the share"
os.environ["TIME_PACE"] = "0.8"; assert abs(tm.allowance(credit, NOW) - 2.4) < 1e-9; os.environ.pop("TIME_PACE")
fresh82(spent_row(3.5)); tm.slack = lambda: 1.5
real_slack = tm.slack; fresh82(spent_row(3.5)); tm.slack = lambda: 1.5
assert not refused("anthropic"), "a run under way may go over, against the pool's allowance"
fresh82(spent_row(4.5)); assert refused("anthropic"); del tm.slack
fresh82(spent_row(4.5)); assert refused("anthropic"); tm.slack = real_slack
# a window pool refuses once the window is spent and allows again after its reset
fresh82(spent_row(2, "venice")); assert refused("venice")
assert not refused("venice", tm.window_bounds("hours:5", NOW)[1] + dt.timedelta(minutes=1)), "new window"
@@ -1071,8 +1070,7 @@ out = io.StringIO()
with contextlib.redirect_stdout(out): tm.cmd_doctor()
assert "pool `credits` | expiring, $30.00; spent $1.00 since reset; next reset " in out.getvalue() and "allowance today $3.00" in out.getvalue(), out.getvalue()
assert "pool `sub` | window, $2.00; spent $0.00" in out.getvalue()
import astra as ast
assert ast.board.__code__ and tm.pool_spent(credit) == 1 and tm.pool_spent(sub_) == 0
assert tm.pool_spent(credit) == 1 and tm.pool_spent(sub_) == 0
tm.pools = real_pools; os.environ.pop("TIME_DAILY_USD"); tm.LEDGER.clear(); tm._ledger_files.clear()
print("ALL OK 82")