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
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Artifact namespace — Expansion E2 chunk B (spec §2.2, §9).
4
4
  *
5
- * `save/load/link/evaluate` over a durable work product's METADATA. The
5
+ * `save/load/link` over a durable work product's METADATA. The
6
6
  * serialized value is hashed (sha256, node:crypto — no new dep) and the bytes
7
7
  * are DISCARDED; nothing but the metadata row is persisted (the 00030
8
8
  * counter-annotation). Lineage v0: artifacts saved within a run get
@@ -22,6 +22,17 @@ const run_context_1 = require("./run-context");
22
22
  const scrub_1 = require("./scrub");
23
23
  const classification_1 = require("./classification");
24
24
  const task_settings_1 = require("../settings/task-settings");
25
+ const manifest_1 = require("../prompts/manifest");
26
+ /** The configured scrub mode for one artifact save (BEFORE the S8-c PII/PHI
27
+ * floor). Resolved EXACTLY as capture-write.ts / samples.ts do: a configured
28
+ * control plane WINS (`resolver.get(task).scrub`), else the rig's default. A
29
+ * task with no identity to key on falls back to the default (no row to resolve).
30
+ * Pure and synchronous — the resolver read is cache-only. */
31
+ function resolveContentScrubMode(content, task) {
32
+ return content.resolver !== null && task !== undefined
33
+ ? content.resolver.get(task).scrub
34
+ : content.defaultScrub;
35
+ }
25
36
  /** Map an artifact `type` to a content-type for the object store. */
