modelrig 0.8.1 → 0.10.0

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 (382) hide show
  1. package/CHANGELOG.md +324 -0
  2. package/README.md +55 -29
  3. package/data/PROVENANCE.md +14 -0
  4. package/data/pricing-map.json +26 -0
  5. package/dist/adapters/attempt-meta-map.d.ts +8 -1
  6. package/dist/adapters/attempt-meta-map.d.ts.map +1 -1
  7. package/dist/adapters/attempt-meta-map.js +4 -0
  8. package/dist/adapters/build-adapters.js +2 -2
  9. package/dist/adapters/gemini.d.ts +28 -1
  10. package/dist/adapters/gemini.d.ts.map +1 -1
  11. package/dist/adapters/gemini.js +38 -9
  12. package/dist/adapters/grok.d.ts.map +1 -1
  13. package/dist/adapters/grok.js +53 -4
  14. package/dist/adapters/openai-compat.d.ts +8 -2
  15. package/dist/adapters/openai-compat.d.ts.map +1 -1
  16. package/dist/adapters/openai-compat.js +8 -1
  17. package/dist/adapters/openai-stream.d.ts +10 -2
  18. package/dist/adapters/openai-stream.d.ts.map +1 -1
  19. package/dist/adapters/openai-stream.js +5 -1
  20. package/dist/adapters/openai.d.ts +10 -1
  21. package/dist/adapters/openai.d.ts.map +1 -1
  22. package/dist/adapters/openai.js +57 -7
  23. package/dist/adapters/responses-api.d.ts +61 -0
  24. package/dist/adapters/responses-api.d.ts.map +1 -0
  25. package/dist/adapters/responses-api.js +124 -0
  26. package/dist/artifacts/artifact.d.ts +31 -12
  27. package/dist/artifacts/artifact.d.ts.map +1 -1
  28. package/dist/artifacts/artifact.js +218 -188
  29. package/dist/artifacts/index.d.ts +15 -5
  30. package/dist/artifacts/index.d.ts.map +1 -1
  31. package/dist/artifacts/index.js +19 -5
  32. package/dist/artifacts/run-context.d.ts +3 -24
  33. package/dist/artifacts/run-context.d.ts.map +1 -1
  34. package/dist/artifacts/run-context.js +3 -39
  35. package/dist/bakeoff/engine.d.ts +29 -0
  36. package/dist/bakeoff/engine.d.ts.map +1 -1
  37. package/dist/bakeoff/engine.js +47 -0
  38. package/dist/bakeoff/eval-cases-rig.d.ts +36 -0
  39. package/dist/bakeoff/eval-cases-rig.d.ts.map +1 -0
  40. package/dist/bakeoff/eval-cases-rig.js +27 -0
  41. package/dist/bakeoff/eval-cases.d.ts +19 -0
  42. package/dist/bakeoff/eval-cases.d.ts.map +1 -1
  43. package/dist/bakeoff/eval-cases.js +18 -1
  44. package/dist/bakeoff/golden-judge.d.ts +47 -0
  45. package/dist/bakeoff/golden-judge.d.ts.map +1 -0
  46. package/dist/bakeoff/golden-judge.js +49 -0
  47. package/dist/bakeoff/groundedness.d.ts +58 -0
  48. package/dist/bakeoff/groundedness.d.ts.map +1 -0
  49. package/dist/bakeoff/groundedness.js +165 -0
  50. package/dist/bakeoff/quality.d.ts +43 -0
  51. package/dist/bakeoff/quality.d.ts.map +1 -1
  52. package/dist/bakeoff/quality.js +31 -0
  53. package/dist/bakeoff/replay.d.ts +11 -0
  54. package/dist/bakeoff/replay.d.ts.map +1 -1
  55. package/dist/bakeoff/replay.js +12 -0
  56. package/dist/bakeoff/report.d.ts +7 -0
  57. package/dist/bakeoff/report.d.ts.map +1 -1
  58. package/dist/bakeoff/report.js +26 -0
  59. package/dist/cli-judge.d.ts +12 -0
  60. package/dist/cli-judge.d.ts.map +1 -0
  61. package/dist/cli-judge.js +48 -0
  62. package/dist/cli.d.ts.map +1 -1
  63. package/dist/cli.js +22 -42
  64. package/dist/config.d.ts +85 -29
  65. package/dist/config.d.ts.map +1 -1
  66. package/dist/config.js +109 -47
  67. package/dist/detect/detector.d.ts +4 -2
  68. package/dist/detect/detector.d.ts.map +1 -1
  69. package/dist/detect/safe-harbor.d.ts +57 -0
  70. package/dist/detect/safe-harbor.d.ts.map +1 -0
  71. package/dist/detect/safe-harbor.js +278 -0
  72. package/dist/doctor-cli.d.ts +7 -0
  73. package/dist/doctor-cli.d.ts.map +1 -0
  74. package/dist/doctor-cli.js +67 -0
  75. package/dist/doctor-preflight.d.ts +52 -0
  76. package/dist/doctor-preflight.d.ts.map +1 -0
  77. package/dist/doctor-preflight.js +112 -0
  78. package/dist/feedback/coverage.d.ts +11 -8
  79. package/dist/feedback/coverage.d.ts.map +1 -1
  80. package/dist/feedback/coverage.js +29 -16
  81. package/dist/feedback/grade.d.ts +58 -0
  82. package/dist/feedback/grade.d.ts.map +1 -0
  83. package/dist/feedback/grade.js +67 -0
  84. package/dist/gateway/http-protocol.d.ts +20 -1
  85. package/dist/gateway/http-protocol.d.ts.map +1 -1
  86. package/dist/gateway/http-protocol.js +1 -1
  87. package/dist/gateway/serve-client.d.ts +99 -0
  88. package/dist/gateway/serve-client.d.ts.map +1 -0
  89. package/dist/gateway/serve-client.js +360 -0
  90. package/dist/index.d.ts +68 -29
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +167 -46
  93. package/dist/init/observe-cli.js +1 -1
  94. package/dist/init/observe.d.ts +2 -2
  95. package/dist/init/observe.d.ts.map +1 -1
  96. package/dist/init/observe.js +11 -7
  97. package/dist/mask/arm.d.ts +112 -0
  98. package/dist/mask/arm.d.ts.map +1 -0
  99. package/dist/mask/arm.js +179 -0
  100. package/dist/mask/index.d.ts +2 -0
  101. package/dist/mask/index.d.ts.map +1 -1
  102. package/dist/mask/index.js +7 -1
  103. package/dist/mask/mask-policy-cli.d.ts +12 -4
  104. package/dist/mask/mask-policy-cli.d.ts.map +1 -1
  105. package/dist/mask/mask-policy-cli.js +34 -9
  106. package/dist/prompts/manifest.d.ts +128 -0
  107. package/dist/prompts/manifest.d.ts.map +1 -0
  108. package/dist/prompts/manifest.js +214 -0
  109. package/dist/prompts/prompt-fetch.d.ts +84 -0
  110. package/dist/prompts/prompt-fetch.d.ts.map +1 -0
  111. package/dist/prompts/prompt-fetch.js +120 -0
  112. package/dist/prompts/prompt-resolve.d.ts +76 -0
  113. package/dist/prompts/prompt-resolve.d.ts.map +1 -0
  114. package/dist/prompts/prompt-resolve.js +93 -0
  115. package/dist/prompts/slot-resolver.d.ts +91 -0
  116. package/dist/prompts/slot-resolver.d.ts.map +1 -0
  117. package/dist/prompts/slot-resolver.js +135 -0
  118. package/dist/prompts/tools-register.d.ts +60 -0
  119. package/dist/prompts/tools-register.d.ts.map +1 -0
  120. package/dist/prompts/tools-register.js +48 -0
  121. package/dist/prompts/version-hash.d.ts +29 -0
  122. package/dist/prompts/version-hash.d.ts.map +1 -0
  123. package/dist/prompts/version-hash.js +54 -0
  124. package/dist/prompts-export-cli.d.ts +21 -0
  125. package/dist/prompts-export-cli.d.ts.map +1 -0
  126. package/dist/prompts-export-cli.js +130 -0
  127. package/dist/query/grammar.d.ts +2 -2
  128. package/dist/query/grammar.d.ts.map +1 -1
  129. package/dist/query/grammar.js +3 -1
  130. package/dist/query/saved.d.ts +13 -0
  131. package/dist/query/saved.d.ts.map +1 -1
  132. package/dist/query/saved.js +67 -1
  133. package/dist/receipts/types.d.ts +1 -1
  134. package/dist/receipts/types.d.ts.map +1 -1
  135. package/dist/receipts/types.js +1 -0
  136. package/dist/registry/build.d.ts +43 -1
  137. package/dist/registry/build.d.ts.map +1 -1
  138. package/dist/registry/build.js +52 -0
  139. package/dist/registry/cache-policy.d.ts.map +1 -1
  140. package/dist/registry/cache-policy.js +22 -0
  141. package/dist/registry/pricing-shape.d.ts +67 -8
  142. package/dist/registry/pricing-shape.d.ts.map +1 -1
  143. package/dist/registry/pricing-shape.js +50 -13
  144. package/dist/registry/pricing.d.ts +6 -5
  145. package/dist/registry/pricing.d.ts.map +1 -1
  146. package/dist/registry/pricing.js +9 -5
  147. package/dist/registry/rows.d.ts.map +1 -1
  148. package/dist/registry/rows.js +1 -0
  149. package/dist/registry/select.d.ts +6 -1
  150. package/dist/registry/select.d.ts.map +1 -1
  151. package/dist/registry/select.js +11 -0
  152. package/dist/routes/call-config.d.ts +199 -0
  153. package/dist/routes/call-config.d.ts.map +1 -0
  154. package/dist/routes/call-config.js +343 -0
  155. package/dist/routes/destination-loader.d.ts +16 -0
  156. package/dist/routes/destination-loader.d.ts.map +1 -0
  157. package/dist/routes/destination-loader.js +29 -0
  158. package/dist/routes/draft.d.ts +7 -0
  159. package/dist/routes/draft.d.ts.map +1 -1
  160. package/dist/routes/draft.js +12 -0
  161. package/dist/routes/loader.d.ts.map +1 -1
  162. package/dist/routes/loader.js +31 -56
  163. package/dist/routes/objective-loader.d.ts +12 -0
  164. package/dist/routes/objective-loader.d.ts.map +1 -1
  165. package/dist/routes/objective-loader.js +82 -0
  166. package/dist/routes/output-loader.d.ts +42 -0
  167. package/dist/routes/output-loader.d.ts.map +1 -0
  168. package/dist/routes/output-loader.js +112 -0
  169. package/dist/routes/prompt-loader.d.ts +49 -0
  170. package/dist/routes/prompt-loader.d.ts.map +1 -0
  171. package/dist/routes/prompt-loader.js +113 -0
  172. package/dist/routes/resolved-bundle.d.ts +69 -0
  173. package/dist/routes/resolved-bundle.d.ts.map +1 -1
  174. package/dist/routes/resolved-bundle.js +76 -0
  175. package/dist/routes/screen-loader.d.ts +29 -1
  176. package/dist/routes/screen-loader.d.ts.map +1 -1
  177. package/dist/routes/screen-loader.js +59 -1
  178. package/dist/run/accept.d.ts +5 -0
  179. package/dist/run/accept.d.ts.map +1 -1
  180. package/dist/run/accept.js +2 -0
  181. package/dist/run/cost.d.ts +31 -2
  182. package/dist/run/cost.d.ts.map +1 -1
  183. package/dist/run/cost.js +57 -2
  184. package/dist/run/destination.d.ts +39 -0
  185. package/dist/run/destination.d.ts.map +1 -0
  186. package/dist/run/destination.js +45 -0
  187. package/dist/run/dispatch.d.ts +67 -16
  188. package/dist/run/dispatch.d.ts.map +1 -1
  189. package/dist/run/dispatch.js +133 -29
  190. package/dist/run/grounding.d.ts +28 -2
  191. package/dist/run/grounding.d.ts.map +1 -1
  192. package/dist/run/grounding.js +54 -10
  193. package/dist/run/raw-defaults.d.ts.map +1 -1
  194. package/dist/run/raw-defaults.js +6 -1
  195. package/dist/run/raw-finalize.d.ts +50 -0
  196. package/dist/run/raw-finalize.d.ts.map +1 -0
  197. package/dist/run/raw-finalize.js +266 -0
  198. package/dist/run/raw-knobs.d.ts +36 -0
  199. package/dist/run/raw-knobs.d.ts.map +1 -0
  200. package/dist/run/raw-knobs.js +99 -0
  201. package/dist/run/raw-request.d.ts +24 -0
  202. package/dist/run/raw-request.d.ts.map +1 -0
  203. package/dist/run/raw-request.js +69 -0
  204. package/dist/run/raw-schema.d.ts +76 -0
  205. package/dist/run/raw-schema.d.ts.map +1 -0
  206. package/dist/run/raw-schema.js +166 -0
  207. package/dist/run/raw-search-cost.d.ts +48 -0
  208. package/dist/run/raw-search-cost.d.ts.map +1 -0
  209. package/dist/run/raw-search-cost.js +78 -0
  210. package/dist/run/raw-support.d.ts +64 -6
  211. package/dist/run/raw-support.d.ts.map +1 -1
  212. package/dist/run/raw-support.js +84 -11
  213. package/dist/run/raw.d.ts +25 -26
  214. package/dist/run/raw.d.ts.map +1 -1
  215. package/dist/run/raw.js +30 -351
  216. package/dist/run/record-attempt.d.ts +12 -0
  217. package/dist/run/record-attempt.d.ts.map +1 -1
  218. package/dist/run/record-attempt.js +30 -12
  219. package/dist/run/repair-attempt.d.ts +68 -0
  220. package/dist/run/repair-attempt.d.ts.map +1 -0
  221. package/dist/run/repair-attempt.js +180 -0
  222. package/dist/run/resolve-destination.d.ts +49 -0
  223. package/dist/run/resolve-destination.d.ts.map +1 -0
  224. package/dist/run/resolve-destination.js +76 -0
  225. package/dist/run/routing-docs.d.ts.map +1 -1
  226. package/dist/run/routing-docs.js +10 -5
  227. package/dist/run/run.d.ts +30 -1
  228. package/dist/run/run.d.ts.map +1 -1
  229. package/dist/run/run.js +94 -172
  230. package/dist/run/telemetry-row.d.ts +92 -0
  231. package/dist/run/telemetry-row.d.ts.map +1 -0
  232. package/dist/run/telemetry-row.js +81 -0
  233. package/dist/run/validate.d.ts +12 -1
  234. package/dist/run/validate.d.ts.map +1 -1
  235. package/dist/run/validate.js +31 -0
  236. package/dist/run/web-search-pricing.d.ts +43 -0
  237. package/dist/run/web-search-pricing.d.ts.map +1 -0
  238. package/dist/run/web-search-pricing.js +56 -0
  239. package/dist/savings/odometer.d.ts +4 -0
  240. package/dist/savings/odometer.d.ts.map +1 -1
  241. package/dist/savings/odometer.js +20 -1
  242. package/dist/savings/swap-execute.d.ts +7 -0
  243. package/dist/savings/swap-execute.d.ts.map +1 -1
  244. package/dist/savings/swap-execute.js +30 -0
  245. package/dist/savings/swaps-client.d.ts +10 -0
  246. package/dist/savings/swaps-client.d.ts.map +1 -1
  247. package/dist/screen/fixtures/probe-corpora.d.ts +23 -0
  248. package/dist/screen/fixtures/probe-corpora.d.ts.map +1 -0
  249. package/dist/screen/fixtures/probe-corpora.js +69 -0
  250. package/dist/screen/index.d.ts +21 -0
  251. package/dist/screen/index.d.ts.map +1 -0
  252. package/dist/screen/index.js +64 -0
  253. package/dist/screen/model-screen.d.ts +111 -0
  254. package/dist/screen/model-screen.d.ts.map +1 -0
  255. package/dist/screen/model-screen.js +178 -0
  256. package/dist/screen/patterns.d.ts +51 -0
  257. package/dist/screen/patterns.d.ts.map +1 -0
  258. package/dist/screen/patterns.js +151 -0
  259. package/dist/screen/phi-gate.d.ts +52 -0
  260. package/dist/screen/phi-gate.d.ts.map +1 -0
  261. package/dist/screen/phi-gate.js +86 -0
  262. package/dist/screen/policy.d.ts +71 -0
  263. package/dist/screen/policy.d.ts.map +1 -0
  264. package/dist/screen/policy.js +334 -0
  265. package/dist/screen/probe.d.ts +118 -0
  266. package/dist/screen/probe.d.ts.map +1 -0
  267. package/dist/screen/probe.js +132 -0
  268. package/dist/screen/screen-cli.d.ts +16 -0
  269. package/dist/screen/screen-cli.d.ts.map +1 -0
  270. package/dist/screen/screen-cli.js +178 -0
  271. package/dist/screen/screen.d.ts +99 -0
  272. package/dist/screen/screen.d.ts.map +1 -0
  273. package/dist/screen/screen.js +0 -0
  274. package/dist/screen/sidecar.d.ts +69 -0
  275. package/dist/screen/sidecar.d.ts.map +1 -0
  276. package/dist/screen/sidecar.js +145 -0
  277. package/dist/screen/types.d.ts +43 -2
  278. package/dist/screen/types.d.ts.map +1 -1
  279. package/dist/settings/api-fetcher.d.ts +14 -3
  280. package/dist/settings/api-fetcher.d.ts.map +1 -1
  281. package/dist/settings/api-fetcher.js +61 -10
  282. package/dist/settings/grading-guide.d.ts +102 -0
  283. package/dist/settings/grading-guide.d.ts.map +1 -0
  284. package/dist/settings/grading-guide.js +23 -0
  285. package/dist/settings/index.d.ts +3 -2
  286. package/dist/settings/index.d.ts.map +1 -1
  287. package/dist/settings/index.js +2 -1
  288. package/dist/settings/task-settings.d.ts +44 -7
  289. package/dist/settings/task-settings.d.ts.map +1 -1
  290. package/dist/settings/task-settings.js +53 -12
  291. package/dist/status.d.ts +32 -20
  292. package/dist/status.d.ts.map +1 -1
  293. package/dist/status.js +51 -30
  294. package/dist/telemetry/artifact-store.d.ts +5 -6
  295. package/dist/telemetry/artifact-store.d.ts.map +1 -1
  296. package/dist/telemetry/artifact-store.js +21 -24
  297. package/dist/telemetry/attempt-meta.d.ts +76 -1
  298. package/dist/telemetry/attempt-meta.d.ts.map +1 -1
  299. package/dist/telemetry/attempt-meta.js +33 -1
  300. package/dist/telemetry/exporter-setup.d.ts +2 -0
  301. package/dist/telemetry/exporter-setup.d.ts.map +1 -1
  302. package/dist/telemetry/exporter-setup.js +6 -1
  303. package/dist/telemetry/exporter.d.ts +2 -2
  304. package/dist/telemetry/exporter.d.ts.map +1 -1
  305. package/dist/telemetry/exporter.js +22 -41
  306. package/dist/telemetry/grade-mappers.d.ts +25 -0
  307. package/dist/telemetry/grade-mappers.d.ts.map +1 -0
  308. package/dist/telemetry/grade-mappers.js +64 -0
  309. package/dist/telemetry/grades-sql.d.ts +56 -0
  310. package/dist/telemetry/grades-sql.d.ts.map +1 -0
  311. package/dist/telemetry/grades-sql.js +156 -0
  312. package/dist/telemetry/ingest-protocol.d.ts +55 -48
  313. package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
  314. package/dist/telemetry/ingest-protocol.js +48 -83
  315. package/dist/telemetry/org-identity.d.ts +44 -0
  316. package/dist/telemetry/org-identity.d.ts.map +1 -0
  317. package/dist/telemetry/org-identity.js +98 -0
  318. package/dist/telemetry/route-registration.d.ts +48 -0
  319. package/dist/telemetry/route-registration.d.ts.map +1 -0
  320. package/dist/telemetry/route-registration.js +77 -0
  321. package/dist/telemetry/sinks.d.ts +10 -1
  322. package/dist/telemetry/sinks.d.ts.map +1 -1
  323. package/dist/telemetry/sinks.js +52 -6
  324. package/dist/telemetry/store-migrations.d.ts.map +1 -1
  325. package/dist/telemetry/store-migrations.js +64 -0
  326. package/dist/telemetry/store.d.ts +9 -6
  327. package/dist/telemetry/store.d.ts.map +1 -1
  328. package/dist/telemetry/store.js +8 -50
  329. package/dist/tenancy/api-key-format.d.ts +45 -1
  330. package/dist/tenancy/api-key-format.d.ts.map +1 -1
  331. package/dist/tenancy/api-key-format.js +50 -1
  332. package/dist/types/provider.d.ts +23 -3
  333. package/dist/types/provider.d.ts.map +1 -1
  334. package/dist/types/provider.js +26 -0
  335. package/dist/types/route.d.ts +154 -2
  336. package/dist/types/route.d.ts.map +1 -1
  337. package/dist/types/telemetry.d.ts +73 -48
  338. package/dist/types/telemetry.d.ts.map +1 -1
  339. package/dist/validate-cli.d.ts.map +1 -1
  340. package/dist/validate-cli.js +32 -0
  341. package/dist/verify/verify.d.ts +5 -0
  342. package/dist/verify/verify.d.ts.map +1 -1
  343. package/dist/verify/verify.js +2 -0
  344. package/dist/watch/evaluate.d.ts +84 -1
  345. package/dist/watch/evaluate.d.ts.map +1 -1
  346. package/dist/watch/evaluate.js +28 -0
  347. package/dist/watch/monitor.d.ts +8 -2
  348. package/dist/watch/monitor.d.ts.map +1 -1
  349. package/dist/watch/monitor.js +13 -5
  350. package/dist/watch/regret-monitor-cli.d.ts +16 -0
  351. package/dist/watch/regret-monitor-cli.d.ts.map +1 -0
  352. package/dist/watch/regret-monitor-cli.js +137 -0
  353. package/dist/watch/regret-monitor.d.ts +168 -0
  354. package/dist/watch/regret-monitor.d.ts.map +1 -0
  355. package/dist/watch/regret-monitor.js +304 -0
  356. package/dist/watch/upgrade.d.ts +62 -0
  357. package/dist/watch/upgrade.d.ts.map +1 -0
  358. package/dist/watch/upgrade.js +57 -0
  359. package/docs/agent-skill/SKILL.md +181 -9
  360. package/docs/how-it-fits.md +3 -2
  361. package/docs/instrumentation.md +219 -46
  362. package/docs/llms.txt +158 -35
  363. package/docs/managed-serving.md +150 -0
  364. package/docs/mcp-oracle.md +322 -0
  365. package/docs/migration-playbook.md +5 -4
  366. package/docs/quickstart.md +263 -89
  367. package/package.json +18 -4
  368. package/registry/leaderboard.json +74 -0
  369. package/registry/registry.json +232 -112
  370. package/screen.d.ts +16 -0
  371. package/templates/call-disposition-qa.json +77 -0
  372. package/templates/catalog-cleansing.json +77 -0
  373. package/templates/compliance-review.json +76 -0
  374. package/templates/cs-next-action.json +76 -0
  375. package/templates/document-extraction.json +78 -0
  376. package/templates/financial-classification.json +75 -0
  377. package/templates/lead-qualification.json +76 -0
  378. package/templates/medical-classification.json +71 -0
  379. package/templates/ticket-triage.json +76 -0
  380. package/dist/feedback/feedback.d.ts +0 -35
  381. package/dist/feedback/feedback.d.ts.map +0 -1
  382. package/dist/feedback/feedback.js +0 -39
