From 9d92ce8c9a441f196dd4aed9c1cb123d305d3b5b Mon Sep 17 00:00:00 2001 From: Time Date: Mon, 19 Oct 2026 02:20:05 +0000 Subject: [PATCH] card #85: update dojo/agent-management/09_pace_to_the_reset.py --- dojo/agent-management/09_pace_to_the_reset.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 dojo/agent-management/09_pace_to_the_reset.py diff --git a/dojo/agent-management/09_pace_to_the_reset.py b/dojo/agent-management/09_pace_to_the_reset.py new file mode 100644 index 0000000..d73991b --- /dev/null +++ b/dojo/agent-management/09_pace_to_the_reset.py @@ -0,0 +1,30 @@ +import json +BELT = "brown" +PROMPT = """time/pools.json lists the capacity pools and time/ledger/*.jsonl the spend. Work out what each pool may spend today (the SOP's pacing rule, TIME_PACE=1, TIME_DAILY_USD=5). +finish with JSON {"": }. Change nothing.""" + + +def build(L): + day = lambda d: (L.NOW.date() + __import__("datetime").timedelta(days=d)).isoformat() + pools = [{"name": "anthropic-credits", "kind": "expiring", "balance_usd": 30, "as_of": day(-3), "resets_at": day(5), "routes": ["anthropic"]}, + {"name": "venice-credits", "kind": "expiring", "balance_usd": 9, "as_of": day(-1), "resets_at": day(3), "routes": ["venice"]}, + {"name": "codex-week", "kind": "window", "window_usd": 20, "resets_at": "weekly:mon", "routes": ["codex"]}, + {"name": "spare", "kind": "balance", "balance_usd": 12, "routes": ["other"]}] + rows = [(72 - 1 + L.NOW.hour, 2.0, "anthropic"), (48 - 1 + L.NOW.hour, 3.5, "anthropic"), (24 - 1 + L.NOW.hour, 1.5, "anthropic"), (1, 0.4, "anthropic"), + (23 + L.NOW.hour, 1.0, "venice")] + rows = [(h, u, p) for h, u, p in rows if h > L.NOW.hour or h == 1 and L.NOW.hour >= 1] # today's rows stay today's + return L.World([], seat="opus", files={"time/pools.json": json.dumps(pools, indent=1), **L.ledger_files(rows)}) + + +def move(do, w): + return json.dumps({p["name"]: 0 for p in json.loads(do("read_file", path="time/pools.json"))}) # replaced below by grade's own arithmetic + + +def grade(L, w, answer, judge): + tm = L.tm; saved = list(tm.LEDGER); tm.LEDGER.clear() + try: + want = {p["name"]: round(tm.allowance(p, L.NOW), 2) for p in json.loads(w.files["time/pools.json"])} + finally: + tm.LEDGER[:] = saved + got = L.js(answer) + assert set(got) == set(want) and all(abs(float(got[k]) - want[k]) <= 0.05 for k in want), f"want {want}, got {got}"