agentinputlab 0.1.0a1__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.
Files changed (469) hide show
  1. agentinputlab/__init__.py +28 -0
  2. agentinputlab/algorithms/__init__.py +6 -0
  3. agentinputlab/algorithms/acquire/__init__.py +145 -0
  4. agentinputlab/algorithms/acquire/adaptive_rag/__init__.py +43 -0
  5. agentinputlab/algorithms/acquire/adaptive_rag/replay.py +367 -0
  6. agentinputlab/algorithms/acquire/adaptive_rag/runtime.py +1202 -0
  7. agentinputlab/algorithms/acquire/adaptive_rag_common_support.py +542 -0
  8. agentinputlab/algorithms/acquire/hyde.py +296 -0
  9. agentinputlab/algorithms/acquire/hyde_controlled.py +200 -0
  10. agentinputlab/algorithms/acquire/hyde_external.py +148 -0
  11. agentinputlab/algorithms/acquire/ircot.py +28 -0
  12. agentinputlab/algorithms/acquire/ircot_common_support.py +478 -0
  13. agentinputlab/algorithms/acquire/ircot_native.py +355 -0
  14. agentinputlab/algorithms/acquire/ircot_replay.py +327 -0
  15. agentinputlab/algorithms/acquire/qrag/__init__.py +79 -0
  16. agentinputlab/algorithms/acquire/qrag/bridge.py +828 -0
  17. agentinputlab/algorithms/acquire/qrag/common_support.py +891 -0
  18. agentinputlab/algorithms/acquire/qrag/native_axis.py +71 -0
  19. agentinputlab/algorithms/acquire/qrag/reader_adapter.py +139 -0
  20. agentinputlab/algorithms/acquire/r2ag/__init__.py +57 -0
  21. agentinputlab/algorithms/acquire/r2ag/bridge.py +1312 -0
  22. agentinputlab/algorithms/acquire/r2ag/common_support.py +1029 -0
  23. agentinputlab/algorithms/acquire/r2ag/socket_runtime.py +255 -0
  24. agentinputlab/algorithms/clarify/__init__.py +61 -0
  25. agentinputlab/algorithms/clarify/_structured.py +64 -0
  26. agentinputlab/algorithms/clarify/active_task_disambiguation.py +371 -0
  27. agentinputlab/algorithms/clarify/ask_or_assume/__init__.py +17 -0
  28. agentinputlab/algorithms/clarify/ask_or_assume/monitor.py +410 -0
  29. agentinputlab/algorithms/clarify/future_turns.py +379 -0
  30. agentinputlab/algorithms/clarify/udcs.py +255 -0
  31. agentinputlab/algorithms/clarify/udcs_deterministic.py +196 -0
  32. agentinputlab/algorithms/curate/__init__.py +65 -0
  33. agentinputlab/algorithms/curate/acon/__init__.py +27 -0
  34. agentinputlab/algorithms/curate/acon/common.py +284 -0
  35. agentinputlab/algorithms/curate/acon/common_support.py +136 -0
  36. agentinputlab/algorithms/curate/acon/history_bridge.py +309 -0
  37. agentinputlab/algorithms/curate/acon/observation_bridge.py +290 -0
  38. agentinputlab/algorithms/curate/llmlingua/__init__.py +30 -0
  39. agentinputlab/algorithms/curate/llmlingua/adapters.py +537 -0
  40. agentinputlab/algorithms/curate/llmlingua/budget.py +48 -0
  41. agentinputlab/algorithms/curate/llmlingua/controlled.py +175 -0
  42. agentinputlab/algorithms/curate/llmlingua/multilingual.py +105 -0
  43. agentinputlab/algorithms/curate/llmlingua/span_map.py +167 -0
  44. agentinputlab/algorithms/curate/recomp/__init__.py +47 -0
  45. agentinputlab/algorithms/curate/recomp/external.py +1129 -0
  46. agentinputlab/algorithms/curate/recomp/selective.py +304 -0
  47. agentinputlab/algorithms/decompose/__init__.py +107 -0
  48. agentinputlab/algorithms/decompose/decomp/__init__.py +53 -0
  49. agentinputlab/algorithms/decompose/decomp/common_support.py +478 -0
  50. agentinputlab/algorithms/decompose/decomp/planner_component.py +199 -0
  51. agentinputlab/algorithms/decompose/decomp/worker_bridge.py +416 -0
  52. agentinputlab/algorithms/decompose/llm_compiler/__init__.py +35 -0
  53. agentinputlab/algorithms/decompose/llm_compiler/bridge.py +520 -0
  54. agentinputlab/algorithms/decompose/llm_compiler/common_support.py +504 -0
  55. agentinputlab/algorithms/decompose/plan_and_budget/__init__.py +43 -0
  56. agentinputlab/algorithms/decompose/plan_and_budget/cached_soft_budget.py +362 -0
  57. agentinputlab/algorithms/decompose/plan_and_budget/decomposer_component.py +107 -0
  58. agentinputlab/algorithms/decompose/plan_and_budget/full.py +205 -0
  59. agentinputlab/algorithms/decompose/plan_and_budget/hard_cap.py +246 -0
  60. agentinputlab/algorithms/decompose/plan_and_budget/regenerated_soft_budget.py +448 -0
  61. agentinputlab/algorithms/decompose/plan_and_solve/__init__.py +33 -0
  62. agentinputlab/algorithms/decompose/plan_and_solve/plan_component.py +192 -0
  63. agentinputlab/algorithms/decompose/plan_and_solve/ps_prompt.py +127 -0
  64. agentinputlab/algorithms/decompose/self_ask/__init__.py +27 -0
  65. agentinputlab/algorithms/decompose/self_ask/loop.py +362 -0
  66. agentinputlab/algorithms/decompose/self_ask/planner_component.py +117 -0
  67. agentinputlab/algorithms/reformulate/__init__.py +85 -0
  68. agentinputlab/algorithms/reformulate/infocqr/__init__.py +40 -0
  69. agentinputlab/algorithms/reformulate/infocqr/cache_replay.py +362 -0
  70. agentinputlab/algorithms/reformulate/infocqr/external.py +675 -0
  71. agentinputlab/algorithms/reformulate/infocqr/student.py +189 -0
  72. agentinputlab/algorithms/reformulate/query2doc/__init__.py +42 -0
  73. agentinputlab/algorithms/reformulate/query2doc/controlled_live.py +190 -0
  74. agentinputlab/algorithms/reformulate/query2doc/models.py +95 -0
  75. agentinputlab/algorithms/reformulate/query2doc/official_cached.py +335 -0
  76. agentinputlab/algorithms/reformulate/query2doc/querygym_bridge.py +223 -0
  77. agentinputlab/algorithms/reformulate/query2doc/querygym_runtime.py +326 -0
  78. agentinputlab/algorithms/reformulate/reformer/__init__.py +23 -0
  79. agentinputlab/algorithms/reformulate/reformer/external.py +417 -0
  80. agentinputlab/algorithms/reformulate/rrr.py +696 -0
  81. agentinputlab/annotation/__init__.py +5 -0
  82. agentinputlab/annotation/independent.py +428 -0
  83. agentinputlab/annotation/server.py +233 -0
  84. agentinputlab/annotation/static/app.js +121 -0
  85. agentinputlab/annotation/static/index.html +60 -0
  86. agentinputlab/annotation/static/review.css +2 -0
  87. agentinputlab/annotation/static/review.html +10 -0
  88. agentinputlab/annotation/static/review.js +11 -0
  89. agentinputlab/annotation/static/styles.css +55 -0
  90. agentinputlab/annotation/store.py +444 -0
  91. agentinputlab/api.py +368 -0
  92. agentinputlab/artifacts/__init__.py +15 -0
  93. agentinputlab/artifacts/json_file.py +104 -0
  94. agentinputlab/artifacts/manifest.py +98 -0
  95. agentinputlab/artifacts/store.py +157 -0
  96. agentinputlab/backends/__init__.py +98 -0
  97. agentinputlab/backends/embedding/__init__.py +25 -0
  98. agentinputlab/backends/embedding/base.py +145 -0
  99. agentinputlab/backends/embedding/callable.py +75 -0
  100. agentinputlab/backends/embedding/replay.py +129 -0
  101. agentinputlab/backends/llm/__init__.py +31 -0
  102. agentinputlab/backends/llm/base.py +149 -0
  103. agentinputlab/backends/llm/callable.py +108 -0
  104. agentinputlab/backends/llm/decomp_completion.py +88 -0
  105. agentinputlab/backends/llm/final_content_stop.py +72 -0
  106. agentinputlab/backends/llm/gpt_oss_final_channel.py +84 -0
  107. agentinputlab/backends/llm/openai_compatible.py +332 -0
  108. agentinputlab/backends/llm/transformers.py +171 -0
  109. agentinputlab/backends/retrieval/__init__.py +35 -0
  110. agentinputlab/backends/retrieval/base.py +50 -0
  111. agentinputlab/backends/retrieval/dense.py +777 -0
  112. agentinputlab/backends/retrieval/memory.py +119 -0
  113. agentinputlab/backends/retrieval/sqlite_fts.py +155 -0
  114. agentinputlab/backends/user/__init__.py +15 -0
  115. agentinputlab/backends/user/base.py +66 -0
  116. agentinputlab/backends/user/callable.py +54 -0
  117. agentinputlab/backends/user/replay.py +89 -0
  118. agentinputlab/backends/vector.py +38 -0
  119. agentinputlab/benchmarks/__init__.py +246 -0
  120. agentinputlab/benchmarks/acquisition.py +106 -0
  121. agentinputlab/benchmarks/ale.py +540 -0
  122. agentinputlab/benchmarks/appworld_ul.py +669 -0
  123. agentinputlab/benchmarks/assets.py +226 -0
  124. agentinputlab/benchmarks/base.py +68 -0
  125. agentinputlab/benchmarks/beir_archive.py +235 -0
  126. agentinputlab/benchmarks/beir_sample.py +269 -0
  127. agentinputlab/benchmarks/bfcl_native.py +245 -0
  128. agentinputlab/benchmarks/bfcl_v3.py +607 -0
  129. agentinputlab/benchmarks/cache.py +218 -0
  130. agentinputlab/benchmarks/clariq.py +203 -0
  131. agentinputlab/benchmarks/data/registry.json +321 -0
  132. agentinputlab/benchmarks/data/smoke_assets.json +511 -0
  133. agentinputlab/benchmarks/data/statebench_v0_8_1_task_ids.json +475 -0
  134. agentinputlab/benchmarks/data/toolsandbox_165848b_scenario_names.json +1 -0
  135. agentinputlab/benchmarks/execution.py +1111 -0
  136. agentinputlab/benchmarks/interactive.py +257 -0
  137. agentinputlab/benchmarks/ir_query.py +204 -0
  138. agentinputlab/benchmarks/longbench.py +203 -0
  139. agentinputlab/benchmarks/paired_replay.py +479 -0
  140. agentinputlab/benchmarks/preprocess.py +2313 -0
  141. agentinputlab/benchmarks/production.py +236 -0
  142. agentinputlab/benchmarks/qa.py +963 -0
  143. agentinputlab/benchmarks/registry.py +110 -0
  144. agentinputlab/benchmarks/retrieval.py +459 -0
  145. agentinputlab/benchmarks/runtime.py +509 -0
  146. agentinputlab/benchmarks/statebench.py +938 -0
  147. agentinputlab/benchmarks/tau3.py +725 -0
  148. agentinputlab/benchmarks/toolsandbox.py +626 -0
  149. agentinputlab/benchmarks/trec_dl_sample.py +263 -0
  150. agentinputlab/campaign.py +654 -0
  151. agentinputlab/campaign_runner.py +953 -0
  152. agentinputlab/cli/__init__.py +6 -0
  153. agentinputlab/cli/main.py +933 -0
  154. agentinputlab/connectors/__init__.py +46 -0
  155. agentinputlab/connectors/knowledge/__init__.py +4 -0
  156. agentinputlab/connectors/tools/__init__.py +30 -0
  157. agentinputlab/connectors/tools/base.py +57 -0
  158. agentinputlab/connectors/tools/mcp.py +222 -0
  159. agentinputlab/connectors/tools/memory.py +41 -0
  160. agentinputlab/connectors/tools/openapi.py +695 -0
  161. agentinputlab/connectors/tools/schema.py +102 -0
  162. agentinputlab/contracts/__init__.py +91 -0
  163. agentinputlab/contracts/availability.py +24 -0
  164. agentinputlab/contracts/dependency.py +58 -0
  165. agentinputlab/contracts/enums.py +82 -0
  166. agentinputlab/contracts/errors.py +63 -0
  167. agentinputlab/contracts/evidence.py +43 -0
  168. agentinputlab/contracts/intent.py +110 -0
  169. agentinputlab/contracts/lifecycle.py +164 -0
  170. agentinputlab/contracts/patch.py +167 -0
  171. agentinputlab/contracts/serialization.py +93 -0
  172. agentinputlab/contracts/state.py +127 -0
  173. agentinputlab/contracts/trace.py +59 -0
  174. agentinputlab/contracts/worker.py +42 -0
  175. agentinputlab/core/__init__.py +7 -0
  176. agentinputlab/data/__init__.py +32 -0
  177. agentinputlab/data/checksums.py +9 -0
  178. agentinputlab/data/downloader.py +235 -0
  179. agentinputlab/data/http.py +171 -0
  180. agentinputlab/data/index.py +21 -0
  181. agentinputlab/data/overlap.py +28 -0
  182. agentinputlab/data/preprocess.py +32 -0
  183. agentinputlab/data/storage.py +57 -0
  184. agentinputlab/data/trec_sample.py +427 -0
  185. agentinputlab/evaluation/__init__.py +5 -0
  186. agentinputlab/evaluation/outcomes.py +32 -0
  187. agentinputlab/experiments/__init__.py +278 -0
  188. agentinputlab/experiments/analysis.py +981 -0
  189. agentinputlab/experiments/artifacts.py +687 -0
  190. agentinputlab/experiments/automatic_measurement.py +678 -0
  191. agentinputlab/experiments/auxiliary_matrix.py +203 -0
  192. agentinputlab/experiments/bindings.py +430 -0
  193. agentinputlab/experiments/blueprints.py +147 -0
  194. agentinputlab/experiments/builders/__init__.py +45 -0
  195. agentinputlab/experiments/builders/executable_external_payload.py +423 -0
  196. agentinputlab/experiments/builders/external_process_arena.py +1018 -0
  197. agentinputlab/experiments/builders/registry_intervention.py +463 -0
  198. agentinputlab/experiments/cli.py +158 -0
  199. agentinputlab/experiments/controls.py +340 -0
  200. agentinputlab/experiments/driver_guard.py +205 -0
  201. agentinputlab/experiments/drivers/__init__.py +89 -0
  202. agentinputlab/experiments/drivers/external_arena.py +2908 -0
  203. agentinputlab/experiments/drivers/method_process.py +662 -0
  204. agentinputlab/experiments/drivers/parity_process.py +1484 -0
  205. agentinputlab/experiments/drivers/static_production.py +1574 -0
  206. agentinputlab/experiments/executor.py +448 -0
  207. agentinputlab/experiments/loader.py +605 -0
  208. agentinputlab/experiments/measurement.py +675 -0
  209. agentinputlab/experiments/paper_analysis.py +1818 -0
  210. agentinputlab/experiments/parity_identity.py +605 -0
  211. agentinputlab/experiments/plan.py +277 -0
  212. agentinputlab/experiments/production_builders.py +3739 -0
  213. agentinputlab/experiments/readiness.py +432 -0
  214. agentinputlab/experiments/schema.py +514 -0
  215. agentinputlab/experiments/secrets.py +177 -0
  216. agentinputlab/experiments/stateful_analysis.py +1738 -0
  217. agentinputlab/experiments/transfer_analysis.py +1316 -0
  218. agentinputlab/experiments/unseen_analysis.py +1025 -0
  219. agentinputlab/integrations/__init__.py +1 -0
  220. agentinputlab/integrations/action_space/__init__.py +1 -0
  221. agentinputlab/integrations/external_workers/__init__.py +76 -0
  222. agentinputlab/integrations/external_workers/ace.py +431 -0
  223. agentinputlab/integrations/external_workers/base.py +181 -0
  224. agentinputlab/integrations/external_workers/decomp_live.py +249 -0
  225. agentinputlab/integrations/external_workers/decomp_planner.py +30 -0
  226. agentinputlab/integrations/external_workers/infocqr_student.py +280 -0
  227. agentinputlab/integrations/external_workers/ircot.py +576 -0
  228. agentinputlab/integrations/external_workers/llmcompiler_live.py +360 -0
  229. agentinputlab/integrations/external_workers/longllmlingua.py +162 -0
  230. agentinputlab/integrations/external_workers/method.py +314 -0
  231. agentinputlab/integrations/external_workers/process.py +678 -0
  232. agentinputlab/integrations/external_workers/supervisor.py +1071 -0
  233. agentinputlab/integrations/full_architecture/__init__.py +1 -0
  234. agentinputlab/integrations/full_architecture/hyde.py +212 -0
  235. agentinputlab/integrations/full_architecture/plan_and_budget.py +188 -0
  236. agentinputlab/integrations/live_history.py +222 -0
  237. agentinputlab/integrations/prompt_optimization/__init__.py +1 -0
  238. agentinputlab/integrations/training/__init__.py +1 -0
  239. agentinputlab/metrics/__init__.py +50 -0
  240. agentinputlab/metrics/catalog.py +313 -0
  241. agentinputlab/metrics/harm.py +95 -0
  242. agentinputlab/metrics/paired.py +40 -0
  243. agentinputlab/metrics/qa.py +76 -0
  244. agentinputlab/metrics/text.py +33 -0
  245. agentinputlab/metrics/third_party.py +161 -0
  246. agentinputlab/models/__init__.py +4 -0
  247. agentinputlab/observability/__init__.py +56 -0
  248. agentinputlab/observability/budget.py +316 -0
  249. agentinputlab/observability/instrumentation.py +754 -0
  250. agentinputlab/observability/models.py +403 -0
  251. agentinputlab/observability/monitor.py +380 -0
  252. agentinputlab/optimizers/__init__.py +1 -0
  253. agentinputlab/optimizers/clarify/__init__.py +12 -0
  254. agentinputlab/optimizers/context/__init__.py +22 -0
  255. agentinputlab/optimizers/decompose/__init__.py +64 -0
  256. agentinputlab/optimizers/evidence/__init__.py +22 -0
  257. agentinputlab/optimizers/rewrite/__init__.py +30 -0
  258. agentinputlab/parity/__init__.py +5 -0
  259. agentinputlab/parity/base.py +206 -0
  260. agentinputlab/production_campaign.py +763 -0
  261. agentinputlab/py.typed +1 -0
  262. agentinputlab/recipes/__init__.py +333 -0
  263. agentinputlab/recipes/ace.py +418 -0
  264. agentinputlab/recipes/ace_bfcl.py +273 -0
  265. agentinputlab/recipes/ace_common_support.py +169 -0
  266. agentinputlab/recipes/ace_native_plan.py +322 -0
  267. agentinputlab/recipes/ace_online.py +711 -0
  268. agentinputlab/recipes/ace_retrieval.py +330 -0
  269. agentinputlab/recipes/ace_statebench.py +382 -0
  270. agentinputlab/recipes/ace_tau.py +463 -0
  271. agentinputlab/recipes/ace_toolsandbox.py +432 -0
  272. agentinputlab/recipes/acon_guideline.py +22 -0
  273. agentinputlab/recipes/adaptive_rag.py +822 -0
  274. agentinputlab/recipes/llmlingua2_inference.py +146 -0
  275. agentinputlab/recipes/llmlingua2_training.py +796 -0
  276. agentinputlab/recipes/mce.py +1486 -0
  277. agentinputlab/recipes/mce_final.py +335 -0
  278. agentinputlab/recipes/mce_text_fit.py +499 -0
  279. agentinputlab/recipes/mce_text_only.py +298 -0
  280. agentinputlab/recipes/qrag.py +729 -0
  281. agentinputlab/recipes/qrag_inference.py +364 -0
  282. agentinputlab/recipes/r2ag_features.py +236 -0
  283. agentinputlab/recipes/r2ag_inference.py +503 -0
  284. agentinputlab/recipes/r2ag_training.py +948 -0
  285. agentinputlab/recipes/recomp_abstractive.py +592 -0
  286. agentinputlab/recipes/recomp_extractive.py +525 -0
  287. agentinputlab/recipes/reformer.py +17 -0
  288. agentinputlab/recipes/rqrag.py +1516 -0
  289. agentinputlab/recipes/rqrag_common_support.py +193 -0
  290. agentinputlab/recipes/rqrag_completion.py +147 -0
  291. agentinputlab/recipes/skillopt.py +462 -0
  292. agentinputlab/recipes/skillopt_common_support.py +154 -0
  293. agentinputlab/recipes/skillopt_environment.py +165 -0
  294. agentinputlab/recipes/skillopt_environment_cli.py +5 -0
  295. agentinputlab/recipes/skillopt_retrieval.py +188 -0
  296. agentinputlab/recipes/smartsearch.py +897 -0
  297. agentinputlab/recipes/smartsearch_curriculum.py +283 -0
  298. agentinputlab/recipes/smartsearch_grpo_contracts.py +58 -0
  299. agentinputlab/recipes/smartsearch_grpo_data.py +314 -0
  300. agentinputlab/recipes/smartsearch_grpo_meter.py +324 -0
  301. agentinputlab/recipes/smartsearch_grpo_prefix.py +144 -0
  302. agentinputlab/recipes/smartsearch_grpo_rollout.py +119 -0
  303. agentinputlab/recipes/smartsearch_grpo_tools.py +364 -0
  304. agentinputlab/recipes/smartsearch_grpo_training.py +305 -0
  305. agentinputlab/recipes/smartsearch_grpo_transport.py +248 -0
  306. agentinputlab/recipes/smartsearch_grpo_worker.py +364 -0
  307. agentinputlab/recipes/smartsearch_inference.py +524 -0
  308. agentinputlab/recipes/smartsearch_native_data.py +172 -0
  309. agentinputlab/recipes/smartsearch_policy.py +616 -0
  310. agentinputlab/recipes/smartsearch_policy_worker.py +9 -0
  311. agentinputlab/recipes/smartsearch_sampling.py +232 -0
  312. agentinputlab/recipes/smartsearch_teacher.py +203 -0
  313. agentinputlab/recipes/smartsearch_training.py +265 -0
  314. agentinputlab/registry/__init__.py +46 -0
  315. agentinputlab/registry/beta.py +727 -0
  316. agentinputlab/registry/data/algorithms.json +1959 -0
  317. agentinputlab/registry/data/auxiliary_method_profiles.json +34 -0
  318. agentinputlab/registry/loader.py +100 -0
  319. agentinputlab/registry/result_manifest.py +184 -0
  320. agentinputlab/registry/runtime.py +195 -0
  321. agentinputlab/registry/schema.py +449 -0
  322. agentinputlab/runner/__init__.py +30 -0
  323. agentinputlab/runner/balance.py +248 -0
  324. agentinputlab/runner/cache.py +135 -0
  325. agentinputlab/runner/composite.py +130 -0
  326. agentinputlab/runner/engine.py +285 -0
  327. agentinputlab/runner/runtime_guard.py +268 -0
  328. agentinputlab/runner/worker.py +80 -0
  329. agentinputlab/runtime_bootstrap.py +288 -0
  330. agentinputlab/selectors/__init__.py +196 -0
  331. agentinputlab/selectors/advanced.py +1514 -0
  332. agentinputlab/selectors/artifacts.py +1087 -0
  333. agentinputlab/selectors/base.py +112 -0
  334. agentinputlab/selectors/campaigns.py +1893 -0
  335. agentinputlab/selectors/catalog.py +86 -0
  336. agentinputlab/selectors/discovery.py +1860 -0
  337. agentinputlab/selectors/evaluation.py +1348 -0
  338. agentinputlab/selectors/features.py +383 -0
  339. agentinputlab/selectors/learned.py +502 -0
  340. agentinputlab/selectors/no_op.py +28 -0
  341. agentinputlab/selectors/outcome_table.py +475 -0
  342. agentinputlab/selectors/producer.py +853 -0
  343. agentinputlab/selectors/rules.py +109 -0
  344. agentinputlab/selectors/runtime.py +420 -0
  345. agentinputlab/studies/__init__.py +16 -0
  346. agentinputlab/studies/design.py +165 -0
  347. agentinputlab/studies/paired.py +322 -0
  348. agentinputlab/studio/__init__.py +6 -0
  349. agentinputlab/studio/campaigns.py +819 -0
  350. agentinputlab/studio/engine.py +1408 -0
  351. agentinputlab/studio/model_backends.py +425 -0
  352. agentinputlab/studio/prepared.py +410 -0
  353. agentinputlab/studio/server.py +613 -0
  354. agentinputlab/studio/static/app.js +397 -0
  355. agentinputlab/studio/static/campaigns.html +175 -0
  356. agentinputlab/studio/static/campaigns.js +426 -0
  357. agentinputlab/studio/static/index.html +192 -0
  358. agentinputlab/studio/static/result.html +103 -0
  359. agentinputlab/studio/static/result.js +273 -0
  360. agentinputlab/studio/static/styles.css +467 -0
  361. agentinputlab-0.1.0a1.data/data/share/agentinputlab/CITATION.cff +22 -0
  362. agentinputlab-0.1.0a1.dist-info/METADATA +392 -0
  363. agentinputlab-0.1.0a1.dist-info/RECORD +469 -0
  364. agentinputlab-0.1.0a1.dist-info/WHEEL +5 -0
  365. agentinputlab-0.1.0a1.dist-info/entry_points.txt +6 -0
  366. agentinputlab-0.1.0a1.dist-info/licenses/LICENSE +21 -0
  367. agentinputlab-0.1.0a1.dist-info/licenses/NOTICE +31 -0
  368. agentinputlab-0.1.0a1.dist-info/licenses/THIRD_PARTY_NOTICES.md +94 -0
  369. agentinputlab-0.1.0a1.dist-info/top_level.txt +2 -0
  370. workers/README.md +94 -0
  371. workers/ace/README.md +261 -0
  372. workers/ace/__init__.py +1 -0
  373. workers/ace/compatibility_manifest.json +39 -0
  374. workers/ace/driver.py +1682 -0
  375. workers/acon/README.md +215 -0
  376. workers/acon/__init__.py +5 -0
  377. workers/acon/compatibility_manifest.json +93 -0
  378. workers/acon/driver.py +1859 -0
  379. workers/acon/fitted.py +395 -0
  380. workers/acon/guideline.py +470 -0
  381. workers/acon/guideline_source_manifest.json +20 -0
  382. workers/adaptive_rag/README.md +96 -0
  383. workers/adaptive_rag/__init__.py +15 -0
  384. workers/adaptive_rag/compatibility_manifest.json +61 -0
  385. workers/adaptive_rag/driver.py +1470 -0
  386. workers/adaptive_rag/fixture_runtime.py +163 -0
  387. workers/adaptive_rag/runtime.py +252 -0
  388. workers/ask_or_assume/README.md +124 -0
  389. workers/ask_or_assume/__init__.py +1 -0
  390. workers/ask_or_assume/compatibility_manifest.json +36 -0
  391. workers/ask_or_assume/driver.py +1227 -0
  392. workers/decomp/README.md +133 -0
  393. workers/decomp/UPSTREAM_LICENSE.Apache-2.0.txt +201 -0
  394. workers/decomp/__init__.py +5 -0
  395. workers/decomp/compatibility_manifest.json +205 -0
  396. workers/decomp/driver.py +1015 -0
  397. workers/decomp/live.py +137 -0
  398. workers/decomp/runtime.py +231 -0
  399. workers/infocqr/README.md +106 -0
  400. workers/infocqr/__init__.py +1 -0
  401. workers/infocqr/compatibility_manifest.json +84 -0
  402. workers/infocqr/driver.py +1766 -0
  403. workers/ircot/README.md +167 -0
  404. workers/ircot/__init__.py +7 -0
  405. workers/ircot/compatibility_manifest.json +121 -0
  406. workers/ircot/controlled.py +457 -0
  407. workers/ircot/driver.py +1373 -0
  408. workers/ircot/fixture_bindings.json +39 -0
  409. workers/ircot/fixture_config.json +48 -0
  410. workers/ircot/fixture_prompt.txt +2 -0
  411. workers/ircot/native_qa.py +398 -0
  412. workers/ircot/qa_compatibility_manifest.json +57 -0
  413. workers/ircot/runtime.py +97 -0
  414. workers/llmcompiler/README.md +160 -0
  415. workers/llmcompiler/__init__.py +1 -0
  416. workers/llmcompiler/compatibility_manifest.json +45 -0
  417. workers/llmcompiler/driver.py +1514 -0
  418. workers/llmcompiler/export_prompts.py +74 -0
  419. workers/llmcompiler/live.py +174 -0
  420. workers/llmcompiler/patch_manifest.json +147 -0
  421. workers/mce/README.md +198 -0
  422. workers/mce/__init__.py +29 -0
  423. workers/mce/compatibility_manifest.json +115 -0
  424. workers/mce/driver.py +2585 -0
  425. workers/mce/final_eval.py +173 -0
  426. workers/official_arenas/README.md +25 -0
  427. workers/official_arenas/__init__.py +1 -0
  428. workers/official_arenas/capture_records.py +110 -0
  429. workers/official_arenas/driver.py +619 -0
  430. workers/official_arenas/protocol.py +334 -0
  431. workers/official_arenas/providers/__init__.py +1 -0
  432. workers/official_arenas/providers/_live_history.py +228 -0
  433. workers/official_arenas/providers/_message_compat.py +77 -0
  434. workers/official_arenas/providers/appworld_ul.py +196 -0
  435. workers/official_arenas/providers/fixture.py +112 -0
  436. workers/official_arenas/providers/statebench.py +960 -0
  437. workers/official_arenas/providers/tau3.py +1672 -0
  438. workers/official_arenas/providers/tau_retail.py +586 -0
  439. workers/official_arenas/providers/toolsandbox.py +1321 -0
  440. workers/official_arenas/providers/tooltalk.py +699 -0
  441. workers/official_arenas/retail_capture.py +188 -0
  442. workers/official_arenas/retail_driver.py +275 -0
  443. workers/qrag/README.md +172 -0
  444. workers/qrag/__init__.py +1 -0
  445. workers/qrag/compatibility_manifest.json +64 -0
  446. workers/qrag/driver.py +673 -0
  447. workers/r2ag/README.md +154 -0
  448. workers/r2ag/__init__.py +5 -0
  449. workers/r2ag/compatibility_manifest.json +55 -0
  450. workers/r2ag/driver.py +1287 -0
  451. workers/r2ag/feature_schema.json +8 -0
  452. workers/r2ag/runtime.py +589 -0
  453. workers/recomp/README.md +120 -0
  454. workers/recomp/__init__.py +1 -0
  455. workers/recomp/compatibility_manifest.json +43 -0
  456. workers/recomp/driver.py +1653 -0
  457. workers/reformer/README.md +125 -0
  458. workers/reformer/__init__.py +1 -0
  459. workers/reformer/compatibility_manifest.json +68 -0
  460. workers/reformer/driver.py +1459 -0
  461. workers/reformer/induction.py +457 -0
  462. workers/rrr/README.md +126 -0
  463. workers/rrr/__init__.py +1 -0
  464. workers/rrr/compatibility_manifest.json +57 -0
  465. workers/rrr/driver.py +1133 -0
  466. workers/smartsearch/README.md +331 -0
  467. workers/smartsearch/__init__.py +1 -0
  468. workers/smartsearch/compatibility_manifest.json +41 -0
  469. workers/smartsearch/driver.py +1643 -0