@@ -13,12 +13,13 @@
13
13
  * write that fails is logged and dropped; the customer's pipeline is untouched.
14
14
  *
15
15
  * ── GATING ────────────────────────────────────────────────────────────────
16
- * The namespace is inert unless the rig enabled it (`MODELRIG_ARTIFACTS=1`).
16
+ * The namespace is inert unless the rig enabled it (a control plane is configured,
17
+ * or the dev-only local force-on; the org capture posture governs at runtime).
17
18
  * A disabled namespace's `run.start()` sets NO context, so `getActiveRunContext`
18
19
  * returns null everywhere and the run loop's auto-step is never reached —
19
20
  * v1 wire, zero new rows, zero behaviour change (spec §1.4).
20
21
  */
21
- import type { ArtifactEvaluationRow, RunRow, StepRow } from "../types/telemetry";
22
+ import type { RunRow, StepRow } from "../types/telemetry";
22
23
  import type { RunMetaV1 } from "../telemetry/attempt-meta";
23
24
  /** The narrow buffer the run/artifact namespace writes through — the local
24
25
  * telemetry store satisfies it. Kept narrow so this module depends on the row
@@ -119,23 +120,10 @@ export declare function isValidStepKey(key: string): boolean;
119
120
  export declare function resolveStepKey(explicit: string | undefined, tagStep: string | undefined, auto: () => string): string;
120
121
  /** Test-only: clear the once-per-process invalid-stepKey warning latch. */
