@rulemetric/cli 0.14.1 → 0.15.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 (246) hide show
  1. package/dist/base-command.js +1 -1
  2. package/dist/{chunk-HNYHZO2J.js → chunk-3H44B6PB.js} +1 -1
  3. package/dist/chunk-4DA6L7KL.js +1 -0
  4. package/dist/chunk-4GOXEEXZ.js +1 -0
  5. package/dist/{chunk-RMRVUI7B.js → chunk-5PMTNNA6.js} +1 -1
  6. package/dist/{chunk-EMLLGASZ.js → chunk-5TM7AOH2.js} +1 -1
  7. package/dist/{chunk-GKVHFXUQ.js → chunk-5Z6XXOJL.js} +1 -1
  8. package/dist/{chunk-Q36QSFSB.js → chunk-6QMIDH6X.js} +1 -1
  9. package/dist/{chunk-3FNTV2TW.js → chunk-6T6YFPBW.js} +1 -1
  10. package/dist/{chunk-FYZ6HHCV.js → chunk-74KE4VOX.js} +1 -1
  11. package/dist/chunk-77FH6UZP.js +111 -0
  12. package/dist/{chunk-XGMOVQ5G.js → chunk-7LFCZI64.js} +1 -1
  13. package/dist/{chunk-7H4HJ2RV.js → chunk-AFEJYDUK.js} +1 -1
  14. package/dist/{chunk-WWQWHC4K.js → chunk-BDQTVYYF.js} +1 -1
  15. package/dist/{chunk-EUHRTEVJ.js → chunk-CIKQXFQ2.js} +1 -1
  16. package/dist/chunk-CMDOLJ23.js +1 -0
  17. package/dist/chunk-CQD2R3BA.js +3 -0
  18. package/dist/{chunk-I6ZQOMZS.js → chunk-CVPAKEEZ.js} +1 -1
  19. package/dist/{chunk-QRIJ3AHP.js → chunk-CYCH2EQC.js} +1 -1
  20. package/dist/{chunk-AGEZAKCC.js → chunk-CZBO3A6B.js} +1 -1
  21. package/dist/{chunk-JTYVBR5H.js → chunk-DANMUHNW.js} +1 -1
  22. package/dist/{chunk-4FJYVYCU.js → chunk-DX6IPDED.js} +1 -1
  23. package/dist/chunk-DYET4EYU.js +1 -0
  24. package/dist/{chunk-MXHAXY66.js → chunk-EJY5GK6A.js} +1 -1
  25. package/dist/{chunk-H6FVXVGG.js → chunk-FADINV4H.js} +1 -1
  26. package/dist/{chunk-DVU5PHPM.js → chunk-FG343JM3.js} +1 -1
  27. package/dist/{chunk-RXZLBSDO.js → chunk-FXQS7AEZ.js} +1 -1
  28. package/dist/{chunk-LJRJ2RAC.js → chunk-FZMO7XSN.js} +3 -3
  29. package/dist/{chunk-XMTKP74H.js → chunk-GDLQNY4V.js} +1 -1
  30. package/dist/{chunk-76UKAFNM.js → chunk-GIXHG5FK.js} +1 -1
  31. package/dist/{chunk-XJ25HFIT.js → chunk-GLBWNB2N.js} +1 -1
  32. package/dist/chunk-HT6R6KR3.js +3 -0
  33. package/dist/{chunk-OP4U3XBZ.js → chunk-HXOQUYG3.js} +1 -1
  34. package/dist/{chunk-V55ROUNP.js → chunk-IFIWDL7G.js} +1 -1
  35. package/dist/{chunk-B5X6HCBK.js → chunk-ISYU5BMU.js} +1 -1
  36. package/dist/chunk-JNLDISBA.js +4 -0
  37. package/dist/{chunk-MMLRWCBW.js → chunk-JOXTWLLK.js} +1 -1
  38. package/dist/{chunk-QAMHZY2P.js → chunk-JSGXFD42.js} +1 -1
  39. package/dist/chunk-JU5ZNXPK.js +1 -0
  40. package/dist/{chunk-6ANODRDT.js → chunk-JUBXWTJA.js} +1 -1
  41. package/dist/{chunk-YK2IEHLB.js → chunk-KE5K3F7J.js} +1 -1
  42. package/dist/{chunk-VIFOLTZT.js → chunk-KEVDLLHT.js} +1 -1
  43. package/dist/{chunk-7MTYUTUN.js → chunk-KR36ZDGN.js} +1 -1
  44. package/dist/{chunk-OVS7ZDJ4.js → chunk-L562Y4RN.js} +1 -1
  45. package/dist/{chunk-43VKTVM3.js → chunk-LJE5J3EW.js} +1 -1
  46. package/dist/{chunk-XMA6SWOT.js → chunk-LLXC5SRC.js} +1 -1
  47. package/dist/chunk-MOJY6S5J.js +1 -0
  48. package/dist/{chunk-IQEZ3T5A.js → chunk-MYGVN6X4.js} +1 -1
  49. package/dist/chunk-N2PP2A7M.js +1 -0
  50. package/dist/{chunk-44TYRMIS.js → chunk-NWV66NMA.js} +1 -1
  51. package/dist/{chunk-KOYHJFB3.js → chunk-PDXHRF4E.js} +1 -1
  52. package/dist/{chunk-5Z3H5JHK.js → chunk-PJ4RIUI3.js} +1 -1
  53. package/dist/{chunk-NYNHX7OX.js → chunk-Q7IDLOSP.js} +1 -1
  54. package/dist/{chunk-IO46ICZY.js → chunk-QFTAU33Y.js} +1 -1
  55. package/dist/{chunk-5BT375C7.js → chunk-QNSIBPWG.js} +1 -1
  56. package/dist/{chunk-3IMRLHJJ.js → chunk-QPAOX7P2.js} +1 -1
  57. package/dist/{chunk-RG3R4EAB.js → chunk-QPVUGTDP.js} +1 -1
  58. package/dist/{chunk-BMT5WMEV.js → chunk-RDL4HXFL.js} +1 -1
  59. package/dist/{chunk-2UK4DZFW.js → chunk-RE7RAZQ5.js} +1 -1
  60. package/dist/{chunk-35YVHBLL.js → chunk-RYCVPQYK.js} +1 -1
  61. package/dist/{chunk-VU24IH5S.js → chunk-SFZPFNC6.js} +1 -1
  62. package/dist/{chunk-ZK3ACE4T.js → chunk-T7HZZ4DJ.js} +1 -1
  63. package/dist/{chunk-LB24UKHZ.js → chunk-TWPD3ICV.js} +1 -1
  64. package/dist/{chunk-BFQVAU6N.js → chunk-UVCVJKEN.js} +1 -1
  65. package/dist/chunk-V576KKH6.js +1 -0
  66. package/dist/{chunk-CT6GJQIR.js → chunk-VUNJGZPP.js} +1 -1
  67. package/dist/{chunk-AIYFT4P6.js → chunk-W6MMJRFZ.js} +1 -1
  68. package/dist/{chunk-FKTT7A4H.js → chunk-WL5ZWQAS.js} +1 -1
  69. package/dist/chunk-WQFR2LOY.js +15 -0
  70. package/dist/{chunk-MU7KKU3O.js → chunk-WUCACPGC.js} +1 -1
  71. package/dist/{chunk-42A4PUW7.js → chunk-X6CF5KTW.js} +4 -4
  72. package/dist/{chunk-N4YPDZJF.js → chunk-XCH4HPEZ.js} +1 -1
  73. package/dist/{chunk-VXL5H3VZ.js → chunk-XIOYV5A7.js} +1 -1
  74. package/dist/{chunk-W23OYQXI.js → chunk-XXPWPKTD.js} +1 -1
  75. package/dist/{chunk-SCQK52SL.js → chunk-YXMAGC53.js} +1 -1
  76. package/dist/commands/antigravity/backfill.js +1 -1
  77. package/dist/commands/auth/create-key.js +1 -1
  78. package/dist/commands/auth/login.js +1 -1
  79. package/dist/commands/auth/logout.js +1 -1
  80. package/dist/commands/auth/revoke-key.js +1 -1
  81. package/dist/commands/auth/signup.js +1 -1
  82. package/dist/commands/auth/status.js +1 -1
  83. package/dist/commands/capture/scope.js +1 -1
  84. package/dist/commands/catalog/index.js +1 -1
  85. package/dist/commands/catalog/recommend.js +1 -1
  86. package/dist/commands/crons/list.js +1 -1
  87. package/dist/commands/crons/run.js +1 -1
  88. package/dist/commands/dashboard.js +1 -1
  89. package/dist/commands/diagnostics.js +1 -1
  90. package/dist/commands/eval-targets/create.js +1 -1
  91. package/dist/commands/eval-targets/list.js +1 -1
  92. package/dist/commands/evals/agent.js +1 -1
  93. package/dist/commands/evals/auto-run.js +1 -1
  94. package/dist/commands/evals/benchmark.js +1 -1
  95. package/dist/commands/evals/compare.js +1 -1
  96. package/dist/commands/evals/create.js +1 -1
  97. package/dist/commands/evals/optimize-description.js +1 -1
  98. package/dist/commands/evals/optimize.js +1 -1
  99. package/dist/commands/evals/refine-cases.js +1 -1
  100. package/dist/commands/evals/run.js +1 -1
  101. package/dist/commands/evals/validate-judge.js +1 -1
  102. package/dist/commands/experiments/list.js +1 -1
  103. package/dist/commands/gateway/ensure.js +1 -1
  104. package/dist/commands/hooks/install.js +1 -1
  105. package/dist/commands/hooks/run.js +1 -1
  106. package/dist/commands/hooks/uninstall.js +1 -1
  107. package/dist/commands/instructions/create.js +1 -1
  108. package/dist/commands/instructions/dedupe.js +1 -1
  109. package/dist/commands/instructions/delete.js +1 -1
  110. package/dist/commands/instructions/fork.js +1 -1
  111. package/dist/commands/instructions/get.js +1 -1
  112. package/dist/commands/instructions/list.js +1 -1
  113. package/dist/commands/instructions/promote.js +1 -1
  114. package/dist/commands/instructions/pull.js +1 -1
  115. package/dist/commands/instructions/restore.js +1 -1
  116. package/dist/commands/instructions/retract.js +1 -1
  117. package/dist/commands/instructions/upstream.js +1 -1
  118. package/dist/commands/instructions/versions.js +1 -1
  119. package/dist/commands/launcher.js +1 -1
  120. package/dist/commands/local/down.js +1 -1
  121. package/dist/commands/local/up.js +1 -1
  122. package/dist/commands/org/current.js +1 -1
  123. package/dist/commands/org/list.js +1 -1
  124. package/dist/commands/org/switch.js +1 -1
  125. package/dist/commands/packs/add-instruction.js +1 -1
  126. package/dist/commands/packs/apply.js +1 -1
  127. package/dist/commands/packs/create.js +1 -1
  128. package/dist/commands/packs/fork.js +1 -1
  129. package/dist/commands/packs/get.js +1 -1
  130. package/dist/commands/packs/list.js +1 -1
  131. package/dist/commands/packs/remove-instruction.js +1 -1
  132. package/dist/commands/proxy/env.js +1 -1
  133. package/dist/commands/proxy/logs.js +1 -1
  134. package/dist/commands/proxy/restart.js +1 -1
  135. package/dist/commands/proxy/setup.js +1 -1
  136. package/dist/commands/proxy/start.js +1 -1
  137. package/dist/commands/proxy/status.js +1 -1
  138. package/dist/commands/proxy/stop.js +1 -1
  139. package/dist/commands/research/backfill.js +1 -1
  140. package/dist/commands/research/tail-transcript.js +1 -1
  141. package/dist/commands/service/install.js +1 -1
  142. package/dist/commands/service/status.js +1 -1
  143. package/dist/commands/service/uninstall.js +1 -1
  144. package/dist/commands/sessions/analyze.js +1 -1
  145. package/dist/commands/sessions/delete.js +1 -1
  146. package/dist/commands/sessions/end.js +1 -1
  147. package/dist/commands/sessions/import.js +1 -1
  148. package/dist/commands/sessions/list.js +1 -1
  149. package/dist/commands/sessions/start.js +1 -1
  150. package/dist/commands/setup.js +1 -1
  151. package/dist/commands/skills/export-approved.js +1 -1
  152. package/dist/commands/skills/install.js +1 -1
  153. package/dist/commands/skills/list.js +1 -1
  154. package/dist/commands/skills/publish.js +1 -1
  155. package/dist/commands/skills/search.js +1 -1
  156. package/dist/commands/skills/update.js +1 -1
  157. package/dist/commands/suggestions/accept.js +1 -1
  158. package/dist/commands/suggestions/auto.js +1 -1
  159. package/dist/commands/suggestions/dismiss.js +1 -1
  160. package/dist/commands/suggestions/list.js +1 -1
  161. package/dist/commands/suggestions/refresh.js +1 -1
  162. package/dist/commands/suggestions/undo.js +1 -1
  163. package/dist/dashboard/Dashboard.js +1 -1
  164. package/dist/dashboard/data.js +1 -1
  165. package/dist/dashboard/launcher/LauncherOverlay.js +1 -1
  166. package/dist/dashboard/launcher/api.js +1 -1
  167. package/dist/dashboard/launcher/useLaunchJobs.js +1 -1
  168. package/dist/dashboard/panels/measurement.js +1 -1
  169. package/dist/lib/active-org-refresh.js +1 -1
  170. package/dist/lib/agent-loop.js +1 -1
  171. package/dist/lib/antigravity-transcript.js +1 -1
  172. package/dist/lib/api-client.js +1 -1
  173. package/dist/lib/codex-exec.js +1 -1
  174. package/dist/lib/ensure-api-key.js +1 -1
  175. package/dist/lib/ensure-fresh-token.js +1 -1
  176. package/dist/lib/eval-analyzer.js +1 -1
  177. package/dist/lib/eval-benchmark.js +1 -1
  178. package/dist/lib/eval-candidate-run.js +1 -1
  179. package/dist/lib/eval-case-generator.js +1 -1
  180. package/dist/lib/eval-conversation-handler.js +1 -1
  181. package/dist/lib/eval-executor.js +1 -1
  182. package/dist/lib/eval-grader.js +1 -1
  183. package/dist/lib/eval-meta-judge.js +1 -1
  184. package/dist/lib/eval-resume.js +1 -1
  185. package/dist/lib/eval-run-batch.js +1 -1
  186. package/dist/lib/eval-trigger-tester.js +1 -1
  187. package/dist/lib/evolution-cost.js +1 -1
  188. package/dist/lib/evolution-enrolment.js +1 -1
  189. package/dist/lib/insights/generation/installed-asks.js +1 -1
  190. package/dist/lib/insights/generation/project-evidence.js +1 -0
  191. package/dist/lib/insights/generation/prompts.js +1 -1
  192. package/dist/lib/insights/nomination/nominate.js +1 -1
  193. package/dist/lib/instruction-proposer.js +1 -1
  194. package/dist/lib/instruction-restoration.js +1 -0
  195. package/dist/lib/instructions/acceptance/accept-events.js +1 -1
  196. package/dist/lib/instructions/acceptance/accept-hook.js +1 -1
  197. package/dist/lib/instructions/acceptance/hook-install.js +1 -1
  198. package/dist/lib/instructions/acceptance/reverse-applications.js +1 -1
  199. package/dist/lib/instructions/acceptance/suggestion-accept.js +1 -1
  200. package/dist/lib/jobs/handlers/cron-auto-accept-suggestions.js +1 -1
  201. package/dist/lib/jobs/handlers/cron-eval-autorun.js +1 -1
  202. package/dist/lib/jobs/handlers/cron-instruction-evolution.js +1 -1
  203. package/dist/lib/jobs/handlers/cron-instruction-training.js +1 -1
  204. package/dist/lib/jobs/handlers/cron-reconcile-attribution.js +1 -1
  205. package/dist/lib/jobs/handlers/cron-refine-cases.js +1 -1
  206. package/dist/lib/jobs/handlers/cron-refresh-pricing.js +1 -1
  207. package/dist/lib/jobs/handlers/cron-retire-unused-skills.js +1 -1
  208. package/dist/lib/jobs/handlers/cron-suggest-instructions.js +1 -1
  209. package/dist/lib/jobs/handlers/distill-memories.js +1 -1
  210. package/dist/lib/jobs/handlers/harbor-ab-verdict.js +1 -1
  211. package/dist/lib/jobs/handlers/harbor-ab.js +1 -1
  212. package/dist/lib/jobs/handlers/process-changelog.js +1 -1
  213. package/dist/lib/jobs/handlers/process-conversation.js +1 -1
  214. package/dist/lib/jobs/handlers/process-eval.js +1 -1
  215. package/dist/lib/jobs/handlers/process-insights.js +1 -1
  216. package/dist/lib/jobs/handlers/process-judge-review.js +1 -1
  217. package/dist/lib/jobs/handlers/process-launch.js +1 -1
  218. package/dist/lib/jobs/handlers/process-memory-ab.js +1 -1
  219. package/dist/lib/jobs/handlers/process-run-cleanup.js +1 -1
  220. package/dist/lib/jobs/handlers/process-session-goal.js +1 -1
  221. package/dist/lib/jobs/shed-retry.js +1 -1
  222. package/dist/lib/judge-review-runner.js +1 -1
  223. package/dist/lib/llm-client.js +1 -1
  224. package/dist/lib/manual-tasks.js +1 -1
  225. package/dist/lib/measurement-llm.js +1 -1
  226. package/dist/lib/optimize-compare.js +1 -1
  227. package/dist/lib/refine-cases.js +1 -1
  228. package/dist/lib/research-client.js +1 -1
  229. package/dist/lib/retraction.js +1 -1
  230. package/dist/lib/setup-steps.js +1 -1
  231. package/dist/lib/study-fixture.js +1 -0
  232. package/dist/lib/telemetry.js +1 -1
  233. package/dist/lib/terminal-target-heartbeat.js +1 -1
  234. package/dist/lib/work-report.js +1 -1
  235. package/oclif.manifest.json +1 -1
  236. package/package.json +6 -6
  237. package/dist/chunk-BAITMD76.js +0 -1
  238. package/dist/chunk-DHX4U6EC.js +0 -13
  239. package/dist/chunk-E7GQJML3.js +0 -1
  240. package/dist/chunk-FBSZ6KCM.js +0 -1
  241. package/dist/chunk-POEMCITL.js +0 -1
  242. package/dist/chunk-Q776YUBD.js +0 -1
  243. package/dist/chunk-RAQLVO2X.js +0 -1
  244. package/dist/chunk-SG4UDDHB.js +0 -4
  245. package/dist/chunk-SJKS3PYX.js +0 -109
  246. package/dist/chunk-VBXL7XO7.js +0 -1
