@tangle-network/agent-eval 0.128.2 → 0.130.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 (424) hide show
  1. package/CHANGELOG.md +279 -0
  2. package/README.md +19 -0
  3. package/dist/active-curriculum-C4mk67HP.js +214 -0
  4. package/dist/active-curriculum-C4mk67HP.js.map +1 -0
  5. package/dist/adversarial-smnADNFS.d.ts +21 -0
  6. package/dist/adversarial-smnADNFS.d.ts.map +1 -0
  7. package/dist/analyst/index.d.ts +83 -2932
  8. package/dist/analyst/index.d.ts.map +1 -0
  9. package/dist/analyst/index.js +319 -364
  10. package/dist/analyst/index.js.map +1 -1
  11. package/dist/analyst-BkTS3C58.d.ts +89 -0
  12. package/dist/analyst-BkTS3C58.d.ts.map +1 -0
  13. package/dist/analyst-LsnNpSkm.js +152 -0
  14. package/dist/analyst-LsnNpSkm.js.map +1 -0
  15. package/dist/analyze-runs-C1CavBMk.js +1067 -0
  16. package/dist/analyze-runs-C1CavBMk.js.map +1 -0
  17. package/dist/analyze-runs-FsgYCinh.d.ts +72 -0
  18. package/dist/analyze-runs-FsgYCinh.d.ts.map +1 -0
  19. package/dist/attribute-vocabulary-DLJ6303h.d.ts +54 -0
  20. package/dist/attribute-vocabulary-DLJ6303h.d.ts.map +1 -0
  21. package/dist/authenticity/index.d.ts +81 -79
  22. package/dist/authenticity/index.d.ts.map +1 -0
  23. package/dist/authenticity/index.js +209 -193
  24. package/dist/authenticity/index.js.map +1 -1
  25. package/dist/baseline-HsBvw_dk.js +550 -0
  26. package/dist/baseline-HsBvw_dk.js.map +1 -0
  27. package/dist/baseline-hG3K85h4.d.ts +125 -0
  28. package/dist/baseline-hG3K85h4.d.ts.map +1 -0
  29. package/dist/belief-state/index.d.ts +448 -1205
  30. package/dist/belief-state/index.d.ts.map +1 -0
  31. package/dist/belief-state/index.js +1617 -1710
  32. package/dist/belief-state/index.js.map +1 -1
  33. package/dist/benchmarks/index.d.ts +2 -894
  34. package/dist/benchmarks/index.js +2 -59
  35. package/dist/benchmarks-DviOvUNr.js +754 -0
  36. package/dist/benchmarks-DviOvUNr.js.map +1 -0
  37. package/dist/builder-eval/index.d.ts +150 -662
  38. package/dist/builder-eval/index.d.ts.map +1 -0
  39. package/dist/builder-eval/index.js +356 -345
  40. package/dist/builder-eval/index.js.map +1 -1
  41. package/dist/calibration-CNWWA6K8.js +94 -0
  42. package/dist/calibration-CNWWA6K8.js.map +1 -0
  43. package/dist/campaign/index.d.ts +5 -6390
  44. package/dist/campaign/index.js +3 -212
  45. package/dist/campaign-CBKZvQ1H.js +3885 -0
  46. package/dist/campaign-CBKZvQ1H.js.map +1 -0
  47. package/dist/cli.d.ts +1 -1
  48. package/dist/cli.js +164 -174
  49. package/dist/cli.js.map +1 -1
  50. package/dist/client-C97NMzqi.d.ts +581 -0
  51. package/dist/client-C97NMzqi.d.ts.map +1 -0
  52. package/dist/client-CYzbdJOZ.js +637 -0
  53. package/dist/client-CYzbdJOZ.js.map +1 -0
  54. package/dist/code-agent-session-BjkMTQ7H.js +1390 -0
  55. package/dist/code-agent-session-BjkMTQ7H.js.map +1 -0
  56. package/dist/code-agent-session-DqqgOJaz.d.ts +143 -0
  57. package/dist/code-agent-session-DqqgOJaz.d.ts.map +1 -0
  58. package/dist/concurrency-DIxRZF_J.js +85 -0
  59. package/dist/concurrency-DIxRZF_J.js.map +1 -0
  60. package/dist/contract/index.d.ts +645 -5605
  61. package/dist/contract/index.d.ts.map +1 -0
  62. package/dist/contract/index.js +1730 -1937
  63. package/dist/contract/index.js.map +1 -1
  64. package/dist/control.d.ts +3 -1030
  65. package/dist/control.js +2 -32
  66. package/dist/cost-ledger-DIgQUFZZ.js +801 -0
  67. package/dist/cost-ledger-DIgQUFZZ.js.map +1 -0
  68. package/dist/cost-ledger-Dye6jCgg.d.ts +236 -0
  69. package/dist/cost-ledger-Dye6jCgg.d.ts.map +1 -0
  70. package/dist/dataset-BvtnC8Dc.d.ts +115 -0
  71. package/dist/dataset-BvtnC8Dc.d.ts.map +1 -0
  72. package/dist/default-registry-C-vFCSEc.js +2579 -0
  73. package/dist/default-registry-C-vFCSEc.js.map +1 -0
  74. package/dist/default-registry-CNPo-Vsb.d.ts +540 -0
  75. package/dist/default-registry-CNPo-Vsb.d.ts.map +1 -0
  76. package/dist/emitter-CPBAhxum.js +266 -0
  77. package/dist/emitter-CPBAhxum.js.map +1 -0
  78. package/dist/emitter-DGQGoLyj.d.ts +113 -0
  79. package/dist/emitter-DGQGoLyj.d.ts.map +1 -0
  80. package/dist/errors-8YnH8WlF.js +64 -0
  81. package/dist/errors-8YnH8WlF.js.map +1 -0
  82. package/dist/errors-CEk209JS.d.ts +76 -0
  83. package/dist/errors-CEk209JS.d.ts.map +1 -0
  84. package/dist/eval-campaign-DEm6c8ru.js +349 -0
  85. package/dist/eval-campaign-DEm6c8ru.js.map +1 -0
  86. package/dist/execution-tracks-CpgFPpS5.js +93 -0
  87. package/dist/execution-tracks-CpgFPpS5.js.map +1 -0
  88. package/dist/exporters-q9iL-2Jf.js +148 -0
  89. package/dist/exporters-q9iL-2Jf.js.map +1 -0
  90. package/dist/extract-usage-BrQ8mCLX.js +155 -0
  91. package/dist/extract-usage-BrQ8mCLX.js.map +1 -0
  92. package/dist/failure-cluster-CqcvCcdR.d.ts +59 -0
  93. package/dist/failure-cluster-CqcvCcdR.d.ts.map +1 -0
  94. package/dist/feedback-trajectory-CVaeREXV.d.ts +340 -0
  95. package/dist/feedback-trajectory-CVaeREXV.d.ts.map +1 -0
  96. package/dist/fuzz.d.ts +320 -646
  97. package/dist/fuzz.d.ts.map +1 -0
  98. package/dist/fuzz.js +670 -617
  99. package/dist/fuzz.js.map +1 -1
  100. package/dist/hf-dataset-DBJXXoY1.js +763 -0
  101. package/dist/hf-dataset-DBJXXoY1.js.map +1 -0
  102. package/dist/hosted/index.d.ts +11 -831
  103. package/dist/hosted/index.d.ts.map +1 -0
  104. package/dist/hosted/index.js +2 -37
  105. package/dist/index-2JJSA6-r2.d.ts +926 -0
  106. package/dist/index-2JJSA6-r2.d.ts.map +1 -0
  107. package/dist/index-6N0aYmpW.d.ts +217 -0
  108. package/dist/index-6N0aYmpW.d.ts.map +1 -0
  109. package/dist/index-BAvgST_9.d.ts +131 -0
  110. package/dist/index-BAvgST_9.d.ts.map +1 -0
  111. package/dist/index-BvnJuTGD.d.ts +68 -0
  112. package/dist/index-BvnJuTGD.d.ts.map +1 -0
  113. package/dist/index-C61Wi7yg.d.ts +547 -0
  114. package/dist/index-C61Wi7yg.d.ts.map +1 -0
  115. package/dist/index-CAPUUKaM.d.ts +335 -0
  116. package/dist/index-CAPUUKaM.d.ts.map +1 -0
  117. package/dist/index-DE5fb3EC.d.ts +2244 -0
  118. package/dist/index-DE5fb3EC.d.ts.map +1 -0
  119. package/dist/index-DSC51roc.d.ts +102 -0
  120. package/dist/index-DSC51roc.d.ts.map +1 -0
  121. package/dist/index.d.ts +3776 -15120
  122. package/dist/index.d.ts.map +1 -0
  123. package/dist/index.js +11185 -11191
  124. package/dist/index.js.map +1 -1
  125. package/dist/integrity-BzRbCHzi.js +424 -0
  126. package/dist/integrity-BzRbCHzi.js.map +1 -0
  127. package/dist/integrity-rmVhXWA7.d.ts +61 -0
  128. package/dist/integrity-rmVhXWA7.d.ts.map +1 -0
  129. package/dist/judge-calibration-DFtEMlde.d.ts +146 -0
  130. package/dist/judge-calibration-DFtEMlde.d.ts.map +1 -0
  131. package/dist/ledger-core/index.d.ts +2 -0
  132. package/dist/ledger-core/index.js +2 -0
  133. package/dist/ledger-core-DtZz1RG0.js +388 -0
  134. package/dist/ledger-core-DtZz1RG0.js.map +1 -0
  135. package/dist/llm-client--GR4JbZE.js +687 -0
  136. package/dist/llm-client--GR4JbZE.js.map +1 -0
  137. package/dist/llm-client-B_nIBlYo.d.ts +290 -0
  138. package/dist/llm-client-B_nIBlYo.d.ts.map +1 -0
  139. package/dist/matrix/index.d.ts +3 -155
  140. package/dist/matrix/index.js +2 -8
  141. package/dist/matrix-BzQnu2S6.js +270 -0
  142. package/dist/matrix-BzQnu2S6.js.map +1 -0
  143. package/dist/meta-eval/index.d.ts +4 -1027
  144. package/dist/meta-eval/index.js +393 -390
  145. package/dist/meta-eval/index.js.map +1 -1
  146. package/dist/metrics-C9YY1OcL.js +239 -0
  147. package/dist/metrics-C9YY1OcL.js.map +1 -0
  148. package/dist/mint-yN2M2eh0.js +201 -0
  149. package/dist/mint-yN2M2eh0.js.map +1 -0
  150. package/dist/multi-layer-verifier-BHY1gWAc.d.ts +138 -0
  151. package/dist/multi-layer-verifier-BHY1gWAc.d.ts.map +1 -0
  152. package/dist/multishot/index.d.ts +273 -481
  153. package/dist/multishot/index.d.ts.map +1 -0
  154. package/dist/multishot/index.js +595 -548
  155. package/dist/multishot/index.js.map +1 -1
  156. package/dist/off-policy-DvgzvtIx.js +220 -0
  157. package/dist/off-policy-DvgzvtIx.js.map +1 -0
  158. package/dist/off-policy-mskQw8Mb.d.ts +153 -0
  159. package/dist/off-policy-mskQw8Mb.d.ts.map +1 -0
  160. package/dist/openapi.json +1 -1
  161. package/dist/opencode-sqlite-BGrHeDu3.js +318 -0
  162. package/dist/opencode-sqlite-BGrHeDu3.js.map +1 -0
  163. package/dist/outcome-store-BYHIuO0e.d.ts +65 -0
  164. package/dist/outcome-store-BYHIuO0e.d.ts.map +1 -0
  165. package/dist/outcome-store-ChBKlTd_.js +75 -0
  166. package/dist/outcome-store-ChBKlTd_.js.map +1 -0
  167. package/dist/paired-arms-D9D0wXj2.js +260 -0
  168. package/dist/paired-arms-D9D0wXj2.js.map +1 -0
  169. package/dist/pipelines/index.d.ts +95 -532
  170. package/dist/pipelines/index.d.ts.map +1 -0
  171. package/dist/pipelines/index.js +497 -478
  172. package/dist/pipelines/index.js.map +1 -1
  173. package/dist/pre-registration-DakwTRXk.js +96 -0
  174. package/dist/pre-registration-DakwTRXk.js.map +1 -0
  175. package/dist/propose-review-control-LhIWGzHl.js +1458 -0
  176. package/dist/propose-review-control-LhIWGzHl.js.map +1 -0
  177. package/dist/query-CJ_DX8vl.d.ts +28 -0
  178. package/dist/query-CJ_DX8vl.d.ts.map +1 -0
  179. package/dist/query-Di7eEQ79.js +83 -0
  180. package/dist/query-Di7eEQ79.js.map +1 -0
  181. package/dist/raw-provider-sink-BQd7mzyT.js +201 -0
  182. package/dist/raw-provider-sink-BQd7mzyT.js.map +1 -0
  183. package/dist/raw-provider-sink-BU29Sh8h.d.ts +134 -0
  184. package/dist/raw-provider-sink-BU29Sh8h.d.ts.map +1 -0
  185. package/dist/redact-7Aq1ukl-.js +107 -0
  186. package/dist/redact-7Aq1ukl-.js.map +1 -0
  187. package/dist/release-report-Cz9NKH39.js +603 -0
  188. package/dist/release-report-Cz9NKH39.js.map +1 -0
  189. package/dist/release-report-mvB2G4_J.d.ts +244 -0
  190. package/dist/release-report-mvB2G4_J.d.ts.map +1 -0
  191. package/dist/replay-GnyotH0J.js +1741 -0
  192. package/dist/replay-GnyotH0J.js.map +1 -0
  193. package/dist/replay-OoidtG1E.d.ts +749 -0
  194. package/dist/replay-OoidtG1E.d.ts.map +1 -0
  195. package/dist/reporting.d.ts +6 -1298
  196. package/dist/reporting.js +6 -50
  197. package/dist/researcher-CwTdwXG1.d.ts +314 -0
  198. package/dist/researcher-CwTdwXG1.d.ts.map +1 -0
  199. package/dist/reward-hacking-eAnOsynk.d.ts +224 -0
  200. package/dist/reward-hacking-eAnOsynk.d.ts.map +1 -0
  201. package/dist/reward-hacking-qipEpKvY.js +596 -0
  202. package/dist/reward-hacking-qipEpKvY.js.map +1 -0
  203. package/dist/reward-nw2xZGZG.js +137 -0
  204. package/dist/reward-nw2xZGZG.js.map +1 -0
  205. package/dist/rl.d.ts +916 -3596
  206. package/dist/rl.d.ts.map +1 -0
  207. package/dist/rl.js +2362 -1751
  208. package/dist/rl.js.map +1 -1
  209. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  210. package/dist/rollout/index.d.ts +3 -1048
  211. package/dist/rollout/index.js +8 -110
  212. package/dist/rollout-BOYjemfR.js +624 -0
  213. package/dist/rollout-BOYjemfR.js.map +1 -0
  214. package/dist/rubric-predictive-validity-B3xmbmS1.js +141 -0
  215. package/dist/rubric-predictive-validity-B3xmbmS1.js.map +1 -0
  216. package/dist/rubric-predictive-validity-Ku_clp_1.d.ts +74 -0
  217. package/dist/rubric-predictive-validity-Ku_clp_1.d.ts.map +1 -0
  218. package/dist/run-evidence-ClRX_8A9.d.ts +225 -0
  219. package/dist/run-evidence-ClRX_8A9.d.ts.map +1 -0
  220. package/dist/run-record-BuoE80Dq.js +467 -0
  221. package/dist/run-record-BuoE80Dq.js.map +1 -0
  222. package/dist/run-record-CnZu_gjl.d.ts +357 -0
  223. package/dist/run-record-CnZu_gjl.d.ts.map +1 -0
  224. package/dist/run-score-iEEAWiBY.js +41 -0
  225. package/dist/run-score-iEEAWiBY.js.map +1 -0
  226. package/dist/runtime-trajectory-1gyaTOoC.js +93 -0
  227. package/dist/runtime-trajectory-1gyaTOoC.js.map +1 -0
  228. package/dist/runtime-trajectory-BvSZcCHD.d.ts +50 -0
  229. package/dist/runtime-trajectory-BvSZcCHD.d.ts.map +1 -0
  230. package/dist/schema-BtVldJ3T.d.ts +206 -0
  231. package/dist/schema-BtVldJ3T.d.ts.map +1 -0
  232. package/dist/schema-C6DW4ZHR.js +821 -0
  233. package/dist/schema-C6DW4ZHR.js.map +1 -0
  234. package/dist/schema-CRhEY1SO.js +69 -0
  235. package/dist/schema-CRhEY1SO.js.map +1 -0
  236. package/dist/schema-Cef2cFmb.d.ts +408 -0
  237. package/dist/schema-Cef2cFmb.d.ts.map +1 -0
  238. package/dist/semantic-concept-judge-B6cWNJ2K.js +725 -0
  239. package/dist/semantic-concept-judge-B6cWNJ2K.js.map +1 -0
  240. package/dist/sequential-Br0mAPHA.js +148 -0
  241. package/dist/sequential-Br0mAPHA.js.map +1 -0
  242. package/dist/sequential-CYwq6Ff_.d.ts +141 -0
  243. package/dist/sequential-CYwq6Ff_.d.ts.map +1 -0
  244. package/dist/series-convergence-CjO2QdRW.js +43 -0
  245. package/dist/series-convergence-CjO2QdRW.js.map +1 -0
  246. package/dist/series-convergence-ofsqPWhs.d.ts +35 -0
  247. package/dist/series-convergence-ofsqPWhs.d.ts.map +1 -0
  248. package/dist/server-m5D9cvnG.js +1040 -0
  249. package/dist/server-m5D9cvnG.js.map +1 -0
  250. package/dist/skill-usage-C_pXm7lP.d.ts +534 -0
  251. package/dist/skill-usage-C_pXm7lP.d.ts.map +1 -0
  252. package/dist/skillopt-optimization-method-B7wX7XkF.d.ts +1739 -0
  253. package/dist/skillopt-optimization-method-B7wX7XkF.d.ts.map +1 -0
  254. package/dist/skillopt-optimization-method-D4ODwFVV.js +7712 -0
  255. package/dist/skillopt-optimization-method-D4ODwFVV.js.map +1 -0
  256. package/dist/statistics-Cmj6nynr.d.ts +514 -0
  257. package/dist/statistics-Cmj6nynr.d.ts.map +1 -0
  258. package/dist/statistics-CnnxdpOg.js +1437 -0
  259. package/dist/statistics-CnnxdpOg.js.map +1 -0
  260. package/dist/store-CT9YIIve.d.ts +117 -0
  261. package/dist/store-CT9YIIve.d.ts.map +1 -0
  262. package/dist/store-CxJry_cs.d.ts +229 -0
  263. package/dist/store-CxJry_cs.d.ts.map +1 -0
  264. package/dist/storyboard/index.d.ts +84 -203
  265. package/dist/storyboard/index.d.ts.map +1 -0
  266. package/dist/storyboard/index.js +609 -542
  267. package/dist/storyboard/index.js.map +1 -1
  268. package/dist/summary-report-BNs5nmXI.js +862 -0
  269. package/dist/summary-report-BNs5nmXI.js.map +1 -0
  270. package/dist/summary-report-Cj9gdw4i.d.ts +407 -0
  271. package/dist/summary-report-Cj9gdw4i.d.ts.map +1 -0
  272. package/dist/supervisor-run/index.d.ts +2 -849
  273. package/dist/supervisor-run/index.js +2 -64
  274. package/dist/supervisor-run-_lnTLM3z.js +1679 -0
  275. package/dist/supervisor-run-_lnTLM3z.js.map +1 -0
  276. package/dist/task-failure-attributes-CQZlB3et.js +311 -0
  277. package/dist/task-failure-attributes-CQZlB3et.js.map +1 -0
  278. package/dist/test-graded-scenario-BsqWLmPt.js +318 -0
  279. package/dist/test-graded-scenario-BsqWLmPt.js.map +1 -0
  280. package/dist/test-graded-scenario-D1TaI2va.d.ts +141 -0
  281. package/dist/test-graded-scenario-D1TaI2va.d.ts.map +1 -0
  282. package/dist/tools-BmuN627J.js +1085 -0
  283. package/dist/tools-BmuN627J.js.map +1 -0
  284. package/dist/trace-attributes.d.ts +2 -52
  285. package/dist/trace-attributes.js +131 -61
  286. package/dist/trace-attributes.js.map +1 -1
  287. package/dist/traces.d.ts +12 -2365
  288. package/dist/traces.js +12 -251
  289. package/dist/trajectory-D_7rLrvE.js +56 -0
  290. package/dist/trajectory-D_7rLrvE.js.map +1 -0
  291. package/dist/types-DGsxbAEd.d.ts +387 -0
  292. package/dist/types-DGsxbAEd.d.ts.map +1 -0
  293. package/dist/types-k9tZGKUg.d.ts +640 -0
  294. package/dist/types-k9tZGKUg.d.ts.map +1 -0
  295. package/dist/verdict-Dps8_okt.d.ts +37 -0
  296. package/dist/verdict-Dps8_okt.d.ts.map +1 -0
  297. package/dist/wire/index.d.ts +702 -1174
  298. package/dist/wire/index.d.ts.map +1 -0
  299. package/dist/wire/index.js +2 -81
  300. package/docs/feature-guide.md +1 -1
  301. package/docs/rollout.md +116 -2
  302. package/package.json +18 -10
  303. package/dist/benchmarks/index.js.map +0 -1
  304. package/dist/campaign/index.js.map +0 -1
  305. package/dist/chunk-2JX3CFMB.js +0 -695
  306. package/dist/chunk-2JX3CFMB.js.map +0 -1
  307. package/dist/chunk-2MKQIFS4.js +0 -183
  308. package/dist/chunk-2MKQIFS4.js.map +0 -1
  309. package/dist/chunk-3RF76KTD.js +0 -84
  310. package/dist/chunk-3RF76KTD.js.map +0 -1
  311. package/dist/chunk-5DTSBUL2.js +0 -159
  312. package/dist/chunk-5DTSBUL2.js.map +0 -1
  313. package/dist/chunk-7ZZMD7UK.js +0 -386
  314. package/dist/chunk-7ZZMD7UK.js.map +0 -1
  315. package/dist/chunk-BOD4O7OF.js +0 -40
  316. package/dist/chunk-BOD4O7OF.js.map +0 -1
  317. package/dist/chunk-BYT7ELPS.js +0 -1553
  318. package/dist/chunk-BYT7ELPS.js.map +0 -1
  319. package/dist/chunk-DJKY2TSY.js +0 -2428
  320. package/dist/chunk-DJKY2TSY.js.map +0 -1
  321. package/dist/chunk-DPUHNQLN.js +0 -232
  322. package/dist/chunk-DPUHNQLN.js.map +0 -1
  323. package/dist/chunk-DRYIUNWY.js +0 -622
  324. package/dist/chunk-DRYIUNWY.js.map +0 -1
  325. package/dist/chunk-EJGRPCO3.js +0 -617
  326. package/dist/chunk-EJGRPCO3.js.map +0 -1
  327. package/dist/chunk-EOSZT7PL.js +0 -2001
  328. package/dist/chunk-EOSZT7PL.js.map +0 -1
  329. package/dist/chunk-EZJEIH2R.js +0 -1559
  330. package/dist/chunk-EZJEIH2R.js.map +0 -1
  331. package/dist/chunk-GGE4NNQT.js +0 -65
  332. package/dist/chunk-GGE4NNQT.js.map +0 -1
  333. package/dist/chunk-HHWE3POT.js +0 -94
  334. package/dist/chunk-HHWE3POT.js.map +0 -1
  335. package/dist/chunk-IHQDPH7D.js +0 -171
  336. package/dist/chunk-IHQDPH7D.js.map +0 -1
  337. package/dist/chunk-JHCHEVET.js +0 -274
  338. package/dist/chunk-JHCHEVET.js.map +0 -1
  339. package/dist/chunk-K4DBDHLK.js +0 -158
  340. package/dist/chunk-K4DBDHLK.js.map +0 -1
  341. package/dist/chunk-K6N6XJJX.js +0 -306
  342. package/dist/chunk-K6N6XJJX.js.map +0 -1
  343. package/dist/chunk-MA6HLL3S.js +0 -65
  344. package/dist/chunk-MA6HLL3S.js.map +0 -1
  345. package/dist/chunk-MAZ26DC7.js +0 -99
  346. package/dist/chunk-MAZ26DC7.js.map +0 -1
  347. package/dist/chunk-MHELPNRP.js +0 -1212
  348. package/dist/chunk-MHELPNRP.js.map +0 -1
  349. package/dist/chunk-NACAGYSY.js +0 -1040
  350. package/dist/chunk-NACAGYSY.js.map +0 -1
  351. package/dist/chunk-NKAGIDE2.js +0 -7633
  352. package/dist/chunk-NKAGIDE2.js.map +0 -1
  353. package/dist/chunk-NPCTHQIO.js +0 -91
  354. package/dist/chunk-NPCTHQIO.js.map +0 -1
  355. package/dist/chunk-NYLOYM6N.js +0 -332
  356. package/dist/chunk-NYLOYM6N.js.map +0 -1
  357. package/dist/chunk-ONWEPEDO.js +0 -57
  358. package/dist/chunk-ONWEPEDO.js.map +0 -1
  359. package/dist/chunk-P5W7RQKK.js +0 -576
  360. package/dist/chunk-P5W7RQKK.js.map +0 -1
  361. package/dist/chunk-P6FYH6K4.js +0 -1161
  362. package/dist/chunk-P6FYH6K4.js.map +0 -1
  363. package/dist/chunk-PBE2LOSS.js +0 -669
  364. package/dist/chunk-PBE2LOSS.js.map +0 -1
  365. package/dist/chunk-PC4UYEBM.js +0 -166
  366. package/dist/chunk-PC4UYEBM.js.map +0 -1
  367. package/dist/chunk-PXE2VKMX.js +0 -140
  368. package/dist/chunk-PXE2VKMX.js.map +0 -1
  369. package/dist/chunk-PZ5AY32C.js +0 -10
  370. package/dist/chunk-PZ5AY32C.js.map +0 -1
  371. package/dist/chunk-RZTMDUO7.js +0 -49
  372. package/dist/chunk-RZTMDUO7.js.map +0 -1
  373. package/dist/chunk-S5YLIBFX.js +0 -136
  374. package/dist/chunk-S5YLIBFX.js.map +0 -1
  375. package/dist/chunk-SZLVEKMJ.js +0 -1446
  376. package/dist/chunk-SZLVEKMJ.js.map +0 -1
  377. package/dist/chunk-T4SQEITX.js +0 -95
  378. package/dist/chunk-T4SQEITX.js.map +0 -1
  379. package/dist/chunk-TBL77AUT.js +0 -355
  380. package/dist/chunk-TBL77AUT.js.map +0 -1
  381. package/dist/chunk-TSN7JT6D.js +0 -1646
  382. package/dist/chunk-TSN7JT6D.js.map +0 -1
  383. package/dist/chunk-TT4KNT67.js +0 -124
  384. package/dist/chunk-TT4KNT67.js.map +0 -1
  385. package/dist/chunk-UB2LOJ6Q.js +0 -4461
  386. package/dist/chunk-UB2LOJ6Q.js.map +0 -1
  387. package/dist/chunk-UWZZKKU7.js +0 -237
  388. package/dist/chunk-UWZZKKU7.js.map +0 -1
  389. package/dist/chunk-VBQ3CRKH.js +0 -291
  390. package/dist/chunk-VBQ3CRKH.js.map +0 -1
  391. package/dist/chunk-VGRCHJON.js +0 -163
  392. package/dist/chunk-VGRCHJON.js.map +0 -1
  393. package/dist/chunk-VI2UW6B6.js +0 -162
  394. package/dist/chunk-VI2UW6B6.js.map +0 -1
  395. package/dist/chunk-VLOATJQ2.js +0 -908
  396. package/dist/chunk-VLOATJQ2.js.map +0 -1
  397. package/dist/chunk-VQMK5FMP.js +0 -247
  398. package/dist/chunk-VQMK5FMP.js.map +0 -1
  399. package/dist/chunk-VZSRQ272.js +0 -149
  400. package/dist/chunk-VZSRQ272.js.map +0 -1
  401. package/dist/chunk-WGXIEX7P.js +0 -116
  402. package/dist/chunk-WGXIEX7P.js.map +0 -1
  403. package/dist/chunk-WS3NZZQQ.js +0 -929
  404. package/dist/chunk-WS3NZZQQ.js.map +0 -1
  405. package/dist/chunk-XDWDC2MP.js +0 -695
  406. package/dist/chunk-XDWDC2MP.js.map +0 -1
  407. package/dist/chunk-XPRT64IE.js +0 -766
  408. package/dist/chunk-XPRT64IE.js.map +0 -1
  409. package/dist/chunk-YJBNWCAA.js +0 -1056
  410. package/dist/chunk-YJBNWCAA.js.map +0 -1
  411. package/dist/chunk-ZET2UAYW.js +0 -89
  412. package/dist/chunk-ZET2UAYW.js.map +0 -1
  413. package/dist/chunk-ZUUWPZCV.js +0 -752
  414. package/dist/chunk-ZUUWPZCV.js.map +0 -1
  415. package/dist/control.js.map +0 -1
  416. package/dist/hosted/index.js.map +0 -1
  417. package/dist/matrix/index.js.map +0 -1
  418. package/dist/reporting.js.map +0 -1
  419. package/dist/rollout/index.js.map +0 -1
  420. package/dist/run-campaign-ISHFZ7FJ.js +0 -17
  421. package/dist/run-campaign-ISHFZ7FJ.js.map +0 -1
  422. package/dist/supervisor-run/index.js.map +0 -1
  423. package/dist/traces.js.map +0 -1
  424. package/dist/wire/index.js.map +0 -1