@@ -0,0 +1,607 @@
1
+ """Gold-isolated BFCL v3 simple-Python adapter and external scorer bridge.
2
+
3
+ The official v1.3 source archive supplies the prompt, possible answers, model
4
+ decoders, and AST checker. AgentInputLab separates prompts and evaluator gold.
5
+ Callers can bind an explicit non-attested callback or a source-verified Python
6
+ function-calling bridge. Case-level source verification does not assert the
7
+ full official CLI/aggregate leaderboard workflow.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import math
14
+ import re
15
+ from collections.abc import Callable, Mapping
16
+ from dataclasses import dataclass, field
17
+ from pathlib import Path
18
+ from types import MappingProxyType
19
+ from typing import Any, Protocol, runtime_checkable
20
+
21
+ from agentinputlab.artifacts import sha256_file
22
+ from agentinputlab.contracts.errors import ArtifactError, ValidationError
23
+ from agentinputlab.contracts.serialization import canonical_json, freeze_mapping
24
+
25
+ from .assets import BenchmarkSmokeAssetRegistry
26
+ from .base import BenchmarkExample
27
+ from .preprocess import PreparedBenchmark, load_prepared_benchmark
28
+
29
+ BFCL_V3_OFFICIAL_SOURCE_REVISION = "ea13468e4423454d0c213704fb87cf7cb3990433"
30
+ BFCL_V3_SOURCE_ARCHIVE_SHA256 = "57854157e82aed5723a1458d2a4ac426e3256959ded4a20ddc4d627c22edb7fe"
31
+ BFCL_V3_SCORER_ID = (
32
+ "bfcl_eval.eval_checker.eval_runner:ast_file_runner+"
33
+ "bfcl_eval.eval_checker.ast_eval.ast_checker:ast_checker"
34
+ )
35
+ BFCL_V3_SCORER_REVISION = "31f1420ae78709920d2fc49ceb93ea3dc451379cf5f320ac0b02b9845d0cbb36"
36
+ BFCL_V3_AST_CHECKER_REVISION = "58a8a1d8a42ec4f7e0f340a8bf11ab4035c54d38d933ae2621f22bbc7c8d1c9b"
37
+
38
+ _BENCHMARK_ID = "bfcl.v3.simple_python"
39
+ _ASSET_ID = "bfcl.v3.simple_python.v1_3"
40
+ _PROCESSOR = "bfcl_v3_simple_tar_v1"
41
+ _SPLIT = "test"
42
+ _CALLER_ASSERTED = "caller_asserted"
43
+ _EXTERNAL_BRIDGE = "external_bridge"
44
+ _SHA256 = re.compile(r"^[0-9a-f]{64}$")
45
+ _LOADER_CONSTRUCTION_TOKEN = object()
46
+ _EXPECTED_IDS = frozenset(f"simple_{index}" for index in range(400))
47
+ _EXPECTED_COUNTS = {
48
+ "audit": 1,
49
+ "functions": 400,
50
+ "gold": 400,
51
+ "ground_truth_candidates": 400,
52
+ "inputs": 400,
53
+ "source_files": 8,
54
+ }
55
+ _INPUT_FIELDS = {
56
+ "id",
57
+ "instruction",
58
+ "query",
59
+ "visible_metadata",
60
+ "visible_tool_names",
61
+ }
62
+ _VISIBLE_METADATA_FIELDS = {
63
+ "benchmark_cell",
64
+ "bfcl_category",
65
+ "function",
66
+ "source_split",
67
+ }
68
+ _FUNCTION_FIELDS = {"description", "name", "parameters"}
69
+ _GOLD_FIELDS = {"ground_truth", "id"}
70
+ BFCL_V3_SELECTED_SOURCE_SHA256: Mapping[str, str] = MappingProxyType(
71
+ {
72
+ "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4",
73
+ (
74
+ "berkeley-function-call-leaderboard/bfcl_eval/constants/category_mapping.py"
75
+ ): "c08dfe14283990bc4f67333183d8c14a2506da6d99ac00c6ef5f018dd44757fc",
76
+ (
77
+ "berkeley-function-call-leaderboard/bfcl_eval/data/BFCL_v3_simple.json"
78
+ ): "fbc37b2ad252bf9af985582e0e07b456173fe627d957491472ea9cef5fb83158",
79
+ (
80
+ "berkeley-function-call-leaderboard/bfcl_eval/data/possible_answer/BFCL_v3_simple.json"
81
+ ): "2911a2bc00df82c4f999ffa64fedb0164cb88e96212ffa5972087eb91fd496ee",
82
+ (
83
+ "berkeley-function-call-leaderboard/bfcl_eval/eval_checker/ast_eval/ast_checker.py"
84
+ ): BFCL_V3_AST_CHECKER_REVISION,
85
+ (
86
+ "berkeley-function-call-leaderboard/bfcl_eval/eval_checker/eval_runner.py"
87
+ ): BFCL_V3_SCORER_REVISION,
88
+ (
89
+ "berkeley-function-call-leaderboard/bfcl_eval/model_handler/base_handler.py"
90
+ ): "4a2f4e677d1f6930f396dbc92c50138f56268f970de7e4f815fb801607cafad1",
91
+ (
92
+ "berkeley-function-call-leaderboard/pyproject.toml"
93
+ ): "20d86859dc988e442c13a6c4f3567094bd8f2d4a269d59015337bdf6aeba7dd3",
94
+ }
95
+ )
96
+
97
+
98
+ @dataclass(frozen=True, slots=True)
99
+ class BFCLV3EvaluationResult:
100
+ """One caller-asserted official-AST validity bit."""
101
+
102
+ ast_accuracy: float
103
+ provenance_status: str = field(init=False, default=_CALLER_ASSERTED)
104
+ evaluation_scope: str = field(init=False, default=_EXTERNAL_BRIDGE)
105
+ official_runtime_verified: bool = field(init=False, default=False)
106
+
107
+ def __post_init__(self) -> None:
108
+ if isinstance(self.ast_accuracy, bool) or not isinstance(self.ast_accuracy, (int, float)):
109
+ raise ValidationError("BFCL v3 ast_accuracy must be numeric")
110
+ numeric = float(self.ast_accuracy)
111
+ if not math.isfinite(numeric) or numeric not in {0.0, 1.0}:
112
+ raise ValidationError("BFCL v3 case-level ast_accuracy must be exactly 0 or 1")
113
+ object.__setattr__(self, "ast_accuracy", numeric)
114
+
115
+ @property
116
+ def metrics(self) -> Mapping[str, float]:
117
+ return MappingProxyType({"ast_accuracy": self.ast_accuracy})
118
+
119
+
120
+ @runtime_checkable
121
+ class BFCLV3ScorerBridge(Protocol):
122
+ """Revision-bound external BFCL decoder/scorer contract."""
123
+
124
+ bfcl_bridge_contract: str
125
+ benchmark_id: str
126
+ source_revision: str
127
+ scorer_id: str
128
+ scorer_revision: str
129
+ ast_checker_revision: str
130
+ model_handler_id: str
131
+ model_handler_revision: str
132
+ bridge_id: str
133
+ bridge_revision: str
134
+ test_category: str
135
+ language: str
136
+ provenance_status: str
137
+ evaluation_scope: str
138
+ official_runtime_verified: bool
139
+
140
+ def evaluate(
141
+ self,
142
+ evaluator_payload: Mapping[str, Any],
143
+ prediction: Any,
144
+ ) -> BFCLV3EvaluationResult: ...
145
+
146
+
147
+ @dataclass(frozen=True, slots=True)
148
+ class CallerAssertedBFCLV3ScorerBridge:
149
+ """Explicit wrapper for a non-attested external BFCL v1.3 callback."""
150
+
151
+ bridge_id: str
152
+ bridge_revision: str
153
+ model_handler_id: str
154
+ model_handler_revision: str
155
+ callback: Callable[
156
+ [Mapping[str, Any], Any],
157
+ BFCLV3EvaluationResult,
158
+ ] = field(repr=False)
159
+ bfcl_bridge_contract: str = field(init=False, default="bfcl_v3_scorer_bridge_v1")
160
+ benchmark_id: str = field(init=False, default=_BENCHMARK_ID)
161
+ source_revision: str = field(init=False, default=BFCL_V3_OFFICIAL_SOURCE_REVISION)
162
+ scorer_id: str = field(init=False, default=BFCL_V3_SCORER_ID)
163
+ scorer_revision: str = field(init=False, default=BFCL_V3_SCORER_REVISION)
164
+ ast_checker_revision: str = field(
165
+ init=False,
166
+ default=BFCL_V3_AST_CHECKER_REVISION,
167
+ )
168
+ test_category: str = field(init=False, default="simple")
169
+ language: str = field(init=False, default="Python")
170
+ provenance_status: str = field(init=False, default=_CALLER_ASSERTED)
171
+ evaluation_scope: str = field(init=False, default=_EXTERNAL_BRIDGE)
172
+ official_runtime_verified: bool = field(init=False, default=False)
173
+
174
+ def __post_init__(self) -> None:
175
+ for label in ("bridge_id", "model_handler_id"):
176
+ value = getattr(self, label)
177
+ if not isinstance(value, str) or not value.strip() or value != value.strip():
178
+ raise ValidationError(f"BFCL v3 scorer bridge {label} must be non-empty")
179
+ for label in ("bridge_revision", "model_handler_revision"):
180
+ value = getattr(self, label)
181
+ if not isinstance(value, str) or _SHA256.fullmatch(value) is None:
182
+ raise ValidationError(f"BFCL v3 scorer bridge {label} must be a lowercase SHA-256")
183
+ if not callable(self.callback):
184
+ raise TypeError("BFCL v3 scorer bridge callback must be callable")
185
+
186
+ def evaluate(
187
+ self,
188
+ evaluator_payload: Mapping[str, Any],
189
+ prediction: Any,
190
+ ) -> BFCLV3EvaluationResult:
191
+ result = self.callback(evaluator_payload, prediction)
192
+ if not isinstance(result, BFCLV3EvaluationResult):
193
+ raise ValidationError(
194
+ "BFCL v3 scorer callback must return BFCLV3EvaluationResult; "
195
+ "bare metrics are not accepted"
196
+ )
197
+ if (
198
+ result.provenance_status != self.provenance_status
199
+ or result.evaluation_scope != self.evaluation_scope
200
+ or result.official_runtime_verified is not False
201
+ ):
202
+ raise ValidationError(
203
+ "BFCL v3 evaluation result provenance differs from its caller-asserted bridge"
204
+ )
205
+ return result
206
+
207
+
208
+ class PreparedBFCLV3SimpleAdapter:
209
+ """Loader-only production adapter for the locked BFCL v3 simple-Python cell."""
210
+
211
+ benchmark_id = _BENCHMARK_ID
212
+ adapter_metric_names = ("ast_accuracy",)
213
+ split = _SPLIT
214
+ pairing_mode = "stateless_score_twice"
215
+
216
+ def __init__(
217
+ self,
218
+ prepared: PreparedBenchmark,
219
+ *,
220
+ evaluation_bridge: BFCLV3ScorerBridge,
221
+ _construction_token: object | None = None,
222
+ ) -> None:
223
+ if _construction_token is not _LOADER_CONSTRUCTION_TOKEN:
224
+ raise ValidationError(
225
+ "BFCL v3 production adapters must be constructed with load_bfcl_v3_simple_adapter()"
226
+ )
227
+ if not isinstance(prepared, PreparedBenchmark):
228
+ raise TypeError("prepared must be a PreparedBenchmark")
229
+ if not isinstance(evaluation_bridge, BFCLV3ScorerBridge):
230
+ raise TypeError(
231
+ "evaluation_bridge must implement BFCLV3ScorerBridge; wrap external "
232
+ "callbacks with CallerAssertedBFCLV3ScorerBridge"
233
+ )
234
+ _validate_prepared_identity(prepared)
235
+ _validate_scorer_bridge(evaluation_bridge)
236
+ _verify_prepared_file_hashes(prepared)
237
+
238
+ input_rows = _records_by_id(prepared.inputs_path, label="BFCL v3 prepared inputs")
239
+ gold_rows = _records_by_id(prepared.gold_path, label="BFCL v3 evaluator gold")
240
+ audit_rows = _read_jsonl(prepared.audit_path, label="BFCL v3 source audit")
241
+ if set(input_rows) != _EXPECTED_IDS or set(gold_rows) != _EXPECTED_IDS:
242
+ raise ArtifactError("BFCL v3 simple IDs differ from the audited 400-case cell")
243
+ if len(audit_rows) != 1:
244
+ raise ArtifactError("BFCL v3 source audit must contain exactly one record")
245
+ _validate_source_audit(audit_rows[0])
246
+
247
+ examples: list[BenchmarkExample] = []
248
+ for index in range(400):
249
+ example_id = f"simple_{index}"
250
+ visible = input_rows[example_id]
251
+ gold = gold_rows[example_id]
252
+ if set(visible) != _INPUT_FIELDS:
253
+ raise ArtifactError("BFCL v3 prepared input schema differs from the lock")
254
+ if set(gold) != _GOLD_FIELDS or gold.get("id") != example_id:
255
+ raise ArtifactError("BFCL v3 evaluator gold schema differs from the lock")
256
+ query = _required_text(visible, "query", label="BFCL v3 prepared input")
257
+ instruction = _required_text(
258
+ visible,
259
+ "instruction",
260
+ label="BFCL v3 prepared input",
261
+ )
262
+ metadata = _validated_visible_metadata(visible["visible_metadata"])
263
+ function = metadata["function"]
264
+ if not isinstance(function, Mapping): # pragma: no cover - validation invariant
265
+ raise ArtifactError("BFCL v3 function metadata is invalid")
266
+ tool_names = visible["visible_tool_names"]
267
+ if not isinstance(tool_names, list) or tool_names != [function["name"]]:
268
+ raise ArtifactError(
269
+ "BFCL v3 visible tool names must contain the prompt function exactly"
270
+ )
271
+ ground_truth = gold["ground_truth"]
272
+ if (
273
+ not isinstance(ground_truth, list)
274
+ or len(ground_truth) != 1
275
+ or not isinstance(ground_truth[0], Mapping)
276
+ ):
277
+ raise ArtifactError("BFCL v3 simple evaluator gold must contain one answer object")
278
+ examples.append(
279
+ BenchmarkExample(
280
+ example_id=example_id,
281
+ query=query,
282
+ instruction=instruction,
283
+ visible_metadata=metadata,
284
+ visible_tool_names=(function["name"],),
285
+ evaluator_gold=_frozen_mapping(
286
+ {"ground_truth": ground_truth},
287
+ label="BFCL v3 evaluator gold",
288
+ ),
289
+ )
290
+ )
291
+
292
+ self.prepared = prepared
293
+ self._evaluation_bridge = evaluation_bridge
294
+ self._examples = tuple(examples)
295
+ self._examples_by_id = {example.example_id: example for example in examples}
296
+ self._expected_file_sha256 = MappingProxyType(dict(prepared.file_sha256))
297
+
298
+ def verify_integrity(self) -> None:
299
+ """Re-hash all prepared files before exposure or scoring."""
300
+
301
+ if dict(self.prepared.file_sha256) != dict(self._expected_file_sha256):
302
+ raise ArtifactError("prepared BFCL v3 declared file hashes changed after loading")
303
+ _verify_prepared_file_hashes(self.prepared)
304
+
305
+ def examples(self, split: str) -> tuple[BenchmarkExample, ...]:
306
+ if split != self.split:
307
+ raise ValidationError(
308
+ f"BFCL v3 simple adapter exposes split {self.split!r}, not {split!r}"
309
+ )
310
+ self.verify_integrity()
311
+ return self._examples
312
+
313
+ def example(self, split: str, example_id: str) -> BenchmarkExample:
314
+ if split != self.split:
315
+ raise ValidationError(
316
+ f"BFCL v3 simple adapter exposes split {self.split!r}, not {split!r}"
317
+ )
318
+ self.verify_integrity()
319
+ try:
320
+ return self._examples_by_id[example_id]
321
+ except KeyError as exc:
322
+ raise ValidationError(f"unknown BFCL v3 simple example {example_id!r}") from exc
323
+
324
+ def function_tools(self, example: BenchmarkExample) -> tuple[Mapping[str, Any], ...]:
325
+ """Expose the bound handler's native function schema, including name conversion."""
326
+ if self._examples_by_id.get(getattr(example, "example_id", None)) is not example:
327
+ raise ValidationError("benchmark example does not belong to this BFCL v3 adapter")
328
+ self.verify_integrity()
329
+ convert = getattr(self._evaluation_bridge, "tools", None)
330
+ if not callable(convert):
331
+ raise ValidationError("this BFCL scorer bridge does not expose native function tools")
332
+ tools = tuple(convert(example.visible_metadata["function"]))
333
+ if not tools or any(not isinstance(tool, Mapping) for tool in tools):
334
+ raise ValidationError("BFCL native schema converter returned invalid tools")
335
+ return tools
336
+
337
+ def score(self, example: BenchmarkExample, prediction: Any) -> Mapping[str, float]:
338
+ if not isinstance(example, BenchmarkExample):
339
+ raise TypeError("example must be a BenchmarkExample")
340
+ if self._examples_by_id.get(example.example_id) is not example:
341
+ raise ValidationError("benchmark example does not belong to this BFCL v3 adapter")
342
+ self.verify_integrity()
343
+ function = example.visible_metadata.get("function")
344
+ if not isinstance(function, Mapping): # pragma: no cover - construction invariant
345
+ raise ArtifactError("BFCL v3 example function metadata is invalid")
346
+ ground_truth = example.evaluator_gold.get("ground_truth")
347
+ if not isinstance(ground_truth, tuple): # frozen by construction
348
+ raise ArtifactError("BFCL v3 example evaluator gold is invalid")
349
+ evaluator_payload = _frozen_mapping(
350
+ {
351
+ "benchmark_id": self.benchmark_id,
352
+ "function": function,
353
+ "ground_truth": ground_truth,
354
+ "language": self._evaluation_bridge.language,
355
+ "source_revision": BFCL_V3_OFFICIAL_SOURCE_REVISION,
356
+ "test_category": self._evaluation_bridge.test_category,
357
+ },
358
+ label="BFCL v3 evaluator payload",
359
+ )
360
+ result = self._evaluation_bridge.evaluate(evaluator_payload, prediction)
361
+ if not isinstance(result, BFCLV3EvaluationResult):
362
+ raise ValidationError("BFCL v3 scorer bridge returned an invalid result type")
363
+ return result.metrics
364
+
365
+ @property
366
+ def evaluation_provenance(self) -> Mapping[str, Any]:
367
+ """Return explicit scorer/decoder identities and evaluation scope."""
368
+
369
+ return _frozen_mapping(
370
+ {
371
+ "ast_checker_revision": self._evaluation_bridge.ast_checker_revision,
372
+ "benchmark_id": self._evaluation_bridge.benchmark_id,
373
+ "bridge_id": self._evaluation_bridge.bridge_id,
374
+ "bridge_revision": self._evaluation_bridge.bridge_revision,
375
+ "evaluation_scope": self._evaluation_bridge.evaluation_scope,
376
+ "language": self._evaluation_bridge.language,
377
+ "model_handler_id": self._evaluation_bridge.model_handler_id,
378
+ "model_handler_revision": self._evaluation_bridge.model_handler_revision,
379
+ "official_runtime_verified": self._evaluation_bridge.official_runtime_verified,
380
+ "provenance_status": self._evaluation_bridge.provenance_status,
381
+ "scorer_id": self._evaluation_bridge.scorer_id,
382
+ "scorer_revision": self._evaluation_bridge.scorer_revision,
383
+ "source_revision": self._evaluation_bridge.source_revision,
384
+ "test_category": self._evaluation_bridge.test_category,
385
+ },
386
+ label="BFCL v3 evaluation provenance",
387
+ )
388
+
389
+
390
+ def load_bfcl_v3_simple_adapter(
391
+ prepared_root: str | Path,
392
+ *,
393
+ evaluation_bridge: BFCLV3ScorerBridge,
394
+ ) -> PreparedBFCLV3SimpleAdapter:
395
+ """Load the exact checksum-pinned BFCL cell and its typed scorer bridge."""
396
+
397
+ asset = BenchmarkSmokeAssetRegistry.default().get(_ASSET_ID)
398
+ if asset.cell_id != _BENCHMARK_ID or asset.sha256 != BFCL_V3_SOURCE_ARCHIVE_SHA256:
399
+ raise ArtifactError("registered BFCL v3 source identity differs from the production lock")
400
+ prepared = load_prepared_benchmark(asset, prepared_root)
401
+ return _construct_bfcl_v3_simple_adapter(
402
+ prepared,
403
+ evaluation_bridge=evaluation_bridge,
404
+ _construction_token=_LOADER_CONSTRUCTION_TOKEN,
405
+ )
406
+
407
+
408
+ def _construct_bfcl_v3_simple_adapter(
409
+ prepared: PreparedBenchmark,
410
+ *,
411
+ evaluation_bridge: BFCLV3ScorerBridge,
412
+ _construction_token: object,
413
+ ) -> PreparedBFCLV3SimpleAdapter:
414
+ """Internal seam shared only by the verified loader and isolated unit fixtures."""
415
+
416
+ if _construction_token is not _LOADER_CONSTRUCTION_TOKEN:
417
+ raise ValidationError("invalid BFCL v3 loader construction token")
418
+ return PreparedBFCLV3SimpleAdapter(
419
+ prepared,
420
+ evaluation_bridge=evaluation_bridge,
421
+ _construction_token=_construction_token,
422
+ )
423
+
424
+
425
+ def _validate_prepared_identity(prepared: PreparedBenchmark) -> None:
426
+ expected = {
427
+ "asset_id": _ASSET_ID,
428
+ "cell_id": _BENCHMARK_ID,
429
+ "processor": _PROCESSOR,
430
+ "processor_revision": "1",
431
+ "source_revision": BFCL_V3_OFFICIAL_SOURCE_REVISION,
432
+ "source_sha256": BFCL_V3_SOURCE_ARCHIVE_SHA256,
433
+ "split": _SPLIT,
434
+ }
435
+ for name, value in expected.items():
436
+ if getattr(prepared, name) != value:
437
+ raise ArtifactError(f"prepared BFCL v3 identity mismatch for {name}")
438
+ if dict(prepared.counts) != _EXPECTED_COUNTS:
439
+ raise ArtifactError("prepared BFCL v3 counts differ from the audited cell")
440
+ if set(prepared.file_sha256) != {"audit.jsonl", "gold.jsonl", "inputs.jsonl"}:
441
+ raise ArtifactError("prepared BFCL v3 file set is incomplete")
442
+ if prepared.audit_path is None:
443
+ raise ArtifactError("prepared BFCL v3 source audit is missing")
444
+
445
+
446
+ def _validate_scorer_bridge(bridge: BFCLV3ScorerBridge) -> None:
447
+ from .bfcl_native import BFCL_NATIVE_SCOPE, BFCL_NATIVE_SCORER_ID, SourceVerifiedBFCLV3ASTBridge
448
+ if isinstance(bridge,SourceVerifiedBFCLV3ASTBridge):
449
+ if (getattr(bridge,'_verified_source_sha256',None)!=BFCL_V3_SOURCE_ARCHIVE_SHA256
450
+ or bridge.provenance_status!='source_verified' or bridge.evaluation_scope!=BFCL_NATIVE_SCOPE
451
+ or bridge.scorer_id!=BFCL_NATIVE_SCORER_ID or bridge.official_runtime_verified is not False):
452
+ raise ValidationError('BFCL native source/scoring scope differs')
453
+ return
454
+ expected = {
455
+ "ast_checker_revision": BFCL_V3_AST_CHECKER_REVISION,
456
+ "benchmark_id": _BENCHMARK_ID,
457
+ "bfcl_bridge_contract": "bfcl_v3_scorer_bridge_v1",
458
+ "evaluation_scope": _EXTERNAL_BRIDGE,
459
+ "language": "Python",
460
+ "provenance_status": _CALLER_ASSERTED,
461
+ "scorer_id": BFCL_V3_SCORER_ID,
462
+ "scorer_revision": BFCL_V3_SCORER_REVISION,
463
+ "source_revision": BFCL_V3_OFFICIAL_SOURCE_REVISION,
464
+ "test_category": "simple",
465
+ }
466
+ for name, value in expected.items():
467
+ if getattr(bridge, name) != value:
468
+ raise ValidationError(f"BFCL v3 scorer bridge identity mismatch for {name}")
469
+ if bridge.official_runtime_verified is not False:
470
+ raise ValidationError("current BFCL v3 bridge cannot claim official runtime verification")
471
+ for label in ("bridge_id", "model_handler_id"):
472
+ value = getattr(bridge, label)
473
+ if not isinstance(value, str) or not value.strip() or value != value.strip():
474
+ raise ValidationError(f"BFCL v3 scorer bridge {label} must be non-empty")
475
+ for label in ("bridge_revision", "model_handler_revision"):
476
+ value = getattr(bridge, label)
477
+ if not isinstance(value, str) or _SHA256.fullmatch(value) is None:
478
+ raise ValidationError(f"BFCL v3 scorer bridge {label} must be a lowercase SHA-256")
479
+
480
+
481
+ def _validate_source_audit(audit: Mapping[str, Any]) -> None:
482
+ expected_fields = {
483
+ "category",
484
+ "evaluation_boundary",
485
+ "id",
486
+ "license_id",
487
+ "official_cli",
488
+ "selected_source_sha256",
489
+ "source_revision",
490
+ "source_tag",
491
+ }
492
+ if set(audit) != expected_fields:
493
+ raise ArtifactError("BFCL v3 source audit schema differs from the production lock")
494
+ expected = {
495
+ "category": "simple",
496
+ "id": "bfcl-v3-simple-source-audit",
497
+ "license_id": "Apache-2.0",
498
+ "official_cli": "bfcl evaluate --test-category simple",
499
+ "source_revision": BFCL_V3_OFFICIAL_SOURCE_REVISION,
500
+ "source_tag": "v1.3",
501
+ }
502
+ for key, value in expected.items():
503
+ if audit.get(key) != value:
504
+ raise ArtifactError(f"BFCL v3 source audit identity mismatch for {key}")
505
+ if dict(audit.get("selected_source_sha256", {})) != dict(BFCL_V3_SELECTED_SOURCE_SHA256):
506
+ raise ArtifactError("BFCL v3 selected source hashes differ from the audited lock")
507
+ boundary = audit.get("evaluation_boundary")
508
+ if (
509
+ not isinstance(boundary, str)
510
+ or "evaluator-only" not in boundary
511
+ or "does not execute BFCL" not in boundary
512
+ ):
513
+ raise ArtifactError("BFCL v3 source audit does not preserve the evaluation boundary")
514
+
515
+
516
+ def _validated_visible_metadata(value: Any) -> Mapping[str, Any]:
517
+ if not isinstance(value, Mapping) or set(value) != _VISIBLE_METADATA_FIELDS:
518
+ raise ArtifactError("BFCL v3 visible metadata schema differs from the lock")
519
+ if (
520
+ value.get("benchmark_cell") != _BENCHMARK_ID
521
+ or value.get("bfcl_category") != "simple"
522
+ or value.get("source_split") != _SPLIT
523
+ ):
524
+ raise ArtifactError("BFCL v3 visible metadata identity differs from the lock")
525
+ function = value.get("function")
526
+ if not isinstance(function, Mapping) or set(function) != _FUNCTION_FIELDS:
527
+ raise ArtifactError("BFCL v3 function schema differs from the lock")
528
+ _required_text(function, "name", label="BFCL v3 function")
529
+ _required_text(function, "description", label="BFCL v3 function")
530
+ if not isinstance(function.get("parameters"), Mapping):
531
+ raise ArtifactError("BFCL v3 function parameters must be an object")
532
+ return _frozen_mapping(value, label="BFCL v3 visible metadata")
533
+
534
+
535
+ def _verify_prepared_file_hashes(prepared: PreparedBenchmark) -> None:
536
+ for name, expected in sorted(prepared.file_sha256.items()):
537
+ if not isinstance(expected, str) or _SHA256.fullmatch(expected) is None:
538
+ raise ArtifactError(f"prepared BFCL v3 hash is invalid for {name}")
539
+ try:
540
+ actual = sha256_file(prepared.root / name)
541
+ except OSError as exc:
542
+ raise ArtifactError(f"prepared BFCL v3 file cannot be verified: {name}") from exc
543
+ if actual != expected:
544
+ raise ArtifactError(f"prepared BFCL v3 file hash mismatch: {name}")
545
+
546
+
547
+ def _records_by_id(path: Path, *, label: str) -> dict[str, dict[str, Any]]:
548
+ indexed: dict[str, dict[str, Any]] = {}
549
+ for row in _read_jsonl(path, label=label):
550
+ row_id = _required_text(row, "id", label=label)
551
+ if row_id in indexed:
552
+ raise ArtifactError(f"{label} contains duplicate IDs")
553
+ indexed[row_id] = row
554
+ return indexed
555
+
556
+
557
+ def _read_jsonl(path: Path | None, *, label: str) -> list[dict[str, Any]]:
558
+ if path is None:
559
+ raise ArtifactError(f"{label} is missing")
560
+ try:
561
+ lines = path.read_text(encoding="utf-8").splitlines()
562
+ except (OSError, UnicodeError) as exc:
563
+ raise ArtifactError(f"{label} cannot be read as UTF-8") from exc
564
+ rows: list[dict[str, Any]] = []
565
+ for line_number, line in enumerate(lines, start=1):
566
+ if not line.strip():
567
+ raise ArtifactError(f"{label} contains a blank line at {line_number}")
568
+ try:
569
+ value = json.loads(line)
570
+ except json.JSONDecodeError as exc:
571
+ raise ArtifactError(f"{label} contains invalid JSON at line {line_number}") from exc
572
+ if not isinstance(value, dict):
573
+ raise ArtifactError(f"{label} rows must be objects")
574
+ rows.append(value)
575
+ if not rows:
576
+ raise ArtifactError(f"{label} must not be empty")
577
+ return rows
578
+
579
+
580
+ def _required_text(record: Mapping[str, Any], key: str, *, label: str) -> str:
581
+ value = record.get(key)
582
+ if not isinstance(value, str) or not value.strip():
583
+ raise ArtifactError(f"{label} field {key!r} must be a non-empty string")
584
+ return value
585
+
586
+
587
+ def _frozen_mapping(value: Mapping[str, Any], *, label: str) -> Mapping[str, Any]:
588
+ try:
589
+ detached = json.loads(canonical_json(value))
590
+ return freeze_mapping(detached)
591
+ except (TypeError, ValueError) as exc:
592
+ raise ArtifactError(f"{label} must be canonically serializable") from exc
593
+
594
+
595
+ __all__ = [
596
+ "BFCL_V3_AST_CHECKER_REVISION",
597
+ "BFCL_V3_OFFICIAL_SOURCE_REVISION",
598
+ "BFCL_V3_SCORER_ID",
599
+ "BFCL_V3_SCORER_REVISION",
600
+ "BFCL_V3_SELECTED_SOURCE_SHA256",
601
+ "BFCL_V3_SOURCE_ARCHIVE_SHA256",
602
+ "BFCLV3EvaluationResult",
603
+ "BFCLV3ScorerBridge",
604
+ "CallerAssertedBFCLV3ScorerBridge",
605
+ "PreparedBFCLV3SimpleAdapter",
606
+ "load_bfcl_v3_simple_adapter",
607
+ ]