modelrig 0.0.1 → 0.2.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 (420) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/LICENSE +201 -0
  3. package/README.md +145 -8
  4. package/data/PROVENANCE.md +19 -0
  5. package/data/pricing-manual.json +22 -0
  6. package/data/pricing-map.json +46362 -0
  7. package/data/pricing-overlay.json +419 -0
  8. package/dist/adapters/anthropic.d.ts +90 -0
  9. package/dist/adapters/anthropic.d.ts.map +1 -0
  10. package/dist/adapters/anthropic.js +296 -0
  11. package/dist/adapters/build-adapters.d.ts +11 -0
  12. package/dist/adapters/build-adapters.d.ts.map +1 -0
  13. package/dist/adapters/build-adapters.js +45 -0
  14. package/dist/adapters/deepseek.d.ts +47 -0
  15. package/dist/adapters/deepseek.d.ts.map +1 -0
  16. package/dist/adapters/deepseek.js +216 -0
  17. package/dist/adapters/gemini.d.ts +44 -0
  18. package/dist/adapters/gemini.d.ts.map +1 -0
  19. package/dist/adapters/gemini.js +262 -0
  20. package/dist/adapters/grok.d.ts +53 -0
  21. package/dist/adapters/grok.d.ts.map +1 -0
  22. package/dist/adapters/grok.js +232 -0
  23. package/dist/adapters/openai-compat.d.ts +80 -0
  24. package/dist/adapters/openai-compat.d.ts.map +1 -0
  25. package/dist/adapters/openai-compat.js +244 -0
  26. package/dist/adapters/openai-stream.d.ts +58 -0
  27. package/dist/adapters/openai-stream.d.ts.map +1 -0
  28. package/dist/adapters/openai-stream.js +120 -0
  29. package/dist/adapters/openai.d.ts +55 -0
  30. package/dist/adapters/openai.d.ts.map +1 -0
  31. package/dist/adapters/openai.js +281 -0
  32. package/dist/adapters/sampling.d.ts +28 -0
  33. package/dist/adapters/sampling.d.ts.map +1 -0
  34. package/dist/adapters/sampling.js +34 -0
  35. package/dist/adapters/tool-mapping.d.ts +92 -0
  36. package/dist/adapters/tool-mapping.d.ts.map +1 -0
  37. package/dist/adapters/tool-mapping.js +143 -0
  38. package/dist/artifacts/artifact.d.ts +137 -0
  39. package/dist/artifacts/artifact.d.ts.map +1 -0
  40. package/dist/artifacts/artifact.js +377 -0
  41. package/dist/artifacts/content-uploader.d.ts +87 -0
  42. package/dist/artifacts/content-uploader.d.ts.map +1 -0
  43. package/dist/artifacts/content-uploader.js +124 -0
  44. package/dist/artifacts/index.d.ts +63 -0
  45. package/dist/artifacts/index.d.ts.map +1 -0
  46. package/dist/artifacts/index.js +80 -0
  47. package/dist/artifacts/run-context.d.ts +129 -0
  48. package/dist/artifacts/run-context.d.ts.map +1 -0
  49. package/dist/artifacts/run-context.js +208 -0
  50. package/dist/artifacts/scrub.d.ts +60 -0
  51. package/dist/artifacts/scrub.d.ts.map +1 -0
  52. package/dist/artifacts/scrub.js +139 -0
  53. package/dist/artifacts/step.d.ts +26 -0
  54. package/dist/artifacts/step.d.ts.map +1 -0
  55. package/dist/artifacts/step.js +37 -0
  56. package/dist/artifacts/taint.d.ts +63 -0
  57. package/dist/artifacts/taint.d.ts.map +1 -0
  58. package/dist/artifacts/taint.js +76 -0
  59. package/dist/bakeoff/cache-sim.d.ts +99 -0
  60. package/dist/bakeoff/cache-sim.d.ts.map +1 -0
  61. package/dist/bakeoff/cache-sim.js +126 -0
  62. package/dist/bakeoff/engine.d.ts +52 -0
  63. package/dist/bakeoff/engine.d.ts.map +1 -0
  64. package/dist/bakeoff/engine.js +163 -0
  65. package/dist/bakeoff/eval-cases.d.ts +96 -0
  66. package/dist/bakeoff/eval-cases.d.ts.map +1 -0
  67. package/dist/bakeoff/eval-cases.js +105 -0
  68. package/dist/bakeoff/replay.d.ts +52 -0
  69. package/dist/bakeoff/replay.d.ts.map +1 -0
  70. package/dist/bakeoff/replay.js +94 -0
  71. package/dist/bakeoff/report.d.ts +41 -0
  72. package/dist/bakeoff/report.d.ts.map +1 -0
  73. package/dist/bakeoff/report.js +142 -0
  74. package/dist/bakeoff/samples.d.ts +77 -0
  75. package/dist/bakeoff/samples.d.ts.map +1 -0
  76. package/dist/bakeoff/samples.js +148 -0
  77. package/dist/bakeoff/stats.d.ts +13 -0
  78. package/dist/bakeoff/stats.d.ts.map +1 -0
  79. package/dist/bakeoff/stats.js +48 -0
  80. package/dist/bakeoff/types.d.ts +37 -0
  81. package/dist/bakeoff/types.d.ts.map +1 -0
  82. package/dist/bakeoff/types.js +10 -0
  83. package/dist/cli.d.ts +25 -0
  84. package/dist/cli.d.ts.map +1 -0
  85. package/dist/cli.js +590 -0
  86. package/dist/config.d.ts +204 -0
  87. package/dist/config.d.ts.map +1 -0
  88. package/dist/config.js +252 -0
  89. package/dist/deprecations.d.ts +32 -0
  90. package/dist/deprecations.d.ts.map +1 -0
  91. package/dist/deprecations.js +59 -0
  92. package/dist/feedback/coverage.d.ts +32 -0
  93. package/dist/feedback/coverage.d.ts.map +1 -0
  94. package/dist/feedback/coverage.js +95 -0
  95. package/dist/feedback/feedback.d.ts +35 -0
  96. package/dist/feedback/feedback.d.ts.map +1 -0
  97. package/dist/feedback/feedback.js +39 -0
  98. package/dist/gateway/http-protocol.d.ts +175 -0
  99. package/dist/gateway/http-protocol.d.ts.map +1 -0
  100. package/dist/gateway/http-protocol.js +105 -0
  101. package/dist/index.d.ts +242 -0
  102. package/dist/index.d.ts.map +1 -0
  103. package/dist/index.js +576 -0
  104. package/dist/init/finder.d.ts +94 -0
  105. package/dist/init/finder.d.ts.map +1 -0
  106. package/dist/init/finder.js +343 -0
  107. package/dist/init/init-cli.d.ts +10 -0
  108. package/dist/init/init-cli.d.ts.map +1 -0
  109. package/dist/init/init-cli.js +86 -0
  110. package/dist/init/observe-cli.d.ts +19 -0
  111. package/dist/init/observe-cli.d.ts.map +1 -0
  112. package/dist/init/observe-cli.js +73 -0
  113. package/dist/init/observe.d.ts +81 -0
  114. package/dist/init/observe.d.ts.map +1 -0
  115. package/dist/init/observe.js +245 -0
  116. package/dist/init/run.d.ts +99 -0
  117. package/dist/init/run.d.ts.map +1 -0
  118. package/dist/init/run.js +281 -0
  119. package/dist/init/signatures.d.ts +39 -0
  120. package/dist/init/signatures.d.ts.map +1 -0
  121. package/dist/init/signatures.js +116 -0
  122. package/dist/matrix/aggregate.d.ts +89 -0
  123. package/dist/matrix/aggregate.d.ts.map +1 -0
  124. package/dist/matrix/aggregate.js +186 -0
  125. package/dist/query/grammar.d.ts +35 -0
  126. package/dist/query/grammar.d.ts.map +1 -0
  127. package/dist/query/grammar.js +279 -0
  128. package/dist/query/run.d.ts +8 -0
  129. package/dist/query/run.d.ts.map +1 -0
  130. package/dist/query/run.js +21 -0
  131. package/dist/registry/build.d.ts +219 -0
  132. package/dist/registry/build.d.ts.map +1 -0
  133. package/dist/registry/build.js +313 -0
  134. package/dist/registry/cache-policy.d.ts +94 -0
  135. package/dist/registry/cache-policy.d.ts.map +1 -0
  136. package/dist/registry/cache-policy.js +238 -0
  137. package/dist/registry/call-notes.d.ts +11 -0
  138. package/dist/registry/call-notes.d.ts.map +1 -0
  139. package/dist/registry/call-notes.js +110 -0
  140. package/dist/registry/claims.d.ts +63 -0
  141. package/dist/registry/claims.d.ts.map +1 -0
  142. package/dist/registry/claims.js +107 -0
  143. package/dist/registry/effective-rate.d.ts +151 -0
  144. package/dist/registry/effective-rate.d.ts.map +1 -0
  145. package/dist/registry/effective-rate.js +156 -0
  146. package/dist/registry/facts.d.ts +32 -0
  147. package/dist/registry/facts.d.ts.map +1 -0
  148. package/dist/registry/facts.js +136 -0
  149. package/dist/registry/fingerprint.d.ts +20 -0
  150. package/dist/registry/fingerprint.d.ts.map +1 -0
  151. package/dist/registry/fingerprint.js +150 -0
  152. package/dist/registry/parity.d.ts +52 -0
  153. package/dist/registry/parity.d.ts.map +1 -0
  154. package/dist/registry/parity.js +82 -0
  155. package/dist/registry/pricing-shape.d.ts +113 -0
  156. package/dist/registry/pricing-shape.d.ts.map +1 -0
  157. package/dist/registry/pricing-shape.js +123 -0
  158. package/dist/registry/pricing.d.ts +43 -0
  159. package/dist/registry/pricing.d.ts.map +1 -0
  160. package/dist/registry/pricing.js +127 -0
  161. package/dist/registry/rows.d.ts +16 -0
  162. package/dist/registry/rows.d.ts.map +1 -0
  163. package/dist/registry/rows.js +57 -0
  164. package/dist/registry/seed.d.ts +43 -0
  165. package/dist/registry/seed.d.ts.map +1 -0
  166. package/dist/registry/seed.js +97 -0
  167. package/dist/registry/select.d.ts +68 -0
  168. package/dist/registry/select.d.ts.map +1 -0
  169. package/dist/registry/select.js +141 -0
  170. package/dist/registry/staleness.d.ts +18 -0
  171. package/dist/registry/staleness.d.ts.map +1 -0
  172. package/dist/registry/staleness.js +39 -0
  173. package/dist/rigindex/bootstrap.d.ts +36 -0
  174. package/dist/rigindex/bootstrap.d.ts.map +1 -0
  175. package/dist/rigindex/bootstrap.js +97 -0
  176. package/dist/rigindex/fit.d.ts +24 -0
  177. package/dist/rigindex/fit.d.ts.map +1 -0
  178. package/dist/rigindex/fit.js +76 -0
  179. package/dist/rigindex/gates.d.ts +52 -0
  180. package/dist/rigindex/gates.d.ts.map +1 -0
  181. package/dist/rigindex/gates.js +109 -0
  182. package/dist/rigindex/graph.d.ts +31 -0
  183. package/dist/rigindex/graph.d.ts.map +1 -0
  184. package/dist/rigindex/graph.js +120 -0
  185. package/dist/rigindex/index.d.ts +23 -0
  186. package/dist/rigindex/index.d.ts.map +1 -0
  187. package/dist/rigindex/index.js +112 -0
  188. package/dist/rigindex/types.d.ts +76 -0
  189. package/dist/rigindex/types.d.ts.map +1 -0
  190. package/dist/rigindex/types.js +8 -0
  191. package/dist/routes/cache-lint.d.ts +41 -0
  192. package/dist/routes/cache-lint.d.ts.map +1 -0
  193. package/dist/routes/cache-lint.js +81 -0
  194. package/dist/routes/draft.d.ts +83 -0
  195. package/dist/routes/draft.d.ts.map +1 -0
  196. package/dist/routes/draft.js +135 -0
  197. package/dist/routes/loader.d.ts +63 -0
  198. package/dist/routes/loader.d.ts.map +1 -0
  199. package/dist/routes/loader.js +574 -0
  200. package/dist/routes/manifest.d.ts +24 -0
  201. package/dist/routes/manifest.d.ts.map +1 -0
  202. package/dist/routes/manifest.js +118 -0
  203. package/dist/routes/resolved-bundle.d.ts +79 -0
  204. package/dist/routes/resolved-bundle.d.ts.map +1 -0
  205. package/dist/routes/resolved-bundle.js +148 -0
  206. package/dist/routes/sampling-config.d.ts +32 -0
  207. package/dist/routes/sampling-config.d.ts.map +1 -0
  208. package/dist/routes/sampling-config.js +91 -0
  209. package/dist/routes/serveability.d.ts +52 -0
  210. package/dist/routes/serveability.d.ts.map +1 -0
  211. package/dist/routes/serveability.js +73 -0
  212. package/dist/routes/template.d.ts +18 -0
  213. package/dist/routes/template.d.ts.map +1 -0
  214. package/dist/routes/template.js +94 -0
  215. package/dist/run/ajv.d.ts +22 -0
  216. package/dist/run/ajv.d.ts.map +1 -0
  217. package/dist/run/ajv.js +32 -0
  218. package/dist/run/cache-handle.d.ts +58 -0
  219. package/dist/run/cache-handle.d.ts.map +1 -0
  220. package/dist/run/cache-handle.js +54 -0
  221. package/dist/run/cache-stamp.d.ts +65 -0
  222. package/dist/run/cache-stamp.d.ts.map +1 -0
  223. package/dist/run/cache-stamp.js +0 -0
  224. package/dist/run/capture-write.d.ts +33 -0
  225. package/dist/run/capture-write.d.ts.map +1 -0
  226. package/dist/run/capture-write.js +55 -0
  227. package/dist/run/cost.d.ts +26 -0
  228. package/dist/run/cost.d.ts.map +1 -0
  229. package/dist/run/cost.js +41 -0
  230. package/dist/run/dispatch.d.ts +99 -0
  231. package/dist/run/dispatch.d.ts.map +1 -0
  232. package/dist/run/dispatch.js +191 -0
  233. package/dist/run/envelope.d.ts +21 -0
  234. package/dist/run/envelope.d.ts.map +1 -0
  235. package/dist/run/envelope.js +45 -0
  236. package/dist/run/grounding.d.ts +56 -0
  237. package/dist/run/grounding.d.ts.map +1 -0
  238. package/dist/run/grounding.js +89 -0
  239. package/dist/run/raw.d.ts +88 -0
  240. package/dist/run/raw.d.ts.map +1 -0
  241. package/dist/run/raw.js +286 -0
  242. package/dist/run/record-attempt.d.ts +40 -0
  243. package/dist/run/record-attempt.d.ts.map +1 -0
  244. package/dist/run/record-attempt.js +99 -0
  245. package/dist/run/repair.d.ts +36 -0
  246. package/dist/run/repair.d.ts.map +1 -0
  247. package/dist/run/repair.js +61 -0
  248. package/dist/run/resolve.d.ts +99 -0
  249. package/dist/run/resolve.d.ts.map +1 -0
  250. package/dist/run/resolve.js +203 -0
  251. package/dist/run/retry.d.ts +19 -0
  252. package/dist/run/retry.d.ts.map +1 -0
  253. package/dist/run/retry.js +50 -0
  254. package/dist/run/run.d.ts +55 -0
  255. package/dist/run/run.d.ts.map +1 -0
  256. package/dist/run/run.js +540 -0
  257. package/dist/run/stream.d.ts +49 -0
  258. package/dist/run/stream.d.ts.map +1 -0
  259. package/dist/run/stream.js +87 -0
  260. package/dist/run/validate.d.ts +15 -0
  261. package/dist/run/validate.d.ts.map +1 -0
  262. package/dist/run/validate.js +55 -0
  263. package/dist/savings/cache-ledger.d.ts +108 -0
  264. package/dist/savings/cache-ledger.d.ts.map +1 -0
  265. package/dist/savings/cache-ledger.js +174 -0
  266. package/dist/savings/cache-reconcile.d.ts +64 -0
  267. package/dist/savings/cache-reconcile.d.ts.map +1 -0
  268. package/dist/savings/cache-reconcile.js +59 -0
  269. package/dist/savings/cache-stats.d.ts +63 -0
  270. package/dist/savings/cache-stats.d.ts.map +1 -0
  271. package/dist/savings/cache-stats.js +108 -0
  272. package/dist/savings/emit.d.ts +38 -0
  273. package/dist/savings/emit.d.ts.map +1 -0
  274. package/dist/savings/emit.js +100 -0
  275. package/dist/savings/odometer.d.ts +32 -0
  276. package/dist/savings/odometer.d.ts.map +1 -0
  277. package/dist/savings/odometer.js +70 -0
  278. package/dist/savings/swap-execute.d.ts +58 -0
  279. package/dist/savings/swap-execute.d.ts.map +1 -0
  280. package/dist/savings/swap-execute.js +130 -0
  281. package/dist/savings/swaps-client.d.ts +55 -0
  282. package/dist/savings/swaps-client.d.ts.map +1 -0
  283. package/dist/savings/swaps-client.js +95 -0
  284. package/dist/settings/api-fetcher.d.ts +39 -0
  285. package/dist/settings/api-fetcher.d.ts.map +1 -0
  286. package/dist/settings/api-fetcher.js +92 -0
  287. package/dist/settings/index.d.ts +10 -0
  288. package/dist/settings/index.d.ts.map +1 -0
  289. package/dist/settings/index.js +15 -0
  290. package/dist/settings/task-settings.d.ts +91 -0
  291. package/dist/settings/task-settings.d.ts.map +1 -0
  292. package/dist/settings/task-settings.js +116 -0
  293. package/dist/status.d.ts +77 -0
  294. package/dist/status.d.ts.map +1 -0
  295. package/dist/status.js +113 -0
  296. package/dist/telemetry/artifact-store.d.ts +48 -0
  297. package/dist/telemetry/artifact-store.d.ts.map +1 -0
  298. package/dist/telemetry/artifact-store.js +189 -0
  299. package/dist/telemetry/cache-miss-streak.d.ts +79 -0
  300. package/dist/telemetry/cache-miss-streak.d.ts.map +1 -0
  301. package/dist/telemetry/cache-miss-streak.js +99 -0
  302. package/dist/telemetry/capture.d.ts +31 -0
  303. package/dist/telemetry/capture.d.ts.map +1 -0
  304. package/dist/telemetry/capture.js +81 -0
  305. package/dist/telemetry/exporter-setup.d.ts +28 -0
  306. package/dist/telemetry/exporter-setup.d.ts.map +1 -0
  307. package/dist/telemetry/exporter-setup.js +34 -0
  308. package/dist/telemetry/exporter.d.ts +137 -0
  309. package/dist/telemetry/exporter.d.ts.map +1 -0
  310. package/dist/telemetry/exporter.js +510 -0
  311. package/dist/telemetry/health.d.ts +76 -0
  312. package/dist/telemetry/health.d.ts.map +1 -0
  313. package/dist/telemetry/health.js +92 -0
  314. package/dist/telemetry/ingest-protocol.d.ts +310 -0
  315. package/dist/telemetry/ingest-protocol.d.ts.map +1 -0
  316. package/dist/telemetry/ingest-protocol.js +363 -0
  317. package/dist/telemetry/load-error-report.d.ts +24 -0
  318. package/dist/telemetry/load-error-report.d.ts.map +1 -0
  319. package/dist/telemetry/load-error-report.js +50 -0
  320. package/dist/telemetry/otel-map.d.ts +121 -0
  321. package/dist/telemetry/otel-map.d.ts.map +1 -0
  322. package/dist/telemetry/otel-map.js +224 -0
  323. package/dist/telemetry/otel-normalize.d.ts +104 -0
  324. package/dist/telemetry/otel-normalize.d.ts.map +1 -0
  325. package/dist/telemetry/otel-normalize.js +530 -0
  326. package/dist/telemetry/otlp-emitter.d.ts +52 -0
  327. package/dist/telemetry/otlp-emitter.d.ts.map +1 -0
  328. package/dist/telemetry/otlp-emitter.js +144 -0
  329. package/dist/telemetry/otlp-proto.d.ts +29 -0
  330. package/dist/telemetry/otlp-proto.d.ts.map +1 -0
  331. package/dist/telemetry/otlp-proto.js +266 -0
  332. package/dist/telemetry/sinks.d.ts +90 -0
  333. package/dist/telemetry/sinks.d.ts.map +1 -0
  334. package/dist/telemetry/sinks.js +180 -0
  335. package/dist/telemetry/store.d.ts +65 -0
  336. package/dist/telemetry/store.d.ts.map +1 -0
  337. package/dist/telemetry/store.js +547 -0
  338. package/dist/tenancy/api-key-format.d.ts +77 -0
  339. package/dist/tenancy/api-key-format.d.ts.map +1 -0
  340. package/dist/tenancy/api-key-format.js +110 -0
  341. package/dist/tenancy/constants.d.ts +23 -0
  342. package/dist/tenancy/constants.d.ts.map +1 -0
  343. package/dist/tenancy/constants.js +25 -0
  344. package/dist/tenancy/scrub.d.ts +47 -0
  345. package/dist/tenancy/scrub.d.ts.map +1 -0
  346. package/dist/tenancy/scrub.js +85 -0
  347. package/dist/types/config-teaching.d.ts +62 -0
  348. package/dist/types/config-teaching.d.ts.map +1 -0
  349. package/dist/types/config-teaching.js +183 -0
  350. package/dist/types/failures-teaching.d.ts +56 -0
  351. package/dist/types/failures-teaching.d.ts.map +1 -0
  352. package/dist/types/failures-teaching.js +177 -0
  353. package/dist/types/failures.d.ts +27 -0
  354. package/dist/types/failures.d.ts.map +1 -0
  355. package/dist/types/failures.js +41 -0
  356. package/dist/types/provider.d.ts +200 -0
  357. package/dist/types/provider.d.ts.map +1 -0
  358. package/dist/types/provider.js +40 -0
  359. package/dist/types/route.d.ts +205 -0
  360. package/dist/types/route.d.ts.map +1 -0
  361. package/dist/types/route.js +6 -0
  362. package/dist/types/telemetry.d.ts +206 -0
  363. package/dist/types/telemetry.d.ts.map +1 -0
  364. package/dist/types/telemetry.js +6 -0
  365. package/dist/validate-cli.d.ts +12 -0
  366. package/dist/validate-cli.d.ts.map +1 -0
  367. package/dist/validate-cli.js +57 -0
  368. package/dist/verify/capture.d.ts +66 -0
  369. package/dist/verify/capture.d.ts.map +1 -0
  370. package/dist/verify/capture.js +180 -0
  371. package/dist/verify/cli-run.d.ts +23 -0
  372. package/dist/verify/cli-run.d.ts.map +1 -0
  373. package/dist/verify/cli-run.js +57 -0
  374. package/dist/verify/diff.d.ts +48 -0
  375. package/dist/verify/diff.d.ts.map +1 -0
  376. package/dist/verify/diff.js +157 -0
  377. package/dist/verify/index.d.ts +17 -0
  378. package/dist/verify/index.d.ts.map +1 -0
  379. package/dist/verify/index.js +24 -0
  380. package/dist/verify/report.d.ts +14 -0
  381. package/dist/verify/report.d.ts.map +1 -0
  382. package/dist/verify/report.js +88 -0
  383. package/dist/verify/types.d.ts +101 -0
  384. package/dist/verify/types.d.ts.map +1 -0
  385. package/dist/verify/types.js +17 -0
  386. package/dist/verify/verify.d.ts +29 -0
  387. package/dist/verify/verify.d.ts.map +1 -0
  388. package/dist/verify/verify.js +148 -0
  389. package/dist/watch/budget.d.ts +19 -0
  390. package/dist/watch/budget.d.ts.map +1 -0
  391. package/dist/watch/budget.js +35 -0
  392. package/dist/watch/evaluate.d.ts +225 -0
  393. package/dist/watch/evaluate.d.ts.map +1 -0
  394. package/dist/watch/evaluate.js +155 -0
  395. package/dist/watch/monitor.d.ts +116 -0
  396. package/dist/watch/monitor.d.ts.map +1 -0
  397. package/dist/watch/monitor.js +199 -0
  398. package/dist/watch/proposals.d.ts +89 -0
  399. package/dist/watch/proposals.d.ts.map +1 -0
  400. package/dist/watch/proposals.js +197 -0
  401. package/dist/watch/run-record.d.ts +64 -0
  402. package/dist/watch/run-record.d.ts.map +1 -0
  403. package/dist/watch/run-record.js +86 -0
  404. package/dist/watch/run-reported.d.ts +20 -0
  405. package/dist/watch/run-reported.d.ts.map +1 -0
  406. package/dist/watch/run-reported.js +53 -0
  407. package/dist/watch/run.d.ts +73 -0
  408. package/dist/watch/run.d.ts.map +1 -0
  409. package/dist/watch/run.js +83 -0
  410. package/dist/watch/state-store.d.ts +48 -0
  411. package/dist/watch/state-store.d.ts.map +1 -0
  412. package/dist/watch/state-store.js +86 -0
  413. package/dist/watch/state.d.ts +21 -0
  414. package/dist/watch/state.d.ts.map +1 -0
  415. package/dist/watch/state.js +93 -0
  416. package/package.json +56 -14
  417. package/registry/LICENSE +20 -0
  418. package/registry/leaderboard.json +3639 -0
  419. package/registry/registry.json +7263 -0
  420. package/index.js +0 -3
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ /**
3
+ * The capture step — records N invocations of the ORIGINAL call site's
4
+ * inputs/outputs LOCALLY (spec §9 Tier-2 verify). Two surfaces:
5
+ *
6
+ * - `captureOriginal(site, originalFn, inputs)` — invoke the original call
7
+ * (a black-box function the skill/harness wraps around the customer's real
8
+ * call) once per input and record the I/O into a fixture. Honest refusal is
9
+ * built in: a streaming or dynamically-assembled-prompt call site is REFUSED
10
+ * up front (those are T0/T1 territory), and an input the original throws on
11
+ * is recorded as a per-input refusal, never a lost sample.
12
+ * - `openShadowCaptureStore(dbPath)` — a durable local SQLite buffer for the
13
+ * same captures, the same posture as telemetry/capture.ts: a plain
14
+ * better-sqlite3 handle with record/readAll/close and NO network or upload
15
+ * accessor. Captures stay in the SDK process; nothing here uploads.
16
+ *
17
+ * The portable `ShadowCaptureFixture` (JSON) is the hand-off the CLI reads and
18
+ * the skill embeds context from — the only thing that leaves this module, and
19
+ * only to local disk.
20
+ */
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.captureOriginal = captureOriginal;
26
+ exports.openShadowCaptureStore = openShadowCaptureStore;
27
+ exports.serializeFixture = serializeFixture;
28
+ exports.parseFixture = parseFixture;
29
+ const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
30
+ const node_fs_1 = require("node:fs");
31
+ const node_path_1 = require("node:path");
32
+ /**
33
+ * Capture N original invocations into a fixture. Streaming/dynamic sites are
34
+ * refused before any call; per-input failures become `uncapturable` refusals.
35
+ */
36
+ async function captureOriginal(site, originalFn, inputs, opts = {}) {
37
+ const capturedAt = (opts.now ?? (() => new Date().toISOString()))();
38
+ const nd = site.nondeterministicPaths;
39
+ const upfront = refuseUpFront(site);
40
+ if (upfront !== null) {
41
+ return {
42
+ callSiteId: site.callSiteId,
43
+ original: site.original,
44
+ capturedAt,
45
+ samples: [],
46
+ refusals: [upfront],
47
+ ...(nd !== undefined ? { nondeterministicPaths: nd } : {}),
48
+ };
49
+ }
50
+ const samples = [];
51
+ const refusals = [];
52
+ for (const input of inputs) {
53
+ try {
54
+ const output = await originalFn(input);
55
+ samples.push({ input, output });
56
+ }
57
+ catch (err) {
58
+ refusals.push({
59
+ reason: "uncapturable",
60
+ detail: `input ${JSON.stringify(input)} could not be captured: ` +
61
+ (err instanceof Error ? err.message : String(err)),
62
+ });
63
+ }
64
+ }
65
+ return {
66
+ callSiteId: site.callSiteId,
67
+ original: site.original,
68
+ capturedAt,
69
+ samples,
70
+ ...(refusals.length > 0 ? { refusals } : {}),
71
+ ...(nd !== undefined ? { nondeterministicPaths: nd } : {}),
72
+ };
73
+ }
74
+ function refuseUpFront(site) {
75
+ if (site.streaming === true) {
76
+ return {
77
+ reason: "streaming",
78
+ detail: `call site ${site.callSiteId} streams tokens — a streaming call has no single ` +
79
+ "terminal output to replay against; per the batch-first deferral this is T0/T1 territory",
80
+ };
81
+ }
82
+ if (site.dynamicPrompt === true) {
83
+ return {
84
+ reason: "dynamic-prompt",
85
+ detail: `call site ${site.callSiteId} assembles its prompt dynamically — it does not map to a ` +
86
+ "stable template + variables, so it cannot be replayed through a task route (T0/T1 territory)",
87
+ };
88
+ }
89
+ return null;
90
+ }
91
+ const SHADOW_SQL = `
92
+ CREATE TABLE IF NOT EXISTS shadow_captures (
93
+ call_site_id TEXT NOT NULL,
94
+ seq INTEGER NOT NULL,
95
+ provider TEXT NOT NULL,
96
+ model TEXT NOT NULL,
97
+ input_json TEXT NOT NULL,
98
+ output_text TEXT NOT NULL,
99
+ PRIMARY KEY (call_site_id, seq)
100
+ );
101
+ `;
102
+ /**
103
+ * A separate better-sqlite3 handle — deliberately NOT wired to any exporter or
104
+ * upload path. Shadow captures are original-call outputs used only to prove
105
+ * equivalence locally; nothing here ever leaves the machine (the SDK's
106
+ * export-isolation posture, extended to the verifier).
107
+ */
108
+ function openShadowCaptureStore(dbPath) {
109
+ (0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(dbPath), { recursive: true });
110
+ const db = new better_sqlite3_1.default(dbPath);
111
+ db.pragma("journal_mode = WAL");
112
+ db.exec(SHADOW_SQL);
113
+ const nextSeq = db.prepare("SELECT COALESCE(MAX(seq), -1) + 1 AS n FROM shadow_captures WHERE call_site_id = ?");
114
+ const insert = db.prepare(`
115
+ INSERT INTO shadow_captures (call_site_id, seq, provider, model, input_json, output_text)
116
+ VALUES (@call_site_id, @seq, @provider, @model, @input_json, @output_text)
117
+ `);
118
+ const selectAll = db.prepare("SELECT input_json, output_text FROM shadow_captures WHERE call_site_id = ? ORDER BY seq ASC");
119
+ return {
120
+ record(row) {
121
+ const seq = nextSeq.get(row.callSiteId).n;
122
+ insert.run({
123
+ call_site_id: row.callSiteId,
124
+ seq,
125
+ provider: row.provider,
126
+ model: row.model,
127
+ input_json: JSON.stringify(row.input),
128
+ output_text: row.output,
129
+ });
130
+ },
131
+ readAll(callSiteId) {
132
+ return selectAll.all(callSiteId).map((r) => ({
133
+ input: JSON.parse(r.input_json),
134
+ output: r.output_text,
135
+ }));
136
+ },
137
+ close() {
138
+ db.close();
139
+ },
140
+ };
141
+ }
142
+ // ── Portable fixture JSON (the CLI hand-off) ─────────────────────────────────
143
+ function serializeFixture(fixture) {
144
+ return `${JSON.stringify(fixture, null, 2)}\n`;
145
+ }
146
+ /** A non-null, non-array object (the shape a JSON `{...}` decodes to). */
147
+ function isPlainObject(v) {
148
+ return v !== null && typeof v === "object" && !Array.isArray(v);
149
+ }
150
+ /** Parse + shape-validate a fixture (errors teach — the CLI surfaces them). */
151
+ function parseFixture(json) {
152
+ let raw;
153
+ try {
154
+ raw = JSON.parse(json);
155
+ }
156
+ catch (err) {
157
+ throw new Error(`capture fixture is not valid JSON: ${err.message}`);
158
+ }
159
+ if (raw === null || typeof raw !== "object") {
160
+ throw new Error("capture fixture must be a JSON object");
161
+ }
162
+ const o = raw;
163
+ if (typeof o.callSiteId !== "string")
164
+ throw new Error('capture fixture is missing "callSiteId"');
165
+ const original = o.original;
166
+ if (!isPlainObject(original) || typeof original.provider !== "string" || typeof original.model !== "string") {
167
+ throw new Error('capture fixture is missing a valid "original" { provider, model }');
168
+ }
169
+ if (!Array.isArray(o.samples))
170
+ throw new Error('capture fixture is missing a "samples" array');
171
+ for (const [i, s] of o.samples.entries()) {
172
+ const sample = s;
173
+ // `input` must be a plain object of template variables — null and arrays
174
+ // pass a bare `typeof === "object"` check but break render/replay downstream.
175
+ if (!isPlainObject(sample) || typeof sample.output !== "string" || !isPlainObject(sample.input)) {
176
+ throw new Error(`capture fixture sample ${i} must be { input: object, output: string }`);
177
+ }
178
+ }
179
+ return raw;
180
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `modelrig verify-swap` runner — reads a local capture fixture, replays it
3
+ * through the drafted same-model route, and writes BOTH report forms: the
4
+ * machine-readable JSON (the skill parses it) and the human-readable Markdown
5
+ * (the Tier-2 PR embeds it). Lives here (not cli.ts) for the LOC cap (P1),
6
+ * beside the report renderer it drives — same split as bakeoff/report.ts.
7
+ *
8
+ * Exit code is the gate the skill reads: 0 = equivalent / equivalent-modulo,
9
+ * 1 = DIVERGENT (do not merge), 2 = REFUSED (not a Tier-2 replacement — a
10
+ * correct outcome that needs a human's T0/T1 rethink, not a merge).
11
+ */
12
+ import type { RigConfig } from "../config";
13
+ export interface VerifySwapCliOptions {
14
+ readonly route: string;
15
+ readonly fixturePath: string;
16
+ readonly envelopeUsd?: number;
17
+ /** Print the machine-readable JSON to stdout instead of the Markdown. */
18
+ readonly asJson?: boolean;
19
+ /** Also write the Markdown report to this path (the PR body source). */
20
+ readonly outPath?: string;
21
+ }
22
+ export declare function runVerifySwapCli(config: RigConfig, opts: VerifySwapCliOptions): Promise<number>;
23
+ //# sourceMappingURL=cli-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-run.d.ts","sourceRoot":"","sources":["../../src/verify/cli-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAM3C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAQD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,MAAM,CAAC,CA+BjB"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * `modelrig verify-swap` runner — reads a local capture fixture, replays it
4
+ * through the drafted same-model route, and writes BOTH report forms: the
5
+ * machine-readable JSON (the skill parses it) and the human-readable Markdown
6
+ * (the Tier-2 PR embeds it). Lives here (not cli.ts) for the LOC cap (P1),
7
+ * beside the report renderer it drives — same split as bakeoff/report.ts.
8
+ *
9
+ * Exit code is the gate the skill reads: 0 = equivalent / equivalent-modulo,
10
+ * 1 = DIVERGENT (do not merge), 2 = REFUSED (not a Tier-2 replacement — a
11
+ * correct outcome that needs a human's T0/T1 rethink, not a merge).
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.runVerifySwapCli = runVerifySwapCli;
15
+ const node_fs_1 = require("node:fs");
16
+ const node_path_1 = require("node:path");
17
+ const index_1 = require("../index");
18
+ const capture_1 = require("./capture");
19
+ const report_1 = require("./report");
20
+ function exitFor(report) {
21
+ if (report.overall === "divergent")
22
+ return 1;
23
+ if (report.overall === "refused")
24
+ return 2;
25
+ return 0;
26
+ }
27
+ async function runVerifySwapCli(config, opts) {
28
+ const fixture = (0, capture_1.parseFixture)((0, node_fs_1.readFileSync)(opts.fixturePath, "utf8"));
29
+ const rig = (0, index_1.createRig)(config);
30
+ try {
31
+ const report = await rig.verifySwap(opts.route, fixture, {
32
+ ...(opts.envelopeUsd !== undefined ? { envelopeUsd: opts.envelopeUsd } : {}),
33
+ });
34
+ // Persist both forms next to the telemetry db (captures never travel; the
35
+ // report is aggregate + local).
36
+ const outDir = (0, node_path_1.join)((0, node_path_1.dirname)(config.telemetryDbPath), "verify");
37
+ (0, node_fs_1.mkdirSync)(outDir, { recursive: true });
38
+ const stem = (0, node_path_1.join)(outDir, `${report.route}@${report.routeVersion}`);
39
+ (0, node_fs_1.writeFileSync)(`${stem}.json`, `${JSON.stringify(report, null, 2)}\n`);
40
+ const markdown = (0, report_1.renderReportMarkdown)(report);
41
+ (0, node_fs_1.writeFileSync)(`${stem}.md`, markdown);
42
+ if (opts.outPath !== undefined) {
43
+ (0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(opts.outPath), { recursive: true });
44
+ (0, node_fs_1.writeFileSync)(opts.outPath, markdown);
45
+ }
46
+ if (opts.asJson)
47
+ console.log(JSON.stringify(report, null, 2));
48
+ else
49
+ console.log(markdown);
50
+ console.log(`report → ${stem}.json · ${stem}.md` + (opts.outPath !== undefined ? ` · ${opts.outPath}` : ""));
51
+ return exitFor(report);
52
+ }
53
+ finally {
54
+ // One-shot CLI: await the settled drain so the exporter's final batch lands.
55
+ await rig.close();
56
+ }
57
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The diff engine — the honest verdict vocabulary that makes the verifier's
3
+ * report trustworthy. Pure (no adapters, no run loop): it compares an
4
+ * original output against a routed one and returns one of three verdicts.
5
+ *
6
+ * Design decision (flagged for architect review): the routed output arrives
7
+ * as PARSED JSON — `run()` only returns after the output validated against the
8
+ * route schema (or it throws), so a routed sample is guaranteed schema-
9
+ * conformant and JSON. We therefore compare STRUCTURE, not raw bytes. For JSON,
10
+ * key order and whitespace are not behavior, so "byte-identical where
11
+ * deterministic" is operationalized as CANONICAL identity (sorted-key
12
+ * serialization). Structured-field equality — with declared nondeterministic
13
+ * fields excluded — is the fallback, exactly as the spec's §6 evaluation
14
+ * contract prescribes.
15
+ */
16
+ import type { SampleDiff } from "./types";
17
+ /** Deterministic JSON serialization: object keys sorted recursively, arrays
18
+ * left in order (order is semantic). The operative notion of "byte-identical"
19
+ * for JSON outputs. */
20
+ export declare function canonicalJson(value: unknown): string;
21
+ export interface Divergence {
22
+ /** JSON-pointer path to the first differing node. */
23
+ readonly path: string;
24
+ readonly originalValue: unknown;
25
+ readonly routedValue: unknown;
26
+ }
27
+ /**
28
+ * First point at which `original` and `routed` structurally differ, in a
29
+ * stable depth-first order, or null when they are deep-equal after masking the
30
+ * declared nondeterministic paths. Object keys are visited in sorted order so
31
+ * the "first" differing field is deterministic across runs.
32
+ */
33
+ export declare function firstDivergence(original: unknown, routed: unknown, nondeterministicPaths: readonly string[], path?: string): Divergence | null;
34
+ /**
35
+ * Diff an original output (raw text) against a routed output (already parsed by
36
+ * `run()`), returning the verdict. `routedParsed` is guaranteed schema-
37
+ * conformant JSON by the run loop; `originalText` is whatever the original call
38
+ * site emitted.
39
+ *
40
+ * - byte / canonical identity ⇒ `equivalent`
41
+ * - structurally equal after masking declared nd-paths ⇒
42
+ * `equivalent-modulo-nondeterminism`
43
+ * - a real structured field differs ⇒ `divergent` (first field named)
44
+ * - the original is not JSON ⇒ `divergent` (a free-text call site — this
45
+ * isn't route-shaped work; T0/T1 territory, honestly flagged not forced)
46
+ */
47
+ export declare function diffOutputs(originalText: string, routedParsed: unknown, routedText: string, nondeterministicPaths: readonly string[]): SampleDiff;
48
+ //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/verify/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;uBAEuB;AACvB,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAcD,MAAM,WAAW,UAAU;IACzB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAQD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,OAAO,EACf,qBAAqB,EAAE,SAAS,MAAM,EAAE,EACxC,IAAI,SAAK,GACR,UAAU,GAAG,IAAI,CAuCnB;AAwBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,OAAO,EACrB,UAAU,EAAE,MAAM,EAClB,qBAAqB,EAAE,SAAS,MAAM,EAAE,GACvC,UAAU,CAyCZ"}
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ /**
3
+ * The diff engine — the honest verdict vocabulary that makes the verifier's
4
+ * report trustworthy. Pure (no adapters, no run loop): it compares an
5
+ * original output against a routed one and returns one of three verdicts.
6
+ *
7
+ * Design decision (flagged for architect review): the routed output arrives
8
+ * as PARSED JSON — `run()` only returns after the output validated against the
9
+ * route schema (or it throws), so a routed sample is guaranteed schema-
10
+ * conformant and JSON. We therefore compare STRUCTURE, not raw bytes. For JSON,
11
+ * key order and whitespace are not behavior, so "byte-identical where
12
+ * deterministic" is operationalized as CANONICAL identity (sorted-key
13
+ * serialization). Structured-field equality — with declared nondeterministic
14
+ * fields excluded — is the fallback, exactly as the spec's §6 evaluation
15
+ * contract prescribes.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.canonicalJson = canonicalJson;
19
+ exports.firstDivergence = firstDivergence;
20
+ exports.diffOutputs = diffOutputs;
21
+ /** Deterministic JSON serialization: object keys sorted recursively, arrays
22
+ * left in order (order is semantic). The operative notion of "byte-identical"
23
+ * for JSON outputs. */
24
+ function canonicalJson(value) {
25
+ return JSON.stringify(sortKeys(value));
26
+ }
27
+ function sortKeys(value) {
28
+ if (Array.isArray(value))
29
+ return value.map(sortKeys);
30
+ if (value !== null && typeof value === "object") {
31
+ const out = {};
32
+ for (const key of Object.keys(value).sort()) {
33
+ out[key] = sortKeys(value[key]);
34
+ }
35
+ return out;
36
+ }
37
+ return value;
38
+ }
39
+ /** True when `path` is exactly, or nested under, any declared nondeterministic
40
+ * path. `/meta` masks `/meta` and `/meta/gen`; it never masks `/metadata`. */
41
+ function isMasked(path, nondeterministicPaths) {
42
+ return nondeterministicPaths.some((nd) => path === nd || path.startsWith(`${nd}/`));
43
+ }
44
+ /**
45
+ * First point at which `original` and `routed` structurally differ, in a
46
+ * stable depth-first order, or null when they are deep-equal after masking the
47
+ * declared nondeterministic paths. Object keys are visited in sorted order so
48
+ * the "first" differing field is deterministic across runs.
49
+ */
50
+ function firstDivergence(original, routed, nondeterministicPaths, path = "") {
51
+ const here = path === "" ? "" : path;
52
+ if (isMasked(here || "/", nondeterministicPaths))
53
+ return null;
54
+ if (Array.isArray(original) || Array.isArray(routed)) {
55
+ if (!Array.isArray(original) || !Array.isArray(routed) || original.length !== routed.length) {
56
+ return { path: here || "/", originalValue: original, routedValue: routed };
57
+ }
58
+ for (let i = 0; i < original.length; i += 1) {
59
+ const d = firstDivergence(original[i], routed[i], nondeterministicPaths, `${here}/${i}`);
60
+ if (d !== null)
61
+ return d;
62
+ }
63
+ return null;
64
+ }
65
+ if (isObject(original) || isObject(routed)) {
66
+ if (!isObject(original) || !isObject(routed)) {
67
+ return { path: here || "/", originalValue: original, routedValue: routed };
68
+ }
69
+ const keys = [...new Set([...Object.keys(original), ...Object.keys(routed)])].sort();
70
+ for (const key of keys) {
71
+ const childPath = `${here}/${escapePointer(key)}`;
72
+ if (isMasked(childPath, nondeterministicPaths))
73
+ continue;
74
+ const inO = Object.prototype.hasOwnProperty.call(original, key);
75
+ const inR = Object.prototype.hasOwnProperty.call(routed, key);
76
+ if (!inO || !inR) {
77
+ return { path: childPath, originalValue: original[key], routedValue: routed[key] };
78
+ }
79
+ const d = firstDivergence(original[key], routed[key], nondeterministicPaths, childPath);
80
+ if (d !== null)
81
+ return d;
82
+ }
83
+ return null;
84
+ }
85
+ // Scalars (incl. null): a strict, type-aware compare.
86
+ if (original !== routed) {
87
+ return { path: here || "/", originalValue: original, routedValue: routed };
88
+ }
89
+ return null;
90
+ }
91
+ function isObject(v) {
92
+ return v !== null && typeof v === "object" && !Array.isArray(v);
93
+ }
94
+ /** RFC-6901 escaping for a path segment (`~`→`~0`, `/`→`~1`). */
95
+ function escapePointer(key) {
96
+ return key.replace(/~/g, "~0").replace(/\//g, "~1");
97
+ }
98
+ function shortValue(v) {
99
+ const s = typeof v === "string" ? v : JSON.stringify(v);
100
+ return s !== undefined && s.length > 60 ? `${s.slice(0, 57)}…` : String(s);
101
+ }
102
+ function tryParse(text) {
103
+ try {
104
+ return { ok: true, value: JSON.parse(text) };
105
+ }
106
+ catch {
107
+ return { ok: false };
108
+ }
109
+ }
110
+ /**
111
+ * Diff an original output (raw text) against a routed output (already parsed by
112
+ * `run()`), returning the verdict. `routedParsed` is guaranteed schema-
113
+ * conformant JSON by the run loop; `originalText` is whatever the original call
114
+ * site emitted.
115
+ *
116
+ * - byte / canonical identity ⇒ `equivalent`
117
+ * - structurally equal after masking declared nd-paths ⇒
118
+ * `equivalent-modulo-nondeterminism`
119
+ * - a real structured field differs ⇒ `divergent` (first field named)
120
+ * - the original is not JSON ⇒ `divergent` (a free-text call site — this
121
+ * isn't route-shaped work; T0/T1 territory, honestly flagged not forced)
122
+ */
123
+ function diffOutputs(originalText, routedParsed, routedText, nondeterministicPaths) {
124
+ // True byte-identity first — the strongest, cheapest signal.
125
+ if (originalText === routedText) {
126
+ return { verdict: "equivalent", firstDivergentPath: null, detail: "byte-identical output" };
127
+ }
128
+ const parsedOriginal = tryParse(originalText);
129
+ if (!parsedOriginal.ok) {
130
+ return {
131
+ verdict: "divergent",
132
+ firstDivergentPath: null,
133
+ detail: "original output is not JSON — this is a free-text call site; equivalence is not " +
134
+ "provable through a task route (T0/T1 territory, not a Tier-2 replacement)",
135
+ };
136
+ }
137
+ // Canonical identity: for JSON, key order and whitespace are not behavior.
138
+ if (canonicalJson(parsedOriginal.value) === canonicalJson(routedParsed)) {
139
+ return { verdict: "equivalent", firstDivergentPath: null, detail: "canonically identical JSON" };
140
+ }
141
+ const d = firstDivergence(parsedOriginal.value, routedParsed, nondeterministicPaths);
142
+ if (d === null) {
143
+ return {
144
+ verdict: "equivalent-modulo-nondeterminism",
145
+ firstDivergentPath: null,
146
+ detail: nondeterministicPaths.length > 0
147
+ ? `structurally equal after excluding nondeterministic field(s): ${nondeterministicPaths.join(", ")}`
148
+ : "structurally equal (serialization differs only)",
149
+ };
150
+ }
151
+ return {
152
+ verdict: "divergent",
153
+ firstDivergentPath: d.path,
154
+ detail: `structured field ${d.path} differs: original=${shortValue(d.originalValue)} ` +
155
+ `routed=${shortValue(d.routedValue)}`,
156
+ };
157
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shadow-equivalence verifier (Expansion §9, autonomy-ladder Tier 2) — the
3
+ * public barrel. Proves a same-model call replacement is behavior-preserving
4
+ * before a human merges the Tier-2 PR: capture (local) → replay through the
5
+ * routed replacement (reusing the run loop) → diff (honest verdict vocabulary)
6
+ * → report (machine + human). Refusing an uncapturable call site is a correct
7
+ * output, never a failure.
8
+ */
9
+ export { verifySwap } from "./verify";
10
+ export type { VerifySwapRequest } from "./verify";
11
+ export { diffOutputs, firstDivergence, canonicalJson } from "./diff";
12
+ export type { Divergence } from "./diff";
13
+ export { captureOriginal, openShadowCaptureStore, parseFixture, serializeFixture, } from "./capture";
14
+ export type { OriginalCallSite, OriginalCallFn, CaptureOptions, ShadowCaptureStore, ShadowCaptureRecord, } from "./capture";
15
+ export { renderReportMarkdown } from "./report";
16
+ export type { ShadowCapture, ShadowCaptureFixture, CaptureRefusal, SampleVerdict, EquivalenceVerdict, SampleDiff, SampleReport, EquivalenceReport, } from "./types";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verify/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * Shadow-equivalence verifier (Expansion §9, autonomy-ladder Tier 2) — the
4
+ * public barrel. Proves a same-model call replacement is behavior-preserving
5
+ * before a human merges the Tier-2 PR: capture (local) → replay through the
6
+ * routed replacement (reusing the run loop) → diff (honest verdict vocabulary)
7
+ * → report (machine + human). Refusing an uncapturable call site is a correct
8
+ * output, never a failure.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.renderReportMarkdown = exports.serializeFixture = exports.parseFixture = exports.openShadowCaptureStore = exports.captureOriginal = exports.canonicalJson = exports.firstDivergence = exports.diffOutputs = exports.verifySwap = void 0;
12
+ var verify_1 = require("./verify");
13
+ Object.defineProperty(exports, "verifySwap", { enumerable: true, get: function () { return verify_1.verifySwap; } });
14
+ var diff_1 = require("./diff");
15
+ Object.defineProperty(exports, "diffOutputs", { enumerable: true, get: function () { return diff_1.diffOutputs; } });
16
+ Object.defineProperty(exports, "firstDivergence", { enumerable: true, get: function () { return diff_1.firstDivergence; } });
17
+ Object.defineProperty(exports, "canonicalJson", { enumerable: true, get: function () { return diff_1.canonicalJson; } });
18
+ var capture_1 = require("./capture");
19
+ Object.defineProperty(exports, "captureOriginal", { enumerable: true, get: function () { return capture_1.captureOriginal; } });
20
+ Object.defineProperty(exports, "openShadowCaptureStore", { enumerable: true, get: function () { return capture_1.openShadowCaptureStore; } });
21
+ Object.defineProperty(exports, "parseFixture", { enumerable: true, get: function () { return capture_1.parseFixture; } });
22
+ Object.defineProperty(exports, "serializeFixture", { enumerable: true, get: function () { return capture_1.serializeFixture; } });
23
+ var report_1 = require("./report");
24
+ Object.defineProperty(exports, "renderReportMarkdown", { enumerable: true, get: function () { return report_1.renderReportMarkdown; } });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Report rendering — the shadow-equivalence report the skill's Tier-2 PR
3
+ * embeds. Two forms, one source: the machine-readable form is the
4
+ * `EquivalenceReport` object serialized as JSON (stable, `schemaVersion: 1`);
5
+ * the human-readable form is the Markdown below, written for a PR reviewer who
6
+ * must decide whether the same-model replacement is safe to merge.
7
+ *
8
+ * The rendering never editorializes the verdict — it prints exactly what the
9
+ * diff decided, always alongside the plumbing-not-model-choice guarantee so a
10
+ * reader cannot mistake equivalence for a model-quality claim.
11
+ */
12
+ import type { EquivalenceReport } from "./types";
13
+ export declare function renderReportMarkdown(report: EquivalenceReport): string;
14
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/verify/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAoC,MAAM,SAAS,CAAC;AAwCnF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CA+CtE"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * Report rendering — the shadow-equivalence report the skill's Tier-2 PR
4
+ * embeds. Two forms, one source: the machine-readable form is the
5
+ * `EquivalenceReport` object serialized as JSON (stable, `schemaVersion: 1`);
6
+ * the human-readable form is the Markdown below, written for a PR reviewer who
7
+ * must decide whether the same-model replacement is safe to merge.
8
+ *
9
+ * The rendering never editorializes the verdict — it prints exactly what the
10
+ * diff decided, always alongside the plumbing-not-model-choice guarantee so a
11
+ * reader cannot mistake equivalence for a model-quality claim.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.renderReportMarkdown = renderReportMarkdown;
15
+ const VERDICT_LABEL = {
16
+ equivalent: "EQUIVALENT",
17
+ "equivalent-modulo-nondeterminism": "EQUIVALENT (modulo nondeterminism)",
18
+ divergent: "DIVERGENT",
19
+ refused: "REFUSED",
20
+ };
21
+ /** The one-line headline a reviewer reads first. */
22
+ function headline(report) {
23
+ const label = VERDICT_LABEL[report.overall];
24
+ switch (report.overall) {
25
+ case "equivalent":
26
+ return `✅ **${label}** — all ${report.n} replayed input(s) reproduced the original output.`;
27
+ case "equivalent-modulo-nondeterminism":
28
+ return `🟡 **${label}** — all ${report.n} input(s) matched once declared nondeterministic fields were excluded.`;
29
+ case "divergent":
30
+ return `❌ **${label}** — ${report.counts.divergent} of ${report.n} input(s) did not reproduce; do not merge.`;
31
+ case "refused":
32
+ return `⛔ **${label}** — not a Tier-2 replacement. ${report.refusalReason ?? ""}`.trim();
33
+ }
34
+ }
35
+ /** Escape `|` so a field value never breaks the markdown table (the report is
36
+ * embedded in a PR body — a stray pipe from an odd JSON key must not corrupt it). */
37
+ function cell(text) {
38
+ return text.replace(/\|/g, "\\|");
39
+ }
40
+ function sampleRow(s) {
41
+ const detail = s.failureClass !== null
42
+ ? `replay failed (${s.failureClass})`
43
+ : s.firstDivergentPath !== null
44
+ ? `first differs at \`${cell(s.firstDivergentPath)}\``
45
+ : cell(s.detail);
46
+ return `| ${s.index} | ${s.verdict} | ${cell(s.servedModel ?? "—")} | $${s.costUsd.toFixed(4)} | ${detail} |`;
47
+ }
48
+ function renderReportMarkdown(report) {
49
+ const lines = [];
50
+ lines.push("## Shadow-equivalence verification");
51
+ lines.push("");
52
+ lines.push(headline(report));
53
+ lines.push("");
54
+ lines.push(`- **Call site:** \`${report.callSiteId}\``);
55
+ lines.push(`- **Route:** \`${report.route}@${report.routeVersion}\``);
56
+ lines.push(`- **Pinned model:** \`${report.pinnedModel}\` (original == replacement)`);
57
+ lines.push(`- **Ran at:** ${report.ranAt}`);
58
+ lines.push(`- **Tally:** ${report.counts.equivalent} equivalent · ` +
59
+ `${report.counts.equivalentModulo} modulo-nondeterminism · ${report.counts.divergent} divergent`);
60
+ lines.push("");
61
+ lines.push(`> ${report.guarantee}`);
62
+ lines.push("");
63
+ if (report.samples.length > 0) {
64
+ lines.push("| # | verdict | served model | cost | detail |");
65
+ lines.push("|---|---------|--------------|------|--------|");
66
+ for (const s of report.samples)
67
+ lines.push(sampleRow(s));
68
+ lines.push("");
69
+ }
70
+ if (report.refusals.length > 0) {
71
+ lines.push("### Refusals (honest, not failures)");
72
+ lines.push("");
73
+ for (const r of report.refusals)
74
+ lines.push(`- **${r.reason}** — ${r.detail}`);
75
+ lines.push("");
76
+ lines.push("Refused call sites are T0/T1 territory (gateway-pointing or instrumentation), " +
77
+ "not same-model call replacement — this is a correct outcome, not a gap.");
78
+ lines.push("");
79
+ }
80
+ lines.push(report.overall === "divergent"
81
+ ? "**Rollback is git-native:** revert this PR to restore the original call byte-for-byte."
82
+ : report.overall === "refused"
83
+ ? "No change is proposed for this call site."
84
+ : "Safe to merge on this evidence: the routed replacement preserves behavior. " +
85
+ "Rollback stays git-native (revert this PR) — same-model means it is also a route-YAML flip.");
86
+ lines.push("");
87
+ return lines.join("\n");
88
+ }