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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
This commit is contained in:
GodopuandClaude Fable 5.1 committed 2026-09-13 19:56:37 +09:00
1 parent 0550320590
commit d09c1627ce
2 files changed
+13 -6

No files matched your search

+8 -3
View File
@@ -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 # The heartbeats were honoured: the job was not closed after the first idle
# window, it stayed open up to the wall clock ... # 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}" 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 # ... and the close itself landed within the wall clock plus a small margin.
# (the error publish alone can take ~10 s against the public broker). # Measured on the record's own close time: the error publish that follows
assert elapsed <= timeout_s + 15, f"idle grace outlived --timeout {timeout_s}s: {elapsed:.1f}s\n{stderr}" # 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}"
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
+5 -3
View File
@@ -936,14 +936,16 @@ def test_t1_20_loop_worker_late_completed_continues_to_reviewer(tmp_path, mock_h
"--type", "loop", "--type", "loop",
"--registry-dir", str(reg_dir), "--registry-dir", str(reg_dir),
"--workdir", str(tmp_path), "--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", "--idle-timeout", "2",
], ],
cwd=tmp_path, cwd=tmp_path,
timeout=60, timeout=90,
) )
stop_ev.set() 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()) 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] 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" assert len(rev_prompts) >= 1, "Reviewer must be dispatched after worker completes during grace period"