121
122
  export declare function resetStepKeyWarningsForTest(): void;
122
- /** A run-level evaluation the caller attaches (E5 chunk V.2) — the run-subject
123
- * mirror of ArtifactEvaluateOptions. The subject is the run, so there is no ref. */
124
- export interface RunEvaluateOptions {
125
- readonly evaluator: string;
126
- readonly kind: "deterministic" | "model-judge" | "human";
127
- readonly score?: number;
128
- readonly passed?: boolean;
129
- readonly label?: string;
130
- readonly explanation?: string;
131
- }
132
123
  /** A handle a caller holds to end a run it started. */
133
124
  export interface RunHandle {
134
125
  readonly runId: string;
135
126
  end(status?: RunStatus): void;
136
- /** Attach a run-level evaluation to THIS run (E5 V.2). Works after end() —
137
- * verdicts are often post-hoc. Fail-open + inert when the namespace is off. */
138
- evaluate(opts: RunEvaluateOptions): void;
139
127
  }
140
128
  /** The `run` namespace, bound to one rig's buffer + gate. Disabled ⇒ inert. */
141
129
  export interface RunNamespace {
@@ -147,9 +135,6 @@ export interface RunNamespace {
147
135
  start(opts: RunStartOptions): RunHandle;
148
136
  /** End the active run with a terminal status (default "succeeded"). */
149
137
  end(status?: RunStatus): void;
150
- /** Attach a run-level evaluation to the ACTIVE run (E5 V.2) — the run-subject
151
- * mirror of `artifact.evaluate`. No active run ⇒ a warned no-op (fail-open). */
152
- evaluate(opts: RunEvaluateOptions): void;
153
138
  /** Concurrency-safe run scope. Runs `fn` inside `AsyncLocalStorage.run`, so
154
139
  * overlapping `scope()` calls each keep their OWN ambient run context — the
155
140
  * correct primitive for `Promise.all` over items. Ends the run "succeeded" on
@@ -160,11 +145,5 @@ export interface RunNamespace {
160
145
  export declare function createRunNamespace(deps: {
161
146
  readonly buffer: ArtifactBuffer;
162
147
  readonly enabled: boolean;
163
- /** The evaluation writer (E5 V.2) — the artifact store's recordArtifactEvaluation.
164
- * Absent (disabled / no store) ⇒ run.evaluate is inert. Kept OFF the narrow
165
- * ArtifactBuffer so that contract stays "cannot reach anything but run/step". */
166
- readonly artifactStore?: {
167
- recordArtifactEvaluation(row: ArtifactEvaluationRow): void;
168
- };
169
148
  }): RunNamespace;
