casebench 0.1.0__tar.gz

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.
Files changed (242) hide show
  1. casebench-0.1.0/LICENSE +211 -0
  2. casebench-0.1.0/PKG-INFO +82 -0
  3. casebench-0.1.0/README.md +45 -0
  4. casebench-0.1.0/casebench/__init__.py +5 -0
  5. casebench-0.1.0/casebench/capture/__init__.py +1 -0
  6. casebench-0.1.0/casebench/capture/assemble.py +92 -0
  7. casebench-0.1.0/casebench/capture/backend.py +47 -0
  8. casebench-0.1.0/casebench/capture/cli.py +36 -0
  9. casebench-0.1.0/casebench/capture/config.py +28 -0
  10. casebench-0.1.0/casebench/capture/conformance.py +33 -0
  11. casebench-0.1.0/casebench/capture/context.py +53 -0
  12. casebench-0.1.0/casebench/capture/corpus_routes.py +50 -0
  13. casebench-0.1.0/casebench/capture/functions.py +115 -0
  14. casebench-0.1.0/casebench/capture/interface.py +23 -0
  15. casebench-0.1.0/casebench/capture/otlp/__init__.py +1 -0
  16. casebench-0.1.0/casebench/capture/otlp/decode.py +82 -0
  17. casebench-0.1.0/casebench/capture/otlp/mapping.py +105 -0
  18. casebench-0.1.0/casebench/capture/parsers/__init__.py +1 -0
  19. casebench-0.1.0/casebench/capture/parsers/anthropic/__init__.py +86 -0
  20. casebench-0.1.0/casebench/capture/parsers/anthropic/casebench-plugin.json +5 -0
  21. casebench-0.1.0/casebench/capture/parsers/anthropic/samples/plain-with-tool-result.json +76 -0
  22. casebench-0.1.0/casebench/capture/parsers/anthropic/samples/streamed-tool-call.json +97 -0
  23. casebench-0.1.0/casebench/capture/parsers/gemini/__init__.py +77 -0
  24. casebench-0.1.0/casebench/capture/parsers/gemini/casebench-plugin.json +5 -0
  25. casebench-0.1.0/casebench/capture/parsers/gemini/samples/plain-with-function-response.json +86 -0
  26. casebench-0.1.0/casebench/capture/parsers/gemini/samples/streamed-function-call.json +86 -0
  27. casebench-0.1.0/casebench/capture/parsers/openai/__init__.py +106 -0
  28. casebench-0.1.0/casebench/capture/parsers/openai/casebench-plugin.json +5 -0
  29. casebench-0.1.0/casebench/capture/parsers/openai/samples/plain-with-tool-result.json +72 -0
  30. casebench-0.1.0/casebench/capture/parsers/openai/samples/streamed-tool-call.json +104 -0
  31. casebench-0.1.0/casebench/capture/proxy/__init__.py +1 -0
  32. casebench-0.1.0/casebench/capture/proxy/forward.py +143 -0
  33. casebench-0.1.0/casebench/capture/proxy/redact.py +18 -0
  34. casebench-0.1.0/casebench/capture/proxy/routes.py +45 -0
  35. casebench-0.1.0/casebench/capture/proxy/server.py +38 -0
  36. casebench-0.1.0/casebench/capture/proxy/sse.py +23 -0
  37. casebench-0.1.0/casebench/capture/read.py +17 -0
  38. casebench-0.1.0/casebench/capture/recorder.py +82 -0
  39. casebench-0.1.0/casebench/capture/redirect.py +83 -0
  40. casebench-0.1.0/casebench/capture/routing.py +16 -0
  41. casebench-0.1.0/casebench/capture/session.py +165 -0
  42. casebench-0.1.0/casebench/capture/sizes.py +11 -0
  43. casebench-0.1.0/casebench/capture/step.py +75 -0
  44. casebench-0.1.0/casebench/cases/__init__.py +1 -0
  45. casebench-0.1.0/casebench/cases/build.py +98 -0
  46. casebench-0.1.0/casebench/cases/cli.py +214 -0
  47. casebench-0.1.0/casebench/cases/draft.py +42 -0
  48. casebench-0.1.0/casebench/cases/resolve.py +39 -0
  49. casebench-0.1.0/casebench/cases/suite.py +31 -0
  50. casebench-0.1.0/casebench/cli.py +60 -0
  51. casebench-0.1.0/casebench/config.py +128 -0
  52. casebench-0.1.0/casebench/core/__init__.py +1 -0
  53. casebench-0.1.0/casebench/core/canonical.py +20 -0
  54. casebench-0.1.0/casebench/core/case.py +140 -0
  55. casebench-0.1.0/casebench/core/jurisdiction.py +57 -0
  56. casebench-0.1.0/casebench/core/model.py +15 -0
  57. casebench-0.1.0/casebench/core/score.py +95 -0
  58. casebench-0.1.0/casebench/corpus/__init__.py +1 -0
  59. casebench-0.1.0/casebench/corpus/add.py +115 -0
  60. casebench-0.1.0/casebench/corpus/add_cli.py +607 -0
  61. casebench-0.1.0/casebench/corpus/binding.py +122 -0
  62. casebench-0.1.0/casebench/corpus/bundled.py +75 -0
  63. casebench-0.1.0/casebench/corpus/cache.py +118 -0
  64. casebench-0.1.0/casebench/corpus/check.py +77 -0
  65. casebench-0.1.0/casebench/corpus/cli.py +105 -0
  66. casebench-0.1.0/casebench/corpus/conformance.py +43 -0
  67. casebench-0.1.0/casebench/corpus/connectors/__init__.py +1 -0
  68. casebench-0.1.0/casebench/corpus/connectors/folder/__init__.py +68 -0
  69. casebench-0.1.0/casebench/corpus/connectors/folder/casebench-plugin.json +5 -0
  70. casebench-0.1.0/casebench/corpus/connectors/folder/samples/README.md +4 -0
  71. casebench-0.1.0/casebench/corpus/connectors/folder/samples/config.json +1 -0
  72. casebench-0.1.0/casebench/corpus/connectors/folder/samples/corpus/sample-1.json +1 -0
  73. casebench-0.1.0/casebench/corpus/connectors/folder/samples/corpus/sample-2.json +1 -0
  74. casebench-0.1.0/casebench/corpus/connectors/http/__init__.py +86 -0
  75. casebench-0.1.0/casebench/corpus/connectors/mcp/__init__.py +170 -0
  76. casebench-0.1.0/casebench/corpus/corpora.py +76 -0
  77. casebench-0.1.0/casebench/corpus/from_profile.py +135 -0
  78. casebench-0.1.0/casebench/corpus/guard.py +39 -0
  79. casebench-0.1.0/casebench/corpus/ids.py +21 -0
  80. casebench-0.1.0/casebench/corpus/interface.py +56 -0
  81. casebench-0.1.0/casebench/corpus/mapping.py +24 -0
  82. casebench-0.1.0/casebench/corpus/passage.py +55 -0
  83. casebench-0.1.0/casebench/corpus/probe_cli.py +77 -0
  84. casebench-0.1.0/casebench/corpus/profile.py +55 -0
  85. casebench-0.1.0/casebench/corpus/profiles/README.md +13 -0
  86. casebench-0.1.0/casebench/corpus/record.py +27 -0
  87. casebench-0.1.0/casebench/corpus/results.py +56 -0
  88. casebench-0.1.0/casebench/corpus/routing.py +69 -0
  89. casebench-0.1.0/casebench/corpus/suggest.py +80 -0
  90. casebench-0.1.0/casebench/envfiles.py +94 -0
  91. casebench-0.1.0/casebench/exporters/__init__.py +1 -0
  92. casebench-0.1.0/casebench/exporters/interface.py +11 -0
  93. casebench-0.1.0/casebench/extract/__init__.py +1 -0
  94. casebench-0.1.0/casebench/extract/agreement.py +52 -0
  95. casebench-0.1.0/casebench/extract/cli.py +150 -0
  96. casebench-0.1.0/casebench/extract/compare.py +58 -0
  97. casebench-0.1.0/casebench/extract/config.py +19 -0
  98. casebench-0.1.0/casebench/extract/estimate.py +93 -0
  99. casebench-0.1.0/casebench/extract/prompt.py +30 -0
  100. casebench-0.1.0/casebench/extract/reading.py +54 -0
  101. casebench-0.1.0/casebench/extract/run.py +162 -0
  102. casebench-0.1.0/casebench/formats/__init__.py +1 -0
  103. casebench-0.1.0/casebench/formats/extensions.py +20 -0
  104. casebench-0.1.0/casebench/formats/files.py +28 -0
  105. casebench-0.1.0/casebench/formats/read.py +39 -0
  106. casebench-0.1.0/casebench/formats/registry.py +47 -0
  107. casebench-0.1.0/casebench/formats/schema.py +29 -0
  108. casebench-0.1.0/casebench/formats/schema_cli.py +38 -0
  109. casebench-0.1.0/casebench/formats/schemas/case/1.0.json +320 -0
  110. casebench-0.1.0/casebench/formats/schemas/document/1.0.json +57 -0
  111. casebench-0.1.0/casebench/formats/schemas/index.json +3 -0
  112. casebench-0.1.0/casebench/formats/schemas/profile/1.0.json +142 -0
  113. casebench-0.1.0/casebench/formats/schemas/report/1.0.json +819 -0
  114. casebench-0.1.0/casebench/formats/schemas/suite/1.0.json +84 -0
  115. casebench-0.1.0/casebench/formats/validate_cli.py +96 -0
  116. casebench-0.1.0/casebench/formats/version.py +62 -0
  117. casebench-0.1.0/casebench/judge/__init__.py +1 -0
  118. casebench-0.1.0/casebench/judge/budget.py +33 -0
  119. casebench-0.1.0/casebench/judge/client.py +85 -0
  120. casebench-0.1.0/casebench/judge/config.py +33 -0
  121. casebench-0.1.0/casebench/judge/judges.py +21 -0
  122. casebench-0.1.0/casebench/judge/memo.py +37 -0
  123. casebench-0.1.0/casebench/judge/prompts.py +81 -0
  124. casebench-0.1.0/casebench/judge/resolve.py +135 -0
  125. casebench-0.1.0/casebench/key_record.py +37 -0
  126. casebench-0.1.0/casebench/keys.py +48 -0
  127. casebench-0.1.0/casebench/loading.py +70 -0
  128. casebench-0.1.0/casebench/metrics/__init__.py +1 -0
  129. casebench-0.1.0/casebench/metrics/authorities.py +102 -0
  130. casebench-0.1.0/casebench/metrics/base.py +73 -0
  131. casebench-0.1.0/casebench/metrics/builtin/__init__.py +1 -0
  132. casebench-0.1.0/casebench/metrics/builtin/citation_integrity/__init__.py +102 -0
  133. casebench-0.1.0/casebench/metrics/builtin/criteria/__init__.py +53 -0
  134. casebench-0.1.0/casebench/metrics/builtin/outcome/__init__.py +45 -0
  135. casebench-0.1.0/casebench/metrics/builtin/precedent/__init__.py +8 -0
  136. casebench-0.1.0/casebench/metrics/builtin/statute/__init__.py +8 -0
  137. casebench-0.1.0/casebench/metrics/criteria.py +94 -0
  138. casebench-0.1.0/casebench/metrics/loading.py +31 -0
  139. casebench-0.1.0/casebench/plugins/__init__.py +1 -0
  140. casebench-0.1.0/casebench/plugins/cli.py +66 -0
  141. casebench-0.1.0/casebench/plugins/conformance.py +90 -0
  142. casebench-0.1.0/casebench/plugins/kinds.py +67 -0
  143. casebench-0.1.0/casebench/plugins/manifest.py +59 -0
  144. casebench-0.1.0/casebench/plugins/registry.py +67 -0
  145. casebench-0.1.0/casebench/plugins/samples.py +43 -0
  146. casebench-0.1.0/casebench/plugins/scaffold.py +111 -0
  147. casebench-0.1.0/casebench/plugins/templates.py +130 -0
  148. casebench-0.1.0/casebench/providers/__init__.py +1 -0
  149. casebench-0.1.0/casebench/providers/builtin/__init__.py +1 -0
  150. casebench-0.1.0/casebench/providers/builtin/anthropic/__init__.py +72 -0
  151. casebench-0.1.0/casebench/providers/builtin/anthropic/casebench-plugin.json +5 -0
  152. casebench-0.1.0/casebench/providers/builtin/anthropic/samples/config.json +1 -0
  153. casebench-0.1.0/casebench/providers/builtin/anthropic/samples/list.json +38 -0
  154. casebench-0.1.0/casebench/providers/builtin/azure/__init__.py +60 -0
  155. casebench-0.1.0/casebench/providers/builtin/bedrock/__init__.py +66 -0
  156. casebench-0.1.0/casebench/providers/builtin/google/__init__.py +65 -0
  157. casebench-0.1.0/casebench/providers/builtin/openai/__init__.py +64 -0
  158. casebench-0.1.0/casebench/providers/builtin/openai/casebench-plugin.json +5 -0
  159. casebench-0.1.0/casebench/providers/builtin/openai/samples/list.json +35 -0
  160. casebench-0.1.0/casebench/providers/call.py +44 -0
  161. casebench-0.1.0/casebench/providers/conformance.py +38 -0
  162. casebench-0.1.0/casebench/providers/interface.py +57 -0
  163. casebench-0.1.0/casebench/providers/send.py +86 -0
  164. casebench-0.1.0/casebench/providers/settings.py +31 -0
  165. casebench-0.1.0/casebench/py.typed +0 -0
  166. casebench-0.1.0/casebench/references/__init__.py +1 -0
  167. casebench-0.1.0/casebench/references/court.py +43 -0
  168. casebench-0.1.0/casebench/references/interface.py +12 -0
  169. casebench-0.1.0/casebench/report/__init__.py +1 -0
  170. casebench-0.1.0/casebench/report/agreement.py +32 -0
  171. casebench-0.1.0/casebench/report/baselines.py +24 -0
  172. casebench-0.1.0/casebench/report/citations.py +24 -0
  173. casebench-0.1.0/casebench/report/cli.py +89 -0
  174. casebench-0.1.0/casebench/report/comparable.py +71 -0
  175. casebench-0.1.0/casebench/report/compare.py +45 -0
  176. casebench-0.1.0/casebench/report/funnel.py +156 -0
  177. casebench-0.1.0/casebench/report/record.py +49 -0
  178. casebench-0.1.0/casebench/report/render.py +142 -0
  179. casebench-0.1.0/casebench/report/statistics.py +60 -0
  180. casebench-0.1.0/casebench/report/tables.py +99 -0
  181. casebench-0.1.0/casebench/runs/__init__.py +1 -0
  182. casebench-0.1.0/casebench/runs/cli.py +175 -0
  183. casebench-0.1.0/casebench/runs/dry_run.py +128 -0
  184. casebench-0.1.0/casebench/runs/log.py +136 -0
  185. casebench-0.1.0/casebench/runs/producer.py +74 -0
  186. casebench-0.1.0/casebench/runs/progress.py +32 -0
  187. casebench-0.1.0/casebench/runs/rescore.py +69 -0
  188. casebench-0.1.0/casebench/runs/runner.py +89 -0
  189. casebench-0.1.0/casebench/runs/scoring.py +152 -0
  190. casebench-0.1.0/casebench/setup/__init__.py +1 -0
  191. casebench-0.1.0/casebench/setup/advice.py +30 -0
  192. casebench-0.1.0/casebench/setup/catalog.py +112 -0
  193. casebench-0.1.0/casebench/setup/check_cli.py +74 -0
  194. casebench-0.1.0/casebench/setup/checks.py +264 -0
  195. casebench-0.1.0/casebench/setup/corpus_question.py +216 -0
  196. casebench-0.1.0/casebench/setup/guide.md +142 -0
  197. casebench-0.1.0/casebench/setup/guide_cli.py +38 -0
  198. casebench-0.1.0/casebench/setup/init_cli.py +437 -0
  199. casebench-0.1.0/casebench/setup/judge_question.py +89 -0
  200. casebench-0.1.0/casebench/setup/key_question.py +136 -0
  201. casebench-0.1.0/casebench/setup/keys_cli.py +58 -0
  202. casebench-0.1.0/casebench/setup/models.py +68 -0
  203. casebench-0.1.0/casebench/setup/models_cli.py +56 -0
  204. casebench-0.1.0/casebench/setup/picker.py +112 -0
  205. casebench-0.1.0/casebench/setup/routes.py +106 -0
  206. casebench-0.1.0/casebench/setup/scan.py +276 -0
  207. casebench-0.1.0/casebench/setup/screen.py +109 -0
  208. casebench-0.1.0/casebench/setup/sdks.py +76 -0
  209. casebench-0.1.0/casebench/setup/summary.py +79 -0
  210. casebench-0.1.0/casebench/setup/update.py +80 -0
  211. casebench-0.1.0/casebench/suites/__init__.py +1 -0
  212. casebench-0.1.0/casebench/suites/cli.py +133 -0
  213. casebench-0.1.0/casebench/suites/court.py +143 -0
  214. casebench-0.1.0/casebench/suites/freeze.py +147 -0
  215. casebench-0.1.0/casebench/suites/generate.py +41 -0
  216. casebench-0.1.0/casebench/suites/qualify.py +36 -0
  217. casebench-0.1.0/casebench/suites/resolve.py +52 -0
  218. casebench-0.1.0/casebench/targets/__init__.py +1 -0
  219. casebench-0.1.0/casebench/targets/answer.py +32 -0
  220. casebench-0.1.0/casebench/targets/builtin/__init__.py +1 -0
  221. casebench-0.1.0/casebench/targets/builtin/command/__init__.py +52 -0
  222. casebench-0.1.0/casebench/targets/builtin/command/casebench-plugin.json +5 -0
  223. casebench-0.1.0/casebench/targets/builtin/command/samples/config.json +1 -0
  224. casebench-0.1.0/casebench/targets/builtin/http/__init__.py +105 -0
  225. casebench-0.1.0/casebench/targets/builtin/http/casebench-plugin.json +5 -0
  226. casebench-0.1.0/casebench/targets/builtin/http/samples/config.json +1 -0
  227. casebench-0.1.0/casebench/targets/builtin/python/__init__.py +144 -0
  228. casebench-0.1.0/casebench/targets/builtin/python/casebench-plugin.json +5 -0
  229. casebench-0.1.0/casebench/targets/builtin/python/entry.py +30 -0
  230. casebench-0.1.0/casebench/targets/builtin/python/framing.py +31 -0
  231. casebench-0.1.0/casebench/targets/builtin/python/samples/config.json +1 -0
  232. casebench-0.1.0/casebench/targets/builtin/python/trace_context.py +21 -0
  233. casebench-0.1.0/casebench/targets/builtin/python/worker.py +57 -0
  234. casebench-0.1.0/casebench/targets/cli.py +53 -0
  235. casebench-0.1.0/casebench/targets/interface.py +22 -0
  236. casebench-0.1.0/casebench/targets/load.py +19 -0
  237. casebench-0.1.0/casebench/targets/placeholders.py +63 -0
  238. casebench-0.1.0/casebench/targets/sample.py +34 -0
  239. casebench-0.1.0/casebench/tasks/__init__.py +1 -0
  240. casebench-0.1.0/casebench/tasks/interface.py +16 -0
  241. casebench-0.1.0/pyproject.toml +139 -0
  242. casebench-0.1.0/pyproject.toml.orig +117 -0