@@ -1,216 +1,232 @@
1
- import "../chunk-PZ5AY32C.js";
2
-
3
- // src/authenticity/index.ts
4
- var DEFAULT_MOCK = /\bmock|\bfake|\bdummy|\bstub\b|simulat|hardcoded|placeholder|TODO|not\s+implemented|FIXME/i;
1
+ //#region src/authenticity/index.ts
2
+ const DEFAULT_MOCK = /\bmock|\bfake|\bdummy|\bstub\b|simulat|hardcoded|placeholder|TODO|not\s+implemented|FIXME/i;
5
3
  function basename(p) {
6
- return p.split("/").pop() ?? p;
4
+ return p.split("/").pop() ?? p;
7
5
  }
8
6
  function escapeRe(s) {
9
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
10
8
  }
9
+ /** Top-level symbols a source file declares (contract/library/class/etc.), used to
10
+ * test whether other files reference the artifact. Language-agnostic keyword set. */
11
11
  function declaredNames(content) {
12
- const names = /* @__PURE__ */ new Set();
13
- const re = /\b(?:contract|library|interface|abstract\s+contract|class|enum|struct|module|package)\s+([A-Za-z_]\w*)/g;
14
- let m = re.exec(content);
15
- while (m) {
16
- const name = m[1];
17
- if (name && name.length >= 4) names.add(name);
18
- m = re.exec(content);
19
- }
20
- return [...names];
12
+ const names = /* @__PURE__ */ new Set();
13
+ const re = /\b(?:contract|library|interface|abstract\s+contract|class|enum|struct|module|package)\s+([A-Za-z_]\w*)/g;
14
+ let m = re.exec(content);
15
+ while (m) {
16
+ const name = m[1];
17
+ if (name && name.length >= 4) names.add(name);
18
+ m = re.exec(content);
19
+ }
20
+ return [...names];
21
21
  }
