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
package/dist/status.js CHANGED
@@ -33,57 +33,77 @@ function exportModeOf(config) {
33
33
  return config.export?.mode ?? "local-only";
34
34
  }
35
35
  /**
36
- * The artifact-namespace posture as a boolean + a reason, derivable from config
37
- * ALONE (so both the banner and `/status` agree). The four cases the §2 flip
38
- * creates, each named honestly:
39
- * on + control plane → the default is now on (a sink exists to ship to)
40
- * on + local-only → an explicit MODELRIG_ARTIFACTS opt-in
41
- * off + control plane → an explicit MODELRIG_ARTIFACTS=0 opt-out
42
- * off + local-only → nothing to ship to; off is the local-only default
36
+ * The artifact-namespace posture as a boolean + a reason (P15 CP-3). The on/off
37
+ * SOURCE is the ORG's account posture (`artifact_posture`), resolved from the
38
+ * control plane — never an env var. The cases, each named honestly:
39
+ * control plane, posture off → capture off — your account settings
40
+ * control plane, posture managed/metadata → capture on — your account settings
41
+ * control plane, posture resolving (null) → capture on — account settings (resolving)
42
+ * local-only, dev force-on → MODELRIG_ARTIFACTS=1 (dev-only, local rig)
43
+ * local-only, off → nothing to ship to; off is the local default
44
+ * `posture` is the resolver's current value (null until the first run resolves
45
+ * it, or always null for local-only / hand-built configs).
43
46
  */
