From 650b9041b0201c6c4bd84a9cba1711e79f29947c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 1 Dec 2026 16:55:51 +0100 Subject: [PATCH] Fix the clock of the usage-limit wait test --- bin/loop_claude/test_black_box.py | 9 +++++++-- docs/reading-cost.md | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/loop_claude/test_black_box.py b/bin/loop_claude/test_black_box.py index 7b0d0ab8..92388521 100644 --- a/bin/loop_claude/test_black_box.py +++ b/bin/loop_claude/test_black_box.py @@ -141,6 +141,9 @@ if os.path.basename(sys.argv[0]) == "loop-claude": record({"argv": sys.argv[1:]}) pause = time.sleep time.sleep = lambda seconds: record({"sleep": seconds}) if seconds >= 1 else pause(seconds) + # A test that sets LOOP_TEST_NOW fixes the loop's wall clock at that many seconds since the epoch. + if "LOOP_TEST_NOW" in os.environ: + time.time = lambda: float(os.environ["LOOP_TEST_NOW"]) # The host's own memory doesn't matter: every read finds all of it available. sys.path.insert(0, os.path.dirname(os.path.realpath(sys.argv[0]))) import pathlib @@ -704,13 +707,15 @@ class Cycles(unittest.TestCase): def test_waits_out_a_usage_limit_which_ends_a_run_of_failures(self): checkout = Checkout(self) checkout.env["TZ"] = "UTC" - resets_at = int(time.time()) + 3600 + now = 1_800_000_000 + checkout.env["LOOP_TEST_NOW"] = str(now) + resets_at = now + 3600 rejected = json.dumps({"type": "rate_limit_event", "rate_limit_info": {"status": "rejected", "resetsAt": resets_at}}) limited = json.dumps({"type": "result", "api_error_status": 429, "is_error": True, "result": "You've hit your session limit"}) run = checkout.run([worker(exit=1), worker(exit=1), worker(stream=f"{rejected}\n{limited}\n", result=False, exit=1), worker(exit=1), worker(), judge(stdout=limited, exit=1), judge()]) self.assertEqual(run.code, 130) self.assertEqual(run.roles(), ["worker"] * 5 + ["judge"] * 2 + ["worker"]) - self.assertEqual([round(seconds, -1) for seconds in run.sleeps], [60, 60, 3720, 60, 600]) + self.assertEqual(run.sleeps, [60, 60, 3720, 60, 600]) self.assertIn(f"the worker hit a usage limit (You've hit your session limit); retrying at {datetime.datetime.fromtimestamp(resets_at + 120, datetime.timezone.utc):%Y-%m-%d %H:%M:%S}\n", run.stderr) self.assertIn("the judge hit a usage limit (You've hit your session limit); retrying at ", run.stderr) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 3778a071..b3ba5b08 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -3864,3 +3864,13 @@ Read most (opens and searches): Read most (opens and searches): - `agents/stability-reviewer.md` 1 + +## Reading cost, chunk 180918d0d6c2, finished 2026-12-01T15:54:50Z + +122282 new input tokens before the first commit. + +Read most (opens and searches): + +- `docs/decisions.md` 18 +- `todo.md` 12 +- `README.md` 4