@@ -1,4 +1,4 @@
1
- import{d as I}from"./chunk-E7GQJML3.js";import{a as O}from"./chunk-PIVEJTNF.js";import{a as J}from"./chunk-6XTLP2G7.js";import{y as T}from"./chunk-42A4PUW7.js";import{f as L}from"./chunk-XQYAVSUQ.js";import{a as t}from"./chunk-ZLLER3HP.js";import{spawn as z}from"node:child_process";import{existsSync as V,mkdirSync as Z,readdirSync as K}from"node:fs";import{homedir as q,tmpdir as G}from"node:os";import{dirname as W,join as d,resolve as F}from"node:path";var Q=10800*1e3,X=/^rm-[a-z0-9-]+-task$/,Y=/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/,y=/^[A-Za-z0-9._-]+$/;function rr(r,i,n){return new Promise((l,a)=>{let o=z(r,i,{cwd:n.cwd,env:n.env,stdio:["ignore","pipe","pipe"]}),e="",g="",m="",_=setTimeout(()=>o.kill("SIGKILL"),n.timeoutMs);o.stdout.on("data",s=>{let w=s.toString("utf8");if(e+=w,!n.onLine)return;m+=w;let $=m.split(`
2
- `);m=$.pop()??"";for(let p of $)n.onLine(p)}),o.stderr.on("data",s=>{g+=s.toString("utf8")}),o.on("error",s=>{clearTimeout(_),a(s)}),o.on("close",s=>{clearTimeout(_),m&&n.onLine&&n.onLine(m),l({status:s,stdout:e,stderr:g})})})}t(rr,"defaultRun");var nr={harnessDir:t(()=>O(),"harnessDir"),resolveBin:J,run:rr,exists:V,mkdir:t(r=>Z(r,{recursive:!0}),"mkdir"),readdir:K,jobsRoot:d(G(),"rulemetric-harbor"),now:t(()=>Date.now(),"now")};function er(r){if(r.trials&&r.trials.length>0){let i=r.trials.filter(n=>n.reward!=null);return{n:i.length,passes:i.filter(n=>n.reward>=.5).length}}return r.reward_mean==null||!r.n_trials?{n:r.n_trials??0,passes:null}:{n:r.n_trials,passes:Math.round(r.reward_mean*r.n_trials)}}t(er,"armReward");function sr(r){if(!X.test(r.task??""))throw new Error(`harbor_ab: refusing task "${r.task}" \u2014 not an rm-*-task name; a task is a directory name, never a path`);if(!Y.test(r.instructions??"")||r.instructions.split("/").includes(".."))throw new Error(`harbor_ab: refusing instructions "${r.instructions}" \u2014 must be a plain relative path under scripts/harbor`);if(!y.test(r.model??""))throw new Error(`harbor_ab: refusing model "${r.model}"`);if(!Number.isInteger(r.nTrials)||r.nTrials<1||r.nTrials>200)throw new Error(`harbor_ab: refusing nTrials=${r.nTrials} \u2014 must be an integer in 1..200`);if(r.class!=="proven"&&r.class!=="negative"&&r.class!=="unvalidated")throw new Error(`harbor_ab: unknown task class "${r.class}"`);if(r.axis!=="reward"&&r.axis!=="cost")throw new Error(`harbor_ab: unknown axis "${r.axis}"`)}t(sr,"validate");function tr(r,i){let n=new Set((process.env.PATH??"").split(":").filter(Boolean));for(let l of["harbor","docker","claude","codex","python3"]){let a=r.resolveBin(l);a&&n.add(W(a))}for(let l of[d(q(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"])n.add(l);return{...process.env,PATH:[...n].join(":"),HARBOR_JOBS_DIR:i}}t(tr,"spawnEnv");function f(r,i=20){return r.trim().split(`
1
+ import{d as I}from"./chunk-MOJY6S5J.js";import{a as O}from"./chunk-PIVEJTNF.js";import{a as J}from"./chunk-6XTLP2G7.js";import{y as T}from"./chunk-X6CF5KTW.js";import{f as L}from"./chunk-XQYAVSUQ.js";import{a as t}from"./chunk-ZLLER3HP.js";import{spawn as z}from"node:child_process";import{existsSync as V,mkdirSync as Z,readdirSync as K}from"node:fs";import{homedir as q,tmpdir as G}from"node:os";import{dirname as W,join as d,resolve as F}from"node:path";var Q=10800*1e3,X=/^rm-[a-z0-9-]+-task$/,Y=/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/,y=/^[A-Za-z0-9._-]+$/;function rr(r,i,n){return new Promise((c,a)=>{let o=z(r,i,{cwd:n.cwd,env:n.env,stdio:["ignore","pipe","pipe"]}),e="",_="",m="",p=setTimeout(()=>o.kill("SIGKILL"),n.timeoutMs);o.stdout.on("data",s=>{let w=s.toString("utf8");if(e+=w,!n.onLine)return;m+=w;let $=m.split(`
2
+ `);m=$.pop()??"";for(let v of $)n.onLine(v)}),o.stderr.on("data",s=>{_+=s.toString("utf8")}),o.on("error",s=>{clearTimeout(p),a(s)}),o.on("close",s=>{clearTimeout(p),m&&n.onLine&&n.onLine(m),c({status:s,stdout:e,stderr:_})})})}t(rr,"defaultRun");var nr={harnessDir:t(()=>O(),"harnessDir"),resolveBin:J,run:rr,exists:V,mkdir:t(r=>Z(r,{recursive:!0}),"mkdir"),readdir:K,jobsRoot:d(G(),"rulemetric-harbor"),now:t(()=>Date.now(),"now")};function er(r){if(r.trials&&r.trials.length>0){let i=r.trials.filter(n=>n.reward!=null);return{n:i.length,passes:i.filter(n=>n.reward>=.5).length}}return r.reward_mean==null||!r.n_trials?{n:r.n_trials??0,passes:null}:{n:r.n_trials,passes:Math.round(r.reward_mean*r.n_trials)}}t(er,"armReward");function sr(r){if(!X.test(r.task??""))throw new Error(`harbor_ab: refusing task "${r.task}" \u2014 not an rm-*-task name; a task is a directory name, never a path`);if(!Y.test(r.instructions??"")||r.instructions.split("/").includes(".."))throw new Error(`harbor_ab: refusing instructions "${r.instructions}" \u2014 must be a plain relative path under scripts/harbor`);if(!y.test(r.model??""))throw new Error(`harbor_ab: refusing model "${r.model}"`);if(!Number.isInteger(r.nTrials)||r.nTrials<1||r.nTrials>200)throw new Error(`harbor_ab: refusing nTrials=${r.nTrials} \u2014 must be an integer in 1..200`);if(r.class!=="proven"&&r.class!=="negative"&&r.class!=="unvalidated")throw new Error(`harbor_ab: unknown task class "${r.class}"`);if(r.axis!=="reward"&&r.axis!=="cost")throw new Error(`harbor_ab: unknown axis "${r.axis}"`)}t(sr,"validate");function tr(r,i){let n=new Set((process.env.PATH??"").split(":").filter(Boolean));for(let c of["harbor","docker","claude","codex","python3"]){let a=r.resolveBin(c);a&&n.add(W(a))}for(let c of[d(q(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"])n.add(c);return{...process.env,PATH:[...n].join(":"),HARBOR_JOBS_DIR:i}}t(tr,"spawnEnv");function g(r,i=20){return r.trim().split(`
3
3
  `).slice(-i).join(`
4
- `)}t(f,"tail");async function j(r,i,n,l,a,o=[]){let e=await r.run("python3",[d(i,l),...a],{cwd:i,env:n,timeoutMs:3e5});if(e.status!==0&&!o.includes(e.status))return{status:e.status,json:null,stderr:e.stderr};try{return{status:e.status,json:JSON.parse(e.stdout),stderr:e.stderr}}catch{throw new Error(`harbor_ab: ${l} printed something that is not JSON: ${f(e.stdout,5)}`)}}t(j,"readJson");async function wr(r,i,n=nr){let l=t(u=>i?.logger?.info?.(u)??console.log(u),"log"),a=r.measurement?L.parse(r.measurement):null,o=a?.engine??"claude";if(o==="pi")throw new Error("harbor_ab: Pi supports eval trials, not Harbor tasks");if(a){if(r={...r,model:a.model??T,class:o==="claude"&&a.model===T?r.class:"unvalidated"},o==="codex"&&r.axis==="cost")throw new Error("harbor_ab: dollar-cost telemetry is unavailable for Codex");if(!n.resolveBin(o))throw new Error(`harbor_ab: ${o} engine unavailable on this worker`)}sr(r);let e=n.harnessDir();if(!e)throw new Error("harbor_ab: no Harbor harness on this worker \u2014 scripts/harbor/run.sh was not found from the CLI build, the working directory, or RULEMETRIC_HARBOR_DIR. This job should not have been enqueued here: the readiness probe reports harness=false for a worker like this one.");let g=d(e,r.task),m=F(e,r.instructions);if(!n.exists(g))throw new Error(`harbor_ab: task directory not found: ${g}`);if(!n.exists(m))throw new Error(`harbor_ab: instruction file not found: ${m}`);let _=n.now(),s=d(n.jobsRoot,`${r.task}-${_}`);n.mkdir(s);let w=tr(n,s);l(`[harbor_ab] ${r.task} (${r.class}/${r.axis}, lane ${r.lane}): n=${r.nTrials}/arm on ${r.model} \u2192 ${s}`);let $=[d(e,"run.sh"),"ab",g,"--instructions",m,"--engine",o,"-m",r.model,"--n-attempts",String(r.nTrials)],p=await n.run("bash",$,{cwd:e,env:w,timeoutMs:Q,onLine:t(u=>l(`[harbor_ab] ${u}`),"onLine")});if(p.status!==0)throw new Error(`harbor_ab: ${r.task} run.sh exited ${p.status??"by signal"} after ${Math.round((n.now()-_)/1e3)}s: ${f(p.stderr)||f(p.stdout)||"(no output)"}`);let A=n.readdir(s),k=A.find(u=>/^ab-\d+-baseline$/.test(u)),E=A.find(u=>/^ab-\d+-with$/.test(u));if(!k||!E)throw new Error(`harbor_ab: run.sh exited 0 but the arm job dirs are missing under ${s} (found: ${A.join(", ")||"nothing"})`);let x=d(s,k),S=d(s,E),D=t(async u=>{let c=await j(n,e,w,"summarize.py",[u]);if(!c.json)throw new Error(`harbor_ab: summarize.py failed on ${u}: ${f(c.stderr,5)}`);return c.json},"summarize"),[N,U]=await Promise.all([D(x),D(S)]),R=await j(n,e,w,"cost_delta.py",[x,S,"--json"]);if(R.status!==0&&R.status!==3)throw new Error(`harbor_ab: cost_delta.py exited ${R.status}: ${f(R.stderr,5)}`);let b=R.json,h=await j(n,e,w,"provenance.py",["--compare",x,S,"--json"],[1]);if(h.status!==0&&h.status!==1)throw new Error(`harbor_ab: provenance.py exited ${h.status}: ${f(h.stderr,5)}`);if(!h.json)throw new Error(`harbor_ab: provenance.py printed no comparison: ${f(h.stderr,5)}`);let M=h.json,B=t((u,c)=>{let C=er(c);return{job:u,rewardMean:c.reward_mean,n:C.n,passes:C.passes,costUsd:c.cost_usd,tokens:c.tokens??null,durationMs:c.duration_ms,turns:c.turns,agentErrors:c.agent_errors}},"arm"),H=B(k,N),P=B(E,U),v=I({taskClass:r.class,axis:r.axis,baseline:{n:H.n,passes:H.passes},with:{n:P.n,passes:P.passes},cost:b,provenance:M});return l(`[harbor_ab] ${r.task}: ${v.decision} \u2014 ${v.reason}`),{task:r.task,class:r.class,axis:r.axis,lane:r.lane,model:r.model,...a?{measurement:a}:{},nTrials:r.nTrials,decision:v.decision,reason:v.reason,baseline:H,with:P,rewardDelta:v.reward.delta,rewardCi:v.reward.ci,cost:b?{decision:b.decision,deltaUsd:b.delta_usd,deltaPct:b.delta_pct,ciUsd:b.ci_usd,perSuccess:b.per_success?{decision:b.per_success.decision,deltaPct:b.per_success.delta_pct}:null,rewardRegressed:b.reward.regressed}:null,provenance:M,jobsDir:s,durationMs:n.now()-_}}t(wr,"harborAb");export{Q as a,er as b,wr as c};
4
+ `)}t(g,"tail");async function j(r,i,n,c,a,o=[]){let e=await r.run("python3",[d(i,c),...a],{cwd:i,env:n,timeoutMs:3e5});if(e.status!==0&&!o.includes(e.status))return{status:e.status,json:null,stderr:e.stderr};try{return{status:e.status,json:JSON.parse(e.stdout),stderr:e.stderr}}catch{throw new Error(`harbor_ab: ${c} printed something that is not JSON: ${g(e.stdout,5)}`)}}t(j,"readJson");async function wr(r,i,n=nr){let c=t(u=>i?.logger?.info?.(u)??console.log(u),"log"),a=r.measurement?L.parse(r.measurement):null,o=a?.engine??"claude";if(o==="pi")throw new Error("harbor_ab: Pi supports eval trials, not Harbor tasks");if(a){if(r={...r,model:a.model??T,class:o==="claude"&&a.model===T?r.class:"unvalidated"},o==="codex"&&r.axis==="cost")throw new Error("harbor_ab: dollar-cost telemetry is unavailable for Codex");if(!n.resolveBin(o))throw new Error(`harbor_ab: ${o} engine unavailable on this worker`)}sr(r);let e=n.harnessDir();if(!e)throw new Error("harbor_ab: no Harbor harness on this worker \u2014 scripts/harbor/run.sh was not found from the CLI build, the working directory, or RULEMETRIC_HARBOR_DIR. This job should not have been enqueued here: the readiness probe reports harness=false for a worker like this one.");let _=d(e,r.task),m=F(e,r.instructions);if(!n.exists(_))throw new Error(`harbor_ab: task directory not found: ${_}`);if(!n.exists(m))throw new Error(`harbor_ab: instruction file not found: ${m}`);let p=n.now(),s=d(n.jobsRoot,`${r.task}-${p}`);n.mkdir(s);let w=tr(n,s);c(`[harbor_ab] ${r.task} (${r.class}/${r.axis}, lane ${r.lane}): n=${r.nTrials}/arm on ${r.model} \u2192 ${s}`);let $=[d(e,"run.sh"),"ab",_,"--instructions",m,"--engine",o,"-m",r.model,"--n-attempts",String(r.nTrials)],v=await n.run("bash",$,{cwd:e,env:w,timeoutMs:Q,onLine:t(u=>c(`[harbor_ab] ${u}`),"onLine")});if(v.status!==0)throw new Error(`harbor_ab: ${r.task} run.sh exited ${v.status??"by signal"} after ${Math.round((n.now()-p)/1e3)}s: ${g(v.stderr)||g(v.stdout)||"(no output)"}`);let A=n.readdir(s),k=A.find(u=>/^ab-\d+-baseline$/.test(u)),E=A.find(u=>/^ab-\d+-with$/.test(u));if(!k||!E)throw new Error(`harbor_ab: run.sh exited 0 but the arm job dirs are missing under ${s} (found: ${A.join(", ")||"nothing"})`);let S=d(s,k),x=d(s,E),D=t(async u=>{let l=await j(n,e,w,"summarize.py",[u]);if(!l.json)throw new Error(`harbor_ab: summarize.py failed on ${u}: ${g(l.stderr,5)}`);return l.json},"summarize"),[N,U]=await Promise.all([D(S),D(x)]),R=await j(n,e,w,"cost_delta.py",[S,x,"--json"]);if(R.status!==0&&R.status!==3)throw new Error(`harbor_ab: cost_delta.py exited ${R.status}: ${g(R.stderr,5)}`);let b=R.json,h=await j(n,e,w,"provenance.py",["--compare",S,x,"--json"],[1]);if(h.status!==0&&h.status!==1)throw new Error(`harbor_ab: provenance.py exited ${h.status}: ${g(h.stderr,5)}`);if(!h.json)throw new Error(`harbor_ab: provenance.py printed no comparison: ${g(h.stderr,5)}`);let M=h.json,B=t((u,l)=>{let C=er(l);return{job:u,rewardMean:l.reward_mean,n:C.n,passes:C.passes,costUsd:l.cost_usd,tokens:l.tokens??null,durationMs:l.duration_ms,turns:l.turns,agentErrors:l.agent_errors}},"arm"),H=B(k,N),P=B(E,U),f=I({taskClass:r.class,axis:r.axis,baseline:{n:H.n,passes:H.passes},with:{n:P.n,passes:P.passes},cost:b,provenance:M});return c(`[harbor_ab] ${r.task}: ${f.decision} \u2014 ${f.reason}`),{task:r.task,class:r.class,axis:r.axis,lane:r.lane,model:r.model,...a?{measurement:a}:{},nTrials:r.nTrials,decision:f.decision,decisionSemanticsVersion:f.decisionSemanticsVersion,reason:f.reason,baseline:H,with:P,rewardDelta:f.reward.delta,rewardCi:f.reward.ci,cost:b?{decision:b.decision,deltaUsd:b.delta_usd,deltaPct:b.delta_pct,ciUsd:b.ci_usd,perSuccess:b.per_success?{decision:b.per_success.decision,deltaPct:b.per_success.delta_pct}:null,rewardRegressed:b.reward.regressed}:null,provenance:M,jobsDir:s,durationMs:n.now()-p}}t(wr,"harborAb");export{Q as a,er as b,wr as c};
@@ -1 +1 @@
1
- import{a as j}from"./chunk-5Z3H5JHK.js";import{a as E}from"./chunk-NBTC5FNV.js";import{a as J}from"./chunk-TU2AR6XO.js";import{d as T}from"./chunk-NJ5UED3H.js";import{b as I,c as P,d as v}from"./chunk-44TYRMIS.js";import{a as b}from"./chunk-ZLLER3HP.js";import{useEffect as R,useState as i}from"react";import{Box as l,Text as s,useInput as Z}from"ink";import{jsx as t,jsxs as a}from"react/jsx-runtime";function K({onClose:A,activeOrg:F,defaultProjectPath:y,width:_}){let{jobs:u,error:L,loading:$,refetch:S}=j(20),[M,C]=i([]),[d,m]=i("list"),[f,w]=i(0),[h,g]=i(null),[x,B]=i(null),[p,c]=i(null);R(()=>{v().then(C).catch(o=>{let r=o instanceof Error?o.message:String(o);c(`couldn't load launchers: ${r}`),C([{tool:"claude_code",capabilities:{headless:!0,interactive:!0,remoteSpawn:!0}}])})},[]),R(()=>{if(!p)return;let o=setTimeout(()=>c(null),5e3);return()=>clearTimeout(o)},[p]),Z((o,r)=>{if(h){if(o==="y"||o==="Y"){let e=h.id;g(null),P(e).then(()=>{S(),c(`cancelled ${e.slice(0,8)}`)}).catch(n=>c(`cancel failed: ${n instanceof Error?n.message:String(n)}`))}else(o==="n"||o==="N"||r.escape)&&g(null);return}if(r.escape){if(d!=="none"){m("none");return}A();return}if(r.tab){m(e=>e==="list"?"form":e==="form"?"none":"list");return}if(o!=="q"&&d==="list"){if(r.upArrow)w(e=>Math.max(0,e-1));else if(r.downArrow)w(e=>Math.min(u.length-1,e+1));else if(o==="c"){let e=u[f];e&&(e.status==="running"||e.status==="queued"||e.status==="pending")&&g(e)}else if(o==="r"){let e=u[f],n=e?.result?.externalSessionId;e&&e.tool==="claude_code"&&n?(B({tool:"claude_code",projectPath:e.config.projectPath,resumeSessionId:n}),m("form")):c("resume needs a Claude Code session with a session id")}else if(o==="o"){let n=u[f]?.result?.externalSessionId;if(n){let O=process.env.RULEMETRIC_WEB_URL??"http://localhost:5174";import("node:child_process").then(({spawn:U})=>{U("open",[`${O}/sessions/${n}`],{detached:!0,stdio:"ignore"}).unref()})}}}});async function N(o){await I(o),B(null),m("list"),c("launched"),S()}return b(N,"handleSubmit"),a(l,{flexDirection:"column",borderStyle:"round",borderColor:T,width:_,paddingX:1,children:[a(l,{children:[t(s,{bold:!0,color:T,children:"Launcher"}),t(s,{dimColor:!0,children:" active org: "}),t(s,{children:F??"(none)"}),$&&t(s,{dimColor:!0,children:" loading\u2026"}),L&&a(s,{color:"#F55B5B",children:[" \u26A0 ",L]})]}),t(l,{marginTop:1,children:t(E,{jobs:u,selectedIndex:f,focused:d==="list"})}),t(l,{marginTop:1,children:t(J,{launchers:M,defaultProjectPath:x?.projectPath??y,defaultTool:x?.tool,defaultResumeSessionId:x?.resumeSessionId,focused:d==="form",onSubmit:N})}),h&&t(l,{marginTop:1,children:a(s,{color:"#FFD700",children:["Cancel job ",h.id.slice(0,8),"? (y/n)"]})}),p&&t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\xB7 ",p]})}),t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\u2191\u2193 select tab focus c cancel r resume o open esc ",d==="none"?"close":"back"]})})]})}b(K,"LauncherOverlay");export{K as a};
1
+ import{a as j}from"./chunk-PJ4RIUI3.js";import{a as E}from"./chunk-NBTC5FNV.js";import{a as J}from"./chunk-TU2AR6XO.js";import{d as T}from"./chunk-NJ5UED3H.js";import{b as I,c as P,d as v}from"./chunk-NWV66NMA.js";import{a as b}from"./chunk-ZLLER3HP.js";import{useEffect as R,useState as i}from"react";import{Box as l,Text as s,useInput as Z}from"ink";import{jsx as t,jsxs as a}from"react/jsx-runtime";function K({onClose:A,activeOrg:F,defaultProjectPath:y,width:_}){let{jobs:u,error:L,loading:$,refetch:S}=j(20),[M,C]=i([]),[d,m]=i("list"),[f,w]=i(0),[h,g]=i(null),[x,B]=i(null),[p,c]=i(null);R(()=>{v().then(C).catch(o=>{let r=o instanceof Error?o.message:String(o);c(`couldn't load launchers: ${r}`),C([{tool:"claude_code",capabilities:{headless:!0,interactive:!0,remoteSpawn:!0}}])})},[]),R(()=>{if(!p)return;let o=setTimeout(()=>c(null),5e3);return()=>clearTimeout(o)},[p]),Z((o,r)=>{if(h){if(o==="y"||o==="Y"){let e=h.id;g(null),P(e).then(()=>{S(),c(`cancelled ${e.slice(0,8)}`)}).catch(n=>c(`cancel failed: ${n instanceof Error?n.message:String(n)}`))}else(o==="n"||o==="N"||r.escape)&&g(null);return}if(r.escape){if(d!=="none"){m("none");return}A();return}if(r.tab){m(e=>e==="list"?"form":e==="form"?"none":"list");return}if(o!=="q"&&d==="list"){if(r.upArrow)w(e=>Math.max(0,e-1));else if(r.downArrow)w(e=>Math.min(u.length-1,e+1));else if(o==="c"){let e=u[f];e&&(e.status==="running"||e.status==="queued"||e.status==="pending")&&g(e)}else if(o==="r"){let e=u[f],n=e?.result?.externalSessionId;e&&e.tool==="claude_code"&&n?(B({tool:"claude_code",projectPath:e.config.projectPath,resumeSessionId:n}),m("form")):c("resume needs a Claude Code session with a session id")}else if(o==="o"){let n=u[f]?.result?.externalSessionId;if(n){let O=process.env.RULEMETRIC_WEB_URL??"http://localhost:5174";import("node:child_process").then(({spawn:U})=>{U("open",[`${O}/sessions/${n}`],{detached:!0,stdio:"ignore"}).unref()})}}}});async function N(o){await I(o),B(null),m("list"),c("launched"),S()}return b(N,"handleSubmit"),a(l,{flexDirection:"column",borderStyle:"round",borderColor:T,width:_,paddingX:1,children:[a(l,{children:[t(s,{bold:!0,color:T,children:"Launcher"}),t(s,{dimColor:!0,children:" active org: "}),t(s,{children:F??"(none)"}),$&&t(s,{dimColor:!0,children:" loading\u2026"}),L&&a(s,{color:"#F55B5B",children:[" \u26A0 ",L]})]}),t(l,{marginTop:1,children:t(E,{jobs:u,selectedIndex:f,focused:d==="list"})}),t(l,{marginTop:1,children:t(J,{launchers:M,defaultProjectPath:x?.projectPath??y,defaultTool:x?.tool,defaultResumeSessionId:x?.resumeSessionId,focused:d==="form",onSubmit:N})}),h&&t(l,{marginTop:1,children:a(s,{color:"#FFD700",children:["Cancel job ",h.id.slice(0,8),"? (y/n)"]})}),p&&t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\xB7 ",p]})}),t(l,{marginTop:1,children:a(s,{dimColor:!0,children:["\u2191\u2193 select tab focus c cancel r resume o open esc ",d==="none"?"close":"back"]})})]})}b(K,"LauncherOverlay");export{K as a};
@@ -1 +1 @@
1
- import{l as E}from"./chunk-42A4PUW7.js";import{a as p,e as w}from"./chunk-PZNWH4VQ.js";import{a as o}from"./chunk-ZLLER3HP.js";import{fileURLToPath as v}from"node:url";import{existsSync as A,readFileSync as b}from"node:fs";import{dirname as L,join as x}from"node:path";function C(){let t=L(v(import.meta.url));for(let e=0;e<8;e++){let s=x(t,"package.json");if(A(s))try{let i=JSON.parse(b(s,"utf8"));if(i.name==="@rulemetric/cli"&&i.version)return i.version}catch{}let n=L(t);if(n===t)break;t=n}return"0.0.0"}o(C,"readCliVersion");var O=C(),I="https://rulemetric.com",l=class extends Error{constructor(s,n){super(n);this.statusCode=s;this.name="ApiError"}static{o(this,"ApiError")}};function S(){let t=p(),e=process.env.RULEMETRIC_API_URL??t.apiUrl;if(!e){if(process.env.RULEMETRIC_STRICT_LOCAL==="1"||t.strictLocal==="1")throw new Error("RULEMETRIC_STRICT_LOCAL is set but no RULEMETRIC_API_URL is configured \u2014 refusing the cloud default. Set RULEMETRIC_API_URL in the environment or ~/.config/rulemetric/env.");e=I}let s=new URL(e);if(s.protocol==="http:"&&s.hostname!=="localhost"&&s.hostname!=="127.0.0.1")throw new Error(`API URL must use HTTPS for non-localhost hosts: ${e}`);return e}o(S,"getBaseUrl");async function a(t,e={}){let n=`${S()}${t}`,i={"Content-Type":"application/json","User-Agent":`rulemetric-cli/${O}`,...e.headers},m=p(),d=process.env.RULEMETRIC_API_KEY||m.apiKey||w()?.accessToken||m.accessToken;d&&(i.Authorization=`Bearer ${d}`);let h=new URL(n),f=h.hostname==="localhost"||h.hostname==="127.0.0.1",P=process.env.HTTPS_PROXY,R=process.env.HTTP_PROXY;f&&(delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY);let u=e.timeoutMs?new AbortController:void 0,g=!1,y=u?setTimeout(()=>{g=!0,u.abort()},e.timeoutMs):void 0,r;try{r=await fetch(n,{method:e.method??"GET",headers:i,body:e.body?JSON.stringify(e.body):void 0,signal:u?.signal})}catch(T){if(g){let U=new URL(n).host,_=Math.round(e.timeoutMs/1e3);throw new l(408,`Request to ${U} timed out after ${_}s. This is usually transient or a local proxy/gateway issue \u2014 retry, and if it persists check HTTPS_PROXY / the RuleMetric gateway (:8787).`)}throw T}finally{y&&clearTimeout(y),f&&(P!==void 0&&(process.env.HTTPS_PROXY=P),R!==void 0&&(process.env.HTTP_PROXY=R))}let c;if(r.headers.get("content-type")?.includes("application/json")?c=await r.json():c=await r.text(),!r.ok){let{message:T}=E(r.status,c);throw new l(r.status,T)}return c}o(a,"api");var j=o(t=>a(t),"apiGet"),F=o((t,e)=>a(t,{method:"POST",body:e}),"apiPost"),B=o((t,e)=>a(t,{method:"PUT",body:e}),"apiPut"),D=o((t,e)=>a(t,{method:"PATCH",body:e}),"apiPatch"),G=o(t=>a(t,{method:"DELETE"}),"apiDelete");export{I as a,l as b,S as c,a as d,j as e,F as f,B as g,D as h,G as i};
1
+ import{l as E}from"./chunk-X6CF5KTW.js";import{a as p,e as w}from"./chunk-PZNWH4VQ.js";import{a as o}from"./chunk-ZLLER3HP.js";import{fileURLToPath as v}from"node:url";import{existsSync as A,readFileSync as b}from"node:fs";import{dirname as L,join as x}from"node:path";function C(){let t=L(v(import.meta.url));for(let e=0;e<8;e++){let s=x(t,"package.json");if(A(s))try{let i=JSON.parse(b(s,"utf8"));if(i.name==="@rulemetric/cli"&&i.version)return i.version}catch{}let n=L(t);if(n===t)break;t=n}return"0.0.0"}o(C,"readCliVersion");var O=C(),I="https://rulemetric.com",l=class extends Error{constructor(s,n){super(n);this.statusCode=s;this.name="ApiError"}static{o(this,"ApiError")}};function S(){let t=p(),e=process.env.RULEMETRIC_API_URL??t.apiUrl;if(!e){if(process.env.RULEMETRIC_STRICT_LOCAL==="1"||t.strictLocal==="1")throw new Error("RULEMETRIC_STRICT_LOCAL is set but no RULEMETRIC_API_URL is configured \u2014 refusing the cloud default. Set RULEMETRIC_API_URL in the environment or ~/.config/rulemetric/env.");e=I}let s=new URL(e);if(s.protocol==="http:"&&s.hostname!=="localhost"&&s.hostname!=="127.0.0.1")throw new Error(`API URL must use HTTPS for non-localhost hosts: ${e}`);return e}o(S,"getBaseUrl");async function a(t,e={}){let n=`${S()}${t}`,i={"Content-Type":"application/json","User-Agent":`rulemetric-cli/${O}`,...e.headers},m=p(),d=process.env.RULEMETRIC_API_KEY||m.apiKey||w()?.accessToken||m.accessToken;d&&(i.Authorization=`Bearer ${d}`);let h=new URL(n),f=h.hostname==="localhost"||h.hostname==="127.0.0.1",P=process.env.HTTPS_PROXY,R=process.env.HTTP_PROXY;f&&(delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY);let u=e.timeoutMs?new AbortController:void 0,g=!1,y=u?setTimeout(()=>{g=!0,u.abort()},e.timeoutMs):void 0,r;try{r=await fetch(n,{method:e.method??"GET",headers:i,body:e.body?JSON.stringify(e.body):void 0,signal:u?.signal})}catch(T){if(g){let U=new URL(n).host,_=Math.round(e.timeoutMs/1e3);throw new l(408,`Request to ${U} timed out after ${_}s. This is usually transient or a local proxy/gateway issue \u2014 retry, and if it persists check HTTPS_PROXY / the RuleMetric gateway (:8787).`)}throw T}finally{y&&clearTimeout(y),f&&(P!==void 0&&(process.env.HTTPS_PROXY=P),R!==void 0&&(process.env.HTTP_PROXY=R))}let c;if(r.headers.get("content-type")?.includes("application/json")?c=await r.json():c=await r.text(),!r.ok){let{message:T}=E(r.status,c);throw new l(r.status,T)}return c}o(a,"api");var j=o(t=>a(t),"apiGet"),F=o((t,e)=>a(t,{method:"POST",body:e}),"apiPost"),B=o((t,e)=>a(t,{method:"PUT",body:e}),"apiPut"),D=o((t,e)=>a(t,{method:"PATCH",body:e}),"apiPatch"),G=o(t=>a(t,{method:"DELETE"}),"apiDelete");export{I as a,l as b,S as c,a as d,j as e,F as f,B as g,D as h,G as i};
@@ -1,3 +1,3 @@
1
- import{e as p}from"./chunk-LJRE3LZ2.js";import{C as f}from"./chunk-42A4PUW7.js";import{a as r}from"./chunk-ZLLER3HP.js";var g=80,h=/\b(must|never|always|do not|don'?t|avoid|prefer|require[sd]?|before|after|only|instead of|use|run|add|keep|stop|refuse|check|verify|ask|write|read)\b/i,m=200,k=r(()=>({asks:[],omitted:0}),"empty");function A(s){return s.replace(/\s+/g," ").trim().toLowerCase()}r(A,"key");function I(s){let t=[];for(let o of s.split(`
1
+ import{e as p}from"./chunk-LJRE3LZ2.js";import{C as f}from"./chunk-X6CF5KTW.js";import{a as r}from"./chunk-ZLLER3HP.js";var g=80,h=/\b(must|never|always|do not|don'?t|avoid|prefer|require[sd]?|before|after|only|instead of|use|run|add|keep|stop|refuse|check|verify|ask|write|read)\b/i,m=200,k=r(()=>({asks:[],omitted:0}),"empty");function A(s){return s.replace(/\s+/g," ").trim().toLowerCase()}r(A,"key");function I(s){let t=[];for(let o of s.split(`
2
2
  `)){let e=o.trim(),n=t.length>0?t[t.length-1]:"",i=e===""||/^(?:[-*+]|\d+[.)]|#|```|>|\||!)/.test(e);if(n!==""&&!/[.!?:;]$/.test(n)&&!/^(?:#|```)/.test(n)&&!i){t[t.length-1]=`${n} ${e}`;continue}t.push(e)}return t.join(`
3
3
  `)}r(I,"unwrap");function y(s,t=p){if(!s)return k();try{let o=new Set,e=[],n=[];for(let l of t(s))for(let d of f(I(l.content))){let c=A(d);if(c===""||o.has(c))continue;o.add(c);let a=d.replace(/\s+/g," ").trim(),u=a.length>m?`${a.slice(0,m)}\u2026`:a;(h.test(u)?e:n).push(u)}let i=[...e,...n];return{asks:i.slice(0,g),omitted:Math.max(0,i.length-g)}}catch{return k()}}r(y,"readInstalledAsks");export{g as a,m as b,y as c};
@@ -0,0 +1,3 @@
1
+ import{a as s}from"./chunk-ZLLER3HP.js";var _=1.959963984540054;function k(n,t,e=_){if(t===0)return{lower:0,upper:1};let o=n/t,r=e*e,i=1+r/t,u=(o+r/(2*t))/i,a=e/i*Math.sqrt(o*(1-o)/t+r/(4*t*t));return{lower:Math.max(0,u-a),upper:Math.min(1,u+a)}}s(k,"wilsonInterval");function L(n,t){let e=n,o=t,r=e+o;if(r===0)return{pValue:1,nDiscordant:0};let i=Math.min(e,o),u=Math.pow(.5,r),a=u;for(let c=1;c<=i;c++)u*=(r-c+1)/c,a+=u;return{pValue:Math.min(1,2*a),nDiscordant:r}}s(L,"mcnemarExact");function U(n,t,e=10){return{sufficient:n>=e&&t>=e,minN:e,nWith:n,nWithout:t,shortfall:{with:Math.max(0,e-n),without:Math.max(0,e-t)}}}s(U,"assessSufficiency");function M(n){let t=n>>>0;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}s(M,"seededRandom");function C(n,t){let e=n.length;if(e===1)return n[0];let o=(e-1)*t,r=Math.floor(o),i=Math.ceil(o);return r===i?n[r]:n[r]+(o-r)*(n[i]-n[r])}s(C,"sortedQuantile");function j(n,t={}){let e=n.length;if(e===0)return{estimate:0,lower:0,upper:0,iterations:0};let o=t.iterations??1e4,r=t.ciLevel??.95,i=M(t.seed??1),u=n.reduce((l,f)=>l+f,0)/e,a=new Array(o);for(let l=0;l<o;l++){let f=0;for(let h=0;h<e;h++)f+=n[i()*e|0];a[l]=f/e}a.sort((l,f)=>l-f);let c=(1-r)/2;return{estimate:u,lower:C(a,c),upper:C(a,1-c),iterations:o}}s(j,"pairedBootstrapCI");function V(n,t={}){let e=n.filter(d=>d.withScores.length>0&&d.withoutScores.length>0);if(e.length===0)return{estimate:0,lower:0,upper:0,pValue:1,iterations:0};let o=s(d=>d.reduce((p,g)=>p+g,0)/d.length,"mean"),r=e.map(d=>d.withScores.length*d.withoutScores.length/(d.withScores.length+d.withoutScores.length)),i=r.reduce((d,p)=>d+p,0),u=s(d=>d.reduce((p,g,w)=>p+r[w]*g,0)/i,"combine"),a=u(e.map(d=>o(d.withScores)-o(d.withoutScores))),c=t.iterations??1e4,l=t.ciLevel??.95,f=M(t.seed??1),h=new Array(c),b=0,x=0;for(let d=0;d<c;d++){let p=e.map(w=>{let $=0;for(let v=0;v<w.withScores.length;v++)$+=w.withScores[f()*w.withScores.length|0];let T=0;for(let v=0;v<w.withoutScores.length;v++)T+=w.withoutScores[f()*w.withoutScores.length|0];return $/w.withScores.length-T/w.withoutScores.length}),g=u(p);h[d]=g,g<=0&&b++,g>=0&&x++}h.sort((d,p)=>d-p);let A=(1-l)/2;return{estimate:a,lower:C(h,A),upper:C(h,1-A),pValue:Math.min(1,2*Math.min(b,x)/c),iterations:c}}s(V,"stratifiedBootstrapCI");function Q(n,t){let e=n.length,o=t.length;if(e===0||o===0)return 0;let r=[...n.map(l=>({t:l,exposed:!0})),...t.map(l=>({t:l,exposed:!1}))].sort((l,f)=>l.t-f.t),i=0,u=0;for(;u<r.length;){let l=u;for(;l+1<r.length&&r[l+1].t===r[u].t;)l++;let f=(u+1+l+1)/2;for(let h=u;h<=l;h++)r[h].exposed&&(i+=f);u=l+1}let c=(i-e*(e+1)/2)/(e*o);return Math.abs(c-.5)}s(Q,"cohortTimeSeparation");var N=.35,D=900*1e3;function W(n,t,e=N,o=D){if(n.length===0||t.length===0)return!1;let r=[...n,...t];return Math.max(...r)-Math.min(...r)<o?!1:Q(n,t)>e}s(W,"isTimeSeparated");var K=s(n=>n===0||n===1,"isBinary");function ee(n,t,e){return n.every(r=>r[t]!=null&&r[e]!=null)?n.reduce((r,i)=>r+(i[t]-i[e]),0)/n.length:null}s(ee,"meanPairDelta");function q(n,t={}){let e=t.baseline??"no-rule",o=t.minN??10,r=n.length,i=n.map(d=>d.withScore-d.withoutScore),u=r===0?0:i.reduce((d,p)=>d+p,0)/r,a=j(i,{seed:t.seed,iterations:t.iterations}),c={lower:a.lower,upper:a.upper},l=n.every(d=>K(d.withScore)&&K(d.withoutScore)),f=null;if(l&&r>0){let d=0,p=0;for(let g of n)g.withScore===1&&g.withoutScore===0?d++:g.withScore===0&&g.withoutScore===1&&p++;f=L(d,p).pValue}let{sufficient:h}=U(r,r,o),b=c.lower>0||c.upper<0,A={mode:"controlled",baseline:e,delta:u,ci:c,pValue:f,significant:h&&b,sufficient:h,nWith:r,nWithout:r,costDelta:ee(n,"withCost","withoutCost"),latencyDelta:ee(n,"withLatency","withoutLatency"),confounded:!1};return h||(A.insufficientReason=`insufficient data: need >= ${o} paired tasks per cohort, have ${r}`),A}s(q,"buildControlledVerdict");var we=2;function Y(n,t={}){let e=t.minN??10,o=t.minPerStratum??we,r=t.maxTimeSeparation??N,i=t.minStratumSpanMs??D,u=n.filter(m=>m.withScores.length>=o&&m.withoutScores.length>=o),a=u.filter(m=>m.withTimes!=null&&m.withoutTimes!=null&&W(m.withTimes,m.withoutTimes,r,i)),c=new Set(a.map(m=>m.key)),l=u.filter(m=>!c.has(m.key)),f=n.filter(m=>m.withScores.length>0&&m.withoutScores.length>0&&(m.withScores.length<o||m.withoutScores.length<o)).length,h=l.reduce((m,S)=>m+S.withScores.length,0),b=l.reduce((m,S)=>m+S.withoutScores.length,0),x=V(l,{seed:t.seed,iterations:t.iterations}),A={lower:x.lower,upper:x.upper},d=x.estimate,p=l.length>0&&h>=e&&b>=e,g=l.length>0?x.pValue:null,w=p&&(A.lower>0||A.upper<0),$=n.reduce((m,S)=>m+S.withScores.length+S.withoutScores.length,0),T=$>0?(h+b)/$:0,v={mode:"observational",baseline:t.baseline??"no-rule",delta:d,ci:A,pValue:g,significant:w,sufficient:p,nWith:h,nWithout:b,costDelta:null,latencyDelta:null,confounded:!0,strata:l.length,strataDroppedForTimeSeparation:a.length,coverage:T};if(!p){let m=f>0?` (${f} project(s) had both cohorts but fewer than ${o} sessions in one of them)`:"",S=a.length>0?` ${a.length} project-month(s) held both cohorts but their sessions are separated in time (exposure predicts when a session ran), so the difference within them is a calendar difference, not a treatment effect`:"";v.insufficientReason=l.length===0?a.length>0?`insufficient data: no comparable cohort.${S}${m}`:`insufficient data: no project has >= ${o} exposed AND >= ${o} unexposed sessions to compare within${m}`:`insufficient data: need >= ${e} sessions per cohort across comparable projects, have ${h} exposed / ${b} unexposed${m}${S?`.${S}`:""}`}return v}s(Y,"buildStratifiedVerdict");function te(n){let t=new Map;for(let e of n){let o=t.get(e.stratum);o||(o={key:e.stratum,withScores:[],withoutScores:[],withTimes:[],withoutTimes:[]},t.set(e.stratum,o)),(e.exposed?o.withScores:o.withoutScores).push(e.score),e.time!=null&&(e.exposed?o.withTimes:o.withoutTimes).push(e.time)}for(let e of t.values())(e.withTimes.length!==e.withScores.length||e.withoutTimes.length!==e.withoutScores.length)&&(delete e.withTimes,delete e.withoutTimes);return[...t.values()]}s(te,"toStrata");var R=.05;function ne(n,t={}){let e=t.trialIndex??0,o=t.seed??1,r=t.exposedFraction??.5,i=t.effect??0,u=M(o+e*2),a=n.map(c=>{let l=u()<r;return{stratum:c.stratum,score:l?c.score+i:c.score,exposed:l,time:c.time}});return Y(te(a),{seed:o+e*2+1,iterations:t.iterations??500,minN:t.minN,minPerStratum:t.minPerStratum})}s(ne,"runCalibrationTrial");function B(n,t={}){let e=t.trials??200,o=[];for(let r=0;r<e;r++)o.push(ne(n,{...t,trialIndex:r}));return I(o,t.effect??0)}s(B,"calibrate");function I(n,t){let e=0,o=0,r=0,i=0;for(let c of n)c.sufficient&&(e++,c.significant&&o++,r+=c.delta,i=Math.max(i,Math.abs(c.delta)));let u=e>0?o/e:0,a=k(o,e,_);return{trials:n.length,evaluated:e,insufficient:n.length-e,significantTrials:o,significantRate:u,significantRateCi:a,meanDelta:e>0?r/e:0,maxAbsDelta:i,alpha:R,effect:t,calibrated:t===0&&e>0&&a.lower<=R&&R<=a.upper}}s(I,"summarizeTrials");function P(n,t={}){return B(n,{...t,effect:0})}s(P,"aaCalibration");function Z(n,t,e={}){return B(n,{...e,effect:t})}s(Z,"powerCheck");var be=.8416212335729143;var re=[{ym:"2026-03",n:122,mean:.287},{ym:"2026-04",n:50,mean:.07},{ym:"2026-05",n:267,mean:.089},{ym:"2026-06",n:61,mean:.201},{ym:"2026-07",n:162,mean:.071}],X=662;function H(n=2){let t=[];for(let e of re){let o=Math.round(e.n*e.mean);for(let r=0;r<e.n;r++)t.push({stratum:`proj-${r%n}|${e.ym}`,score:r<o?1:0})}if(n===2&&t.length!==X)throw new Error(`realisticCanaryCorpus: expected ${X} sessions, built ${t.length}`);return t}s(H,"realisticCanaryCorpus");function ie(n=600){return Array.from({length:n},(t,e)=>({stratum:"only",score:e%4===0?1:0}))}s(ie,"flatCanaryCorpus");var ae=50,se=4,F={min:.2,max:.7};function Se(n,t){let e=M(t),o=F.max-F.min;return Array.from({length:n},()=>F.min+e()*o)}s(Se,"caseDifficulties");function oe(n,t,e){let o=0;for(let r=0;r<t;r++)e()<n&&o++;return o/t}s(oe,"passRate");function ce(n={}){let t=n.trialIndex??0,e=n.seed??1,o=n.cases??ae,r=n.assertions??se,i=n.effect??0,u=Se(o,e),a=M(e+t*2),c=u.map(l=>({withScore:oe(l+i,r,a),withoutScore:oe(l,r,a)}));return q(c,{baseline:"prior-version",seed:e+t*2+1,iterations:n.iterations??500,minN:n.minN})}s(ce,"runControlledCalibrationTrial");function G(n={}){let t=n.trials??200,e=[];for(let o=0;o<t;o++)e.push(ce({...n,trialIndex:o}));return I(e,n.effect??0)}s(G,"controlledCalibration");function le(n={}){return G({...n,effect:0})}s(le,"controlledAaCalibration");function ue(n,t={}){return G({...t,effect:n})}s(ue,"controlledPowerCheck");var de={maxSignificantRate:.15,maxMeanAbsDelta:.02,maxWorstCaseDelta:.15,powerProbeEffect:.2,minPower:.9,minPowerMeanDelta:.15};function E(n,t,e){let o=e.filter(r=>!r.ok).map(r=>r.why);return{name:n,passed:o.length===0,detail:o.length===0?`${n}: ok (rate=${t.significantRate.toFixed(3)}, meanDelta=${t.meanDelta.toFixed(4)}, evaluated=${t.evaluated}/${t.trials})`:`${n}: ${o.join("; ")}`,result:t}}s(E,"check");function Ae(n={}){let t=n.trials??200,e=n.powerTrials??200,o=de,r=[],i=P(ie(),{trials:t,seed:11});r.push(E("aa-flat",i,[{ok:i.calibrated,why:`\u03B1=${R} outside rate CI [${i.significantRateCi.lower.toFixed(3)}, ${i.significantRateCi.upper.toFixed(3)}]`},{ok:i.significantRate<o.maxSignificantRate,why:`false-positive rate ${i.significantRate.toFixed(3)} \u2265 ${o.maxSignificantRate}`},{ok:Math.abs(i.meanDelta)<o.maxMeanAbsDelta,why:`mean delta ${i.meanDelta.toFixed(4)} not centred on zero`}]));let u=P(H(),{trials:t,seed:23});r.push(E("aa-realistic",u,[{ok:u.calibrated,why:`\u03B1=${R} outside rate CI [${u.significantRateCi.lower.toFixed(3)}, ${u.significantRateCi.upper.toFixed(3)}]`},{ok:u.significantRate<o.maxSignificantRate,why:`false-positive rate ${u.significantRate.toFixed(3)} \u2265 ${o.maxSignificantRate}`},{ok:Math.abs(u.meanDelta)<o.maxMeanAbsDelta,why:`mean delta ${u.meanDelta.toFixed(4)} not centred on zero`},{ok:u.maxAbsDelta<o.maxWorstCaseDelta,why:`worst single-trial delta ${u.maxAbsDelta.toFixed(3)} \u2265 ${o.maxWorstCaseDelta}`}]));let a=Z(H(),o.powerProbeEffect,{trials:e,seed:5});r.push(E("power-observational",a,[{ok:a.significantRate>o.minPower,why:`detects +${o.powerProbeEffect} only ${a.significantRate.toFixed(3)} of the time`},{ok:a.meanDelta>o.minPowerMeanDelta,why:`measured mean delta ${a.meanDelta.toFixed(3)} understates the injected +${o.powerProbeEffect}`}]));let c=le({trials:t,seed:31});r.push(E("aa-controlled",c,[{ok:c.calibrated,why:`\u03B1=${R} outside rate CI [${c.significantRateCi.lower.toFixed(3)}, ${c.significantRateCi.upper.toFixed(3)}]`},{ok:c.significantRate<o.maxSignificantRate,why:`false-positive rate ${c.significantRate.toFixed(3)} \u2265 ${o.maxSignificantRate}`},{ok:Math.abs(c.meanDelta)<o.maxMeanAbsDelta,why:`mean delta ${c.meanDelta.toFixed(4)} not centred on zero`}]));let l=ue(o.powerProbeEffect,{trials:e,seed:37});r.push(E("power-controlled",l,[{ok:l.significantRate>o.minPower,why:`detects +${o.powerProbeEffect} only ${l.significantRate.toFixed(3)} of the time`}]));let f=r.filter(h=>!h.passed).map(h=>h.detail);return{green:f.length===0,checks:r,failures:f}}s(Ae,"runPromotionCanary");var Me=3,Re=7,J="(preamble)",_e=/^\s*(`{3,}|~{3,})/,$e=/^(#{1,6})\s+(.*)$/;function y(n){let t=n.split(`
2
+ `),e=[],o=[],r={heading:"",level:0,path:[J],body:[]},i=null,u=s(()=>{e.push({heading:r.heading,level:r.level,path:r.path,body:r.body.join(`
3
+ `).trim()})},"flush");for(let a of t){let c=_e.exec(a);if(c){let f=c[1];i==null?i={marker:f}:f[0]===i.marker[0]&&f.length>=i.marker.length&&(i=null),r.body.push(a);continue}if(i!=null){r.body.push(a);continue}let l=$e.exec(a);if(l){u();let f=l[1].length,h=l[2].trim();o.length=Math.max(0,f-1),o[f-1]=h,r={heading:h,level:f,path:Array.from({length:f},(b,x)=>o[x]??`(unnamed level ${x+1})`),body:[]};continue}r.body.push(a)}return u(),e.filter((a,c)=>!(c===0&&a.level===0&&a.body===""))}s(y,"splitMarkdownSections");function O(n){let t=new Map,e=new Map;for(let o of n){let r=o.level===0?J:o.path.join(" > "),i=(t.get(r)??0)+1;t.set(r,i),e.set(i===1?r:`${r} #${i}`,o)}return e}s(O,"sectionKeys");function he(n,t){let e=O(y(n)),o=O(y(t)),r=[],i=[],u=[];for(let[a,c]of o){let l=e.get(a);l?l.body!==c.body&&r.push(a):i.push(a)}for(let a of e.keys())o.has(a)||u.push(a);return{changed:r.sort(),added:i.sort(),removed:u.sort()}}s(he,"diffSections");function me(n){return[...new Set([...n.changed,...n.added,...n.removed])].sort()}s(me,"touchedSections");var fe=s(n=>n.trim().toLowerCase(),"normalize");function Ee(n,t,e){if(e.length===0)return[];let o=new Set(e.map(fe)),r=he(n,t),i=new Set(me(r)),u=new Map([...O(y(n)),...O(y(t))]),a=[];for(let c of i){let l=u.get(c);(l?l.path:c.split(" > ")).some(h=>o.has(fe(h)))&&a.push(c)}return a.sort()}s(Ee,"protectedViolations");export{_ as a,q as b,be as c,Ae as d,Me as e,Re as f,Ee as g};
@@ -1,4 +1,4 @@
1
- import{b as p}from"./chunk-ZK3ACE4T.js";import{g as l}from"./chunk-N4YPDZJF.js";import{a}from"./chunk-ZLLER3HP.js";var g=5,h=a(e=>e==null?"n/a":`${Math.round(e*100)}%`,"pct");function b(e){return!e||e.length===0?"":`
1
+ import{b as p}from"./chunk-T7HZZ4DJ.js";import{g as l}from"./chunk-XCH4HPEZ.js";import{a}from"./chunk-ZLLER3HP.js";var g=5,h=a(e=>e==null?"n/a":`${Math.round(e*100)}%`,"pct");function b(e){return!e||e.length===0?"":`
2
2
 
3
3
  ## Prior cases that FAILED to discriminate \u2014 do NOT reproduce these
4
4
  The cases below were run WITH and WITHOUT the instruction and did NOT separate the two
@@ -1,4 +1,4 @@
1
- import{h as o}from"./chunk-I6ZQOMZS.js";import{g as f}from"./chunk-N4YPDZJF.js";import{b as y,e as m,h as d}from"./chunk-76UKAFNM.js";import{a as S}from"./chunk-ZLLER3HP.js";var _=1800*1e3,G=300*1e3,R=10,T=`Given these messages from an AI coding session, write a 1-2 sentence summary of what the user is trying to accomplish. Focus on the goal, not the steps. No preamble.
1
+ import{h as o}from"./chunk-CVPAKEEZ.js";import{g as f}from"./chunk-XCH4HPEZ.js";import{b as y,e as m,h as d}from"./chunk-GIXHG5FK.js";import{a as S}from"./chunk-ZLLER3HP.js";var _=1800*1e3,G=300*1e3,R=10,T=`Given these messages from an AI coding session, write a 1-2 sentence summary of what the user is trying to accomplish. Focus on the goal, not the steps. No preamble.
2
2
 
3
3
  Return strict JSON in the form: {"goalSummary": "..."}`;async function N(n,e={}){let w=e.llm??f,i=e.now??Date.now,v=e.getSession??(async s=>{try{return await o(()=>m(`/api/sessions/${s}`),{label:"session detail",idempotent:!0})}catch(t){if(t instanceof y&&t.statusCode===404)return null;throw t}}),l=e.getEvents??((s,t)=>o(()=>m(`/api/sessions/${s}/events?limit=${t.limit}&sort=${t.sort}`),{label:"session events",idempotent:!0})),P=e.saveGoal??(async(s,t)=>{await o(()=>d(`/api/sessions/${s}/enrich`,{analysis:t}),{label:"session enrich"})}),r=await v(n.sessionId);if(!r)return{skipped:"not_found"};let[A]=await l(n.sessionId,{limit:1,sort:"desc"}),h=new Date(A?.timestamp??r.startedAt).getTime();if(i()-h>_)return{skipped:"stale"};let c=r.analysis??{},g=c.goalSummaryAt?new Date(c.goalSummaryAt).getTime():0;if(g&&i()-g<G)return{skipped:"recent"};let u=(await l(n.sessionId,{limit:R*2,sort:"asc"})).filter(s=>s.content&&(s.eventType==="user_message"||s.eventType==="assistant_response")).map(s=>`${s.eventType==="user_message"?"USER":"ASSISTANT"}: ${s.content}`).join(`
4
4
 
@@ -1 +1 @@
1
- import{f as r}from"./chunk-76UKAFNM.js";import{a as i}from"./chunk-ZLLER3HP.js";async function p(e,t,n,o){await r(`/api/instruction-suggestions/${encodeURIComponent(e)}/events`,{eventType:"accepted",projectPath:t,instructionId:n,actor:o})}i(p,"logAccepted");async function a(e,t,n,o,s="redundant"){await r(`/api/instruction-suggestions/${encodeURIComponent(e)}/events`,{eventType:s,projectPath:t,instructionId:n,actor:o})}i(a,"logRefused");export{p as a,a as b};
1
+ import{f as r}from"./chunk-GIXHG5FK.js";import{a as i}from"./chunk-ZLLER3HP.js";async function p(e,t,n,o){await r(`/api/instruction-suggestions/${encodeURIComponent(e)}/events`,{eventType:"accepted",projectPath:t,instructionId:n,actor:o})}i(p,"logAccepted");async function a(e,t,n,o,s="redundant"){await r(`/api/instruction-suggestions/${encodeURIComponent(e)}/events`,{eventType:s,projectPath:t,instructionId:n,actor:o})}i(a,"logRefused");export{p as a,a as b};
@@ -0,0 +1,4 @@
1
+ import{a as y}from"./chunk-6XTLP2G7.js";import{a as s}from"./chunk-ZLLER3HP.js";import{spawn as v}from"node:child_process";import{mkdtempSync as O,readFileSync as D,rmSync as I}from"node:fs";import{tmpdir as M}from"node:os";import{join as E}from"node:path";var R=s(t=>`codex:${t.replace(/^codex:/,"")}`,"codexModelId");function $(t,o,i=!1){return["exec","--json","--sandbox",i?"workspace-write":"read-only","--skip-git-repo-check","--ephemeral","--model",t.replace(/^codex:/,""),"--output-last-message",o,"-"]}s($,"buildCodexArgs");function A(t){let o;for(let i of t.split(`
2
+ `)){let c=i.trim();if(!c.startsWith("{"))continue;let n;try{n=JSON.parse(c)}catch{continue}if(typeof n!="object"||n===null)continue;let d=n.usage;if(typeof d!="object"||d===null)continue;let u=s(x=>{let p=d[x];return typeof p=="number"&&Number.isFinite(p)?p:0},"num"),l=u("input_tokens"),a=u("output_tokens");o={inputTokens:l,cachedInputTokens:u("cached_input_tokens"),outputTokens:a,reasoningOutputTokens:u("reasoning_output_tokens"),totalTokens:l+a}}return o}s(A,"parseCodexUsage");async function L(t){let{prompt:o,systemPrompt:i,model:c,timeout:n=12e4,workDir:d=process.cwd()}=t,u=i?`${i}
3
+
4
+ ${o}`:o,l=y("codex");if(!l)return{output:"",exitCode:null,durationMs:0,error:"Codex CLI not found on PATH, well-known install dirs, or the node bin dir \u2014 is it installed?"};let a=O(E(M(),"rulemetric-codex-")),x=E(a,"last-message.txt"),p=Date.now();return new Promise(S=>{let f={...process.env};delete f.HTTPS_PROXY;let _=["/opt/homebrew/bin","/usr/local/bin"],T=(f.PATH??"").split(":").filter(Boolean),b=_.filter(e=>!T.includes(e));b.length&&(f.PATH=[...T,...b].join(":"));let r=v(l,$(c,x,t.writableFixture),{cwd:d,env:f,stdio:["pipe","pipe","pipe"]}),C="",m="",w=256*1024;r.stdout.on("data",e=>{m+=e.toString(),m.length>w&&(m=m.slice(-w))}),r.stderr.on("data",e=>{C+=e.toString()});let g=s(e=>{I(a,{recursive:!0,force:!0}),S({...e,durationMs:Date.now()-p})},"finish"),h=setTimeout(()=>{r.kill("SIGTERM"),g({output:"",exitCode:null,error:`codex exec timed out after ${n}ms`})},n);r.on("error",e=>{clearTimeout(h),g({output:"",exitCode:null,error:`failed to spawn codex: ${e.message} (is the Codex CLI installed?)`})}),r.on("close",e=>{clearTimeout(h);let k="";try{k=D(x,"utf8").trim()}catch{}let P=A(m);if(e!==0||k===""){g({output:k,exitCode:e,usage:P,error:`codex exec failed (exit ${e}): ${C.trim().slice(-500)||"no last message produced"}`});return}g({output:k,exitCode:e,model:R(c),usage:P})}),r.stdin.write(u),r.stdin.end()})}s(L,"executeCodexEval");export{R as a,$ as b,A as c,L as d};
@@ -1,4 +1,4 @@
1
- import{b as $}from"./chunk-OP4U3XBZ.js";import{a as C}from"./chunk-KOYHJFB3.js";import{a as y}from"./chunk-DVU5PHPM.js";import{f}from"./chunk-FBSZ6KCM.js";import{e as h,f as w}from"./chunk-76UKAFNM.js";import{a as v}from"./chunk-ZLLER3HP.js";async function N(n,i,p){let{conversationId:a,messageId:g,messageContent:r}=n,o=await h(`/api/eval-targets/${i}`),c=await h(`/api/eval-targets/${i}/evals`),e=await h(`/api/eval-conversations/${a}/messages`),t=e.findIndex(l=>l.id===g);if(t>=0&&e.slice(t+1).some(u=>u.role==="assistant"&&(u.type==="results"||u.type==="proposal"||u.type==="generated"||u.type==="text"))){p(`Message ${g} already processed \u2014 skipping (idempotency guard)`);return}let s=v(async(l,u,m)=>{await w(`/api/eval-conversations/${a}/messages/assistant`,{content:l,type:u,data:m})},"postMessage"),d=await _(o,c,e,r,p);p(`Action: ${d.action}`);try{switch(d.action){case"run_evals":await x(o,c,a,s,p);break;case"generate_cases":await k(o,i,a,s,p);break;case"analyze_results":case"propose_changes":await E(o,c,e,r,a,s,p);break;case"respond":await s(d.response,"text");break}}catch(l){let u=l instanceof Error?l.message:String(l);throw await s(`Something went wrong: ${u}`,"text").catch(()=>{}),l}}v(N,"processConversationJob");async function _(n,i,p,a,g){let r=p.slice(-10).map(e=>`${e.role}: ${e.content.slice(0,200)}`).join(`
1
+ import{b as $}from"./chunk-HXOQUYG3.js";import{a as C}from"./chunk-PDXHRF4E.js";import{a as y}from"./chunk-FG343JM3.js";import{f}from"./chunk-4GOXEEXZ.js";import{e as h,f as w}from"./chunk-GIXHG5FK.js";import{a as v}from"./chunk-ZLLER3HP.js";async function N(n,i,p){let{conversationId:a,messageId:g,messageContent:r}=n,o=await h(`/api/eval-targets/${i}`),c=await h(`/api/eval-targets/${i}/evals`),e=await h(`/api/eval-conversations/${a}/messages`),t=e.findIndex(l=>l.id===g);if(t>=0&&e.slice(t+1).some(u=>u.role==="assistant"&&(u.type==="results"||u.type==="proposal"||u.type==="generated"||u.type==="text"))){p(`Message ${g} already processed \u2014 skipping (idempotency guard)`);return}let s=v(async(l,u,m)=>{await w(`/api/eval-conversations/${a}/messages/assistant`,{content:l,type:u,data:m})},"postMessage"),d=await _(o,c,e,r,p);p(`Action: ${d.action}`);try{switch(d.action){case"run_evals":await x(o,c,a,s,p);break;case"generate_cases":await k(o,i,a,s,p);break;case"analyze_results":case"propose_changes":await E(o,c,e,r,a,s,p);break;case"respond":await s(d.response,"text");break}}catch(l){let u=l instanceof Error?l.message:String(l);throw await s(`Something went wrong: ${u}`,"text").catch(()=>{}),l}}v(N,"processConversationJob");async function _(n,i,p,a,g){let r=p.slice(-10).map(e=>`${e.role}: ${e.content.slice(0,200)}`).join(`
2
2
  `),o=`You are an eval assistant. Decide what action to take based on the user's message.
3
3
 
4
4
  ## Current State
@@ -1 +1 @@
1
- import{a as G,c as I}from"./chunk-H6FVXVGG.js";import{f as j}from"./chunk-SWSOEYC7.js";import{a as R}from"./chunk-DVU5PHPM.js";import{b as U}from"./chunk-VBXL7XO7.js";import{f as A}from"./chunk-FBSZ6KCM.js";import{b as P,e as C,h as _}from"./chunk-76UKAFNM.js";import{a as x}from"./chunk-ZLLER3HP.js";var J=x(l=>l.summary.pass_rate===1?1:0,"fullPassScore");async function z(l,d={}){let $=d.executeEval??A,M=d.grade??R,q=d.getExperiment??(async o=>{try{return await C(`/api/memory-experiments/${o}`)}catch(e){if(e instanceof P&&e.statusCode===404)return null;throw e}}),B=d.getMemoryBody??(async o=>{try{let e=await C(`/api/memories/${o}`);return t?.memoryVersion!=null&&e.version!==t.memoryVersion?null:e.body}catch(e){if(e instanceof P&&e.statusCode===404)return null;throw e}}),p=d.updateExperiment??(async(o,e)=>{await _(`/api/memory-experiments/${o}`,e)}),t=await q(l.experimentId);if(!t)return{skipped:"not_found"};if(t.status==="completed"||t.status==="failed")return{skipped:"already_terminal",status:t.status};let E=t.memoryBody??await B(t.memoryId);if(E==null)return await p(t.id,{status:"failed",error:"memory no longer exists or its queued version is no longer available"}),{skipped:"memory_gone",status:"failed"};await p(t.id,{status:"running"});let v=t.expectations??[],c=t.model??void 0,i=t.engine??"claude",g=G({engine:i,model:c},{engine:l.graderEngine,model:l.graderModel}),f=x(async o=>{let e=(d.createWorkspace??j)({engine:i,targetType:"prompt",targetContent:o});try{if(e.leakedFiles.length)throw new Error("Contaminated memory trial workspace");return await $({prompt:t.taskPrompt,targetContent:e.systemPrompt,appendTarget:!0,ignoreContextFiles:!0,workDir:e.workDir,model:c,engine:i})}finally{e.cleanup()}},"executeArm"),s=[],u=new Set,b,k,m=[],w=0;try{if(l.measurement){let e=I(l);if(e.engine!==i||e.model!==c)throw new Error("Memory experiment differs from its queued measurement snapshot");g={engine:e.graderEngine,model:e.graderModel}}for(let e=0;e<t.trials;e++){let[r,n]=e%2===0?[await f(E),await f()]:await(async()=>{let y=await f();return[await f(E),y]})();if(r.error||n.error||r.exitCode!==0||n.exitCode!==0||!r.output.trim()||!n.output.trim()){w++,m.push({trial:e+1,reason:(r.error??n.error??"Nonzero exit or empty output").slice(0,500)});continue}if(r.engine!==i||n.engine!==i||!r.model||!n.model||r.model!==n.model||r.provider!==n.provider||r.model&&u.size>0&&!u.has(r.model)||i==="pi"&&c&&r.model!==`pi:${c}`){w++,m.push({trial:e+1,reason:"Harness, provider or model changed within the experiment"});continue}r.model&&u.add(r.model),n.model&&u.add(n.model);let[a,h]=await Promise.all([M({prompt:t.taskPrompt,output:r.output,expectations:v,...g}),M({prompt:t.taskPrompt,output:n.output,expectations:v,...g})]),T=JSON.stringify([a.judge_engine??null,a.judge_model??null]);if([a,h].some(y=>y.summary.pass_rate==null||y.summary.errored||y.summary.total!==v.length)||a.judge_model!==h.judge_model||a.judge_engine!==h.judge_engine||b!==void 0&&b!==T){w++,m.push({trial:e+1,reason:"Grading incomplete or judge changed; not a model failure"});continue}b=T,k={engine:a.judge_engine??null,model:a.judge_model??null},s.push({withScore:J(a),withoutScore:J(h),withLatency:r.durationMs/1e3,withoutLatency:n.durationMs/1e3,withTokens:r.totalTokens,withoutTokens:n.totalTokens,...r.costUsd!==void 0?{withCostUsd:r.costUsd}:{},...n.costUsd!==void 0?{withoutCostUsd:n.costUsd}:{}})}if(s.length===0){let e=`no trials completed (${w}/${t.trials} runs errored \u2014 is the ${i} CLI available?)`;return await p(t.id,{status:"failed",error:e,result:{pairs:s,excluded:m,completedTrials:0,engine:i}}),{status:"failed",requestedTrials:t.trials,completedTrials:0}}let o=U(s.map(e=>({...e,withCost:e.withCostUsd,withoutCost:e.withoutCostUsd})));return await p(t.id,{status:"completed",result:{verdict:o,pairs:s,excluded:m,judge:g,actualJudge:k,methodology:"v2-neutral-appended-memory",completedTrials:s.length,engine:i,model:[...u][0]}}),{status:"completed",requestedTrials:t.trials,completedTrials:s.length,significant:o.significant,delta:o.delta}}catch(o){let e=o instanceof Error?o.message:String(o);return await p(t.id,{status:"failed",error:e.slice(0,500),result:{pairs:s,excluded:m,completedTrials:s.length,engine:i,model:[...u][0]??null,judge:g,actualJudge:k,methodology:"v2-neutral-appended-memory"}}).catch(()=>{}),{status:"failed",requestedTrials:t.trials,completedTrials:s.length}}}x(z,"processMemoryAb");export{z as a};
1
+ import{a as G,c as I}from"./chunk-FADINV4H.js";import{f as j}from"./chunk-SWSOEYC7.js";import{a as R}from"./chunk-FG343JM3.js";import{b as U}from"./chunk-HT6R6KR3.js";import{f as A}from"./chunk-4GOXEEXZ.js";import{b as P,e as C,h as _}from"./chunk-GIXHG5FK.js";import{a as x}from"./chunk-ZLLER3HP.js";var J=x(l=>l.summary.pass_rate===1?1:0,"fullPassScore");async function z(l,d={}){let $=d.executeEval??A,M=d.grade??R,q=d.getExperiment??(async o=>{try{return await C(`/api/memory-experiments/${o}`)}catch(e){if(e instanceof P&&e.statusCode===404)return null;throw e}}),B=d.getMemoryBody??(async o=>{try{let e=await C(`/api/memories/${o}`);return t?.memoryVersion!=null&&e.version!==t.memoryVersion?null:e.body}catch(e){if(e instanceof P&&e.statusCode===404)return null;throw e}}),p=d.updateExperiment??(async(o,e)=>{await _(`/api/memory-experiments/${o}`,e)}),t=await q(l.experimentId);if(!t)return{skipped:"not_found"};if(t.status==="completed"||t.status==="failed")return{skipped:"already_terminal",status:t.status};let E=t.memoryBody??await B(t.memoryId);if(E==null)return await p(t.id,{status:"failed",error:"memory no longer exists or its queued version is no longer available"}),{skipped:"memory_gone",status:"failed"};await p(t.id,{status:"running"});let v=t.expectations??[],c=t.model??void 0,i=t.engine??"claude",g=G({engine:i,model:c},{engine:l.graderEngine,model:l.graderModel}),f=x(async o=>{let e=(d.createWorkspace??j)({engine:i,targetType:"prompt",targetContent:o});try{if(e.leakedFiles.length)throw new Error("Contaminated memory trial workspace");return await $({prompt:t.taskPrompt,targetContent:e.systemPrompt,appendTarget:!0,ignoreContextFiles:!0,workDir:e.workDir,model:c,engine:i})}finally{e.cleanup()}},"executeArm"),s=[],u=new Set,b,k,m=[],w=0;try{if(l.measurement){let e=I(l);if(e.engine!==i||e.model!==c)throw new Error("Memory experiment differs from its queued measurement snapshot");g={engine:e.graderEngine,model:e.graderModel}}for(let e=0;e<t.trials;e++){let[r,n]=e%2===0?[await f(E),await f()]:await(async()=>{let y=await f();return[await f(E),y]})();if(r.error||n.error||r.exitCode!==0||n.exitCode!==0||!r.output.trim()||!n.output.trim()){w++,m.push({trial:e+1,reason:(r.error??n.error??"Nonzero exit or empty output").slice(0,500)});continue}if(r.engine!==i||n.engine!==i||!r.model||!n.model||r.model!==n.model||r.provider!==n.provider||r.model&&u.size>0&&!u.has(r.model)||i==="pi"&&c&&r.model!==`pi:${c}`){w++,m.push({trial:e+1,reason:"Harness, provider or model changed within the experiment"});continue}r.model&&u.add(r.model),n.model&&u.add(n.model);let[a,h]=await Promise.all([M({prompt:t.taskPrompt,output:r.output,expectations:v,...g}),M({prompt:t.taskPrompt,output:n.output,expectations:v,...g})]),T=JSON.stringify([a.judge_engine??null,a.judge_model??null]);if([a,h].some(y=>y.summary.pass_rate==null||y.summary.errored||y.summary.total!==v.length)||a.judge_model!==h.judge_model||a.judge_engine!==h.judge_engine||b!==void 0&&b!==T){w++,m.push({trial:e+1,reason:"Grading incomplete or judge changed; not a model failure"});continue}b=T,k={engine:a.judge_engine??null,model:a.judge_model??null},s.push({withScore:J(a),withoutScore:J(h),withLatency:r.durationMs/1e3,withoutLatency:n.durationMs/1e3,withTokens:r.totalTokens,withoutTokens:n.totalTokens,...r.costUsd!==void 0?{withCostUsd:r.costUsd}:{},...n.costUsd!==void 0?{withoutCostUsd:n.costUsd}:{}})}if(s.length===0){let e=`no trials completed (${w}/${t.trials} runs errored \u2014 is the ${i} CLI available?)`;return await p(t.id,{status:"failed",error:e,result:{pairs:s,excluded:m,completedTrials:0,engine:i}}),{status:"failed",requestedTrials:t.trials,completedTrials:0}}let o=U(s.map(e=>({...e,withCost:e.withCostUsd,withoutCost:e.withoutCostUsd})));return await p(t.id,{status:"completed",result:{verdict:o,pairs:s,excluded:m,judge:g,actualJudge:k,methodology:"v2-neutral-appended-memory",completedTrials:s.length,engine:i,model:[...u][0]}}),{status:"completed",requestedTrials:t.trials,completedTrials:s.length,significant:o.significant,delta:o.delta}}catch(o){let e=o instanceof Error?o.message:String(o);return await p(t.id,{status:"failed",error:e.slice(0,500),result:{pairs:s,excluded:m,completedTrials:s.length,engine:i,model:[...u][0]??null,judge:g,actualJudge:k,methodology:"v2-neutral-appended-memory"}}).catch(()=>{}),{status:"failed",requestedTrials:t.trials,completedTrials:s.length}}}x(z,"processMemoryAb");export{z as a};
@@ -0,0 +1 @@
1
+ import{a as i}from"./chunk-ZLLER3HP.js";import{mkdirSync as y,writeFileSync as p,readFileSync as u,existsSync as a,lstatSync as m,statSync as g}from"node:fs";import{dirname as h,join as x}from"node:path";import{createHash as S}from"node:crypto";var l=i(t=>S("sha256").update(JSON.stringify(t)).digest("hex"),"fixtureHash");function c(t,e){if(e.startsWith("/")||e.includes("\\")||e.split("/").some(r=>!r||r===".."||r==="."))throw new Error("Unsafe fixture path");let n=t;for(let r of e.split("/")){n=x(n,r);try{if(m(n).isSymbolicLink())throw new Error("Fixture path is a symlink")}catch(o){if(o.code!=="ENOENT")throw o}}return n}i(c,"safePath");function E(t,e){for(let n of e){let r=c(t,n.path);y(h(r),{recursive:!0}),p(r,n.content)}}i(E,"installFixture");function O(t,e){let n=e.checks.map(r=>{let o=null,s=!1;try{let f=c(t,r.path);r.kind==="file_absent"?s=!a(f):a(f)&&g(f).size<=2e5&&(o=u(f,"utf8"),s=r.kind==="text_equals"?o===r.expected:d(JSON.parse(o),JSON.parse(r.expected)))}catch{s=!1}return{name:r.name,passed:s,actual:o}});return{checks:n,primaryPassed:n.every((r,o)=>!e.checks[o].primary||r.passed),safeguardsPassed:n.every((r,o)=>e.checks[o].primary||r.passed)}}i(O,"checkFixture");function d(t,e){if(t===e)return!0;if(!t||!e||typeof t!="object"||typeof e!="object"||Array.isArray(t)!==Array.isArray(e))return!1;let n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(o=>Object.prototype.hasOwnProperty.call(e,o)&&d(t[o],e[o]))}i(d,"equalJson");function b(t,e){return e.error?e.error:e.engine!==t.scope.engine?"Observed engine differs from protocol":e.engine==="codex"?"Codex model provenance is requested-only; confirmatory inference refused":e.model!==t.scope.model?"Observed model differs from protocol or is unknown":null}i(b,"studyExclusion");function A(t,e,n,r){for(let f of[...e.files,...n.files])if(u(c(t,f.path),"utf8")!==f.content)throw new Error("Installed fixture differs from frozen bytes");let o=c(t,r==="claude"?"CLAUDE.md":"AGENTS.md"),s=a(o)?u(o,"utf8"):"";if(s!==n.content)throw new Error("Delivered instruction differs from frozen bytes");return{deliveryHash:l({...n,content:s}),fixtureHash:l(e.files)}}i(A,"verifyFixtureDelivery");export{l as a,E as b,O as c,b as d,A as e};
@@ -1 +1 @@
1
- import{b as u,c as d}from"./chunk-MXHAXY66.js";import{b as g}from"./chunk-OP4U3XBZ.js";import{e as m,f as p,h as l}from"./chunk-76UKAFNM.js";import{a as s}from"./chunk-ZLLER3HP.js";async function x(f,R){let r=s(e=>R?.logger?.info?.(e)??console.log(e),"log"),{evalTargetId:n}=f,i=`[cron_refine_cases] ${n}`,t=await m(`/api/eval-targets/${n}`);if(!(t.metadata?.autoRefineCases===!0))return r(`${i} not opted in (metadata.autoRefineCases)`),{skipped:"not-opted-in",reason:`"${t.name}" has not opted into automatic case refinement. Set metadata.autoRefineCases=true to let the loop cull cases that carry no treatment signal, or run \`rulemetric evals refine-cases ${n}\` by hand.`,targetName:t.name};let C=await m(`/api/eval-targets/${n}/judge-calibration`),a=u(C.caseDiscrimination);if(a.refused)return r(`${i} ${a.refused}: ${a.summary}`),{skipped:a.refused,reason:a.summary,targetName:t.name};r(`${i} ${a.summary}`);let o=await d(a,{generate:s(e=>g({content:t.content,name:t.name,feedback:e}),"generate"),createCase:s(e=>p(`/api/eval-targets/${n}/evals`,{name:e.name,prompt:e.prompt,expectations:e.expectations}),"createCase"),retireCase:s(async(e,y)=>{await l(`/api/eval-targets/${n}/evals/${e}`,{retire:!0,retiredReason:y})},"retireCase"),log:r});r(`${i} ${o.summary}`);let{skipped:c,...$}=o;return{...$,targetName:t.name,...c?{skipped:c,reason:o.summary}:{}}}s(x,"cronRefineCases");export{x as a};
1
+ import{b as u,c as d}from"./chunk-EJY5GK6A.js";import{b as g}from"./chunk-HXOQUYG3.js";import{e as m,f as p,h as l}from"./chunk-GIXHG5FK.js";import{a as s}from"./chunk-ZLLER3HP.js";async function x(f,R){let r=s(e=>R?.logger?.info?.(e)??console.log(e),"log"),{evalTargetId:n}=f,i=`[cron_refine_cases] ${n}`,t=await m(`/api/eval-targets/${n}`);if(!(t.metadata?.autoRefineCases===!0))return r(`${i} not opted in (metadata.autoRefineCases)`),{skipped:"not-opted-in",reason:`"${t.name}" has not opted into automatic case refinement. Set metadata.autoRefineCases=true to let the loop cull cases that carry no treatment signal, or run \`rulemetric evals refine-cases ${n}\` by hand.`,targetName:t.name};let C=await m(`/api/eval-targets/${n}/judge-calibration`),a=u(C.caseDiscrimination);if(a.refused)return r(`${i} ${a.refused}: ${a.summary}`),{skipped:a.refused,reason:a.summary,targetName:t.name};r(`${i} ${a.summary}`);let o=await d(a,{generate:s(e=>g({content:t.content,name:t.name,feedback:e}),"generate"),createCase:s(e=>p(`/api/eval-targets/${n}/evals`,{name:e.name,prompt:e.prompt,expectations:e.expectations}),"createCase"),retireCase:s(async(e,y)=>{await l(`/api/eval-targets/${n}/evals/${e}`,{retire:!0,retiredReason:y})},"retireCase"),log:r});r(`${i} ${o.summary}`);let{skipped:c,...$}=o;return{...$,targetName:t.name,...c?{skipped:c,reason:o.summary}:{}}}s(x,"cronRefineCases");export{x as a};
@@ -1 +1 @@
1
- import{f as u}from"./chunk-76UKAFNM.js";import{a as m}from"./chunk-ZLLER3HP.js";async function p(n,a,s){if(a)try{let t=Array.isArray(n.recommendation_candidates)?n.recommendation_candidates.filter(e=>typeof e.title=="string"&&typeof e.artifact=="string"&&typeof e.canonicalBody=="string"&&e.canonicalBody.trim().length>=12).map(e=>({title:String(e.title).trim(),artifact:String(e.artifact),canonicalBody:String(e.canonicalBody).trim(),rationale:String(e.rationale??""),evidence:Array.isArray(e.evidence)?e.evidence:[],outcomeMetric:String(e.outcomeMetric??"session_outcome"),renderings:Array.isArray(e.renderings)?e.renderings:[]})):[],i=n.suggestions,l=Array.isArray(i?.claude_md_additions)?i.claude_md_additions.filter(e=>typeof e?.addition=="string"&&e.addition.trim().length>=12).map(e=>({addition:String(e.addition).trim(),why:String(e.why??"")})):[],d=Array.isArray(n.recommended_skills)?n.recommended_skills.filter(e=>typeof e?.skillId=="string"&&e.skillId.length>0).map(e=>({skillId:String(e.skillId),reason:String(e.reason??"")})):[],g=Array.isArray(i?.features_to_try)?i.features_to_try.filter(e=>typeof e?.feature=="string"&&e.feature.trim().length>=2).map(e=>({feature:String(e.feature).trim(),one_liner:String(e.one_liner??""),why_for_you:String(e.why_for_you??""),example_code:String(e.example_code??"")})):[],c=[...Array.isArray(i?.usage_patterns)?i.usage_patterns.map(e=>({title:String(e.title??"").trim(),lead:String(e.suggestion??""),detail:String(e.detail??""),copyable_prompt:String(e.copyable_prompt??""),origin:"usage_pattern"})):[],...Array.isArray(n.on_the_horizon?.opportunities)?n.on_the_horizon.opportunities.map(e=>({title:String(e.title??"").trim(),lead:String(e.whats_possible??""),detail:String(e.how_to_try??""),copyable_prompt:String(e.copyable_prompt??""),origin:"opportunity"})):[]].filter(e=>e.title.length>=2);if(t.length===0&&l.length===0&&d.length===0&&g.length===0&&c.length===0)return;let r=await u("/api/insights/recommendations/nominate",{projectPath:a,candidates:t.slice(0,40),additions:l.slice(0,20),skills:d.slice(0,20),features:g.slice(0,20),advice:c.slice(0,40)}),o=r.additionsRejected??[];s(` ${r.nominated} recommendation(s) nominated into the suggestion feed (${r.additionsCreated} new instruction(s)`+((r.featuresCreated??0)>0?`, ${r.featuresCreated} feature proposal(s)`:"")+((r.adviceCreated??0)>0?`, ${r.adviceCreated} pattern/opportunity`:"")+(r.skillsUnresolved>0?`, ${r.skillsUnresolved} skill slug(s) unresolved`:"")+(o.length>0?`, ${o.length} rejected as unfilled templates`:"")+")");for(let e of o)s(` rejected "${e.name}" \u2014 unfilled placeholder(s): ${e.placeholders.join(", ")}`);for(let e of r.itemsFailed??[])s(` failed "${e.name}" \u2014 ${e.error}`)}catch(t){s(` nomination skipped (whole batch): ${t instanceof Error?t.message:String(t)}`)}}m(p,"nominateRecommendations");export{p as a};
1
+ import{f as u}from"./chunk-GIXHG5FK.js";import{a as m}from"./chunk-ZLLER3HP.js";async function p(n,a,s){if(a)try{let t=Array.isArray(n.recommendation_candidates)?n.recommendation_candidates.filter(e=>typeof e.title=="string"&&typeof e.artifact=="string"&&typeof e.canonicalBody=="string"&&e.canonicalBody.trim().length>=12).map(e=>({title:String(e.title).trim(),artifact:String(e.artifact),canonicalBody:String(e.canonicalBody).trim(),rationale:String(e.rationale??""),evidence:Array.isArray(e.evidence)?e.evidence:[],outcomeMetric:String(e.outcomeMetric??"session_outcome"),renderings:Array.isArray(e.renderings)?e.renderings:[]})):[],i=n.suggestions,l=Array.isArray(i?.claude_md_additions)?i.claude_md_additions.filter(e=>typeof e?.addition=="string"&&e.addition.trim().length>=12).map(e=>({addition:String(e.addition).trim(),why:String(e.why??"")})):[],d=Array.isArray(n.recommended_skills)?n.recommended_skills.filter(e=>typeof e?.skillId=="string"&&e.skillId.length>0).map(e=>({skillId:String(e.skillId),reason:String(e.reason??"")})):[],g=Array.isArray(i?.features_to_try)?i.features_to_try.filter(e=>typeof e?.feature=="string"&&e.feature.trim().length>=2).map(e=>({feature:String(e.feature).trim(),one_liner:String(e.one_liner??""),why_for_you:String(e.why_for_you??""),example_code:String(e.example_code??"")})):[],c=[...Array.isArray(i?.usage_patterns)?i.usage_patterns.map(e=>({title:String(e.title??"").trim(),lead:String(e.suggestion??""),detail:String(e.detail??""),copyable_prompt:String(e.copyable_prompt??""),origin:"usage_pattern"})):[],...Array.isArray(n.on_the_horizon?.opportunities)?n.on_the_horizon.opportunities.map(e=>({title:String(e.title??"").trim(),lead:String(e.whats_possible??""),detail:String(e.how_to_try??""),copyable_prompt:String(e.copyable_prompt??""),origin:"opportunity"})):[]].filter(e=>e.title.length>=2);if(t.length===0&&l.length===0&&d.length===0&&g.length===0&&c.length===0)return;let r=await u("/api/insights/recommendations/nominate",{projectPath:a,candidates:t.slice(0,40),additions:l.slice(0,20),skills:d.slice(0,20),features:g.slice(0,20),advice:c.slice(0,40)}),o=r.additionsRejected??[];s(` ${r.nominated} recommendation(s) nominated into the suggestion feed (${r.additionsCreated} new instruction(s)`+((r.featuresCreated??0)>0?`, ${r.featuresCreated} feature proposal(s)`:"")+((r.adviceCreated??0)>0?`, ${r.adviceCreated} pattern/opportunity`:"")+(r.skillsUnresolved>0?`, ${r.skillsUnresolved} skill slug(s) unresolved`:"")+(o.length>0?`, ${o.length} rejected as unfilled templates`:"")+")");for(let e of o)s(` rejected "${e.name}" \u2014 unfilled placeholder(s): ${e.placeholders.join(", ")}`);for(let e of r.itemsFailed??[])s(` failed "${e.name}" \u2014 ${e.error}`)}catch(t){s(` nomination skipped (whole batch): ${t instanceof Error?t.message:String(t)}`)}}m(p,"nominateRecommendations");export{p as a};
@@ -1 +1 @@
1
- import{c as l}from"./chunk-76UKAFNM.js";import{c as a,l as u}from"./chunk-PZNWH4VQ.js";import{a as o}from"./chunk-ZLLER3HP.js";var c=120*1e3,t=null;async function k(){if(process.env.RULEMETRIC_API_KEY)return!0;let e=a(u());if(!e.isRefreshable(c))return!0;let r=e.loadToken();return r?.refreshToken?t||(t=f(e,r).finally(()=>{t=null}),t):!0}o(k,"ensureFreshToken");async function f(e,r){let s;try{s=await fetch(`${l()}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:r.refreshToken})})}catch{return!0}if(s.status===401)return e.clearToken(),!1;if(!s.ok)return!0;let n=await s.json().catch(()=>null);if(!n?.accessToken||!n.refreshToken)return!0;let i={accessToken:n.accessToken,refreshToken:n.refreshToken,expiresAt:n.expiresAt??r.expiresAt,email:n.email??r.email};return e.saveToken(i),e.saveEnvFile(i.accessToken),!0}o(f,"doRefresh");export{k as a};
1
+ import{c as l}from"./chunk-GIXHG5FK.js";import{c as a,l as u}from"./chunk-PZNWH4VQ.js";import{a as o}from"./chunk-ZLLER3HP.js";var c=120*1e3,t=null;async function k(){if(process.env.RULEMETRIC_API_KEY)return!0;let e=a(u());if(!e.isRefreshable(c))return!0;let r=e.loadToken();return r?.refreshToken?t||(t=f(e,r).finally(()=>{t=null}),t):!0}o(k,"ensureFreshToken");async function f(e,r){let s;try{s=await fetch(`${l()}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:r.refreshToken})})}catch{return!0}if(s.status===401)return e.clearToken(),!1;if(!s.ok)return!0;let n=await s.json().catch(()=>null);if(!n?.accessToken||!n.refreshToken)return!0;let i={accessToken:n.accessToken,refreshToken:n.refreshToken,expiresAt:n.expiresAt??r.expiresAt,email:n.email??r.email};return e.saveToken(i),e.saveEnvFile(i.accessToken),!0}o(f,"doRefresh");export{k as a};
@@ -1,4 +1,4 @@
1
- import{f as u}from"./chunk-FBSZ6KCM.js";import{a as o}from"./chunk-ZLLER3HP.js";var l=`You are a meta-judge evaluating the quality of an eval run \u2014 not the code output, but whether the test cases and grading themselves are rigorous and meaningful.
1
+ import{f as u}from"./chunk-4GOXEEXZ.js";import{a as o}from"./chunk-ZLLER3HP.js";var l=`You are a meta-judge evaluating the quality of an eval run \u2014 not the code output, but whether the test cases and grading themselves are rigorous and meaningful.
2
2
 
3
3
  You will receive a summary of eval cases, their expectations, and grading results.
4
4
 
@@ -1 +1 @@
1
- import{e as c,f as d}from"./chunk-76UKAFNM.js";import{a as m}from"./chunk-ZLLER3HP.js";async function f(g,p){let r=m(e=>p?.logger?.info?.(e)??console.log(e),"log"),{projectPath:s}=g,i=`[cron_instruction_training] ${s}`;if(!s)return{skipped:"no-project-path"};let n=await d("/api/instruction-experiments/settle",{projectPath:s}),o=n.settled.map(e=>e.outcome),a=o.filter(e=>e==="graduated").length;for(let e of n.settled)r(`${i}: experiment ${e.experimentId} \u2192 ${e.outcome}`);n.examined>0&&r(`${i}: examined ${n.examined} running experiment(s) \u2014 ${n.settled.length} settled (${a} graduated), ${n.stillRunning} still gathering`);let t=await c(`/api/instruction-suggestions/trialable?projectPath=${encodeURIComponent(s)}`);for(let e of t.refused)r(`${i}: not trialling "${e.name}" \u2014 ${e.reason}`);if(t.candidates.length===0)return r(`${i}: no new trial started (${t.running}/${t.limits.maxConcurrent} running, ${t.slots} slot(s) free)`),{examined:n.examined,settled:n.settled.length,graduated:a,nominated:0,running:t.running,outcomes:o};let u=0;for(let e of t.candidates)try{await d("/api/instruction-experiments",{instructionId:e.instructionId,projectPath:s,source:"trial"}),u+=1,r(`${i}: now measuring "${e.name}" (score ${e.score.toFixed(2)})`)}catch(l){r(`${i}: could not measure "${e.name}" \u2014 ${l instanceof Error?l.message:String(l)}`)}return{examined:n.examined,settled:n.settled.length,graduated:a,nominated:u,running:t.running+u,outcomes:o}}m(f,"cronInstructionTraining");export{f as a};
1
+ import{e as c,f as d}from"./chunk-GIXHG5FK.js";import{a as m}from"./chunk-ZLLER3HP.js";async function f(g,p){let r=m(e=>p?.logger?.info?.(e)??console.log(e),"log"),{projectPath:s}=g,i=`[cron_instruction_training] ${s}`;if(!s)return{skipped:"no-project-path"};let n=await d("/api/instruction-experiments/settle",{projectPath:s}),o=n.settled.map(e=>e.outcome),a=o.filter(e=>e==="graduated").length;for(let e of n.settled)r(`${i}: experiment ${e.experimentId} \u2192 ${e.outcome}`);n.examined>0&&r(`${i}: examined ${n.examined} running experiment(s) \u2014 ${n.settled.length} settled (${a} graduated), ${n.stillRunning} still gathering`);let t=await c(`/api/instruction-suggestions/trialable?projectPath=${encodeURIComponent(s)}`);for(let e of t.refused)r(`${i}: not trialling "${e.name}" \u2014 ${e.reason}`);if(t.candidates.length===0)return r(`${i}: no new trial started (${t.running}/${t.limits.maxConcurrent} running, ${t.slots} slot(s) free)`),{examined:n.examined,settled:n.settled.length,graduated:a,nominated:0,running:t.running,outcomes:o};let u=0;for(let e of t.candidates)try{await d("/api/instruction-experiments",{instructionId:e.instructionId,projectPath:s,source:"trial"}),u+=1,r(`${i}: now measuring "${e.name}" (score ${e.score.toFixed(2)})`)}catch(l){r(`${i}: could not measure "${e.name}" \u2014 ${l instanceof Error?l.message:String(l)}`)}return{examined:n.examined,settled:n.settled.length,graduated:a,nominated:u,running:t.running+u,outcomes:o}}m(f,"cronInstructionTraining");export{f as a};
@@ -1 +1 @@
1
- import{d as h,e as g}from"./chunk-SCQK52SL.js";import{e as p,g as f}from"./chunk-76UKAFNM.js";import{a as o}from"./chunk-ZLLER3HP.js";var u="openCandidate";function K(n,s,a){let t=(n??{})[u];if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return e.executionKey!==a||typeof e.content!="string"||!e.content||typeof e.hash!="string"||!e.hash||typeof e.priorHash!="string"||e.priorHash!==s?null:{...a?{executionKey:a}:{},...typeof e.observedKey=="string"?{observedKey:e.observedKey}:{},content:e.content,hash:e.hash,priorHash:e.priorHash,plannedPairs:typeof e.plannedPairs=="number"?e.plannedPairs:0,updatedAt:typeof e.updatedAt=="string"?e.updatedAt:""}}o(K,"resolveOpenCandidate");function C(n){let{plannedPairs:s,carriedPairs:a,liveCases:t}=n;if(t<=0)return 0;let e=s-a;return e<=0?0:Math.ceil(e/t)}o(C,"owedPasses");var d=100;async function x(n){let{evalTargetId:s,candidateContentHash:a}=n,t=[];for(let e=0;;e+=d){let i=await p(`/api/eval-targets/${s}/runs?candidateContentHash=${encodeURIComponent(a)}&limit=${d}&offset=${e}`);if(!Array.isArray(i)||i.length===0||(t.push(...i.filter(r=>{if(r.outputs?.executionKey!==n.executionKey)return!1;if(!n.executionKey)return!0;if(!n.observedKey)return!1;let l=h([r]);if(!l)return!1;let[y,c]=JSON.parse(l),[b,m]=JSON.parse(n.observedKey);return y===b&&(c===null||c===m)})),i.length<d))break}return g(t)}o(x,"fetchCarriedPairs");async function A(n){let{evalTargetId:s,meta:a,blob:t,log:e,tag:i}=n;try{let r={...a};t?r[u]=t:delete r[u],await f(`/api/eval-targets/${s}`,{metadata:r}),e(t?`${i}: banked candidate ${t.hash.slice(0,8)} \u2014 the next run resumes instead of restarting`:`${i}: cleared the banked candidate (this cycle reached a decision)`)}catch(r){e(`${i}: could not update the candidate bank (${r instanceof Error?r.message:String(r)})`)}}o(A,"bankOpenCandidate");function O(n){return{...n.executionKey?{executionKey:n.executionKey}:{},...n.observedKey?{observedKey:n.observedKey}:{},content:n.content,hash:n.hash,priorHash:n.priorHash,plannedPairs:n.plannedPairs,updatedAt:n.now.toISOString()}}o(O,"buildOpenCandidate");export{u as a,K as b,C as c,x as d,A as e,O as f};
1
+ import{d as h,e as g}from"./chunk-YXMAGC53.js";import{e as p,g as f}from"./chunk-GIXHG5FK.js";import{a as o}from"./chunk-ZLLER3HP.js";var u="openCandidate";function K(n,s,a){let t=(n??{})[u];if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return e.executionKey!==a||typeof e.content!="string"||!e.content||typeof e.hash!="string"||!e.hash||typeof e.priorHash!="string"||e.priorHash!==s?null:{...a?{executionKey:a}:{},...typeof e.observedKey=="string"?{observedKey:e.observedKey}:{},content:e.content,hash:e.hash,priorHash:e.priorHash,plannedPairs:typeof e.plannedPairs=="number"?e.plannedPairs:0,updatedAt:typeof e.updatedAt=="string"?e.updatedAt:""}}o(K,"resolveOpenCandidate");function C(n){let{plannedPairs:s,carriedPairs:a,liveCases:t}=n;if(t<=0)return 0;let e=s-a;return e<=0?0:Math.ceil(e/t)}o(C,"owedPasses");var d=100;async function x(n){let{evalTargetId:s,candidateContentHash:a}=n,t=[];for(let e=0;;e+=d){let i=await p(`/api/eval-targets/${s}/runs?candidateContentHash=${encodeURIComponent(a)}&limit=${d}&offset=${e}`);if(!Array.isArray(i)||i.length===0||(t.push(...i.filter(r=>{if(r.outputs?.executionKey!==n.executionKey)return!1;if(!n.executionKey)return!0;if(!n.observedKey)return!1;let l=h([r]);if(!l)return!1;let[y,c]=JSON.parse(l),[b,m]=JSON.parse(n.observedKey);return y===b&&(c===null||c===m)})),i.length<d))break}return g(t)}o(x,"fetchCarriedPairs");async function A(n){let{evalTargetId:s,meta:a,blob:t,log:e,tag:i}=n;try{let r={...a};t?r[u]=t:delete r[u],await f(`/api/eval-targets/${s}`,{metadata:r}),e(t?`${i}: banked candidate ${t.hash.slice(0,8)} \u2014 the next run resumes instead of restarting`:`${i}: cleared the banked candidate (this cycle reached a decision)`)}catch(r){e(`${i}: could not update the candidate bank (${r instanceof Error?r.message:String(r)})`)}}o(A,"bankOpenCandidate");function O(n){return{...n.executionKey?{executionKey:n.executionKey}:{},...n.observedKey?{observedKey:n.observedKey}:{},content:n.content,hash:n.hash,priorHash:n.priorHash,plannedPairs:n.plannedPairs,updatedAt:n.now.toISOString()}}o(O,"buildOpenCandidate");export{u as a,K as b,C as c,x as d,A as e,O as f};
@@ -1 +1 @@
1
- import{a as i}from"./chunk-MMLRWCBW.js";import{h as s}from"./chunk-76UKAFNM.js";import{a as n}from"./chunk-ZLLER3HP.js";async function l(a,c){let{mirrorId:g,evalTargetId:p,config:r}=a,e=n(o=>c.logger.info(o),"log");await i(r,p,e);let t={type:"conversation",conversationId:r.conversationId};return await s(`/api/eval-jobs/${g}/state`,{result:t}).catch(o=>{e(`result persist failed: ${o instanceof Error?o.message:String(o)}`)}),t}n(l,"processConversation");export{l as a};
1
+ import{a as i}from"./chunk-JOXTWLLK.js";import{h as s}from"./chunk-GIXHG5FK.js";import{a as n}from"./chunk-ZLLER3HP.js";async function l(a,c){let{mirrorId:g,evalTargetId:p,config:r}=a,e=n(o=>c.logger.info(o),"log");await i(r,p,e);let t={type:"conversation",conversationId:r.conversationId};return await s(`/api/eval-jobs/${g}/state`,{result:t}).catch(o=>{e(`result persist failed: ${o instanceof Error?o.message:String(o)}`)}),t}n(l,"processConversation");export{l as a};
@@ -0,0 +1 @@
1
+ import{a as l}from"./chunk-ZLLER3HP.js";var x=25;function w(e,r,n=1.959964){let s=1+n*n/r,c=(e+n*n/(2*r))/s,d=n*Math.sqrt(e*(1-e)/r+n*n/(4*r*r))/s;return[c-d,c+d]}l(w,"wilson");function g(e,r,n,s){let[c,d]=w(e,r),[u,t]=w(n,s);return[u-d,t-c]}l(g,"newcombe");var p=l(e=>`${e>=0?"+":""}${e.toFixed(3)}`,"fmt"),f=l(e=>`${e.passes}/${e.n}`,"counts");function _(e){let r=e.provenance;if(!r)return{decisionSemanticsVersion:2,decision:"incomparable",reason:"harness provenance was not checked; no instruction-effect claim is supported",reward:{delta:null,ci:null}};if(!r.comparable)return{decisionSemanticsVersion:2,decision:"incomparable",reason:`the two arms were not the same harness, so this is not an A/B of the rule: ${r.reasons.join("; ")}. Nothing here is evidence about the instruction \u2014 re-run both arms on one harness before reading anything into the numbers.`,reward:{delta:null,ci:null}};let n={...v(e),decisionSemanticsVersion:2};return r?.pooled_across.length?{...n,reason:`${n.reason} [pooled across ${r.pooled_across.join(", ")} by explicit --allow-cross]`}:n}l(_,"judgeSweep");function v(e){let r=e.minN??25,{baseline:n,with:s}=e;if(n.passes==null||s.passes==null||n.n===0||s.n===0)return{decision:"unmeasured",reason:`no reward recorded for the ${[n.passes==null||n.n===0?"baseline":null,s.passes==null||s.n===0?"with-arm":null].filter(Boolean).join(" and ")} arm \u2014 nothing to decide on; check the job dir for a harness error before reading this as a result`,reward:{delta:null,ci:null}};let c=n.passes/n.n,d=s.passes/s.n,u=d-c,t=g(c,n.n,d,s.n),$=t[0]>0||t[1]<0,m=n.n<r||s.n<r,o=`baseline ${f(n)} \u2192 with ${f(s)}, delta ${p(u)}, 95% CI [${p(t[0])}, ${p(t[1])}]`,i={delta:u,ci:t},b=m?` (n=${n.n}/${s.n}, below the ${r}/arm floor)`:"";if(e.taskClass==="unvalidated")return{decision:m?"undecided":"measured",reason:`calibration on an unvalidated engine/model${b}: ${o}. No regression or graduation claim against another model's catalogue.`,reward:i};if(m)return{decision:"undecided",reason:`calibration below the decision floor${b}: ${o}`,reward:i};if(t[1]<0)return{decision:"reward_harm",reason:`lower reward in this comparison: ${o}. This is not a between-period regression test.`,reward:i};if(e.taskClass==="proven"&&e.axis==="reward")return t[0]>0?{decision:"holds",reason:`calibration effect reproduced on this fixture: ${o}. This does not establish representative project improvement.`,reward:i}:{decision:"replication_alert",reason:`prior calibration effect did not reproduce: ${o}. Investigate the rule, model and harness; a valid between-period comparison is required to establish regression. The interval does not establish equivalence.`,reward:i};let a=e.cost;if(e.axis==="cost"&&!a)return{decision:"unmeasured",reason:`no per-trial cost measured \u2014 cost is UNKNOWN, not $0 (${o})`,reward:i};if(a&&a.decision!=="undecided"){let h=`cost ${a.delta_pct==null?"n/a":`${a.delta_pct>=0?"+":""}${a.delta_pct.toFixed(1)}%`}/trial, 95% CI [${a.ci_usd[0].toFixed(4)}, ${a.ci_usd[1].toFixed(4)}] USD`;return{decision:"cost_signal",reason:`${a.decision} in this comparison: ${h}; reward ${o}. ${a.reward.regressed?"The with-arm solved LESS in the observed sample. ":""}Reliability noninferiority is unestablished: no margin was declared. No performance-adoption claim.`,reward:i}}return e.taskClass==="proven"&&e.axis==="cost"?{decision:"replication_alert",reason:`prior cost saving did not reproduce; cost interval includes zero; reward ${o}. No between-period regression or reward-equivalence claim.`,reward:i}:$?{decision:"now_discriminates",reason:`exploratory calibration finding: ${o}. Validate on frozen tasks before making an improvement claim.`,reward:i}:{decision:"inconclusive",reason:`interval includes zero: ${o}. Neither equivalence nor absence of useful effect is established.`,reward:i}}l(v,"judgeMeasured");export{x as a,w as b,g as c,_ as d};
@@ -1 +1 @@
1
- import{d as w}from"./chunk-NJ5UED3H.js";import{c as $,d as p}from"./chunk-76UKAFNM.js";import{a as H,b as k,c as U,d as L,e as O}from"./chunk-XQYAVSUQ.js";import{a as g}from"./chunk-ZLLER3HP.js";import{useCallback as D,useEffect as G,useRef as y,useState as u}from"react";import{Box as q,Text as r,useInput as N}from"ink";import W from"ink-select-input";import X from"ink-text-input";import{spawn as z}from"node:child_process";import{Fragment as T,jsx as s,jsxs as i}from"react/jsx-runtime";function se({width:_,onClose:S}){let[M,j]=u([]),[c,m]=u("status"),[b,A]=u(null),[R,C]=u(""),[E,o]=u(""),[d,P]=u(!1),h=y(!1),v=y(!1),f=y(!0),l=D(async()=>{if(h.current){v.current=!0;return}h.current=!0;try{let t=await Promise.allSettled([p("/api/settings/measurement",{timeoutMs:5e3}).then(e=>L(k.parse(e))),p("/api/settings/harbor",{timeoutMs:5e3}).then(e=>O(U.parse(e)))]);f.current&&j(t.flatMap((e,n)=>e.status==="fulfilled"?e.value:[{id:`error-${n}`,label:n===0?"Measurement unavailable":"Harbor unavailable",detail:e.reason instanceof Error?e.reason.message:String(e.reason)}]))}finally{h.current=!1,v.current&&f.current&&(v.current=!1,l())}},[]);G(()=>{f.current=!0,l();let t=setInterval(()=>void l(),3e4);return()=>{f.current=!1,clearInterval(t)}},[l]);async function I(t,e){let n=H.safeParse({engine:t,model:e.trim()||null});if(!n.success){o(n.error.issues.map(a=>a.message).join("; "));return}P(!0);try{await p("/api/settings/measurement",{method:"PATCH",body:n.data,timeoutMs:5e3}),o("Saved for future opted-in jobs. Schedules and file permissions are unchanged."),m("status"),await l()}catch(a){o(a instanceof Error?a.message:String(a))}finally{P(!1)}}g(I,"save");function x(t){try{let e=new URL(t,process.env.RULEMETRIC_WEB_URL??$()).toString(),n=process.platform==="darwin"?"open":process.platform==="win32"?"rundll32":"xdg-open",a=process.platform==="win32"?["url.dll,FileProtocolHandler",e]:[e],B=z(n,a,{stdio:"ignore"});B.on("error",()=>o(`Open in your browser: ${e}`)),B.on("exit",F=>{F&&o(`Open in your browser: ${e}`)}),o(`Opening ${e}`)}catch(e){o(e instanceof Error?e.message:String(e))}}return g(x,"openPage"),N((t,e)=>{if(!d){if(e.escape){c==="status"?S():(m("status"),o(""));return}c==="status"&&((t==="q"||t==="m")&&S(),t==="r"&&l(),t==="c"&&(o(""),m("engine")),t==="e"&&x("/eval-targets"),t==="t"&&x("/memories"),t==="h"&&x("/settings"))}}),i(q,{width:_,flexDirection:"column",borderStyle:"round",borderColor:w,paddingX:1,children:[s(r,{bold:!0,color:w,children:"Measurement \xB7 account settings"}),c==="status"&&i(T,{children:[M.length===0?s(r,{children:"Loading measurement status\u2026"}):M.map(t=>i(r,{children:[i(r,{bold:!0,children:[t.label,": "]}),t.detail]},t.id)),s(r,{dimColor:!0,children:"Trials compare with/without an instruction or memory within a fixed harness/model. Inspect exclusions and uncertainty before claiming a gain."}),s(r,{children:"c engine/model \xB7 e nightly trials & eval evidence \xB7 t memory trials"}),s(r,{children:"h Harbor/settings \xB7 r refresh \xB7 Esc back (e/t/h open dashboard)"})]}),c==="engine"&&i(T,{children:[s(r,{children:"Choose actor for future opted-in jobs. This does not enable schedules or file rewrites."}),s(W,{items:[{label:"Claude Code",value:"claude"},{label:"Codex",value:"codex"},{label:"Pi",value:"pi"},{label:"Unset \u2014 existing worker defaults",value:"unset"}],onSelect:t=>{if(!d){if(t.value==="unset"){I(null,"");return}A(t.value),C(""),m("model")}}})]}),c==="model"&&i(T,{children:[s(r,{children:b==="pi"?"Required provider/model (Harbor unsupported)":b==="codex"?"Required supported Codex model":"Claude model (blank uses defaults)"}),i(q,{children:[s(r,{children:"Model: "}),s(X,{value:R,onChange:C,focus:!d,onSubmit:()=>{d||I(b,R)}})]}),s(r,{dimColor:!0,children:"Enter saves \xB7 Esc cancels"})]}),d&&s(r,{children:"Saving\u2026"}),E&&s(r,{children:E})]})}g(se,"MeasurementPanel");export{se as a};
1
+ import{d as w}from"./chunk-NJ5UED3H.js";import{c as $,d as p}from"./chunk-GIXHG5FK.js";import{a as H,b as k,c as U,d as L,e as O}from"./chunk-XQYAVSUQ.js";import{a as g}from"./chunk-ZLLER3HP.js";import{useCallback as D,useEffect as G,useRef as y,useState as u}from"react";import{Box as q,Text as r,useInput as N}from"ink";import W from"ink-select-input";import X from"ink-text-input";import{spawn as z}from"node:child_process";import{Fragment as T,jsx as s,jsxs as i}from"react/jsx-runtime";function se({width:_,onClose:S}){let[M,j]=u([]),[c,m]=u("status"),[b,A]=u(null),[R,C]=u(""),[E,o]=u(""),[d,P]=u(!1),h=y(!1),v=y(!1),f=y(!0),l=D(async()=>{if(h.current){v.current=!0;return}h.current=!0;try{let t=await Promise.allSettled([p("/api/settings/measurement",{timeoutMs:5e3}).then(e=>L(k.parse(e))),p("/api/settings/harbor",{timeoutMs:5e3}).then(e=>O(U.parse(e)))]);f.current&&j(t.flatMap((e,n)=>e.status==="fulfilled"?e.value:[{id:`error-${n}`,label:n===0?"Measurement unavailable":"Harbor unavailable",detail:e.reason instanceof Error?e.reason.message:String(e.reason)}]))}finally{h.current=!1,v.current&&f.current&&(v.current=!1,l())}},[]);G(()=>{f.current=!0,l();let t=setInterval(()=>void l(),3e4);return()=>{f.current=!1,clearInterval(t)}},[l]);async function I(t,e){let n=H.safeParse({engine:t,model:e.trim()||null});if(!n.success){o(n.error.issues.map(a=>a.message).join("; "));return}P(!0);try{await p("/api/settings/measurement",{method:"PATCH",body:n.data,timeoutMs:5e3}),o("Saved for future opted-in jobs. Schedules and file permissions are unchanged."),m("status"),await l()}catch(a){o(a instanceof Error?a.message:String(a))}finally{P(!1)}}g(I,"save");function x(t){try{let e=new URL(t,process.env.RULEMETRIC_WEB_URL??$()).toString(),n=process.platform==="darwin"?"open":process.platform==="win32"?"rundll32":"xdg-open",a=process.platform==="win32"?["url.dll,FileProtocolHandler",e]:[e],B=z(n,a,{stdio:"ignore"});B.on("error",()=>o(`Open in your browser: ${e}`)),B.on("exit",F=>{F&&o(`Open in your browser: ${e}`)}),o(`Opening ${e}`)}catch(e){o(e instanceof Error?e.message:String(e))}}return g(x,"openPage"),N((t,e)=>{if(!d){if(e.escape){c==="status"?S():(m("status"),o(""));return}c==="status"&&((t==="q"||t==="m")&&S(),t==="r"&&l(),t==="c"&&(o(""),m("engine")),t==="e"&&x("/eval-targets"),t==="t"&&x("/memories"),t==="h"&&x("/settings"))}}),i(q,{width:_,flexDirection:"column",borderStyle:"round",borderColor:w,paddingX:1,children:[s(r,{bold:!0,color:w,children:"Measurement \xB7 account settings"}),c==="status"&&i(T,{children:[M.length===0?s(r,{children:"Loading measurement status\u2026"}):M.map(t=>i(r,{children:[i(r,{bold:!0,children:[t.label,": "]}),t.detail]},t.id)),s(r,{dimColor:!0,children:"Trials compare with/without an instruction or memory within a fixed harness/model. Inspect exclusions and uncertainty before claiming a gain."}),s(r,{children:"c engine/model \xB7 e nightly trials & eval evidence \xB7 t memory trials"}),s(r,{children:"h Harbor/settings \xB7 r refresh \xB7 Esc back (e/t/h open dashboard)"})]}),c==="engine"&&i(T,{children:[s(r,{children:"Choose actor for future opted-in jobs. This does not enable schedules or file rewrites."}),s(W,{items:[{label:"Claude Code",value:"claude"},{label:"Codex",value:"codex"},{label:"Pi",value:"pi"},{label:"Unset \u2014 existing worker defaults",value:"unset"}],onSelect:t=>{if(!d){if(t.value==="unset"){I(null,"");return}A(t.value),C(""),m("model")}}})]}),c==="model"&&i(T,{children:[s(r,{children:b==="pi"?"Required provider/model (Harbor unsupported)":b==="codex"?"Required supported Codex model":"Claude model (blank uses defaults)"}),i(q,{children:[s(r,{children:"Model: "}),s(X,{value:R,onChange:C,focus:!d,onSubmit:()=>{d||I(b,R)}})]}),s(r,{dimColor:!0,children:"Enter saves \xB7 Esc cancels"})]}),d&&s(r,{children:"Saving\u2026"}),E&&s(r,{children:E})]})}g(se,"MeasurementPanel");export{se as a};
@@ -0,0 +1 @@
1
+ import{b as R,c as L,f as s,g as I,i as h}from"./chunk-XXPWPKTD.js";import{c as ne}from"./chunk-5TM7AOH2.js";import{b as re}from"./chunk-IEQDLURA.js";import{d as te,e as oe,f as se}from"./chunk-KINIFUZQ.js";import{a as Y}from"./chunk-5PMTNNA6.js";import{a as O}from"./chunk-ZYGBABMZ.js";import{a as U}from"./chunk-IFIWDL7G.js";import{c as N}from"./chunk-FZMO7XSN.js";import{a as F}from"./chunk-LLXC5SRC.js";import{a as W}from"./chunk-4DA6L7KL.js";import{a as $}from"./chunk-WQFR2LOY.js";import{a as q}from"./chunk-Q7IDLOSP.js";import{b as J}from"./chunk-XIOYV5A7.js";import{b as V}from"./chunk-5RBLIVBF.js";import{a as K}from"./chunk-JSGXFD42.js";import{a as x}from"./chunk-CZBO3A6B.js";import{a as j}from"./chunk-JUBXWTJA.js";import{a as Q}from"./chunk-W6MMJRFZ.js";import{a as D}from"./chunk-PZS55PW2.js";import{a as ee}from"./chunk-QPAOX7P2.js";import{e as P}from"./chunk-CIKQXFQ2.js";import{b as G}from"./chunk-5Z6XXOJL.js";import{a as z}from"./chunk-CYCH2EQC.js";import{a as X}from"./chunk-VUNJGZPP.js";import{a as Z}from"./chunk-L562Y4RN.js";import{b as C}from"./chunk-PIVEJTNF.js";import{k as B}from"./chunk-DYET4EYU.js";import{d as S}from"./chunk-GPBN4ROE.js";import{b as M,e as T,f as E}from"./chunk-GIXHG5FK.js";import{a as l}from"./chunk-ZLLER3HP.js";var H=null,w=null,ce={process_eval:W,process_insights:$,process_launch:J,process_send_message:O,process_conversation:F,process_session_goal:U,distill_memories:G,memory_ab:K,process_run_cleanup:Y,cron_refine_cases:j,cron_retire_unused_skills:ee,cron_reconcile_attribution:x,cron_suggest_instructions:P,cron_refresh_skills:D,cron_refresh_pricing:Q,cron_eval_autorun:X,cron_auto_accept_suggestions:z,cron_instruction_training:Z,cron_instruction_evolution:B,process_judge_review:q,harbor_ab:N},ae=Object.keys(ce),me=new Set([]);function pe(e=process.env){return e.DATABASE_URL?ae:ae.filter(t=>!me.has(t))}l(pe,"availableCapabilities");var ge=3e4,_e=3e4,fe=3e4,ie=500,le=1e4,ve=`thin-agent-${process.pid}`,A=null;function ke(e,t,r,p){let d;try{let i=S();d={claude:i.claudeBin!=null,codex:i.codexBin!=null,pi:i.piBin!=null,codexModel:i.codexConfiguredModel}}catch{}let m;try{m=C()}catch{}let g=l(i=>E("/api/workers/heartbeat",{workerType:"cli-worker",clientName:ve,clientVersion:p,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:i,metadata:{capabilities:e,mode:"thin-agent",measurementProtocol:1,studyProtocol:1,memorySnapshots:1,boundedAutorun:1,llmEngines:d,harborReady:m,machine:H?.summary()}}).then(c=>{let u=c?.advisory;u&&u.message!==A?(A=u.message,s(r,{event:"worker_advisory",code:u.code,message:u.message})):u||(A=null)}).catch(c=>{s(r,{event:"presence_heartbeat_error",error:c instanceof Error?c.message:String(c)})}),"send");g("alive");let f=setInterval(()=>g("alive"),fe),a=null,n=l(()=>a||(clearInterval(f),a=Promise.race([g("shutting_down"),new Promise(i=>setTimeout(i,2e3).unref())]),a),"sayGoodbye");return t.addEventListener("abort",()=>{n()},{once:!0}),{shutdown:n}}l(ke,"startPresenceHeartbeat");async function be(e,t,r=S()){let p=[...r.claudeBin?["claude"]:[],...r.codexBin?["codex"]:[],...r.piBin?["pi"]:[]],d=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${t}&measurementProtocol=1&studyProtocol=1&memorySnapshots=1&boundedAutorun=1&measurementEngines=${encodeURIComponent(p.join(","))}`,m=await T(`/api/work/next?${d}`);return m==null||typeof m=="string"?null:m}l(be,"pollForWork");function he(e,t){return{logger:{info:l(r=>t(r),"info"),warn:l(r=>t(r),"warn"),error:l(r=>t(r),"error")},job:{attempts:e}}}l(he,"makeHelpers");async function we(e,t,r,p){let d=ce[e.kind],m=Date.now();if(s(r,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!d){let n=`unknown kind: ${e.kind}`;s(r,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:n}),await E(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:n,terminal:!0}).catch(()=>{});return}let g=l(()=>{s(r,{event:"heartbeat",jobId:e.id}),h(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken},{budgetMs:Math.min(L,Math.max(0,t-1e3)),signal:p,log:r,event:"heartbeat",jobId:e.id}).then(n=>{n.ok||s(r,{event:"heartbeat_error",jobId:e.id,attempts:n.attempts,error:n.error instanceof Error?n.error.message:String(n.error)})})},"beat"),f=setInterval(g,t);w={jobId:e.id,beat:g};let a;try{let n=he(e.attempts,r);a={kind:"complete",result:await d(e.payload,n)??{}}}catch(n){let i=H?.pausesSince(m)??[],c=se(i),u=n instanceof Error?n.message:String(n),v=V(n),o=!v&&oe(i);a={kind:"fail",message:c?`${c}; ${u}`:u,pausedDuringJob:!!c,terminal:v,hostSuspended:o}}try{if(a.kind==="complete"){s(r,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-m});let n=await h(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:a.result},{budgetMs:R,signal:p,log:r,event:"complete_post",jobId:e.id});n.ok||s(r,{event:"complete_post_error",jobId:e.id,kind:e.kind,attempts:n.attempts,error:n.error instanceof Error?n.error.message:String(n.error)})}else{s(r,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-m,terminal:a.terminal,error:a.message,...a.pausedDuringJob?{pausedDuringJob:!0}:{},...a.hostSuspended?{hostSuspended:!0}:{}});let n=await h(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:a.message,terminal:a.terminal,hostSuspended:a.hostSuspended},{budgetMs:R,signal:p,log:r,event:"fail_post",jobId:e.id});n.ok||s(r,{event:"fail_post_error",jobId:e.id,attempts:n.attempts,error:n.error instanceof Error?n.error.message:String(n.error)})}}finally{clearInterval(f),w=null}}l(we,"runOne");var de=new Set(["process_eval","process_conversation","process_insights","process_session_goal","distill_memories","memory_ab","cron_suggest_instructions","cron_eval_autorun","cron_instruction_evolution","process_judge_review","harbor_ab"]);async function Ze(e){let t=e.log??(()=>{}),r=e.pollWaitMs??ge,p=e.heartbeatIntervalMs??_e,d=e.capabilities??pe();s(t,{event:"agent_start",capabilities:d,pollWaitMs:r,heartbeatIntervalMs:p});try{let o=re();o.removed.length>0&&s(t,{event:"eval_worktrees_swept",removed:o.removed.length})}catch(o){s(t,{event:"eval_worktree_sweep_failed",error:o instanceof Error?o.message:String(o)})}H=te({signal:e.signal,onPause:l(o=>{s(t,{event:"machine_pause",...o,jobId:w?.jobId??null}),w?.beat()},"onPause")});let m=ke(d,e.signal,t,e.version);ne({signal:e.signal,log:t}).catch(o=>{s(t,{event:"tt_heartbeat_fatal",error:o instanceof Error?o.message:String(o)})});let g=5*6e4,f=0,a=l(()=>{if(!e.readInstalledVersion||!e.version)return!1;let o=Date.now();if(o-f<g)return!1;f=o;let b=e.readInstalledVersion();return!!(b&&b!==e.version)},"versionDrifted"),n=new AbortController,i=n.signal;e.signal.aborted?n.abort():e.signal.addEventListener("abort",()=>n.abort(),{once:!0});let c=l(async(o,b)=>{let _=ie;for(;!i.aborted;){if(a()){s(t,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),n.abort(),e.onVersionDrift?.();break}let y=null;try{y=await be([...b],r)}catch(k){let ue=k instanceof M?k.statusCode:void 0;if(s(t,{event:"poll_error",lane:o,status:ue,error:k instanceof Error?k.message:String(k)}),!await I(_,i))break;_=Math.min(_*2,le);continue}if(!y){if(s(t,{event:"poll_204",lane:o}),!await I(_,i))break;_=Math.min(_*2,le);continue}_=ie,await we(y,p,t,i)}},"runLane"),u=d.filter(o=>de.has(o)),v=d.filter(o=>!de.has(o));u.length>0&&v.length>0?(s(t,{event:"agent_lanes",heavy:u.length,fast:v.length}),await Promise.all([c("heavy",u),c("fast",v)])):await c("single",d),await m.shutdown(),s(t,{event:"agent_stop"})}l(Ze,"runAgentLoop");export{ce as a,ae as b,pe as c,be as d,Ze as e};
@@ -1 +1 @@
1
- import{a}from"./chunk-76UKAFNM.js";import{a as e}from"./chunk-ZLLER3HP.js";function i(){return process.env.RULEMETRIC_API_URL??a}e(i,"apiUrl");function u(){let n=process.env.RULEMETRIC_API_KEY??process.env.RULEMETRIC_ACCESS_TOKEN;if(!n)throw new Error("not signed in \u2014 run `rulemetric auth login`");return n}e(u,"authToken");async function t(n,o){let r=await fetch(`${i()}${n}`,{...o,headers:{Authorization:`Bearer ${u()}`,"Content-Type":"application/json",...o?.headers??{}},signal:AbortSignal.timeout(1e4)});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);return await r.json()}e(t,"request");function c({limit:n}){return t(`/api/launch-jobs?limit=${n}`)}e(c,"fetchLaunchJobs");function h(n){return t("/api/launch-jobs",{method:"POST",body:JSON.stringify(n)})}e(h,"createLaunchJob");function l(n){return t(`/api/launch-jobs/${n}/cancel`,{method:"POST"})}e(l,"cancelLaunchJob");function p(){return t("/api/launchers")}e(p,"listLaunchers");export{c as a,h as b,l as c,p as d};
1
+ import{a}from"./chunk-GIXHG5FK.js";import{a as e}from"./chunk-ZLLER3HP.js";function i(){return process.env.RULEMETRIC_API_URL??a}e(i,"apiUrl");function u(){let n=process.env.RULEMETRIC_API_KEY??process.env.RULEMETRIC_ACCESS_TOKEN;if(!n)throw new Error("not signed in \u2014 run `rulemetric auth login`");return n}e(u,"authToken");async function t(n,o){let r=await fetch(`${i()}${n}`,{...o,headers:{Authorization:`Bearer ${u()}`,"Content-Type":"application/json",...o?.headers??{}},signal:AbortSignal.timeout(1e4)});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);return await r.json()}e(t,"request");function c({limit:n}){return t(`/api/launch-jobs?limit=${n}`)}e(c,"fetchLaunchJobs");function h(n){return t("/api/launch-jobs",{method:"POST",body:JSON.stringify(n)})}e(h,"createLaunchJob");function l(n){return t(`/api/launch-jobs/${n}/cancel`,{method:"POST"})}e(l,"cancelLaunchJob");function p(){return t("/api/launchers")}e(p,"listLaunchers");export{c as a,h as b,l as c,p as d};
@@ -1,4 +1,4 @@
1
- import{f as p}from"./chunk-FBSZ6KCM.js";import{a as c}from"./chunk-ZLLER3HP.js";var y=`You are an expert at improving AI coding instructions, skills, and prompts. You receive eval results showing how well the current content performs, and your job is to propose specific improvements.
1
+ import{f as p}from"./chunk-4GOXEEXZ.js";import{a as c}from"./chunk-ZLLER3HP.js";var y=`You are an expert at improving AI coding instructions, skills, and prompts. You receive eval results showing how well the current content performs, and your job is to propose specific improvements.
2
2
 
3
3
  You will receive:
4
4
  1. The current content of the eval target
@@ -1 +1 @@
1
- import{a as i}from"./chunk-44TYRMIS.js";import{a as f}from"./chunk-ZLLER3HP.js";import{useEffect as J,useState as u,useCallback as m,useRef as s}from"react";var y=5e3;function T(a=20){let[d,b]=u([]),[g,l]=u(null),[h,p]=u(!0),r=s(!1),e=s(null),c=s(0),t=m(async()=>{let o=++c.current;try{let n=await i({limit:a});if(r.current||o!==c.current)return;b(n),l(null)}catch(n){if(r.current||o!==c.current)return;l(n instanceof Error?n.message:String(n))}finally{if(r.current||o!==c.current)return;p(!1),e.current=setTimeout(()=>{t()},y)}},[a]),L=m(()=>{e.current&&clearTimeout(e.current),t()},[t]);return J(()=>(r.current=!1,t(),()=>{r.current=!0,e.current&&clearTimeout(e.current)}),[t]),{jobs:d,error:g,loading:h,refetch:L}}f(T,"useLaunchJobs");export{T as a};
1
+ import{a as i}from"./chunk-NWV66NMA.js";import{a as f}from"./chunk-ZLLER3HP.js";import{useEffect as J,useState as u,useCallback as m,useRef as s}from"react";var y=5e3;function T(a=20){let[d,b]=u([]),[g,l]=u(null),[h,p]=u(!0),r=s(!1),e=s(null),c=s(0),t=m(async()=>{let o=++c.current;try{let n=await i({limit:a});if(r.current||o!==c.current)return;b(n),l(null)}catch(n){if(r.current||o!==c.current)return;l(n instanceof Error?n.message:String(n))}finally{if(r.current||o!==c.current)return;p(!1),e.current=setTimeout(()=>{t()},y)}},[a]),L=m(()=>{e.current&&clearTimeout(e.current),t()},[t]);return J(()=>(r.current=!1,t(),()=>{r.current=!0,e.current&&clearTimeout(e.current)}),[t]),{jobs:d,error:g,loading:h,refetch:L}}f(T,"useLaunchJobs");export{T as a};
@@ -1 +1 @@
1
- import{c as d,d as t}from"./chunk-HNYHZO2J.js";import{a as r}from"./chunk-ZLLER3HP.js";async function g(o,i){let{evalTargetId:s}=o;try{let e=await t({targetId:s,engineFlag:"auto",skipReviewed:!0,log:r(a=>i.logger.info(`[judge-review] ${a}`),"log"),warn:r(a=>i.logger.warn(`[judge-review] ${a}`),"warn")});return{evalTargetId:s,reviewerModel:e.reviewerModel,comparedPairs:e.report.pairs,disagreements:e.report.disagreements.length,persisted:e.persisted,alreadyReviewed:e.alreadyReviewed,deferredPartialRuns:e.deferredPartialRuns}}catch(e){if(e instanceof d)return i.logger.info(`[judge-review] skipped (${e.reason}): ${e.message}`),{evalTargetId:s,skipped:e.reason};throw e}}r(g,"processJudgeReview");export{g as a};
1
+ import{c as d,d as t}from"./chunk-3H44B6PB.js";import{a as r}from"./chunk-ZLLER3HP.js";async function g(o,i){let{evalTargetId:s}=o;try{let e=await t({targetId:s,engineFlag:"auto",skipReviewed:!0,log:r(a=>i.logger.info(`[judge-review] ${a}`),"log"),warn:r(a=>i.logger.warn(`[judge-review] ${a}`),"warn")});return{evalTargetId:s,reviewerModel:e.reviewerModel,comparedPairs:e.report.pairs,disagreements:e.report.disagreements.length,persisted:e.persisted,alreadyReviewed:e.alreadyReviewed,deferredPartialRuns:e.deferredPartialRuns}}catch(e){if(e instanceof d)return i.logger.info(`[judge-review] skipped (${e.reason}): ${e.message}`),{evalTargetId:s,skipped:e.reason};throw e}}r(g,"processJudgeReview");export{g as a};
@@ -1 +1 @@
1
- import{b as $}from"./chunk-VBXL7XO7.js";import{e as w,f as k}from"./chunk-76UKAFNM.js";import{a as u}from"./chunk-ZLLER3HP.js";function h(e){if(e.length===0)return{mean:0,stddev:0,min:0,max:0};let n=e.reduce((s,a)=>s+a,0)/e.length,o=e.reduce((s,a)=>s+(a-n)**2,0)/e.length;return{mean:Math.round(n*1e3)/1e3,stddev:Math.round(Math.sqrt(o)*1e3)/1e3,min:Math.min(...e),max:Math.max(...e)}}u(h,"computeStats");var x="with_target",E="without_target";function _(e){let n=e.grading.summary?.pass_rate;return typeof n=="number"&&n>=1}u(_,"fullPass");function b(e){return e.grading.summary?.pass_rate!=null}u(b,"hasGrading");function R(e){let n=e.timing.total_tokens;return typeof n=="number"&&n>0?n:void 0}u(R,"tokensOf");function v(e){let n=e.timing.duration_ms;return typeof n=="number"&&!isNaN(n)?n/1e3:void 0}u(v,"secondsOf");function y(e,n){let o={};for(let s of e)(o[n(s)]??=[]).push(s);return o}u(y,"groupBy");function C(e,n){let o=y(e.filter(b),i=>i.evalId),s=y(n.filter(b),i=>i.evalId),a=u((i,l)=>i.runNumber-l.runNumber,"byRun"),t=[];for(let i of Object.keys(o)){let l=o[i].sort(a),d=(s[i]??[]).sort(a);for(let r=0;r<Math.min(l.length,d.length);r++){let c={withScore:_(l[r])?1:0,withoutScore:_(d[r])?1:0},f=R(l[r]),g=R(d[r]);f!=null&&g!=null&&(c.withCost=f,c.withoutCost=g);let p=v(l[r]),m=v(d[r]);p!=null&&m!=null&&(c.withLatency=p,c.withoutLatency=m),t.push(c)}}return t}u(C,"pairRunsByEval");function T(e){let n=e.filter(r=>r.status==="completed");if(n.length===0)return{runSummary:{},verdict:null,notes:["No completed runs found"],totalRuns:0};let o=y(n,r=>r.configuration),s={},a=[];for(let[r,c]of Object.entries(o)){let f=c.filter(b).map(m=>m.grading.summary.pass_rate),g=c.map(v).filter(m=>m!=null),p=c.map(R).filter(m=>m!=null);s[r]={},f.length>0&&(s[r].pass_rate=h(f)),g.length>0&&(s[r].time_seconds=h(g)),p.length>0&&(s[r].tokens=h(p))}let t=null,i=o[x]??[],l=o[E]??[],d=C(i,l);if(d.length>0){if(t=$(d),!t.sufficient)a.push(t.insufficientReason??"Insufficient data for a significance verdict.");else if(t.significant){let r=t.delta>=0?"improves":"reduces",c=t.pValue!=null?`, McNemar p=${t.pValue.toFixed(4)}`:"";a.push(`Target ${r} the pass rate by ${Math.abs(t.delta*100).toFixed(0)}% (95% CI ${(t.ci.lower*100).toFixed(0)}\u2013${(t.ci.upper*100).toFixed(0)}%, n=${t.nWith}${c}).`)}else a.push(`No significant effect on pass rate (95% CI ${(t.ci.lower*100).toFixed(0)}\u2013${(t.ci.upper*100).toFixed(0)}%, n=${t.nWith}).`);t.costDelta!=null&&Math.round(t.costDelta)!==0&&a.push(`Token cost delta: ${t.costDelta>=0?"+":""}${Math.round(t.costDelta)} tokens/task.`),t.latencyDelta!=null&&Math.abs(t.latencyDelta)>1&&a.push(`Target ${t.latencyDelta>0?"adds":"saves"} ${Math.abs(t.latencyDelta).toFixed(1)}s/task.`)}for(let r of Object.values(s))if(r.pass_rate&&r.pass_rate.stddev>.2){a.push(`High pass-rate variance (stddev=${r.pass_rate.stddev.toFixed(2)}) \u2014 results may be unreliable.`);break}return{runSummary:s,verdict:t,notes:a,totalRuns:n.length}}u(T,"summarizeRuns");async function S(e,n){let o=n?`&iteration=${n}`:"",s=100,a=[];for(let t=0;t<1e5;t+=s){let i=await w(`/api/eval-targets/${e}/runs?limit=${s}&offset=${t}&activeCasesOnly=1${o}`);if(a.push(...i),i.length<s)break}return T(a)}u(S,"aggregateBenchmark");async function B(e,n,o){return k(`/api/eval-targets/${e}/benchmarks`,{iteration:n,runSummary:o.runSummary,notes:o.notes})}u(B,"postBenchmark");export{T as a,S as b,B as c};
1
+ import{b as $}from"./chunk-HT6R6KR3.js";import{e as w,f as k}from"./chunk-GIXHG5FK.js";import{a as u}from"./chunk-ZLLER3HP.js";function h(e){if(e.length===0)return{mean:0,stddev:0,min:0,max:0};let n=e.reduce((s,a)=>s+a,0)/e.length,o=e.reduce((s,a)=>s+(a-n)**2,0)/e.length;return{mean:Math.round(n*1e3)/1e3,stddev:Math.round(Math.sqrt(o)*1e3)/1e3,min:Math.min(...e),max:Math.max(...e)}}u(h,"computeStats");var x="with_target",E="without_target";function _(e){let n=e.grading.summary?.pass_rate;return typeof n=="number"&&n>=1}u(_,"fullPass");function b(e){return e.grading.summary?.pass_rate!=null}u(b,"hasGrading");function R(e){let n=e.timing.total_tokens;return typeof n=="number"&&n>0?n:void 0}u(R,"tokensOf");function v(e){let n=e.timing.duration_ms;return typeof n=="number"&&!isNaN(n)?n/1e3:void 0}u(v,"secondsOf");function y(e,n){let o={};for(let s of e)(o[n(s)]??=[]).push(s);return o}u(y,"groupBy");function C(e,n){let o=y(e.filter(b),i=>i.evalId),s=y(n.filter(b),i=>i.evalId),a=u((i,l)=>i.runNumber-l.runNumber,"byRun"),t=[];for(let i of Object.keys(o)){let l=o[i].sort(a),d=(s[i]??[]).sort(a);for(let r=0;r<Math.min(l.length,d.length);r++){let c={withScore:_(l[r])?1:0,withoutScore:_(d[r])?1:0},f=R(l[r]),g=R(d[r]);f!=null&&g!=null&&(c.withCost=f,c.withoutCost=g);let p=v(l[r]),m=v(d[r]);p!=null&&m!=null&&(c.withLatency=p,c.withoutLatency=m),t.push(c)}}return t}u(C,"pairRunsByEval");function T(e){let n=e.filter(r=>r.status==="completed");if(n.length===0)return{runSummary:{},verdict:null,notes:["No completed runs found"],totalRuns:0};let o=y(n,r=>r.configuration),s={},a=[];for(let[r,c]of Object.entries(o)){let f=c.filter(b).map(m=>m.grading.summary.pass_rate),g=c.map(v).filter(m=>m!=null),p=c.map(R).filter(m=>m!=null);s[r]={},f.length>0&&(s[r].pass_rate=h(f)),g.length>0&&(s[r].time_seconds=h(g)),p.length>0&&(s[r].tokens=h(p))}let t=null,i=o[x]??[],l=o[E]??[],d=C(i,l);if(d.length>0){if(t=$(d),!t.sufficient)a.push(t.insufficientReason??"Insufficient data for a significance verdict.");else if(t.significant){let r=t.delta>=0?"improves":"reduces",c=t.pValue!=null?`, McNemar p=${t.pValue.toFixed(4)}`:"";a.push(`Target ${r} the pass rate by ${Math.abs(t.delta*100).toFixed(0)}% (95% CI ${(t.ci.lower*100).toFixed(0)}\u2013${(t.ci.upper*100).toFixed(0)}%, n=${t.nWith}${c}).`)}else a.push(`No significant effect on pass rate (95% CI ${(t.ci.lower*100).toFixed(0)}\u2013${(t.ci.upper*100).toFixed(0)}%, n=${t.nWith}).`);t.costDelta!=null&&Math.round(t.costDelta)!==0&&a.push(`Token cost delta: ${t.costDelta>=0?"+":""}${Math.round(t.costDelta)} tokens/task.`),t.latencyDelta!=null&&Math.abs(t.latencyDelta)>1&&a.push(`Target ${t.latencyDelta>0?"adds":"saves"} ${Math.abs(t.latencyDelta).toFixed(1)}s/task.`)}for(let r of Object.values(s))if(r.pass_rate&&r.pass_rate.stddev>.2){a.push(`High pass-rate variance (stddev=${r.pass_rate.stddev.toFixed(2)}) \u2014 results may be unreliable.`);break}return{runSummary:s,verdict:t,notes:a,totalRuns:n.length}}u(T,"summarizeRuns");async function S(e,n){let o=n?`&iteration=${n}`:"",s=100,a=[];for(let t=0;t<1e5;t+=s){let i=await w(`/api/eval-targets/${e}/runs?limit=${s}&offset=${t}&activeCasesOnly=1${o}`);if(a.push(...i),i.length<s)break}return T(a)}u(S,"aggregateBenchmark");async function B(e,n,o){return k(`/api/eval-targets/${e}/benchmarks`,{iteration:n,runSummary:o.runSummary,notes:o.notes})}u(B,"postBenchmark");export{T as a,S as b,B as c};
@@ -1,4 +1,4 @@
1
- import{e as d}from"./chunk-QWCEZEDO.js";import{a as R,g as v,h as T,j as I,m as C}from"./chunk-OZQNSELV.js";import{d as g}from"./chunk-GPBN4ROE.js";import{e as _}from"./chunk-76UKAFNM.js";import{g as m,l as k}from"./chunk-PZNWH4VQ.js";import{a as i}from"./chunk-ZLLER3HP.js";import{execSync as j}from"node:child_process";import{existsSync as p,readFileSync as y}from"node:fs";import{homedir as f}from"node:os";import{join as a}from"node:path";var P=["install","auth","hooks","worker"],O=["judge"],M=[...P,...O];function $(){return{projectPath:process.cwd(),configDir:k()}}i($,"defaultContext");var A=a(f(),".mitmproxy","mitmproxy-ca-cert.pem");function S(e){if(!e)return"";if(e.length<=8)return"*".repeat(e.length);let t=e.slice(0,4),n=e.slice(-4);return`${t}${"*".repeat(Math.max(4,e.length-8))}${n}`}i(S,"maskToken");function te(e,t){let n=e===null?[]:e.replace(/\n$/,"").split(`
1
+ import{e as d}from"./chunk-QWCEZEDO.js";import{a as R,g as v,h as T,j as I,m as C}from"./chunk-OZQNSELV.js";import{d as g}from"./chunk-GPBN4ROE.js";import{e as _}from"./chunk-GIXHG5FK.js";import{g as m,l as k}from"./chunk-PZNWH4VQ.js";import{a as i}from"./chunk-ZLLER3HP.js";import{execSync as j}from"node:child_process";import{existsSync as p,readFileSync as y}from"node:fs";import{homedir as f}from"node:os";import{join as a}from"node:path";var P=["install","auth","hooks","worker"],O=["judge"],M=[...P,...O];function $(){return{projectPath:process.cwd(),configDir:k()}}i($,"defaultContext");var A=a(f(),".mitmproxy","mitmproxy-ca-cert.pem");function S(e){if(!e)return"";if(e.length<=8)return"*".repeat(e.length);let t=e.slice(0,4),n=e.slice(-4);return`${t}${"*".repeat(Math.max(4,e.length-8))}${n}`}i(S,"maskToken");function te(e,t){let n=e===null?[]:e.replace(/\n$/,"").split(`
2
2
  `),o=t===null?[]:t.replace(/\n$/,"").split(`
3
3
  `),s=[],u=Math.max(n.length,o.length);for(let c=0;c<u;c++){let l=n[c],r=o[c];l===r?s.push(` ${l}`):(l!==void 0&&s.push(`-${l}`),r!==void 0&&s.push(`+${r}`))}return s.join(`
4
4
  `)}i(te,"renderDiff");function x(e,t){let n=a(e,"env");if(!p(n))return null;try{let s=y(n,"utf-8").match(new RegExp(`^${t}=(.+)$`,"m"));return s?s[1]:null}catch{return null}}i(x,"readEnvValue");async function b(){if(!m())return!1;try{return(await Promise.race([_("/api/setup/status"),new Promise((t,n)=>setTimeout(()=>n(new Error("setup/status timeout")),2500))]))?.workerActive===!0}catch{return!1}}i(b,"workerActive");function E(e,t){let n=a(e,".claude",t),o={},s=null;if(p(n))try{s=y(n,"utf-8").replace(/\n$/,""),o=JSON.parse(s)}catch{o={}}return{settings:o,before:s}}i(E,"readProjectSettings");function D(e){let{settings:t,before:n}=E(e,"settings.local.json");return v(t),{before:n,after:JSON.stringify(t,null,2)}}i(D,"projectHooksSettings");function N(e){let{settings:t,before:n}=E(e,"settings.local.json"),o={...t.env??{}};return o.HTTPS_PROXY=`http://localhost:${d}`,o.NO_PROXY=I,o.NODE_EXTRA_CA_CERTS=A,{before:n,after:JSON.stringify({...t,env:o},null,2)}}i(N,"projectProxyEnvSettings");function U(e){let{settings:t,before:n}=E(e,"settings.json");if(n===null)return null;let{removed:o}=C(t,d);return o?{before:n,after:JSON.stringify(t,null,2)}:null}i(U,"projectSharedSettingsMigration");var Y=a(f(),"Library","LaunchAgents","com.rulemetric.worker.plist"),G=a(f(),".config","systemd","user","rulemetric-worker.service");function h(e){j(e,{stdio:"inherit"})}i(h,"runCommand");var L=[{id:"install",title:"Install the CLI",command:"npm install -g @rulemetric/cli",async detect(){return m()||await b()},async plan(){return{id:"install",title:"Install the CLI",command:"npm install -g @rulemetric/cli",artifacts:[{path:"npm install -g @rulemetric/cli",kind:"command",before:null,after:"rulemetric --version # verifies the binary is on PATH"}]}},async apply(){h("npm install -g @rulemetric/cli")}},{id:"auth",title:"Authenticate",command:"rulemetric auth login",async detect(){return m()},async plan(e){let t=a(e.configDir,"env"),n=null;if(p(t))try{n=X(y(t,"utf-8"))}catch{n="(unreadable)"}let o=x(e.configDir,"RULEMETRIC_ACCESS_TOKEN"),u=[`RULEMETRIC_ACCESS_TOKEN=${S(o||"<token-from-login>")}`],c=x(e.configDir,"RULEMETRIC_API_KEY");c&&u.push(`RULEMETRIC_API_KEY=${S(c)}`);let l=process.env.RULEMETRIC_API_URL;l&&u.push(`RULEMETRIC_API_URL=${l}`);let r=u.join(`
@@ -1 +1 @@
1
- import{b as g}from"./chunk-3ZHVP3KE.js";import{d as k,e as h}from"./chunk-RXZLBSDO.js";import{e as m,i as f}from"./chunk-76UKAFNM.js";import{a as c}from"./chunk-ZLLER3HP.js";import{existsSync as b}from"node:fs";async function w($,y){let r=c(t=>y?.logger?.info?.(t)??console.log(t),"log"),{projectPath:s}=$,n=`[cron_retire_unused_skills] ${s}`;if(!s||!b(s))return{skipped:"project-missing",reason:`${s} does not exist on this machine \u2014 refusing to delete files for a project that is not here.`};let o=await m("/api/insights/groom-candidates"),e=g({captureHealthy:o.skillCaptureHealthy===!0,captureReason:o.skillCaptureHealthy===void 0?"API did not report skill capture health (older deployment)":o.skillCaptureReason,candidates:o.unusedSkills??[]});if(e.refused)return r(`${n} ${e.refused}: ${e.summary}`),{skipped:e.refused,reason:e.summary,held:e.held.length};r(`${n} ${e.summary}`);let a=[],d=[],l=0;for(let t of e.retire){let u=k({kind:"skill_file",target:t.name,cwd:s});if(!u.ok){l+=1,r(`${n} could not plan removal of ${t.name}: ${u.refusal??"unresolved"}`);continue}let R=new Date().toISOString().replace(/[:.]/g,"-"),i=h(u,R);if(!i.applied){l+=1,r(`${n} failed to remove ${t.name}: ${i.error??"unknown error"}`);continue}a.push(t.name),i.backupPath&&d.push(i.backupPath),r(`${n} retired ${t.name} (backup: ${i.backupPath??"none"})`);try{await f(`/api/instructions/${t.instructionId}`)}catch(p){r(`${n} removed ${t.name} but could not archive its instruction row: ${p instanceof Error?p.message:String(p)}`)}}return{retired:a.length,failed:l,held:e.held.length,names:a,backups:d,reason:e.summary}}c(w,"cronRetireUnusedSkills");export{w as a};
1
+ import{b as g}from"./chunk-3ZHVP3KE.js";import{d as k,e as h}from"./chunk-FXQS7AEZ.js";import{e as m,i as f}from"./chunk-GIXHG5FK.js";import{a as c}from"./chunk-ZLLER3HP.js";import{existsSync as b}from"node:fs";async function w($,y){let r=c(t=>y?.logger?.info?.(t)??console.log(t),"log"),{projectPath:s}=$,n=`[cron_retire_unused_skills] ${s}`;if(!s||!b(s))return{skipped:"project-missing",reason:`${s} does not exist on this machine \u2014 refusing to delete files for a project that is not here.`};let o=await m("/api/insights/groom-candidates"),e=g({captureHealthy:o.skillCaptureHealthy===!0,captureReason:o.skillCaptureHealthy===void 0?"API did not report skill capture health (older deployment)":o.skillCaptureReason,candidates:o.unusedSkills??[]});if(e.refused)return r(`${n} ${e.refused}: ${e.summary}`),{skipped:e.refused,reason:e.summary,held:e.held.length};r(`${n} ${e.summary}`);let a=[],d=[],l=0;for(let t of e.retire){let u=k({kind:"skill_file",target:t.name,cwd:s});if(!u.ok){l+=1,r(`${n} could not plan removal of ${t.name}: ${u.refusal??"unresolved"}`);continue}let R=new Date().toISOString().replace(/[:.]/g,"-"),i=h(u,R);if(!i.applied){l+=1,r(`${n} failed to remove ${t.name}: ${i.error??"unknown error"}`);continue}a.push(t.name),i.backupPath&&d.push(i.backupPath),r(`${n} retired ${t.name} (backup: ${i.backupPath??"none"})`);try{await f(`/api/instructions/${t.instructionId}`)}catch(p){r(`${n} removed ${t.name} but could not archive its instruction row: ${p instanceof Error?p.message:String(p)}`)}}return{retired:a.length,failed:l,held:e.held.length,names:a,backups:d,reason:e.summary}}c(w,"cronRetireUnusedSkills");export{w as a};
@@ -1 +1 @@
1
- import{c as u}from"./chunk-FKTT7A4H.js";import{b as c,e as y,f as m}from"./chunk-76UKAFNM.js";import{a as n,b as t,i as s,k as p}from"./chunk-PZNWH4VQ.js";import{a}from"./chunk-ZLLER3HP.js";import{hostname as l}from"node:os";async function R(f,r,h){t();let o=process.env.RULEMETRIC_API_KEY,d=n().apiKey;if(o||d)try{await y("/api/profile");return}catch(e){if(!(e instanceof c)||e.statusCode!==401)return;if(o){r('Your exported RULEMETRIC_API_KEY was rejected (revoked?). Unset it or replace it with a fresh key (`rulemetric auth create-key --name "my-laptop"`).');return}p(),t(),r("Stored API key was rejected (revoked?) \u2014 replacing it with a fresh one.")}let i=`${l()} (auto)`;try{let e=await m("/api/auth/api-keys",{name:i});s(e.key,process.env.RULEMETRIC_API_URL),t(),f(`Created API key "${i}" for hooks + proxy auth (saved to your config).`),u("key_created",{},h)}catch(e){let k=e instanceof Error?e.message:String(e);r(`Could not auto-create an API key (${k}). Hooks/proxy will work via your session token for ABOUT AN HOUR \u2014 the token expires, and capture then stops until a key exists. Run \`rulemetric auth create-key --name "my-laptop"\` (or \`rulemetric auth login\` again) to fix this permanently.`)}}a(R,"ensureDeviceApiKey");export{R as a};
1
+ import{c as u}from"./chunk-WL5ZWQAS.js";import{b as c,e as y,f as m}from"./chunk-GIXHG5FK.js";import{a as n,b as t,i as s,k as p}from"./chunk-PZNWH4VQ.js";import{a}from"./chunk-ZLLER3HP.js";import{hostname as l}from"node:os";async function R(f,r,h){t();let o=process.env.RULEMETRIC_API_KEY,d=n().apiKey;if(o||d)try{await y("/api/profile");return}catch(e){if(!(e instanceof c)||e.statusCode!==401)return;if(o){r('Your exported RULEMETRIC_API_KEY was rejected (revoked?). Unset it or replace it with a fresh key (`rulemetric auth create-key --name "my-laptop"`).');return}p(),t(),r("Stored API key was rejected (revoked?) \u2014 replacing it with a fresh one.")}let i=`${l()} (auto)`;try{let e=await m("/api/auth/api-keys",{name:i});s(e.key,process.env.RULEMETRIC_API_URL),t(),f(`Created API key "${i}" for hooks + proxy auth (saved to your config).`),u("key_created",{},h)}catch(e){let k=e instanceof Error?e.message:String(e);r(`Could not auto-create an API key (${k}). Hooks/proxy will work via your session token for ABOUT AN HOUR \u2014 the token expires, and capture then stops until a key exists. Run \`rulemetric auth create-key --name "my-laptop"\` (or \`rulemetric auth login\` again) to fix this permanently.`)}}a(R,"ensureDeviceApiKey");export{R as a};
@@ -1,4 +1,4 @@
1
- import{a as f,b as M}from"./chunk-Q776YUBD.js";import{e as _,f as S}from"./chunk-42A4PUW7.js";import{a as o}from"./chunk-ZLLER3HP.js";import*as m from"node:fs/promises";import*as x from"node:path";import{eq as j}from"drizzle-orm";import{randomBytes as Y}from"node:crypto";var A="#0d9488",h="#1a1a1a",$="#666666",C="#f5f5f7",N="#ffffff",D="#e5e5e9",I=["Added","Changed","Fixed","Removed","Deprecated","Security"];function U(e){let t=["January","February","March","April","May","June","July","August","September","October","November","December"],[n,r,a]=e.split("-").map(d=>parseInt(d,10));return!n||!r||!a||r<1||r>12?e:`${t[r-1]} ${a}, ${n}`}o(U,"formatIsoDate");function l(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}o(l,"escapeHtml");function z(e){let t=[];for(let n of I){let r=e[n];r&&r.length>0&&t.push({name:n,items:r})}return t}o(z,"orderedSections");function v(e){let{version:t,date:n,sections:r,unsubscribeUrl:a,productUrl:d,recipientName:u}=e,c=U(n),s=`What's new in RuleMetric \u2014 ${c}`,y=u?`Hi ${u},`:"Hi there,",i=z(r),p=new Date().getUTCFullYear(),b=i.map(({name:R,items:E})=>{let w=E.map(O=>` <li style="margin:0 0 6px 0;font-size:15px;line-height:1.5;color:${h};">${l(O)}</li>`).join(`
1
+ import{a as f,b as M}from"./chunk-V576KKH6.js";import{e as _,f as S}from"./chunk-X6CF5KTW.js";import{a as o}from"./chunk-ZLLER3HP.js";import*as m from"node:fs/promises";import*as x from"node:path";import{eq as j}from"drizzle-orm";import{randomBytes as Y}from"node:crypto";var A="#0d9488",h="#1a1a1a",$="#666666",C="#f5f5f7",N="#ffffff",D="#e5e5e9",I=["Added","Changed","Fixed","Removed","Deprecated","Security"];function U(e){let t=["January","February","March","April","May","June","July","August","September","October","November","December"],[n,r,a]=e.split("-").map(d=>parseInt(d,10));return!n||!r||!a||r<1||r>12?e:`${t[r-1]} ${a}, ${n}`}o(U,"formatIsoDate");function l(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}o(l,"escapeHtml");function z(e){let t=[];for(let n of I){let r=e[n];r&&r.length>0&&t.push({name:n,items:r})}return t}o(z,"orderedSections");function v(e){let{version:t,date:n,sections:r,unsubscribeUrl:a,productUrl:d,recipientName:u}=e,c=U(n),s=`What's new in RuleMetric \u2014 ${c}`,y=u?`Hi ${u},`:"Hi there,",i=z(r),p=new Date().getUTCFullYear(),b=i.map(({name:R,items:E})=>{let w=E.map(O=>` <li style="margin:0 0 6px 0;font-size:15px;line-height:1.5;color:${h};">${l(O)}</li>`).join(`
2
2
  `);return` <h3 style="margin:24px 0 8px 0;font-size:16px;line-height:1.3;font-weight:600;color:${h};">${R}</h3>
3
3
  <ul style="margin:0 0 8px 0;padding-left:20px;">
4
4
  ${w}
@@ -1,4 +1,4 @@
1
- import{a as U,b as F}from"./chunk-3FNTV2TW.js";import{a as h,b as I}from"./chunk-B5X6HCBK.js";import{a as w,b as k,e as R}from"./chunk-LJRE3LZ2.js";import{d as $}from"./chunk-GYNZ3OZF.js";import{g as C,i as D,j as P}from"./chunk-UPFH72PF.js";import{e as v,f as x,i as j}from"./chunk-76UKAFNM.js";import{D as S,F as b,G as T,o as A}from"./chunk-42A4PUW7.js";import{a as l}from"./chunk-ZLLER3HP.js";import*as u from"node:fs";import*as m from"node:path";var O=new Set(["mcp","subagent","feature"]);function ie(e,t,n){return L(m.join(e,"CLAUDE.md"),t,n)}l(ie,"appendToCLAUDEmd");function L(e,t,n){let i=w(t),s=k(t),a=u.existsSync(e)?u.readFileSync(e,"utf8"):"";if(a.includes(i))return!1;let p=`${a.length>0&&!a.endsWith(`
1
+ import{a as U,b as F}from"./chunk-6T6YFPBW.js";import{a as h,b as I}from"./chunk-ISYU5BMU.js";import{a as w,b as k,e as R}from"./chunk-LJRE3LZ2.js";import{d as $}from"./chunk-GYNZ3OZF.js";import{g as C,i as D,j as P}from"./chunk-UPFH72PF.js";import{e as v,f as x,i as j}from"./chunk-GIXHG5FK.js";import{D as S,F as b,G as T,o as A}from"./chunk-X6CF5KTW.js";import{a as l}from"./chunk-ZLLER3HP.js";import*as u from"node:fs";import*as m from"node:path";var O=new Set(["mcp","subagent","feature"]);function ie(e,t,n){return L(m.join(e,"CLAUDE.md"),t,n)}l(ie,"appendToCLAUDEmd");function L(e,t,n){let i=w(t),s=k(t),a=u.existsSync(e)?u.readFileSync(e,"utf8"):"";if(a.includes(i))return!1;let p=`${a.length>0&&!a.endsWith(`
2
2
  `)?`
3
3
 
4
4
  `:a.length>0?`
@@ -1,2 +1,2 @@
1
- import{c as E,n as m}from"./chunk-T75KAEJO.js";import{a as d}from"./chunk-76UKAFNM.js";import{a as c}from"./chunk-ZLLER3HP.js";import*as p from"node:fs";import*as u from"node:path";import*as _ from"node:os";function T(){if(process.env.RULEMETRIC_API_KEY||process.env.RULEMETRIC_ACCESS_TOKEN)return;let s=u.join(_.homedir(),".config","rulemetric","env");C(s)||C(u.join(process.cwd(),".env.local"))}c(T,"ensureEnv");function C(s){try{let t=p.readFileSync(s,"utf-8");for(let n of t.split(`
1
+ import{c as E,n as m}from"./chunk-T75KAEJO.js";import{a as d}from"./chunk-GIXHG5FK.js";import{a as c}from"./chunk-ZLLER3HP.js";import*as p from"node:fs";import*as u from"node:path";import*as _ from"node:os";function T(){if(process.env.RULEMETRIC_API_KEY||process.env.RULEMETRIC_ACCESS_TOKEN)return;let s=u.join(_.homedir(),".config","rulemetric","env");C(s)||C(u.join(process.cwd(),".env.local"))}c(T,"ensureEnv");function C(s){try{let t=p.readFileSync(s,"utf-8");for(let n of t.split(`
2
2
  `)){let e=n.trim();if(!e||e.startsWith("#"))continue;let o=e.indexOf("=");if(o<0)continue;let r=e.slice(0,o).trim(),i=e.slice(o+1).trim();process.env[r]||(process.env[r]=i)}return!!(process.env.RULEMETRIC_API_KEY||process.env.RULEMETRIC_ACCESS_TOKEN)}catch{return!1}}c(C,"loadEnvFile");T();async function I(s){let t={totalSessions:0,totalCalls:0,totalInputTokens:0,totalOutputTokens:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,totalCostUSD:0,providers:{}},n=await m(s);t.providers={};for(let a of n)t.providers[a.provider]=(t.providers[a.provider]||0)+1;let e=new E,o=n.filter(a=>a.provider==="claude");for(let a of o)try{let h=p.readdirSync(a.path).filter(f=>f.endsWith(".jsonl"));t.totalSessions+=h.length;for(let f of h){let v=p.readFileSync(u.join(a.path,f),"utf-8"),R=e.parse(v);for(let l of R.events)l.tokenUsage&&(t.totalCalls++,t.totalInputTokens+=l.tokenUsage.input,t.totalOutputTokens+=l.tokenUsage.output,t.totalCacheReadTokens+=l.tokenUsage.cacheRead??0,t.totalCacheWriteTokens+=l.tokenUsage.cacheWrite??0)}}catch{}let r=15,i=75;return t.totalCostUSD=Math.round((t.totalInputTokens/1e6*r+t.totalOutputTokens/1e6*i+t.totalCacheReadTokens/1e6*(r*.1)+t.totalCacheWriteTokens/1e6*(r*1.25))*100)/100,t}c(I,"loadLocalStats");async function U(s){let t=process.env.RULEMETRIC_API_URL??d,n=process.env.RULEMETRIC_API_KEY,e=process.env.RULEMETRIC_ACCESS_TOKEN,o=n??e;if(!o)return null;let r=new URLSearchParams;s&&r.set("projectPath",s);try{let i=await fetch(`${t}/api/insights/compute?${r}`,{headers:{Authorization:`Bearer ${o}`},signal:AbortSignal.timeout(5e3)});return i.ok?await i.json():null}catch{return null}}c(U,"loadApiInsights");async function g(s){let t=process.env.RULEMETRIC_API_URL??d,n=process.env.RULEMETRIC_API_KEY??process.env.RULEMETRIC_ACCESS_TOKEN;if(!n)return null;let e=new URLSearchParams;s&&e.set("projectPath",s);try{let o=await fetch(`${t}/api/insights/linked-instructions?${e}`,{headers:{Authorization:`Bearer ${n}`},signal:AbortSignal.timeout(5e3)});return o.ok?await o.json():null}catch{return null}}c(g,"loadLinkedInstructions");export{I as a,U as b,g as c};
@@ -1 +1 @@
1
- import{c as g}from"./chunk-JTYVBR5H.js";import{e as h,f}from"./chunk-76UKAFNM.js";import{q as u,r as m}from"./chunk-42A4PUW7.js";import{a as c}from"./chunk-ZLLER3HP.js";import*as i from"node:fs";import*as d from"node:path";var v=new Set(u);async function w(r){let{applications:l}=await h(`/api/recommendation-applications?instructionId=${encodeURIComponent(r.instructionId)}&projectPath=${encodeURIComponent(r.projectPath)}&limit=200`),t=l.filter(e=>v.has(e.status)&&e.inverse),s=[];for(let e of m(t.map(n=>({...n,appliedAt:n.appliedAt})))){let n=e.inverse;if(n.kind==="delete-paths"){let p=y(r.dir,n.paths);s.push({applicationId:e.id,target:e.targetPath,reversed:p.removed,drifted:!1,reason:p.reason}),(p.removed||p.alreadyGone)&&await f(`/api/recommendation-applications/${encodeURIComponent(e.id)}/transition`,{status:"reverted"});continue}if(n.kind!=="remove-hook-entry"){s.push({applicationId:e.id,target:e.targetPath,reversed:!1,drifted:!1,reason:`no reverser for inverse kind '${n.kind}' \u2014 recorded, not reversed`});continue}let o=g({dir:r.dir,inverse:n});s.push({applicationId:e.id,target:e.targetPath,reversed:o.removed,drifted:o.drifted,reason:o.reason}),(o.removed||o.code==="not-present")&&await f(`/api/recommendation-applications/${encodeURIComponent(e.id)}/transition`,{status:"reverted"})}return s}c(w,"reverseApplications");function y(r,l){let t=d.resolve(r),s=!1,e=0;for(let n of l){let o=d.resolve(t,n);if(o===t||!o.startsWith(t+d.sep))return{removed:!1,alreadyGone:!1,reason:`refused: ${n} does not resolve to a path inside the project`};if(!i.existsSync(o)&&!I(o)){e+=1;continue}try{i.rmSync(o,{recursive:!0,force:!0}),s=!0;let a=d.dirname(o);a.startsWith(t+d.sep)&&i.readdirSync(a).length===0&&i.rmdirSync(a)}catch(a){return{removed:!1,alreadyGone:!1,reason:`could not remove ${n}: ${a instanceof Error?a.message:String(a)}`}}}return!s&&e===l.length?{removed:!1,alreadyGone:!0,reason:"already removed"}:{removed:s,alreadyGone:!1}}c(y,"deletePaths");function I(r){try{return i.lstatSync(r).isSymbolicLink()}catch{return!1}}c(I,"isSymlink");function b(r){let l=r.name??r.instructionId,t=[],s=r.reversals.filter(e=>e.reversed);if(r.stripped.length>0)t.push(`Removed ${l} from ${r.stripped.join(", ")}.`);else if(s.length>0)for(let e of s)t.push(`Removed ${l} from ${e.target}.`),e.drifted&&t.push(" (that file had changed since it was installed; only the recorded entry was removed)");else{let e=r.searched.length>0?` (searched ${r.searched.join(", ")})`:"";t.push(`No rulemetric-managed block for ${r.instructionId} was found in this directory${e}.`)}for(let e of r.reversals.filter(n=>!n.reversed))t.push(`Still installed in ${e.target}: ${e.reason??"the recorded inverse did not apply"}`);return r.dismissalError?(t.push(`Could not record the dismissal: ${r.dismissalError}`),t.push(r.stripped.length>0||s.length>0?' What was removed above stays removed \u2014 only the "stop proposing this" record failed.':" Nothing was removed, and the dismissal was not recorded either."),t.push(" This proposal may be suggested again. Re-run this command to retry."),t):(t.push("It will not be proposed again for 30 days."),t.push("Turn auto-adoption off entirely: rulemetric suggestions auto --off"),t)}c(b,"describeUndo");export{w as a,y as b,b as c};
1
+ import{c as g}from"./chunk-DANMUHNW.js";import{e as h,f}from"./chunk-GIXHG5FK.js";import{q as u,r as m}from"./chunk-X6CF5KTW.js";import{a as c}from"./chunk-ZLLER3HP.js";import*as i from"node:fs";import*as d from"node:path";var v=new Set(u);async function w(r){let{applications:l}=await h(`/api/recommendation-applications?instructionId=${encodeURIComponent(r.instructionId)}&projectPath=${encodeURIComponent(r.projectPath)}&limit=200`),t=l.filter(e=>v.has(e.status)&&e.inverse),s=[];for(let e of m(t.map(n=>({...n,appliedAt:n.appliedAt})))){let n=e.inverse;if(n.kind==="delete-paths"){let p=y(r.dir,n.paths);s.push({applicationId:e.id,target:e.targetPath,reversed:p.removed,drifted:!1,reason:p.reason}),(p.removed||p.alreadyGone)&&await f(`/api/recommendation-applications/${encodeURIComponent(e.id)}/transition`,{status:"reverted"});continue}if(n.kind!=="remove-hook-entry"){s.push({applicationId:e.id,target:e.targetPath,reversed:!1,drifted:!1,reason:`no reverser for inverse kind '${n.kind}' \u2014 recorded, not reversed`});continue}let o=g({dir:r.dir,inverse:n});s.push({applicationId:e.id,target:e.targetPath,reversed:o.removed,drifted:o.drifted,reason:o.reason}),(o.removed||o.code==="not-present")&&await f(`/api/recommendation-applications/${encodeURIComponent(e.id)}/transition`,{status:"reverted"})}return s}c(w,"reverseApplications");function y(r,l){let t=d.resolve(r),s=!1,e=0;for(let n of l){let o=d.resolve(t,n);if(o===t||!o.startsWith(t+d.sep))return{removed:!1,alreadyGone:!1,reason:`refused: ${n} does not resolve to a path inside the project`};if(!i.existsSync(o)&&!I(o)){e+=1;continue}try{i.rmSync(o,{recursive:!0,force:!0}),s=!0;let a=d.dirname(o);a.startsWith(t+d.sep)&&i.readdirSync(a).length===0&&i.rmdirSync(a)}catch(a){return{removed:!1,alreadyGone:!1,reason:`could not remove ${n}: ${a instanceof Error?a.message:String(a)}`}}}return!s&&e===l.length?{removed:!1,alreadyGone:!0,reason:"already removed"}:{removed:s,alreadyGone:!1}}c(y,"deletePaths");function I(r){try{return i.lstatSync(r).isSymbolicLink()}catch{return!1}}c(I,"isSymlink");function b(r){let l=r.name??r.instructionId,t=[],s=r.reversals.filter(e=>e.reversed);if(r.stripped.length>0)t.push(`Removed ${l} from ${r.stripped.join(", ")}.`);else if(s.length>0)for(let e of s)t.push(`Removed ${l} from ${e.target}.`),e.drifted&&t.push(" (that file had changed since it was installed; only the recorded entry was removed)");else{let e=r.searched.length>0?` (searched ${r.searched.join(", ")})`:"";t.push(`No rulemetric-managed block for ${r.instructionId} was found in this directory${e}.`)}for(let e of r.reversals.filter(n=>!n.reversed))t.push(`Still installed in ${e.target}: ${e.reason??"the recorded inverse did not apply"}`);return r.dismissalError?(t.push(`Could not record the dismissal: ${r.dismissalError}`),t.push(r.stripped.length>0||s.length>0?' What was removed above stays removed \u2014 only the "stop proposing this" record failed.':" Nothing was removed, and the dismissal was not recorded either."),t.push(" This proposal may be suggested again. Re-run this command to retry."),t):(t.push("It will not be proposed again for 30 days."),t.push("Turn auto-adoption off entirely: rulemetric suggestions auto --off"),t)}c(b,"describeUndo");export{w as a,y as b,b as c};
@@ -1 +1 @@
1
- import{b as s,c as a}from"./chunk-5MXZJWQS.js";import{f as c}from"./chunk-FBSZ6KCM.js";import{f as u}from"./chunk-XQYAVSUQ.js";import{a as m}from"./chunk-ZLLER3HP.js";import{mkdtempSync as p,rmSync as d}from"node:fs";import{join as f}from"node:path";import{tmpdir as l}from"node:os";async function g(n,o,i){let r=u.parse(n),e=p(f(l(),"rulemetric-measurement-generation-"));try{let t=await c({engine:r.engine,model:r.model??void 0,systemPrompt:o,prompt:i,workDir:e,timeout:12e4});if(t.error||t.exitCode!==0||!t.output.trim())throw new Error(`Selected ${r.engine} generator failed: ${t.error??`exit ${t.exitCode}, empty output`}`);return t.output}finally{d(e,{recursive:!0,force:!0})}}m(g,"runMeasurementText");async function S(n,o,i){let r=await g(n,o,i),e=s(a(r)??r);if(!e.ok||!e.value||Array.isArray(e.value)||typeof e.value!="object")throw new Error(`Selected ${n.engine} generator returned invalid JSON`);return e.value}m(S,"runMeasurementJson");export{g as a,S as b};
1
+ import{b as s,c as a}from"./chunk-5MXZJWQS.js";import{f as c}from"./chunk-4GOXEEXZ.js";import{f as u}from"./chunk-XQYAVSUQ.js";import{a as m}from"./chunk-ZLLER3HP.js";import{mkdtempSync as p,rmSync as d}from"node:fs";import{join as f}from"node:path";import{tmpdir as l}from"node:os";async function g(n,o,i){let r=u.parse(n),e=p(f(l(),"rulemetric-measurement-generation-"));try{let t=await c({engine:r.engine,model:r.model??void 0,systemPrompt:o,prompt:i,workDir:e,timeout:12e4});if(t.error||t.exitCode!==0||!t.output.trim())throw new Error(`Selected ${r.engine} generator failed: ${t.error??`exit ${t.exitCode}, empty output`}`);return t.output}finally{d(e,{recursive:!0,force:!0})}}m(g,"runMeasurementText");async function S(n,o,i){let r=await g(n,o,i),e=s(a(r)??r);if(!e.ok||!e.value||Array.isArray(e.value)||typeof e.value!="object")throw new Error(`Selected ${n.engine} generator returned invalid JSON`);return e.value}m(S,"runMeasurementJson");export{g as a,S as b};
@@ -1 +1 @@
1
- import{a as m,c as d}from"./chunk-VBXL7XO7.js";import{a as s}from"./chunk-ZLLER3HP.js";var h=4,i=1,_=2,f=.0641;function x(e,r=f){return!(e>0)||!(r>=0)?null:Math.sqrt((m+d)**2*r/e)}s(x,"mdeForPairs");function w(e,r=f){if(!(e>0))throw new Error("pairsForMde: mde must be > 0");if(!(r>=0))throw new Error("pairsForMde: variance must be >= 0");return Math.max(1,Math.ceil((m+d)**2*r/e**2))}s(w,"pairsForMde");var p=10,c=128;function R(e){let r=e.autoEvolvePairs;if(r==null)return{minPairs:p,configured:!1};let a=typeof r=="number"?r:typeof r=="string"?Number(r):NaN;if(!Number.isFinite(a)||a<1)return{minPairs:p,configured:!1,note:`metadata.autoEvolvePairs=${JSON.stringify(r)} is not a positive number \u2014 using the default ${p}`};let n=Math.floor(a);return{minPairs:Math.min(c,Math.max(10,n)),configured:!0,...n>c?{note:`metadata.autoEvolvePairs=${n} clamped to the ${c}-pair ceiling`}:n<10?{note:`metadata.autoEvolvePairs=${n} raised to ${10} \u2014 a controlled verdict is refused below ${10} pairs, so a smaller batch buys a certain refusal. Use metadata.autoEvolvePaused to stop the spend instead.`}:{}}}s(R,"readPairBudget");function $(e){let r=e.autoEvolvePaused;return r===!0||r==="true"}s($,"isEvolutionPaused");function O(e){let{liveCases:r,passes:a,variance:n}=e,t=Math.max(0,r)*Math.max(0,a),o=t*2,l=t*2;return{liveCases:r,passes:a,plannedPairs:t,proposalCalls:i,executorCalls:o,graderCalls:l,totalCalls:i+o+l,maxCalls:i+o+l*_,mde:x(t,n)}}s(O,"estimateEvolutionCost");function L(e){let{runs:r,plannedPairs:a,usablePairs:n,passes:t,liveCases:o,wallMs:l,variance:g}=e,b=e.proposalCalls??i,v=e.verdictPairs??n,C=r.length,E=r.filter(P=>P.status==="completed"&&P.grading?.judge_model!=null).length;return{proposalCalls:b,executorCalls:C,graderCalls:E,modelCalls:b+C+E,plannedPairs:a,usablePairs:n,verdictPairs:v,passes:t,liveCases:o,mde:x(v,g),wallMs:l}}s(L,"observedEvolutionCost");function A(e){return e==null?"n/a":`${(e*100).toFixed(1)}pp`}s(A,"pp");function D(e){return`${e.liveCases} case(s) x ${e.passes} pass(es) = ${e.plannedPairs} planned pair(s), ~${e.totalCalls} model calls (up to ${e.maxCalls}) \u2014 resolves an effect of +/-${A(e.mde)} at 80% power`}s(D,"describeEvolutionCost");export{h as a,i as b,_ as c,f as d,x as e,w as f,p as g,c as h,R as i,$ as j,O as k,L as l,A as m,D as n};
1
+ import{a as m,c as d}from"./chunk-HT6R6KR3.js";import{a as s}from"./chunk-ZLLER3HP.js";var h=4,i=1,_=2,f=.0641;function x(e,r=f){return!(e>0)||!(r>=0)?null:Math.sqrt((m+d)**2*r/e)}s(x,"mdeForPairs");function w(e,r=f){if(!(e>0))throw new Error("pairsForMde: mde must be > 0");if(!(r>=0))throw new Error("pairsForMde: variance must be >= 0");return Math.max(1,Math.ceil((m+d)**2*r/e**2))}s(w,"pairsForMde");var p=10,c=128;function R(e){let r=e.autoEvolvePairs;if(r==null)return{minPairs:p,configured:!1};let a=typeof r=="number"?r:typeof r=="string"?Number(r):NaN;if(!Number.isFinite(a)||a<1)return{minPairs:p,configured:!1,note:`metadata.autoEvolvePairs=${JSON.stringify(r)} is not a positive number \u2014 using the default ${p}`};let n=Math.floor(a);return{minPairs:Math.min(c,Math.max(10,n)),configured:!0,...n>c?{note:`metadata.autoEvolvePairs=${n} clamped to the ${c}-pair ceiling`}:n<10?{note:`metadata.autoEvolvePairs=${n} raised to ${10} \u2014 a controlled verdict is refused below ${10} pairs, so a smaller batch buys a certain refusal. Use metadata.autoEvolvePaused to stop the spend instead.`}:{}}}s(R,"readPairBudget");function $(e){let r=e.autoEvolvePaused;return r===!0||r==="true"}s($,"isEvolutionPaused");function O(e){let{liveCases:r,passes:a,variance:n}=e,t=Math.max(0,r)*Math.max(0,a),o=t*2,l=t*2;return{liveCases:r,passes:a,plannedPairs:t,proposalCalls:i,executorCalls:o,graderCalls:l,totalCalls:i+o+l,maxCalls:i+o+l*_,mde:x(t,n)}}s(O,"estimateEvolutionCost");function L(e){let{runs:r,plannedPairs:a,usablePairs:n,passes:t,liveCases:o,wallMs:l,variance:g}=e,b=e.proposalCalls??i,v=e.verdictPairs??n,C=r.length,E=r.filter(P=>P.status==="completed"&&P.grading?.judge_model!=null).length;return{proposalCalls:b,executorCalls:C,graderCalls:E,modelCalls:b+C+E,plannedPairs:a,usablePairs:n,verdictPairs:v,passes:t,liveCases:o,mde:x(v,g),wallMs:l}}s(L,"observedEvolutionCost");function A(e){return e==null?"n/a":`${(e*100).toFixed(1)}pp`}s(A,"pp");function D(e){return`${e.liveCases} case(s) x ${e.passes} pass(es) = ${e.plannedPairs} planned pair(s), ~${e.totalCalls} model calls (up to ${e.maxCalls}) \u2014 resolves an effect of +/-${A(e.mde)} at 80% power`}s(D,"describeEvolutionCost");export{h as a,i as b,_ as c,f as d,x as e,w as f,p as g,c as h,R as i,$ as j,O as k,L as l,A as m,D as n};
@@ -1 +1 @@
1
- import{b as o,f as a}from"./chunk-76UKAFNM.js";import{a as n}from"./chunk-ZLLER3HP.js";function c(e){return e==null?e??null:e instanceof Date?e.toISOString():e}n(c,"serializeDate");async function d(e){let r={provider:e.provider,plan:e.plan,limitType:e.limitType,value:e.value,unit:e.unit,comparator:e.comparator,resetsAt:c(e.resetsAt),sourceType:e.sourceType,sourceUrl:e.sourceUrl,sourceEvidence:e.sourceEvidence,confidence:e.confidence,observedAt:c(e.observedAt)};return a("/api/internal/research/observe",r)}n(d,"postObservation");async function f(e){let r=0,i=0,s=[];for(let u of e)try{await d(u),r++}catch(t){i++;let p=t instanceof o?`HTTP ${t.statusCode}: ${t.message}`:String(t);s.length<5&&s.push(p)}return{posted:r,failed:i,errors:s}}n(f,"postObservations");export{d as a,f as b};
1
+ import{b as o,f as a}from"./chunk-GIXHG5FK.js";import{a as n}from"./chunk-ZLLER3HP.js";function c(e){return e==null?e??null:e instanceof Date?e.toISOString():e}n(c,"serializeDate");async function d(e){let r={provider:e.provider,plan:e.plan,limitType:e.limitType,value:e.value,unit:e.unit,comparator:e.comparator,resetsAt:c(e.resetsAt),sourceType:e.sourceType,sourceUrl:e.sourceUrl,sourceEvidence:e.sourceEvidence,confidence:e.confidence,observedAt:c(e.observedAt)};return a("/api/internal/research/observe",r)}n(d,"postObservation");async function f(e){let r=0,i=0,s=[];for(let u of e)try{await d(u),r++}catch(t){i++;let p=t instanceof o?`HTTP ${t.statusCode}: ${t.message}`:String(t);s.length<5&&s.push(p)}return{posted:r,failed:i,errors:s}}n(f,"postObservations");export{d as a,f as b};