card #85: update dojo/agent-management/09_pace_to_the_reset.py
This commit is contained in:
1 parent
f8273000e6
commit
9d92ce8c9a
1 file changed
+30
@@ -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 {"<pool name>": <usd, 2 decimals>}. 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}"
|
||||
Reference in new issue
Block a user