26
37
  function contentTypeFor(type) {
27
38
  const t = type.toLowerCase();
@@ -33,6 +44,9 @@ function contentTypeFor(type) {
33
44
  return "text/csv";
34
45
  if (t === "html")
35
46
  return "text/html; charset=utf-8";
47
+ // PSR-1: a structure-only assembly manifest is stored as a linked JSON artifact.
48
+ if (t === "manifest")
49
+ return "application/json";
36
50
  return "application/octet-stream";
37
51
  }
38
52
  function idOf(ref) {
@@ -46,9 +60,9 @@ function warn(scope, err) {
46
60
  function inertApi() {
47
61
  return {
48
62
  save: () => null,
63
+ saveManifest: () => null,
49
64
  load: () => { },
50
65
  link: () => { },
51
- evaluate: () => { },
52
66
  promoteToEval: () => null,
53
67
  batch: (fn) => fn(),
54
68
  flushContent: () => Promise.resolve(),
@@ -151,203 +165,219 @@ function createArtifactApi(deps) {
151
165
  }
152
166
  }
153
167
  }
154
- return {
155
- save(value, opts) {
156
- const ctx = (0, run_context_1.getActiveRunContext)();
157
- // zeroRetention: refuse fail-closed BEFORE hashing or building any row.
158
- if (ctx !== null && ctx.zeroRetention) {
159
- skippedZeroRetention += 1;
160
- console.warn(`[modelrig artifacts] zeroRetention run — artifact "${opts.name}" NOT recorded ` +
161
- "(fail-closed at the SDK gate; no metadata, no hash persisted).");
162
- return null;
163
- }
164
- // Hash the serialization, then DISCARD the bytes — metadata + hash only.
165
- const serialized = typeof value === "string" ? value : JSON.stringify(value ?? null);
166
- const bytes = Buffer.byteLength(serialized, "utf8");
167
- const contentHash = `sha256:${(0, node_crypto_1.createHash)("sha256").update(serialized).digest("hex")}`;
168
- const schema = opts.schema ?? null;
169
- const id = (0, node_crypto_1.randomUUID)();
170
- const version = opts.supersedes !== undefined ? opts.supersedes.version + 1 : 1;
171
- // G1 (spec §3): an explicit stepKey wins; absent, the artifact lands in the
172
- // AMBIENT step — the most recent auto-step in this run context — so
173
- // `artifact.save` and the run/@step graph compose. Null outside a step (or
174
- // outside a run context), exactly as before.
175
- const stepKey = opts.stepKey ?? ctx?.currentStepKey() ?? null;
176
- // S8-b: validate data_classification against the shared enum. A bad value
177
- // would fail the DB CHECK (00058) and drop the row at ingest, so catch it
178
- // here with a teaching warning and drop the LABEL (the artifact still
179
- // saves — a metadata typo must not lose the artifact). Normalize first so
180
- // "PHI"/" pii " keep their meaning (and their scrub floor) rather than
181
- // silently dropping.
182
- let classification = (0, classification_1.normalizeClassification)(opts.classification);
183
- if (opts.classification !== undefined && classification !== null && !(0, classification_1.isDataClassification)(classification)) {
184
- console.warn(`[modelrig artifacts] artifact "${opts.name}" has an unknown data_classification ` +
185
- `${JSON.stringify(opts.classification)} — label dropped (artifact still saved). ` +
186
- `fix_hint: use one of ${classification_1.DATA_CLASSIFICATIONS.join(", ")}.`);
187
- classification = null;
188
- }
189
- // Custody applies only when a rig content policy exists AND the caller left
190
- // the bytes to us (a caller-supplied contentRef = their own store; managed
191
- // custody must not double-home it).
192
- const custodyApplies = content !== undefined && opts.contentRef === undefined;
193
- // Scrub is computed HERE (before the row is written) so its counts-only
194
- // summary can ride the immutable artifact row (00039). Only when custody
195
- // applies; null otherwise (custody off ⇒ nothing was scanned).
196
- // S8-c: a `pii`/`phi` artifact forces the scrub mode to a floor of
197
- // `redact`, so PII/PHI content is never uploaded verbatim even when the
198
- // task's configured mode is `off`/`detect`. A stronger `block` stays.
199
- const effScrub = content !== undefined ? (0, task_settings_1.effectiveScrubMode)(content.scrub, classification) : null;
200
- const scrubbed = custodyApplies && content !== undefined && effScrub !== null ? (0, scrub_1.scrubContent)(serialized, effScrub) : null;
201
- const scrubSummary = scrubbed !== null && effScrub !== null ? (0, scrub_1.summarizeScrub)(effScrub, scrubbed) : null;
202
- if (scrubbed !== null)
203
- scrubFindings += scrubbed.findings.reduce((n, f) => n + f.count, 0);
204
- try {
205
- store.recordArtifact({
206
- id,
207
- runId: ctx?.runId ?? null,
208
- // E3: step attribution is an explicit caller-supplied key; G1 adds the
209
- // ambient-step fallback (resolved above) so a save with no stepKey joins
210
- // the current run/@step. Absent both ⇒ null, exactly as before.
211
- stepKey,
212
- attemptNo: opts.attemptNo ?? null,
213
- task: opts.task ?? null,
214
- name: opts.name,
215
- type: opts.type,
216
- version,
217
- supersedesArtifactId: opts.supersedes?.id ?? null,
218
- declaredSchema: schema,
219
- fingerprintCell: (0, fingerprint_1.fingerprintSchema)(schema)?.cellKey ?? null,
220
- contentRef: opts.contentRef ?? null,
221
- contentHash,
222
- contentBytes: bytes,
223
- dataClassification: classification,
224
- expiresAt: opts.expiresAt ?? null,
225
- // Per-row scrub findings ride the original (scanned) row (00039).
226
- scrub: scrubSummary,
227
- });
228
- saves += 1;
229
- if (opts.task !== undefined)
230
- savedTasks.set(id, opts.task); // for promoteToEval (chunk A)
231
- // Lineage v0: derived_from edges to everything loaded since the last save.
232
- if (ctx !== null) {
233
- for (const loadedId of ctx.takeLoadedIds()) {
234
- if (loadedId === id)
235
- continue; // edges_no_self
236
- store.recordArtifactEdge({ fromArtifactId: id, toArtifactId: loadedId, kind: "derived_from" });
237
- inferredEdges += 1;
238
- }
168
+ // Extracted so `saveManifest` (PSR-1) can compose them without re-implementing
169
+ // the custody/lineage save path or the edges_no_self link. The bodies are the
170
+ // original `save`/`link` verbatim — the returned object references these.
171
+ const save = (value, opts) => {
172
+ const ctx = (0, run_context_1.getActiveRunContext)();
173
+ // zeroRetention: refuse fail-closed BEFORE hashing or building any row.
174
+ if (ctx !== null && ctx.zeroRetention) {
175
+ skippedZeroRetention += 1;
176
+ console.warn(`[modelrig artifacts] zeroRetention run — artifact "${opts.name}" NOT recorded ` +
177
+ "(fail-closed at the SDK gate; no metadata, no hash persisted).");
178
+ return null;
179
+ }
180
+ // Hash the serialization, then DISCARD the bytes — metadata + hash only.
181
+ const serialized = typeof value === "string" ? value : JSON.stringify(value ?? null);
182
+ const bytes = Buffer.byteLength(serialized, "utf8");
183
+ const contentHash = `sha256:${(0, node_crypto_1.createHash)("sha256").update(serialized).digest("hex")}`;
184
+ const schema = opts.schema ?? null;
185
+ const id = (0, node_crypto_1.randomUUID)();
186
+ const version = opts.supersedes !== undefined ? opts.supersedes.version + 1 : 1;
187
+ // G1 (spec §3): an explicit stepKey wins; absent, the artifact lands in the
188
+ // AMBIENT step — the most recent auto-step in this run context — so
189
+ // `artifact.save` and the run/@step graph compose. Null outside a step (or
190
+ // outside a run context), exactly as before.
191
+ const stepKey = opts.stepKey ?? ctx?.currentStepKey() ?? null;
192
+ // S8-b: validate data_classification against the shared enum. A bad value
193
+ // would fail the DB CHECK (00058) and drop the row at ingest, so catch it
194
+ // here with a teaching warning and drop the LABEL (the artifact still
195
+ // saves — a metadata typo must not lose the artifact). Normalize first so
196
+ // "PHI"/" pii " keep their meaning (and their scrub floor) rather than
197
+ // silently dropping.
198
+ let classification = (0, classification_1.normalizeClassification)(opts.classification);
199
+ if (opts.classification !== undefined && classification !== null && !(0, classification_1.isDataClassification)(classification)) {
200
+ console.warn(`[modelrig artifacts] artifact "${opts.name}" has an unknown data_classification ` +
201
+ `${JSON.stringify(opts.classification)} — label dropped (artifact still saved). ` +
202
+ `fix_hint: use one of ${classification_1.DATA_CLASSIFICATIONS.join(", ")}.`);
203
+ classification = null;
204
+ }
205
+ // Custody applies only when a rig content policy exists AND the caller left
206
+ // the bytes to us (a caller-supplied contentRef = their own store; managed
207
+ // custody must not double-home it).
208
+ const custodyApplies = content !== undefined && opts.contentRef === undefined;
209
+ // Scrub is computed HERE (before the row is written) so its counts-only
210
+ // summary can ride the immutable artifact row (00039). Only when custody
211
+ // applies; null otherwise (custody off ⇒ nothing was scanned). The
212
+ // configured mode comes from the per-task/account control-plane setting
213
+ // (P15 CP-3b — resolver wins; `content.defaultScrub` fallback local/direct).
214
+ // S8-c: a `pii`/`phi` artifact forces the scrub mode to a floor of
215
+ // `redact`, so PII/PHI content is never uploaded verbatim even when the
216
+ // task's configured mode is `off`/`detect`. A stronger `block` stays.
217
+ const effScrub = content !== undefined
218
+ ? (0, task_settings_1.effectiveScrubMode)(resolveContentScrubMode(content, opts.task), classification)
219
+ : null;
220
+ const scrubbed = custodyApplies && content !== undefined && effScrub !== null ? (0, scrub_1.scrubContent)(serialized, effScrub) : null;
221
+ const scrubSummary = scrubbed !== null && effScrub !== null ? (0, scrub_1.summarizeScrub)(effScrub, scrubbed) : null;
222
+ if (scrubbed !== null)
223
+ scrubFindings += scrubbed.findings.reduce((n, f) => n + f.count, 0);
224
+ try {
225
+ store.recordArtifact({
226
+ id,
227
+ runId: ctx?.runId ?? null,
228
+ // E3: step attribution is an explicit caller-supplied key; G1 adds the
229
+ // ambient-step fallback (resolved above) so a save with no stepKey joins
230
+ // the current run/@step. Absent both ⇒ null, exactly as before.
231
+ stepKey,
232
+ attemptNo: opts.attemptNo ?? null,
233
+ task: opts.task ?? null,
234
+ name: opts.name,
235
+ type: opts.type,
236
+ version,
237
+ supersedesArtifactId: opts.supersedes?.id ?? null,
238
+ declaredSchema: schema,
239
+ fingerprintCell: (0, fingerprint_1.fingerprintSchema)(schema)?.cellKey ?? null,
240
+ contentRef: opts.contentRef ?? null,
241
+ contentHash,
242
+ contentBytes: bytes,
243
+ dataClassification: classification,
244
+ expiresAt: opts.expiresAt ?? null,
245
+ // Per-row scrub findings ride the original (scanned) row (00039).
246
+ scrub: scrubSummary,
247
+ });
248
+ saves += 1;
249
+ if (opts.task !== undefined)
250
+ savedTasks.set(id, opts.task); // for promoteToEval (chunk A)
251
+ // Lineage v0: derived_from edges to everything loaded since the last save.
252
+ if (ctx !== null) {
253
+ for (const loadedId of ctx.takeLoadedIds()) {
254
+ if (loadedId === id)
255
+ continue; // edges_no_self
256
+ store.recordArtifactEdge({ fromArtifactId: id, toArtifactId: loadedId, kind: "derived_from" });
257
+ inferredEdges += 1;
239
258
  }
240
259
  }
241
- catch (err) {
242
- warn("save", err);
243
- return null;
260
+ }
261
+ catch (err) {
262
+ warn("save", err);
263
+ return null;
264
+ }
265
+ // ── Content custody (E2-C) ──────────────────────────────────────────
266
+ // Off by default: only when a rig has configured content custody. The
267
+ // metadata row above is written regardless — content is layered on, never
268
+ // a precondition. zeroRetention already returned above, so we never reach
269
+ // here for a zeroRetention run (structural, not re-checked).
270
+ if (content !== undefined && scrubbed !== null) {
271
+ if (scrubbed.blocked) {
272
+ // `block` mode found PII/PHI → content upload refused (counted). The
273
+ // artifact keeps its metadata + hash; it simply stores no content.
274
+ contentBlocked += 1;
275
+ console.warn(`[modelrig artifacts] scrub blocked content for "${opts.name}" ` +
276
+ `(${scrubbed.findings.length} finding type(s)); metadata + hash kept, no content stored.`);
244
277
  }
245
- // ── Content custody (E2-C) ──────────────────────────────────────────
246
- // Off by default: only when a rig has configured content custody. The
247
- // metadata row above is written regardless — content is layered on, never
248
- // a precondition. zeroRetention already returned above, so we never reach
249
- // here for a zeroRetention run (structural, not re-checked).
250
- if (content !== undefined && scrubbed !== null) {
251
- if (scrubbed.blocked) {
252
- // `block` mode found PII/PHI → content upload refused (counted). The
253
- // artifact keeps its metadata + hash; it simply stores no content.
254
- contentBlocked += 1;
255
- console.warn(`[modelrig artifacts] scrub blocked content for "${opts.name}" ` +
256
- `(${scrubbed.findings.length} finding type(s)); metadata + hash kept, no content stored.`);
257
- }
258
- else if (effScrub === "redact" && scrubbed.findings.length > 0 && scrubbed.text !== null) {
259
- // Redaction is a SUPERSEDING version (immutability): the original row
260
- // keeps its hash and stores NO content; a new version records the
261
- // masked content's hash and uploads the masked bytes.
262
- const maskedSerialized = scrubbed.text;
263
- const maskedBytes = Buffer.byteLength(maskedSerialized, "utf8");
264
- const maskedHash = `sha256:${(0, node_crypto_1.createHash)("sha256").update(maskedSerialized).digest("hex")}`;
265
- const redactedId = (0, node_crypto_1.randomUUID)();
266
- const redactedVersion = version + 1;
267
- try {
268
- store.recordArtifact({
269
- id: redactedId,
270
- runId: ctx?.runId ?? null,
271
- // Same ambient-step resolution as the original row it supersedes.
272
- stepKey,
273
- attemptNo: opts.attemptNo ?? null,
274
- task: opts.task ?? null,
275
- name: opts.name,
276
- type: opts.type,
277
- version: redactedVersion,
278
- supersedesArtifactId: id, // supersedes the original (ruling c column)
279
- declaredSchema: schema,
280
- fingerprintCell: (0, fingerprint_1.fingerprintSchema)(schema)?.cellKey ?? null,
281
- contentRef: null,
282
- contentHash: maskedHash,
283
- contentBytes: maskedBytes,
284
- dataClassification: classification,
285
- expiresAt: opts.expiresAt ?? null,
286
- // Findings ride the original scanned row; the masked version stores
287
- // no PII, so its own scrub is null (avoid double-counting).
288
- scrub: null,
289
- });
290
- saves += 1;
291
- fireUpload({
292
- artifactId: redactedId,
293
- contentType: contentTypeFor(opts.type),
294
- body: Buffer.from(maskedSerialized, "utf8"),
295
- contentHash: maskedHash,
296
- }, content.upload);
297
- // The live version is the redacted one — hand its handle back.
298
- return { id: redactedId, name: opts.name, type: opts.type, version: redactedVersion };
299
- }
300
- catch (err) {
301
- warn("save (redacted version)", err);
302
- // Fall through to returning the original handle (metadata-only).
303
- }
304
- }
305
- else {
306
- // off / detect / redact-with-no-findings: upload the bytes verbatim.
278
+ else if (effScrub === "redact" && scrubbed.findings.length > 0 && scrubbed.text !== null) {
279
+ // Redaction is a SUPERSEDING version (immutability): the original row
280
+ // keeps its hash and stores NO content; a new version records the
281
+ // masked content's hash and uploads the masked bytes.
282
+ const maskedSerialized = scrubbed.text;
283
+ const maskedBytes = Buffer.byteLength(maskedSerialized, "utf8");
284
+ const maskedHash = `sha256:${(0, node_crypto_1.createHash)("sha256").update(maskedSerialized).digest("hex")}`;
285
+ const redactedId = (0, node_crypto_1.randomUUID)();
286
+ const redactedVersion = version + 1;
287
+ try {
288
+ store.recordArtifact({
289
+ id: redactedId,
290
+ runId: ctx?.runId ?? null,
291
+ // Same ambient-step resolution as the original row it supersedes.
292
+ stepKey,
293
+ attemptNo: opts.attemptNo ?? null,
294
+ task: opts.task ?? null,
295
+ name: opts.name,
296
+ type: opts.type,
297
+ version: redactedVersion,
298
+ supersedesArtifactId: id, // supersedes the original (ruling c column)
299
+ declaredSchema: schema,
300
+ fingerprintCell: (0, fingerprint_1.fingerprintSchema)(schema)?.cellKey ?? null,
301
+ contentRef: null,
302
+ contentHash: maskedHash,
303
+ contentBytes: maskedBytes,
304
+ dataClassification: classification,
305
+ expiresAt: opts.expiresAt ?? null,
306
+ // Findings ride the original scanned row; the masked version stores
307
+ // no PII, so its own scrub is null (avoid double-counting).
308
+ scrub: null,
309
+ });
310
+ saves += 1;
307
311
  fireUpload({
308
- artifactId: id,
312
+ artifactId: redactedId,
309
313
  contentType: contentTypeFor(opts.type),
310
- body: Buffer.from(scrubbed.text ?? serialized, "utf8"),
311
- contentHash,
314
+ body: Buffer.from(maskedSerialized, "utf8"),
315
+ contentHash: maskedHash,
312
316
  }, content.upload);
317
+ // The live version is the redacted one — hand its handle back.
318
+ return { id: redactedId, name: opts.name, type: opts.type, version: redactedVersion };
319
+ }
320
+ catch (err) {
321
+ warn("save (redacted version)", err);
322
+ // Fall through to returning the original handle (metadata-only).
313
323
  }
314
324
  }
315
- return { id, name: opts.name, type: opts.type, version };
316
- },
325
+ else {
326
+ // off / detect / redact-with-no-findings: upload the bytes verbatim.
327
+ fireUpload({
328
+ artifactId: id,
329
+ contentType: contentTypeFor(opts.type),
330
+ body: Buffer.from(scrubbed.text ?? serialized, "utf8"),
331
+ contentHash,
332
+ }, content.upload);
333
+ }
334
+ }
335
+ return { id, name: opts.name, type: opts.type, version };
336
+ };
337
+ const link = (from, to, kind) => {
338
+ const fromId = idOf(from);
339
+ const toId = idOf(to);
340
+ if (fromId === toId)
341
+ return; // edges_no_self
342
+ try {
343
+ store.recordArtifactEdge({ fromArtifactId: fromId, toArtifactId: toId, kind });
344
+ }
345
+ catch (err) {
346
+ warn("link", err);
347
+ }
348
+ };
349
+ // PSR-1: validate a structure-only manifest, save it as a linked `manifest`
350
+ // artifact (ZERO-DDL free-text type), and chain `prompt → manifest` via
351
+ // derived_from. Never throws; an invalid manifest is a counted, teaching warn.
352
+ const saveManifest = (prompt, manifest, opts) => {
353
+ const result = (0, manifest_1.validateManifest)(manifest);
354
+ if (!result.ok) {
355
+ console.warn(`[modelrig artifacts] manifest for prompt "${idOf(prompt)}" is invalid — not emitted: ` +
356
+ `${result.errors.join("; ")}`);
357
+ return null;
358
+ }
359
+ const promptName = typeof prompt === "string" ? undefined : prompt.name;
360
+ const name = opts?.name ?? (promptName !== undefined ? `${promptName}.manifest` : "manifest");
361
+ const handle = save(JSON.stringify(result.manifest), {
362
+ name,
363
+ type: "manifest",
364
+ ...(opts?.task !== undefined ? { task: opts.task } : {}),
365
+ ...(opts?.stepKey !== undefined ? { stepKey: opts.stepKey } : {}),
366
+ ...(opts?.attemptNo !== undefined ? { attemptNo: opts.attemptNo } : {}),
367
+ });
368
+ if (handle === null)
369
+ return null; // custody/zeroRetention refused — no edge.
370
+ // Chain prompt → manifest: the prompt is assembled per this manifest recipe.
371
+ link(prompt, handle, "derived_from");
372
+ return handle;
373
+ };
374
+ return {
375
+ save,
376
+ saveManifest,
317
377
  load(ref) {
318
378
  (0, run_context_1.getActiveRunContext)()?.noteLoad(idOf(ref));
319
379
  },
320
- link(from, to, kind) {
321
- const fromId = idOf(from);
322
- const toId = idOf(to);
323
- if (fromId === toId)
324
- return; // edges_no_self
325
- try {
326
- store.recordArtifactEdge({ fromArtifactId: fromId, toArtifactId: toId, kind });
327
- }
328
- catch (err) {
329
- warn("link", err);
330
- }
331
- },
332
- evaluate(ref, opts) {
333
- try {
334
- store.recordArtifactEvaluation({
335
- id: (0, node_crypto_1.randomUUID)(),
336
- artifactId: idOf(ref),
337
- runId: null,
338
- evaluator: opts.evaluator,
339
- evaluatorKind: opts.kind,
340
- score: opts.score ?? null,
341
- passed: opts.passed ?? null,
342
- label: opts.label ?? null,
343
- explanation: opts.explanation ?? null,
344
- createdBy: null,
345
- });
346
- }
347
- catch (err) {
348
- warn("evaluate", err);
349
- }
350
- },
380
+ link,
351
381
  promoteToEval(ref, opts) {
352
382
  const sourceArtifactId = idOf(ref);
353
383
  // Resolve the task: explicit wins, else the task this artifact was saved
@@ -3,19 +3,22 @@
3
3
  *
4
4
  * Lives here (not spread through `index.ts`) so the SDK entrypoint stays under
5
5
  * the LOC cap and the run/artifact surface has one home. Chunk A ships the run
6
- * lifecycle + `@step`; chunk B adds the artifact primitives (save/load/evaluate).
6
+ * lifecycle + `@step`; chunk B adds the artifact primitives (save/load/link).
7
7
  */
8
8
  import type { ArtifactBuffer, RunNamespace } from "./run-context";
9
9
  import type { ArtifactApi, ArtifactContentDeps } from "./artifact";
10
10
  import type { ArtifactContentConfig, ArtifactsConfig } from "../config";
11
+ import type { TaskSettingsResolver } from "../settings/task-settings";
11
12
  import type { ArtifactStore } from "../telemetry/artifact-store";
12
13
  export { getActiveRunContext, createRunNamespace } from "./run-context";
13
- export type { RunNamespace, RunHandle, RunStartOptions, RunEvaluateOptions, RunStatus, ActiveRunContext, ArtifactBuffer, GroundTruthStepInput, } from "./run-context";
14
+ export type { RunNamespace, RunHandle, RunStartOptions, RunStatus, ActiveRunContext, ArtifactBuffer, GroundTruthStepInput, } from "./run-context";
14
15
  export { step } from "./step";
15
16
  export { createArtifactApi } from "./artifact";
16
17
  export { openArtifactStore } from "../telemetry/artifact-store";
17
18
  export type { ArtifactStore } from "../telemetry/artifact-store";
18
- export type { ArtifactApi, ArtifactHandle, ArtifactSaveOptions, ArtifactEvaluateOptions, ArtifactPromoteOptions, ArtifactContentDeps, ArtifactContentUploader, } from "./artifact";
19
+ export type { ArtifactApi, ArtifactHandle, ArtifactSaveOptions, ArtifactManifestOptions, ArtifactPromoteOptions, ArtifactContentDeps, ArtifactContentUploader, } from "./artifact";
20
+ export { validateManifest, assertValidManifest, parseAuthoringDoc } from "../prompts/manifest";
21
+ export type { Slot, SlotKind, Manifest, DynamicSource, DynamicSourceKind, CachePolicy, StaticFrom, ManifestValidation, AuthoringDoc, } from "../prompts/manifest";
19
22
  export { uploadArtifactContent } from "./content-uploader";
20
23
  export type { ContentUploadConfig, ContentUploadInput, ContentUploadOutcome, } from "./content-uploader";
21
24
  export { scrubContent, luhnValid, detectSpans, scrubDetectors } from "./scrub";
@@ -24,7 +27,7 @@ export { DATA_CLASSIFICATIONS, SENSITIVE_CLASSIFICATIONS, isDataClassification,
24
27
  export type { DataClassification } from "./classification";
25
28
  export { computeDownstreamClosure, TAINT_DEFAULT_MAX_DEPTH, TAINT_DEFAULT_CAP, } from "./taint";
26
29
  export type { TaintEdge, Supersession, TaintNode, TaintClosure, TaintOptions, } from "./taint";
27
- export type { RunRow, StepRow, ArtifactRow, ArtifactEdgeRow, ArtifactEvaluationRow, EvalCaseRow, EvalCaseOrigin, } from "../types/telemetry";
30
+ export type { RunRow, StepRow, ArtifactRow, ArtifactEdgeRow, EvalCaseRow, EvalCaseOrigin, } from "../types/telemetry";
28
31
  /** The rig-bound artifact surface exposed as `rig.artifacts`: the run lifecycle
29
32
  * (chunk A) + the artifact primitives (chunk B). */
30
33
  export interface ArtifactNamespace {
@@ -40,6 +43,9 @@ export declare function wireRigArtifacts(deps: {
40
43
  readonly enabled: boolean;
41
44
  readonly artifactStore: ArtifactStore | null;
42
45
  readonly artifacts?: ArtifactsConfig;
46
+ /** Control-plane settings resolver (§1.5; P15 CP-3b) — the per-task/account
47
+ * scrub source the content-upload path reads. null local-only/direct. */
48
+ readonly resolver?: TaskSettingsResolver | null;
43
49
  }): {
44
50
  readonly namespace: ArtifactNamespace;
45
51
  readonly onArtifactsFlushed?: () => Promise<void>;
@@ -49,7 +55,7 @@ export declare function wireRigArtifacts(deps: {
49
55
  * custody is off. Kept here (not in the SDK entrypoint) so index.ts stays under
50
56
  * the LOC cap (P1) and the content wiring lives beside the namespace it feeds.
51
57
  */
52
- export declare function buildArtifactContentDeps(content: ArtifactContentConfig | undefined): ArtifactContentDeps | undefined;
58
+ export declare function buildArtifactContentDeps(content: ArtifactContentConfig | undefined, resolver: TaskSettingsResolver | null): ArtifactContentDeps | undefined;
53
59
  /** Build the rig-bound artifact namespace. Disabled ⇒ every entry is inert
54
60
  * (run.start is a no-op, save returns null, no rows written) — spec §1.4. The
55
61
  * artifact store is present only when enabled (index.ts opens it then). */
@@ -61,5 +67,9 @@ export declare function createArtifactNamespace(deps: {
61
67
  * deps are built here (buildArtifactContentDeps) so the SDK entrypoint stays
62
68
  * under the LOC cap. */
63
69
  readonly content?: ArtifactContentConfig;
70
+ /** Control-plane settings resolver (§1.5; P15 CP-3b) — threaded into the
71
+ * content deps so the upload path resolves scrub per task/account. null
72
+ * local-only/direct (then the content-on default governs). */
73
+ readonly resolver?: TaskSettingsResolver | null;
64
74
  }): ArtifactNamespace;
65
75
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/artifacts/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxE,YAAY,EACV,YAAY,EACZ,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,iBAAiB,E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I,CAAC;CACjD,GAAG,iBAAiB,CAcpB"}
@@ -4,16 +4,17 @@
4
4
  *
5
5
  * Lives here (not spread through `index.ts`) so the SDK entrypoint stays under
6
6
  * the LOC cap and the run/artifact surface has one home. Chunk A ships the run
7
- * lifecycle + `@step`; chunk B adds the artifact primitives (save/load/evaluate).
7
+ * lifecycle + `@step`; chunk B adds the artifact primitives (save/load/link).
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.TAINT_DEFAULT_CAP = exports.TAINT_DEFAULT_MAX_DEPTH = exports.computeDownstreamClosure = exports.normalizeClassification = exports.isDataClassification = exports.SENSITIVE_CLASSIFICATIONS = exports.DATA_CLASSIFICATIONS = exports.scrubDetectors = exports.detectSpans = exports.luhnValid = exports.scrubContent = exports.uploadArtifactContent = exports.openArtifactStore = exports.createArtifactApi = exports.step = exports.createRunNamespace = exports.getActiveRunContext = void 0;
10
+ exports.TAINT_DEFAULT_CAP = exports.TAINT_DEFAULT_MAX_DEPTH = exports.computeDownstreamClosure = exports.normalizeClassification = exports.isDataClassification = exports.SENSITIVE_CLASSIFICATIONS = exports.DATA_CLASSIFICATIONS = exports.scrubDetectors = exports.detectSpans = exports.luhnValid = exports.scrubContent = exports.uploadArtifactContent = exports.parseAuthoringDoc = exports.assertValidManifest = exports.validateManifest = exports.openArtifactStore = exports.createArtifactApi = exports.step = exports.createRunNamespace = exports.getActiveRunContext = void 0;
11
11
  exports.wireRigArtifacts = wireRigArtifacts;
12
12
  exports.buildArtifactContentDeps = buildArtifactContentDeps;
13
13
  exports.createArtifactNamespace = createArtifactNamespace;
14
14
  const run_context_1 = require("./run-context");
15
15
  const artifact_1 = require("./artifact");
16
16
  const content_uploader_1 = require("./content-uploader");
17
+ const config_1 = require("../config");
17
18
  var run_context_2 = require("./run-context");
18
19
  Object.defineProperty(exports, "getActiveRunContext", { enumerable: true, get: function () { return run_context_2.getActiveRunContext; } });
19
20
  Object.defineProperty(exports, "createRunNamespace", { enumerable: true, get: function () { return run_context_2.createRunNamespace; } });
@@ -23,6 +24,13 @@ var artifact_2 = require("./artifact");
23
24
  Object.defineProperty(exports, "createArtifactApi", { enumerable: true, get: function () { return artifact_2.createArtifactApi; } });
24
25
  var artifact_store_1 = require("../telemetry/artifact-store");
25
26
  Object.defineProperty(exports, "openArtifactStore", { enumerable: true, get: function () { return artifact_store_1.openArtifactStore; } });
27
+ // PSR-1 — the structure-only assembly-manifest model (spec §2.1). Re-exported
28
+ // here so `export * from "./artifacts"` in index.ts puts it on the public
29
+ // `modelrig` surface for the InferWealth inference + a future MCP write path.
30
+ var manifest_1 = require("../prompts/manifest");
31
+ Object.defineProperty(exports, "validateManifest", { enumerable: true, get: function () { return manifest_1.validateManifest; } });
32
+ Object.defineProperty(exports, "assertValidManifest", { enumerable: true, get: function () { return manifest_1.assertValidManifest; } });
33
+ Object.defineProperty(exports, "parseAuthoringDoc", { enumerable: true, get: function () { return manifest_1.parseAuthoringDoc; } });
26
34
  var content_uploader_2 = require("./content-uploader");
27
35
  Object.defineProperty(exports, "uploadArtifactContent", { enumerable: true, get: function () { return content_uploader_2.uploadArtifactContent; } });
28
36
  var scrub_1 = require("./scrub");
@@ -49,6 +57,7 @@ function wireRigArtifacts(deps) {
49
57
  const namespace = createArtifactNamespace({
50
58
  buffer: deps.buffer,
51
59
  enabled: deps.enabled,
60
+ resolver: deps.resolver ?? null,
52
61
  ...(deps.artifactStore !== null ? { artifactStore: deps.artifactStore } : {}),
53
62
  ...(deps.artifacts?.content !== undefined ? { content: deps.artifacts.content } : {}),
54
63
  });
@@ -63,11 +72,14 @@ function wireRigArtifacts(deps) {
63
72
  * custody is off. Kept here (not in the SDK entrypoint) so index.ts stays under
64
73
  * the LOC cap (P1) and the content wiring lives beside the namespace it feeds.
65
74
  */
66
- function buildArtifactContentDeps(content) {
75
+ function buildArtifactContentDeps(content, resolver) {
67
76
  if (content === undefined)
68
77
  return undefined;
69
78
  return {
70
- scrub: content.scrub,
79
+ // Scrub comes from the per-task/account control-plane setting at runtime
80
+ // (P15 CP-3b); the resolver wins, `defaultScrub` is the local/direct fallback.
81
+ resolver,
82
+ defaultScrub: config_1.DEFAULT_CONTENT_SCRUB_MODE,
71
83
  upload: (input) => (0, content_uploader_1.uploadArtifactContent)(input, { uploadsUrl: content.uploadsUrl, apiKey: content.apiKey, maxBytes: content.maxBytes }, fetch),
72
84
  };
73
85
  }
@@ -75,7 +87,9 @@ function buildArtifactContentDeps(content) {
75
87
  * (run.start is a no-op, save returns null, no rows written) — spec §1.4. The
76
88
  * artifact store is present only when enabled (index.ts opens it then). */
77
89
  function createArtifactNamespace(deps) {
78
- const contentDeps = deps.enabled ? buildArtifactContentDeps(deps.content) : undefined;
90
+ const contentDeps = deps.enabled
91
+ ? buildArtifactContentDeps(deps.content, deps.resolver ?? null)
92
+ : undefined;
79
93
  return {
80
94
  run: (0, run_context_1.createRunNamespace)(deps),
81
95
  artifact: (0, artifact_1.createArtifactApi)({