|
2 | 2 | """The K gate: which of pass@K / pass^K decides an item, and what reaches Langfuse.""" |
3 | 3 |
|
4 | 4 | import contextlib |
| 5 | +import importlib |
| 6 | +import inspect |
5 | 7 | from unittest.mock import MagicMock, patch |
6 | 8 |
|
7 | 9 | import pytest |
@@ -169,3 +171,44 @@ def test_a_hard_failure_fails_under_both_gates(): |
169 | 171 | for gate in ("any", "power"): |
170 | 172 | with pytest.raises(GeneralQuestionAssertionError): |
171 | 173 | _evaluate(gate, (False, False, False)) |
| 174 | + |
| 175 | + |
| 176 | +# --------------------------------------------------------------------------- # |
| 177 | +# signature compatibility — `gate` must not shift an existing positional argument |
| 178 | +# --------------------------------------------------------------------------- # |
| 179 | +@pytest.mark.parametrize( |
| 180 | + "module_name", |
| 181 | + [ |
| 182 | + "visualization", |
| 183 | + "metric_skill", |
| 184 | + "alert_skill", |
| 185 | + "kda_skill", |
| 186 | + "general_question", |
| 187 | + "guardrail", |
| 188 | + "search_tool", |
| 189 | + ], |
| 190 | +) |
| 191 | +def test_gate_is_the_last_parameter_of_every_evaluator(module_name): |
| 192 | + """Inserted anywhere earlier, a positional caller binds max_iterations or |
| 193 | + initial_conversation_id to `gate`, which then reaches normalize_gate and raises.""" |
| 194 | + module = importlib.import_module(f"gooddata_eval.core.agentic.{module_name}") |
| 195 | + fn = next(v for k, v in vars(module).items() if k.startswith("evaluate_agentic_")) |
| 196 | + names = [p.name for p in inspect.signature(fn).parameters.values()] |
| 197 | + |
| 198 | + assert names[-1] == "gate" |
| 199 | + assert names[5] == "k" |
| 200 | + assert names[6] in ("max_iterations", "initial_conversation_id") |
| 201 | + |
| 202 | + |
| 203 | +def test_a_positional_seventh_argument_still_binds_where_it_used_to(): |
| 204 | + """The regression the parameter order protects: 7 positional args, no keywords.""" |
| 205 | + with _judged(True): |
| 206 | + evaluate_agentic_general_question( |
| 207 | + "https://example.com", # host |
| 208 | + "tok", # token |
| 209 | + "ws", # workspace_id |
| 210 | + "Q", # question |
| 211 | + "rubric", # expected_output |
| 212 | + 1, # k |
| 213 | + "conv-0", # initial_conversation_id -- NOT gate |
| 214 | + ) |
0 commit comments