From d09c1627ceb17e2524f5f0568e92414dccc0282a Mon Sep 17 00:00:00 2001 From: Godopu Date: Sun, 13 Sep 2026 19:56:37 +0900 Subject: [PATCH] test(issue-18): measure the wall-clock close on the record and widen the loop worker's wall clock Both tests ran against the public broker with second-scale budgets: the error publish after the close can take 10-20 s, and a worker's `started` must land before a 12 s wall clock. Assert the close time from the record's updated_at and give the loop scenario a 30 s wall clock. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff --- tests/test_issue14_delivery_ack.py | 11 ++++++++--- tests/test_issue6_fail_closed.py | 8 +++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/test_issue14_delivery_ack.py b/tests/test_issue14_delivery_ack.py index 1ea2790..0ad19c9 100644 --- a/tests/test_issue14_delivery_ack.py +++ b/tests/test_issue14_delivery_ack.py @@ -503,9 +503,14 @@ def test_wrapper_idle_grace_never_outlives_the_wall_clock(tmp_path): # The heartbeats were honoured: the job was not closed after the first idle # window, it stayed open up to the wall clock ... assert elapsed >= timeout_s - 1, f"closed before the wall clock: {elapsed:.1f}s\n{stderr}" - # ... and not a moment past it beyond closing and publishing the error - # (the error publish alone can take ~10 s against the public broker). - assert elapsed <= timeout_s + 15, f"idle grace outlived --timeout {timeout_s}s: {elapsed:.1f}s\n{stderr}" + # ... and the close itself landed within the wall clock plus a small margin. + # Measured on the record's own close time: the error publish that follows + # the close can take 10-20 s against the public broker and is not what + # this test is about. + import calendar + closed_at = calendar.timegm(time.strptime(job_data["updated_at"], "%Y-%m-%dT%H:%M:%SZ")) + close_delay = closed_at - started + assert close_delay <= timeout_s + 8, f"idle grace outlived --timeout {timeout_s}s: closed after {close_delay:.0f}s\n{stderr}" # --------------------------------------------------------------------------- diff --git a/tests/test_issue6_fail_closed.py b/tests/test_issue6_fail_closed.py index b382a80..2ca1fea 100644 --- a/tests/test_issue6_fail_closed.py +++ b/tests/test_issue6_fail_closed.py @@ -936,14 +936,16 @@ def test_t1_20_loop_worker_late_completed_continues_to_reviewer(tmp_path, mock_h "--type", "loop", "--registry-dir", str(reg_dir), "--workdir", str(tmp_path), - "--timeout", "12", + # wall clock wide enough that the worker's `started` (published + # over the broker) lands before it, so the idle path is what fires + "--timeout", "30", "--idle-timeout", "2", ], cwd=tmp_path, - timeout=60, + timeout=90, ) stop_ev.set() - assert "Worker completed during grace period. Continuing to reviewer." in res.stdout + assert "Worker completed during grace period. Continuing to reviewer." in res.stdout, res.stdout + res.stderr final_st = json.loads(state_file.read_text()) rev_prompts = [c for c in final_st.get("calls", []) if "agent" in c and "prompt" in c and "agt_reviewer" in c] assert len(rev_prompts) >= 1, "Reviewer must be dispatched after worker completes during grace period"