170
149
  //# sourceMappingURL=run-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-context.d.ts","sourceRoot":"","sources":["../../src/artifacts/run-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAI3D;;sEAEsE;AACtE,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,mEAAmE;IACnE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;wEAEoE;IACpE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;oCAGgC;IAChC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC;;;;mCAI+B;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;CAC3B;A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15
  *
16
16
  * ── GATING ────────────────────────────────────────────────────────────────
17
- * The namespace is inert unless the rig enabled it (`MODELRIG_ARTIFACTS=1`).
17
+ * The namespace is inert unless the rig enabled it (a control plane is configured,
18
+ * or the dev-only local force-on; the org capture posture governs at runtime).
18
19
  * A disabled namespace's `run.start()` sets NO context, so `getActiveRunContext`
19
20
  * returns null everywhere and the run loop's auto-step is never reached —
20
21
  * v1 wire, zero new rows, zero behaviour change (spec §1.4).
@@ -129,30 +130,7 @@ function warnOnce(scope, err) {
129
130
  }
130
131
  function createRunNamespace(deps) {
131
132
  const { buffer, enabled } = deps;
132
- const evalStore = deps.artifactStore;
133
- /** Write ONE run-subject evaluation (artifactId null, runId set). Fail-open. */
134
- function writeRunEvaluation(runId, opts) {
135
- if (!enabled || evalStore === undefined || runId === "")
136
- return;
137
- try {
138
- evalStore.recordArtifactEvaluation({
139
- id: (0, node_crypto_1.randomUUID)(),
140
- artifactId: null,
141
- runId,
142
- evaluator: opts.evaluator,
143
- evaluatorKind: opts.kind,
144
- score: opts.score ?? null,
145
- passed: opts.passed ?? null,
146
- label: opts.label ?? null,
147
- explanation: opts.explanation ?? null,
148
- createdBy: null,
149
- });
150
- }
151
- catch (err) {
152
- warnOnce("run.evaluate", err);
153
- }
154
- }
155
- const inertHandle = { runId: "", end() { }, evaluate() { } };
133
+ const inertHandle = { runId: "", end() { } };
156
134
  function buildContext(startRow, traceId, zeroRetention) {
157
135
  const runId = startRow.id;
158
136
  const episodeKey = startRow.episodeKey;
@@ -250,7 +228,6 @@ function createRunNamespace(deps) {
250
228
  return {
251
229
  runId: ctx.runId,
252
230
  end: (status) => endContext(ctx, status),
253
- evaluate: (opts2) => writeRunEvaluation(ctx.runId, opts2),
254
231
  };
255
232
  },
256
233
  end(status) {
@@ -258,19 +235,6 @@ function createRunNamespace(deps) {
258
235
  if (ctx !== undefined)
259
236
  endContext(ctx, status);
260
237
  },
261
- evaluate(opts) {
262
- const ctx = storage.getStore();
263
- // `ended` counts as gone — same rule as getActiveRunContext. `enterWith`
264
- // has no lexical exit, so an ended run's context stays ambient on this
265
- // async path; without this check ns.evaluate re-attributes verdicts to
266
- // the ended run (post-end verdicts belong to the HANDLE, which closes
267
- // over its runId — that path is unaffected).
268
- if (ctx === undefined || ctx.ended) {
269
- console.warn("[modelrig artifacts] run.evaluate() with no active run — dropped");
270
- return;
271
- }
272
- writeRunEvaluation(ctx.runId, opts);
273
- },
274
238
  async scope(opts, fn) {
275
239
  if (!enabled)
276
240
  return fn();
@@ -13,6 +13,7 @@
13
13
  import type { CaptureStore } from "../telemetry/capture";
14
14
  import type { RunDeps } from "../run/run";
15
15
  import type { CandidateSpec, ObjectiveMode, RouteBundle } from "../types/route";
16
+ import type { GraderType } from "./quality";
16
17
  import type { QualityGate } from "../types/quality";
17
18
  import type { ArmSamples, KeepOutputsMode } from "./samples";
18
19
  import type { BakeoffArtifact, BakeoffObjective, VariantMetrics } from "./types";
@@ -52,6 +53,10 @@ export interface BakeoffRequest {
52
53
  readonly expected?: ReadonlyMap<string, {
53
54
  readonly value: unknown;
54
55
  }>;
56
+ /** LRE-1b: the golden set's grader for `expected` scoring (`exact` binary /
57
+ * `field-level` per-field / `llm-judge` deferred). Set by the from-eval-cases
58
+ * runner from the eval set's grader; absent ⇒ field-level (pre-LRE-1b). */
59
+ readonly graderType?: GraderType;
55
60
  /** Q1 quality gate (spec §4.2): scored on every replayed sample to populate
56
61
  * valueAccuracy + the quality pass rate, unlocking computeProposal's cost-first
57
62
  * third clause. A function, so it rides `rig.bakeoff` (programmatic) only — the
@@ -84,11 +89,35 @@ export interface BakeoffMirrorConfig {
84
89
  * Same PostgREST transport pattern as the telemetry exporter; captures have
85
90
  * no cloud surface — ONLY aggregate metrics travel. */
86
91
  export declare function mirrorBakeoff(artifact: BakeoffArtifact, config: BakeoffMirrorConfig): Promise<void>;
92
+ /** N4 swap direction (near-optimal spec §4.2): the winner's effective $/1k vs the
93
+ * incumbent's. `up` = better-and-dearer (raises cost to cut regret); `down` = the
94
+ * shipped saving; `lateral` = within EPS (RB-1 never proposes a true lateral, but
95
+ * the label is honest at the boundary). Zero new measurement — both arms are
96
+ * already in the matrix. */
97
+ export interface SwapDirection {
98
+ readonly direction: "up" | "down" | "lateral";
99
+ /** winnerEff − incumbentEff, signed (USD per 1k conformant); null if either ∞. */
100
+ readonly costDeltaUsdPer1k: number | null;
101
+ }
102
+ /**
103
+ * Derive a bake-off's proposed-swap direction from the winner's vs the
104
+ * incumbent's `effectiveUsdPer1kConformant` (spec §4.2). The incumbent is the
105
+ * `default` arm when present, else the first non-reference arm — matching
106
+ * `computeProposal`'s incumbent selection (requested variants keep their order in
107
+ * the matrix, with the reference pushed last). Null when there is no proposal.
108
+ * Pure, additive: `computeProposal` is untouched (the winner is only read back).
109
+ */
110
+ export declare function deriveSwapDirection(artifact: BakeoffArtifact): SwapDirection | null;
87
111
  /**
88
112
  * The proposal-evidence jsonb for a bake-off artifact (near-optimal spec §4.6) —
89
113
  * the winning variant, the RB-1 objective/reference/regret/quality_metric, and a
90
114
  * per-arm matrix (with per-arm regret). Built here so the CLI stays thin; the PR
91
115
  * body reads these fields back off `proposal.evidence`. ZERO DDL — freeform jsonb.
116
+ *
117
+ * N4 (spec §4.2, ADDITIVE): when a proposal exists, stamp `swap_direction` +
118
+ * `cost_delta_usd_per_1k` so the PR body, the approval prompt, and the odometer
119
+ * treat a cost-raising promotion honestly. Absent on a no-proposal artifact (the
120
+ * existing evidence shape is byte-identical).
92
121
  */
93
122
  export declare function bakeoffEvidence(artifact: BakeoffArtifact, spentUsd: number): Record<string, unknown>;
94
123
  //# sourceMappingURL=engine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/bakeoff/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CA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,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,eAAe,GAAG,aAAa,GAAG,IAAI,CAkBnF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA2CpG"}
@@ -16,12 +16,14 @@ exports.REFERENCE_ARM = void 0;
16
16
  exports.runBakeoff = runBakeoff;
17
17
  exports.computeProposal = computeProposal;
18
18
  exports.mirrorBakeoff = mirrorBakeoff;
19
+ exports.deriveSwapDirection = deriveSwapDirection;
19
20
  exports.bakeoffEvidence = bakeoffEvidence;
20
21
  const node_crypto_1 = require("node:crypto");
21
22
  const loader_1 = require("../routes/loader");
22
23
  const replay_1 = require("./replay");
23
24
  const stats_1 = require("./stats");
24
25
  const judge_1 = require("./judge");
26
+ const golden_judge_1 = require("./golden-judge");
25
27
  const pairwise_1 = require("./pairwise");
26
28
  const disagreement_1 = require("./disagreement");
27
29
  const reference_1 = require("./reference");
@@ -81,6 +83,11 @@ async function runBakeoff(deps, captures, req, samplesSink) {
81
83
  // reference comparison in the engine) — WITHOUT the keepOutputs sink persist.
82
84
  const pairwiseJudgeCfg = route.bakeoff?.pairwise?.judge;
83
85
  const retainForPairwise = pairwiseJudgeCfg !== undefined;
86
+ // LRE-2 llm-judge grader: when the eval set grades by `llm-judge`, each arm's
87
+ // output is scored against its GOLDEN via the pairwise judge. Reuse the route's
88
+ // declared (load-validated, #223 F3) pairwise/bakeoff judge model — a golden
89
+ // judge is built FRESH per arm (its cap is per arm) inside the replay calls.
90
+ const goldenJudgeCfg = req.graderType === "llm-judge" ? (route.bakeoff?.pairwise?.judge ?? route.bakeoff?.judge) : undefined;
84
91
  // Replay every requested arm. Raw samples are kept ALWAYS (paired regret is
85
92
  // computed from per-sample quality); the keepOutputs sink is separate. A fresh
86
93
  // judge scorer per arm keeps `max_samples` per-arm (spec §4.3).
@@ -96,7 +103,9 @@ async function runBakeoff(deps, captures, req, samplesSink) {
96
103
  ...(keepOutputs ? { keepOutputs: true } : {}),
97
104
  ...(retainForPairwise ? { retainOutputForPairwise: true } : {}),
98
105
  ...(req.expected !== undefined ? { expected: req.expected } : {}),
106
+ ...(req.graderType !== undefined ? { graderType: req.graderType } : {}),
99
107
  ...(judgeCfg !== undefined ? { judge: (0, judge_1.makeJudgeScorer)(deps, route, judgeCfg) } : {}),
108
+ ...(goldenJudgeCfg !== undefined ? { goldenJudge: (0, golden_judge_1.makeGoldenJudge)(deps, route, goldenJudgeCfg) } : {}),
100
109
  ...(req.qualityGate !== undefined ? { qualityGate: req.qualityGate } : {}),
101
110
  });
102
111
  replayN = Math.max(replayN, samples.length);
@@ -122,7 +131,9 @@ async function runBakeoff(deps, captures, req, samplesSink) {
122
131
  envelopeUsd: refEnvelope,
123
132
  ...(retainForPairwise ? { retainOutputForPairwise: true } : {}),
124
133
  ...(req.expected !== undefined ? { expected: req.expected } : {}),
134
+ ...(req.graderType !== undefined ? { graderType: req.graderType } : {}),
125
135
  ...(judgeCfg !== undefined ? { judge: (0, judge_1.makeJudgeScorer)(deps, route, judgeCfg) } : {}),
136
+ ...(goldenJudgeCfg !== undefined ? { goldenJudge: (0, golden_judge_1.makeGoldenJudge)(deps, route, goldenJudgeCfg) } : {}),
126
137
  ...(req.qualityGate !== undefined ? { qualityGate: req.qualityGate } : {}),
127
138
  });
128
139
  const partial = refSamples.length < replayN || refSamples.some((s) => s.failureClass === "budget_exhausted");
@@ -421,14 +432,50 @@ async function mirrorBakeoff(artifact, config) {
421
432
  throw new Error(`bakeoff mirror upsert → ${response.status} ${await response.text().catch(() => "")}`);
422
433
  }
423
434
  }
435
+ /**
436
+ * Derive a bake-off's proposed-swap direction from the winner's vs the
437
+ * incumbent's `effectiveUsdPer1kConformant` (spec §4.2). The incumbent is the
438
+ * `default` arm when present, else the first non-reference arm — matching
439
+ * `computeProposal`'s incumbent selection (requested variants keep their order in
440
+ * the matrix, with the reference pushed last). Null when there is no proposal.
441
+ * Pure, additive: `computeProposal` is untouched (the winner is only read back).
442
+ */
443
+ function deriveSwapDirection(artifact) {
444
+ const p = artifact.proposal;
445
+ if (p === null || p === undefined)
446
+ return null;
447
+ const winner = artifact.variants.find((m) => m.variant === p.variant);
448
+ const incumbent = artifact.variants.find((m) => m.variant === "default" && m.isReference !== true) ??
449
+ artifact.variants.find((m) => m.isReference !== true);
450
+ if (winner === undefined || incumbent === undefined)
451
+ return null;
452
+ const w = winner.effectiveUsdPer1kConformant;
453
+ const i = incumbent.effectiveUsdPer1kConformant;
454
+ const costDeltaUsdPer1k = Number.isFinite(w) && Number.isFinite(i) ? w - i : null;
455
+ const direction = costDeltaUsdPer1k === null || Math.abs(costDeltaUsdPer1k) <= EPS
456
+ ? "lateral"
457
+ : costDeltaUsdPer1k > 0
458
+ ? "up"
459
+ : "down";
460
+ return { direction, costDeltaUsdPer1k };
461
+ }
424
462
  /**
425
463
  * The proposal-evidence jsonb for a bake-off artifact (near-optimal spec §4.6) —
426
464
  * the winning variant, the RB-1 objective/reference/regret/quality_metric, and a
427
465
  * per-arm matrix (with per-arm regret). Built here so the CLI stays thin; the PR
428
466
  * body reads these fields back off `proposal.evidence`. ZERO DDL — freeform jsonb.
467
+ *
468
+ * N4 (spec §4.2, ADDITIVE): when a proposal exists, stamp `swap_direction` +
469
+ * `cost_delta_usd_per_1k` so the PR body, the approval prompt, and the odometer
470
+ * treat a cost-raising promotion honestly. Absent on a no-proposal artifact (the
471
+ * existing evidence shape is byte-identical).
429
472
  */
430
473
  function bakeoffEvidence(artifact, spentUsd) {
474
+ const dir = deriveSwapDirection(artifact);
431
475
  return {
476
+ ...(dir !== null
477
+ ? { swap_direction: dir.direction, cost_delta_usd_per_1k: dir.costDeltaUsdPer1k }
478
+ : {}),
432
479
  bakeoff_id: artifact.id,
433
480
  replay_n: artifact.replayN,
434
481
  ran_at: artifact.ranAt,
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The rig-facing from-eval-cases bake-off delegates — extracted from index.ts to
3
+ * keep it under the 700-LOC cap (P1). Both `rig.bakeoffFromEvalCases` (LOCAL
4
+ * artifact store + captures) and `rig.bakeoffFromEvalCasesWith` (LRE-1b: stores
5
+ * the CALLER injects — the server's cross-plane rehydration resolver) funnel
6
+ * through `runRigEvalCasesBakeoff`, so option defaulting lives in one place.
7
+ */
8
+ import { type EvalCaseBakeoffResult, type EvalCaseStores } from "./eval-cases";
9
+ import type { BakeoffSamplesSink } from "./engine";
10
+ import type { GraderType } from "./quality";
11
+ import type { KeepOutputsMode } from "./samples";
12
+ import type { RunDeps } from "../run/run";
13
+ import type { CandidateSpec, ObjectiveMode, RouteBundle } from "../types/route";
14
+ import type { QualityGate } from "../types/quality";
15
+ /** The shared option shape for both from-eval-cases rig entry points. */
16
+ export interface EvalCasesBakeoffOpts {
17
+ readonly variants: readonly string[];
18
+ readonly envelopeUsdPerVariant?: number;
19
+ readonly keepOutputs?: KeepOutputsMode;
20
+ readonly objectiveMode?: ObjectiveMode;
21
+ readonly qualityGate?: QualityGate;
22
+ readonly graderType?: GraderType;
23
+ }
24
+ /** Run the from-eval-cases engine over the given deps + stores, defaulting the
25
+ * envelope and threading the reference-auto resolver + samples sink. Pure over
26
+ * its inputs — no local-store assumptions (the caller picks the stores). */
27
+ export declare function runRigEvalCasesBakeoff(input: {
28
+ readonly deps: RunDeps;
29
+ readonly stores: EvalCaseStores;
30
+ readonly task: string;
31
+ readonly samplesSink?: BakeoffSamplesSink;
32
+ readonly resolveReferenceAuto: (route: RouteBundle) => CandidateSpec | null;
33
+ readonly defaultEnvelopeUsd: number;
34
+ readonly opts: EvalCasesBakeoffOpts;
35
+ }): Promise<EvalCaseBakeoffResult>;
36
+ //# sourceMappingURL=eval-cases-rig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-cases-rig.d.ts","source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C;IACpC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;CACrC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAiBjC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /**
3
+ * The rig-facing from-eval-cases bake-off delegates — extracted from index.ts to
4
+ * keep it under the 700-LOC cap (P1). Both `rig.bakeoffFromEvalCases` (LOCAL
5
+ * artifact store + captures) and `rig.bakeoffFromEvalCasesWith` (LRE-1b: stores
6
+ * the CALLER injects — the server's cross-plane rehydration resolver) funnel
7
+ * through `runRigEvalCasesBakeoff`, so option defaulting lives in one place.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.runRigEvalCasesBakeoff = runRigEvalCasesBakeoff;
11
+ const eval_cases_1 = require("./eval-cases");
12
+ /** Run the from-eval-cases engine over the given deps + stores, defaulting the
13
+ * envelope and threading the reference-auto resolver + samples sink. Pure over
14
+ * its inputs — no local-store assumptions (the caller picks the stores). */
15
+ function runRigEvalCasesBakeoff(input) {
16
+ const { deps, stores, task, samplesSink, resolveReferenceAuto, defaultEnvelopeUsd, opts } = input;
17
+ return (0, eval_cases_1.runBakeoffFromEvalCases)(deps, stores, {
18
+ task,
19
+ variants: opts.variants,
20
+ envelopeUsdPerVariant: opts.envelopeUsdPerVariant ?? defaultEnvelopeUsd,
21
+ qualityGate: opts.qualityGate,
22
+ ...(opts.keepOutputs !== undefined ? { keepOutputs: opts.keepOutputs } : {}),
23
+ ...(opts.objectiveMode !== undefined ? { objectiveMode: opts.objectiveMode } : {}),
24
+ ...(opts.graderType !== undefined ? { graderType: opts.graderType } : {}),
25
+ resolveReferenceAuto,
26
+ }, samplesSink);
27
+ }
@@ -21,6 +21,7 @@ import type { ExportableTelemetryStore } from "../telemetry/store";
21
21
  import type { EvalCaseRow } from "../types/telemetry";
22
22
  import type { RunDeps } from "../run/run";
23
23
  import { type BakeoffSamplesSink } from "./engine";
24
+ import type { GraderType } from "./quality";
24
25
  import type { KeepOutputsMode } from "./samples";
25
26
  import type { BakeoffArtifact } from "./types";
26
27
  import type { CandidateSpec, ObjectiveMode, RouteBundle } from "../types/route";
@@ -39,6 +40,10 @@ export interface EvalCaseSelectionDeps {
39
40
  export interface RehydratedCase {
40
41
  readonly caseId: string;
41
42
  readonly capture: CaptureRow;
43
+ /** LRE-1b: the golden (corrected) artifact id, or null for a failure case (no
44
+ * golden to grade against — it scores by conformance only). Carried so the
45
+ * runner can build the `expected` map from the golden's content. */
46
+ readonly correctedArtifactId: string | null;
42
47
  }
43
48
  export interface EvalCaseRefusal {
44
49
  readonly caseId: string;
@@ -88,6 +93,15 @@ export interface EvalCaseStores {
88
93
  readonly artifacts: Pick<ArtifactStore, "readEvalCasesByTask" | "getArtifactById"> | null;
89
94
  readonly telemetry: Pick<ExportableTelemetryStore, "getStepInferenceId">;
90
95
  readonly captures: () => Pick<CaptureStore, "getByInferenceId">;
96
+ /** LRE-1b: resolve a golden (corrected) artifact's PARSED content value, or
97
+ * null when it is not readable (predates retention, evicted, or content custody
98
+ * is off). Injected so the runner can score a challenger's output against the
99
+ * golden (the `exact` grader). Absent ⇒ from-eval-cases scores by conformance
100
+ * only (pre-LRE-1b behavior) — a golden with no readable content is honest
101
+ * about it rather than pretending the case is graded. */
102
+ readonly golden?: (correctedArtifactId: string) => {
103
+ readonly value: unknown;
104
+ } | null;
91
105
  }
92
106
  export declare function runBakeoffFromEvalCases(deps: RunDeps, stores: EvalCaseStores, req: {
93
107
  readonly task: string;
@@ -97,5 +111,10 @@ export declare function runBakeoffFromEvalCases(deps: RunDeps, stores: EvalCaseS
97
111
  readonly objectiveMode?: ObjectiveMode;
98
112
  readonly resolveReferenceAuto?: (route: RouteBundle) => CandidateSpec | null;
99
113
  readonly qualityGate?: QualityGate;
114
+ /** The golden set's grader — all three wired: `exact` (binary), `field-level`
115
+ * (per-field partial credit), `llm-judge` (pairwise vs the golden, LRE-2).
116
+ * Applied to every case that HAS a readable golden; a failure case (no golden)
117
+ * still scores by conformance. */
118
+ readonly graderType?: GraderType;
100
119
  }, samplesSink?: BakeoffSamplesSink): Promise<EvalCaseBakeoffResult>;
101
120
  //# sourceMappingURL=eval-cases.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"eval-cases.d.ts","sourceRoot":"","sources":["../../src/bakeoff/eval-cases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAc,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;oDACoD;AACpD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,EAAE,CAAC;IAC9D,QAAQ,CAAC,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK;QAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IAClG,QAAQ,CAAC,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,GAA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aAAa,CAAC;IACvC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,aAAa,GAAG,IAAI,CAAC;IAC7E,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC;;;sCAGkC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;CAClC,EACD,WAAW,CAAC,EAAE,kBAAkB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,CA+ChC"}
@@ -53,7 +53,7 @@ function selectEvalCaseCaptures(deps, task) {
53
53
  refuse("input not captured locally (route `capture` was off, or the capture was evicted)");
54
54
  continue;
55
55
  }
56
- rehydratable.push({ caseId: c.id, capture });
56
+ rehydratable.push({ caseId: c.id, capture, correctedArtifactId: c.correctedArtifactId });
57
57
  }
58
58
  return { task, total: cases.length, rehydratable, refusals };
59
59
  }
@@ -94,11 +94,28 @@ async function runBakeoffFromEvalCases(deps, stores, req, samplesSink) {
94
94
  }, req.task);
95
95
  if (selection.rehydratable.length === 0)
96
96
  return { selection, artifact: null };
97
+ // LRE-1b: build the golden `expected` map — for each rehydratable case that has
98
+ // a corrected artifact whose content the injected `golden` resolver can read,
99
+ // key the golden value by the capture's inferenceId (the engine's `expected`
100
+ // key). A failure case (no golden) or an unreadable golden simply omits its
101
+ // key → that sample scores by conformance, never a silent zero.
102
+ const expected = new Map();
103
+ if (stores.golden !== undefined) {
104
+ for (const r of selection.rehydratable) {
105
+ if (r.correctedArtifactId === null)
106
+ continue;
107
+ const g = stores.golden(r.correctedArtifactId);
108
+ if (g !== null)
109
+ expected.set(r.capture.inferenceId, { value: g.value });
110
+ }
111
+ }
97
112
  const artifact = await (0, engine_1.runBakeoff)(deps, evalCaseCaptureStore(selection.rehydratable), {
98
113
  route: req.task,
99
114
  variants: req.variants,
100
115
  replayLastN: selection.rehydratable.length, // replay every rehydratable case
101
116
  envelopeUsdPerVariant: req.envelopeUsdPerVariant,
117
+ ...(expected.size > 0 ? { expected } : {}),
118
+ ...(req.graderType !== undefined ? { graderType: req.graderType } : {}),
102
119
  ...(req.keepOutputs !== undefined ? { keepOutputs: req.keepOutputs } : {}),
103
120
  ...(req.objectiveMode !== undefined ? { objectiveMode: req.objectiveMode } : {}),
104
121
  ...(req.resolveReferenceAuto !== undefined ? { resolveReferenceAuto: req.resolveReferenceAuto } : {}),
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The `llm-judge` grader (LRE-2, live-routing-evals §R-3/§4). When a golden eval
3
+ * set's `grader.type` is `llm-judge`, each rehydratable case is scored by an LLM
4
+ * COMPARISON of the challenger's output against the case's GOLDEN (`expected`)
5
+ * value — reusing the N5/N6 PAIRWISE judge machinery (pairwise.ts), not a new
6
+ * dispatch path.
7
+ *
8
+ * Why pairwise-vs-golden (R-3, "LLM-judge reuses the N5/N6 pairwise judge"):
9
+ * - The pairwise judge already asks "which of A / B is the better answer for
10
+ * VALUE (correctness + completeness)". Presenting A = the challenger output
11
+ * and B = the golden turns that into "is the challenger at least as good as
12
+ * the known-correct golden?" — exactly a grade against a reference.
13
+ * - The verdict maps to a per-sample value accuracy via the SAME `winValue`
14
+ * the pairwise aggregation uses (win=1, tie=0.5, loss=0). This is the
15
+ * CONSERVATIVE mapping (L5, never round in our favor): a tie against the
16
+ * golden is 0.5, never rounded up to full credit; a loss is 0. Builder
17
+ * decision — flagged in the PR body for QA.
18
+ * - The judge model MUST be a declared candidate (#223 F3) — enforced at load
19
+ * for `bakeoff.pairwise.judge` / `bakeoff.judge`, whose model this reuses, so
20
+ * it is a real, reachable model here.
21
+ *
22
+ * CAPPED + METERED + fail-closed exactly like the pairwise judge (it IS the
23
+ * pairwise judge): past `maxSamples` per arm `score()` returns null and the
24
+ * sample falls back to conformance (counted by omission), an unparseable verdict
25
+ * returns null, and the metered attempt row still stands.
26
+ */
27
+ import type { RunDeps } from "../run/run";
28
+ import type { CandidateSpec, RouteBundle } from "../types/route";
29
+ /** A per-arm golden grader: `score(output, golden, taskInput)` returns the
30
+ * challenger output's value accuracy in [0,1] judged against the golden, or null
31
+ * when the cap is hit or the judge could not produce a valid verdict. */
32
+ export interface GoldenJudgeScorer {
33
+ score(output: unknown, golden: unknown, taskInput: unknown): Promise<number | null>;
34
+ }
35
+ /**
36
+ * Build a golden judge over the pairwise-judge loop. Each arm gets a FRESH judge
37
+ * (the underlying pairwise judge caps `maxSamples` per arm). A = the challenger
38
+ * output, B = the golden `expected` value; the pairwise verdict (win/tie/loss)
39
+ * maps to [0,1] via `winValue` — an output judged at least as good as the golden
40
+ * scores high, a worse output scores 0. Position bias is the pairwise judge's
41
+ * known limit (fixed A/B order); noted in verification.
42
+ */
43
+ export declare function makeGoldenJudge(deps: RunDeps, baseRoute: RouteBundle, judge: {
44
+ readonly model: CandidateSpec;
45
+ readonly maxSamples: number;
46
+ }): GoldenJudgeScorer;
47
+ //# sourceMappingURL=golden-judge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"golden-judge.d.ts","sourceRoot":"","sources":["../../src/bakeoff/golden-judge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGjE;;yEAEyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACrF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACpE,iBAAiB,CAUnB"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /**
3
+ * The `llm-judge` grader (LRE-2, live-routing-evals §R-3/§4). When a golden eval
4
+ * set's `grader.type` is `llm-judge`, each rehydratable case is scored by an LLM
5
+ * COMPARISON of the challenger's output against the case's GOLDEN (`expected`)
6
+ * value — reusing the N5/N6 PAIRWISE judge machinery (pairwise.ts), not a new
7
+ * dispatch path.
8
+ *
9
+ * Why pairwise-vs-golden (R-3, "LLM-judge reuses the N5/N6 pairwise judge"):
10
+ * - The pairwise judge already asks "which of A / B is the better answer for
11
+ * VALUE (correctness + completeness)". Presenting A = the challenger output
12
+ * and B = the golden turns that into "is the challenger at least as good as
13
+ * the known-correct golden?" — exactly a grade against a reference.
14
+ * - The verdict maps to a per-sample value accuracy via the SAME `winValue`
15
+ * the pairwise aggregation uses (win=1, tie=0.5, loss=0). This is the
16
+ * CONSERVATIVE mapping (L5, never round in our favor): a tie against the
17
+ * golden is 0.5, never rounded up to full credit; a loss is 0. Builder
18
+ * decision — flagged in the PR body for QA.
19
+ * - The judge model MUST be a declared candidate (#223 F3) — enforced at load
20
+ * for `bakeoff.pairwise.judge` / `bakeoff.judge`, whose model this reuses, so
21
+ * it is a real, reachable model here.
22
+ *
23
+ * CAPPED + METERED + fail-closed exactly like the pairwise judge (it IS the
24
+ * pairwise judge): past `maxSamples` per arm `score()` returns null and the
25
+ * sample falls back to conformance (counted by omission), an unparseable verdict
26
+ * returns null, and the metered attempt row still stands.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.makeGoldenJudge = makeGoldenJudge;
30
+ const pairwise_1 = require("./pairwise");
31
+ /**
32
+ * Build a golden judge over the pairwise-judge loop. Each arm gets a FRESH judge
33
+ * (the underlying pairwise judge caps `maxSamples` per arm). A = the challenger
34
+ * output, B = the golden `expected` value; the pairwise verdict (win/tie/loss)
35
+ * maps to [0,1] via `winValue` — an output judged at least as good as the golden
36
+ * scores high, a worse output scores 0. Position bias is the pairwise judge's
37
+ * known limit (fixed A/B order); noted in verification.
38
+ */
39
+ function makeGoldenJudge(deps, baseRoute, judge) {
40
+ const pairwise = (0, pairwise_1.makePairwiseJudge)(deps, baseRoute, judge);
41
+ return {
42
+ async score(output, golden, taskInput) {
43
+ // compare(A=output, B=golden): "win" ⇒ output beats the golden, "tie" ⇒ as
44
+ // good as, "loss" ⇒ worse. winValue gives 1 / 0.5 / 0.
45
+ const outcome = await pairwise.compare(output, golden, taskInput);
46
+ return outcome === null ? null : (0, pairwise_1.winValue)(outcome);
47
+ },
48
+ };
49
+ }