22
+ /** Is a required artifact referenced/imported by any non-artifact file? Catches the
23
+ * "decorative / dead-code artifact" facade (a real-looking deliverable nothing in
24
+ * the running system imports, deploys, or calls). Purely structural — no domain. */
22
25
  function isArtifactReferenced(required, others) {
23
- if (!required.length || !others.length) return false;
24
- return required.some((rf) => {
25
- const stem = rf.path.replace(/\.[^.]+$/, "");
26
- const base = basename(rf.path);
27
- const names = declaredNames(rf.content ?? "");
28
- return others.some((o) => {
29
- const c = o.content ?? "";
30
- if (!c) return false;
31
- if (c.includes(base) || c.includes(stem)) return true;
32
- return names.some((n) => new RegExp(`\\b${escapeRe(n)}\\b`).test(c));
33
- });
34
- });
26
+ if (!required.length || !others.length) return false;
27
+ return required.some((rf) => {
28
+ const stem = rf.path.replace(/\.[^.]+$/, "");
29
+ const base = basename(rf.path);
30
+ const names = declaredNames(rf.content ?? "");
31
+ return others.some((o) => {
32
+ const c = o.content ?? "";
33
+ if (!c) return false;
34
+ if (c.includes(base) || c.includes(stem)) return true;
35
+ return names.some((n) => new RegExp(`\\b${escapeRe(n)}\\b`).test(c));
36
+ });
37
+ });
35
38
  }
