reeval-python 0.15.1__py3-none-any.whl → 0.17.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
reeval_python/__init__.py CHANGED
@@ -17,14 +17,15 @@ from reeval_python.environment import (
17
17
  plugin,
18
18
  )
19
19
  from reeval_python.errors import ReevalAssertionError, ReevalCallError
20
- from reeval_python.expect import Expectation, expect, soft
21
- from reeval_python.options import EvalOptions, JudgeDefaults, JudgeOptions
20
+ from reeval_python.expect import Expectation, expect
21
+ from reeval_python.options import BestOf, EvalOptions, JudgeDefaults, JudgeOptions
22
22
  from reeval_python.types import BackgroundHandle, Diff, ExecResult, FileChange, Turn, Verdict
23
23
 
24
24
  __all__ = [
25
25
  "DEFAULT_EGRESS_ALLOW",
26
26
  "AttemptContext",
27
27
  "BackgroundHandle",
28
+ "BestOf",
28
29
  "Diff",
29
30
  "DockerSandbox",
30
31
  "Environment",
@@ -52,6 +53,5 @@ __all__ = [
52
53
  "fake_judge",
53
54
  "group",
54
55
  "plugin",
55
- "soft",
56
56
  "todo",
57
57
  ]
reeval_python/_wire.py CHANGED
@@ -48,13 +48,17 @@ class AntigravityHarnessDescriptor(TypedDict):
48
48
  startTimeout: NotRequired[Duration]
49
49
 
50
50
 
51
- # One `expect` or `expect.soft` matcher call an attempt made.
51
+ # One `expect` or `expect.require` matcher call an attempt made, or a check another language
52
+ # made.
52
53
  class AssertionRecord(TypedDict):
54
+ # `path:line` of the call in the eval file, relative to the project root, when reeval saw
55
+ # it.
56
+ at: NotRequired[str]
53
57
  # Async matchers only (`toHaveFile`, `toSucceed`, `.resolves`, `expect.poll`).
54
58
  durationMs: NotRequired[float]
55
- # `expect`'s second argument, or `<matcher> <first argument>` (or the command `c.exec` ran,
56
- # or the judge's question), cut at 60 characters; ` #2`, ` #3` on repeats within the
57
- # attempt.
59
+ # `label` is the supplied `expect` label. Without one, it is the matcher plus its first
60
+ # argument or named subject, cut at 60 characters. Repeats get ` #2`, ` #3`, and later
61
+ # suffixes.
58
62
  label: str
59
63
  # The eval gave the label.
60
64
  labelled: bool
@@ -62,6 +66,8 @@ class AssertionRecord(TypedDict):
62
66
  matcher: str
63
67
  # Why it failed or couldn't answer, cut at 1 KB.
64
68
  message: NotRequired[str]
69
+ # A failure didn't end the eval's body: an `expect`. False for `expect.require` and for a
70
+ # check that threw, such as Python's `assert`, which end the body when they fail.
65
71
  soft: bool
66
72
  # `error`: the matcher couldn't answer (a subject it can't read, an event the harness
67
73
  # doesn't report).
@@ -100,7 +106,7 @@ class AttemptCallExec(TypedDict):
100
106
  retries: NotRequired[int]
101
107
 
102
108
 
103
- # `c.serve(command, port?)`: a background process and its port.
109
+ # `c.serve(command, port?)`: a background process, once it listens, and its port.
104
110
  class AttemptCallServe(TypedDict):
105
111
  # A shell command; `PORT` is set to the port.
106
112
  command: str
@@ -152,6 +158,14 @@ class AttemptCallWriteFile(TypedDict):
152
158
  path: str
153
159
 
154
160
 
161
+ # Where the eval made the call, which the record names beside the check's outcome.
162
+ class AttemptCallExpectAt(TypedDict):
163
+ # The eval file: absolute, or relative to the project root.
164
+ file: str
165
+ # From 1.
166
+ line: int
167
+
168
+
155
169
  # `expect.poll`: reeval re-reads the subject and retries the matcher until it passes, recording
156
170
  # only the final outcome. The subject must be one reeval can re-read: the attempt, a command or
157
171
  # a file.
@@ -167,6 +181,7 @@ AttemptCallExpect = TypedDict(
167
181
  "AttemptCallExpect",
168
182
  {
169
183
  "args": "list[MatcherArg]",
184
+ "at": "NotRequired[AttemptCallExpectAt]",
170
185
  "label": "NotRequired[str]",
171
186
  "matcher": "str",
172
187
  "not": "bool",
@@ -178,9 +193,19 @@ AttemptCallExpect = TypedDict(
178
193
  )
179
194
 
180
195
 
196
+ # Where the eval made the call, which the record names beside the check's outcome.
197
+ class AttemptCallRecordAt(TypedDict):
198
+ # The eval file: absolute, or relative to the project root.
199
+ file: str
200
+ # From 1.
201
+ line: int
202
+
203
+
181
204
  # A check the eval's own language made, such as Python's `assert`: recorded as a matcher call
182
205
  # is, so it's named, counted and compared the same. Replies with its record.
183
206
  class AttemptCallRecord(TypedDict):
207
+ # Where the eval made the call, which the record names beside the check's outcome.
208
+ at: NotRequired[AttemptCallRecordAt]
184
209
  # The check's own name, the same whether it passes or fails.
185
210
  label: NotRequired[str]
186
211
  # What made the check in the eval's language, e.g. `assert`.
@@ -188,7 +213,8 @@ class AttemptCallRecord(TypedDict):
188
213
  # Why it failed.
189
214
  message: NotRequired[str]
190
215
  op: Literal["record"]
191
- # A failure fails the attempt at its end, as `expect.soft`. Default false.
216
+ # The body carried on after a failure, as after an `expect`. Default false: the check
217
+ # raised, as Python's `assert` does.
192
218
  soft: NotRequired[bool]
193
219
  status: Literal["pass", "fail"]
194
220
  # What it checked, as the eval wrote it (`result.ok`): names the check when it has no label.
@@ -199,8 +225,8 @@ class AttemptCallRecord(TypedDict):
199
225
  # failed.
200
226
  class AttemptCallJudge(TypedDict):
201
227
  op: Literal["judge"]
202
- options: NotRequired[JudgeCallData]
203
- # A yes/no question about the graded turn or value.
228
+ options: JudgeCallData
229
+ # A yes/no question about the inputs `options` turns on.
204
230
  question: str
205
231
 
206
232
 
@@ -211,7 +237,7 @@ AttemptCall: TypeAlias = "AttemptCallSend | AttemptCallExec | AttemptCallServe |
211
237
 
212
238
  # The runner to reeval: the eval's body has finished. The attempt's checks and record follow.
213
239
  class AttemptDone(TypedDict):
214
- # What the body threw, if it threw. A failed `expect` (not soft) is one.
240
+ # What the body threw, if it threw. A failed `expect.require` is one.
215
241
  error: NotRequired[AttemptError]
216
242
  type: Literal["done"]
217
243
 
@@ -252,7 +278,7 @@ class AttemptReplyServe(TypedDict):
252
278
  id: str
253
279
  ok: Literal[True]
254
280
  op: Literal["serve"]
255
- # The container port it was given.
281
+ # The container port it listens on.
256
282
  port: float
257
283
 
258
284
 
@@ -362,6 +388,20 @@ class AttemptStart(TypedDict):
362
388
  type: Literal["start"]
363
389
 
364
390
 
391
+ class CaptureConsoleItem(TypedDict):
392
+ level: Literal["error", "warning", "info", "log", "debug"]
393
+ source: str
394
+ text: str
395
+ url: NotRequired[str]
396
+
397
+
398
+ class CaptureFailedRequestsItem(TypedDict):
399
+ error: NotRequired[str]
400
+ method: str
401
+ status: NotRequired[float]
402
+ url: str
403
+
404
+
365
405
  # `artifacts/<name>.png` under the attempt directory.
366
406
  class CaptureFile(TypedDict):
367
407
  bytes: float
@@ -369,15 +409,30 @@ class CaptureFile(TypedDict):
369
409
  sha256: str
370
410
 
371
411
 
372
- # What `c.capture()` returns: the PNG is also in the attempt record under `artifacts/`.
412
+ # What `c.capture()` returns: the PNG is also in the attempt record under `artifacts/`, and the
413
+ # page facts in `artifacts/<name>.capture.json` beside it.
373
414
  class Capture(TypedDict):
415
+ # Each message the console showed, in order; at most 100 of each level.
416
+ console: list[CaptureConsoleItem]
417
+ # How many messages, errors and requests the caps left out; absent when none.
418
+ dropped: NotRequired[float]
419
+ # The page errors: each uncaught exception and unhandled promise rejection, with its stack,
420
+ # at most 100.
421
+ errors: list[str]
422
+ # Requests that failed or answered 400 or above, in order, at most 100.
423
+ failedRequests: list[CaptureFailedRequestsItem]
374
424
  # `artifacts/<name>.png` under the attempt directory.
375
425
  file: CaptureFile
426
+ # Where the page ended up, after redirects and client-side routing: a path on the app.
427
+ finalUrl: str
376
428
  name: str
377
429
  # Path on the app, as passed in.
378
430
  path: str
379
431
  # Container port that was tunneled.
380
432
  port: float
433
+ # The HTTP status of the main frame's latest document, after redirects. A full navigation
434
+ # replaces it; a client-side route change keeps it. Absent when no response came.
435
+ status: NotRequired[float]
381
436
  # What the author asked, including `'full-page'`.
382
437
  viewport: CaptureWindow | Literal["full-page"]
383
438
 
@@ -415,7 +470,8 @@ class CaptureOptions(TypedDict):
415
470
  # Vision model for `instructions`. Cascades like `question`. Default is `analysis.model`,
416
471
  # else the attempt's judge model, whichever is first a language model; never Jev.
417
472
  model: NotRequired[str]
418
- # How long to poll before failing. Default `'60s'`.
473
+ # How long to poll before failing; a 502, 503 or 504 is polled past until then. Default
474
+ # `'60s'`.
419
475
  timeout: NotRequired[Duration]
420
476
  # The window and saved PNG size, or `'full-page'`. Default 1280×720.
421
477
  viewport: NotRequired[CaptureWindow | Literal["full-page"]]
@@ -434,17 +490,24 @@ class CaptureWindow(TypedDict):
434
490
  width: int
435
491
 
436
492
 
437
- # One cell of an eval: a harness, an environment (`-` when none is set) and that environment's
438
- # image (`sandbox` id: tag, dockerfile and install). With `compare`, the control is `baseline`
439
- # (or the cascaded environment, or an empty `baseline`) and each variant is that environment on
440
- # its own, including its sandbox.
493
+ # A cell of an evaluation combines a harness, an environment (`-` when none is set), and that
494
+ # environment's sandbox id. With `compare`, the control is `baseline` (or the cascaded
495
+ # environment, or an empty `baseline`) and each variant is that environment on its own,
496
+ # including its sandbox.
441
497
  class Cell(TypedDict):
442
- # The environment's own name, also on a variant cell (`with-house-greeting`, with no
443
- # prefix).
498
+ # The environment's own name, also on a variant cell (`with-skill`, with no prefix).
444
499
  environment: str
500
+ # The harness id: `id` when set, otherwise `<kind>:<model>` (`<kind>` alone without a
501
+ # model), with `[effort=<value>]` appended whenever `effort` is set.
445
502
  harness: str
503
+ # The harness id, the environment name, and the sandbox id, joined with `/`.
446
504
  key: str
447
505
  role: CellRole
506
+ # The sandbox id is `id` when set, or `fake` for the fake sandbox. A Docker sandbox starts
507
+ # with the engine (`docker` by default). It adds `:` and the sanitized final component of
508
+ # `image` or `from`, or for `dockerfile` the sanitized filename (the parent directory name
509
+ # when that filename is `Dockerfile` and a parent is present). Non-empty `install` steps
510
+ # append `+` and an eight-character hash.
448
511
  sandbox: str
449
512
  # The variant's name, for variant cells.
450
513
  variant: NotRequired[str]
@@ -509,9 +572,6 @@ class ConfigJudgeOptions(TypedDict):
509
572
  model: NotRequired[FakeJudgeModel | str]
510
573
  # AI SDK provider options for the judge's calls, keyed by provider.
511
574
  providerOptions: NotRequired[dict[str, dict[str, JSONValue]]]
512
- # The judge's state: what the judge is given beside the question, not the workspace's or the
513
- # attempt's state. Merged key by key down the cascade.
514
- state: NotRequired[JudgeStateOptions]
515
575
  # Minimum score (0–1) for a `pass` verdict.
516
576
  threshold: NotRequired[float]
517
577
 
@@ -744,6 +804,10 @@ class EvalOptionsDataCompareHarnessOnly(TypedDict):
744
804
  only: list[str] | str
745
805
 
746
806
 
807
+ class EvalOptionsDataCompareRunsBestOf(TypedDict):
808
+ bestOf: float
809
+
810
+
747
811
  class EvalOptionsDataCompare(TypedDict):
748
812
  # Screenshot defaults for `c.capture()`. Shallow-merged; `viewport` and `model` replace the
749
813
  # value.
@@ -765,7 +829,7 @@ class EvalOptionsDataCompare(TypedDict):
765
829
  judge: NotRequired[ConfigJudgeOptions]
766
830
  # Keys a profile's `limit` may not narrow for this group or eval.
767
831
  pin: NotRequired[list[PinnableKey]]
768
- # Defaults for every question: `model`, and `state` merged key by key, down the cascade.
832
+ # The model every question that names none of its own is answered by, down the cascade.
769
833
  question: NotRequired[QuestionOptions]
770
834
  # What a language model is asked about the attempts, always a list; they never change pass,
771
835
  # fail or the exit code. A question with `across` picks between pairs of attempts once they
@@ -776,13 +840,17 @@ class EvalOptionsDataCompare(TypedDict):
776
840
  # show (a helper, a fixture, data it reads) changes what it measures. A group's applies to
777
841
  # the evals inside it that set none.
778
842
  revision: NotRequired[float | str]
779
- # Attempts per cell. Unset at every level, a compare with variants runs 4 a side, the fewest
780
- # whose lift can reach a verdict, and anything else runs once, a pooled `evaluate.each` case
781
- # included.
782
- runs: NotRequired[float]
843
+ # Attempts per cell: a number, or `{ bestOf: n }` (odd, 3 or more), which stops each cell
844
+ # once a majority of its `n` attempts agree and gates it on that majority; not on a compared
845
+ # eval. Unset at every level, a compare with variants runs 4 a side, the fewest whose lift
846
+ # can reach a verdict, and anything else runs once, a pooled `evaluate.each` case included.
847
+ runs: NotRequired[float | EvalOptionsDataCompareRunsBestOf]
783
848
  # The default machine when the resolved environment omits `sandbox`. Cascades like
784
849
  # `harness`. Not an environment: it does not invent skills, files or a name.
785
850
  sandbox: NotRequired[DockerSandboxDescriptor | FakeSandboxDescriptor]
851
+ # When each attempt's workspace is copied into its directory in `.reeval/runs`: `true` after
852
+ # the checks, `'turns'` after each `c.send` too, `false` never. Default `true`.
853
+ snapshot: NotRequired[SnapshotOptions | Literal["turns"] | bool]
786
854
  # Labels for `--tag` and profiles to select by; a group's are added to its evals'.
787
855
  tags: NotRequired[list[str]]
788
856
  # Per attempt.
@@ -821,6 +889,10 @@ class EvalOptionsDataCompare2HarnessOnly(TypedDict):
821
889
  only: list[str] | str
822
890
 
823
891
 
892
+ class EvalOptionsDataCompare2RunsBestOf(TypedDict):
893
+ bestOf: float
894
+
895
+
824
896
  class EvalOptionsDataCompare2(TypedDict):
825
897
  # Screenshot defaults for `c.capture()`. Shallow-merged; `viewport` and `model` replace the
826
898
  # value.
@@ -840,7 +912,7 @@ class EvalOptionsDataCompare2(TypedDict):
840
912
  judge: NotRequired[ConfigJudgeOptions]
841
913
  # Keys a profile's `limit` may not narrow for this group or eval.
842
914
  pin: NotRequired[list[PinnableKey]]
843
- # Defaults for every question: `model`, and `state` merged key by key, down the cascade.
915
+ # The model every question that names none of its own is answered by, down the cascade.
844
916
  question: NotRequired[QuestionOptions]
845
917
  # What a language model is asked about the attempts, always a list; they never change pass,
846
918
  # fail or the exit code. A question with `across` picks between pairs of attempts once they
@@ -851,13 +923,17 @@ class EvalOptionsDataCompare2(TypedDict):
851
923
  # show (a helper, a fixture, data it reads) changes what it measures. A group's applies to
852
924
  # the evals inside it that set none.
853
925
  revision: NotRequired[float | str]
854
- # Attempts per cell. Unset at every level, a compare with variants runs 4 a side, the fewest
855
- # whose lift can reach a verdict, and anything else runs once, a pooled `evaluate.each` case
856
- # included.
857
- runs: NotRequired[float]
926
+ # Attempts per cell: a number, or `{ bestOf: n }` (odd, 3 or more), which stops each cell
927
+ # once a majority of its `n` attempts agree and gates it on that majority; not on a compared
928
+ # eval. Unset at every level, a compare with variants runs 4 a side, the fewest whose lift
929
+ # can reach a verdict, and anything else runs once, a pooled `evaluate.each` case included.
930
+ runs: NotRequired[float | EvalOptionsDataCompare2RunsBestOf]
858
931
  # The default machine when the resolved environment omits `sandbox`. Cascades like
859
932
  # `harness`. Not an environment: it does not invent skills, files or a name.
860
933
  sandbox: NotRequired[DockerSandboxDescriptor | FakeSandboxDescriptor]
934
+ # When each attempt's workspace is copied into its directory in `.reeval/runs`: `true` after
935
+ # the checks, `'turns'` after each `c.send` too, `false` never. Default `true`.
936
+ snapshot: NotRequired[SnapshotOptions | Literal["turns"] | bool]
861
937
  # Labels for `--tag` and profiles to select by; a group's are added to its evals'.
862
938
  tags: NotRequired[list[str]]
863
939
  # Per attempt.
@@ -880,6 +956,10 @@ class EvalOptionsData3HarnessOnly(TypedDict):
880
956
  only: list[str] | str
881
957
 
882
958
 
959
+ class EvalOptionsData3RunsBestOf(TypedDict):
960
+ bestOf: float
961
+
962
+
883
963
  class EvalOptionsData3(TypedDict):
884
964
  # Screenshot defaults for `c.capture()`. Shallow-merged; `viewport` and `model` replace the
885
965
  # value.
@@ -899,7 +979,7 @@ class EvalOptionsData3(TypedDict):
899
979
  judge: NotRequired[ConfigJudgeOptions]
900
980
  # Keys a profile's `limit` may not narrow for this group or eval.
901
981
  pin: NotRequired[list[PinnableKey]]
902
- # Defaults for every question: `model`, and `state` merged key by key, down the cascade.
982
+ # The model every question that names none of its own is answered by, down the cascade.
903
983
  question: NotRequired[QuestionOptions]
904
984
  # What a language model is asked about the attempts, always a list; they never change pass,
905
985
  # fail or the exit code. A question with `across` picks between pairs of attempts once they
@@ -910,13 +990,17 @@ class EvalOptionsData3(TypedDict):
910
990
  # show (a helper, a fixture, data it reads) changes what it measures. A group's applies to
911
991
  # the evals inside it that set none.
912
992
  revision: NotRequired[float | str]
913
- # Attempts per cell. Unset at every level, a compare with variants runs 4 a side, the fewest
914
- # whose lift can reach a verdict, and anything else runs once, a pooled `evaluate.each` case
915
- # included.
916
- runs: NotRequired[float]
993
+ # Attempts per cell: a number, or `{ bestOf: n }` (odd, 3 or more), which stops each cell
994
+ # once a majority of its `n` attempts agree and gates it on that majority; not on a compared
995
+ # eval. Unset at every level, a compare with variants runs 4 a side, the fewest whose lift
996
+ # can reach a verdict, and anything else runs once, a pooled `evaluate.each` case included.
997
+ runs: NotRequired[float | EvalOptionsData3RunsBestOf]
917
998
  # The default machine when the resolved environment omits `sandbox`. Cascades like
918
999
  # `harness`. Not an environment: it does not invent skills, files or a name.
919
1000
  sandbox: NotRequired[DockerSandboxDescriptor | FakeSandboxDescriptor]
1001
+ # When each attempt's workspace is copied into its directory in `.reeval/runs`: `true` after
1002
+ # the checks, `'turns'` after each `c.send` too, `false` never. Default `true`.
1003
+ snapshot: NotRequired[SnapshotOptions | Literal["turns"] | bool]
920
1004
  # Labels for `--tag` and profiles to select by; a group's are added to its evals'.
921
1005
  tags: NotRequired[list[str]]
922
1006
  # Per attempt.
@@ -1182,12 +1266,12 @@ InstallStep: TypeAlias = "str | InstallStepRun"
1182
1266
  JSONValue: TypeAlias = "list[JSONValue] | bool | None | float | dict[str, JSONValue] | str"
1183
1267
 
1184
1268
 
1185
- # A capture this judge call sent as a file part. Bytes live in `artifacts/<name>.png`.
1269
+ # A capture this judge call sent as a file part. Bytes live in the `artifacts/<name>.png` file.
1186
1270
  class JudgeArtifactRef(TypedDict):
1187
1271
  bytes: float
1188
1272
  mediaType: Literal["image/png"]
1189
1273
  name: str
1190
- # `artifacts/<name>.png` under the attempt directory.
1274
+ # The `artifacts/<name>.png` path under the attempt directory.
1191
1275
  path: str
1192
1276
  sha256: str
1193
1277
 
@@ -1242,12 +1326,16 @@ class JudgeCallDataOnValue(TypedDict):
1242
1326
 
1243
1327
 
1244
1328
  # `c.judge()`'s options as data: the judge options, with the model by name or a fake judge's
1245
- # numeric score, plus the call-only `on` and `artifacts`.
1329
+ # numeric score, the inputs it shows the judge (at least one turned on) and `on`.
1246
1330
  class JudgeCallData(TypedDict):
1247
1331
  # Captures this call sends the judge as image file parts: a capture `c.capture` returned, or
1248
1332
  # its name, or `true` for every capture so far. The provider that cannot take files fails
1249
1333
  # the call.
1250
1334
  artifacts: NotRequired[Literal[True] | list[str | Capture]]
1335
+ checks: NotRequired[bool | list[str]]
1336
+ contents: NotRequired[list[str]]
1337
+ diff: NotRequired[bool | list[str]]
1338
+ files: NotRequired[bool]
1251
1339
  # The gateway the judge's calls go through, by name or by its helper. It skips the config's
1252
1340
  # `gateway` fallback: the plan refuses a gateway that isn't listed or can't serve the model.
1253
1341
  gateway: NotRequired[Literal["direct", "vercel", "openrouter", "vertex"] | JudgeCallDataGatewayDirect | JudgeCallDataGatewayVercel | JudgeCallDataGatewayOpenrouter | JudgeCallDataGatewayVertex]
@@ -1255,15 +1343,17 @@ class JudgeCallData(TypedDict):
1255
1343
  maxConcurrent: NotRequired[int]
1256
1344
  # `'provider/model'`, or a fake judge with a numeric score.
1257
1345
  model: NotRequired[str | FakeJudgeData]
1258
- # What to grade instead of the latest turn: an earlier turn, or a value.
1346
+ # The turn `task`, `output`, `transcript` and `diff` read instead of the latest: an earlier
1347
+ # turn, or a value graded as the output.
1259
1348
  on: NotRequired[JudgeCallDataOnTurn | JudgeCallDataOnValue]
1349
+ output: NotRequired[bool]
1260
1350
  # AI SDK provider options for the judge's calls, keyed by provider.
1261
1351
  providerOptions: NotRequired[dict[str, dict[str, JSONValue]]]
1262
- # The judge's state: what the judge is given beside the question, not the workspace's or the
1263
- # attempt's state. Merged key by key down the cascade.
1264
- state: NotRequired[JudgeStateOptions]
1352
+ task: NotRequired[bool]
1265
1353
  # Minimum score (0–1) for a `pass` verdict.
1266
1354
  threshold: NotRequired[float]
1355
+ transcript: NotRequired[bool | Literal["tools", "full"]]
1356
+ turns: NotRequired[Literal["last", "all"]]
1267
1357
 
1268
1358
 
1269
1359
  # What `c.judge()` returns when the call failed (the provider's error, after any retries): the
@@ -1282,35 +1372,6 @@ class JudgeFailure(TypedDict):
1282
1372
  verdict: Literal["error"]
1283
1373
 
1284
1374
 
1285
- # What the judge is given: each key is a key of the state in `judge-input.json`. An unset key
1286
- # keeps its default, which is what the judge gets with no `state` option at all.
1287
- class JudgeStateOptions(TypedDict):
1288
- # `c.exec` results so far; a list shows only those commands, as passed to `c.exec`. Default
1289
- # false.
1290
- checks: NotRequired[bool | list[str]]
1291
- # Workspace files shown whole, as they are now, changed or not: exact paths or
1292
- # gitignore-style patterns (`'**'`, `'src/**'`; the last match wins, `!` excludes) over the
1293
- # files git sees in the workspace. A missing exact path is `null`; a pattern that matches
1294
- # nothing adds nothing. These files leave the diff. Default none.
1295
- contents: NotRequired[list[str]]
1296
- # The diff since the eval started. A list is gitignore-style patterns over workspace paths:
1297
- # the last matching pattern wins and `!` excludes. Default true.
1298
- diff: NotRequired[bool | list[str]]
1299
- # `status path` lines for the changed files, under `diff`'s patterns. Default true.
1300
- files: NotRequired[bool]
1301
- # The graded turn's final message, or `on`'s value. Default true.
1302
- output: NotRequired[bool]
1303
- # The graded turn's prompt. Default true.
1304
- task: NotRequired[bool]
1305
- # The graded turn's transcript as text lines: `true` is messages and tool calls with tool
1306
- # output clipped, `'tools'` tool calls only, `'full'` adds reasoning and whole tool output.
1307
- # Default false.
1308
- transcript: NotRequired[bool | Literal["tools", "full"]]
1309
- # `'all'`: every turn up to the graded one under `turns`, each with its task, output and
1310
- # (with `transcript`) transcript. Default `'last'`.
1311
- turns: NotRequired[Literal["last", "all"]]
1312
-
1313
-
1314
1375
  # One argument to a matcher: a JSON value, a regular expression as `{ regexp, flags? }`, or a
1315
1376
  # pattern in the runner's own language as `{ matchedBy, answers }`.
1316
1377
  MatcherArg: TypeAlias = "Pattern | AnsweredPattern | JSONValue"
@@ -1559,67 +1620,48 @@ class PluginSourcePlugin4(TypedDict):
1559
1620
  PluginSource: TypeAlias = "PluginSourcePlugin | PluginSourcePlugin2 | PluginSourcePlugin3 | PluginSourcePlugin4"
1560
1621
 
1561
1622
 
1562
- class QuestionQuestion(TypedDict):
1563
- # The factor it varies when pairing, or both: `'environment'` holds the harness, `'harness'`
1564
- # holds the environment. Unset, it's asked of each attempt on its own.
1565
- across: NotRequired[PairFactor | list[PairFactor]]
1566
- # Each attempt's own captures, by name; `true` sends all of them. Replaces
1567
- # `question.artifacts`.
1568
- artifacts: NotRequired[Literal[True] | list[str]]
1569
- # The answers a question asked of each attempt picks from, with a short reason.
1570
- choices: NotRequired[list[str]]
1571
- # `'provider/model'` that answers it, over the cascaded `question.model`.
1572
- model: NotRequired[str]
1573
- question: str
1574
- # What it's shown of each attempt, over the cascaded `question.state`, key by key.
1575
- state: NotRequired[QuestionStateOptions]
1576
-
1577
-
1578
1623
  # A question a language model answers after the attempts: its text, or the text and its options.
1579
1624
  # With `across`, it picks between two attempts that differ only in that factor, in both orders;
1580
1625
  # without it, it's asked of each attempt on its own. Without a model, the cascaded
1581
1626
  # `question.model` answers, else `analysis.model`, else the judge's when it's a language model.
1582
- # `state` and `artifacts` choose what it's shown of each attempt.
1583
- Question: TypeAlias = "str | QuestionQuestion"
1584
-
1585
-
1586
- # Defaults for every question: `model` and `artifacts` replaced, `state` merged key by key.
1587
- class QuestionOptions(TypedDict):
1588
- # Each attempt's own captures, by name; `true` sends all of them. Default none.
1627
+ # It's shown only the inputs it turns on, at least one.
1628
+ class Question(TypedDict):
1629
+ # The factor it varies when pairing, or both: `'environment'` holds the harness, `'harness'`
1630
+ # holds the environment. Unset, it's asked of each attempt on its own.
1631
+ across: NotRequired[PairFactor | list[PairFactor]]
1632
+ # Each attempt's own captures, by name; `true` sends all of them.
1589
1633
  artifacts: NotRequired[Literal[True] | list[str]]
1590
- # `'provider/model'` that answers every question below it without its own `model`.
1591
- model: NotRequired[str]
1592
- # What it's shown of each attempt.
1593
- state: NotRequired[QuestionStateOptions]
1594
-
1595
-
1596
- # What a question is shown of each attempt: the keys of `judge.state` but `contents` (the
1597
- # attempts' workspaces are gone when questions are asked). An unset key keeps its default: a
1598
- # pairwise question shows the task and the diff; one asked of each attempt also shows the final
1599
- # message and the transcript.
1600
- class QuestionStateOptions(TypedDict):
1601
- # `c.exec` results; a list shows only those commands, as passed to `c.exec`. Default false.
1634
+ # `c.exec` results; a list shows only those commands, as passed to `c.exec`.
1602
1635
  checks: NotRequired[bool | list[str]]
1636
+ # The answers a question asked of each attempt picks from, with a short reason.
1637
+ choices: NotRequired[list[str]]
1603
1638
  # The diff since the eval started. A list is gitignore-style patterns over workspace paths:
1604
- # the last matching pattern wins and `!` excludes. Default true.
1639
+ # the last matching pattern wins and `!` excludes.
1605
1640
  diff: NotRequired[bool | list[str]]
1606
- # `status path` lines for the changed files, under `diff`'s patterns. Default false.
1641
+ # `status path` lines for the changed files, under `diff`'s patterns.
1607
1642
  files: NotRequired[bool]
1608
- # The final message: the agent's own account of its work. Default false in a pair, true per
1609
- # attempt.
1643
+ # `'provider/model'` that answers it, over the cascaded `question.model`.
1644
+ model: NotRequired[str]
1645
+ # The final message: the agent's own account of its work.
1610
1646
  output: NotRequired[bool]
1611
- # The prompts the attempt was sent, once for both sides when they match. Default true.
1647
+ question: str
1648
+ # The prompts the attempt was sent, once for both sides when they match.
1612
1649
  task: NotRequired[bool]
1613
1650
  # The transcript as text lines: `true` is messages and tool calls with tool output clipped,
1614
1651
  # `'tools'` tool calls only, `'full'` adds reasoning and whole tool output. It names each
1615
- # harness's tools, so a pair of two harnesses isn't blind. Default false in a pair, true per
1616
- # attempt.
1652
+ # harness's tools, so a pair of two harnesses isn't blind.
1617
1653
  transcript: NotRequired[bool | Literal["tools", "full"]]
1618
1654
  # `'all'`: every turn under `turns`, each with its task, output and (with `transcript`)
1619
1655
  # transcript; `'last'`: the last turn only. Default `'all'`.
1620
1656
  turns: NotRequired[Literal["last", "all"]]
1621
1657
 
1622
1658
 
1659
+ # Defaults for every question below it. What a question is shown is its own, never a default.
1660
+ class QuestionOptions(TypedDict):
1661
+ # `'provider/model'` that answers every question below it without its own `model`.
1662
+ model: NotRequired[str]
1663
+
1664
+
1623
1665
  SandboxDescriptor: TypeAlias = "FakeSandboxDescriptor | DockerSandboxDescriptor"
1624
1666
 
1625
1667
 
@@ -1734,6 +1776,14 @@ class SkillSourceSkill5(TypedDict):
1734
1776
  SkillSource: TypeAlias = "SkillSourceSkill | SkillSourceSkill2 | SkillSourceSkill3 | SkillSourceSkill4 | SkillSourceSkill5"
1735
1777
 
1736
1778
 
1779
+ # `snapshot` as an object, merged field by field over the levels above.
1780
+ class SnapshotOptions(TypedDict):
1781
+ # Write each as `<name>.tar.gz` instead of a directory. Default `false`.
1782
+ compress: NotRequired[bool]
1783
+ # `true` after the checks, `'turns'` after each `c.send` too, `false` never. Default `true`.
1784
+ when: NotRequired[Literal["turns"] | bool]
1785
+
1786
+
1737
1787
  # `header` values, the `query` string, or the request `body`.
1738
1788
  SubstituteIn: TypeAlias = "Literal[\"header\", \"query\", \"body\"]"
1739
1789
 
@@ -1917,6 +1967,7 @@ WebEventType: TypeAlias = "Literal[\"web-search\", \"web-fetch\"]"
1917
1967
  CAMEL_KEYS: frozenset[str] = frozenset(
1918
1968
  {
1919
1969
  "atMs",
1970
+ "bestOf",
1920
1971
  "cacheRead",
1921
1972
  "cacheWrite",
1922
1973
  "costUsd",
@@ -1924,6 +1975,8 @@ CAMEL_KEYS: frozenset[str] = frozenset(
1924
1975
  "durationMs",
1925
1976
  "exitCode",
1926
1977
  "failWith",
1978
+ "failedRequests",
1979
+ "finalUrl",
1927
1980
  "flakeRate",
1928
1981
  "ignoreAbort",
1929
1982
  "matchedBy",
reeval_python/aio.py CHANGED
@@ -7,16 +7,8 @@ await expect(await c.exec("npm test")).to_succeed()
7
7
 
8
8
  from __future__ import annotations
9
9
 
10
- from typing import Any
11
-
12
10
  from reeval_python.expect import AsyncExpectation, _Expect # pyright: ignore[reportPrivateUsage]
13
11
 
14
12
  expect: _Expect[AsyncExpectation] = _Expect(AsyncExpectation, sync=False)
15
13
 
16
-
17
- def soft(actual: Any, label: str | None = None) -> AsyncExpectation:
18
- """`expect.soft(actual, label)`."""
19
- return expect.soft(actual, label)
20
-
21
-
22
- __all__ = ["AsyncExpectation", "expect", "soft"]
14
+ __all__ = ["AsyncExpectation", "expect"]
@@ -1,55 +1,55 @@
1
1
  {
2
- "version": "0.15.1",
2
+ "version": "0.17.0",
3
3
  "binaries": {
4
4
  "linux-x64": {
5
- "name": "reeval-0.15.1-linux-x64",
6
- "sha256": "1514aa35048abc1bb90174f4bae90cbad829008c62cc7c61b7a061d616f190aa",
7
- "size": 90777056
5
+ "name": "reeval-0.17.0-linux-x64",
6
+ "sha256": "167a2c024339b814ae96a06c896a6b63ec5e55859306720180a0ea3f36497374",
7
+ "size": 90895840
8
8
  },
9
9
  "linux-arm64": {
10
- "name": "reeval-0.15.1-linux-arm64",
11
- "sha256": "9765c6f7b5c83cea1f4040143ee15403540404598897b6cef90eaa695b4c7f90",
12
- "size": 90753320
10
+ "name": "reeval-0.17.0-linux-arm64",
11
+ "sha256": "875f0a0651e69d4f4a730da2bd474d510f0480759c0afddf9288c26c4777a459",
12
+ "size": 90884392
13
13
  },
14
14
  "linux-x64-musl": {
15
- "name": "reeval-0.15.1-linux-x64-musl",
16
- "sha256": "98524643d0be87ba8f8a4320ec2e20f6c6c1e7a77cd5418005e6602a0cc54f0b",
17
- "size": 84747824
15
+ "name": "reeval-0.17.0-linux-x64-musl",
16
+ "sha256": "4db54f5801de5b74b18b9d640c05640501027f078421543aac6f810e2ee64afe",
17
+ "size": 84866608
18
18
  },
19
19
  "linux-arm64-musl": {
20
- "name": "reeval-0.15.1-linux-arm64-musl",
21
- "sha256": "822041705bdaaff553fa34286abf29435c2e9866afd9ee6fa76b06a1c55730f4",
22
- "size": 83889360
20
+ "name": "reeval-0.17.0-linux-arm64-musl",
21
+ "sha256": "20dbf7bba2f40b5b33665248ccca542af47d63453017ca14692026a570af4da3",
22
+ "size": 84020432
23
23
  },
24
24
  "darwin-x64": {
25
- "name": "reeval-0.15.1-darwin-x64",
26
- "sha256": "cea280d80792e701b9b1d559415d24a02f3cdf6ba1040f9d428e5bf5bb97e533",
27
- "size": 78786832
25
+ "name": "reeval-0.17.0-darwin-x64",
26
+ "sha256": "26bb34c7a17dde11b3253dac53c2b5e6e9e2d4c31a3b0998c116bfca6c363dbc",
27
+ "size": 78901520
28
28
  },
29
29
  "darwin-arm64": {
30
- "name": "reeval-0.15.1-darwin-arm64",
31
- "sha256": "e7f1fdeb31f41e79ec137d22ff036a25201f0e960f996b669602aef246462c16",
32
- "size": 71754354
30
+ "name": "reeval-0.17.0-darwin-arm64",
31
+ "sha256": "050c1d1e62c4bb3d077d70b8900677ab477c7232d2ac139d3dffb03635516e93",
32
+ "size": 71869938
33
33
  },
34
34
  "windows-x64": {
35
- "name": "reeval-0.15.1-windows-x64.exe",
36
- "sha256": "efe14b3ee751bbf4132c476eb138e8a32036122d1f4ec6f927bb31f302d0e32d",
37
- "size": 95552512
35
+ "name": "reeval-0.17.0-windows-x64.exe",
36
+ "sha256": "f355207f49881d77083a8a9986584ded82834750a331b0b4a8155bc78ca2bd0c",
37
+ "size": 95670784
38
38
  },
39
39
  "linux-x64-baseline": {
40
- "name": "reeval-0.15.1-linux-x64-baseline",
41
- "sha256": "0d3dca1f8ed50316aff10edf990611394da259d280bbeb52704548080508967d",
42
- "size": 90777056
40
+ "name": "reeval-0.17.0-linux-x64-baseline",
41
+ "sha256": "1e83472d1ad452f0efa3bc48105363fccb1eb2003fc4b8a6d8e8cbe32715a1d1",
42
+ "size": 90895840
43
43
  },
44
44
  "linux-x64-musl-baseline": {
45
- "name": "reeval-0.15.1-linux-x64-musl-baseline",
46
- "sha256": "a5091a4a02eed53d676c5f670a661c18657507b425bf28705b4f7afeb8417d80",
47
- "size": 84747824
45
+ "name": "reeval-0.17.0-linux-x64-musl-baseline",
46
+ "sha256": "32b889572e318e866f270e019eb8d4693ff5a0a1a16d4921eb143790edc59d13",
47
+ "size": 84866608
48
48
  },
49
49
  "windows-x64-baseline": {
50
- "name": "reeval-0.15.1-windows-x64-baseline.exe",
51
- "sha256": "8bc8772981f5352f3a08824193a1a59c324e105508b20c41814ec4e41f500c58",
52
- "size": 95552512
50
+ "name": "reeval-0.17.0-windows-x64-baseline.exe",
51
+ "sha256": "c7e705a97681edd99e46f9bd5bdaec9b83cdec96c4e0182c749066d5afc0288e",
52
+ "size": 95670784
53
53
  }
54
54
  }
55
55
  }
reeval_python/checks.py CHANGED
@@ -12,6 +12,8 @@ from __future__ import annotations
12
12
  import ast
13
13
  import itertools
14
14
  import linecache
15
+ import os
16
+ import sys
15
17
  import traceback
16
18
  import warnings
17
19
  from collections.abc import Callable
@@ -86,6 +88,8 @@ def check(
86
88
  "subject": subject,
87
89
  "status": "pass",
88
90
  }
91
+ frame = sys._getframe(1) # pyright: ignore[reportPrivateUsage]
92
+ call["at"] = {"file": os.path.abspath(frame.f_code.co_filename), "line": frame.f_lineno}
89
93
  if value:
90
94
  recorder = _recorder.get()
91
95
  if recorder is not None:
@@ -141,13 +145,16 @@ def unrecorded_failure(exc: AssertionError) -> AttemptCallRecord:
141
145
  if node is not None:
142
146
  subject = _subject(ast.get_source_segment(source, node.test) or ast.unparse(node.test))
143
147
  message = str(exc) or (f"assert {subject}" if subject != "AssertionError" else subject)
144
- return {
148
+ call: AttemptCallRecord = {
145
149
  "op": "record",
146
150
  "matcher": "assert",
147
151
  "subject": subject,
148
152
  "status": "fail",
149
153
  "message": message,
150
154
  }
155
+ if frames and frames[-1].lineno is not None:
156
+ call["at"] = {"file": os.path.abspath(frames[-1].filename), "line": frames[-1].lineno}
157
+ return call
151
158
 
152
159
 
153
160
  def escaped_failures(exc: BaseException) -> list[AttemptCallRecord]:
reeval_python/context.py CHANGED
@@ -14,6 +14,7 @@ from reeval_python._wire import (
14
14
  AttemptCall,
15
15
  AttemptCallExec,
16
16
  AttemptCallExpect,
17
+ AttemptCallExpectAt,
17
18
  AttemptCallExpectPoll,
18
19
  AttemptCallJudge,
19
20
  JudgeCallData,
@@ -21,12 +22,34 @@ from reeval_python._wire import (
21
22
  )
22
23
  from reeval_python.errors import ReevalAssertionError, ReevalCallError
23
24
  from reeval_python.expect import bind_expect, tracked
24
- from reeval_python.options import JudgeOptions
25
+ from reeval_python.options import JUDGE_INPUTS, JudgeOptions
25
26
  from reeval_python.types import BackgroundHandle, ExecResult, Turn, Verdict
26
27
  from reeval_python.wire import Patterns, json_value, options_to_wire, seconds, wire_args
27
28
 
28
29
  _UNSET: Any = object()
29
30
 
31
+ NO_JUDGE_INPUT = (
32
+ "c.judge() shows the judge nothing: turn on at least one input, such as diff=True or "
33
+ "contents=['src/**']. The inputs are "
34
+ + ", ".join(JUDGE_INPUTS[:-1])
35
+ + f" or {JUDGE_INPUTS[-1]}."
36
+ )
37
+
38
+
39
+ def _input_on(value: object) -> bool:
40
+ return (
41
+ value is not None
42
+ and value is not False
43
+ and not (isinstance(value, (list, tuple)) and not value)
44
+ )
45
+
46
+
47
+ def _shows_something(options: JudgeOptions) -> None:
48
+ """Refuses a call that turns no input on, before it reaches reeval or a model."""
49
+ if not any(_input_on(options.get(key)) for key in JUDGE_INPUTS):
50
+ raise TypeError(NO_JUDGE_INPUT)
51
+
52
+
30
53
  SendFn = Callable[[AttemptCall], Awaitable[dict[str, Any]]]
31
54
 
32
55
  # Set while `expect.poll` calls its function: reads and commands are described, not made, so
@@ -234,8 +257,10 @@ class AttemptContext:
234
257
  self, question: str, *, on: object = _UNSET, **options: Unpack[JudgeOptions]
235
258
  ) -> Coroutine[Any, Any, Verdict]:
236
259
  """Ask the judge a yes/no question about the latest turn, or `on` an earlier turn or
237
- a value: an `ExecResult`, a `Verdict` or any JSON value, `None` included."""
260
+ a value: an `ExecResult`, a `Verdict` or any JSON value, `None` included. It's shown only
261
+ the inputs the call turns on, at least one: `c.judge("…", diff=True)`."""
238
262
  _not_describing("c.judge")
263
+ _shows_something(options)
239
264
  return tracked(self._judge(question, on, dict(options)), "c.judge()")
240
265
 
241
266
  async def _judge(self, question: str, on: object, options: dict[str, Any]) -> Verdict:
@@ -245,9 +270,11 @@ class AttemptContext:
245
270
  wire_opts["on"] = (
246
271
  {"turn": on.index} if isinstance(on, Turn) else {"value": json_value(on, accepted)}
247
272
  )
248
- call: AttemptCallJudge = {"op": "judge", "question": question}
249
- if wire_opts:
250
- call["options"] = cast(JudgeCallData, wire_opts)
273
+ call: AttemptCallJudge = {
274
+ "op": "judge",
275
+ "question": question,
276
+ "options": cast(JudgeCallData, wire_opts),
277
+ }
251
278
  reply = await self._call(call)
252
279
  return Verdict._from_wire(cast(dict[str, Any], reply["verdict"])) # pyright: ignore[reportPrivateUsage]
253
280
 
@@ -261,6 +288,7 @@ class AttemptContext:
261
288
  not_: bool,
262
289
  soft: bool,
263
290
  poll: AttemptCallExpectPoll | None = None,
291
+ at: AttemptCallExpectAt | None = None,
264
292
  ) -> None:
265
293
  patterns = Patterns()
266
294
  call: AttemptCallExpect = {
@@ -275,6 +303,8 @@ class AttemptContext:
275
303
  call["label"] = label
276
304
  if poll is not None:
277
305
  call["poll"] = {**poll}
306
+ if at is not None:
307
+ call["at"] = at
278
308
  reply = await self._call(call)
279
309
  # reeval asks for the strings it tested the patterns on; each round answers more. A
280
310
  # subject that changes on every read never runs out of new strings, so the rounds stop.
@@ -293,7 +323,7 @@ class AttemptContext:
293
323
  f"{PATTERN_ROUNDS} times over: check it once it has stopped changing"
294
324
  )
295
325
  assertion = cast(dict[str, Any], reply.get("assertion") or {})
296
- if assertion.get("status") == "fail" and not soft:
326
+ if assertion.get("status") in ("fail", "error") and not soft:
297
327
  raise ReevalAssertionError(str(assertion.get("message") or "expect failed"))
298
328
 
299
329
  def bind_expect(self) -> None:
@@ -383,8 +413,10 @@ class SyncAttemptContext:
383
413
  self, question: str, *, on: object = _UNSET, **options: Unpack[JudgeOptions]
384
414
  ) -> Verdict:
385
415
  """Ask the judge a yes/no question about the latest turn, or `on` an earlier turn or
386
- a value: an `ExecResult`, a `Verdict` or any JSON value, `None` included."""
416
+ a value: an `ExecResult`, a `Verdict` or any JSON value, `None` included. It's shown only
417
+ the inputs the call turns on, at least one: `c.judge("…", diff=True)`."""
387
418
  _not_describing("c.judge")
419
+ _shows_something(options)
388
420
  return self._run(self._ctx._judge(question, on, dict(options))) # pyright: ignore[reportPrivateUsage]
389
421
 
390
422
  def bind_expect(self) -> None:
reeval_python/expect.py CHANGED
@@ -1,19 +1,22 @@
1
1
  """`expect` for `def` bodies: reeval's matchers, with snake_case names, each a blocking call.
2
2
 
3
3
  `reeval_python.aio.expect` is the same for `async def` bodies, where each matcher is awaited.
4
- reeval runs the matcher on what the eval hands it and records the check.
4
+ reeval runs the matcher on what the eval hands it and records the check. A failed `expect`
5
+ fails the attempt and the body carries on; `expect.require` raises, ending the body there.
5
6
  """
6
7
 
7
8
  from __future__ import annotations
8
9
 
9
10
  import itertools
11
+ import os
10
12
  import re
13
+ import sys
11
14
  from collections.abc import Callable, Coroutine, Sequence
12
15
  from contextvars import ContextVar
13
16
  from datetime import timedelta
14
17
  from typing import TYPE_CHECKING, Any, Generic, Self, TypeVar
15
18
 
16
- from reeval_python._wire import AttemptCallExpectPoll, MatcherSubject
19
+ from reeval_python._wire import AttemptCallExpectAt, AttemptCallExpectPoll, MatcherSubject
17
20
  from reeval_python.wire import seconds, subject_for_matcher
18
21
 
19
22
  if TYPE_CHECKING:
@@ -93,6 +96,25 @@ def _bound(what: str, sync: bool) -> SubmitFn:
93
96
  return submit
94
97
 
95
98
 
99
+ _PACKAGE = os.path.dirname(os.path.abspath(__file__)) + os.sep
100
+
101
+
102
+ def call_site(depth: int = 1) -> AttemptCallExpectAt | None:
103
+ """Where the eval made the call: its frame in a `.eval.py` file, as a helper in another file
104
+ is called from one, else the first frame outside reeval_python."""
105
+ frame = sys._getframe(depth) # pyright: ignore[reportPrivateUsage]
106
+ first: AttemptCallExpectAt | None = None
107
+ while frame is not None:
108
+ name = frame.f_code.co_filename
109
+ file = os.path.abspath(name)
110
+ if not file.startswith(_PACKAGE) and not name.startswith("<"):
111
+ if file.endswith(".eval.py"):
112
+ return {"file": file, "line": frame.f_lineno}
113
+ first = first or {"file": file, "line": frame.f_lineno}
114
+ frame = frame.f_back
115
+ return first
116
+
117
+
96
118
  def _given(*args: Any) -> list[Any]:
97
119
  """A matcher's arguments up to the first one left out, as reeval reads them."""
98
120
  out: list[Any] = []
@@ -114,7 +136,7 @@ class _Matchers(Generic[R]):
114
136
  *,
115
137
  label: str | None = None,
116
138
  not_: bool = False,
117
- soft: bool = False,
139
+ soft: bool = True,
118
140
  poll: AttemptCallExpectPoll | None = None,
119
141
  ) -> None:
120
142
  self._subject = subject
@@ -150,6 +172,9 @@ class _Matchers(Generic[R]):
150
172
  }
151
173
  if self._poll is not None:
152
174
  fields["poll"] = self._poll
175
+ at = call_site()
176
+ if at is not None:
177
+ fields["at"] = at
153
178
  return fields
154
179
 
155
180
  def to_be(self, expected: Any) -> R:
@@ -222,19 +247,16 @@ class AsyncExpectation(_Matchers[Coroutine[Any, Any, None]]):
222
247
  E = TypeVar("E", bound=_Matchers[Any])
223
248
 
224
249
 
225
- class _Expect(Generic[E]):
226
- def __init__(self, make: type[E], sync: bool) -> None:
250
+ class _Checks(Generic[E]):
251
+ def __init__(self, make: type[E], sync: bool, *, soft: bool) -> None:
227
252
  self._make = make
228
253
  self._sync = sync
254
+ self._soft = soft
255
+ self._name = "expect" if soft else "expect.require"
229
256
 
230
257
  def __call__(self, actual: Any, label: str | None = None) -> E:
231
- submit = _bound("expect()", self._sync)
232
- return self._make(subject_for_matcher(actual), submit, label=label)
233
-
234
- def soft(self, actual: Any, label: str | None = None) -> E:
235
- """A check whose failure fails the attempt once the body is done, not here."""
236
- submit = _bound("expect.soft()", self._sync)
237
- return self._make(subject_for_matcher(actual), submit, label=label, soft=True)
258
+ submit = _bound(f"{self._name}()", self._sync)
259
+ return self._make(subject_for_matcher(actual), submit, label=label, soft=self._soft)
238
260
 
239
261
  def poll(
240
262
  self,
@@ -252,22 +274,33 @@ class _Expect(Generic[E]):
252
274
  """
253
275
  from reeval_python.context import AttemptContext, SyncAttemptContext, describe
254
276
 
255
- submit = _bound("expect.poll()", self._sync)
277
+ where = f"{self._name}.poll"
278
+ submit = _bound(f"{where}()", self._sync)
256
279
  if isinstance(actual, AttemptContext | SyncAttemptContext):
257
280
  subject: MatcherSubject = {"attempt": True}
258
281
  elif callable(actual):
259
282
  subject = describe(actual)
260
283
  else:
261
284
  raise TypeError(
262
- "expect.poll takes c, or a function that reads a file or runs a command, e.g. "
263
- "expect.poll(lambda: c.read_file('ready.txt')): a value never changes"
285
+ f"{where} takes c, or a function that reads a file or runs a command, e.g. "
286
+ f"{where}(lambda: c.read_file('ready.txt')): a value never changes"
264
287
  )
265
288
  poll: AttemptCallExpectPoll = {}
266
289
  if interval is not None:
267
- poll["interval"] = _ms(interval, "expect.poll(interval=…)")
290
+ poll["interval"] = _ms(interval, f"{where}(interval=…)")
268
291
  if timeout is not None:
269
- poll["timeout"] = _ms(timeout, "expect.poll(timeout=…)")
270
- return self._make(subject, submit, label=label, poll=poll)
292
+ poll["timeout"] = _ms(timeout, f"{where}(timeout=…)")
293
+ return self._make(subject, submit, label=label, soft=self._soft, poll=poll)
294
+
295
+
296
+ class _Expect(_Checks[E]):
297
+ """`expect(actual, label)`: a failed matcher fails the attempt, and the body carries on."""
298
+
299
+ def __init__(self, make: type[E], sync: bool) -> None:
300
+ super().__init__(make, sync, soft=True)
301
+ self.require: _Checks[E] = _Checks(make, sync, soft=False)
302
+ """`expect.require(actual, label)`, for a gate: a failed matcher raises
303
+ `ReevalAssertionError`, ending the body there, as `assert` does."""
271
304
 
272
305
 
273
306
  def _ms(value: timedelta | float, where: str) -> float:
@@ -278,8 +311,3 @@ def _ms(value: timedelta | float, where: str) -> float:
278
311
 
279
312
 
280
313
  expect: _Expect[Expectation] = _Expect(Expectation, sync=True)
281
-
282
-
283
- def soft(actual: Any, label: str | None = None) -> Expectation:
284
- """`expect.soft(actual, label)`."""
285
- return expect.soft(actual, label)
reeval_python/options.py CHANGED
@@ -22,14 +22,36 @@ class JudgeDefaults(TypedDict, total=False):
22
22
  max_concurrent: int
23
23
  model: str | FakeJudge
24
24
  provider_options: Mapping[str, Mapping[str, Any]]
25
- state: Mapping[str, Any]
26
25
  threshold: float
27
26
 
28
27
 
29
28
  class JudgeOptions(JudgeDefaults, total=False):
30
- """`c.judge()`'s options: the judge defaults, plus the captures it sends."""
29
+ """`c.judge()`'s options: the judge defaults, and what the call shows the judge.
31
30
 
31
+ Every input is off unless the call turns it on, and a call turns on at least one of `task`,
32
+ `output`, `files`, `diff`, `contents`, `transcript`, `checks` or `artifacts`. `turns` says
33
+ whether they read every turn up to the graded one (`"all"`) or that turn alone.
34
+ """
35
+
36
+ task: bool
37
+ output: bool
38
+ files: bool
39
+ diff: bool | Sequence[str]
40
+ contents: Sequence[str]
41
+ transcript: bool | Literal["tools", "full"]
42
+ checks: bool | Sequence[str]
32
43
  artifacts: Literal[True] | Sequence[str]
44
+ turns: Literal["last", "all"]
45
+
46
+
47
+ JUDGE_INPUTS = ("task", "output", "files", "diff", "contents", "transcript", "checks", "artifacts")
48
+
49
+
50
+ class BestOf(TypedDict):
51
+ """`runs={"best_of": 5}`: stop each cell once a majority of its 5 attempts agree."""
52
+
53
+ best_of: int
54
+ """Odd, 3 or more."""
33
55
 
34
56
 
35
57
  class EvalOptions(TypedDict, total=False):
@@ -45,10 +67,17 @@ class EvalOptions(TypedDict, total=False):
45
67
  judge: JudgeDefaults
46
68
  pin: Sequence[str]
47
69
  question: Mapping[str, Any]
48
- questions: Sequence[str | Mapping[str, Any]]
49
- """Asked of each attempt, or between attempts with `across`; `[]` clears the group's."""
50
- runs: int
70
+ questions: Sequence[Mapping[str, Any]]
71
+ """Asked of each attempt, or between attempts with `across`; `[]` clears the group's. Each
72
+ names what it's shown: `{"question": …, "diff": True}`, at least one input."""
73
+ runs: int | BestOf
74
+ """Attempts per cell, or `{"best_of": n}`, which gates each cell on its majority. Not on a
75
+ compared eval."""
51
76
  sandbox: DockerSandbox | Mapping[str, Any]
77
+ snapshot: bool | Literal["turns"] | Mapping[str, Any]
78
+ """When each attempt's workspace is copied into its directory in `.reeval/runs`: `True` after
79
+ the checks, `"turns"` after each `send` too, `False` never, or `{"when": …, "compress": True}`
80
+ for `<name>.tar.gz` files. Default `True`."""
52
81
  revision: int | str
53
82
  """The eval's version, in its fingerprint: bump it when a helper, a constant outside the body
54
83
  or a fixture changes what it measures. A group's applies to evals inside that set none."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: reeval-python
3
- Version: 0.15.1
3
+ Version: 0.17.0
4
4
  Summary: Python authoring SDK for reeval (*.eval.py eval files)
5
5
  Project-URL: Homepage, https://reeval.ai
6
6
  Project-URL: Repository, https://github.com/invertase/reeval
@@ -73,7 +73,7 @@ from reeval_python import SyncAttemptContext, evaluate, expect
73
73
  def lands(c: SyncAttemptContext) -> None:
74
74
  c.send("Create greet.py that prints hi")
75
75
  assert c.exec("test -f greet.py").ok
76
- expect(c.judge("Does greet.py print hi?")).to_pass()
76
+ expect(c.judge("Does greet.py print hi?", contents=["greet.py"])).to_pass()
77
77
  ```
78
78
 
79
79
  Plain `assert` is first-class, as in pytest: each one in an eval file is a check in the run
@@ -83,24 +83,33 @@ as in Python, and is recorded with its message and both sides of a comparison as
83
83
  (`greet.py exists: assert 1 == 2`). An `AssertionError` the body catches isn't a failed check, so
84
84
  a retry loop can assert; one the escaping error carries (each failure in a `TaskGroup`'s
85
85
  `ExceptionGroup`, or one an error was raised from or while handling) is. Use typed results (`ExecResult.ok`, `Verdict.passed`, `Turn.text`, …) and `c.file(path)`
86
- for quick checks. Keep `expect` for reeval matchers (`to_have_file`, `to_succeed`, soft checks,
86
+ for quick checks. Keep `expect` for reeval matchers (`to_have_file`, `to_succeed`, checks that carry on,
87
87
  labels) — Playwright-style.
88
88
 
89
- #### What a caught failure counts as
89
+ #### Checks carry on; `expect.require` is a gate
90
90
 
91
- A failed `expect` is a check the moment it fails: reeval records it before
92
- `ReevalAssertionError` reaches the body. One the body catches still fails the attempt when the
93
- body ends, as `expect.soft` does, and its error says the eval caught it. A plain `assert` the body
94
- catches records nothing, as in Python.
91
+ A failed `expect` is recorded and the body carries on, so every later check and judge still runs;
92
+ the attempt fails when the body ends. `expect.require` raises `ReevalAssertionError` instead, for a
93
+ gate the rest depends on:
94
+
95
+ ```python
96
+ c.send("Add a sign-up page")
97
+ expect.require(c.exec("npm run build"), "builds").to_succeed() # stops here if the build fails
98
+ expect(c.exec("npm test"), "tests pass").to_succeed() # recorded, carries on
99
+ ```
100
+
101
+ reeval records a failed `expect.require` before the error reaches the body. One the body catches
102
+ still fails the attempt when the body ends, and its error says the eval caught it. A plain
103
+ `assert` the body catches records nothing, as in Python.
95
104
 
96
105
  | The body catches | Recorded | Fails the attempt |
97
106
  |---|---|---|
98
- | a failed `expect(…)` | a failed check | yes, when the body ends |
107
+ | a failed `expect.require(…)` | a failed check | yes, when the body ends |
99
108
  | a failed `assert` | nothing | no |
100
109
  | neither (it escapes) | a failed check | yes |
101
110
 
102
111
  So retry with `expect.poll`, which retries the matcher and records only its final outcome, or with
103
- a plain `assert` or `if` in the loop, never `expect` in `try`/`except`:
112
+ a plain `assert` or `if` in the loop, never `expect.require` in `try`/`except`:
104
113
 
105
114
  ```python
106
115
  # Retries the command until it succeeds, for up to 10 seconds: one check.
@@ -136,6 +145,13 @@ duration is seconds or a `timedelta`: `{"timeout": 90}`, `docker(start_timeout=t
136
145
  `expect.poll(…, timeout=10)`. `docker()`, `fake_harness()`, `fake_judge()` and `plugin.*` return
137
146
  values to pass as options, not data to edit.
138
147
 
148
+ `c.judge` takes the inputs the judge reads as keywords, and needs at least one: `diff=True`,
149
+ `contents=["src/**"]`, `output=True` with `on=result`, and so on. With none it raises `TypeError`.
150
+
151
+ ```python
152
+ expect(c.judge("Is it valid JSON?", on=result, output=True)).to_pass()
153
+ ```
154
+
139
155
  ### `def` and `async def` bodies
140
156
 
141
157
  A `def` body gets a blocking context: `c.exec(…)` runs the command and returns its `ExecResult`,
@@ -0,0 +1,22 @@
1
+ reeval_python/__init__.py,sha256=EjoZRdxQwnpazy5U49o2IWczzh7gzVUGJDssbXyY30Q,1356
2
+ reeval_python/__main__.py,sha256=opVNjZHR3dLJnP_p528E5oz8E-oow6606wwPZ0L0Mto,282
3
+ reeval_python/_wire.py,sha256=hvt5lAGoUP_2bHrlLzXAy9i3arzAwrQIbNxZ-ykzuBc,84679
4
+ reeval_python/aio.py,sha256=yyi09fi_Bt7N704HRcRJLTGmNHcxyD3bFwevPcMa_Z4,421
5
+ reeval_python/binaries.json,sha256=XhI3O7ULc2mRJLKkfjZpJaDlOE6ltEqhKY3vOKhF9As,1902
6
+ reeval_python/checks.py,sha256=gYSpLMzMMvZ_neV5siB9cLpUfOwSbax6tj-N8N57NNE,11078
7
+ reeval_python/cli.py,sha256=qyXObxNbWoisgQCo0tEhqDh0oM141dQ77Jqung60Vv0,18953
8
+ reeval_python/context.py,sha256=nwALo7CvcJ8ite98vq_MdYOK23hbX2xhc7Ucwo_C698,16902
9
+ reeval_python/declare.py,sha256=T2BMiNUoKwDMIzUKlofdFRs8vn8uldu3JXgwzeZiyK0,20185
10
+ reeval_python/environment.py,sha256=9GYE6j2M0xoITBpbg5oU1_9e87guOPo-YNNNVy_Stb0,6261
11
+ reeval_python/errors.py,sha256=wgwjeVoZImkIuKC2GiYK6ahar85glpOmDAWKRg6cowY,894
12
+ reeval_python/expect.py,sha256=M_0YWpWl-l-g2KFRrxzr9XtD8SV82JlHPFhlR9CVVoQ,10928
13
+ reeval_python/options.py,sha256=yA2j8ylRpHMkRKS45cFakoVP7l24RP_gYft_PEX1Xhw,3437
14
+ reeval_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ reeval_python/runner.py,sha256=bNwRfHQdeM0PC113G5d0RzFRtHcFMMLj8bE3cnoZKII,21070
16
+ reeval_python/types.py,sha256=Ycy9KwhmtSfYKTny-DFbshBRkvxDlSA-g_fRakZZN5Q,3342
17
+ reeval_python/wire.py,sha256=ONOx_4Jlr6QNk_4pX7DaJHgEe8qBBO8AiYd0H9ogwW4,7129
18
+ reeval_python-0.17.0.dist-info/METADATA,sha256=JZmUkap0nkePxDPG8_X4_HrBwzyKQD9lOpncqBCbDtI,10022
19
+ reeval_python-0.17.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
20
+ reeval_python-0.17.0.dist-info/entry_points.txt,sha256=174mqsaUhMzSZlbOUgyM8P_YN-VXmrGcU8F3H-6Eu7g,50
21
+ reeval_python-0.17.0.dist-info/licenses/LICENSE,sha256=ksfhGdGZnBIw2o77d0o71LHzgK-bRGUx1qS6nzYMjK4,11348
22
+ reeval_python-0.17.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.4
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,22 +0,0 @@
1
- reeval_python/__init__.py,sha256=0mcMjb-43i_UQbuqDKrbt8NFchNIbfHJOXB9qETgfu8,1352
2
- reeval_python/__main__.py,sha256=opVNjZHR3dLJnP_p528E5oz8E-oow6606wwPZ0L0Mto,282
3
- reeval_python/_wire.py,sha256=uz2pRTFRw2PGs6BYNbAJgksNMxdkK0xcNwp54l5e85k,82437
4
- reeval_python/aio.py,sha256=jMZmlD3pq9dlkSRxRajfurD-aJhDZMGVLkq53xrMfLs,603
5
- reeval_python/binaries.json,sha256=o7MoimvWkXITE4p2VVW0JKG3CJmjiGVOoR3TBBC6mUE,1902
6
- reeval_python/checks.py,sha256=aErhwCrt8cCtWpyDq9kPuypv7qI4w3uZeFWgB9ogLJo,10717
7
- reeval_python/cli.py,sha256=qyXObxNbWoisgQCo0tEhqDh0oM141dQ77Jqung60Vv0,18953
8
- reeval_python/context.py,sha256=tOw2an2Ma8e6K8Igw5VjroUfpbuxGOq5Mt-rYqFtwQo,15825
9
- reeval_python/declare.py,sha256=T2BMiNUoKwDMIzUKlofdFRs8vn8uldu3JXgwzeZiyK0,20185
10
- reeval_python/environment.py,sha256=9GYE6j2M0xoITBpbg5oU1_9e87guOPo-YNNNVy_Stb0,6261
11
- reeval_python/errors.py,sha256=wgwjeVoZImkIuKC2GiYK6ahar85glpOmDAWKRg6cowY,894
12
- reeval_python/expect.py,sha256=ti8k2J-FX7W-FreI302yh8gkXrUld0B16_r9bq8R7Ck,9704
13
- reeval_python/options.py,sha256=x5W-2FZ4iH4ipWypUb64_85v9tx4CAo6IhCTgn6Mx8s,2180
14
- reeval_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- reeval_python/runner.py,sha256=bNwRfHQdeM0PC113G5d0RzFRtHcFMMLj8bE3cnoZKII,21070
16
- reeval_python/types.py,sha256=Ycy9KwhmtSfYKTny-DFbshBRkvxDlSA-g_fRakZZN5Q,3342
17
- reeval_python/wire.py,sha256=ONOx_4Jlr6QNk_4pX7DaJHgEe8qBBO8AiYd0H9ogwW4,7129
18
- reeval_python-0.15.1.dist-info/METADATA,sha256=JWO7NPgn3i_b47FGOTa09b8fb9Epb388Zu411apE0gA,9303
19
- reeval_python-0.15.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
20
- reeval_python-0.15.1.dist-info/entry_points.txt,sha256=174mqsaUhMzSZlbOUgyM8P_YN-VXmrGcU8F3H-6Eu7g,50
21
- reeval_python-0.15.1.dist-info/licenses/LICENSE,sha256=ksfhGdGZnBIw2o77d0o71LHzgK-bRGUx1qS6nzYMjK4,11348
22
- reeval_python-0.15.1.dist-info/RECORD,,