44
- function artifactsPosture(config) {
45
- const enabled = config.artifacts?.enabled === true;
47
+ function artifactsPosture(config, posture = null) {
46
48
  const localOnly = exportModeOf(config) === "local-only";
47
- if (enabled) {
49
+ if (localOnly) {
50
+ const enabled = config.artifacts?.enabled === true;
48
51
  return {
49
52
  enabled,
50
- reason: localOnly ? "MODELRIG_ARTIFACTS opt-in (local-only rig)" : "control plane configured",
53
+ reason: enabled
54
+ ? "MODELRIG_ARTIFACTS=1 (dev-only, local rig)"
55
+ : "local-only rig — no control plane to ship to",
51
56
  };
52
57
  }
53
- return {
54
- enabled,
55
- reason: localOnly ? "local-only rig — no control plane to ship to" : "MODELRIG_ARTIFACTS=0 opt-out",
56
- };
58
+ // Control plane configured: the org account posture (P15) governs on/off.
59
+ if (posture === "off") {
60
+ return { enabled: false, reason: "capture off — your account settings (posture: off)" };
61
+ }
62
+ const src = posture === null ? "your account settings (resolving)" : `your account settings (posture: ${posture})`;
63
+ return { enabled: true, reason: `capture on — ${src}` };
64
+ }
65
+ /** Whether content is EFFECTIVELY stored: content transport configured AND the
66
+ * org posture is not one that suppresses content (P15). posture `off`/`metadata`
67
+ * → the server stores no content, so report it off honestly; `managed`/resolving
68
+ * with content configured → on (attempted; the server is the gate). */
69
+ function contentCustodyOn(config, posture) {
70
+ if (config.artifacts?.content === undefined)
71
+ return false;
72
+ return posture !== "off" && posture !== "metadata";
57
73
  }
58
- /** Build the full status snapshot from config + the resolver's per-task cache,
59
- * plus (GS-1) an optional runs-recorded summary read from the local buffer. */
60
- function buildRigStatus(config, tasks = new Map(), runs) {
74
+ /** Build the full status snapshot from config + the resolver's per-task cache and
75
+ * org posture (P15), plus (GS-1) an optional runs-recorded summary from the buffer. */
76
+ function buildRigStatus(config, tasks = new Map(), runs, posture = null) {
61
77
  return {
62
78
  exportMode: exportModeOf(config),
63
- artifacts: artifactsPosture(config),
64
- contentCustody: config.artifacts?.content !== undefined,
79
+ artifacts: artifactsPosture(config, posture),
80
+ contentCustody: contentCustodyOn(config, posture),
65
81
  otlp: config.otlp ? "configured" : "disabled",
82
+ managedServing: config.managedServing === true ? "enabled" : "disabled",
66
83
  cache: cachePosture(),
67
84
  tasks: [...tasks].map(([task, s]) => ({ task, ...s })),
68
85
  ...(runs != null ? { runs } : {}),
69
86
  };
70
87
  }
71
- /** The one-line boot banner (§2). Concise on purpose — mode, artifacts (+why),
72
- * content, otlp. */
73
- function formatBootBanner(config) {
74
- const a = artifactsPosture(config);
75
- const content = config.artifacts?.content !== undefined ? "on" : "off";
88
+ /** The one-line boot banner (§2 + P15). Concise on purpose — mode, artifacts
89
+ * (+source), content, otlp. `posture` is null at boot (resolves on the first run),
90
+ * so the banner names the SOURCE (account settings) rather than a stale value. */
91
+ function formatBootBanner(config, posture = null) {
92
+ const a = artifactsPosture(config, posture);
93
+ const content = contentCustodyOn(config, posture) ? "on" : "off";
76
94
  const otlp = config.otlp ? "on" : "off";
95
+ const managedServing = config.managedServing === true ? "on" : "off";
77
96
  return (`[modelrig] telemetry: ${exportModeOf(config)} · ` +
78
97
  `artifacts: ${a.enabled ? "on" : "off"} (${a.reason}) · ` +
79
- `content: ${content} · otlp: ${otlp}`);
98
+ `content: ${content} · otlp: ${otlp} · managed-serving: ${managedServing}`);
80
99
  }
81
100
  /**
82
101
  * Emit the boot banner to stderr — ONCE at rig construction, and ONLY when a
83
- * control plane is configured (the case where the §2 default flip is in effect
84
- * and the posture is non-obvious). A pure local-only rig with artifacts off is
85
- * the boring, expected default and stays silent (no banner noise in tests or
86
- * embedders). Stderr, so it never pollutes a command's stdout.
102
+ * control plane is configured (the case where capture is on by default and the
103
+ * posture — resolved from account settings — is non-obvious). A pure local-only
104
+ * rig with artifacts off is the boring, expected default and stays silent (no
105
+ * banner noise in tests or embedders). Stderr, so it never pollutes stdout.
106
+ * Posture is null at boot; the banner names its source (account settings).
87
107
  */
88
108
  function emitBootBanner(config) {
89
109
  if (config.export === undefined)
@@ -98,6 +118,7 @@ function formatStatusReport(status) {
98
118
  ` artifacts : ${status.artifacts.enabled ? "enabled" : "disabled"} (${status.artifacts.reason})`,
99
119
  ` content custody : ${status.contentCustody ? "enabled" : "disabled"}`,
100
120
  ` otlp span export : ${status.otlp}`,
121
+ ` managed serving : ${status.managedServing} (config: managedServing)`,
101
122
  ` cache accounting : on (policy ${status.cache.policyVersion}) — cache-eligible: ${status.cache.eligibleProviders.length > 0 ? status.cache.eligibleProviders.join(", ") : "none"}`,
102
123
  " (live hit rate + effective input rate: console route cache page)",
103
124
  ];
@@ -9,11 +9,14 @@
9
9
  * a sha256 of bytes hashed-then-discarded. Rows are immutable facts: INSERT OR
10
10
  * IGNORE, read past a rowid watermark exactly like inferences.
11
11
  */
12
- import type { ArtifactEdgeRow, ArtifactEvaluationRow, ArtifactRow, EvalCaseRow } from "../types/telemetry";
12
+ import type { ArtifactEdgeRow, ArtifactRow, EvalCaseRow, GradeRow } from "../types/telemetry";
13
13
  export interface ArtifactStore {
14
14
  recordArtifact(row: ArtifactRow): void;
15
15
  recordArtifactEdge(row: ArtifactEdgeRow): void;
16
- recordArtifactEvaluation(row: ArtifactEvaluationRow): void;
16
+ /** Record a unified judgment (grade primitive, R1) — the canonical write path
17
+ * for a grade on an artifact/run subject, which transacts on THIS handle.
18
+ * Writes the shared local `grades` table (read/exported by the telemetry handle). */
19
+ recordGrade(row: GradeRow): void;
17
20
  /** Record a promoted eval case (E4 chunk A) — rides the `:eval_cases` export
18
21
  * stream to the control plane, exactly like the other artifact-graph rows. */
19
22
  recordEvalCase(row: EvalCaseRow): void;
@@ -25,10 +28,6 @@ export interface ArtifactStore {
25
28
  rowid: number;
26
29
  row: ArtifactEdgeRow;
27
30
  }>;
28
- readEvaluationsAfter(afterRowid: number, limit: number): Array<{
29
- rowid: number;
30
- row: ArtifactEvaluationRow;
31
- }>;
32
31
  readEvalCasesAfter(afterRowid: number, limit: number): Array<{
33
32
  rowid: number;
34
33
  row: EvalCaseRow;
@@ -1 +1 @@
1
- {"version":3,"file":"artifact-store.d.ts","sourceRoot":"","sources":["../../src/telemetry/artifact-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/C,wBAAwB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC3D;kFAC8E;IAC9E,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAClG,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IAClG,oBAAoB,CAClB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,qBAAqB,CAAA;KAAE,CAAC,CAAC;IACxD,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAA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U,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAClG,gFAAgF;IAChF,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;IACjD;gEAC4D;IAC5D,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAChD;;oFAEgF;IAChF,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,KAAK,IAAI,IAAI,CAAC;CACf;AA2DD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CA2H/D"}
@@ -18,6 +18,7 @@ exports.openArtifactStore = openArtifactStore;
18
18
  const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
19
19
  const node_fs_1 = require("node:fs");
20
20
  const node_path_1 = require("node:path");
21
+ const grades_sql_1 = require("./grades-sql");
21
22
  const ARTIFACTS_SQL = `
22
23
  CREATE TABLE IF NOT EXISTS artifacts (
23
24
  id TEXT PRIMARY KEY, run_id TEXT, step_key TEXT, attempt_no INTEGER, task TEXT,
@@ -53,14 +54,6 @@ function toArtifact(r) {
53
54
  function toEdge(r) {
54
55
  return { fromArtifactId: r.from_artifact_id, toArtifactId: r.to_artifact_id, kind: r.kind };
55
56
  }
56
- function toEval(r) {
57
- return {
58
- id: r.id, artifactId: r.artifact_id, runId: r.run_id, evaluator: r.evaluator,
59
- evaluatorKind: r.evaluator_kind,
60
- score: r.score, passed: r.passed === null ? null : r.passed !== 0,
61
- label: r.label, explanation: r.explanation, createdBy: r.created_by,
62
- };
63
- }
64
57
  function toEvalCase(r) {
65
58
  return {
66
59
  id: r.id, task: r.task, sourceArtifactId: r.source_artifact_id,
@@ -78,6 +71,23 @@ function openArtifactStore(dbPath) {
78
71
  // telemetry guarantee; the cloud exporter is the durable copy.
79
72
  db.pragma("synchronous = NORMAL");
80
73
  db.exec(ARTIFACTS_SQL);
74
+ // Grade primitive (R1): the unified `grades` table is shared with the telemetry
75
+ // handle (same file). CREATE IF NOT EXISTS so whichever handle opens first wins;
76
+ // then backfill this store's evaluations into grades (idempotent, INSERT OR
77
+ // IGNORE) so pre-grade evaluations still export as grades. Additive.
78
+ db.exec(grades_sql_1.GRADES_TABLE_SQL);
79
+ (0, grades_sql_1.backfillGradesFromEvaluations)(db);
80
+ // F4: additive per-criterion `criteria` column on a dev DB that predates it
81
+ // and was created by THIS handle (so the telemetry store's v16 rung may not
82
+ // have run). CREATE IF NOT EXISTS above won't add it to an existing table;
83
+ // gradeBindParams now binds @criteria, so the column must exist before any
84
+ // insert. Same swallow-on-duplicate pattern as scrub/run_id.
85
+ try {
86
+ db.exec("ALTER TABLE grades ADD COLUMN criteria TEXT");
87
+ }
88
+ catch {
89
+ /* column already present — no-op */
90
+ }
81
91
  // Additive column for a dev DB that predates E4 (CREATE TABLE IF NOT EXISTS
82
92
  // won't add it to an existing table). SQLite has no ADD COLUMN IF NOT EXISTS;
83
93
  // a duplicate-column error on re-run is expected and swallowed.
@@ -110,14 +120,11 @@ function openArtifactStore(dbPath) {
110
120
  @data_classification, @expires_at, @scrub
111
121
  )`);
112
122
  const insEdge = db.prepare("INSERT OR IGNORE INTO artifact_edges (from_artifact_id, to_artifact_id, kind) VALUES (@from_artifact_id, @to_artifact_id, @kind)");
113
- const insEval = db.prepare(`
114
- INSERT OR IGNORE INTO artifact_evaluations (
115
- id, artifact_id, run_id, evaluator, evaluator_kind, score, passed, label, explanation, created_by
116
- ) VALUES (@id, @artifact_id, @run_id, @evaluator, @evaluator_kind, @score, @passed, @label, @explanation, @created_by)`);
117
123
  const insEvalCase = db.prepare(`
118
124
  INSERT OR IGNORE INTO eval_cases (
119
125
  id, task, source_artifact_id, corrected_artifact_id, origin, note, created_by
120
126
  ) VALUES (@id, @task, @source_artifact_id, @corrected_artifact_id, @origin, @note, @created_by)`);
127
+ const insGrade = (0, grades_sql_1.prepareGradeInsert)(db);
121
128
  return {
122
129
  recordArtifact(row) {
123
130
  insArtifact.run({
@@ -135,13 +142,8 @@ function openArtifactStore(dbPath) {
135
142
  recordArtifactEdge(row) {
136
143
  insEdge.run({ from_artifact_id: row.fromArtifactId, to_artifact_id: row.toArtifactId, kind: row.kind });
137
144
  },
138
- recordArtifactEvaluation(row) {
139
- insEval.run({
140
- id: row.id, artifact_id: row.artifactId, run_id: row.runId, evaluator: row.evaluator,
141
- evaluator_kind: row.evaluatorKind, score: row.score,
142
- passed: row.passed === null ? null : row.passed ? 1 : 0,
143
- label: row.label, explanation: row.explanation, created_by: row.createdBy,
144
- });
145
+ recordGrade(row) {
146
+ insGrade.run((0, grades_sql_1.gradeBindParams)(row));
145
147
  },
146
148
  recordEvalCase(row) {
147
149
  insEvalCase.run({
@@ -160,11 +162,6 @@ function openArtifactStore(dbPath) {
160
162
  .all(afterRowid, limit);
161
163
  return rows.map((r) => ({ rowid: r.__r, row: toEdge(r) }));
162
164
  },
163
- readEvaluationsAfter(afterRowid, limit) {
164
- const rows = db.prepare("SELECT rowid AS __r, * FROM artifact_evaluations WHERE rowid > ? ORDER BY rowid LIMIT ?")
165
- .all(afterRowid, limit);
166
- return rows.map((r) => ({ rowid: r.__r, row: toEval(r) }));
167
- },
168
165
  readEvalCasesAfter(afterRowid, limit) {
169
166
  const rows = db.prepare("SELECT rowid AS __r, * FROM eval_cases WHERE rowid > ? ORDER BY rowid LIMIT ?")
170
167
  .all(afterRowid, limit);
@@ -12,8 +12,33 @@
12
12
  * enum/identifier/hash (length > 128 or containing whitespace).
13
13
  */
14
14
  import type { AdapterUsage, ProviderId } from "../types/provider";
15
+ import type { OutputKind } from "../types/route";
16
+ import type { ScreenReceipt } from "../screen/types";
15
17
  export type FinishReason = "stop" | "length" | "tool_calls" | "content_filter" | "refusal" | "error" | "other";
16
18
  export type ContextBucket = "≤4k" | "≤16k" | "≤64k" | "≤200k" | ">200k";
19
+ /**
20
+ * How the rendered prompt reached the model on ONE attempt (GitLab issue #5,
21
+ * R1) — the proof surface for the cache-handle rule, stamped on
22
+ * `inferences.meta.prompt_delivery` by the adapter that made the call:
23
+ * • `system` — the rendered system prompt went as the provider's system
24
+ * instruction; the user turn carried the trigger / `prompt.user`.
25
+ * • `user` — no system instruction was sent because the rendered system
26
+ * prompt was EMPTY; the user turn alone carried the prompt.
27
+ * • `user+cache` — a cache HANDLE was sent (Gemini `cachedContent`), so the
28
+ * system instruction could not be: everything rendered — the
29
+ * system prompt (if any), then the user turn — was delivered
30
+ * AS the user turn. Nothing was dropped.
31
+ * Stamped today by the Gemini adapter (the one provider where a handle changes
32
+ * delivery); absent on other providers' rows (⇒ delivered as declared).
33
+ */
34
+ export type PromptDelivery = "system" | "user" | "user+cache";
35
+ export declare const PROMPT_DELIVERIES: ReadonlySet<string>;
36
+ /** The output contract a ROUTE-lane attempt was held to (issue #1 / plan §7.3,
37
+ * QA-S7): `json` (parsed + schema-checked) or `text` (returned verbatim). Same
38
+ * producer/enum pattern as {@link PromptDelivery}; stamped on
39
+ * `inferences.meta.output_kind` for every dispatched route-lane row, absent on
40
+ * raw-lane rows (the raw lane has no route contract). */
41
+ export declare const OUTPUT_KINDS: ReadonlySet<string>;
17
42
  /** D1 egress receipt — shape RESERVED here; populated by the D1 mission. */
18
43
  export interface EgressReceiptV1 {
19
44
  readonly endpoint?: string;
@@ -26,6 +51,7 @@ export interface EgressReceiptV1 {
26
51
  readonly search_provider?: string;
27
52
  readonly tool_calls?: number;
28
53
  }
54
+ export type ServedTierSource = "provider" | "requested_fallback";
29
55
  export interface AttemptMetaV1 {
30
56
  readonly v: 1;
31
57
  readonly finish_reason?: FinishReason;
@@ -50,6 +76,13 @@ export interface AttemptMetaV1 {
50
76
  readonly search_provider?: string;
51
77
  };
52
78
  readonly model_snapshot?: string;
79
+ /** Issue #2 (L6 F5): where `servedTier` came from — `provider` (the response
80
+ * echoed a tier: openai `service_tier`, gemini `serviceTier` /
81
+ * `usageMetadata.trafficType`) or `requested_fallback` (no echo; the adapter
82
+ * assumed the requested tier). Pricing reads the served tier, so a
83
+ * fallback-priced row is identifiable here. Absent on adapters without the
84
+ * signal. */
85
+ readonly served_tier_source?: ServedTierSource;
53
86
  readonly provider_request_id?: string;
54
87
  readonly http_status?: number;
55
88
  readonly error_code?: string;
@@ -65,8 +98,32 @@ export interface AttemptMetaV1 {
65
98
  /** sha256 of the RENDERED request — a hash, never content. */
66
99
  readonly input_hash?: string;
67
100
  readonly output_hash?: string;
101
+ /** R2 (issue #6): `sha256:<hex>` of the CANONICAL (sorted-key) JSON of the
102
+ * schema this attempt was asked to conform to — the raw lane's declared
103
+ * `responseSchema` today. A hash, never content; lets declared-vs-served
104
+ * schema drift be queried on `inferences.meta`. Absent ⇒ no schema declared. */
105
+ readonly schema_sha?: string;
68
106
  readonly context_bucket?: ContextBucket;
69
107
  readonly egress?: EgressReceiptV1;
108
+ /** LRE-2: the live A/B experiment arm this call was drawn onto (an identifier —
109
+ * `provider/model` or a variant/arm name), or absent for a non-experiment call.
110
+ * The A/B readout groups `inferences` by `meta.arm`. Meta-safe by construction
111
+ * (an identifier, no whitespace); a non-conforming value is dropped like any. */
112
+ readonly arm?: string;
113
+ /** Screening SC-1a receipt (spec §5) — the counts-only screen summary rides
114
+ * HERE, on `inferences.meta.screen`, so SC-1 adds ZERO migration (§8). Every
115
+ * field is an enum / count / hash (findings are `{detector,type,source,count}`
116
+ * with no-whitespace labels), so the classification rule and the server ingest
117
+ * backstop (`sanitizeMetaForWire`) pass it through intact. Produced by the
118
+ * single producer `summarizeScreen`; NEVER carries a matched value. Reserved &
119
+ * additive. */
120
+ readonly screen?: ScreenReceipt;
121
+ /** Issue #5 (R1): how the rendered prompt reached the model — see
122
+ * {@link PromptDelivery}. Absent ⇒ the adapter did not report it. */
123
+ readonly prompt_delivery?: PromptDelivery;
124
+ /** QA-S7 (issue #1, plan §7.3): the route's output contract on this attempt —
125
+ * `json` | `text`. Route lane only; absent on raw rows. */
126
+ readonly output_kind?: OutputKind;
70
127
  }
71
128
  export interface RunMetaV1 {
72
129
  readonly v: 1;
@@ -89,6 +146,8 @@ export interface AttemptMetaSource {
89
146
  readonly renderedRequest?: string;
90
147
  readonly outputText?: string | null;
91
148
  readonly declaredToolNames?: readonly string[];
149
+ /** QA-S7: the route's output contract (route lane only). */
150
+ readonly outputKind?: OutputKind;
92
151
  }
93
152
  /** Canonicalize the RENDERED request for `input_hash` (spec §2) — system + user
94
153
  * + schema, joined the SAME way in both lanes so a routed and a raw call with
@@ -111,14 +170,30 @@ export interface AttemptMetaInputs {
111
170
  readonly outputText?: string | null;
112
171
  /** Declared tool ids; any tool_call name NOT in this set is hashed. */
113
172
  readonly declaredToolNames?: readonly string[];
173
+ /** R2: the canonical schema sha (`sha256:<hex>`) to stamp on `meta.schema_sha`.
174
+ * Already a hash — gated by the classification rule like any identifier.
175
+ * Absent ⇒ no key ⇒ byte-identical to a schema-free row. */
176
+ readonly schemaSha?: string;
177
+ /** QA-S7: the route-lane output contract to stamp on `meta.output_kind`.
178
+ * Absent (the raw lane) ⇒ no key ⇒ byte-identical. */
179
+ readonly outputKind?: OutputKind;
114
180
  /** For the cost components (via src/run/cost.ts). */
115
181
  readonly provider?: ProviderId;
116
182
  readonly model?: string;
117
- readonly usage?: Pick<AdapterUsage, "tokensIn" | "tokensOut" | "tokensCached" | "tokensCacheWrite" | "tokensCacheWrite1h">;
183
+ readonly usage?: Pick<AdapterUsage, "tokensIn" | "tokensOut" | "tokensCached" | "tokensCacheWrite" | "tokensCacheWrite1h"> &
184
+ /** issue #2: the served tier, so `meta.cost` components price like the row. */
185
+ Partial<Pick<AdapterUsage, "servedTier">>;
118
186
  /** Whether the caller streamed deltas (run loop stream() path). */
119
187
  readonly streaming?: boolean;
120
188
  /** Repair-rung count carried by the run loop, if any. */
121
189
  readonly repairCount?: number;
190
+ /** LRE-2: the drawn A/B arm name (RunOptions.arm), stamped onto `meta.arm` when
191
+ * meta-safe. Absent ⇒ no `arm` key ⇒ byte-identical to a non-experiment call. */
192
+ readonly arm?: string;
193
+ /** SC-1a: the counts-only screen receipt to ride on `meta.screen`. Passed
194
+ * through verbatim (already counts/enums/hashes — no free text). Absent ⇒ no
195
+ * `screen` key ⇒ byte-identical to a non-screened row. */
196
+ readonly screen?: ScreenReceipt;
122
197
  }
123
198
  /** The classification-rule string test (spec §2, §5 wire backstop): a value is
124
199
  * an ENUM / IDENTIFIER / HASH only if it is at most 128 chars AND contains no
@@ -1 +1 @@
1
- {"version":3,"file":"attempt-meta.d.ts","sourceRoot":"","sources":["../../src/telemetry/attempt-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,gBAAgB,GAChB,SAAS,GACT,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAExE,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE;QAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnG,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,QAAQ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;gEACgE;AAChE,eAAO,MAAM,iBAAiB,mEAAoE,CAAC;AACnG,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AA4BhE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,cAAc,CAAA;CAAE,EAAE,CAS5G;AAID;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAInE;AAED;;;2CAG2C;AAC3C,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkBrE;AAwCD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,GAAG,IAAI,CA0GpF"}
@@ -13,7 +13,7 @@
13
13
  * enum/identifier/hash (length > 128 or containing whitespace).
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.RESERVED_TAG_KEYS = void 0;
16
+ exports.RESERVED_TAG_KEYS = exports.OUTPUT_KINDS = exports.PROMPT_DELIVERIES = void 0;
17
17
  exports.renderRequestForHash = renderRequestForHash;
18
18
  exports.isMetaSafeString = isMetaSafeString;
19
19
  exports.sanitizeMetaForWire = sanitizeMetaForWire;
@@ -26,6 +26,13 @@ const node_fs_1 = require("node:fs");
26
26
  const node_path_1 = require("node:path");
27
27
  const cost_1 = require("../run/cost");
28
28
  const config_1 = require("../config");
29
+ exports.PROMPT_DELIVERIES = new Set(["system", "user", "user+cache"]);
30
+ /** The output contract a ROUTE-lane attempt was held to (issue #1 / plan §7.3,
31
+ * QA-S7): `json` (parsed + schema-checked) or `text` (returned verbatim). Same
32
+ * producer/enum pattern as {@link PromptDelivery}; stamped on
33
+ * `inferences.meta.output_kind` for every dispatched route-lane row, absent on
34
+ * raw-lane rows (the raw lane has no route contract). */
35
+ exports.OUTPUT_KINDS = new Set(["json", "text"]);
29
36
  /** Canonicalize the RENDERED request for `input_hash` (spec §2) — system + user
30
37
  * + schema, joined the SAME way in both lanes so a routed and a raw call with
31
38
  * the identical prompt+schema hash identically (lane parity, spec §6.3). The
@@ -234,10 +241,35 @@ function summarizeAttemptMeta(inputs) {
234
241
  meta.finish_reason = a.finish_reason;
235
242
  if (typeof a.refusal === "boolean")
236
243
  meta.refusal = a.refusal;
244
+ if (a.served_tier_source === "provider" || a.served_tier_source === "requested_fallback") {
245
+ meta.served_tier_source = a.served_tier_source;
246
+ }
237
247
  if (typeof a.streaming === "boolean")
238
248
  meta.streaming = a.streaming;
239
249
  else if (typeof inputs.streaming === "boolean")
240
250
  meta.streaming = inputs.streaming;
251
+ // LRE-2 A/B arm — an identifier, gated by the classification rule (absent ⇒
252
+ // no key ⇒ byte-identical to a non-experiment row).
253
+ if (isMetaSafeString(inputs.arm))
254
+ meta.arm = inputs.arm;
255
+ // R2 declared-schema hash — a `sha256:` string (71 chars, no whitespace).
256
+ if (isMetaSafeString(inputs.schemaSha))
257
+ meta.schema_sha = inputs.schemaSha;
258
+ // SC-1a screen receipt (spec §5, §8) — the counts-only screen summary rides
259
+ // on meta.screen (ZERO migration). Already counts/enums/hashes; passed
260
+ // through verbatim (absent ⇒ no key ⇒ byte-identical to a non-screened row).
261
+ if (inputs.screen !== undefined)
262
+ meta.screen = inputs.screen;
263
+ // Issue #5 (R1): prompt delivery — an enum our adapters produce; anything
264
+ // outside the vocabulary is dropped (absent ⇒ no key ⇒ byte-identical).
265
+ if (typeof a.prompt_delivery === "string" && exports.PROMPT_DELIVERIES.has(a.prompt_delivery)) {
266
+ meta.prompt_delivery = a.prompt_delivery;
267
+ }
268
+ // QA-S7: route-lane output contract — the same enum discipline; anything
269
+ // outside `json` | `text` is dropped (absent ⇒ no key ⇒ byte-identical).
270
+ if (typeof inputs.outputKind === "string" && exports.OUTPUT_KINDS.has(inputs.outputKind)) {
271
+ meta.output_kind = inputs.outputKind;
272
+ }
241
273
  // Externally-sourced identifiers — gated by the classification rule.
242
274
  if (isMetaSafeString(a.model_snapshot))
243
275
  meta.model_snapshot = a.model_snapshot;
@@ -19,6 +19,8 @@ export interface ExporterSetupExtras {
19
19
  readonly artifactStore: ArtifactStore | null;
20
20
  /** E4 chunk 0: retry 404'd content after a confirmed artifacts flush. */
21
21
  readonly onArtifactsFlushed?: () => Promise<void>;
22
+ /** `createRig({ expectOrg })` (M5) — threaded to the api sink's org line. */
23
+ readonly expectOrg?: string;
22
24
  }
23
25
  /**
24
26
  * Construct the sink for the configured mode, wire the exporter, and start its
@@ -1 +1 @@
1
- {"version":3,"file":"exporter-setup.d.ts","sourceRoot":"","sources":["../../src/telemetry/exporter-setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAChD,QAAQ,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACtD,gFAAgF;IAChF,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7C,yEAAyE;IACzE,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B,EACnC,YAAY,EAAE,eAAe,GAAG,kBAAkB,EAClD,MAAM,EAAE,mBAAmB,GAC1B,QAAQ,CAyBV"}
@@ -10,13 +10,14 @@ exports.startTelemetryExporter = startTelemetryExporter;
10
10
  const node_os_1 = require("node:os");
11
11
  const exporter_1 = require("./exporter");
12
12
  const sinks_1 = require("./sinks");
13
+ const route_registration_1 = require("./route-registration");
13
14
  /**
14
15
  * Construct the sink for the configured mode, wire the exporter, and start its
15
16
  * flush loop. Returns the running exporter (the caller stops it on close()).
16
17
  */
17
18
  function startTelemetryExporter(telemetry, exportConfig, extras) {
18
19
  const sourceId = exportConfig.sourceId ?? (0, node_os_1.hostname)();
19
- const sink = (0, sinks_1.buildTelemetrySink)(exportConfig, sourceId);
20
+ const sink = (0, sinks_1.buildTelemetrySink)(exportConfig, sourceId, extras.expectOrg !== undefined ? { expectOrg: extras.expectOrg } : {});
20
21
  const exporter = (0, exporter_1.createTelemetryExporter)(telemetry, {
21
22
  sink,
22
23
  sourceId,
@@ -30,5 +31,9 @@ function startTelemetryExporter(telemetry, exportConfig, extras) {
30
31
  ...(extras.onArtifactsFlushed !== undefined ? { onArtifactsFlushed: extras.onArtifactsFlushed } : {}),
31
32
  });
32
33
  exporter.start();
34
+ // RV-1 declare-on-startup: the declared routes (metadata + bundle) go out now,
35
+ // fire-and-forget, so a route is visible before its first call / first flush.
36
+ // Never awaited, never throws — createRig cannot block or fail on it.
37
+ void (0, route_registration_1.registerRoutesOnStartup)(sink, sourceId, extras.routes);
33
38
  return exporter;
34
39
  }
@@ -83,8 +83,8 @@ export interface ExporterConfig {
83
83
  readonly artifacts?: boolean;
84
84
  /** The local artifact-metadata buffer (chunk B). A SEPARATE handle from the
85
85
  * telemetry store; present only when the namespace is enabled. Its rows ride
86
- * the `:artifacts`/`:edges`/`:evals` watermark streams (watermarks live in the
87
- * main store's export_state, rows are read from here). */
86
+ * the `:artifacts`/`:edges`/`:eval_cases` watermark streams (watermarks live in
87
+ * the main store's export_state, rows are read from here). */
88
88
  readonly artifactStore?: ArtifactStore;
89
89
  /**
90
90
  * Post-flush hook fired AFTER a confirmed export of the artifacts stream (E4
@@ -1 +1 @@
1
- {"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../src/telemetry/exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAYlE,OAAO,KAAK,EACV,WAAW,EASZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1F;8BAC0B;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B;;6EAEyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,OAA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