39
+ /** Deterministic authenticity scan of produced files. Pure — same files in,
40
+ * same score out. No LLM, no IO. */
36
41
  function scoreAuthenticity(files, signals) {
37
- const w = {
38
- artifact: signals.weights?.artifact ?? 40,
39
- impl: signals.weights?.impl ?? 25,
40
- infra: signals.weights?.infra ?? 20,
41
- wiring: signals.weights?.wiring ?? 15
42
- };
43
- const mockRe = signals.mock ?? DEFAULT_MOCK;
44
- const required = signals.requiredArtifact ? files.filter(
45
- (f) => signals.requiredArtifact.test(f.path) && !(signals.vendored?.test(f.path) ?? false)
46
- ) : [];
47
- const others = signals.requiredArtifact ? files.filter((f) => !required.includes(f)) : files;
48
- const requiredText = required.map((f) => f.content ?? "").join("\n");
49
- const otherText = others.map((f) => f.content ?? "").join("\n");
50
- const allText = files.map((f) => f.content ?? "").join("\n");
51
- const requiredArtifactPresent = signals.requiredArtifact ? required.length > 0 : true;
52
- const usesRealImpl = signals.realImpl.test(signals.requiredArtifact ? requiredText : allText);
53
- const realInfra = signals.realInfra.test(allText);
54
- const wired = signals.wiring ? signals.wiring.test(otherText || allText) : false;
55
- const artifactReferenced = isArtifactReferenced(required, others);
56
- const artifactWired = wired || artifactReferenced;
57
- const fakeShim = files.some(
58
- (f) => signals.fakeShim.test(basename(f.path)) || signals.fakeShim.test(f.content ?? "")
59
- );
60
- const mockHits = (allText.match(
61
- new RegExp(mockRe.source, mockRe.flags.includes("g") ? mockRe.flags : `${mockRe.flags}g`)
62
- ) ?? []).length;
63
- const loc = Math.max(1, allText.split("\n").length);
64
- const mockDensity = Math.min(100, Math.round(mockHits / loc * 1e3));
65
- const decorativeArtifact = requiredArtifactPresent && usesRealImpl && !artifactWired;
66
- let realness = 0;
67
- if (requiredArtifactPresent) realness += w.artifact;
68
- if (usesRealImpl) realness += w.impl;
69
- if (realInfra) realness += w.infra;
70
- if (wired) realness += w.wiring;
71
- if (fakeShim) realness -= 25;
72
- realness -= Math.min(20, mockDensity);
73
- realness = Math.max(0, Math.min(100, realness));
74
- const flags = [];
75
- if (signals.requiredArtifact && !requiredArtifactPresent) {
76
- flags.push(
77
- `NO_REQUIRED_ARTIFACT: task needs ${signals.label} artifact (${signals.requiredArtifact}); none produced`
78
- );
79
- }
80
- if (requiredArtifactPresent && signals.requiredArtifact && !usesRealImpl) {
81
- flags.push("ARTIFACT_NO_REAL_IMPL: required artifact exists but lacks the real implementation");
82
- }
83
- if (fakeShim) flags.push("FAKE_SHIM: ships a client-side stand-in simulating the real infra");
84
- if (!realInfra && !requiredArtifactPresent)
85
- flags.push("NO_REAL_INFRA: no real infra calls \u2014 cosmetic at best");
86
- if (mockDensity >= 8)
87
- flags.push(`HIGH_MOCK_DENSITY: ${mockDensity} mock/stub markers per 1000 LOC`);
88
- if (signals.wiring && requiredArtifactPresent && !wired)
89
- flags.push("NOT_WIRED: artifact exists but is never used by the client");
90
- if (decorativeArtifact)
91
- flags.push(
92
- "DEAD_ARTIFACT: required artifact is not referenced/imported anywhere \u2014 decorative or dead code"
93
- );
94
- return {
95
- realness,
96
- requiredArtifactPresent,
97
- requiredArtifactCount: required.length,
98
- usesRealImpl,
99
- realInfra,
100
- wired,
101
- artifactReferenced,
102
- artifactWired,
103
- fakeShim,
104
- mockDensity,
105
- flags
106
- };
42
+ const w = {
43
+ artifact: signals.weights?.artifact ?? 40,
44
+ impl: signals.weights?.impl ?? 25,
45
+ infra: signals.weights?.infra ?? 20,
46
+ wiring: signals.weights?.wiring ?? 15
47
+ };
48
+ const mockRe = signals.mock ?? DEFAULT_MOCK;
49
+ const required = signals.requiredArtifact ? files.filter((f) => signals.requiredArtifact.test(f.path) && !(signals.vendored?.test(f.path) ?? false)) : [];
50
+ const others = signals.requiredArtifact ? files.filter((f) => !required.includes(f)) : files;
51
+ const requiredText = required.map((f) => f.content ?? "").join("\n");
52
+ const otherText = others.map((f) => f.content ?? "").join("\n");
53
+ const allText = files.map((f) => f.content ?? "").join("\n");
54
+ const requiredArtifactPresent = signals.requiredArtifact ? required.length > 0 : true;
55
+ const usesRealImpl = signals.realImpl.test(signals.requiredArtifact ? requiredText : allText);
56
+ const realInfra = signals.realInfra.test(allText);
57
+ const wired = signals.wiring ? signals.wiring.test(otherText || allText) : false;
58
+ const artifactReferenced = isArtifactReferenced(required, others);
59
+ const artifactWired = wired || artifactReferenced;
60
+ const fakeShim = files.some((f) => signals.fakeShim.test(basename(f.path)) || signals.fakeShim.test(f.content ?? ""));
61
+ const mockHits = (allText.match(new RegExp(mockRe.source, mockRe.flags.includes("g") ? mockRe.flags : `${mockRe.flags}g`)) ?? []).length;
62
+ const loc = Math.max(1, allText.split("\n").length);
63
+ const mockDensity = Math.min(100, Math.round(mockHits / loc * 1e3));
64
+ const decorativeArtifact = requiredArtifactPresent && usesRealImpl && !artifactWired;
65
+ let realness = 0;
66
+ if (requiredArtifactPresent) realness += w.artifact;
67
+ if (usesRealImpl) realness += w.impl;
68
+ if (realInfra) realness += w.infra;
69
+ if (wired) realness += w.wiring;
70
+ if (fakeShim) realness -= 25;
71
+ realness -= Math.min(20, mockDensity);
72
+ realness = Math.max(0, Math.min(100, realness));
73
+ const flags = [];
74
+ if (signals.requiredArtifact && !requiredArtifactPresent) flags.push(`NO_REQUIRED_ARTIFACT: task needs ${signals.label} artifact (${signals.requiredArtifact}); none produced`);
75
+ if (requiredArtifactPresent && signals.requiredArtifact && !usesRealImpl) flags.push("ARTIFACT_NO_REAL_IMPL: required artifact exists but lacks the real implementation");
76
+ if (fakeShim) flags.push("FAKE_SHIM: ships a client-side stand-in simulating the real infra");
77
+ if (!realInfra && !requiredArtifactPresent) flags.push("NO_REAL_INFRA: no real infra calls — cosmetic at best");
78
+ if (mockDensity >= 8) flags.push(`HIGH_MOCK_DENSITY: ${mockDensity} mock/stub markers per 1000 LOC`);
79
+ if (signals.wiring && requiredArtifactPresent && !wired) flags.push("NOT_WIRED: artifact exists but is never used by the client");
80
+ if (decorativeArtifact) flags.push("DEAD_ARTIFACT: required artifact is not referenced/imported anywhere — decorative or dead code");
81
+ return {
82
+ realness,
83
+ requiredArtifactPresent,
84
+ requiredArtifactCount: required.length,
85
+ usesRealImpl,
86
+ realInfra,
87
+ wired,
88
+ artifactReferenced,
89
+ artifactWired,
90
+ fakeShim,
91
+ mockDensity,
92
+ flags
93
+ };
107
94
  }
95
+ /** Anti-Goodhart gate: a required-artifact-missing or faked submission is
96
+ * capped and cannot rank high regardless of buildability. */
108
97
  function gateRealness(r, opts = {}) {
109
- const floor = opts.floor ?? 30;
110
- if ((opts.requireArtifact ?? true) && !r.requiredArtifactPresent) {
111
- return { gated: true, reason: "required artifact missing" };
112
- }
113
- if (r.fakeShim && !r.usesRealImpl) {
114
- return { gated: true, reason: "fake shim with no real implementation" };
115
- }
116
- if (opts.requireArtifactWired && r.requiredArtifactPresent && r.usesRealImpl && !r.artifactWired) {
117
- return { gated: true, reason: "required artifact present but never wired into the system" };
118
- }
119
- if (r.realness < floor)
120
- return { gated: true, reason: `realness ${r.realness} below floor ${floor}` };
121
- return { gated: false };
98
+ const floor = opts.floor ?? 30;
99
+ if ((opts.requireArtifact ?? true) && !r.requiredArtifactPresent) return {
100
+ gated: true,
101
+ reason: "required artifact missing"
102
+ };
103
+ if (r.fakeShim && !r.usesRealImpl) return {
104
+ gated: true,
105
+ reason: "fake shim with no real implementation"
106
+ };
107
+ if (opts.requireArtifactWired && r.requiredArtifactPresent && r.usesRealImpl && !r.artifactWired) return {
108
+ gated: true,
109
+ reason: "required artifact present but never wired into the system"
110
+ };
111
+ if (r.realness < floor) return {
112
+ gated: true,
113
+ reason: `realness ${r.realness} below floor ${floor}`
114
+ };
115
+ return { gated: false };
122
116
  }
123
117
  function fileDigest(files, opts = {}) {
124
- const maxFiles = opts.maxFiles ?? 14;
125
- const perFile = opts.perFile ?? 1200;
126
- const ordered = opts.prioritize ? [...files].sort(
127
- (a, b) => Number(opts.prioritize.test(b.path)) - Number(opts.prioritize.test(a.path))
128
- ) : files;
129
- return ordered.slice(0, maxFiles).map((f) => `// ${f.path}
130
- ${(f.content ?? "").slice(0, perFile)}`).join("\n\n");
118
+ const maxFiles = opts.maxFiles ?? 14;
119
+ const perFile = opts.perFile ?? 1200;
120
+ return (opts.prioritize ? [...files].sort((a, b) => Number(opts.prioritize.test(b.path)) - Number(opts.prioritize.test(a.path))) : files).slice(0, maxFiles).map((f) => `// ${f.path}\n${(f.content ?? "").slice(0, perFile)}`).join("\n\n");
131
121
  }
132
122
  function clampPct(v) {
133
- const n = typeof v === "number" ? v : Number(v);
134
- return Number.isFinite(n) ? Math.max(0, Math.min(100, Math.round(n))) : 0;
123
+ const n = typeof v === "number" ? v : Number(v);
124
+ return Number.isFinite(n) ? Math.max(0, Math.min(100, Math.round(n))) : 0;
135
125
  }
126
+ /**
127
+ * LLM nuance scoring — judges the "looks real but is hollow" axis structure
128
+ * misses. Inject a `complete` caller; returns mocked/fake/unique % + a verdict.
129
+ * Fail-soft: a bad/unparseable response yields a worst-case (fully-fake) read,
130
+ * never a false pass.
131
+ */
136
132
  async function scoreAuthenticityNuance(files, complete, opts = {}) {
137
- const system = 'You audit whether an agent BUILT THE REAL THING or faked it. Be skeptical: a pretty UI, cosmetic labels, simulated/in-memory stand-ins for real infra, and cargo-culted imports do NOT count as real. Respond with ONLY JSON: {"mockedPct":0-100,"fakePct":0-100,"uniquePct":0-100,"verdict":"one sentence"}. mockedPct = how much is mocked/stubbed; fakePct = how hollow/facade it is; uniquePct = how distinctive vs boilerplate.';
138
- const user = (opts.intent ? `Intended deliverable: ${opts.intent}
139
-
140
- ` : "") + `Produced files:
141
- ${fileDigest(files, { prioritize: opts.prioritize })}`;
142
- try {
143
- const raw = await complete(system, user);
144
- const m = raw.match(/\{[\s\S]*\}/);
145
- if (!m)
146
- return { mockedPct: 100, fakePct: 100, uniquePct: 0, verdict: "unparseable judge response" };
147
- const j = JSON.parse(m[0]);
148
- return {
149
- mockedPct: clampPct(j.mockedPct),
150
- fakePct: clampPct(j.fakePct),
151
- uniquePct: clampPct(j.uniquePct),
152
- verdict: typeof j.verdict === "string" ? j.verdict : ""
153
- };
154
- } catch (err) {
155
- return {
156
- mockedPct: 100,
157
- fakePct: 100,
158
- uniquePct: 0,
159
- verdict: `judge error: ${err instanceof Error ? err.message : String(err)}`
160
- };
161
- }
133
+ const system = "You audit whether an agent BUILT THE REAL THING or faked it. Be skeptical: a pretty UI, cosmetic labels, simulated/in-memory stand-ins for real infra, and cargo-culted imports do NOT count as real. Respond with ONLY JSON: {\"mockedPct\":0-100,\"fakePct\":0-100,\"uniquePct\":0-100,\"verdict\":\"one sentence\"}. mockedPct = how much is mocked/stubbed; fakePct = how hollow/facade it is; uniquePct = how distinctive vs boilerplate.";
134
+ const user = (opts.intent ? `Intended deliverable: ${opts.intent}\n\n` : "") + `Produced files:\n${fileDigest(files, { prioritize: opts.prioritize })}`;
135
+ try {
136
+ const m = (await complete(system, user)).match(/\{[\s\S]*\}/);
137
+ if (!m) return {
138
+ mockedPct: 100,
139
+ fakePct: 100,
140
+ uniquePct: 0,
141
+ verdict: "unparseable judge response"
142
+ };
143
+ const j = JSON.parse(m[0]);
144
+ return {
145
+ mockedPct: clampPct(j.mockedPct),
146
+ fakePct: clampPct(j.fakePct),
147
+ uniquePct: clampPct(j.uniquePct),
148
+ verdict: typeof j.verdict === "string" ? j.verdict : ""
149
+ };
150
+ } catch (err) {
151
+ return {
152
+ mockedPct: 100,
153
+ fakePct: 100,
154
+ uniquePct: 0,
155
+ verdict: `judge error: ${err instanceof Error ? err.message : String(err)}`
156
+ };
157
+ }
162
158
  }
159
+ /**
160
+ * Ask an LLM to rate realness DIRECTLY on a 0-100 scale — the axis that matched
161
+ * human blind-labels in validation (F1 0.80→0.88 on the gray band; a fakePct/
162
+ * hollowness proxy over-penalized "real core + stubbed periphery" partials, and a
163
+ * weak judge model over-flagged — use a strong one). Domain-agnostic skeleton; the
164
+ * consumer supplies `intent` (what the deliverable should be) and `rubric` (domain
165
+ * specifics of real-vs-fake). Fail-closed: a bad response reads as fully fake.
166
+ */
163
167
  async function judgeRealnessLlm(files, complete, opts = {}) {
164
- const system = "You are a skeptical auditor. Rate how REAL an agent's build is vs the intended deliverable, 0-100. A genuine implementation of the HARD part on the intended infrastructure is SUBSTANTIALLY REAL (>=50) even if peripheral layers are stubbed; a pure simulator / facade / branded-type stand-in / no-op-stubbed dependency with no real implementation is FAKE (<=25). Judge the core on its merits and note the runtime. " + (opts.rubric ? `Domain rubric: ${opts.rubric} ` : "") + 'Respond with ONLY JSON: {"isReal":0-100,"why":"one sentence"}.';
165
- const user = (opts.intent ? `Intended deliverable: ${opts.intent}
166
-
167
- ` : "") + `Produced files:
168
- ${fileDigest(files, { prioritize: opts.prioritize })}`;
169
- try {
170
- const raw = await complete(system, user);
171
- const m = raw.match(/\{[\s\S]*\}/);
172
- if (!m) return { isReal: 0, rationale: "unparseable judge response" };
173
- const j = JSON.parse(m[0]);
174
- return {
175
- isReal: clampPct(j.isReal),
176
- rationale: typeof j.why === "string" ? j.why : ""
177
- };
178
- } catch (err) {
179
- return {
180
- isReal: 0,
181
- rationale: `judge error: ${err instanceof Error ? err.message : String(err)}`
182
- };
183
- }
168
+ const system = "You are a skeptical auditor. Rate how REAL an agent's build is vs the intended deliverable, 0-100. A genuine implementation of the HARD part on the intended infrastructure is SUBSTANTIALLY REAL (>=50) even if peripheral layers are stubbed; a pure simulator / facade / branded-type stand-in / no-op-stubbed dependency with no real implementation is FAKE (<=25). Judge the core on its merits and note the runtime. " + (opts.rubric ? `Domain rubric: ${opts.rubric} ` : "") + "Respond with ONLY JSON: {\"isReal\":0-100,\"why\":\"one sentence\"}.";
169
+ const user = (opts.intent ? `Intended deliverable: ${opts.intent}\n\n` : "") + `Produced files:\n${fileDigest(files, { prioritize: opts.prioritize })}`;
170
+ try {
171
+ const m = (await complete(system, user)).match(/\{[\s\S]*\}/);
172
+ if (!m) return {
173
+ isReal: 0,
174
+ rationale: "unparseable judge response"
175
+ };
176
+ const j = JSON.parse(m[0]);
177
+ return {
178
+ isReal: clampPct(j.isReal),
179
+ rationale: typeof j.why === "string" ? j.why : ""
180
+ };
181
+ } catch (err) {
182
+ return {
183
+ isReal: 0,
184
+ rationale: `judge error: ${err instanceof Error ? err.message : String(err)}`
185
+ };
186
+ }
184
187
  }