@@ -0,0 +1,211 @@
1
+ Copyright (c) the Casebench maintainers.
2
+
3
+ Portions of this software are licensed as follows:
4
+
5
+ - All content that resides under the "ee/" directory of this repository is
6
+ licensed under the license defined in "ee/LICENSE".
7
+ - All third-party components incorporated into this software are licensed
8
+ under the original license provided by the owner of the applicable component.
9
+ - All other content is licensed under the Apache License, Version 2.0, below.
10
+
11
+ Apache License
12
+ Version 2.0, January 2004
13
+ http://www.apache.org/licenses/
14
+
15
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
16
+
17
+ 1. Definitions.
18
+
19
+ "License" shall mean the terms and conditions for use, reproduction,
20
+ and distribution as defined by Sections 1 through 9 of this document.
21
+
22
+ "Licensor" shall mean the copyright owner or entity authorized by
23
+ the copyright owner that is granting the License.
24
+
25
+ "Legal Entity" shall mean the union of the acting entity and all
26
+ other entities that control, are controlled by, or are under common
27
+ control with that entity. For the purposes of this definition,
28
+ "control" means (i) the power, direct or indirect, to cause the
29
+ direction or management of such entity, whether by contract or
30
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
31
+ outstanding shares, or (iii) beneficial ownership of such entity.
32
+
33
+ "You" (or "Your") shall mean an individual or Legal Entity
34
+ exercising permissions granted by this License.
35
+
36
+ "Source" form shall mean the preferred form for making modifications,
37
+ including but not limited to software source code, documentation
38
+ source, and configuration files.
39
+
40
+ "Object" form shall mean any form resulting from mechanical
41
+ transformation or translation of a Source form, including but
42
+ not limited to compiled object code, generated documentation,
43
+ and conversions to other media types.
44
+
45
+ "Work" shall mean the work of authorship, whether in Source or
46
+ Object form, made available under the License, as indicated by a
47
+ copyright notice that is included in or attached to the work
48
+ (an example is provided in the Appendix below).
49
+
50
+ "Derivative Works" shall mean any work, whether in Source or Object
51
+ form, that is based on (or derived from) the Work and for which the
52
+ editorial revisions, annotations, elaborations, or other modifications
53
+ represent, as a whole, an original work of authorship. For the purposes
54
+ of this License, Derivative Works shall not include works that remain
55
+ separable from, or merely link (or bind by name) to the interfaces of,
56
+ the Work and Derivative Works thereof.
57
+
58
+ "Contribution" shall mean any work of authorship, including
59
+ the original version of the Work and any modifications or additions
60
+ to that Work or Derivative Works thereof, that is intentionally
61
+ submitted to Licensor for inclusion in the Work by the copyright owner
62
+ or by an individual or Legal Entity authorized to submit on behalf of
63
+ the copyright owner. For the purposes of this definition, "submitted"
64
+ means any form of electronic, verbal, or written communication sent
65
+ to the Licensor or its representatives, including but not limited to
66
+ communication on electronic mailing lists, source code control systems,
67
+ and issue tracking systems that are managed by, or on behalf of, the
68
+ Licensor for the purpose of discussing and improving the Work, but
69
+ excluding communication that is conspicuously marked or otherwise
70
+ designated in writing by the copyright owner as "Not a Contribution."
71
+
72
+ "Contributor" shall mean Licensor and any individual or Legal Entity
73
+ on behalf of whom a Contribution has been received by Licensor and
74
+ subsequently incorporated within the Work.
75
+
76
+ 2. Grant of Copyright License. Subject to the terms and conditions of
77
+ this License, each Contributor hereby grants to You a perpetual,
78
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
79
+ copyright license to reproduce, prepare Derivative Works of,
80
+ publicly display, publicly perform, sublicense, and distribute the
81
+ Work and such Derivative Works in Source or Object form.
82
+
83
+ 3. Grant of Patent License. Subject to the terms and conditions of
84
+ this License, each Contributor hereby grants to You a perpetual,
85
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
86
+ (except as stated in this section) patent license to make, have made,
87
+ use, offer to sell, sell, import, and otherwise transfer the Work,
88
+ where such license applies only to those patent claims licensable
89
+ by such Contributor that are necessarily infringed by their
90
+ Contribution(s) alone or by combination of their Contribution(s)
91
+ with the Work to which such Contribution(s) was submitted. If You
92
+ institute patent litigation against any entity (including a
93
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
94
+ or a Contribution incorporated within the Work constitutes direct
95
+ or contributory patent infringement, then any patent licenses
96
+ granted to You under this License for that Work shall terminate
97
+ as of the date such litigation is filed.
98
+
99
+ 4. Redistribution. You may reproduce and distribute copies of the
100
+ Work or Derivative Works thereof in any medium, with or without
101
+ modifications, and in Source or Object form, provided that You
102
+ meet the following conditions:
103
+
104
+ (a) You must give any other recipients of the Work or
105
+ Derivative Works a copy of this License; and
106
+
107
+ (b) You must cause any modified files to carry prominent notices
108
+ stating that You changed the files; and
109
+
110
+ (c) You must retain, in the Source form of any Derivative Works
111
+ that You distribute, all copyright, patent, trademark, and
112
+ attribution notices from the Source form of the Work,
113
+ excluding those notices that do not pertain to any part of
114
+ the Derivative Works; and
115
+
116
+ (d) If the Work includes a "NOTICE" text file as part of its
117
+ distribution, then any Derivative Works that You distribute must
118
+ include a readable copy of the attribution notices contained
119
+ within such NOTICE file, excluding those notices that do not
120
+ pertain to any part of the Derivative Works, in at least one
121
+ of the following places: within a NOTICE text file distributed
122
+ as part of the Derivative Works; within the Source form or
123
+ documentation, if provided along with the Derivative Works; or,
124
+ within a display generated by the Derivative Works, if and
125
+ wherever such third-party notices normally appear. The contents
126
+ of the NOTICE file are for informational purposes only and
127
+ do not modify the License. You may add Your own attribution
128
+ notices within Derivative Works that You distribute, alongside
129
+ or as an addendum to the NOTICE text from the Work, provided
130
+ that such additional attribution notices cannot be construed
131
+ as modifying the License.
132
+
133
+ You may add Your own copyright statement to Your modifications and
134
+ may provide additional or different license terms and conditions
135
+ for use, reproduction, or distribution of Your modifications, or
136
+ for any such Derivative Works as a whole, provided Your use,
137
+ reproduction, and distribution of the Work otherwise complies with
138
+ the conditions stated in this License.
139
+
140
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
141
+ any Contribution intentionally submitted for inclusion in the Work
142
+ by You to the Licensor shall be under the terms and conditions of
143
+ this License, without any additional terms or conditions.
144
+ Notwithstanding the above, nothing herein shall supersede or modify
145
+ the terms of any separate license agreement you may have executed
146
+ with Licensor regarding such Contributions.
147
+
148
+ 6. Trademarks. This License does not grant permission to use the trade
149
+ names, trademarks, service marks, or product names of the Licensor,
150
+ except as required for reasonable and customary use in describing the
151
+ origin of the Work and reproducing the content of the NOTICE file.
152
+
153
+ 7. Disclaimer of Warranty. Unless required by applicable law or
154
+ agreed to in writing, Licensor provides the Work (and each
155
+ Contributor provides its Contributions) on an "AS IS" BASIS,
156
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
157
+ implied, including, without limitation, any warranties or conditions
158
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
159
+ PARTICULAR PURPOSE. You are solely responsible for determining the
160
+ appropriateness of using or redistributing the Work and assume any
161
+ risks associated with Your exercise of permissions under this License.
162
+
163
+ 8. Limitation of Liability. In no event and under no legal theory,
164
+ whether in tort (including negligence), contract, or otherwise,
165
+ unless required by applicable law (such as deliberate and grossly
166
+ negligent acts) or agreed to in writing, shall any Contributor be
167
+ liable to You for damages, including any direct, indirect, special,
168
+ incidental, or consequential damages of any character arising as a
169
+ result of this License or out of the use or inability to use the
170
+ Work (including but not limited to damages for loss of goodwill,
171
+ work stoppage, computer failure or malfunction, or any and all
172
+ other commercial damages or losses), even if such Contributor
173
+ has been advised of the possibility of such damages.
174
+
175
+ 9. Accepting Warranty or Additional Liability. While redistributing
176
+ the Work or Derivative Works thereof, You may choose to offer,
177
+ and charge a fee for, acceptance of support, warranty, indemnity,
178
+ or other liability obligations and/or rights consistent with this
179
+ License. However, in accepting such obligations, You may act only
180
+ on Your own behalf and on Your sole responsibility, not on behalf
181
+ of any other Contributor, and only if You agree to indemnify,
182
+ defend, and hold each Contributor harmless for any liability
183
+ incurred by, or claims asserted against, such Contributor by reason
184
+ of your accepting any such warranty or additional liability.
185
+
186
+ END OF TERMS AND CONDITIONS
187
+
188
+ APPENDIX: How to apply the Apache License to your work.
189
+
190
+ To apply the Apache License to your work, attach the following
191
+ boilerplate notice, with the fields enclosed by brackets "[]"
192
+ replaced with your own identifying information. (Don't include
193
+ the brackets!) The text should be enclosed in the appropriate
194
+ comment syntax for the file format. We also recommend that a
195
+ file or class name and description of purpose be included on the
196
+ same "printed page" as the copyright notice for easier
197
+ identification within third-party archives.
198
+
199
+ Copyright [yyyy] [name of copyright owner]
200
+
201
+ Licensed under the Apache License, Version 2.0 (the "License");
202
+ you may not use this file except in compliance with the License.
203
+ You may obtain a copy of the License at
204
+
205
+ http://www.apache.org/licenses/LICENSE-2.0
206
+
207
+ Unless required by applicable law or agreed to in writing, software
208
+ distributed under the License is distributed on an "AS IS" BASIS,
209
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
210
+ See the License for the specific language governing permissions and
211
+ limitations under the License.
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: casebench
3
+ Version: 0.1.0
4
+ Summary: Measure the legal accuracy of an AI system against court decisions and lawyer-written references.
5
+ Keywords: legal,evaluation,llm,benchmark,citations
6
+ Author: Casebench maintainers
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 2 - Pre-Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Legal Industry
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Typing :: Typed
18
+ Requires-Dist: click>=8.5.0
19
+ Requires-Dist: httpx2>=2.13.1
20
+ Requires-Dist: jsonpath-ng>=1.10.0
21
+ Requires-Dist: mcp>=2.3.0
22
+ Requires-Dist: opentelemetry-proto>=1.45.1
23
+ Requires-Dist: packaging>=26.3
24
+ Requires-Dist: pydantic>=2.14.0
25
+ Requires-Dist: pyyaml>=6.0.3
26
+ Requires-Dist: questionary>=2.1.1
27
+ Requires-Dist: rich>=15.0.0
28
+ Requires-Dist: scikit-learn>=1.9.1
29
+ Requires-Dist: scipy>=1.17.1
30
+ Requires-Dist: starlette>=1.7.0
31
+ Requires-Dist: uvicorn>=0.54.0
32
+ Requires-Python: >=3.11
33
+ Project-URL: Repository, https://github.com/Frontier-Legal/casebench
34
+ Project-URL: Issues, https://github.com/Frontier-Legal/casebench/issues
35
+ Project-URL: Changelog, https://github.com/Frontier-Legal/casebench/blob/main/CHANGELOG.md
36
+ Description-Content-Type: text/markdown
37
+
38
+ # Casebench
39
+
40
+ Casebench measures the legal accuracy of an AI system against real court decisions and lawyer-written references, in any jurisdiction.
41
+
42
+ **Status:** early development. There is no release yet; it runs from this repository, as below, and the first release will be announced here. Casebench follows [SemVer](https://semver.org/), and while the version is 0.x any minor release may break the command line, the file formats or the Python interface. The changelog names every break.
43
+
44
+ ## What it will do
45
+
46
+ - Build evaluation cases from court decisions a team already holds: the ruling, the statutes applied and the precedents relied on, each fact pointing at a passage in the decision.
47
+ - Take lawyer-written cases from a spreadsheet, for question answering, research, drafting, editing and extraction tasks.
48
+ - Check every citation in every answer against the corpus: does the authority exist, and does it say what the answer claims?
49
+ - Show where in a multi-step system the right authority was lost: retrieved, kept, read, cited, characterised.
50
+ - Report per task, per metric and per reference source, with the failing example beside every rate. There is no single accuracy number.
51
+
52
+ ## Set it up
53
+
54
+ Paste this into the coding agent you use in your project:
55
+
56
+ > Set up Casebench for this project. Run `uvx --from git+https://github.com/Frontier-Legal/casebench casebench guide` and follow it.
57
+
58
+ The guide has the coding agent read your project and write two things: `casebench.yaml` and an adapter in `.casebench/` that starts your agent the way your production does. Nothing else in your project changes, and no key's value is read or written. It ends when `casebench check` passes, and it asks you one question: which judge model to pay for. Without a coding agent, `casebench init` asks the same things in the terminal.
59
+
60
+ ## Jurisdictions
61
+
62
+ Casebench works in any country with no country-specific code. Models read the decisions and the answers, and your corpus resolves every citation, whatever its format. A data provider that serves several countries needs one connector. [PLUGINS.md](PLUGINS.md) explains how to add a data provider or a model API.
63
+
64
+ ## Principles
65
+
66
+ - Nothing leaves your machines except calls to the system under test and the judge you configure. There is no telemetry.
67
+ - The grader never asks the system it grades.
68
+ - Every result reruns on your own corpus with the open-source code. A shared server, hosted or self-hosted, stores and shows results and never computes a score.
69
+ - Frontier Legal, which maintains Casebench, publishes no rankings of products, and neither does the project.
70
+
71
+ ## Documentation
72
+
73
+ - [docs/design/](docs/design/) describes how Casebench works.
74
+ - [docs/decisions/](docs/decisions/) records why it is built that way.
75
+
76
+ ## Contributing
77
+
78
+ See [CONTRIBUTING.md](CONTRIBUTING.md). The rules for changing the code are in [AGENTS.md](AGENTS.md). Everyone taking part follows the [code of conduct](CODE_OF_CONDUCT.md). Report security issues as [SECURITY.md](SECURITY.md) describes.
79
+
80
+ ## Licence
81
+
82
+ Apache-2.0, except the `ee/` directory, which holds the multi-user team server under its own source-available licence. [LICENSE](LICENSE) states the boundary.
@@ -0,0 +1,45 @@
1
+ # Casebench
2
+
3
+ Casebench measures the legal accuracy of an AI system against real court decisions and lawyer-written references, in any jurisdiction.
4
+
5
+ **Status:** early development. There is no release yet; it runs from this repository, as below, and the first release will be announced here. Casebench follows [SemVer](https://semver.org/), and while the version is 0.x any minor release may break the command line, the file formats or the Python interface. The changelog names every break.
6
+
7
+ ## What it will do
8
+
9
+ - Build evaluation cases from court decisions a team already holds: the ruling, the statutes applied and the precedents relied on, each fact pointing at a passage in the decision.
10
+ - Take lawyer-written cases from a spreadsheet, for question answering, research, drafting, editing and extraction tasks.
11
+ - Check every citation in every answer against the corpus: does the authority exist, and does it say what the answer claims?
12
+ - Show where in a multi-step system the right authority was lost: retrieved, kept, read, cited, characterised.
13
+ - Report per task, per metric and per reference source, with the failing example beside every rate. There is no single accuracy number.
14
+
15
+ ## Set it up
16
+
17
+ Paste this into the coding agent you use in your project:
18
+
19
+ > Set up Casebench for this project. Run `uvx --from git+https://github.com/Frontier-Legal/casebench casebench guide` and follow it.
20
+
21
+ The guide has the coding agent read your project and write two things: `casebench.yaml` and an adapter in `.casebench/` that starts your agent the way your production does. Nothing else in your project changes, and no key's value is read or written. It ends when `casebench check` passes, and it asks you one question: which judge model to pay for. Without a coding agent, `casebench init` asks the same things in the terminal.
22
+
23
+ ## Jurisdictions
24
+
25
+ Casebench works in any country with no country-specific code. Models read the decisions and the answers, and your corpus resolves every citation, whatever its format. A data provider that serves several countries needs one connector. [PLUGINS.md](PLUGINS.md) explains how to add a data provider or a model API.
26
+
27
+ ## Principles
28
+
29
+ - Nothing leaves your machines except calls to the system under test and the judge you configure. There is no telemetry.
30
+ - The grader never asks the system it grades.
31
+ - Every result reruns on your own corpus with the open-source code. A shared server, hosted or self-hosted, stores and shows results and never computes a score.
32
+ - Frontier Legal, which maintains Casebench, publishes no rankings of products, and neither does the project.
33
+
34
+ ## Documentation
35
+
36
+ - [docs/design/](docs/design/) describes how Casebench works.
37
+ - [docs/decisions/](docs/decisions/) records why it is built that way.
38
+
39
+ ## Contributing
40
+
41
+ See [CONTRIBUTING.md](CONTRIBUTING.md). The rules for changing the code are in [AGENTS.md](AGENTS.md). Everyone taking part follows the [code of conduct](CODE_OF_CONDUCT.md). Report security issues as [SECURITY.md](SECURITY.md) describes.
42
+
43
+ ## Licence
44
+
45
+ Apache-2.0, except the `ee/` directory, which holds the multi-user team server under its own source-available licence. [LICENSE](LICENSE) states the boundary.
@@ -0,0 +1,5 @@
1
+ """Measure the legal accuracy of an AI system against court decisions and lawyers' references."""
2
+
3
+ from importlib.metadata import version
4
+
5
+ __version__ = version("casebench")
@@ -0,0 +1 @@
1
+ """Capture: the step model and the parsers that read backend traffic."""
@@ -0,0 +1,92 @@
1
+ """Turn one case's exchanges into steps, pair tool calls and show unaccounted time."""
2
+
3
+ from collections.abc import Callable
4
+
5
+ from casebench.capture.read import ids_in
6
+ from casebench.capture.step import HttpExchange, Step, StepKind, ToolCall
7
+
8
+ ParseExchange = Callable[[HttpExchange], list[Step]]
9
+
10
+
11
+ def paired_tools(steps: list[Step]) -> list[Step]:
12
+ """A tool call asked for in one model response and answered in a later request is a tool
13
+ step: its name and arguments, the result's size, and the time between the two calls."""
14
+ pending: dict[str, tuple[ToolCall, float | None]] = {}
15
+ tools: list[Step] = []
16
+ for step in sorted((s for s in steps if s.kind is StepKind.LLM), key=_start):
17
+ for result in step.tool_results:
18
+ asked = pending.pop(result.id, None)
19
+ if asked is None:
20
+ continue
21
+ call, asked_at = asked
22
+ duration = _ms(asked_at, step.started)
23
+ tools.append(
24
+ Step(
25
+ kind=StepKind.TOOL,
26
+ name=call.name,
27
+ arguments=call.arguments,
28
+ result_size=result.size,
29
+ started=asked_at,
30
+ ended=step.started,
31
+ duration_ms=duration,
32
+ )
33
+ )
34
+ for call in step.requested_tools:
35
+ pending[call.id] = (call, step.ended)
36
+ return tools
37
+
38
+
39
+ def gaps(steps: list[Step]) -> list[Step]:
40
+ """Time between steps that no step covers, named after the steps on either side.
41
+ Gaps are reported to the millisecond, the resolution durations are shown in."""
42
+ timed = sorted((s for s in steps if s.started is not None and s.ended is not None), key=_start)
43
+ found: list[Step] = []
44
+ covered_until: float | None = None
45
+ before: Step | None = None
46
+ for step in timed:
47
+ assert step.started is not None and step.ended is not None
48
+ if covered_until is not None and before is not None:
49
+ missing = round((step.started - covered_until) * 1000)
50
+ if missing > 0:
51
+ found.append(
52
+ Step(
53
+ kind=StepKind.GAP,
54
+ name=f"between {_label(before)} and {_label(step)}",
55
+ started=covered_until,
56
+ ended=step.started,
57
+ duration_ms=float(missing),
58
+ )
59
+ )
60
+ if covered_until is None or step.ended > covered_until:
61
+ covered_until, before = step.ended, step
62
+ return found
63
+
64
+
65
+ def assemble(
66
+ exchanges: list[HttpExchange], parse: ParseExchange, in_process: list[Step]
67
+ ) -> list[Step]:
68
+ parsed = [(exchange, parse(exchange)) for exchange in exchanges]
69
+ known = {i for _, found in parsed for s in found for i in s.doc_ids_out}
70
+ known |= {i for s in in_process for i in s.doc_ids_out}
71
+ steps = [
72
+ step.model_copy(update={"doc_ids_in": ids_in(exchange.request_body, known)})
73
+ if step.kind is StepKind.LLM
74
+ else step
75
+ for exchange, found in parsed
76
+ for step in found
77
+ ] + list(in_process)
78
+ steps += paired_tools(steps)
79
+ steps += gaps(steps)
80
+ return sorted(steps, key=_start)
81
+
82
+
83
+ def _start(step: Step) -> float:
84
+ return step.started if step.started is not None else float("inf")
85
+
86
+
87
+ def _ms(start: float | None, end: float | None) -> float | None:
88
+ return (end - start) * 1000 if start is not None and end is not None else None
89
+
90
+
91
+ def _label(step: Step) -> str:
92
+ return f"{step.kind.value} {step.name or step.model or ''}".rstrip()
@@ -0,0 +1,47 @@
1
+ """Read a backend route's document ids by the JSONPath its config names, or from the path."""
2
+
3
+ import re
4
+ from typing import Any
5
+ from urllib.parse import unquote, urlsplit
6
+
7
+ from jsonpath_ng.ext.parser import parse as jsonpath
8
+
9
+ from casebench.capture.proxy.routes import Route
10
+ from casebench.capture.step import NO_DIAGNOSTIC, HttpExchange, Step, StepKind
11
+
12
+
13
+ def _ids(expression: str | None, document: Any) -> list[str]:
14
+ if expression is None or document is None:
15
+ return []
16
+ return [str(match.value) for match in jsonpath(expression).find(document)]
17
+
18
+
19
+ def fetched(route: Route, url: str) -> str | None:
20
+ """The id a request reads, when its path ends as the route's `fetch_path` does."""
21
+ if route.fetch_path is None or "{id}" not in route.fetch_path:
22
+ return None
23
+ before, _, after = route.fetch_path.partition("{id}")
24
+ pattern = re.escape(before) + r"([^/]+)" + re.escape(after) + "$"
25
+ found = re.search(pattern, urlsplit(url).path)
26
+ return unquote(found.group(1)) if found else None
27
+
28
+
29
+ def backend_step(exchange: HttpExchange, route: Route) -> Step:
30
+ """One retrieval, rerank or document fetch; without ids found, it says so."""
31
+ document_id = fetched(route, exchange.url)
32
+ if document_id is not None:
33
+ kind, ids_in, ids_out = StepKind.DOCUMENT, [], [document_id]
34
+ else:
35
+ kind = StepKind(route.step)
36
+ ids_out = _ids(route.doc_ids, exchange.response_body)
37
+ ids_in = _ids(route.doc_ids_in, exchange.request_body)
38
+ return Step(
39
+ kind=kind,
40
+ name=route.name,
41
+ doc_ids_in=ids_in,
42
+ doc_ids_out=ids_out,
43
+ started=exchange.started,
44
+ ended=exchange.ended,
45
+ duration_ms=exchange.duration_ms,
46
+ note=None if ids_out else NO_DIAGNOSTIC,
47
+ )
@@ -0,0 +1,36 @@
1
+ """`casebench proxy env`: the variables that point an already-running agent at the proxy."""
2
+
3
+ from pathlib import Path
4
+
5
+ import click
6
+
7
+ from casebench.capture.config import routes_for
8
+ from casebench.capture.proxy.routes import environment
9
+ from casebench.capture.session import TRACES_ENDPOINT, traces_endpoint
10
+ from casebench.config import DEFAULT_CONFIG, load_config
11
+
12
+
13
+ @click.group()
14
+ def proxy() -> None:
15
+ """The recording proxy that captures model and backend calls."""
16
+
17
+
18
+ @proxy.command()
19
+ @click.option(
20
+ "--config",
21
+ "config_path",
22
+ type=click.Path(dir_okay=False, path_type=Path),
23
+ default=DEFAULT_CONFIG,
24
+ show_default=True,
25
+ )
26
+ def env(config_path: Path) -> None:
27
+ """Print the lines to set in the agent's environment."""
28
+ config = load_config(config_path)
29
+ if config.capture is None or config.capture.port == 0:
30
+ raise click.ClickException(
31
+ "set capture.port in the config so an agent that is already running can reach "
32
+ "the proxy; when Casebench starts the agent it sets these itself"
33
+ )
34
+ for name, value in environment(routes_for(config.capture), config.capture.port).items():
35
+ click.echo(f"{name}={value}")
36
+ click.echo(f"{TRACES_ENDPOINT}={traces_endpoint(config.capture.port)}")
@@ -0,0 +1,28 @@
1
+ """The `capture:` section of casebench.yaml: the proxy's port and its routes."""
2
+
3
+ from typing import Any
4
+
5
+ from pydantic import Field
6
+
7
+ from casebench.capture.functions import StepFunction
8
+ from casebench.capture.proxy.routes import Route, default_routes
9
+ from casebench.core.model import Record
10
+
11
+
12
+ class CaptureConfig(Record):
13
+ """`port: 0` lets the operating system choose; name a port for an agent already running.
14
+ `traces: true` points the OpenTelemetry exporter of agents Casebench starts at it."""
15
+
16
+ port: int = 0
17
+ routes: list[dict[str, Any]] = Field(default_factory=list)
18
+ functions: list[StepFunction] = Field(default_factory=list)
19
+ traces: bool = False
20
+
21
+
22
+ def routes_for(capture: CaptureConfig | None) -> list[Route]:
23
+ """The parsers' default routes, with the config's fields laid over a route of the same
24
+ name, and the config's new routes added."""
25
+ merged = {route.name: route.model_dump() for route in default_routes()}
26
+ for route in capture.routes if capture else []:
27
+ merged[route["name"]] = {**merged.get(route["name"], {}), **route}
28
+ return [Route.model_validate(fields) for fields in merged.values()]
@@ -0,0 +1,33 @@
1
+ """Conformance for capture parsers, measured as the share of recorded calls parsed.
2
+
3
+ A sample is `{"exchange": <HTTP exchange>, "expected": [<step>, ...]}`.
4
+ """
5
+
6
+ from pathlib import Path
7
+
8
+ from casebench.capture.interface import CaptureParser
9
+ from casebench.capture.step import HttpExchange, Step
10
+ from casebench.plugins.samples import SuiteResult, ratio, read_json, sample_files
11
+
12
+
13
+ def check(parser: CaptureParser, samples: Path) -> SuiteResult:
14
+ result = SuiteResult()
15
+ parsed = 0
16
+ if not parser.hosts:
17
+ result.problems.append("hosts is empty, so no traffic would reach this parser")
18
+ for path in sample_files(samples):
19
+ result.samples += 1
20
+ sample = read_json(path)
21
+ exchange = HttpExchange.model_validate(sample["exchange"])
22
+ expected = [Step.model_validate(step) for step in sample["expected"]]
23
+ try:
24
+ steps = parser.parse(exchange)
25
+ except Exception as error:
26
+ result.problems.append(f"{path.name}: {type(error).__name__}: {error}")
27
+ continue
28
+ if not all(isinstance(step, Step) for step in steps):
29
+ result.problems.append(f"{path.name}: parse() must return Step records")
30
+ continue
31
+ parsed += steps == expected
32
+ result.figure = ratio(parsed, result.samples)
33
+ return result
@@ -0,0 +1,53 @@
1
+ """Tie every captured step to the case that caused it."""
2
+
3
+ from collections.abc import Iterator
4
+ from contextlib import contextmanager
5
+ from contextvars import ContextVar
6
+ from dataclasses import dataclass, field
7
+
8
+ from casebench.capture.step import Step
9
+
10
+
11
+ @dataclass
12
+ class CaseCapture:
13
+ case_id: str
14
+ traceparent: str | None = None
15
+ worker: str | None = None
16
+ steps: list[Step] = field(default_factory=list)
17
+
18
+
19
+ _current: ContextVar[CaseCapture | None] = ContextVar("casebench_case", default=None)
20
+
21
+
22
+ @contextmanager
23
+ def capturing(case_id: str, traceparent: str | None = None) -> Iterator[CaseCapture]:
24
+ """Steps recorded inside this block belong to this case, even with other cases
25
+ running at the same time, because each asyncio task and thread gets its own copy."""
26
+ capture = CaseCapture(case_id, traceparent)
27
+ token = _current.set(capture)
28
+ try:
29
+ yield capture
30
+ finally:
31
+ _current.reset(token)
32
+
33
+
34
+ def record(step: Step) -> bool:
35
+ """Attach a step to the running case; False when no case is running."""
36
+ capture = _current.get()
37
+ if capture is None:
38
+ return False
39
+ capture.steps.append(step)
40
+ return True
41
+
42
+
43
+ def current_traceparent() -> str | None:
44
+ """The running case's trace context, to pass on to an agent outside this process."""
45
+ capture = _current.get()
46
+ return capture.traceparent if capture is not None else None
47
+
48
+
49
+ def set_worker(worker: str) -> None:
50
+ """Note which worker process answers the running case, so its calls are found by path."""
51
+ capture = _current.get()
52
+ if capture is not None:
53
+ capture.worker = worker