Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ All notable changes to SkillEvaluator are documented in this file.
JSON dataset previews and validation output preserve Unicode values, using
readable characters when the output encoding supports them and escapes otherwise.

- Required Tier 3 judges recheck their wall-time deadline before accepting a
result, including when a dependency or logging handler swallowed the timeout
exception. Expired calls remain scoreless errors and restore their caller's
deadline context.

- `skillevaluator view` no longer asks the LLM again when it regenerates a
missing `report.html` for a Tier 3 run that saved its report feedback in
`result.json`. The regenerated report shows the conclusions,
Expand Down
4 changes: 4 additions & 0 deletions src/skillevaluator/tier3/harbor/templates/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -3760,6 +3760,10 @@ def _raise_judge_timeout(_signum, _frame):
except OSError:
signal.signal(signal.SIGALRM, previous_alarm_handler)
result = judge(*args, **kwargs)
# Dependency and logging handlers can swallow the alarm exception.
# Never accept a result returned after this call's wall-time budget.
if time.monotonic() >= deadline:
raise TimeoutError("LLM judge time budget exhausted")
finally:
if alarm_armed:
try:
Expand Down
69 changes: 68 additions & 1 deletion tests/tier3/test_judge_failure_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,10 @@ def test_ragas_goal_judge_obeys_the_required_judge_time_budget(
else:
if not hasattr(signal, "setitimer") or signal.getitimer(signal.ITIMER_REAL)[0] > 0:
pytest.skip("free POSIX interval timer required")
monkeypatch.setattr(verifier, "_JUDGE_WALL_TIME_BUDGET_SEC", 0.05)
# Give setup ample time; deliver the alarm only once scoring is active.
# A 50ms setup deadline could fire inside a library's logging handler.
monkeypatch.setattr(verifier, "_JUDGE_WALL_TIME_BUDGET_SEC", 30.0)
monkeypatch.setattr(verifier, "time", SimpleNamespace(monotonic=lambda: elapsed[0]))
scorer_sleep = 30.0
real_remaining = verifier._remaining_judge_timeout
scorer_bounds: list[float] = []
Expand All @@ -855,6 +858,11 @@ def __init__(self, llm):
async def ascore(self, **_kwargs):
if cutoff == "scorer_timeout":
elapsed[0] = 1.0
else:
# The real timer represents expiry of the virtual deadline.
# Fallback must see that expiry too, after scoring is cancelled.
elapsed[0] = 31.0
signal.setitimer(signal.ITIMER_REAL, 0.01)
try:
await asyncio.sleep(scorer_sleep)
except asyncio.CancelledError:
Expand All @@ -880,6 +888,65 @@ async def ascore(self, **_kwargs):
assert [instance.closed for instance in client.instances] == [1]


@pytest.mark.parametrize("elapsed", [0.5, 1.0, 1.5])
@pytest.mark.parametrize("not_applicable", [False, True])
def test_required_judge_rechecks_its_deadline_after_a_swallowed_timeout(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, elapsed: float, not_applicable: bool
) -> None:
verifier = _load_verifier(tmp_path)
clock = [0.0]
monkeypatch.setattr(verifier, "signal", SimpleNamespace())
monkeypatch.setattr(verifier, "time", SimpleNamespace(monotonic=lambda: clock[0]))
monkeypatch.setattr(verifier, "_JUDGE_WALL_TIME_BUDGET_SEC", 1.0)

def judge():
# A library or logging handler can catch the interval timer's exception.
try:
clock[0] = elapsed
raise TimeoutError("caught by a dependency")
except TimeoutError:
return (
{"score": None, "status": "not_applicable", "reason": "no reference"}
if not_applicable
else {"score": 0.75, "reason": "completed"}
)

result = verifier._call_required_judge("accuracy", judge, allow_not_applicable=not_applicable)

if elapsed >= 1.0:
assert result["status"] == "error"
assert result["score"] is None
assert "time budget exhausted" in result["reason"]
elif not_applicable:
assert result["status"] == "not_applicable"
assert result["score"] is None
else:
assert result["score"] == 0.75
assert result.get("status") != "error"
assert verifier._ACTIVE_JUDGE_DEADLINE.get() is None


def test_required_judge_rechecks_the_inherited_deadline(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
verifier = _load_verifier(tmp_path)
clock = [0.0]
monkeypatch.setattr(verifier, "signal", SimpleNamespace())
monkeypatch.setattr(verifier, "time", SimpleNamespace(monotonic=lambda: clock[0]))
monkeypatch.setattr(verifier, "_JUDGE_WALL_TIME_BUDGET_SEC", 10.0)
token = verifier._ACTIVE_JUDGE_DEADLINE.set(0.25)

def judge():
clock[0] = 0.5
return {"score": 1.0}

try:
result = verifier._call_required_judge("accuracy", judge)
assert result["status"] == "error"
assert result["score"] is None
assert verifier._ACTIVE_JUDGE_DEADLINE.get() == 0.25
finally:
verifier._ACTIVE_JUDGE_DEADLINE.reset(token)


def test_verifier_main_keeps_genuine_zero_judge_verdicts_scoreable(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
Expand Down
Loading