188
+ /**
189
+ * Score realness using the cheapest sufficient signal: trust the deterministic
190
+ * scorer on the CLEAN extremes (obvious fakes / obviously-real-and-wired), and only
191
+ * spend an LLM call on the GRAY band — cells that look real structurally but carry
192
+ * fakeness markers (a fake shim, an unwired/dead artifact, high mock density) or land
193
+ * mid-range. This caps LLM cost at the fraction of cells static analysis can't
194
+ * resolve, which matters at multi-vertical / multi-partner scale.
195
+ *
196
+ * Domain-agnostic: the gray-band TRIGGER is structural; the LLM judges via the
197
+ * consumer-supplied `intent`. Fail-closed (a bad LLM response reads as fully fake).
198
+ */
185
199
  async function scoreRealnessBlended(files, signals, complete, opts = {}) {
186
- const det = scoreAuthenticity(files, signals);
187
- const [lo, hi] = opts.grayBand ?? [30, 70];
188
- const mockGray = opts.mockGrayThreshold ?? 8;
189
- const conflict = det.requiredArtifactPresent && det.usesRealImpl && (det.fakeShim || !det.wired || det.mockDensity >= mockGray);
190
- const midRange = det.realness >= lo && det.realness <= hi;
191
- let band;
192
- if (conflict || midRange) band = "gray";
193
- else if (det.realness < lo) band = "clean-fake";
194
- else band = "clean-real";
195
- if (band !== "gray") {
196
- return { ...det, blendedRealness: det.realness, band, consultedLlm: false };
197
- }
198
- const judgment = await judgeRealnessLlm(files, complete, {
199
- intent: opts.intent,
200
- rubric: opts.rubric,
201
- prioritize: signals.requiredArtifact
202
- });
203
- const blendedRealness = Math.max(
204
- 0,
205
- Math.min(100, Math.round(0.25 * det.realness + 0.75 * judgment.isReal))
206
- );
207
- return { ...det, blendedRealness, band, consultedLlm: true, judgment };
200
+ const det = scoreAuthenticity(files, signals);
201
+ const [lo, hi] = opts.grayBand ?? [30, 70];
202
+ const mockGray = opts.mockGrayThreshold ?? 8;
203
+ const conflict = det.requiredArtifactPresent && det.usesRealImpl && (det.fakeShim || !det.wired || det.mockDensity >= mockGray);
204
+ const midRange = det.realness >= lo && det.realness <= hi;
205
+ let band;
206
+ if (conflict || midRange) band = "gray";
207
+ else if (det.realness < lo) band = "clean-fake";
208
+ else band = "clean-real";
209
+ if (band !== "gray") return {
210
+ ...det,
211
+ blendedRealness: det.realness,
212
+ band,
213
+ consultedLlm: false
214
+ };
215
+ const judgment = await judgeRealnessLlm(files, complete, {
216
+ intent: opts.intent,
217
+ rubric: opts.rubric,
218
+ prioritize: signals.requiredArtifact
219
+ });
220
+ const blendedRealness = Math.max(0, Math.min(100, Math.round(.25 * det.realness + .75 * judgment.isReal)));
221
+ return {
222
+ ...det,
223
+ blendedRealness,
224
+ band,
225
+ consultedLlm: true,
226
+ judgment
227
+ };
208
228
  }
