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"