209
- export {
210
- gateRealness,
211
- judgeRealnessLlm,
212
- scoreAuthenticity,
213
- scoreAuthenticityNuance,
214
- scoreRealnessBlended
215
- };
229
+ //#endregion
230
+ export { gateRealness, judgeRealnessLlm, scoreAuthenticity, scoreAuthenticityNuance, scoreRealnessBlended };
231
+
216
232
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/authenticity/index.ts"],"sourcesContent":["/**\n * Authenticity — \"is this real, or convincing BS?\"\n *\n * Pass/build-style scoring rewards anything that compiles and renders, so an\n * agent can ship a polished frontend with a FAKE in-browser engine and zero of\n * the required on-chain/contract work, and outscore a half-finished real\n * implementation. This module scores what buildability does not: did the agent\n * actually build the intended thing on the intended infra, or fake it.\n *\n * Two layers:\n * - DETERMINISTIC `scoreAuthenticity` — calibrated by construction (no LLM,\n * trustworthy today). Structural signals over the produced files, driven by\n * a domain `AuthenticitySignals` config: required artifact present, real\n * implementation of the hard part, real infra calls, wiring, fake-shim\n * detection, mock/stub density.\n * - LLM NUANCE `scoreAuthenticityNuance` — mocked% / fake% / unique% for the\n * \"looks real but is hollow\" cases structure can't see.\n *\n * `gateRealness` is the anti-Goodhart gate: a submission missing the required\n * artifact (or faking it) is capped and cannot rank high regardless of how\n * buildable it is. Domain-agnostic; ships a Solidity/Fhenix preset.\n *\n * Input is the produced-state currency: `{ path, content }[]` — exactly what\n * `extractProducedState(...).artifacts` yields, so any consumer can feed a run's\n * produced state straight in.\n */\n\nexport interface ProducedFile {\n path: string\n content?: string\n}\n\nexport interface AuthenticitySignals {\n /** Human label for the domain (e.g. 'fhenix-fhe'). */\n label: string\n /** A file the task REQUIRES (e.g. /\\.sol$/ for an on-chain task). */\n requiredArtifact?: RegExp\n /** Vendored/3rd-party paths to exclude from required-artifact detection. */\n vendored?: RegExp\n /** Real implementation of the hard part, inside the required artifact\n * (e.g. Fhenix encrypted types + FHE.* ops). Matched against content, so it\n * fails on comments/strings only if the regex is written tightly. */\n realImpl: RegExp\n /** Real use of the intended client infra (e.g. cofhejs.encrypt() calls). */\n realInfra: RegExp\n /** Evidence the artifact is actually wired/used (e.g. contract writes). */\n wiring?: RegExp\n /** A fake shim standing in for the real thing — matched on file path AND body. */\n fakeShim: RegExp\n /** Mock/stub/TODO markers. Defaults to a generic set. */\n mock?: RegExp\n /** Score weights (default 40/25/20/15). */\n weights?: { artifact?: number; impl?: number; infra?: number; wiring?: number }\n}\n\nexport interface AuthenticityResult {\n /** Deterministic realness, 0 (BS) … 100 (real on real infra). */\n realness: number\n requiredArtifactPresent: boolean\n requiredArtifactCount: number\n usesRealImpl: boolean\n realInfra: boolean\n wired: boolean\n /** The required artifact is actually referenced/imported by other (non-artifact)\n * files — i.e. wired into the rest of the system, not dead code. Domain-agnostic:\n * a deliverable nothing else uses is suspect in any vertical. */\n artifactReferenced: boolean\n /** Convenience: the artifact is connected to the running system, via either the\n * domain wiring signal OR a structural reference. */\n artifactWired: boolean\n fakeShim: boolean\n /** mock/stub markers per 1000 LOC, capped at 100. */\n mockDensity: number\n /** Human-readable BS flags — what's missing or faked. */\n flags: string[]\n}\n\nconst DEFAULT_MOCK =\n /\\bmock|\\bfake|\\bdummy|\\bstub\\b|simulat|hardcoded|placeholder|TODO|not\\s+implemented|FIXME/i\n\nfunction basename(p: string): string {\n return p.split('/').pop() ?? p\n}\n\nfunction escapeRe(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/** Top-level symbols a source file declares (contract/library/class/etc.), used to\n * test whether other files reference the artifact. Language-agnostic keyword set. */\nfunction declaredNames(content: string): string[] {\n const names = new Set<string>()\n const re =\n /\\b(?:contract|library|interface|abstract\\s+contract|class|enum|struct|module|package)\\s+([A-Za-z_]\\w*)/g\n let m = re.exec(content)\n while (m) {\n const name = m[1]\n if (name && name.length >= 4) names.add(name)\n m = re.exec(content)\n }\n return [...names]\n}\n\n/** Is a required artifact referenced/imported by any non-artifact file? Catches the\n * \"decorative / dead-code artifact\" facade (a real-looking deliverable nothing in\n * the running system imports, deploys, or calls). Purely structural — no domain. */\nfunction isArtifactReferenced(\n required: readonly ProducedFile[],\n others: readonly ProducedFile[],\n): boolean {\n if (!required.length || !others.length) return false\n return required.some((rf) => {\n const stem = rf.path.replace(/\\.[^.]+$/, '') // import-path stem (no ext)\n const base = basename(rf.path) // filename incl. ext\n const names = declaredNames(rf.content ?? '')\n return others.some((o) => {\n const c = o.content ?? ''\n if (!c) return false\n if (c.includes(base) || c.includes(stem)) return true // import of the path\n return names.some((n) => new RegExp(`\\\\b${escapeRe(n)}\\\\b`).test(c)) // symbol reference\n })\n })\n}\n\n/** Deterministic authenticity scan of produced files. Pure — same files in,\n * same score out. No LLM, no IO. */\nexport function scoreAuthenticity(\n files: readonly ProducedFile[],\n signals: AuthenticitySignals,\n): AuthenticityResult {\n const w = {\n artifact: signals.weights?.artifact ?? 40,\n impl: signals.weights?.impl ?? 25,\n infra: signals.weights?.infra ?? 20,\n wiring: signals.weights?.wiring ?? 15,\n }\n const mockRe = signals.mock ?? DEFAULT_MOCK\n\n const required = signals.requiredArtifact\n ? files.filter(\n (f) => signals.requiredArtifact!.test(f.path) && !(signals.vendored?.test(f.path) ?? false),\n )\n : []\n const others = signals.requiredArtifact ? files.filter((f) => !required.includes(f)) : files\n\n const requiredText = required.map((f) => f.content ?? '').join('\\n')\n const otherText = others.map((f) => f.content ?? '').join('\\n')\n const allText = files.map((f) => f.content ?? '').join('\\n')\n\n const requiredArtifactPresent = signals.requiredArtifact ? required.length > 0 : true\n // Real impl looked for in the required artifact when there is one, else anywhere.\n const usesRealImpl = signals.realImpl.test(signals.requiredArtifact ? requiredText : allText)\n const realInfra = signals.realInfra.test(allText)\n const wired = signals.wiring ? signals.wiring.test(otherText || allText) : false\n // Structural: is the required artifact actually used by the rest of the system?\n const artifactReferenced = isArtifactReferenced(required, others)\n const artifactWired = wired || artifactReferenced\n const fakeShim = files.some(\n (f) => signals.fakeShim.test(basename(f.path)) || signals.fakeShim.test(f.content ?? ''),\n )\n\n const mockHits = (\n allText.match(\n new RegExp(mockRe.source, mockRe.flags.includes('g') ? mockRe.flags : `${mockRe.flags}g`),\n ) ?? []\n ).length\n const loc = Math.max(1, allText.split('\\n').length)\n const mockDensity = Math.min(100, Math.round((mockHits / loc) * 1000))\n\n // A real-looking artifact that nothing in the system imports/deploys/calls is\n // decorative (dead code) — a common facade. We REPORT this (flag + signal) but do\n // NOT auto-penalize the score: structural reference detection is noisy (an ABI or\n // placeholder-address file makes a dead contract look \"referenced\", while a strong\n // contract-only submission looks \"dead\"), so a score penalty manufactures false\n // negatives on legitimately-partial work. Gate on it only via opts.requireArtifactWired,\n // and let the LLM-nuance layer resolve the ambiguous middle band.\n const decorativeArtifact = requiredArtifactPresent && usesRealImpl && !artifactWired\n\n let realness = 0\n if (requiredArtifactPresent) realness += w.artifact\n if (usesRealImpl) realness += w.impl\n if (realInfra) realness += w.infra\n if (wired) realness += w.wiring\n if (fakeShim) realness -= 25\n realness -= Math.min(20, mockDensity)\n realness = Math.max(0, Math.min(100, realness))\n\n const flags: string[] = []\n if (signals.requiredArtifact && !requiredArtifactPresent) {\n flags.push(\n `NO_REQUIRED_ARTIFACT: task needs ${signals.label} artifact (${signals.requiredArtifact}); none produced`,\n )\n }\n if (requiredArtifactPresent && signals.requiredArtifact && !usesRealImpl) {\n flags.push('ARTIFACT_NO_REAL_IMPL: required artifact exists but lacks the real implementation')\n }\n if (fakeShim) flags.push('FAKE_SHIM: ships a client-side stand-in simulating the real infra')\n if (!realInfra && !requiredArtifactPresent)\n flags.push('NO_REAL_INFRA: no real infra calls — cosmetic at best')\n if (mockDensity >= 8)\n flags.push(`HIGH_MOCK_DENSITY: ${mockDensity} mock/stub markers per 1000 LOC`)\n if (signals.wiring && requiredArtifactPresent && !wired)\n flags.push('NOT_WIRED: artifact exists but is never used by the client')\n if (decorativeArtifact)\n flags.push(\n 'DEAD_ARTIFACT: required artifact is not referenced/imported anywhere — decorative or dead code',\n )\n\n return {\n realness,\n requiredArtifactPresent,\n requiredArtifactCount: required.length,\n usesRealImpl,\n realInfra,\n wired,\n artifactReferenced,\n artifactWired,\n fakeShim,\n mockDensity,\n flags,\n }\n}\n\nexport interface RealnessGate {\n gated: boolean\n reason?: string\n}\n\n/** Anti-Goodhart gate: a required-artifact-missing or faked submission is\n * capped and cannot rank high regardless of buildability. */\nexport function gateRealness(\n r: AuthenticityResult,\n opts: { floor?: number; requireArtifact?: boolean; requireArtifactWired?: boolean } = {},\n): RealnessGate {\n const floor = opts.floor ?? 30\n if ((opts.requireArtifact ?? true) && !r.requiredArtifactPresent) {\n return { gated: true, reason: 'required artifact missing' }\n }\n if (r.fakeShim && !r.usesRealImpl) {\n return { gated: true, reason: 'fake shim with no real implementation' }\n }\n // Opt-in (default off): a vertical where the deliverable MUST be wired into the\n // running system can reject a decorative/dead artifact. Off by default because a\n // contract-only (incomplete-but-real) submission is legitimately partial, not fake.\n if (\n opts.requireArtifactWired &&\n r.requiredArtifactPresent &&\n r.usesRealImpl &&\n !r.artifactWired\n ) {\n return { gated: true, reason: 'required artifact present but never wired into the system' }\n }\n if (r.realness < floor)\n return { gated: true, reason: `realness ${r.realness} below floor ${floor}` }\n return { gated: false }\n}\n\n// ── LLM nuance layer ─────────────────────────────────────────────────────────\n\nexport interface AuthenticityNuance {\n /** 0 (nothing mocked) … 100 (entirely mocked). */\n mockedPct: number\n /** 0 (genuine) … 100 (a hollow facade / cargo-culted). */\n fakePct: number\n /** 0 (boilerplate/template clone) … 100 (distinctive real work). */\n uniquePct: number\n verdict: string\n}\n\n/** A minimal completion fn — inject your model caller (router/tcloud). Keeps\n * this module free of any specific LLM client. */\nexport type CompleteFn = (system: string, user: string) => Promise<string>\n\nfunction fileDigest(\n files: readonly ProducedFile[],\n opts: { maxFiles?: number; perFile?: number; prioritize?: RegExp } = {},\n): string {\n const maxFiles = opts.maxFiles ?? 14\n const perFile = opts.perFile ?? 1200\n // Lead with the required-artifact files (e.g. .sol) so a truncated digest\n // never hides the very thing the judge must assess.\n const ordered = opts.prioritize\n ? [...files].sort(\n (a, b) => Number(opts.prioritize!.test(b.path)) - Number(opts.prioritize!.test(a.path)),\n )\n : files\n return ordered\n .slice(0, maxFiles)\n .map((f) => `// ${f.path}\\n${(f.content ?? '').slice(0, perFile)}`)\n .join('\\n\\n')\n}\n\nfunction clampPct(v: unknown): number {\n const n = typeof v === 'number' ? v : Number(v)\n return Number.isFinite(n) ? Math.max(0, Math.min(100, Math.round(n))) : 0\n}\n\n/**\n * LLM nuance scoring — judges the \"looks real but is hollow\" axis structure\n * misses. Inject a `complete` caller; returns mocked/fake/unique % + a verdict.\n * Fail-soft: a bad/unparseable response yields a worst-case (fully-fake) read,\n * never a false pass.\n */\nexport async function scoreAuthenticityNuance(\n files: readonly ProducedFile[],\n complete: CompleteFn,\n opts: { intent?: string; prioritize?: RegExp } = {},\n): Promise<AuthenticityNuance> {\n const system =\n 'You audit whether an agent BUILT THE REAL THING or faked it. Be skeptical: ' +\n 'a pretty UI, cosmetic labels, simulated/in-memory stand-ins for real infra, ' +\n 'and cargo-culted imports do NOT count as real. Respond with ONLY JSON: ' +\n '{\"mockedPct\":0-100,\"fakePct\":0-100,\"uniquePct\":0-100,\"verdict\":\"one sentence\"}. ' +\n 'mockedPct = how much is mocked/stubbed; fakePct = how hollow/facade it is; ' +\n 'uniquePct = how distinctive vs boilerplate.'\n const user =\n (opts.intent ? `Intended deliverable: ${opts.intent}\\n\\n` : '') +\n `Produced files:\\n${fileDigest(files, { prioritize: opts.prioritize })}`\n try {\n const raw = await complete(system, user)\n const m = raw.match(/\\{[\\s\\S]*\\}/)\n if (!m)\n return { mockedPct: 100, fakePct: 100, uniquePct: 0, verdict: 'unparseable judge response' }\n const j = JSON.parse(m[0]) as Record<string, unknown>\n return {\n mockedPct: clampPct(j.mockedPct),\n fakePct: clampPct(j.fakePct),\n uniquePct: clampPct(j.uniquePct),\n verdict: typeof j.verdict === 'string' ? j.verdict : '',\n }\n } catch (err) {\n return {\n mockedPct: 100,\n fakePct: 100,\n uniquePct: 0,\n verdict: `judge error: ${err instanceof Error ? err.message : String(err)}`,\n }\n }\n}\n\n// ── Realness-direct LLM judge ─────────────────────────────────────────────────\n\nexport interface RealnessJudgment {\n /** 0 (facade/simulator) … 100 (real implementation on the intended infra). */\n isReal: number\n rationale: string\n}\n\n/**\n * Ask an LLM to rate realness DIRECTLY on a 0-100 scale — the axis that matched\n * human blind-labels in validation (F1 0.80→0.88 on the gray band; a fakePct/\n * hollowness proxy over-penalized \"real core + stubbed periphery\" partials, and a\n * weak judge model over-flagged — use a strong one). Domain-agnostic skeleton; the\n * consumer supplies `intent` (what the deliverable should be) and `rubric` (domain\n * specifics of real-vs-fake). Fail-closed: a bad response reads as fully fake.\n */\nexport async function judgeRealnessLlm(\n files: readonly ProducedFile[],\n complete: CompleteFn,\n opts: { intent?: string; rubric?: string; prioritize?: RegExp } = {},\n): Promise<RealnessJudgment> {\n const system =\n \"You are a skeptical auditor. Rate how REAL an agent's build is vs the intended \" +\n 'deliverable, 0-100. A genuine implementation of the HARD part on the intended ' +\n 'infrastructure is SUBSTANTIALLY REAL (>=50) even if peripheral layers are stubbed; ' +\n 'a pure simulator / facade / branded-type stand-in / no-op-stubbed dependency with ' +\n 'no real implementation is FAKE (<=25). Judge the core on its merits and note the ' +\n 'runtime. ' +\n (opts.rubric ? `Domain rubric: ${opts.rubric} ` : '') +\n 'Respond with ONLY JSON: {\"isReal\":0-100,\"why\":\"one sentence\"}.'\n const user =\n (opts.intent ? `Intended deliverable: ${opts.intent}\\n\\n` : '') +\n `Produced files:\\n${fileDigest(files, { prioritize: opts.prioritize })}`\n try {\n const raw = await complete(system, user)\n const m = raw.match(/\\{[\\s\\S]*\\}/)\n if (!m) return { isReal: 0, rationale: 'unparseable judge response' }\n const j = JSON.parse(m[0]) as Record<string, unknown>\n return {\n isReal: clampPct(j.isReal),\n rationale: typeof j.why === 'string' ? j.why : '',\n }\n } catch (err) {\n return {\n isReal: 0,\n rationale: `judge error: ${err instanceof Error ? err.message : String(err)}`,\n }\n }\n}\n\n// ── Blended pipeline: deterministic for the clean extremes, LLM for the gray band ─\n\nexport type RealnessBand = 'clean-real' | 'clean-fake' | 'gray'\n\nexport interface BlendedRealness extends AuthenticityResult {\n /** Final realness after (only-when-needed) LLM adjudication, 0…100. */\n blendedRealness: number\n band: RealnessBand\n /** True iff the LLM judge was actually consulted (gray band only). */\n consultedLlm: boolean\n /** Present iff the LLM was consulted. */\n judgment?: RealnessJudgment\n}\n\n/**\n * Score realness using the cheapest sufficient signal: trust the deterministic\n * scorer on the CLEAN extremes (obvious fakes / obviously-real-and-wired), and only\n * spend an LLM call on the GRAY band — cells that look real structurally but carry\n * fakeness markers (a fake shim, an unwired/dead artifact, high mock density) or land\n * mid-range. This caps LLM cost at the fraction of cells static analysis can't\n * resolve, which matters at multi-vertical / multi-partner scale.\n *\n * Domain-agnostic: the gray-band TRIGGER is structural; the LLM judges via the\n * consumer-supplied `intent`. Fail-closed (a bad LLM response reads as fully fake).\n */\nexport async function scoreRealnessBlended(\n files: readonly ProducedFile[],\n signals: AuthenticitySignals,\n complete: CompleteFn,\n opts: {\n intent?: string\n rubric?: string\n grayBand?: [number, number]\n mockGrayThreshold?: number\n } = {},\n): Promise<BlendedRealness> {\n const det = scoreAuthenticity(files, signals)\n const [lo, hi] = opts.grayBand ?? [30, 70]\n const mockGray = opts.mockGrayThreshold ?? 8\n\n // Structural conflict: a real artifact whose RUNTIME authenticity static analysis\n // can't settle — a fake shim is present, or it isn't wired to a real client (could\n // be a decorative contract next to a simulator, OR an incomplete-but-real build),\n // or mock density is high. Empirically (21 labeled cells) this routes 100% of the\n // deterministic errors to the LLM while leaving an error-free clean band.\n const conflict =\n det.requiredArtifactPresent &&\n det.usesRealImpl &&\n (det.fakeShim || !det.wired || det.mockDensity >= mockGray)\n const midRange = det.realness >= lo && det.realness <= hi\n\n let band: RealnessBand\n if (conflict || midRange) band = 'gray'\n else if (det.realness < lo) band = 'clean-fake'\n else band = 'clean-real'\n\n if (band !== 'gray') {\n return { ...det, blendedRealness: det.realness, band, consultedLlm: false }\n }\n\n // In the gray band the LLM read dominates (that's why we paid for it), with the\n // deterministic score as a light anchor. Weights 0.25/0.75 validated against blind\n // human labels (F1 0.88 vs 0.80 deterministic-only).\n const judgment = await judgeRealnessLlm(files, complete, {\n intent: opts.intent,\n rubric: opts.rubric,\n prioritize: signals.requiredArtifact,\n })\n const blendedRealness = Math.max(\n 0,\n Math.min(100, Math.round(0.25 * det.realness + 0.75 * judgment.isReal)),\n )\n return { ...det, blendedRealness, band, consultedLlm: true, judgment }\n}\n\n// Domain `AuthenticitySignals` (e.g. a Solidity/Fhenix preset) live in the\n// CONSUMER, not the substrate — this module stays domain-agnostic.\n"],"mappings":";;;AA6EA,IAAM,eACJ;AAEF,SAAS,SAAS,GAAmB;AACnC,SAAO,EAAE,MAAM,GAAG,EAAE,IAAI,KAAK;AAC/B;AAEA,SAAS,SAAS,GAAmB;AACnC,SAAO,EAAE,QAAQ,uBAAuB,MAAM;AAChD;AAIA,SAAS,cAAc,SAA2B;AAChD,QAAM,QAAQ,oBAAI,IAAY;AAC9B,QAAM,KACJ;AACF,MAAI,IAAI,GAAG,KAAK,OAAO;AACvB,SAAO,GAAG;AACR,UAAM,OAAO,EAAE,CAAC;AAChB,QAAI,QAAQ,KAAK,UAAU,EAAG,OAAM,IAAI,IAAI;AAC5C,QAAI,GAAG,KAAK,OAAO;AAAA,EACrB;AACA,SAAO,CAAC,GAAG,KAAK;AAClB;AAKA,SAAS,qBACP,UACA,QACS;AACT,MAAI,CAAC,SAAS,UAAU,CAAC,OAAO,OAAQ,QAAO;AAC/C,SAAO,SAAS,KAAK,CAAC,OAAO;AAC3B,UAAM,OAAO,GAAG,KAAK,QAAQ,YAAY,EAAE;AAC3C,UAAM,OAAO,SAAS,GAAG,IAAI;AAC7B,UAAM,QAAQ,cAAc,GAAG,WAAW,EAAE;AAC5C,WAAO,OAAO,KAAK,CAAC,MAAM;AACxB,YAAM,IAAI,EAAE,WAAW;AACvB,UAAI,CAAC,EAAG,QAAO;AACf,UAAI,EAAE,SAAS,IAAI,KAAK,EAAE,SAAS,IAAI,EAAG,QAAO;AACjD,aAAO,MAAM,KAAK,CAAC,MAAM,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAAA,IACrE,CAA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\n * Authenticity — \"is this real, or convincing BS?\"\n *\n * Pass/build-style scoring rewards anything that compiles and renders, so an\n * agent can ship a polished frontend with a FAKE in-browser engine and zero of\n * the required on-chain/contract work, and outscore a half-finished real\n * implementation. This module scores what buildability does not: did the agent\n * actually build the intended thing on the intended infra, or fake it.\n *\n * Two layers:\n * - DETERMINISTIC `scoreAuthenticity` — calibrated by construction (no LLM,\n * trustworthy today). Structural signals over the produced files, driven by\n * a domain `AuthenticitySignals` config: required artifact present, real\n * implementation of the hard part, real infra calls, wiring, fake-shim\n * detection, mock/stub density.\n * - LLM NUANCE `scoreAuthenticityNuance` — mocked% / fake% / unique% for the\n * \"looks real but is hollow\" cases structure can't see.\n *\n * `gateRealness` is the anti-Goodhart gate: a submission missing the required\n * artifact (or faking it) is capped and cannot rank high regardless of how\n * buildable it is. Domain-agnostic; ships a Solidity/Fhenix preset.\n *\n * Input is the produced-state currency: `{ path, content }[]` — exactly what\n * `extractProducedState(...).artifacts` yields, so any consumer can feed a run's\n * produced state straight in.\n */\n\nexport interface ProducedFile {\n path: string\n content?: string\n}\n\nexport interface AuthenticitySignals {\n /** Human label for the domain (e.g. 'fhenix-fhe'). */\n label: string\n /** A file the task REQUIRES (e.g. /\\.sol$/ for an on-chain task). */\n requiredArtifact?: RegExp\n /** Vendored/3rd-party paths to exclude from required-artifact detection. */\n vendored?: RegExp\n /** Real implementation of the hard part, inside the required artifact\n * (e.g. Fhenix encrypted types + FHE.* ops). Matched against content, so it\n * fails on comments/strings only if the regex is written tightly. */\n realImpl: RegExp\n /** Real use of the intended client infra (e.g. cofhejs.encrypt() calls). */\n realInfra: RegExp\n /** Evidence the artifact is actually wired/used (e.g. contract writes). */\n wiring?: RegExp\n /** A fake shim standing in for the real thing — matched on file path AND body. */\n fakeShim: RegExp\n /** Mock/stub/TODO markers. Defaults to a generic set. */\n mock?: RegExp\n /** Score weights (default 40/25/20/15). */\n weights?: { artifact?: number; impl?: number; infra?: number; wiring?: number }\n}\n\nexport interface AuthenticityResult {\n /** Deterministic realness, 0 (BS) … 100 (real on real infra). */\n realness: number\n requiredArtifactPresent: boolean\n requiredArtifactCount: number\n usesRealImpl: boolean\n realInfra: boolean\n wired: boolean\n /** The required artifact is actually referenced/imported by other (non-artifact)\n * files — i.e. wired into the rest of the system, not dead code. Domain-agnostic:\n * a deliverable nothing else uses is suspect in any vertical. */\n artifactReferenced: boolean\n /** Convenience: the artifact is connected to the running system, via either the\n * domain wiring signal OR a structural reference. */\n artifactWired: boolean\n fakeShim: boolean\n /** mock/stub markers per 1000 LOC, capped at 100. */\n mockDensity: number\n /** Human-readable BS flags — what's missing or faked. */\n flags: string[]\n}\n\nconst DEFAULT_MOCK =\n /\\bmock|\\bfake|\\bdummy|\\bstub\\b|simulat|hardcoded|placeholder|TODO|not\\s+implemented|FIXME/i\n\nfunction basename(p: string): string {\n return p.split('/').pop() ?? p\n}\n\nfunction escapeRe(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/** Top-level symbols a source file declares (contract/library/class/etc.), used to\n * test whether other files reference the artifact. Language-agnostic keyword set. */\nfunction declaredNames(content: string): string[] {\n const names = new Set<string>()\n const re =\n /\\b(?:contract|library|interface|abstract\\s+contract|class|enum|struct|module|package)\\s+([A-Za-z_]\\w*)/g\n let m = re.exec(content)\n while (m) {\n const name = m[1]\n if (name && name.length >= 4) names.add(name)\n m = re.exec(content)\n }\n return [...names]\n}\n\n/** Is a required artifact referenced/imported by any non-artifact file? Catches the\n * \"decorative / dead-code artifact\" facade (a real-looking deliverable nothing in\n * the running system imports, deploys, or calls). Purely structural — no domain. */\nfunction isArtifactReferenced(\n required: readonly ProducedFile[],\n others: readonly ProducedFile[],\n): boolean {\n if (!required.length || !others.length) return false\n return required.some((rf) => {\n const stem = rf.path.replace(/\\.[^.]+$/, '') // import-path stem (no ext)\n const base = basename(rf.path) // filename incl. ext\n const names = declaredNames(rf.content ?? '')\n return others.some((o) => {\n const c = o.content ?? ''\n if (!c) return false\n if (c.includes(base) || c.includes(stem)) return true // import of the path\n return names.some((n) => new RegExp(`\\\\b${escapeRe(n)}\\\\b`).test(c)) // symbol reference\n })\n })\n}\n\n/** Deterministic authenticity scan of produced files. Pure — same files in,\n * same score out. No LLM, no IO. */\nexport function scoreAuthenticity(\n files: readonly ProducedFile[],\n signals: AuthenticitySignals,\n): AuthenticityResult {\n const w = {\n artifact: signals.weights?.artifact ?? 40,\n impl: signals.weights?.impl ?? 25,\n infra: signals.weights?.infra ?? 20,\n wiring: signals.weights?.wiring ?? 15,\n }\n const mockRe = signals.mock ?? DEFAULT_MOCK\n\n const required = signals.requiredArtifact\n ? files.filter(\n (f) => signals.requiredArtifact!.test(f.path) && !(signals.vendored?.test(f.path) ?? false),\n )\n : []\n const others = signals.requiredArtifact ? files.filter((f) => !required.includes(f)) : files\n\n const requiredText = required.map((f) => f.content ?? '').join('\\n')\n const otherText = others.map((f) => f.content ?? '').join('\\n')\n const allText = files.map((f) => f.content ?? '').join('\\n')\n\n const requiredArtifactPresent = signals.requiredArtifact ? required.length > 0 : true\n // Real impl looked for in the required artifact when there is one, else anywhere.\n const usesRealImpl = signals.realImpl.test(signals.requiredArtifact ? requiredText : allText)\n const realInfra = signals.realInfra.test(allText)\n const wired = signals.wiring ? signals.wiring.test(otherText || allText) : false\n // Structural: is the required artifact actually used by the rest of the system?\n const artifactReferenced = isArtifactReferenced(required, others)\n const artifactWired = wired || artifactReferenced\n const fakeShim = files.some(\n (f) => signals.fakeShim.test(basename(f.path)) || signals.fakeShim.test(f.content ?? ''),\n )\n\n const mockHits = (\n allText.match(\n new RegExp(mockRe.source, mockRe.flags.includes('g') ? mockRe.flags : `${mockRe.flags}g`),\n ) ?? []\n ).length\n const loc = Math.max(1, allText.split('\\n').length)\n const mockDensity = Math.min(100, Math.round((mockHits / loc) * 1000))\n\n // A real-looking artifact that nothing in the system imports/deploys/calls is\n // decorative (dead code) — a common facade. We REPORT this (flag + signal) but do\n // NOT auto-penalize the score: structural reference detection is noisy (an ABI or\n // placeholder-address file makes a dead contract look \"referenced\", while a strong\n // contract-only submission looks \"dead\"), so a score penalty manufactures false\n // negatives on legitimately-partial work. Gate on it only via opts.requireArtifactWired,\n // and let the LLM-nuance layer resolve the ambiguous middle band.\n const decorativeArtifact = requiredArtifactPresent && usesRealImpl && !artifactWired\n\n let realness = 0\n if (requiredArtifactPresent) realness += w.artifact\n if (usesRealImpl) realness += w.impl\n if (realInfra) realness += w.infra\n if (wired) realness += w.wiring\n if (fakeShim) realness -= 25\n realness -= Math.min(20, mockDensity)\n realness = Math.max(0, Math.min(100, realness))\n\n const flags: string[] = []\n if (signals.requiredArtifact && !requiredArtifactPresent) {\n flags.push(\n `NO_REQUIRED_ARTIFACT: task needs ${signals.label} artifact (${signals.requiredArtifact}); none produced`,\n )\n }\n if (requiredArtifactPresent && signals.requiredArtifact && !usesRealImpl) {\n flags.push('ARTIFACT_NO_REAL_IMPL: required artifact exists but lacks the real implementation')\n }\n if (fakeShim) flags.push('FAKE_SHIM: ships a client-side stand-in simulating the real infra')\n if (!realInfra && !requiredArtifactPresent)\n flags.push('NO_REAL_INFRA: no real infra calls — cosmetic at best')\n if (mockDensity >= 8)\n flags.push(`HIGH_MOCK_DENSITY: ${mockDensity} mock/stub markers per 1000 LOC`)\n if (signals.wiring && requiredArtifactPresent && !wired)\n flags.push('NOT_WIRED: artifact exists but is never used by the client')\n if (decorativeArtifact)\n flags.push(\n 'DEAD_ARTIFACT: required artifact is not referenced/imported anywhere — decorative or dead code',\n )\n\n return {\n realness,\n requiredArtifactPresent,\n requiredArtifactCount: required.length,\n usesRealImpl,\n realInfra,\n wired,\n artifactReferenced,\n artifactWired,\n fakeShim,\n mockDensity,\n flags,\n }\n}\n\nexport interface RealnessGate {\n gated: boolean\n reason?: string\n}\n\n/** Anti-Goodhart gate: a required-artifact-missing or faked submission is\n * capped and cannot rank high regardless of buildability. */\nexport function gateRealness(\n r: AuthenticityResult,\n opts: { floor?: number; requireArtifact?: boolean; requireArtifactWired?: boolean } = {},\n): RealnessGate {\n const floor = opts.floor ?? 30\n if ((opts.requireArtifact ?? true) && !r.requiredArtifactPresent) {\n return { gated: true, reason: 'required artifact missing' }\n }\n if (r.fakeShim && !r.usesRealImpl) {\n return { gated: true, reason: 'fake shim with no real implementation' }\n }\n // Opt-in (default off): a vertical where the deliverable MUST be wired into the\n // running system can reject a decorative/dead artifact. Off by default because a\n // contract-only (incomplete-but-real) submission is legitimately partial, not fake.\n if (\n opts.requireArtifactWired &&\n r.requiredArtifactPresent &&\n r.usesRealImpl &&\n !r.artifactWired\n ) {\n return { gated: true, reason: 'required artifact present but never wired into the system' }\n }\n if (r.realness < floor)\n return { gated: true, reason: `realness ${r.realness} below floor ${floor}` }\n return { gated: false }\n}\n\n// ── LLM nuance layer ─────────────────────────────────────────────────────────\n\nexport interface AuthenticityNuance {\n /** 0 (nothing mocked) … 100 (entirely mocked). */\n mockedPct: number\n /** 0 (genuine) … 100 (a hollow facade / cargo-culted). */\n fakePct: number\n /** 0 (boilerplate/template clone) … 100 (distinctive real work). */\n uniquePct: number\n verdict: string\n}\n\n/** A minimal completion fn — inject your model caller (router/tcloud). Keeps\n * this module free of any specific LLM client. */\nexport type CompleteFn = (system: string, user: string) => Promise<string>\n\nfunction fileDigest(\n files: readonly ProducedFile[],\n opts: { maxFiles?: number; perFile?: number; prioritize?: RegExp } = {},\n): string {\n const maxFiles = opts.maxFiles ?? 14\n const perFile = opts.perFile ?? 1200\n // Lead with the required-artifact files (e.g. .sol) so a truncated digest\n // never hides the very thing the judge must assess.\n const ordered = opts.prioritize\n ? [...files].sort(\n (a, b) => Number(opts.prioritize!.test(b.path)) - Number(opts.prioritize!.test(a.path)),\n )\n : files\n return ordered\n .slice(0, maxFiles)\n .map((f) => `// ${f.path}\\n${(f.content ?? '').slice(0, perFile)}`)\n .join('\\n\\n')\n}\n\nfunction clampPct(v: unknown): number {\n const n = typeof v === 'number' ? v : Number(v)\n return Number.isFinite(n) ? Math.max(0, Math.min(100, Math.round(n))) : 0\n}\n\n/**\n * LLM nuance scoring — judges the \"looks real but is hollow\" axis structure\n * misses. Inject a `complete` caller; returns mocked/fake/unique % + a verdict.\n * Fail-soft: a bad/unparseable response yields a worst-case (fully-fake) read,\n * never a false pass.\n */\nexport async function scoreAuthenticityNuance(\n files: readonly ProducedFile[],\n complete: CompleteFn,\n opts: { intent?: string; prioritize?: RegExp } = {},\n): Promise<AuthenticityNuance> {\n const system =\n 'You audit whether an agent BUILT THE REAL THING or faked it. Be skeptical: ' +\n 'a pretty UI, cosmetic labels, simulated/in-memory stand-ins for real infra, ' +\n 'and cargo-culted imports do NOT count as real. Respond with ONLY JSON: ' +\n '{\"mockedPct\":0-100,\"fakePct\":0-100,\"uniquePct\":0-100,\"verdict\":\"one sentence\"}. ' +\n 'mockedPct = how much is mocked/stubbed; fakePct = how hollow/facade it is; ' +\n 'uniquePct = how distinctive vs boilerplate.'\n const user =\n (opts.intent ? `Intended deliverable: ${opts.intent}\\n\\n` : '') +\n `Produced files:\\n${fileDigest(files, { prioritize: opts.prioritize })}`\n try {\n const raw = await complete(system, user)\n const m = raw.match(/\\{[\\s\\S]*\\}/)\n if (!m)\n return { mockedPct: 100, fakePct: 100, uniquePct: 0, verdict: 'unparseable judge response' }\n const j = JSON.parse(m[0]) as Record<string, unknown>\n return {\n mockedPct: clampPct(j.mockedPct),\n fakePct: clampPct(j.fakePct),\n uniquePct: clampPct(j.uniquePct),\n verdict: typeof j.verdict === 'string' ? j.verdict : '',\n }\n } catch (err) {\n return {\n mockedPct: 100,\n fakePct: 100,\n uniquePct: 0,\n verdict: `judge error: ${err instanceof Error ? err.message : String(err)}`,\n }\n }\n}\n\n// ── Realness-direct LLM judge ─────────────────────────────────────────────────\n\nexport interface RealnessJudgment {\n /** 0 (facade/simulator) … 100 (real implementation on the intended infra). */\n isReal: number\n rationale: string\n}\n\n/**\n * Ask an LLM to rate realness DIRECTLY on a 0-100 scale — the axis that matched\n * human blind-labels in validation (F1 0.80→0.88 on the gray band; a fakePct/\n * hollowness proxy over-penalized \"real core + stubbed periphery\" partials, and a\n * weak judge model over-flagged — use a strong one). Domain-agnostic skeleton; the\n * consumer supplies `intent` (what the deliverable should be) and `rubric` (domain\n * specifics of real-vs-fake). Fail-closed: a bad response reads as fully fake.\n */\nexport async function judgeRealnessLlm(\n files: readonly ProducedFile[],\n complete: CompleteFn,\n opts: { intent?: string; rubric?: string; prioritize?: RegExp } = {},\n): Promise<RealnessJudgment> {\n const system =\n \"You are a skeptical auditor. Rate how REAL an agent's build is vs the intended \" +\n 'deliverable, 0-100. A genuine implementation of the HARD part on the intended ' +\n 'infrastructure is SUBSTANTIALLY REAL (>=50) even if peripheral layers are stubbed; ' +\n 'a pure simulator / facade / branded-type stand-in / no-op-stubbed dependency with ' +\n 'no real implementation is FAKE (<=25). Judge the core on its merits and note the ' +\n 'runtime. ' +\n (opts.rubric ? `Domain rubric: ${opts.rubric} ` : '') +\n 'Respond with ONLY JSON: {\"isReal\":0-100,\"why\":\"one sentence\"}.'\n const user =\n (opts.intent ? `Intended deliverable: ${opts.intent}\\n\\n` : '') +\n `Produced files:\\n${fileDigest(files, { prioritize: opts.prioritize })}`\n try {\n const raw = await complete(system, user)\n const m = raw.match(/\\{[\\s\\S]*\\}/)\n if (!m) return { isReal: 0, rationale: 'unparseable judge response' }\n const j = JSON.parse(m[0]) as Record<string, unknown>\n return {\n isReal: clampPct(j.isReal),\n rationale: typeof j.why === 'string' ? j.why : '',\n }\n } catch (err) {\n return {\n isReal: 0,\n rationale: `judge error: ${err instanceof Error ? err.message : String(err)}`,\n }\n }\n}\n\n// ── Blended pipeline: deterministic for the clean extremes, LLM for the gray band ─\n\nexport type RealnessBand = 'clean-real' | 'clean-fake' | 'gray'\n\nexport interface BlendedRealness extends AuthenticityResult {\n /** Final realness after (only-when-needed) LLM adjudication, 0…100. */\n blendedRealness: number\n band: RealnessBand\n /** True iff the LLM judge was actually consulted (gray band only). */\n consultedLlm: boolean\n /** Present iff the LLM was consulted. */\n judgment?: RealnessJudgment\n}\n\n/**\n * Score realness using the cheapest sufficient signal: trust the deterministic\n * scorer on the CLEAN extremes (obvious fakes / obviously-real-and-wired), and only\n * spend an LLM call on the GRAY band — cells that look real structurally but carry\n * fakeness markers (a fake shim, an unwired/dead artifact, high mock density) or land\n * mid-range. This caps LLM cost at the fraction of cells static analysis can't\n * resolve, which matters at multi-vertical / multi-partner scale.\n *\n * Domain-agnostic: the gray-band TRIGGER is structural; the LLM judges via the\n * consumer-supplied `intent`. Fail-closed (a bad LLM response reads as fully fake).\n */\nexport async function scoreRealnessBlended(\n files: readonly ProducedFile[],\n signals: AuthenticitySignals,\n complete: CompleteFn,\n opts: {\n intent?: string\n rubric?: string\n grayBand?: [number, number]\n mockGrayThreshold?: number\n } = {},\n): Promise<BlendedRealness> {\n const det = scoreAuthenticity(files, signals)\n const [lo, hi] = opts.grayBand ?? [30, 70]\n const mockGray = opts.mockGrayThreshold ?? 8\n\n // Structural conflict: a real artifact whose RUNTIME authenticity static analysis\n // can't settle — a fake shim is present, or it isn't wired to a real client (could\n // be a decorative contract next to a simulator, OR an incomplete-but-real build),\n // or mock density is high. Empirically (21 labeled cells) this routes 100% of the\n // deterministic errors to the LLM while leaving an error-free clean band.\n const conflict =\n det.requiredArtifactPresent &&\n det.usesRealImpl &&\n (det.fakeShim || !det.wired || det.mockDensity >= mockGray)\n const midRange = det.realness >= lo && det.realness <= hi\n\n let band: RealnessBand\n if (conflict || midRange) band = 'gray'\n else if (det.realness < lo) band = 'clean-fake'\n else band = 'clean-real'\n\n if (band !== 'gray') {\n return { ...det, blendedRealness: det.realness, band, consultedLlm: false }\n }\n\n // In the gray band the LLM read dominates (that's why we paid for it), with the\n // deterministic score as a light anchor. Weights 0.25/0.75 validated against blind\n // human labels (F1 0.88 vs 0.80 deterministic-only).\n const judgment = await judgeRealnessLlm(files, complete, {\n intent: opts.intent,\n rubric: opts.rubric,\n prioritize: signals.requiredArtifact,\n })\n const blendedRealness = Math.max(\n 0,\n Math.min(100, Math.round(0.25 * det.realness + 0.75 * judgment.isReal)),\n )\n return { ...det, blendedRealness, band, consultedLlm: true, judgment }\n}\n\n// Domain `AuthenticitySignals` (e.g. a Solidity/Fhenix preset) live in the\n// CONSUMER, not the substrate — this module stays domain-agnostic.\n"],"mappings":";AA6EA,MAAM,eACJ;AAEF,SAAS,SAAS,GAAmB;CACnC,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK;AAC/B;AAEA,SAAS,SAAS,GAAmB;CACnC,OAAO,EAAE,QAAQ,uBAAuB,MAAM;AAChD;;;AAIA,SAAS,cAAc,SAA2B;CAChD,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,KACJ;CACF,IAAI,IAAI,GAAG,KAAK,OAAO;CACvB,OAAO,GAAG;EACR,MAAM,OAAO,EAAE;EACf,IAAI,QAAQ,KAAK,UAAU,GAAG,MAAM,IAAI,IAAI;EAC5C,IAAI,GAAG,KAAK,OAAO;CACrB;CACA,OAAO,CAAC,GAAG,KAAK;AAClB;;;;AAKA,SAAS,qBACP,UACA,QACS;CACT,IAAI,CAAC,SAAS,UAAU,CAAC,OAAO,QAAQ,OAAO;CAC/C,OAAO,SAAS,MAAM,OAAO;EAC3B,MAAM,OAAO,GAAG,KAAK,QAAQ,YAAY,EAAE;EAC3C,MAAM,OAAO,SAAS,GAAG,IAAI;EAC7B,MAAM,QAAQ,cAAc,GAAG,WAAW,EAAE;EAC5C,OAAO,OAAO,MAAM,MAAM;GACxB,MAAM,IAAI,EAAE,WAAW;GACvB,IAAI,CAAC,GAAG,OAAO;GACf,IAAI,EAAE,SAAS,IAAI,KAAK,EAAE,SAAS,IAAI,GAAG,OAAO;GACjD,OAAO,MAAM,MAAM,MAAM,IAAI,OAAO,MAAM,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;EACrE,CAAC;CACH,CAAC;AACH;;;AAIA,SAAgB,kBACd,OACA,SACoB;CACpB,MAAM,I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