@tangle-network/agent-eval 1.0.20 → 1.0.22

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 (154) hide show
  1. package/CHANGELOG.md +32 -6
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-Dngk3LZ0.js → agent-profile-4j6f2n-x.js} +4 -4
  4. package/dist/agent-profile-4j6f2n-x.js.map +1 -0
  5. package/dist/{agent-profile-BO8ruI6R.d.ts → agent-profile-DU5InUT9.d.ts} +4 -4
  6. package/dist/{agent-profile-BO8ruI6R.d.ts.map → agent-profile-DU5InUT9.d.ts.map} +1 -1
  7. package/dist/analyst/index.d.ts +6 -6
  8. package/dist/analyst/index.js +5 -5
  9. package/dist/{analyze-runs-DicleUI_.d.ts → analyze-runs-DYYe18Gw.d.ts} +3 -3
  10. package/dist/{analyze-runs-DicleUI_.d.ts.map → analyze-runs-DYYe18Gw.d.ts.map} +1 -1
  11. package/dist/{analyze-runs-e9vfXY--.js → analyze-runs-jLTRKuoK.js} +5 -5
  12. package/dist/{analyze-runs-e9vfXY--.js.map → analyze-runs-jLTRKuoK.js.map} +1 -1
  13. package/dist/app-grade/index.d.ts +2 -2
  14. package/dist/app-grade/index.js +1 -1
  15. package/dist/{benchmark-command-BGZD77Un.js → benchmark-command-DkUpd9Q6.js} +4 -4
  16. package/dist/{benchmark-command-BGZD77Un.js.map → benchmark-command-DkUpd9Q6.js.map} +1 -1
  17. package/dist/benchmarks/index.d.ts +4 -4
  18. package/dist/benchmarks/index.js +3 -3
  19. package/dist/builder-eval/index.js +1 -1
  20. package/dist/{calibration-Ze7SjhT9.js → calibration-Cf-wpqqO.js} +2 -2
  21. package/dist/{calibration-Ze7SjhT9.js.map → calibration-Cf-wpqqO.js.map} +1 -1
  22. package/dist/campaign/index.d.ts +6 -6
  23. package/dist/campaign/index.js +9 -9
  24. package/dist/{campaign-BfDMncQN.js → campaign-C2mmydmx.js} +12 -12
  25. package/dist/{campaign-BfDMncQN.js.map → campaign-C2mmydmx.js.map} +1 -1
  26. package/dist/{campaign-evidence-BuKlRzSA.js → campaign-evidence-NtH29ctt.js} +3 -3
  27. package/dist/{campaign-evidence-BuKlRzSA.js.map → campaign-evidence-NtH29ctt.js.map} +1 -1
  28. package/dist/cli.js +5 -5
  29. package/dist/{cluster-bootstrap-BYIW7QJ4.js → cluster-bootstrap-B0MTOBRU.js} +2 -2
  30. package/dist/{cluster-bootstrap-BYIW7QJ4.js.map → cluster-bootstrap-B0MTOBRU.js.map} +1 -1
  31. package/dist/contract/index.d.ts +8 -8
  32. package/dist/contract/index.js +10 -10
  33. package/dist/{decision-point-DJWievVw.js → decision-point-Di2LATNH.js} +3 -3
  34. package/dist/{decision-point-DJWievVw.js.map → decision-point-Di2LATNH.js.map} +1 -1
  35. package/dist/{default-registry-CdMtoY-s.js → default-registry-CdFbxPnr.js} +2 -2
  36. package/dist/{default-registry-CdMtoY-s.js.map → default-registry-CdFbxPnr.js.map} +1 -1
  37. package/dist/{default-registry-BpGFsSpZ.d.ts → default-registry-aPvwtzEM.d.ts} +2 -2
  38. package/dist/{default-registry-BpGFsSpZ.d.ts.map → default-registry-aPvwtzEM.d.ts.map} +1 -1
  39. package/dist/{define-agent-eval-DuQNZajG.js → define-agent-eval-BROmIwn1.js} +5 -5
  40. package/dist/{define-agent-eval-DuQNZajG.js.map → define-agent-eval-BROmIwn1.js.map} +1 -1
  41. package/dist/{define-agent-eval-DcK8mg63.d.ts → define-agent-eval-DGWBgCid.d.ts} +6 -6
  42. package/dist/{define-agent-eval-DcK8mg63.d.ts.map → define-agent-eval-DGWBgCid.d.ts.map} +1 -1
  43. package/dist/diagnosis/index.d.ts +1 -1
  44. package/dist/diagnosis/index.js +1 -1
  45. package/dist/{eval-campaign-LmpC_5fm.js → eval-campaign-Dq8DEKmy.js} +2 -2
  46. package/dist/{eval-campaign-LmpC_5fm.js.map → eval-campaign-Dq8DEKmy.js.map} +1 -1
  47. package/dist/{evaluation-BCejQgkV.d.ts → evaluation-CFKj_IlJ.d.ts} +2 -2
  48. package/dist/{evaluation-BCejQgkV.d.ts.map → evaluation-CFKj_IlJ.d.ts.map} +1 -1
  49. package/dist/evaluation.d.ts +1 -1
  50. package/dist/experiment/index.d.ts +2 -2
  51. package/dist/experiment/index.js +6 -6
  52. package/dist/fuzz.js +1 -1
  53. package/dist/{index-CzfdjM6o.d.ts → index-B62BaRzH.d.ts} +2 -2
  54. package/dist/{index-CzfdjM6o.d.ts.map → index-B62BaRzH.d.ts.map} +1 -1
  55. package/dist/{index-DYNHOTTB.d.ts → index-BlTbxHlY.d.ts} +2 -2
  56. package/dist/{index-DYNHOTTB.d.ts.map → index-BlTbxHlY.d.ts.map} +1 -1
  57. package/dist/{index-Bc8BZfzb.d.ts → index-Bp3w4fWc.d.ts} +7 -7
  58. package/dist/{index-Bc8BZfzb.d.ts.map → index-Bp3w4fWc.d.ts.map} +1 -1
  59. package/dist/{index-BdLmBInV.d.ts → index-DNXFzSpc.d.ts} +23 -21
  60. package/dist/{index-BdLmBInV.d.ts.map → index-DNXFzSpc.d.ts.map} +1 -1
  61. package/dist/{index-gSu9DUiw.d.ts → index-DX87wzX3.d.ts} +7 -7
  62. package/dist/{index-gSu9DUiw.d.ts.map → index-DX87wzX3.d.ts.map} +1 -1
  63. package/dist/{index-D_eAFB3T.d.ts → index-QLDWZTxI.d.ts} +4 -4
  64. package/dist/{index-D_eAFB3T.d.ts.map → index-QLDWZTxI.d.ts.map} +1 -1
  65. package/dist/{index-CeYLLnfi.d.ts → index-YS58LHlx.d.ts} +17 -17
  66. package/dist/{index-CeYLLnfi.d.ts.map → index-YS58LHlx.d.ts.map} +1 -1
  67. package/dist/index.d.ts +17 -17
  68. package/dist/index.js +15 -15
  69. package/dist/{judge-gate-BliY81A0.js → judge-gate-CrN0PaAL.js} +2 -2
  70. package/dist/{judge-gate-BliY81A0.js.map → judge-gate-CrN0PaAL.js.map} +1 -1
  71. package/dist/{llm-judge-Bnxuwjxl.js → llm-judge-C813vmpc.js} +9 -9
  72. package/dist/{llm-judge-Bnxuwjxl.js.map → llm-judge-C813vmpc.js.map} +1 -1
  73. package/dist/{matrix-D6zEwLvE.d.ts → matrix-C-GxIgeJ.d.ts} +2 -2
  74. package/dist/{matrix-D6zEwLvE.d.ts.map → matrix-C-GxIgeJ.d.ts.map} +1 -1
  75. package/dist/meta-eval/index.d.ts +2 -2
  76. package/dist/meta-eval/index.js +6 -6
  77. package/dist/multishot/golden/index.d.ts +1 -1
  78. package/dist/multishot/index.d.ts +2 -2
  79. package/dist/openapi.json +1 -1
  80. package/dist/{outcome-observations-BpicIVQi.js → outcome-observations-DPkH-LHQ.js} +2 -2
  81. package/dist/{outcome-observations-BpicIVQi.js.map → outcome-observations-DPkH-LHQ.js.map} +1 -1
  82. package/dist/{paired-arms-Dep5tbsw.js → paired-arms-DjMEtYI9.js} +2 -2
  83. package/dist/{paired-arms-Dep5tbsw.js.map → paired-arms-DjMEtYI9.js.map} +1 -1
  84. package/dist/{paired-promotion-decision-Nt4CkkOT.js → paired-promotion-decision-Bi9__RQS.js} +2 -2
  85. package/dist/{paired-promotion-decision-Nt4CkkOT.js.map → paired-promotion-decision-Bi9__RQS.js.map} +1 -1
  86. package/dist/{paired-promotion-decision-BNzPfXDw.d.ts → paired-promotion-decision-DJU3fZxH.d.ts} +2 -2
  87. package/dist/{paired-promotion-decision-BNzPfXDw.d.ts.map → paired-promotion-decision-DJU3fZxH.d.ts.map} +1 -1
  88. package/dist/{pareto-C445lnEH.js → pareto-fJZg8pXm.js} +3 -3
  89. package/dist/{pareto-C445lnEH.js.map → pareto-fJZg8pXm.js.map} +1 -1
  90. package/dist/pipelines/index.js +1 -1
  91. package/dist/{promotion-gate-DjAsmBSZ.d.ts → promotion-gate-Da0xV4sa.d.ts} +2 -2
  92. package/dist/{promotion-gate-DjAsmBSZ.d.ts.map → promotion-gate-Da0xV4sa.d.ts.map} +1 -1
  93. package/dist/{promotion-policy-CUWOv01m.js → promotion-policy-DCgftbnd.js} +4 -4
  94. package/dist/{promotion-policy-CUWOv01m.js.map → promotion-policy-DCgftbnd.js.map} +1 -1
  95. package/dist/{release-confidence-DDrkmWxT.js → release-confidence-DGtuPDxJ.js} +2 -2
  96. package/dist/{release-confidence-DDrkmWxT.js.map → release-confidence-DGtuPDxJ.js.map} +1 -1
  97. package/dist/reporting.d.ts +3 -3
  98. package/dist/reporting.js +4 -4
  99. package/dist/{researcher-D35yo0B8.d.ts → researcher-CSlc84Bp.d.ts} +2 -2
  100. package/dist/{researcher-D35yo0B8.d.ts.map → researcher-CSlc84Bp.d.ts.map} +1 -1
  101. package/dist/{reward-hacking-DRb8K6N1.js → reward-hacking-BYiDFbIl.js} +2 -2
  102. package/dist/{reward-hacking-DRb8K6N1.js.map → reward-hacking-BYiDFbIl.js.map} +1 -1
  103. package/dist/rl.d.ts +4 -4
  104. package/dist/rl.js +7 -7
  105. package/dist/rollout/index.d.ts +2 -2
  106. package/dist/{rubric-predictive-validity-BMS7SUyh.js → rubric-predictive-validity-DL7gJ51F.js} +2 -2
  107. package/dist/{rubric-predictive-validity-BMS7SUyh.js.map → rubric-predictive-validity-DL7gJ51F.js.map} +1 -1
  108. package/dist/{run-record-CIflWk6i.js → run-record-CFbnkE1K.js} +2 -2
  109. package/dist/{run-record-CIflWk6i.js.map → run-record-CFbnkE1K.js.map} +1 -1
  110. package/dist/{runtime-rollouts-CfRyjk60.js → runtime-rollouts-BNrm5nC_.js} +2 -2
  111. package/dist/{runtime-rollouts-CfRyjk60.js.map → runtime-rollouts-BNrm5nC_.js.map} +1 -1
  112. package/dist/search/index.d.ts +2 -2
  113. package/dist/search/index.js +2 -2
  114. package/dist/{search-kernel-Ds2zILpY.d.ts → search-kernel-CQGLbmgn.d.ts} +3 -3
  115. package/dist/{search-kernel-Ds2zILpY.d.ts.map → search-kernel-CQGLbmgn.d.ts.map} +1 -1
  116. package/dist/{search-summary-BSftVrGY.js → search-summary-sPWiYtSl.js} +4 -4
  117. package/dist/{search-summary-BSftVrGY.js.map → search-summary-sPWiYtSl.js.map} +1 -1
  118. package/dist/{sequential-CqG6aLWS.js → sequential-9TVb5Nu5.js} +3 -3
  119. package/dist/{sequential-CqG6aLWS.js.map → sequential-9TVb5Nu5.js.map} +1 -1
  120. package/dist/{skillopt-optimization-method-DYwEndON.js → skillopt-optimization-method-QO1nU8Kz.js} +6 -6
  121. package/dist/{skillopt-optimization-method-DYwEndON.js.map → skillopt-optimization-method-QO1nU8Kz.js.map} +1 -1
  122. package/dist/{statistical-heldout--0b1lgx4.d.ts → statistical-heldout-CvOwNqt9.d.ts} +4 -4
  123. package/dist/{statistical-heldout--0b1lgx4.d.ts.map → statistical-heldout-CvOwNqt9.d.ts.map} +1 -1
  124. package/dist/{statistical-heldout-D6i58CJ5.js → statistical-heldout-DLO4Ebos.js} +3 -3
  125. package/dist/{statistical-heldout-D6i58CJ5.js.map → statistical-heldout-DLO4Ebos.js.map} +1 -1
  126. package/dist/{statistics-DCZIC-qT.js → statistics-CvvC-MPv.js} +28 -21
  127. package/dist/statistics-CvvC-MPv.js.map +1 -0
  128. package/dist/statistics.d.ts +2 -2
  129. package/dist/statistics.js +2 -2
  130. package/dist/{summary-report-D_uussI3.js → summary-report-BEhqoxrA.js} +3 -3
  131. package/dist/{summary-report-D_uussI3.js.map → summary-report-BEhqoxrA.js.map} +1 -1
  132. package/dist/{summary-report-Cv1AC-iv.d.ts → summary-report-DyZquTaH.d.ts} +2 -2
  133. package/dist/{summary-report-Cv1AC-iv.d.ts.map → summary-report-DyZquTaH.d.ts.map} +1 -1
  134. package/dist/supervisor-run/index.d.ts +1 -1
  135. package/dist/supervisor-run/index.js +1 -1
  136. package/dist/{systemone-C3xyEKvG.d.ts → systemone-DVk-Crtu.d.ts} +4 -4
  137. package/dist/{systemone-C3xyEKvG.d.ts.map → systemone-DVk-Crtu.d.ts.map} +1 -1
  138. package/dist/systemone.d.ts +2 -2
  139. package/dist/systemone.js +1 -1
  140. package/dist/{tool-waste-DEhKfiIE.js → tool-waste-BqSmmPUz.js} +2 -2
  141. package/dist/{tool-waste-DEhKfiIE.js.map → tool-waste-BqSmmPUz.js.map} +1 -1
  142. package/dist/trace-repair/index.js +1 -1
  143. package/dist/{tree-B2y1UR8o.js → tree-C-N2kP-8.js} +4 -4
  144. package/dist/{tree-B2y1UR8o.js.map → tree-C-N2kP-8.js.map} +1 -1
  145. package/dist/{types-BwF--ZRz.d.ts → types-BsdcSWnf.d.ts} +2 -2
  146. package/dist/{types-BwF--ZRz.d.ts.map → types-BsdcSWnf.d.ts.map} +1 -1
  147. package/dist/{types-BAJ2Hb-d.d.ts → types-DUVhW5V1.d.ts} +2 -2
  148. package/dist/{types-BAJ2Hb-d.d.ts.map → types-DUVhW5V1.d.ts.map} +1 -1
  149. package/dist/{types-CeMZYsNF.d.ts → types-ip2D3-Ib.d.ts} +2 -2
  150. package/dist/{types-CeMZYsNF.d.ts.map → types-ip2D3-Ib.d.ts.map} +1 -1
  151. package/docs/design/statistics-decisions.md +7 -0
  152. package/package.json +5 -5
  153. package/dist/agent-profile-Dngk3LZ0.js.map +0 -1
  154. package/dist/statistics-DCZIC-qT.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { u as CostProvenance } from "./cost-ledger-Czro9wmo.js";
2
- import { C as JudgeDimension, w as JudgeScore } from "./types-CeMZYsNF.js";
2
+ import { C as JudgeDimension, w as JudgeScore } from "./types-ip2D3-Ib.js";
3
3
  import { o as MatrixResult } from "./index-DwUGehqX.js";
4
4
  import { AgentProfile } from "@tangle-network/agent-interface";
5
5
  interface MultishotMessage {
@@ -381,4 +381,4 @@ interface RunMultishotMatrixResult {
381
381
  }
382
382
  declare function runMultishotMatrix<TPersona extends MultishotPersona>(opts: RunMultishotMatrixOptions<TPersona>): Promise<RunMultishotMatrixResult>;
383
383
  export { MultishotTransportRequest as A, MultishotMessage as C, MultishotToolDefinition as D, MultishotShape as E, MultishotTransportToolCall as M, assertMultishotShotResult as N, MultishotToolExecutor as O, MultishotFatalToolError as S, MultishotResult as T, renderDimensions as _, MultishotCellOutput as a, MultishotArtifact as b, RunMultishotMatrixResult as c, MultishotShot as d, RunMultishotOptions as f, MultishotJudgeConfig as g, JudgeRunResult as h, ConversationJudgeInput as i, MultishotTransportResponse as j, MultishotTransport as k, computeCellComposite as l, DEFAULT_JUDGE_MODEL as m, CellCompositeInput as n, MultishotJudges as o, runMultishot as p, CellCompositeScore as r, RunMultishotMatrixOptions as s, ArtifactJudgeInput as t, runMultishotMatrix as u, renderJsonFooter as v, MultishotPersona as w, MultishotDriverEmptyError as x, runJudge as y };
384
- //# sourceMappingURL=matrix-D6zEwLvE.d.ts.map
384
+ //# sourceMappingURL=matrix-C-GxIgeJ.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matrix-D6zEwLvE.d.ts","names":[],"sources":["../src/multishot/types.ts","../src/multishot/judges.ts","../src/multishot/multishot.ts","../src/multishot/matrix.ts"],"mappings":";;;;UAIiB;EACf;EACA;EACA;EACA,YAAY;IAAQ;IAAY;IAAc,MAAM;;;UAGrC;EACf;EACA;EACA;IAAc;IAAc,MAAM;;EAClC;;UAGe;EACf,YAAY;EACZ,WAAW;EACX;EACA;;;EAGA;;;;;;;;EAQA,iBAAiB;;UAGF;EACf;EACA;IACE;IACA;IACA,YAAY;;;;;;UAOC;EACf;EACA,UAAU,MAAM;EAChB,QAAQ;EACR;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;IAAY;IAAc;;;UAGX;EACf;IAAW;IAAyB,aAAa;;EACjD;IAAU;IAAwB;;;;EAGlC;;;;EAIA;;;;;;;;KASU,sBACV,KAAK,8BACF,QAAQ;KAED,yBACV,MAAM,yBACN;;EAEE,WAAW;EACX,SAAS;MAER;EAAU;EAAiB;;UAEf;;EAEf;;GAEC;;;;;;;;UASc,eAAe,iBAAiB;;EAE/C,eAAe,SAAS;;;EAGxB,2BAA2B,SAAS;;cAGzB,kCAAkC;WACjB;EAAA,YAAA;;cAMjB,gCAAgC;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AEA;;EAEA;;EAEA;;;;EAIA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA,gBAAgB;;EAEhB,iBAAiB;;;EAGjB,gBAAgB;;;;;;;;;;;;;;;EAehB,UAAU,cAAc;;;;;UAMT;EACf;EACA;EACA;;UAoBe;EACf,cAAc;;EAEd,cAAc,cAAc;;EAE5B,iBAAiB,cAAc;;;;;;;iBAQjB,qBAAqB,OAAO;EAC1C;EACA;EACA;EACA;;UAuBe;EACf,QAAQ,aAAa;;iBAGD,mBAAmB,iBAAiB,kBACxD,MAAM,0BAA0B,YAC/B,QAAQ"}
1
+ {"version":3,"file":"matrix-C-GxIgeJ.d.ts","names":[],"sources":["../src/multishot/types.ts","../src/multishot/judges.ts","../src/multishot/multishot.ts","../src/multishot/matrix.ts"],"mappings":";;;;UAIiB;EACf;EACA;EACA;EACA,YAAY;IAAQ;IAAY;IAAc,MAAM;;;UAGrC;EACf;EACA;EACA;IAAc;IAAc,MAAM;;EAClC;;UAGe;EACf,YAAY;EACZ,WAAW;EACX;EACA;;;EAGA;;;;;;;;EAQA,iBAAiB;;UAGF;EACf;EACA;IACE;IACA;IACA,YAAY;;;;;;UAOC;EACf;EACA,UAAU,MAAM;EAChB,QAAQ;EACR;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;IAAY;IAAc;;;UAGX;EACf;IAAW;IAAyB,aAAa;;EACjD;IAAU;IAAwB;;;;EAGlC;;;;EAIA;;;;;;;;KASU,sBACV,KAAK,8BACF,QAAQ;KAED,yBACV,MAAM,yBACN;;EAEE,WAAW;EACX,SAAS;MAER;EAAU;EAAiB;;UAEf;;EAEf;;GAEC;;;;;;;;UASc,eAAe,iBAAiB;;EAE/C,eAAe,SAAS;;;EAGxB,2BAA2B,SAAS;;cAGzB,kCAAkC;WACjB;EAAA,YAAA;;cAMjB,gCAAgC;EAC/B,YAAA;;;;;;;;;;;;;;;;;;;iBAgCE,0BAA0B,yBAAyB,SAAS;cCvI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;;EAEA;;;;EAIA,gBAAgB;;EAEhB,iBAAiB;;;EAGjB,gBAAgB;;;;;;;;;;;;;;;EAehB,UAAU,cAAc;;;;;UAMT;EACf;EACA;EACA;;UAoBe;EACf,cAAc;;EAEd,cAAc,cAAc;;EAE5B,iBAAiB,cAAc;;;;;;;iBAQjB,qBAAqB,OAAO;EAC1C;EACA;EACA;EACA;;UAuBe;EACf,QAAQ,aAAa;;iBAGD,mBAAmB,iBAAiB,kBACxD,MAAM,0BAA0B,YAC/B,QAAQ"}
@@ -1,4 +1,4 @@
1
- import { Bt as ContinuousAgreement, Gt as SelfPreferenceResult, Ht as ContinuousCalibrationResult, Jt as calibrateJudgeContinuous, Kt as VerbosityBiasResult, Qt as verbosityBias, Rt as CalibrationResult, Ut as GoldenItem, Vt as ContinuousAgreementOptions, Wt as PositionalBiasResult, Xt as positionalBias, Yt as continuousAgreement, Zt as selfPreference, qt as calibrateJudge, zt as CandidateScore } from "../index-BdLmBInV.js";
1
+ import { $t as selfPreference, Bt as CalibrationResult, Gt as GoldenItem, Ht as ContinuousAgreement, Jt as VerbosityBiasResult, Kt as PositionalBiasResult, Qt as positionalBias, Ut as ContinuousAgreementOptions, Vt as CandidateScore, Wt as ContinuousCalibrationResult, Xt as calibrateJudgeContinuous, Yt as calibrateJudge, Zt as continuousAgreement, en as verbosityBias, qt as SelfPreferenceResult } from "../index-DNXFzSpc.js";
2
2
  import { a as RubricPredictiveValidityReport, c as CorrelationInterval, d as FileSystemOutcomeStore, f as FileSystemOutcomeStoreOptions, g as OutcomeStoreError, h as OutcomeStore, i as RubricPredictiveValidityInput, l as OutcomeReduction, m as OutcomeFilter, n as RubricOutcomeExclusion, o as RubricRanking, p as InMemoryOutcomeStore, r as RubricOutcomePair, s as rubricPredictiveValidity, t as OutcomeMetricSpec, u as DeploymentOutcome } from "../rubric-predictive-validity-B3RzbwOx.js";
3
- import { $ as measureJudgeAgreement, $t as CorrelationStudyOptions, A as JudgePanelOutput, At as ProbabilityPolicyAuditInput, B as JudgeConfusion, Bt as clusterBootstrapMean, C as JudgeCalibrationCellVerdict, Ct as EvaluatorAdmissionPolicy, D as JudgeCalibrationGoldItem, Dt as EvaluatorAuditPlan, E as JudgeCalibrationGateConfig, Et as EvaluatorAuditObservation, F as CalibrationExample, Ft as evaluatorAuditObservationSchema, G as JudgeGateRefusedError, Gt as CategoricalForecast, H as JudgeGateDecision, Ht as CalibrationOptions, I as CalibrationMerge, It as planEvaluatorAudit, J as JudgeRunMeta, Jt as calibrationCurve, K as JudgeGateStatus, Kt as OrdinalForecast, L as DEFAULT_JUDGE_GATE_POLICY, Lt as ClusterBootstrapOptions, M as RubricDimensionGuide, Mt as auditEvaluator, N as calibrateJudgePanel, Nt as auditProbabilityPolicy, O as JudgeDimensionCalibration, Ot as EvaluatorAuditPlanInput, P as gateJudgeCalibration, Pt as evaluatorAdmissionPolicySchema, Q as judgeGateDecision, Qt as CorrelationResult, R as JudgeAgreement, Rt as ClusterBootstrapResult, S as CalibrateJudgePanelInput, T as JudgeCalibrationGateCell, Tt as EvaluatorAuditInput, U as JudgeGateInput, Ut as CalibrationPair, V as JudgeExampleAgreement, Vt as CalibrationBin, W as JudgeGatePolicy, Wt as CalibrationReport, X as addCalibrationVerdicts, Xt as multiclassBrierScore, Y as OwnerVerdict, Yt as calibrationFromPairs, Z as assertJudgeMayGate, Zt as rankedProbabilityScore, _ as catchRate, _t as snapshotFromCalibration, a as PerturbedField, at as SentinelMetrics, b as plantByPerturbation, c as PlantEvidence, ct as SentinelSnapshot, d as PlantKindCounts, dt as SentinelTrend, en as CorrelationStudyResult, et as registerCalibrationSet, f as PlantManifest, ft as SnapshotMeta, g as UnseededRejection, gt as snapshotFromAgreement, h as SeededGradingSet, ht as judgeSentinelReport, i as PerturbationKind, it as SentinelMetricName, j as JudgePanelPrompt, jt as ProbabilityPolicyAuditReport, k as JudgePanelCalibration, kt as EvaluatorErrorRate, l as PlantExpectation, lt as SentinelStore, m as SeedPlantsOptions, mt as fileSentinelStore, n as CatchRateStatus, nn as OutcomePair, nt as EvalHealthStamp, o as PerturbedPlant, ot as SentinelReport, p as PlantOutcome, pt as evalHealthStamp, q as JudgeRun, qt as brierScore, r as EvidencePerturbation, rn as correlationStudy, rt as JudgeSentinelOptions, s as Plant, st as SentinelSetOptions, t as CatchRateReport, tn as EvalMetricSpec, tt as snapshotFromJudgeAgreement, u as PlantKind, ut as SentinelThresholds, v as definePlant, vt as snapshotFromSentinelSet, w as JudgeCalibrationGate, wt as EvaluatorAdmissionReport, x as seedPlants, y as perturbEvidence, yt as validateSentinelSnapshot, z as JudgeCalibrationSet, zt as ClusteredObservation } from "../index-CzfdjM6o.js";
3
+ import { $ as measureJudgeAgreement, $t as CorrelationStudyOptions, A as JudgePanelOutput, At as ProbabilityPolicyAuditInput, B as JudgeConfusion, Bt as clusterBootstrapMean, C as JudgeCalibrationCellVerdict, Ct as EvaluatorAdmissionPolicy, D as JudgeCalibrationGoldItem, Dt as EvaluatorAuditPlan, E as JudgeCalibrationGateConfig, Et as EvaluatorAuditObservation, F as CalibrationExample, Ft as evaluatorAuditObservationSchema, G as JudgeGateRefusedError, Gt as CategoricalForecast, H as JudgeGateDecision, Ht as CalibrationOptions, I as CalibrationMerge, It as planEvaluatorAudit, J as JudgeRunMeta, Jt as calibrationCurve, K as JudgeGateStatus, Kt as OrdinalForecast, L as DEFAULT_JUDGE_GATE_POLICY, Lt as ClusterBootstrapOptions, M as RubricDimensionGuide, Mt as auditEvaluator, N as calibrateJudgePanel, Nt as auditProbabilityPolicy, O as JudgeDimensionCalibration, Ot as EvaluatorAuditPlanInput, P as gateJudgeCalibration, Pt as evaluatorAdmissionPolicySchema, Q as judgeGateDecision, Qt as CorrelationResult, R as JudgeAgreement, Rt as ClusterBootstrapResult, S as CalibrateJudgePanelInput, T as JudgeCalibrationGateCell, Tt as EvaluatorAuditInput, U as JudgeGateInput, Ut as CalibrationPair, V as JudgeExampleAgreement, Vt as CalibrationBin, W as JudgeGatePolicy, Wt as CalibrationReport, X as addCalibrationVerdicts, Xt as multiclassBrierScore, Y as OwnerVerdict, Yt as calibrationFromPairs, Z as assertJudgeMayGate, Zt as rankedProbabilityScore, _ as catchRate, _t as snapshotFromCalibration, a as PerturbedField, at as SentinelMetrics, b as plantByPerturbation, c as PlantEvidence, ct as SentinelSnapshot, d as PlantKindCounts, dt as SentinelTrend, en as CorrelationStudyResult, et as registerCalibrationSet, f as PlantManifest, ft as SnapshotMeta, g as UnseededRejection, gt as snapshotFromAgreement, h as SeededGradingSet, ht as judgeSentinelReport, i as PerturbationKind, it as SentinelMetricName, j as JudgePanelPrompt, jt as ProbabilityPolicyAuditReport, k as JudgePanelCalibration, kt as EvaluatorErrorRate, l as PlantExpectation, lt as SentinelStore, m as SeedPlantsOptions, mt as fileSentinelStore, n as CatchRateStatus, nn as OutcomePair, nt as EvalHealthStamp, o as PerturbedPlant, ot as SentinelReport, p as PlantOutcome, pt as evalHealthStamp, q as JudgeRun, qt as brierScore, r as EvidencePerturbation, rn as correlationStudy, rt as JudgeSentinelOptions, s as Plant, st as SentinelSetOptions, t as CatchRateReport, tn as EvalMetricSpec, tt as snapshotFromJudgeAgreement, u as PlantKind, ut as SentinelThresholds, v as definePlant, vt as snapshotFromSentinelSet, w as JudgeCalibrationGate, wt as EvaluatorAdmissionReport, x as seedPlants, y as perturbEvidence, yt as validateSentinelSnapshot, z as JudgeCalibrationSet, zt as ClusteredObservation } from "../index-B62BaRzH.js";
4
4
  export { type CalibrateJudgePanelInput, CalibrationBin, CalibrationExample, CalibrationMerge, CalibrationOptions, CalibrationPair, CalibrationReport, type CalibrationResult, type CandidateScore, CatchRateReport, CatchRateStatus, CategoricalForecast, ClusterBootstrapOptions, ClusterBootstrapResult, ClusteredObservation, type ContinuousAgreement, type ContinuousAgreementOptions, type ContinuousCalibrationResult, type CorrelationInterval, CorrelationResult, CorrelationStudyOptions, CorrelationStudyResult, DEFAULT_JUDGE_GATE_POLICY, DeploymentOutcome, type EvalHealthStamp, EvalMetricSpec, type EvaluatorAdmissionPolicy, type EvaluatorAdmissionReport, type EvaluatorAuditInput, type EvaluatorAuditObservation, type EvaluatorAuditPlan, type EvaluatorAuditPlanInput, type EvaluatorErrorRate, EvidencePerturbation, FileSystemOutcomeStore, FileSystemOutcomeStoreOptions, type GoldenItem, InMemoryOutcomeStore, JudgeAgreement, type JudgeCalibrationCellVerdict, type JudgeCalibrationGate, type JudgeCalibrationGateCell, type JudgeCalibrationGateConfig, type JudgeCalibrationGoldItem, JudgeCalibrationSet, JudgeConfusion, type JudgeDimensionCalibration, JudgeExampleAgreement, JudgeGateDecision, JudgeGateInput, JudgeGatePolicy, JudgeGateRefusedError, JudgeGateStatus, type JudgePanelCalibration, type JudgePanelOutput, type JudgePanelPrompt, JudgeRun, JudgeRunMeta, type JudgeSentinelOptions, OrdinalForecast, OutcomeFilter, OutcomeMetricSpec, OutcomePair, type OutcomeReduction, OutcomeStore, OutcomeStoreError, OwnerVerdict, PerturbationKind, PerturbedField, PerturbedPlant, Plant, PlantEvidence, PlantExpectation, PlantKind, PlantKindCounts, PlantManifest, PlantOutcome, type PositionalBiasResult, type ProbabilityPolicyAuditInput, type ProbabilityPolicyAuditReport, type RubricDimensionGuide, RubricOutcomeExclusion, RubricOutcomePair, RubricPredictiveValidityInput, RubricPredictiveValidityReport, RubricRanking, SeedPlantsOptions, SeededGradingSet, type SelfPreferenceResult, type SentinelMetricName, type SentinelMetrics, type SentinelReport, type SentinelSetOptions, type SentinelSnapshot, type SentinelStore, type SentinelThresholds, type SentinelTrend, type SnapshotMeta, UnseededRejection, type VerbosityBiasResult, addCalibrationVerdicts, assertJudgeMayGate, auditEvaluator, auditProbabilityPolicy, brierScore, calibrateJudge, calibrateJudgeContinuous, calibrateJudgePanel, calibrationCurve, calibrationFromPairs, catchRate, clusterBootstrapMean, continuousAgreement, correlationStudy, definePlant, evalHealthStamp, evaluatorAdmissionPolicySchema, evaluatorAuditObservationSchema, fileSentinelStore, gateJudgeCalibration, judgeGateDecision, judgeSentinelReport, measureJudgeAgreement, multiclassBrierScore, perturbEvidence, planEvaluatorAudit, plantByPerturbation, positionalBias, rankedProbabilityScore, registerCalibrationSet, rubricPredictiveValidity, seedPlants, selfPreference, snapshotFromAgreement, snapshotFromCalibration, snapshotFromJudgeAgreement, snapshotFromSentinelSet, validateSentinelSnapshot, verbosityBias };
@@ -1,15 +1,15 @@
1
1
  import { n as CaptureIntegrityError, s as ValidationError } from "../errors-DeEEV9Vx.js";
2
2
  import { a as hashCanonical, i as compareCodeUnits } from "../canonical-CicJlINA.js";
3
- import { G as calibrateJudge, J as positionalBias, K as calibrateJudgeContinuous, X as verbosityBias, Y as selfPreference, q as continuousAgreement } from "../statistics-DCZIC-qT.js";
3
+ import { J as continuousAgreement, K as calibrateJudge, X as selfPreference, Y as positionalBias, Z as verbosityBias, q as calibrateJudgeContinuous } from "../statistics-CvvC-MPv.js";
4
4
  import { t as mulberry32 } from "../random-DrzcgC7F.js";
5
5
  import { s as runMetricExtractor } from "../query-CGXzO9d4.js";
6
6
  import { n as callLlmJson } from "../llm-client-DMMSg-Ro.js";
7
- import { a as validateObservationOptions, i as reduceOutcomeMetric, n as correlationSummary, r as hasVariation, t as assertUniqueObservationIds } from "../outcome-observations-BpicIVQi.js";
8
- import { a as rankedProbabilityScore, i as multiclassBrierScore, n as calibrationCurve, r as calibrationFromPairs, t as brierScore } from "../calibration-Ze7SjhT9.js";
9
- import { a as judgeGateDecision, c as snapshotFromJudgeAgreement, d as judgeSentinelReport, f as snapshotFromAgreement, g as withJudgeRetry, h as validateSentinelSnapshot, i as assertJudgeMayGate, l as evalHealthStamp, m as snapshotFromSentinelSet, n as JudgeGateRefusedError, o as measureJudgeAgreement, p as snapshotFromCalibration, r as addCalibrationVerdicts, s as registerCalibrationSet, t as DEFAULT_JUDGE_GATE_POLICY, u as fileSentinelStore } from "../judge-gate-BliY81A0.js";
7
+ import { a as validateObservationOptions, i as reduceOutcomeMetric, n as correlationSummary, r as hasVariation, t as assertUniqueObservationIds } from "../outcome-observations-DPkH-LHQ.js";
8
+ import { a as rankedProbabilityScore, i as multiclassBrierScore, n as calibrationCurve, r as calibrationFromPairs, t as brierScore } from "../calibration-Cf-wpqqO.js";
9
+ import { a as judgeGateDecision, c as snapshotFromJudgeAgreement, d as judgeSentinelReport, f as snapshotFromAgreement, g as withJudgeRetry, h as validateSentinelSnapshot, i as assertJudgeMayGate, l as evalHealthStamp, m as snapshotFromSentinelSet, n as JudgeGateRefusedError, o as measureJudgeAgreement, p as snapshotFromCalibration, r as addCalibrationVerdicts, s as registerCalibrationSet, t as DEFAULT_JUDGE_GATE_POLICY, u as fileSentinelStore } from "../judge-gate-CrN0PaAL.js";
10
10
  import { t as computeInterval } from "../interval-Bd2f4CRT.js";
11
- import { t as clusterBootstrapMean } from "../cluster-bootstrap-BYIW7QJ4.js";
12
- import { t as rubricPredictiveValidity } from "../rubric-predictive-validity-BMS7SUyh.js";
11
+ import { t as clusterBootstrapMean } from "../cluster-bootstrap-B0MTOBRU.js";
12
+ import { t as rubricPredictiveValidity } from "../rubric-predictive-validity-DL7gJ51F.js";
13
13
  import { n as InMemoryOutcomeStore, r as OutcomeStoreError, t as FileSystemOutcomeStore } from "../outcome-store-TarrcfHG.js";
14
14
  import { z } from "zod";
15
15
  // src/meta-eval/correlation-study.ts
@@ -1,4 +1,4 @@
1
- import { A as MultishotTransportRequest, D as MultishotToolDefinition, T as MultishotResult, c as RunMultishotMatrixResult, f as RunMultishotOptions, s as RunMultishotMatrixOptions, w as MultishotPersona } from "../../matrix-D6zEwLvE.js";
1
+ import { A as MultishotTransportRequest, D as MultishotToolDefinition, T as MultishotResult, c as RunMultishotMatrixResult, f as RunMultishotOptions, s as RunMultishotMatrixOptions, w as MultishotPersona } from "../../matrix-C-GxIgeJ.js";
2
2
  interface CompareOptions {
3
3
  /** Stop after this many mismatches. A structural divergence high in the
4
4
  * tree would otherwise report every leaf below it. */
@@ -1,5 +1,5 @@
1
- import { C as JudgeDimension, w as JudgeScore } from "../types-CeMZYsNF.js";
2
- import { A as MultishotTransportRequest, C as MultishotMessage, D as MultishotToolDefinition, E as MultishotShape, M as MultishotTransportToolCall, N as assertMultishotShotResult, O as MultishotToolExecutor, S as MultishotFatalToolError, T as MultishotResult, _ as renderDimensions, a as MultishotCellOutput, b as MultishotArtifact, c as RunMultishotMatrixResult, d as MultishotShot, f as RunMultishotOptions, g as MultishotJudgeConfig, h as JudgeRunResult, i as ConversationJudgeInput, j as MultishotTransportResponse, k as MultishotTransport, l as computeCellComposite, m as DEFAULT_JUDGE_MODEL, n as CellCompositeInput, o as MultishotJudges, p as runMultishot, r as CellCompositeScore, s as RunMultishotMatrixOptions, t as ArtifactJudgeInput, u as runMultishotMatrix, v as renderJsonFooter, w as MultishotPersona, x as MultishotDriverEmptyError, y as runJudge } from "../matrix-D6zEwLvE.js";
1
+ import { C as JudgeDimension, w as JudgeScore } from "../types-ip2D3-Ib.js";
2
+ import { A as MultishotTransportRequest, C as MultishotMessage, D as MultishotToolDefinition, E as MultishotShape, M as MultishotTransportToolCall, N as assertMultishotShotResult, O as MultishotToolExecutor, S as MultishotFatalToolError, T as MultishotResult, _ as renderDimensions, a as MultishotCellOutput, b as MultishotArtifact, c as RunMultishotMatrixResult, d as MultishotShot, f as RunMultishotOptions, g as MultishotJudgeConfig, h as JudgeRunResult, i as ConversationJudgeInput, j as MultishotTransportResponse, k as MultishotTransport, l as computeCellComposite, m as DEFAULT_JUDGE_MODEL, n as CellCompositeInput, o as MultishotJudges, p as runMultishot, r as CellCompositeScore, s as RunMultishotMatrixOptions, t as ArtifactJudgeInput, u as runMultishotMatrix, v as renderJsonFooter, w as MultishotPersona, x as MultishotDriverEmptyError, y as runJudge } from "../matrix-C-GxIgeJ.js";
3
3
  import { AgentProfile } from "@tangle-network/agent-interface";
4
4
  /** Prompt and completion tokens one leg reported. */
5
5
  interface MultishotLegTokens {
package/dist/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "@tangle-network/agent-eval — wire protocol",
5
- "version": "1.0.20",
5
+ "version": "1.0.22",
6
6
  "description": "HTTP and stdio RPC interface to agent-eval. The TypeScript runtime is the source of truth; this spec is the contract that cross-language clients (Python, Rust, Go) generate from.\n\nWire-protocol version: 1.1.0. Bumps on breaking changes to request/response schemas.",
7
7
  "contact": {
8
8
  "name": "Tangle Network",
@@ -1,4 +1,4 @@
1
- import { et as pearsonR, nt as spearmanR, ut as makeRng } from "./statistics-DCZIC-qT.js";
1
+ import { dt as makeRng, rt as spearmanR, tt as pearsonR } from "./statistics-CvvC-MPv.js";
2
2
  // src/meta-eval/outcome-observations.ts
3
3
  /** Reduce observations of one named metric; unrelated keys cannot supply a value. */
4
4
  function reduceOutcomeMetric(outcomes, metric, reduction) {
@@ -73,4 +73,4 @@ function interval(values) {
73
73
  }
74
74
  export { validateObservationOptions as a, reduceOutcomeMetric as i, correlationSummary as n, validateOutcomeMetricSpecifications as o, hasVariation as r, assertUniqueObservationIds as t };
75
75
 
76
- //# sourceMappingURL=outcome-observations-BpicIVQi.js.map
76
+ //# sourceMappingURL=outcome-observations-DPkH-LHQ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"outcome-observations-BpicIVQi.js","names":[],"sources":["../src/meta-eval/outcome-observations.ts"],"sourcesContent":["import { pearsonR, spearmanR } from '../statistics'\nimport { makeRng } from '../statistics/internal'\nimport type { DeploymentOutcome } from './outcome-store'\n\nexport type OutcomeReduction = 'latest' | 'mean' | 'max'\n\nexport interface CorrelationInterval {\n lower: number\n upper: number\n}\n\n/** Reduce observations of one named metric; unrelated keys cannot supply a value. */\nexport function reduceOutcomeMetric(\n outcomes: readonly DeploymentOutcome[],\n metric: string,\n reduction: OutcomeReduction,\n): number | null {\n const observations = outcomes.flatMap((outcome) => {\n const value = outcome.metrics[metric]\n return Number.isFinite(outcome.capturedAt) &&\n typeof value === 'number' &&\n Number.isFinite(value)\n ? [{ capturedAt: outcome.capturedAt, value }]\n : []\n })\n if (observations.length === 0) return null\n if (reduction === 'mean') {\n return observations.reduce(\n (sum, observation) => sum + observation.value / observations.length,\n 0,\n )\n }\n if (reduction === 'max') return Math.max(...observations.map((observation) => observation.value))\n return observations.reduce((a, b) => (b.capturedAt > a.capturedAt ? b : a)).value\n}\n\nexport function hasVariation(values: readonly number[]): boolean {\n return values.some((value) => value !== values[0])\n}\n\nexport function correlationSummary(\n xs: number[],\n ys: number[],\n iterations: number,\n seed: number | undefined,\n): {\n pearson: number\n spearman: number\n pearsonCi95: CorrelationInterval | null\n spearmanCi95: CorrelationInterval | null\n} {\n const rng = makeRng(seed, xs, ys)\n const pearsons: number[] = []\n const spearmans: number[] = []\n for (let b = 0; b < iterations; b++) {\n const rx: number[] = []\n const ry: number[] = []\n for (let i = 0; i < xs.length; i++) {\n const index = Math.floor(rng() * xs.length)\n rx.push(xs[index]!)\n ry.push(ys[index]!)\n }\n // A constant resample has no estimable correlation, even when both sides agree.\n if (!hasVariation(rx) || !hasVariation(ry)) continue\n const pearson = pearsonR(rx, ry)\n const spearman = spearmanR(rx, ry)\n if (Number.isFinite(pearson)) pearsons.push(pearson)\n if (Number.isFinite(spearman)) spearmans.push(spearman)\n }\n return {\n pearson: pearsonR(xs, ys),\n spearman: spearmanR(xs, ys),\n pearsonCi95: interval(pearsons),\n spearmanCi95: interval(spearmans),\n }\n}\n\nexport function validateObservationOptions(\n reduction: OutcomeReduction,\n iterations: number,\n seed: number | undefined,\n): void {\n if (!['latest', 'mean', 'max'].includes(reduction)) {\n throw new Error('outcome reduction must be latest, mean, or max')\n }\n if (!Number.isSafeInteger(iterations) || iterations < 1) {\n throw new Error('bootstrap iterations must be a positive safe integer')\n }\n if (seed !== undefined && !Number.isFinite(seed)) {\n throw new Error('bootstrap seed must be finite')\n }\n}\n\nexport function assertUniqueObservationIds(ids: readonly string[], name: string): void {\n if (ids.some((id) => typeof id !== 'string' || id.trim().length === 0)) {\n throw new Error(`${name} must be a nonempty string`)\n }\n if (new Set(ids).size !== ids.length) throw new Error(`duplicate ${name} in outcome study`)\n}\n\nexport function validateOutcomeMetricSpecifications(\n metrics: readonly { id: string; direction: string }[],\n): void {\n if (!Array.isArray(metrics) || metrics.length === 0) {\n throw new Error('outcomeMetrics must declare at least one outcome metric and direction')\n }\n for (const metric of metrics) {\n if (!metric || typeof metric.id !== 'string' || metric.id.trim().length === 0) {\n throw new Error('each outcome metric must have a nonempty id and explicit direction')\n }\n if (metric.direction !== 'higher-is-better' && metric.direction !== 'lower-is-better') {\n throw new Error(\n `outcome metric ${metric.id} must declare higher-is-better or lower-is-better`,\n )\n }\n }\n assertUniqueObservationIds(\n metrics.map((metric) => metric.id),\n 'outcome metric',\n )\n}\n\nfunction interval(values: number[]): CorrelationInterval | null {\n if (values.length === 0) return null\n values.sort((a, b) => a - b)\n return {\n lower: Math.max(-1, values[Math.floor(0.025 * values.length)]!),\n upper: Math.min(1, values[Math.min(values.length - 1, Math.floor(0.975 * values.length))]!),\n }\n}\n"],"mappings":";;;AAYA,SAAgB,oBACd,UACA,QACA,WACe;CACf,MAAM,eAAe,SAAS,SAAS,YAAY;EACjD,MAAM,QAAQ,QAAQ,QAAQ;EAC9B,OAAO,OAAO,SAAS,QAAQ,UAAU,KACvC,OAAO,UAAU,YACjB,OAAO,SAAS,KAAK,IACnB,CAAC;GAAE,YAAY,QAAQ;GAAY;EAAM,CAAC,IAC1C,CAAC;CACP,CAAC;CACD,IAAI,aAAa,WAAW,GAAG,OAAO;CACtC,IAAI,cAAc,QAChB,OAAO,aAAa,QACjB,KAAK,gBAAgB,MAAM,YAAY,QAAQ,aAAa,QAC7D,CACF;CAEF,IAAI,cAAc,OAAO,OAAO,KAAK,IAAI,GAAG,aAAa,KAAK,gBAAgB,YAAY,KAAK,CAAC;CAChG,OAAO,aAAa,QAAQ,GAAG,MAAO,EAAE,aAAa,EAAE,aAAa,IAAI,CAAE,CAAC,CAAC;AAC9E;AAEA,SAAgB,aAAa,QAAoC;CAC/D,OAAO,OAAO,MAAM,UA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CAAC,WAAW,CAAC,GACnE,MAAM,IAAI,MAAM,GAAG,KAAK,2BAA2B;CAErD,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,QAAQ,MAAM,IAAI,MAAM,aAAa,KAAK,kBAAkB;AAC5F;AAEA,SAAgB,oCACd,SACM;CACN,IAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,GAChD,MAAM,IAAI,MAAM,uEAAuE;CAEzF,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,CAAC,UAAU,OAAO,OAAO,OAAO,YAAY,OAAO,GAAG,KAAK,CAAC,CAAC,WAAW,GAC1E,MAAM,IAAI,MAAM,oEAAoE;EAEtF,IAAI,OAAO,cAAc,sBAAsB,OAAO,cAAc,mBAClE,MAAM,IAAI,MACR,kBAAkB,OAAO,GAAG,kDAC9B;CAEJ;CACA,2BACE,QAAQ,KAAK,WAAW,OAAO,EAAE,GACjC,gBACF;AACF;AAEA,SAAS,SAAS,QAA8C;CAC9D,IAAI,OAAO,WAAW,GAAG,OAAO;CAChC,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC;CAC3B,OAAO;EACL,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,OAAQ,OAAO,MAAM,EAAG;EAC9D,OAAO,KAAK,IAAI,GAAG,OAAO,KAAK,IAAI,OAAO,SAAS,GAAG,KAAK,MAAM,OAAQ,OAAO,MAAM,CAAC,EAAG;CAC5F;AACF"}
1
+ {"version":3,"file":"outcome-observations-DPkH-LHQ.js","names":[],"sources":["../src/meta-eval/outcome-observations.ts"],"sourcesContent":["import { pearsonR, spearmanR } from '../statistics'\nimport { makeRng } from '../statistics/internal'\nimport type { DeploymentOutcome } from './outcome-store'\n\nexport type OutcomeReduction = 'latest' | 'mean' | 'max'\n\nexport interface CorrelationInterval {\n lower: number\n upper: number\n}\n\n/** Reduce observations of one named metric; unrelated keys cannot supply a value. */\nexport function reduceOutcomeMetric(\n outcomes: readonly DeploymentOutcome[],\n metric: string,\n reduction: OutcomeReduction,\n): number | null {\n const observations = outcomes.flatMap((outcome) => {\n const value = outcome.metrics[metric]\n return Number.isFinite(outcome.capturedAt) &&\n typeof value === 'number' &&\n Number.isFinite(value)\n ? [{ capturedAt: outcome.capturedAt, value }]\n : []\n })\n if (observations.length === 0) return null\n if (reduction === 'mean') {\n return observations.reduce(\n (sum, observation) => sum + observation.value / observations.length,\n 0,\n )\n }\n if (reduction === 'max') return Math.max(...observations.map((observation) => observation.value))\n return observations.reduce((a, b) => (b.capturedAt > a.capturedAt ? b : a)).value\n}\n\nexport function hasVariation(values: readonly number[]): boolean {\n return values.some((value) => value !== values[0])\n}\n\nexport function correlationSummary(\n xs: number[],\n ys: number[],\n iterations: number,\n seed: number | undefined,\n): {\n pearson: number\n spearman: number\n pearsonCi95: CorrelationInterval | null\n spearmanCi95: CorrelationInterval | null\n} {\n const rng = makeRng(seed, xs, ys)\n const pearsons: number[] = []\n const spearmans: number[] = []\n for (let b = 0; b < iterations; b++) {\n const rx: number[] = []\n const ry: number[] = []\n for (let i = 0; i < xs.length; i++) {\n const index = Math.floor(rng() * xs.length)\n rx.push(xs[index]!)\n ry.push(ys[index]!)\n }\n // A constant resample has no estimable correlation, even when both sides agree.\n if (!hasVariation(rx) || !hasVariation(ry)) continue\n const pearson = pearsonR(rx, ry)\n const spearman = spearmanR(rx, ry)\n if (Number.isFinite(pearson)) pearsons.push(pearson)\n if (Number.isFinite(spearman)) spearmans.push(spearman)\n }\n return {\n pearson: pearsonR(xs, ys),\n spearman: spearmanR(xs, ys),\n pearsonCi95: interval(pearsons),\n spearmanCi95: interval(spearmans),\n }\n}\n\nexport function validateObservationOptions(\n reduction: OutcomeReduction,\n iterations: number,\n seed: number | undefined,\n): void {\n if (!['latest', 'mean', 'max'].includes(reduction)) {\n throw new Error('outcome reduction must be latest, mean, or max')\n }\n if (!Number.isSafeInteger(iterations) || iterations < 1) {\n throw new Error('bootstrap iterations must be a positive safe integer')\n }\n if (seed !== undefined && !Number.isFinite(seed)) {\n throw new Error('bootstrap seed must be finite')\n }\n}\n\nexport function assertUniqueObservationIds(ids: readonly string[], name: string): void {\n if (ids.some((id) => typeof id !== 'string' || id.trim().length === 0)) {\n throw new Error(`${name} must be a nonempty string`)\n }\n if (new Set(ids).size !== ids.length) throw new Error(`duplicate ${name} in outcome study`)\n}\n\nexport function validateOutcomeMetricSpecifications(\n metrics: readonly { id: string; direction: string }[],\n): void {\n if (!Array.isArray(metrics) || metrics.length === 0) {\n throw new Error('outcomeMetrics must declare at least one outcome metric and direction')\n }\n for (const metric of metrics) {\n if (!metric || typeof metric.id !== 'string' || metric.id.trim().length === 0) {\n throw new Error('each outcome metric must have a nonempty id and explicit direction')\n }\n if (metric.direction !== 'higher-is-better' && metric.direction !== 'lower-is-better') {\n throw new Error(\n `outcome metric ${metric.id} must declare higher-is-better or lower-is-better`,\n )\n }\n }\n assertUniqueObservationIds(\n metrics.map((metric) => metric.id),\n 'outcome metric',\n )\n}\n\nfunction interval(values: number[]): CorrelationInterval | null {\n if (values.length === 0) return null\n values.sort((a, b) => a - b)\n return {\n lower: Math.max(-1, values[Math.floor(0.025 * values.length)]!),\n upper: Math.min(1, values[Math.min(values.length - 1, Math.floor(0.975 * values.length))]!),\n }\n}\n"],"mappings":";;;AAYA,SAAgB,oBACd,UACA,QACA,WACe;CACf,MAAM,eAAe,SAAS,SAAS,YAAY;EACjD,MAAM,QAAQ,QAAQ,QAAQ;EAC9B,OAAO,OAAO,SAAS,QAAQ,UAAU,KACvC,OAAO,UAAU,YACjB,OAAO,SAAS,KAAK,IACnB,CAAC;GAAE,YAAY,QAAQ;GAAY;EAAM,CAAC,IAC1C,CAAC;CACP,CAAC;CACD,IAAI,aAAa,WAAW,GAAG,OAAO;CACtC,IAAI,cAAc,QAChB,OAAO,aAAa,QACjB,KAAK,gBAAgB,MAAM,YAAY,QAAQ,aAAa,QAC7D,CACF;CAEF,IAAI,cAAc,OAAO,OAAO,KAAK,IAAI,GAAG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,SAAS,KAAA,KAAa,CAAC,OAAO,SAAS,IAAI,GAC7C,MAAM,IAAI,MAAM,+BAA+B;AAEnD;AAEA,SAAgB,2BAA2B,KAAwB,MAAoB;CACrF,IAAI,IAAI,MAAM,OAAO,OAAO,OAAO,YAAY,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC,GACnE,MAAM,IAAI,MAAM,GAAG,KAAK,2BAA2B;CAErD,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,QAAQ,MAAM,IAAI,MAAM,aAAa,KAAK,kBAAkB;AAC5F;AAEA,SAAgB,oCACd,SACM;CACN,IAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,GAChD,MAAM,IAAI,MAAM,uEAAuE;CAEzF,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,CAAC,UAAU,OAAO,OAAO,OAAO,YAAY,OAAO,GAAG,KAAK,CAAC,CAAC,WAAW,GAC1E,MAAM,IAAI,MAAM,oEAAoE;EAEtF,IAAI,OAAO,cAAc,sBAAsB,OAAO,cAAc,mBAClE,MAAM,IAAI,MACR,kBAAkB,OAAO,GAAG,kDAC9B;CAEJ;CACA,2BACE,QAAQ,KAAK,WAAW,OAAO,EAAE,GACjC,gBACF;AACF;AAEA,SAAS,SAAS,QAA8C;CAC9D,IAAI,OAAO,WAAW,GAAG,OAAO;CAChC,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC;CAC3B,OAAO;EACL,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,OAAQ,OAAO,MAAM,EAAG;EAC9D,OAAO,KAAK,IAAI,GAAG,OAAO,KAAK,IAAI,OAAO,SAAS,GAAG,KAAK,MAAM,OAAQ,OAAO,MAAM,CAAC,EAAG;CAC5F;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { s as ValidationError } from "./errors-DeEEV9Vx.js";
2
2
  import { a as findingTreatmentSchema } from "./finding-composition-Belh_qU3.js";
3
- import { _ as mcnemar, a as wilcoxonSignedRank, p as pairedBootstrap, y as pairedRiskDifference } from "./statistics-DCZIC-qT.js";
3
+ import { a as wilcoxonSignedRank, b as pairedRiskDifference, p as pairedBootstrap, v as mcnemar } from "./statistics-CvvC-MPv.js";
4
4
  // src/arm-populations.ts
5
5
  const keyOf = (row) => JSON.stringify([
6
6
  row.arm,
@@ -335,4 +335,4 @@ function metricValue(row, name) {
335
335
  }
336
336
  export { pairArms as n, pairRunRecords as r, comparePairedArms as t };
337
337
 
338
- //# sourceMappingURL=paired-arms-Dep5tbsw.js.map
338
+ //# sourceMappingURL=paired-arms-DjMEtYI9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"paired-arms-Dep5tbsw.js","names":[],"sources":["../src/arm-populations.ts","../src/paired-arms.ts"],"sourcesContent":["import type { FindingTreatment } from './analyst/finding-composition'\nimport { findingTreatmentSchema } from './analyst/finding-composition'\nimport type { PairedArmRow } from './paired-arms'\n\n/** Expected seed identities must be supplied independently of completed observations. */\nexport interface ArmAssignment {\n pairKey: string\n repKey?: string\n arm: string\n treatment?: FindingTreatment[]\n}\nexport interface ArmPopulationSummary {\n n: number\n passed: number\n failed: number\n missingOutcomes: number\n /** Unknown unless every unit's outcome was observed; missing is never a failed check. */\n passRate: number | null\n metrics: Record<string, { n: number; missing: number; sum: number | null; mean: number | null }>\n}\nexport interface ArmPopulationReading {\n arm: string\n assignments: ArmAssignment[]\n missingObservations: number\n formation: { formed: number; notFormed: number; unknown: number }\n asAssigned: ArmPopulationSummary\n asFormed: ArmPopulationSummary\n}\n\nconst keyOf = (row: ArmAssignment): string =>\n JSON.stringify([row.arm, row.pairKey, row.repKey ?? null])\nfunction checkIdentity(row: ArmAssignment): void {\n for (const value of [row.arm, row.pairKey, ...(row.repKey === undefined ? [] : [row.repKey])]) {\n if (typeof value !== 'string' || !value.trim())\n throw new TypeError('Arm assignments require nonempty identities')\n }\n if (row.treatment !== undefined) {\n if (!Array.isArray(row.treatment)) throw new TypeError('Arm treatment must be an array')\n for (const value of row.treatment) findingTreatmentSchema.parse(value)\n if (new Set(row.treatment.map((t) => t.id)).size !== row.treatment.length)\n throw new TypeError('Duplicate arm treatment id')\n }\n}\nfunction checkObservation(row: PairedArmRow): void {\n checkIdentity(row)\n if (row.pass != null && typeof row.pass !== 'boolean')\n throw new TypeError('Invalid arm pass value')\n if (row.formation !== undefined) {\n if (row.formation === null || typeof row.formation !== 'object')\n throw new TypeError('Invalid formation verdict')\n if (row.formation.formed !== null && typeof row.formation.formed !== 'boolean')\n throw new TypeError('Invalid formation state')\n if (row.formation.reason !== undefined && typeof row.formation.reason !== 'string')\n throw new TypeError('Invalid formation reason')\n }\n for (const value of Object.values(row.metrics ?? {})) {\n if (value !== null && !Number.isFinite(value)) throw new TypeError('Non-finite arm metric')\n }\n}\n\n/** One roster join serves comparison and both denominators; no outcomes are inferred from formation. */\nexport function prepareArmPopulations(\n observations: readonly PairedArmRow[],\n assignments: readonly ArmAssignment[],\n options: { baselineArm: string; treatmentArm: string; metricNames?: string[] },\n): { rows: PairedArmRow[]; readings: ArmPopulationReading[] } {\n const arms = [options.baselineArm, options.treatmentArm]\n const roster = new Map<string, ArmAssignment>()\n for (const entry of assignments) {\n if (!arms.includes(entry.arm)) continue\n checkIdentity(entry)\n const key = keyOf(entry)\n if (roster.has(key)) throw new TypeError('Duplicate arm assignment')\n roster.set(key, structuredClone(entry))\n }\n for (const arm of arms)\n if (![...roster.values()].some((r) => r.arm === arm))\n throw new TypeError(`No assignment roster for arm '${arm}'`)\n const actual = new Map<string, PairedArmRow>()\n for (const row of observations) {\n if (!arms.includes(row.arm)) continue\n checkObservation(row)\n const key = keyOf(row)\n if (!roster.has(key)) throw new TypeError('Observed seed is outside the assignment roster')\n if (actual.has(key)) throw new TypeError('Duplicate arm observation')\n actual.set(key, row)\n }\n const ordered = [...roster.entries()].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n // Placeholder rows carry identities only. They never manufacture pass, metrics or formation.\n const rows = ordered.map(([key, entry]) => actual.get(key) ?? entry)\n const metricNames =\n options.metricNames ??\n [...new Set([...actual.values()].flatMap((r) => Object.keys(r.metrics ?? {})))].sort()\n const readings = arms.map((arm) => {\n const declared = ordered.filter(([, r]) => r.arm === arm)\n const asAssigned = declared.map(([key]) => actual.get(key))\n const asFormed = asAssigned.filter(\n (row): row is PairedArmRow => row?.formation?.formed === true,\n )\n return {\n arm,\n assignments: declared.map(([, r]) => r),\n missingObservations: asAssigned.filter((r) => r === undefined).length,\n formation: {\n formed: asFormed.length,\n notFormed: asAssigned.filter((r) => r?.formation?.formed === false).length,\n unknown: asAssigned.filter((r) => r?.formation?.formed == null).length,\n },\n asAssigned: summarize(asAssigned, metricNames),\n asFormed: summarize(asFormed, metricNames),\n }\n })\n return { rows, readings }\n}\n\nfunction summarize(\n rows: readonly (PairedArmRow | undefined)[],\n names: readonly string[],\n): ArmPopulationSummary {\n const passed = rows.filter((r) => r?.pass === true).length\n const failed = rows.filter((r) => r?.pass === false).length\n const missingOutcomes = rows.length - passed - failed\n const metrics = Object.fromEntries(\n names.map((name) => {\n const values = rows.map((r) => r?.metrics?.[name]).filter((x): x is number => x != null)\n const sum = values.length ? values.reduce((s, v) => s + v, 0) : null\n return [\n name,\n {\n n: values.length,\n missing: rows.length - values.length,\n sum,\n mean: sum === null ? null : sum / values.length,\n },\n ]\n }),\n )\n return {\n n: rows.length,\n passed,\n failed,\n missingOutcomes,\n passRate: rows.length && !missingOutcomes ? passed / rows.length : null,\n metrics,\n }\n}\n","/**\n * Matched-pair arm comparison — \"did the treatment arm beat the baseline arm\n * on the SAME work items?\"\n *\n * An arm A/B over run records is only trustworthy when it is PAIRED: the same\n * task/scenario/seed evaluated under both arms, compared item-by-item, so\n * inter-item difficulty variance cancels instead of masquerading as an arm\n * effect. This module owns the two error-prone steps every consumer otherwise\n * hand-rolls:\n *\n * 1. Pairing — matching rows across arms by `pairKey` (and by `repKey`\n * within multi-rep items), with leftovers REPORTED rather than silently\n * dropped (a silently unbalanced pairing biases every paired statistic\n * downstream). Pairing never keys on outcome content: matching reps by\n * their outcomes deflates discordant-pair counts and makes McNemar\n * anti-conservative, so reps pair only by (`pairKey`, `repKey`) identity.\n * 2. Composition — feeding the matched pairs to the correct paired\n * estimators that already live in `statistics`: `mcnemar` +\n * `pairedRiskDifference` for pass/fail, `pairedBootstrap` +\n * `wilcoxonSignedRank` for continuous metrics. No statistic is\n * re-implemented here.\n *\n * The row shape is deliberately structural — callers project a `RunRecord`\n * (or any record) into `{ pairKey, arm, pass?, metrics? }`. Arm names are\n * caller-supplied parameters; the module ships no domain literal.\n */\n\nimport type { FindingTreatment } from './analyst/finding-composition'\nimport {\n type ArmAssignment,\n type ArmPopulationReading,\n prepareArmPopulations,\n} from './arm-populations'\nimport { ValidationError } from './errors'\nimport type { RunRecord } from './run-record'\nimport type { McNemarResult, PairedBootstrapOptions, PairedBootstrapResult } from './statistics'\nimport {\n mcnemar,\n pairedBootstrap,\n pairedRiskDifference,\n type RiskDifferenceResult,\n wilcoxonSignedRank,\n} from './statistics'\n\n/** One arm observation of one work item. Structural on purpose: callers\n * project their own record type (e.g. a `RunRecord`) into this shape. */\nexport interface PairedArmRow {\n /** Matching key — rows sharing a `pairKey` across both arms form pairs\n * (typically the task/scenario/seed identity). */\n pairKey: string\n /** Rep identity within a `pairKey` (e.g. a seed or rep number). Required on\n * every row of a `pairKey` that has more than one rep in either arm; reps\n * then pair only on exact (`pairKey`, `repKey`) match, never on outcome\n * content. Optional when each arm has at most one rep of the item. */\n repKey?: string\n /** Arm label this row was produced under. */\n arm: string\n /** Binary outcome; omit or null when no pass/fail outcome was observed. */\n pass?: boolean | null\n /** Actual formation verdict from the execution owner; absence/null stays unknown. */\n formation?: { formed: boolean | null; reason?: string }\n /** Recorded treatment provenance; assigned bundles live on the independent roster. */\n treatment?: FindingTreatment[]\n /** Named finite measurements; null/absent readings are unknown, not zero. */\n metrics?: Record<string, number | null>\n}\n\nexport interface PairArmsOptions {\n /** Arm treated as the control side of every pair. */\n baselineArm: string\n /** Arm treated as the treatment side of every pair. */\n treatmentArm: string\n}\n\n/** One matched (baseline, treatment) observation of the same work item. */\nexport interface MatchedPair {\n pairKey: string\n /** 0-based position of this pair within its `pairKey`, ordered by sorted\n * `repKey` (always 0 for a single-rep item). The rep identity itself is on\n * the rows (`baseline.repKey` / `treatment.repKey`). */\n repIndex: number\n baseline: PairedArmRow\n treatment: PairedArmRow\n}\n\nexport interface PairArmsResult {\n /** Matched pairs, ordered by (`pairKey`, `repIndex`). */\n pairs: MatchedPair[]\n /** Baseline rows left without a treatment counterpart — reported, never\n * silently dropped. */\n unpairedBaseline: PairedArmRow[]\n /** Treatment rows left without a baseline counterpart. */\n unpairedTreatment: PairedArmRow[]\n}\n\n/**\n * Match rows across two arms into (baseline, treatment) pairs by `pairKey`.\n *\n * A `pairKey` with at most one row per arm pairs directly, no `repKey`\n * needed. A `pairKey` with multiple reps in either arm requires `repKey` on\n * every one of its rows, and reps pair only on exact (`pairKey`, `repKey`)\n * match — pairing is keyed purely on row identity, never on outcome content\n * (outcome-keyed matching deflates discordant counts and biases McNemar), and\n * is therefore independent of input order. Reps whose `repKey` has no\n * counterpart in the other arm, and items present in only one arm, land in\n * the unpaired lists — reported, never truncated.\n *\n * Fail-loud: throws when either named arm has zero rows (an unknown arm\n * name would otherwise read as \"everything unpaired\"), when the two arm\n * names are equal, when a multi-rep `pairKey` has a row without `repKey`, or\n * when a (`pairKey`, arm) group repeats a `repKey` (the match would be\n * ambiguous).\n */\nexport function pairArms(rows: readonly PairedArmRow[], opts: PairArmsOptions): PairArmsResult {\n const { baselineArm, treatmentArm } = opts\n if (baselineArm === treatmentArm) {\n throw new ValidationError(\n `pairArms: baselineArm and treatmentArm are both '${baselineArm}' — an arm cannot be compared to itself`,\n )\n }\n\n // arm → pairKey → rows\n const byArm = new Map<string, Map<string, PairedArmRow[]>>()\n const armsSeen = new Set<string>()\n for (const row of rows) {\n armsSeen.add(row.arm)\n if (row.arm !== baselineArm && row.arm !== treatmentArm) continue\n const byKey = byArm.get(row.arm) ?? new Map<string, PairedArmRow[]>()\n const group = byKey.get(row.pairKey) ?? []\n group.push(row)\n byKey.set(row.pairKey, group)\n byArm.set(row.arm, byKey)\n }\n\n for (const arm of [baselineArm, treatmentArm]) {\n if (!byArm.has(arm)) {\n const seen = [...armsSeen].sort().join(', ') || '<none>'\n throw new ValidationError(`pairArms: no rows for arm '${arm}' (arms present: ${seen})`)\n }\n }\n\n const baselineByKey = byArm.get(baselineArm)!\n const treatmentByKey = byArm.get(treatmentArm)!\n\n const allKeys = [...new Set([...baselineByKey.keys(), ...treatmentByKey.keys()])].sort()\n const pairs: MatchedPair[] = []\n const unpairedBaseline: PairedArmRow[] = []\n const unpairedTreatment: PairedArmRow[] = []\n for (const pairKey of allKeys) {\n const b = baselineByKey.get(pairKey) ?? []\n const t = treatmentByKey.get(pairKey) ?? []\n\n if (b.length <= 1 && t.length <= 1) {\n if (b.length === 1 && t.length === 1) {\n const baseline = b[0]!\n const treatment = t[0]!\n if (baseline.repKey !== undefined || treatment.repKey !== undefined) {\n if (\n baseline.repKey === undefined ||\n treatment.repKey === undefined ||\n baseline.repKey !== treatment.repKey\n ) {\n unpairedBaseline.push(baseline)\n unpairedTreatment.push(treatment)\n continue\n }\n }\n pairs.push({ pairKey, repIndex: 0, baseline, treatment })\n } else {\n unpairedBaseline.push(...b)\n unpairedTreatment.push(...t)\n }\n continue\n }\n\n const bByRep = indexByRepKey(b, pairKey, baselineArm)\n const tByRep = indexByRepKey(t, pairKey, treatmentArm)\n const repKeys = [...new Set([...bByRep.keys(), ...tByRep.keys()])].sort()\n let repIndex = 0\n for (const repKey of repKeys) {\n const baseline = bByRep.get(repKey)\n const treatment = tByRep.get(repKey)\n if (baseline !== undefined && treatment !== undefined) {\n pairs.push({ pairKey, repIndex: repIndex++, baseline, treatment })\n } else if (baseline !== undefined) {\n unpairedBaseline.push(baseline)\n } else if (treatment !== undefined) {\n unpairedTreatment.push(treatment)\n }\n }\n }\n\n return { pairs, unpairedBaseline, unpairedTreatment }\n}\n\n/** Index a multi-rep (pairKey, arm) group by `repKey`, enforcing that every\n * row carries one and that no repKey repeats within the group. */\nfunction indexByRepKey(\n group: readonly PairedArmRow[],\n pairKey: string,\n arm: string,\n): Map<string, PairedArmRow> {\n const byRep = new Map<string, PairedArmRow>()\n for (const row of group) {\n if (row.repKey === undefined) {\n throw new ValidationError(\n `pairArms: pairKey '${pairKey}' has multiple reps in an arm, but a row in arm '${arm}' ` +\n `is missing repKey — multi-rep items require an explicit repKey on every row so reps ` +\n `pair by identity (pairing reps by outcome or by index would bias the paired statistics)`,\n )\n }\n if (byRep.has(row.repKey)) {\n throw new ValidationError(\n `pairArms: duplicate repKey '${row.repKey}' for pairKey '${pairKey}' in arm '${arm}' — ` +\n `(pairKey, repKey) must uniquely identify a rep within an arm`,\n )\n }\n byRep.set(row.repKey, row)\n }\n return byRep\n}\n\n/** Paired pass/fail comparison over the pairs where BOTH sides carry `pass`. */\nexport interface PairedCorrectness {\n /** Discordant pairs where the treatment passed and the baseline failed. */\n b10: number\n /** Discordant pairs where the baseline passed and the treatment failed. */\n b01: number\n /** Exact McNemar significance over the paired outcomes (`b === b10`, `c === b01`). */\n mcnemar: McNemarResult\n /** Paired effect size: p(treatment) − p(baseline) with a paired-variance CI. */\n riskDifference: RiskDifferenceResult\n}\n\n/** Paired delta summary for one named metric (delta = treatment − baseline). */\nexport interface PairedMetricDelta {\n name: string\n /** Pairs where BOTH sides carry a finite value for this metric. */\n n: number\n /** Pairs where at least one side does not carry the metric. */\n nMissing: number\n /** Median paired delta, or null when `n === 0`. */\n medianDelta: number | null\n /** Mean paired delta, or null when `n === 0`. */\n meanDelta: number | null\n /** Bootstrap CI on the paired delta (`pairedBootstrap`); null when\n * `n === 0` — a zero-width [0, 0] interval on no data would read as a\n * measured tight null. */\n bootstrapCi: PairedBootstrapResult | null\n /** Wilcoxon signed-rank test on the paired deltas; null when `n === 0`. */\n wilcoxon: { w: number; p: number } | null\n}\n\nexport interface ComparePairedArmsOptions extends PairArmsOptions {\n /** Supply all expected seeds to report as-assigned and as-formed populations. */\n assignments?: readonly ArmAssignment[]\n /** Metrics to compare. Default: every metric name observed on any matched\n * pair, sorted. A name that appears on no pair is still reported (with\n * `n = 0`) so a misspelled metric is visible instead of vanishing. */\n metricNames?: string[]\n /** Passed through to `pairedBootstrap` — set `seed` for reproducible CIs. */\n bootstrap?: PairedBootstrapOptions\n}\n\nexport interface PairedArmsComparison {\n /** Absent when the assignment population is unknown (no roster supplied). */\n armPopulations?: ArmPopulationReading[]\n nPairs: number\n nUnpairedBaseline: number\n nUnpairedTreatment: number\n /** null when no matched pair carries `pass` on both sides — a pass/fail\n * verdict over rows that never measured pass/fail would be fabricated. */\n correctness: PairedCorrectness | null\n metricDeltas: PairedMetricDelta[]\n}\n\n/**\n * Full matched-pair arm comparison: pair via {@link pairArms}, then compose\n * the paired estimators from `statistics` over the matched pairs.\n *\n * Correctness uses only the pairs where both sides carry `pass` (`mcnemar.n`\n * is that subset's size); each metric uses only the pairs where both sides\n * carry a finite value for it, with the remainder counted in `nMissing`.\n * Deltas are treatment − baseline throughout. With an assignment roster, pairing\n * covers declared seed identities; missing observations remain identity-only rows\n * and never contribute fabricated outcomes or metrics. Per-arm summaries report\n * every assignment and the explicitly formed subset separately.\n *\n * Fail-loud: inherits {@link pairArms}'s unknown-arm throw, and throws on a\n * non-finite metric value — silently treating corrupt telemetry as \"metric\n * absent\" would misreport it as missing coverage.\n */\nexport function comparePairedArms(\n rows: readonly PairedArmRow[],\n opts: ComparePairedArmsOptions,\n): PairedArmsComparison {\n const populations =\n opts.assignments === undefined ? undefined : prepareArmPopulations(rows, opts.assignments, opts)\n const { pairs, unpairedBaseline, unpairedTreatment } = pairArms(populations?.rows ?? rows, opts)\n\n let correctness: PairedCorrectness | null = null\n const baselinePass: number[] = []\n const treatmentPass: number[] = []\n for (const pair of pairs) {\n if (pair.baseline.pass == null || pair.treatment.pass == null) continue\n baselinePass.push(pair.baseline.pass ? 1 : 0)\n treatmentPass.push(pair.treatment.pass ? 1 : 0)\n }\n if (baselinePass.length > 0) {\n const mc = mcnemar(baselinePass, treatmentPass)\n correctness = {\n b10: mc.b,\n b01: mc.c,\n mcnemar: mc,\n riskDifference: pairedRiskDifference(baselinePass, treatmentPass),\n }\n }\n\n const metricNames =\n opts.metricNames ??\n [\n ...new Set(\n pairs.flatMap((p) => [\n ...Object.keys(p.baseline.metrics ?? {}),\n ...Object.keys(p.treatment.metrics ?? {}),\n ]),\n ),\n ].sort()\n\n const metricDeltas: PairedMetricDelta[] = metricNames.map((name) => {\n const before: number[] = []\n const after: number[] = []\n let nMissing = 0\n for (const pair of pairs) {\n const b = metricValue(pair.baseline, name)\n const t = metricValue(pair.treatment, name)\n if (b === undefined || t === undefined) {\n nMissing++\n continue\n }\n before.push(b)\n after.push(t)\n }\n const bootstrapCi = before.length === 0 ? null : pairedBootstrap(before, after, opts.bootstrap)\n return {\n name,\n n: before.length,\n nMissing,\n medianDelta: bootstrapCi?.median ?? null,\n meanDelta: bootstrapCi?.mean ?? null,\n bootstrapCi,\n wilcoxon: before.length === 0 ? null : wilcoxonSignedRank(before, after),\n }\n })\n\n return {\n ...(populations ? { armPopulations: populations.readings } : {}),\n nPairs: pairs.length,\n nUnpairedBaseline: unpairedBaseline.length,\n nUnpairedTreatment: unpairedTreatment.length,\n correctness,\n metricDeltas,\n }\n}\n\nexport interface MatchedRunRecordPair {\n pairKey: string\n repKey: string\n baseline: RunRecord\n treatment: RunRecord\n}\n\nexport interface PairRunRecordsResult {\n pairs: MatchedRunRecordPair[]\n unpairedBaseline: RunRecord[]\n unpairedTreatment: RunRecord[]\n}\n\ninterface RunRecordArmRow extends PairedArmRow {\n run: RunRecord\n repKey: string\n}\n\n/**\n * Pair two RunRecord arms by the identity of the evaluated work:\n * `(experimentId, scenarioId, seed)`.\n *\n * Falling back to array order, candidate id, or experiment id can compare\n * different tasks and fabricate lift. Duplicate identities throw.\n */\nexport function pairRunRecords(\n baselineRuns: readonly RunRecord[],\n treatmentRuns: readonly RunRecord[],\n): PairRunRecordsResult {\n const baselineRows = runRecordArmRows(baselineRuns, 'baseline')\n const treatmentRows = runRecordArmRows(treatmentRuns, 'treatment')\n validateRunRecordArmRows(baselineRows, 'baseline')\n validateRunRecordArmRows(treatmentRows, 'treatment')\n if (baselineRows.length === 0 || treatmentRows.length === 0) {\n return {\n pairs: [],\n unpairedBaseline: baselineRows.map((row) => row.run),\n unpairedTreatment: treatmentRows.map((row) => row.run),\n }\n }\n\n const result = pairArms([...baselineRows, ...treatmentRows], {\n baselineArm: 'baseline',\n treatmentArm: 'treatment',\n })\n return {\n pairs: result.pairs.map((pair) => {\n const baseline = pair.baseline as RunRecordArmRow\n const treatment = pair.treatment as RunRecordArmRow\n return {\n pairKey: pair.pairKey,\n repKey: baseline.repKey,\n baseline: baseline.run,\n treatment: treatment.run,\n }\n }),\n unpairedBaseline: result.unpairedBaseline.map((row) => (row as RunRecordArmRow).run),\n unpairedTreatment: result.unpairedTreatment.map((row) => (row as RunRecordArmRow).run),\n }\n}\n\nfunction runRecordArmRows(runs: readonly RunRecord[], arm: string): RunRecordArmRow[] {\n return runs.map((run) => {\n const scenarioId = run.scenarioId.trim()\n if (!scenarioId) {\n throw new ValidationError(\n `pairRunRecords: run '${run.runId}' is missing scenarioId; paired comparisons require explicit scenario identity`,\n )\n }\n return {\n pairKey: JSON.stringify([run.experimentId, scenarioId]),\n repKey: String(run.seed),\n arm,\n run,\n }\n })\n}\n\nfunction validateRunRecordArmRows(rows: readonly RunRecordArmRow[], arm: string): void {\n const byPairKey = new Map<string, RunRecordArmRow[]>()\n for (const row of rows) {\n const group = byPairKey.get(row.pairKey) ?? []\n group.push(row)\n byPairKey.set(row.pairKey, group)\n }\n for (const [pairKey, group] of byPairKey) {\n if (group.length > 1) indexByRepKey(group, pairKey, arm)\n }\n}\n\nfunction metricValue(row: PairedArmRow, name: string): number | undefined {\n const v = row.metrics?.[name]\n if (v == null) return undefined\n if (!Number.isFinite(v)) {\n throw new ValidationError(\n `comparePairedArms: non-finite value for metric '${name}' on pairKey '${row.pairKey}' (arm '${row.arm}'): ${v}`,\n )\n }\n return v\n}\n"],"mappings":";;;;AA6BA,MAAM,SAAS,QACb,KAAK,UAAU;CAAC,IAAI;CAAK,IAAI;CAAS,IAAI,UAAU;AAAI,CAAC;AAC3D,SAAS,cAAc,KAA0B;CAC/C,KAAK,MAAM,SAAS;EAAC,IAAI;EAAK,IAAI;EAAS,GAAI,IAAI,WAAW,KAAA,IAAY,CAAC,IAAI,CAAC,IAAI,MAAM;CAAE,GAC1F,IAAI,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,GAC3C,MAAM,IAAI,UAAU,6CAA6C;CAErE,IAAI,IAAI,cAAc,KAAA,GAAW;EAC/B,IAAI,CAAC,MAAM,QAAQ,IAAI,SAAS,GAAG,MAAM,IAAI,UAAU,gCAAgC;EACvF,KAAK,MAAM,SAAS,IAAI,WAAW,uBAAuB,MAAM,KAAK;EACrE,IAAI,IAAI,IAAI,IAAI,UAAU,KAAK,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,UAAU,QACjE,MAAM,IAAI,UAAU,4BAA4B;CACpD;AACF;AACA,SAAS,iBAAiB,KAAyB;CACjD,cAAc,GAAG;CACjB,IAAI,IAAI,QAAQ,QAAQ,OAAO,IAAI,SAAS,WAC1C,MAAM,IAAI,UAAU,wBAAwB;CAC9C,IAAI,IAAI,cAAc,KAAA,GAAW;EAC/B,IAAI,IAAI,cAAc,QAAQ,OAAO,IAAI,cAAc,UACrD,MAAM,IAAI,UAAU,2BAA2B;EACjD,IAAI,IAAI,UAAU,WAAW,QAAQ,OAAO,IAAI,UAAU,WAAW,WACnE,MAAM,IAAI,UAAU,yBAAyB;EAC/C,IAAI,IAAI,UAAU,WAAW,KAAA,KAAa,OAAO,IAAI,UAAU,WAAW,UACxE,MAAM,IAAI,UAAU,0BAA0B;CAClD;CACA,KAAK,MAAM,SAAS,OAAO,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.ts","../src/paired-arms.ts"],"sourcesContent":["import type { FindingTreatment } from './analyst/finding-composition'\nimport { findingTreatmentSchema } from './analyst/finding-composition'\nimport type { PairedArmRow } from './paired-arms'\n\n/** Expected seed identities must be supplied independently of completed observations. */\nexport interface ArmAssignment {\n pairKey: string\n repKey?: string\n arm: string\n treatment?: FindingTreatment[]\n}\nexport interface ArmPopulationSummary {\n n: number\n passed: number\n failed: number\n missingOutcomes: number\n /** Unknown unless every unit's outcome was observed; missing is never a failed check. */\n passRate: number | null\n metrics: Record<string, { n: number; missing: number; sum: number | null; mean: number | null }>\n}\nexport interface ArmPopulationReading {\n arm: string\n assignments: ArmAssignment[]\n missingObservations: number\n formation: { formed: number; notFormed: number; unknown: number }\n asAssigned: ArmPopulationSummary\n asFormed: ArmPopulationSummary\n}\n\nconst keyOf = (row: ArmAssignment): string =>\n JSON.stringify([row.arm, row.pairKey, row.repKey ?? null])\nfunction checkIdentity(row: ArmAssignment): void {\n for (const value of [row.arm, row.pairKey, ...(row.repKey === undefined ? [] : [row.repKey])]) {\n if (typeof value !== 'string' || !value.trim())\n throw new TypeError('Arm assignments require nonempty identities')\n }\n if (row.treatment !== undefined) {\n if (!Array.isArray(row.treatment)) throw new TypeError('Arm treatment must be an array')\n for (const value of row.treatment) findingTreatmentSchema.parse(value)\n if (new Set(row.treatment.map((t) => t.id)).size !== row.treatment.length)\n throw new TypeError('Duplicate arm treatment id')\n }\n}\nfunction checkObservation(row: PairedArmRow): void {\n checkIdentity(row)\n if (row.pass != null && typeof row.pass !== 'boolean')\n throw new TypeError('Invalid arm pass value')\n if (row.formation !== undefined) {\n if (row.formation === null || typeof row.formation !== 'object')\n throw new TypeError('Invalid formation verdict')\n if (row.formation.formed !== null && typeof row.formation.formed !== 'boolean')\n throw new TypeError('Invalid formation state')\n if (row.formation.reason !== undefined && typeof row.formation.reason !== 'string')\n throw new TypeError('Invalid formation reason')\n }\n for (const value of Object.values(row.metrics ?? {})) {\n if (value !== null && !Number.isFinite(value)) throw new TypeError('Non-finite arm metric')\n }\n}\n\n/** One roster join serves comparison and both denominators; no outcomes are inferred from formation. */\nexport function prepareArmPopulations(\n observations: readonly PairedArmRow[],\n assignments: readonly ArmAssignment[],\n options: { baselineArm: string; treatmentArm: string; metricNames?: string[] },\n): { rows: PairedArmRow[]; readings: ArmPopulationReading[] } {\n const arms = [options.baselineArm, options.treatmentArm]\n const roster = new Map<string, ArmAssignment>()\n for (const entry of assignments) {\n if (!arms.includes(entry.arm)) continue\n checkIdentity(entry)\n const key = keyOf(entry)\n if (roster.has(key)) throw new TypeError('Duplicate arm assignment')\n roster.set(key, structuredClone(entry))\n }\n for (const arm of arms)\n if (![...roster.values()].some((r) => r.arm === arm))\n throw new TypeError(`No assignment roster for arm '${arm}'`)\n const actual = new Map<string, PairedArmRow>()\n for (const row of observations) {\n if (!arms.includes(row.arm)) continue\n checkObservation(row)\n const key = keyOf(row)\n if (!roster.has(key)) throw new TypeError('Observed seed is outside the assignment roster')\n if (actual.has(key)) throw new TypeError('Duplicate arm observation')\n actual.set(key, row)\n }\n const ordered = [...roster.entries()].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n // Placeholder rows carry identities only. They never manufacture pass, metrics or formation.\n const rows = ordered.map(([key, entry]) => actual.get(key) ?? entry)\n const metricNames =\n options.metricNames ??\n [...new Set([...actual.values()].flatMap((r) => Object.keys(r.metrics ?? {})))].sort()\n const readings = arms.map((arm) => {\n const declared = ordered.filter(([, r]) => r.arm === arm)\n const asAssigned = declared.map(([key]) => actual.get(key))\n const asFormed = asAssigned.filter(\n (row): row is PairedArmRow => row?.formation?.formed === true,\n )\n return {\n arm,\n assignments: declared.map(([, r]) => r),\n missingObservations: asAssigned.filter((r) => r === undefined).length,\n formation: {\n formed: asFormed.length,\n notFormed: asAssigned.filter((r) => r?.formation?.formed === false).length,\n unknown: asAssigned.filter((r) => r?.formation?.formed == null).length,\n },\n asAssigned: summarize(asAssigned, metricNames),\n asFormed: summarize(asFormed, metricNames),\n }\n })\n return { rows, readings }\n}\n\nfunction summarize(\n rows: readonly (PairedArmRow | undefined)[],\n names: readonly string[],\n): ArmPopulationSummary {\n const passed = rows.filter((r) => r?.pass === true).length\n const failed = rows.filter((r) => r?.pass === false).length\n const missingOutcomes = rows.length - passed - failed\n const metrics = Object.fromEntries(\n names.map((name) => {\n const values = rows.map((r) => r?.metrics?.[name]).filter((x): x is number => x != null)\n const sum = values.length ? values.reduce((s, v) => s + v, 0) : null\n return [\n name,\n {\n n: values.length,\n missing: rows.length - values.length,\n sum,\n mean: sum === null ? null : sum / values.length,\n },\n ]\n }),\n )\n return {\n n: rows.length,\n passed,\n failed,\n missingOutcomes,\n passRate: rows.length && !missingOutcomes ? passed / rows.length : null,\n metrics,\n }\n}\n","/**\n * Matched-pair arm comparison — \"did the treatment arm beat the baseline arm\n * on the SAME work items?\"\n *\n * An arm A/B over run records is only trustworthy when it is PAIRED: the same\n * task/scenario/seed evaluated under both arms, compared item-by-item, so\n * inter-item difficulty variance cancels instead of masquerading as an arm\n * effect. This module owns the two error-prone steps every consumer otherwise\n * hand-rolls:\n *\n * 1. Pairing — matching rows across arms by `pairKey` (and by `repKey`\n * within multi-rep items), with leftovers REPORTED rather than silently\n * dropped (a silently unbalanced pairing biases every paired statistic\n * downstream). Pairing never keys on outcome content: matching reps by\n * their outcomes deflates discordant-pair counts and makes McNemar\n * anti-conservative, so reps pair only by (`pairKey`, `repKey`) identity.\n * 2. Composition — feeding the matched pairs to the correct paired\n * estimators that already live in `statistics`: `mcnemar` +\n * `pairedRiskDifference` for pass/fail, `pairedBootstrap` +\n * `wilcoxonSignedRank` for continuous metrics. No statistic is\n * re-implemented here.\n *\n * The row shape is deliberately structural — callers project a `RunRecord`\n * (or any record) into `{ pairKey, arm, pass?, metrics? }`. Arm names are\n * caller-supplied parameters; the module ships no domain literal.\n */\n\nimport type { FindingTreatment } from './analyst/finding-composition'\nimport {\n type ArmAssignment,\n type ArmPopulationReading,\n prepareArmPopulations,\n} from './arm-populations'\nimport { ValidationError } from './errors'\nimport type { RunRecord } from './run-record'\nimport type { McNemarResult, PairedBootstrapOptions, PairedBootstrapResult } from './statistics'\nimport {\n mcnemar,\n pairedBootstrap,\n pairedRiskDifference,\n type RiskDifferenceResult,\n wilcoxonSignedRank,\n} from './statistics'\n\n/** One arm observation of one work item. Structural on purpose: callers\n * project their own record type (e.g. a `RunRecord`) into this shape. */\nexport interface PairedArmRow {\n /** Matching key — rows sharing a `pairKey` across both arms form pairs\n * (typically the task/scenario/seed identity). */\n pairKey: string\n /** Rep identity within a `pairKey` (e.g. a seed or rep number). Required on\n * every row of a `pairKey` that has more than one rep in either arm; reps\n * then pair only on exact (`pairKey`, `repKey`) match, never on outcome\n * content. Optional when each arm has at most one rep of the item. */\n repKey?: string\n /** Arm label this row was produced under. */\n arm: string\n /** Binary outcome; omit or null when no pass/fail outcome was observed. */\n pass?: boolean | null\n /** Actual formation verdict from the execution owner; absence/null stays unknown. */\n formation?: { formed: boolean | null; reason?: string }\n /** Recorded treatment provenance; assigned bundles live on the independent roster. */\n treatment?: FindingTreatment[]\n /** Named finite measurements; null/absent readings are unknown, not zero. */\n metrics?: Record<string, number | null>\n}\n\nexport interface PairArmsOptions {\n /** Arm treated as the control side of every pair. */\n baselineArm: string\n /** Arm treated as the treatment side of every pair. */\n treatmentArm: string\n}\n\n/** One matched (baseline, treatment) observation of the same work item. */\nexport interface MatchedPair {\n pairKey: string\n /** 0-based position of this pair within its `pairKey`, ordered by sorted\n * `repKey` (always 0 for a single-rep item). The rep identity itself is on\n * the rows (`baseline.repKey` / `treatment.repKey`). */\n repIndex: number\n baseline: PairedArmRow\n treatment: PairedArmRow\n}\n\nexport interface PairArmsResult {\n /** Matched pairs, ordered by (`pairKey`, `repIndex`). */\n pairs: MatchedPair[]\n /** Baseline rows left without a treatment counterpart — reported, never\n * silently dropped. */\n unpairedBaseline: PairedArmRow[]\n /** Treatment rows left without a baseline counterpart. */\n unpairedTreatment: PairedArmRow[]\n}\n\n/**\n * Match rows across two arms into (baseline, treatment) pairs by `pairKey`.\n *\n * A `pairKey` with at most one row per arm pairs directly, no `repKey`\n * needed. A `pairKey` with multiple reps in either arm requires `repKey` on\n * every one of its rows, and reps pair only on exact (`pairKey`, `repKey`)\n * match — pairing is keyed purely on row identity, never on outcome content\n * (outcome-keyed matching deflates discordant counts and biases McNemar), and\n * is therefore independent of input order. Reps whose `repKey` has no\n * counterpart in the other arm, and items present in only one arm, land in\n * the unpaired lists — reported, never truncated.\n *\n * Fail-loud: throws when either named arm has zero rows (an unknown arm\n * name would otherwise read as \"everything unpaired\"), when the two arm\n * names are equal, when a multi-rep `pairKey` has a row without `repKey`, or\n * when a (`pairKey`, arm) group repeats a `repKey` (the match would be\n * ambiguous).\n */\nexport function pairArms(rows: readonly PairedArmRow[], opts: PairArmsOptions): PairArmsResult {\n const { baselineArm, treatmentArm } = opts\n if (baselineArm === treatmentArm) {\n throw new ValidationError(\n `pairArms: baselineArm and treatmentArm are both '${baselineArm}' — an arm cannot be compared to itself`,\n )\n }\n\n // arm → pairKey → rows\n const byArm = new Map<string, Map<string, PairedArmRow[]>>()\n const armsSeen = new Set<string>()\n for (const row of rows) {\n armsSeen.add(row.arm)\n if (row.arm !== baselineArm && row.arm !== treatmentArm) continue\n const byKey = byArm.get(row.arm) ?? new Map<string, PairedArmRow[]>()\n const group = byKey.get(row.pairKey) ?? []\n group.push(row)\n byKey.set(row.pairKey, group)\n byArm.set(row.arm, byKey)\n }\n\n for (const arm of [baselineArm, treatmentArm]) {\n if (!byArm.has(arm)) {\n const seen = [...armsSeen].sort().join(', ') || '<none>'\n throw new ValidationError(`pairArms: no rows for arm '${arm}' (arms present: ${seen})`)\n }\n }\n\n const baselineByKey = byArm.get(baselineArm)!\n const treatmentByKey = byArm.get(treatmentArm)!\n\n const allKeys = [...new Set([...baselineByKey.keys(), ...treatmentByKey.keys()])].sort()\n const pairs: MatchedPair[] = []\n const unpairedBaseline: PairedArmRow[] = []\n const unpairedTreatment: PairedArmRow[] = []\n for (const pairKey of allKeys) {\n const b = baselineByKey.get(pairKey) ?? []\n const t = treatmentByKey.get(pairKey) ?? []\n\n if (b.length <= 1 && t.length <= 1) {\n if (b.length === 1 && t.length === 1) {\n const baseline = b[0]!\n const treatment = t[0]!\n if (baseline.repKey !== undefined || treatment.repKey !== undefined) {\n if (\n baseline.repKey === undefined ||\n treatment.repKey === undefined ||\n baseline.repKey !== treatment.repKey\n ) {\n unpairedBaseline.push(baseline)\n unpairedTreatment.push(treatment)\n continue\n }\n }\n pairs.push({ pairKey, repIndex: 0, baseline, treatment })\n } else {\n unpairedBaseline.push(...b)\n unpairedTreatment.push(...t)\n }\n continue\n }\n\n const bByRep = indexByRepKey(b, pairKey, baselineArm)\n const tByRep = indexByRepKey(t, pairKey, treatmentArm)\n const repKeys = [...new Set([...bByRep.keys(), ...tByRep.keys()])].sort()\n let repIndex = 0\n for (const repKey of repKeys) {\n const baseline = bByRep.get(repKey)\n const treatment = tByRep.get(repKey)\n if (baseline !== undefined && treatment !== undefined) {\n pairs.push({ pairKey, repIndex: repIndex++, baseline, treatment })\n } else if (baseline !== undefined) {\n unpairedBaseline.push(baseline)\n } else if (treatment !== undefined) {\n unpairedTreatment.push(treatment)\n }\n }\n }\n\n return { pairs, unpairedBaseline, unpairedTreatment }\n}\n\n/** Index a multi-rep (pairKey, arm) group by `repKey`, enforcing that every\n * row carries one and that no repKey repeats within the group. */\nfunction indexByRepKey(\n group: readonly PairedArmRow[],\n pairKey: string,\n arm: string,\n): Map<string, PairedArmRow> {\n const byRep = new Map<string, PairedArmRow>()\n for (const row of group) {\n if (row.repKey === undefined) {\n throw new ValidationError(\n `pairArms: pairKey '${pairKey}' has multiple reps in an arm, but a row in arm '${arm}' ` +\n `is missing repKey — multi-rep items require an explicit repKey on every row so reps ` +\n `pair by identity (pairing reps by outcome or by index would bias the paired statistics)`,\n )\n }\n if (byRep.has(row.repKey)) {\n throw new ValidationError(\n `pairArms: duplicate repKey '${row.repKey}' for pairKey '${pairKey}' in arm '${arm}' — ` +\n `(pairKey, repKey) must uniquely identify a rep within an arm`,\n )\n }\n byRep.set(row.repKey, row)\n }\n return byRep\n}\n\n/** Paired pass/fail comparison over the pairs where BOTH sides carry `pass`. */\nexport interface PairedCorrectness {\n /** Discordant pairs where the treatment passed and the baseline failed. */\n b10: number\n /** Discordant pairs where the baseline passed and the treatment failed. */\n b01: number\n /** Exact McNemar significance over the paired outcomes (`b === b10`, `c === b01`). */\n mcnemar: McNemarResult\n /** Paired effect size: p(treatment) − p(baseline) with a paired-variance CI. */\n riskDifference: RiskDifferenceResult\n}\n\n/** Paired delta summary for one named metric (delta = treatment − baseline). */\nexport interface PairedMetricDelta {\n name: string\n /** Pairs where BOTH sides carry a finite value for this metric. */\n n: number\n /** Pairs where at least one side does not carry the metric. */\n nMissing: number\n /** Median paired delta, or null when `n === 0`. */\n medianDelta: number | null\n /** Mean paired delta, or null when `n === 0`. */\n meanDelta: number | null\n /** Bootstrap CI on the paired delta (`pairedBootstrap`); null when\n * `n === 0` — a zero-width [0, 0] interval on no data would read as a\n * measured tight null. */\n bootstrapCi: PairedBootstrapResult | null\n /** Wilcoxon signed-rank test on the paired deltas; null when `n === 0`. */\n wilcoxon: { w: number; p: number } | null\n}\n\nexport interface ComparePairedArmsOptions extends PairArmsOptions {\n /** Supply all expected seeds to report as-assigned and as-formed populations. */\n assignments?: readonly ArmAssignment[]\n /** Metrics to compare. Default: every metric name observed on any matched\n * pair, sorted. A name that appears on no pair is still reported (with\n * `n = 0`) so a misspelled metric is visible instead of vanishing. */\n metricNames?: string[]\n /** Passed through to `pairedBootstrap` — set `seed` for reproducible CIs. */\n bootstrap?: PairedBootstrapOptions\n}\n\nexport interface PairedArmsComparison {\n /** Absent when the assignment population is unknown (no roster supplied). */\n armPopulations?: ArmPopulationReading[]\n nPairs: number\n nUnpairedBaseline: number\n nUnpairedTreatment: number\n /** null when no matched pair carries `pass` on both sides — a pass/fail\n * verdict over rows that never measured pass/fail would be fabricated. */\n correctness: PairedCorrectness | null\n metricDeltas: PairedMetricDelta[]\n}\n\n/**\n * Full matched-pair arm comparison: pair via {@link pairArms}, then compose\n * the paired estimators from `statistics` over the matched pairs.\n *\n * Correctness uses only the pairs where both sides carry `pass` (`mcnemar.n`\n * is that subset's size); each metric uses only the pairs where both sides\n * carry a finite value for it, with the remainder counted in `nMissing`.\n * Deltas are treatment − baseline throughout. With an assignment roster, pairing\n * covers declared seed identities; missing observations remain identity-only rows\n * and never contribute fabricated outcomes or metrics. Per-arm summaries report\n * every assignment and the explicitly formed subset separately.\n *\n * Fail-loud: inherits {@link pairArms}'s unknown-arm throw, and throws on a\n * non-finite metric value — silently treating corrupt telemetry as \"metric\n * absent\" would misreport it as missing coverage.\n */\nexport function comparePairedArms(\n rows: readonly PairedArmRow[],\n opts: ComparePairedArmsOptions,\n): PairedArmsComparison {\n const populations =\n opts.assignments === undefined ? undefined : prepareArmPopulations(rows, opts.assignments, opts)\n const { pairs, unpairedBaseline, unpairedTreatment } = pairArms(populations?.rows ?? rows, opts)\n\n let correctness: PairedCorrectness | null = null\n const baselinePass: number[] = []\n const treatmentPass: number[] = []\n for (const pair of pairs) {\n if (pair.baseline.pass == null || pair.treatment.pass == null) continue\n baselinePass.push(pair.baseline.pass ? 1 : 0)\n treatmentPass.push(pair.treatment.pass ? 1 : 0)\n }\n if (baselinePass.length > 0) {\n const mc = mcnemar(baselinePass, treatmentPass)\n correctness = {\n b10: mc.b,\n b01: mc.c,\n mcnemar: mc,\n riskDifference: pairedRiskDifference(baselinePass, treatmentPass),\n }\n }\n\n const metricNames =\n opts.metricNames ??\n [\n ...new Set(\n pairs.flatMap((p) => [\n ...Object.keys(p.baseline.metrics ?? {}),\n ...Object.keys(p.treatment.metrics ?? {}),\n ]),\n ),\n ].sort()\n\n const metricDeltas: PairedMetricDelta[] = metricNames.map((name) => {\n const before: number[] = []\n const after: number[] = []\n let nMissing = 0\n for (const pair of pairs) {\n const b = metricValue(pair.baseline, name)\n const t = metricValue(pair.treatment, name)\n if (b === undefined || t === undefined) {\n nMissing++\n continue\n }\n before.push(b)\n after.push(t)\n }\n const bootstrapCi = before.length === 0 ? null : pairedBootstrap(before, after, opts.bootstrap)\n return {\n name,\n n: before.length,\n nMissing,\n medianDelta: bootstrapCi?.median ?? null,\n meanDelta: bootstrapCi?.mean ?? null,\n bootstrapCi,\n wilcoxon: before.length === 0 ? null : wilcoxonSignedRank(before, after),\n }\n })\n\n return {\n ...(populations ? { armPopulations: populations.readings } : {}),\n nPairs: pairs.length,\n nUnpairedBaseline: unpairedBaseline.length,\n nUnpairedTreatment: unpairedTreatment.length,\n correctness,\n metricDeltas,\n }\n}\n\nexport interface MatchedRunRecordPair {\n pairKey: string\n repKey: string\n baseline: RunRecord\n treatment: RunRecord\n}\n\nexport interface PairRunRecordsResult {\n pairs: MatchedRunRecordPair[]\n unpairedBaseline: RunRecord[]\n unpairedTreatment: RunRecord[]\n}\n\ninterface RunRecordArmRow extends PairedArmRow {\n run: RunRecord\n repKey: string\n}\n\n/**\n * Pair two RunRecord arms by the identity of the evaluated work:\n * `(experimentId, scenarioId, seed)`.\n *\n * Falling back to array order, candidate id, or experiment id can compare\n * different tasks and fabricate lift. Duplicate identities throw.\n */\nexport function pairRunRecords(\n baselineRuns: readonly RunRecord[],\n treatmentRuns: readonly RunRecord[],\n): PairRunRecordsResult {\n const baselineRows = runRecordArmRows(baselineRuns, 'baseline')\n const treatmentRows = runRecordArmRows(treatmentRuns, 'treatment')\n validateRunRecordArmRows(baselineRows, 'baseline')\n validateRunRecordArmRows(treatmentRows, 'treatment')\n if (baselineRows.length === 0 || treatmentRows.length === 0) {\n return {\n pairs: [],\n unpairedBaseline: baselineRows.map((row) => row.run),\n unpairedTreatment: treatmentRows.map((row) => row.run),\n }\n }\n\n const result = pairArms([...baselineRows, ...treatmentRows], {\n baselineArm: 'baseline',\n treatmentArm: 'treatment',\n })\n return {\n pairs: result.pairs.map((pair) => {\n const baseline = pair.baseline as RunRecordArmRow\n const treatment = pair.treatment as RunRecordArmRow\n return {\n pairKey: pair.pairKey,\n repKey: baseline.repKey,\n baseline: baseline.run,\n treatment: treatment.run,\n }\n }),\n unpairedBaseline: result.unpairedBaseline.map((row) => (row as RunRecordArmRow).run),\n unpairedTreatment: result.unpairedTreatment.map((row) => (row as RunRecordArmRow).run),\n }\n}\n\nfunction runRecordArmRows(runs: readonly RunRecord[], arm: string): RunRecordArmRow[] {\n return runs.map((run) => {\n const scenarioId = run.scenarioId.trim()\n if (!scenarioId) {\n throw new ValidationError(\n `pairRunRecords: run '${run.runId}' is missing scenarioId; paired comparisons require explicit scenario identity`,\n )\n }\n return {\n pairKey: JSON.stringify([run.experimentId, scenarioId]),\n repKey: String(run.seed),\n arm,\n run,\n }\n })\n}\n\nfunction validateRunRecordArmRows(rows: readonly RunRecordArmRow[], arm: string): void {\n const byPairKey = new Map<string, RunRecordArmRow[]>()\n for (const row of rows) {\n const group = byPairKey.get(row.pairKey) ?? []\n group.push(row)\n byPairKey.set(row.pairKey, group)\n }\n for (const [pairKey, group] of byPairKey) {\n if (group.length > 1) indexByRepKey(group, pairKey, arm)\n }\n}\n\nfunction metricValue(row: PairedArmRow, name: string): number | undefined {\n const v = row.metrics?.[name]\n if (v == null) return undefined\n if (!Number.isFinite(v)) {\n throw new ValidationError(\n `comparePairedArms: non-finite value for metric '${name}' on pairKey '${row.pairKey}' (arm '${row.arm}'): ${v}`,\n )\n }\n return v\n}\n"],"mappings":";;;;AA6BA,MAAM,SAAS,QACb,KAAK,UAAU;CAAC,IAAI;CAAK,IAAI;CAAS,IAAI,UAAU;AAAI,CAAC;AAC3D,SAAS,cAAc,KAA0B;CAC/C,KAAK,MAAM,SAAS;EAAC,IAAI;EAAK,IAAI;EAAS,GAAI,IAAI,WAAW,KAAA,IAAY,CAAC,IAAI,CAAC,IAAI,MAAM;CAAE,GAC1F,IAAI,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,GAC3C,MAAM,IAAI,UAAU,6CAA6C;CAEr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I,gBACR,wBAAwB,IAAI,MAAM,+EACpC;EAEF,OAAO;GACL,SAAS,KAAK,UAAU,CAAC,IAAI,cAAc,UAAU,CAAC;GACtD,QAAQ,OAAO,IAAI,IAAI;GACvB;GACA;EACF;CACF,CAAC;AACH;AAEA,SAAS,yBAAyB,MAAkC,KAAmB;CACrF,MAAM,4BAAY,IAAI,IAA+B;CACrD,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAQ,UAAU,IAAI,IAAI,OAAO,KAAK,CAAC;EAC7C,MAAM,KAAK,GAAG;EACd,UAAU,IAAI,IAAI,SAAS,KAAK;CAClC;CACA,KAAK,MAAM,CAAC,SAAS,UAAU,WAC7B,IAAI,MAAM,SAAS,GAAG,cAAc,OAAO,SAAS,GAAG;AAE3D;AAEA,SAAS,YAAY,KAAmB,MAAkC;CACxE,MAAM,IAAI,IAAI,UAAU;CACxB,IAAI,KAAK,MAAM,OAAO,KAAA;CACtB,IAAI,CAAC,OAAO,SAAS,CAAC,GACpB,MAAM,IAAI,gBACR,mDAAmD,KAAK,gBAAgB,IAAI,QAAQ,UAAU,IAAI,IAAI,MAAM,GAC9G;CAEF,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { b as pairedRiskDifferenceExact, h as pairedSignTest, m as pairedDeltaTieFraction, p as pairedBootstrap, v as pairedBinaryScale, x as pairedRiskDifferenceScore } from "./statistics-DCZIC-qT.js";
1
+ import { S as pairedRiskDifferenceScore, h as pairedSignTest, m as pairedDeltaTieFraction, p as pairedBootstrap, x as pairedRiskDifferenceExact, y as pairedBinaryScale } from "./statistics-CvvC-MPv.js";
2
2
  // src/paired-delta-test.ts
3
3
  /** Smallest all-positive sample that can clear a one-sided exact sign test. */
4
4
  function minimumPairsForPairedDeltaTest(confidence = .95) {
@@ -252,4 +252,4 @@ function fmt(x) {
252
252
  }
253
253
  export { pairedDeltaTest as i, pairedDecisionShape as n, minimumPairsForPairedDeltaTest as r, decidePairedPromotion as t };
254
254
 
255
- //# sourceMappingURL=paired-promotion-decision-Nt4CkkOT.js.map
255
+ //# sourceMappingURL=paired-promotion-decision-Bi9__RQS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"paired-promotion-decision-Nt4CkkOT.js","names":[],"sources":["../src/paired-delta-test.ts","../src/paired-promotion-decision.ts"],"sourcesContent":["import {\n type PairedBootstrapOptions,\n type PairedBootstrapResult,\n pairedBootstrap,\n pairedSignTest,\n} from './statistics'\n\nexport interface PairedDeltaTestOptions extends PairedBootstrapOptions {\n /** Smallest candidate-minus-baseline delta that counts as improvement. Default 0. */\n threshold?: number\n /** Caller-required paired observations. The exact test may impose a higher minimum. */\n minPairs?: number\n}\n\nexport interface PairedDeltaTestResult {\n bootstrap: PairedBootstrapResult\n method: 'bootstrap-ci' | 'exact-sign'\n /** Exact one-sided p-value below the bootstrap minimum; otherwise null. */\n pValue: number | null\n /** Effective observation minimum after accounting for confidence. */\n minimumPairs: number\n sufficient: boolean\n /**\n * The bootstrap interval has zero width (or is non-finite), so it carries no\n * information about how far the estimate could be wrong and cannot support a\n * decision in either direction. See {@link pairedDeltaTest}.\n */\n indeterminate: boolean\n significant: boolean\n}\n\n/** Smallest all-positive sample that can clear a one-sided exact sign test. */\nexport function minimumPairsForPairedDeltaTest(confidence = 0.95): number {\n if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) {\n throw new Error(\n `minimumPairsForPairedDeltaTest: confidence must be in (0,1), got ${confidence}`,\n )\n }\n const oneSidedAlpha = (1 - confidence) / 2\n return Math.ceil(Math.log2(1 / oneSidedAlpha))\n}\n\n/**\n * Tests whether a paired candidate-minus-baseline delta clears a threshold.\n *\n * At 20 or more pairs, the percentile bootstrap lower bound carries the\n * decision. Below that point the interval is descriptive only, so the function\n * switches to a pre-registered one-sided exact sign test. The exact path is\n * deliberately conservative: it requires both a point estimate above the\n * threshold and enough consistently positive paired differences.\n *\n * ## A zero-width interval is never significant\n *\n * When every paired delta is identical the resample distribution is a point\n * mass and the interval collapses: `[0, 0]` when all pairs tie, `[g, g]` on n\n * identical deltas of g. Neither says the effect is certain — both say the\n * sample carries no information about how far the estimate could be wrong, and\n * `low > threshold` then answers on the point estimate alone. It fails in both\n * directions: `[0, 0]` clears every NEGATIVE threshold, which is how a\n * tie-dominated pass/fail comparison laundered a regression into a\n * noninferiority pass, and `[g, g]` clears every threshold below g with no\n * spread behind it. Under a bounded asymmetric null whose true mean paired\n * delta is exactly 0 — 2 % of pairs dropping by 1.0, the rest gaining 0.0204 —\n * every sample that misses the drop is exactly that shape, and deciding on\n * `low > 0` promoted 65.65 % of samples at n = 20 against a nominal 5 %.\n *\n * So `indeterminate` is reported and `significant` is false whenever the\n * interval has zero width, on BOTH paths: at small n the exact sign test is a\n * test of the MEDIAN and a zero-spread sample is precisely where it stops\n * saying anything about the mean the caller is thresholding.\n *\n * `threshold` may be negative — that is a noninferiority margin, and it is the\n * regime the zero-width hole is worst in. For a two-point (pass/fail) outcome\n * the percentile bootstrap is not a valid interval at a nonzero margin at all;\n * use {@link decidePairedPromotion}, which routes those to Tango's score\n * interval, rather than thresholding this function's bootstrap directly.\n */\nexport function pairedDeltaTest(\n before: number[],\n after: number[],\n options: PairedDeltaTestOptions = {},\n): PairedDeltaTestResult {\n const threshold = options.threshold ?? 0\n if (!Number.isFinite(threshold)) {\n throw new Error(`pairedDeltaTest: threshold must be finite, got ${threshold}`)\n }\n const confidence = options.confidence ?? 0.95\n const exactMinimum = minimumPairsForPairedDeltaTest(confidence)\n const requestedMinimum = options.minPairs ?? exactMinimum\n if (!Number.isInteger(requestedMinimum) || requestedMinimum < 1) {\n throw new Error(`pairedDeltaTest: minPairs must be a positive integer, got ${requestedMinimum}`)\n }\n const minimumPairs = Math.max(requestedMinimum, exactMinimum)\n const bootstrap = pairedBootstrap(before, after, options)\n const sufficient = bootstrap.n >= minimumPairs\n // A point-mass resample distribution is an absence of evidence, not a\n // certainty, and it is the shape that clears every negative threshold. Both\n // paths refuse it: see the \"zero-width\" section of this function's docs.\n const indeterminate =\n bootstrap.n > 0 &&\n (!Number.isFinite(bootstrap.low) ||\n !Number.isFinite(bootstrap.high) ||\n bootstrap.low === bootstrap.high)\n\n if (bootstrap.gateEligible) {\n return {\n bootstrap,\n method: 'bootstrap-ci',\n pValue: null,\n minimumPairs,\n sufficient,\n indeterminate,\n significant: sufficient && !indeterminate && bootstrap.low > threshold,\n }\n }\n\n const differences = before.map((value, index) => after[index]! - value - threshold)\n const exact = pairedSignTest(differences, 'greater')\n const estimate = options.statistic === 'mean' ? bootstrap.mean : bootstrap.median\n return {\n bootstrap,\n method: 'exact-sign',\n pValue: exact.pValue,\n minimumPairs,\n sufficient,\n indeterminate,\n significant:\n sufficient &&\n !indeterminate &&\n estimate > threshold &&\n exact.pValue <= (1 - bootstrap.confidence) / 2,\n }\n}\n","/**\n * @module\n * ONE rule for \"does this paired interval clear a promotion threshold\".\n *\n * The rule below was derived on `HeldOutGate` (#479) after the same estimator\n * bug shipped twice. It then turned out that a SECOND gate — the composable\n * `heldOutGate`, plus everything else routed through `heldoutSignificance` —\n * still carried the original defect, because the rule had been written into one\n * gate's method body rather than into a shared function. Two copies of a\n * statistical rule is how a defect survives in one of them, so there is now\n * exactly one copy and both gates call it.\n *\n * Three things the rule does that a bare `pairedBootstrap(...).low > threshold`\n * does not:\n *\n * 1. **Two-point (pass/fail) outcomes decide on Tango's SCORE interval.** On a\n * pass/fail eval the paired delta vector is dominated by ties, so the\n * bootstrap of the mean is a resample of a lattice with three atoms and its\n * percentile interval is not valid at a nonzero margin. The score interval\n * (`pairedRiskDifferenceScore`) re-estimates the nuisance loss rate under\n * each hypothesised margin instead of fixing it at the observed value, which\n * is the only construction that stays a confidence interval as the margin\n * moves off zero — the regime every noninferiority threshold lives in.\n * Measured on the composable gate before this change, at a true risk\n * difference sitting exactly on the production caller's -0.05 margin and a\n * nominal 5 %: 14.60 % false promotion at n = 40 and 10.10 % at n = 76.\n * 2. **McNemar's exact test holds a VETO at every non-negative threshold.**\n * Redundant with the interval by construction and kept anyway, so that\n * swapping the estimator for one without that duality cannot silently\n * reintroduce \"promotes what the exact test refuses\". Witness: n = 6, b = 5,\n * c = 0 — no exact argument reaches alpha = 0.05 with 5 discordant pairs\n * (two-sided floor 2/2^5 = 0.0625), whatever an interval says. A NEGATIVE\n * threshold is a noninferiority question, which McNemar's test of \"no\n * difference\" is not the right test for, so the veto does not apply there.\n * 3. **A ZERO-WIDTH interval is refused, wherever it sits.** At [0, 0] it\n * cannot tell a gain from a regression and clears every negative threshold.\n * Away from zero it fails the opposite way: n identical positive deltas give\n * [g, g], which clears threshold 0 on no spread at all. Both are an absence\n * of evidence. Measured on the composable gate before this change, under a\n * bounded asymmetric null whose true mean paired delta is exactly 0: 88.50 %\n * false promotion at n = 6 and 65.65 % at n = 20 against a nominal 5 %.\n *\n * Eligibility follows the requested target. A continuous mean needs the\n * bootstrap minimum; binary outcomes and explicit median targets use the\n * exact-test minimum. A small-sample sign diagnostic cannot certify a mean\n * effect. These floors establish estimator eligibility, not adequate power.\n */\n\nimport { minimumPairsForPairedDeltaTest, pairedDeltaTest } from './paired-delta-test'\nimport {\n BOOTSTRAP_GATE_MIN_N,\n type PairedBootstrapResult,\n pairedBinaryScale,\n pairedDeltaTieFraction,\n pairedRiskDifferenceExact,\n pairedRiskDifferenceScore,\n} from './statistics'\n\n/** Which paired estimator produced the deciding interval. */\nexport type PairedDecisionStatistic =\n | 'paired_risk_difference'\n | 'mean_bootstrap'\n | 'median_bootstrap'\n\n/** Which test carried the decision, given the estimator and the sample size. */\nexport type PairedDecisionMethod = 'score-interval' | 'bootstrap-ci' | 'exact-sign'\n\n/** McNemar's exact paired-binary evidence, on the two-point path only. */\nexport interface PairedMcNemarEvidence {\n /** Discordant pairs the treatment won. */\n b: number\n /** Discordant pairs the control won. */\n c: number\n /** b + c — the only pairs carrying information. */\n nDiscordant: number\n /** Two-sided exact p-value. */\n pValue: number\n}\n\nexport interface PairedPromotionDecisionOptions {\n /** Smallest candidate-minus-baseline delta that counts as improvement, in the\n * caller's native units. May be negative (a noninferiority margin). Default 0. */\n threshold?: number\n /** Confidence level. Default 0.95. */\n confidence?: number\n /** Bootstrap resamples, on the paths where a bootstrap decides. Default 2000. */\n resamples?: number\n /** Deterministic bootstrap seed. Omitted ⇒ derived from the deltas. */\n seed?: number\n /** Caller-required paired observations. The test also imposes its own\n * minimum: bootstrap eligibility for a continuous mean, or the exact-test\n * minimum for binary and explicit median targets. This is not a power guarantee. */\n minPairs?: number\n /**\n * `'mean'` (default) routes by SHAPE: a two-point (pass/fail) outcome on any\n * encoding decides on the score interval, everything else on the mean\n * bootstrap. `'median'` forces the median bootstrap on every input, including\n * shapes where it is structurally blind — kept for callers who want outlier\n * robustness on genuinely continuous outcomes and accept that cost.\n */\n statistic?: 'mean' | 'median'\n /** Declared binary support {0, binaryScale}, including when all observations\n * are zero. Must be finite and positive; every observation must use that\n * support. Uses the risk-difference mean, so cannot accompany 'median'.\n * Omitted: infer binary support from observed positive values. */\n binaryScale?: number\n /**\n * Declare the outcome continuous: never infer a two-point support from the\n * observed values, so the estimator is fixed before the data is seen. A\n * sealed call on a continuous measure must route to the bootstrap whatever\n * the sample happens to look like; with inference on, a sample whose values\n * all land on {0, s} is silently decided on the score interval instead.\n * Measured under discovery's E1 alternative (deltas in {+1, -0.5, 0} on a\n * zero baseline) at 20 pairs: 5.4 % of 2,000 simulated samples (seed 11)\n * re-route without this flag, 0 with it; the exact rate is 5.54 %\n * (`paired-promotion-power.test.ts`). Cannot accompany `binaryScale`.\n */\n continuous?: boolean\n}\n\nexport interface PairedPromotionDecision {\n /** Paired observations supplied. */\n n: number\n /** Threshold the interval was judged against, native units. */\n threshold: number\n confidence: number\n statistic: PairedDecisionStatistic\n method: PairedDecisionMethod\n /** Declared or inferred positive level ({0,1} ⇒ 1, {0,100} ⇒ 100),\n * or null when the outcome is not two-point. Non-null is exactly the\n * condition for the `paired_risk_difference` path, and it is the factor\n * `delta` / `low` / `high` were rescaled by. */\n binaryScale: number | null\n /** Exact-tie fraction over the paired deltas; null when there are no pairs. */\n tieFraction: number | null\n /** Point estimate of the DECIDING statistic, in the caller's native units. */\n delta: number\n /** Lower bound of the DECIDING interval, native units. */\n low: number\n /** Upper bound of the DECIDING interval, native units. */\n high: number\n /** The bootstrap that decided, or null when the score interval did. Callers\n * that need a bootstrap as a diagnostic on the two-point path compute their\n * own — it is not computed here, so the binary path costs no resamples. */\n bootstrap: PairedBootstrapResult | null\n /** McNemar's exact evidence, or null off the two-point path. */\n mcnemar: PairedMcNemarEvidence | null\n /** Exact one-sided sign-test p-value on the small-sample bootstrap path;\n * null otherwise. */\n pValue: number | null\n /** Effective observation minimum for the target, confidence, and caller floor. */\n minimumPairs: number\n /** n >= minimumPairs. */\n sufficient: boolean\n /** The deciding interval is zero-width at numeric precision or non-finite — no evidence in either\n * direction, so it cannot clear any threshold on evidence. */\n indeterminate: boolean\n /** McNemar's exact test refuses at a non-negative threshold. */\n exactTestVetoes: boolean\n /** The deciding interval clears the threshold, ignoring the other two guards. */\n clearsThreshold: boolean\n /** `sufficient && !indeterminate && clearsThreshold && !exactTestVetoes` —\n * the whole rule. */\n promote: boolean\n /** What `delta` measures, for a reason string. */\n label: 'success-rate' | 'mean' | 'median'\n /** Why a zero-width interval is zero-width; empty when it is not. */\n indeterminateCause: string\n /** Sentence naming the test when the exact sign test decided; else empty. */\n methodDetail: string\n}\n\n/** The shape facts that pick the estimator, without computing an interval. */\nexport interface PairedDecisionShape {\n statistic: PairedDecisionStatistic\n /** Declared or inferred positive binary level; null off the binary path. */\n binaryScale: number | null\n /** Exact-tie fraction over the paired deltas; null when there are no pairs. */\n tieFraction: number | null\n}\n\n/**\n * Which estimator {@link decidePairedPromotion} would use on this data, and the\n * shape facts behind it — for callers that must report the shape on a path\n * where no interval is computed at all (an early rejection, or zero pairs).\n * Cheap: no bootstrap, no interval.\n */\nexport function pairedDecisionShape(\n before: number[],\n after: number[],\n statistic: 'mean' | 'median' = 'mean',\n declaredBinaryScale?: number,\n continuous = false,\n): PairedDecisionShape {\n if (continuous && declaredBinaryScale !== undefined) {\n throw new Error('pairedDecisionShape: continuous cannot accompany binaryScale')\n }\n if (declaredBinaryScale !== undefined) {\n if (!Number.isFinite(declaredBinaryScale) || declaredBinaryScale <= 0) {\n throw new Error('pairedDecisionShape: binaryScale must be finite and positive')\n }\n if (statistic === 'median') {\n throw new Error('pairedDecisionShape: binaryScale requires the mean statistic, not median')\n }\n for (const [name, arm] of [\n ['before', before],\n ['after', after],\n ] as const) {\n for (let i = 0; i < arm.length; i++) {\n const value = arm[i]!\n if (value !== 0 && value !== declaredBinaryScale) {\n throw new Error(\n `pairedDecisionShape: ${name}[${i}] must be 0 or binaryScale (${declaredBinaryScale}); got ${value}`,\n )\n }\n }\n }\n }\n const tieFraction = before.length === 0 ? null : pairedDeltaTieFraction(before, after)\n if (statistic === 'median') {\n return { statistic: 'median_bootstrap', binaryScale: null, tieFraction }\n }\n if (continuous) {\n return { statistic: 'mean_bootstrap', binaryScale: null, tieFraction }\n }\n const binaryScale = declaredBinaryScale ?? pairedBinaryScale(before, after)\n if (binaryScale !== null) {\n return { statistic: 'paired_risk_difference', binaryScale, tieFraction }\n }\n return { statistic: 'mean_bootstrap', binaryScale: null, tieFraction }\n}\n\n/**\n * Decide whether a paired candidate-minus-baseline delta clears a promotion\n * threshold. `before` is the baseline arm, `after` the candidate arm, paired by\n * position. Throws on unequal lengths.\n */\nexport function decidePairedPromotion(\n before: number[],\n after: number[],\n options: PairedPromotionDecisionOptions = {},\n): PairedPromotionDecision {\n if (before.length !== after.length) {\n throw new Error(\n `decidePairedPromotion: unequal sample sizes (${before.length} vs ${after.length})`,\n )\n }\n const threshold = options.threshold ?? 0\n if (!Number.isFinite(threshold)) {\n throw new Error(`decidePairedPromotion: threshold must be finite, got ${threshold}`)\n }\n const confidence = options.confidence ?? 0.95\n const exactMinimum = minimumPairsForPairedDeltaTest(confidence)\n const requestedMinimum = options.minPairs ?? exactMinimum\n if (!Number.isInteger(requestedMinimum) || requestedMinimum < 1) {\n throw new Error(\n `decidePairedPromotion: minPairs must be a positive integer, got ${requestedMinimum}`,\n )\n }\n const { binaryScale, tieFraction } = pairedDecisionShape(\n before,\n after,\n options.statistic,\n options.binaryScale,\n options.continuous ?? false,\n )\n const estimatorMinimum =\n binaryScale === null && options.statistic !== 'median' ? BOOTSTRAP_GATE_MIN_N : exactMinimum\n const minimumPairs = Math.max(requestedMinimum, exactMinimum, estimatorMinimum)\n const n = before.length\n const sufficient = n >= minimumPairs\n\n let core: {\n statistic: PairedDecisionStatistic\n method: PairedDecisionMethod\n delta: number\n low: number\n high: number\n bootstrap: PairedBootstrapResult | null\n mcnemar: PairedMcNemarEvidence | null\n pValue: number | null\n clearsThreshold: boolean\n label: PairedPromotionDecision['label']\n methodDetail: string\n }\n\n if (binaryScale !== null) {\n // Normalise the two-point encoding to {0,1} so the estimators see the\n // pass/fail structure, then rescale the answer back into the caller's\n // native units — the threshold is read in the units of the scores, so a\n // 0-100 pass/fail dimension must be gated in points, not in a rate.\n const unitControl = before.map((v) => v / binaryScale)\n const unitTreatment = after.map((v) => v / binaryScale)\n // TWO estimators with different jobs, because no single one does both.\n // `exact` is the authority on RD = 0 and supplies the veto; its\n // Clopper-Pearson interval conditions on the discordant count and is\n // therefore NOT a confidence interval at a nonzero margin. `score` is\n // Tango's, which is.\n const exact = pairedRiskDifferenceExact(unitControl, unitTreatment, confidence)\n const score = pairedRiskDifferenceScore(unitControl, unitTreatment, confidence)\n const low = score.lower * binaryScale\n core = {\n statistic: 'paired_risk_difference',\n method: 'score-interval',\n delta: score.riskDifference * binaryScale,\n low,\n high: score.upper * binaryScale,\n bootstrap: null,\n mcnemar: {\n b: exact.b,\n c: exact.c,\n nDiscordant: exact.nDiscordant,\n pValue: exact.pValue,\n },\n pValue: null,\n clearsThreshold: low > threshold,\n label: 'success-rate',\n methodDetail: '',\n }\n } else {\n const bootstrapStatistic = options.statistic === 'median' ? 'median' : 'mean'\n const test = pairedDeltaTest(before, after, {\n confidence,\n resamples: options.resamples,\n statistic: bootstrapStatistic,\n seed: options.seed,\n threshold,\n minPairs: minimumPairs,\n })\n const ci = test.bootstrap\n core = {\n statistic: bootstrapStatistic === 'mean' ? 'mean_bootstrap' : 'median_bootstrap',\n method: test.method,\n delta: bootstrapStatistic === 'mean' ? ci.mean : ci.median,\n low: ci.low,\n high: ci.high,\n bootstrap: ci,\n mcnemar: null,\n pValue: test.pValue,\n clearsThreshold: test.significant,\n label: bootstrapStatistic,\n methodDetail:\n test.method === 'exact-sign'\n ? bootstrapStatistic === 'mean'\n ? ` The mean requires ${minimumPairs} pairs for bootstrap eligibility;` +\n ` the exact sign-test p=${fmt(test.pValue ?? 1)} does not establish a mean effect.`\n : ` Below ${BOOTSTRAP_GATE_MIN_N} pairs the interval is descriptive only;` +\n ` the median decision uses the exact one-sided sign test, p=${fmt(test.pValue ?? 1)}.`\n : '',\n }\n }\n\n // Equivalent deltas can differ by rounding after subtraction and averaging.\n // Use the interval's own scale so tiny score units retain the same decision\n // as a rescaled copy of the evidence.\n const intervalScale = Math.max(Math.abs(core.low), Math.abs(core.high))\n const intervalTolerance = intervalScale * Number.EPSILON * 8\n const indeterminate =\n !Number.isFinite(core.low) ||\n !Number.isFinite(core.high) ||\n core.high - core.low <= intervalTolerance\n const indeterminateCause = !indeterminate\n ? ''\n : tieFraction === 1\n ? 'every paired delta is an exact tie'\n : core.mcnemar !== null && core.mcnemar.nDiscordant === 0\n ? 'every pair is concordant (0 discordant pairs)'\n : `the ${core.label} CI collapsed to a point at ${fmt(core.low)}`\n // Only at a non-negative threshold: a negative threshold asks a\n // noninferiority question, which McNemar's test of \"no difference\" does not\n // answer.\n const exactTestVetoes =\n core.mcnemar !== null && threshold >= 0 && !(core.mcnemar.pValue < 1 - confidence)\n\n return {\n n,\n threshold,\n confidence,\n binaryScale,\n tieFraction,\n minimumPairs,\n sufficient,\n indeterminate,\n indeterminateCause,\n exactTestVetoes,\n promote: sufficient && !indeterminate && core.clearsThreshold && !exactTestVetoes,\n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GACA,WAAW,QAAQ;GACnB,WAAW;GACX,MAAM,QAAQ;GACd;GACA,UAAU;EACZ,CAAC;EACD,MAAM,KAAK,KAAK;EAChB,OAAO;GACL,WAAW,uBAAuB,SAAS,mBAAmB;GAC9D,QAAQ,KAAK;GACb,OAAO,uBAAuB,SAAS,GAAG,OAAO,GAAG;GACpD,KAAK,GAAG;GACR,MAAM,GAAG;GACT,WAAW;GACX,SAAS;GACT,QAAQ,KAAK;GACb,iBAAiB,KAAK;GACtB,OAAO;GACP,cACE,KAAK,WAAW,eACZ,uBAAuB,SACrB,sBAAsB,aAAa,0DACT,IAAI,KAAK,UAAU,CAAC,EAAE,sCAChD,+GAC8D,IAAI,KAAK,UAAU,CAAC,EAAE,KACtF;EACR;CACF;CAMA,MAAM,oBADgB,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,GAAG,KAAK,IAAI,KAAK,IAAI,CAC/B,IAAI,OAAO,UAAU;CAC3D,MAAM,gBACJ,CAAC,OAAO,SAAS,KAAK,GAAG,KACzB,CAAC,OAAO,SAAS,KAAK,IAAI,KAC1B,KAAK,OAAO,KAAK,OAAO;CAC1B,MAAM,qBAAqB,CAAC,gBACxB,KACA,gBAAgB,IACd,uCACA,KAAK,YAAY,QAAQ,KAAK,QAAQ,gBAAgB,IACpD,kDACA,OAAO,KAAK,MAAM,8BAA8B,IAAI,KAAK,GAAG;CAIpE,MAAM,kBACJ,KAAK,YAAY,QAAQ,aAAa,KAAK,EAAE,KAAK,QAAQ,SAAS,IAAI;CAEzE,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,cAAc,CAAC,iBAAiB,KAAK,mBAAmB,CAAC;EAClE,GAAG;CACL;AACF;AAEA,SAAS,IAAI,GAAmB;CAC9B,OAAO,EAAE,QAAQ,CAAC;AACpB"}
1
+ {"version":3,"file":"paired-promotion-decision-Bi9__RQS.js","names":[],"sources":["../src/paired-delta-test.ts","../src/paired-promotion-decision.ts"],"sourcesContent":["import {\n type PairedBootstrapOptions,\n type PairedBootstrapResult,\n pairedBootstrap,\n pairedSignTest,\n} from './statistics'\n\nexport interface PairedDeltaTestOptions extends PairedBootstrapOptions {\n /** Smallest candidate-minus-baseline delta that counts as improvement. Default 0. */\n threshold?: number\n /** Caller-required paired observations. The exact test may impose a higher minimum. */\n minPairs?: number\n}\n\nexport interface PairedDeltaTestResult {\n bootstrap: PairedBootstrapResult\n method: 'bootstrap-ci' | 'exact-sign'\n /** Exact one-sided p-value below the bootstrap minimum; otherwise null. */\n pValue: number | null\n /** Effective observation minimum after accounting for confidence. */\n minimumPairs: number\n sufficient: boolean\n /**\n * The bootstrap interval has zero width (or is non-finite), so it carries no\n * information about how far the estimate could be wrong and cannot support a\n * decision in either direction. See {@link pairedDeltaTest}.\n */\n indeterminate: boolean\n significant: boolean\n}\n\n/** Smallest all-positive sample that can clear a one-sided exact sign test. */\nexport function minimumPairsForPairedDeltaTest(confidence = 0.95): number {\n if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) {\n throw new Error(\n `minimumPairsForPairedDeltaTest: confidence must be in (0,1), got ${confidence}`,\n )\n }\n const oneSidedAlpha = (1 - confidence) / 2\n return Math.ceil(Math.log2(1 / oneSidedAlpha))\n}\n\n/**\n * Tests whether a paired candidate-minus-baseline delta clears a threshold.\n *\n * At 20 or more pairs, the percentile bootstrap lower bound carries the\n * decision. Below that point the interval is descriptive only, so the function\n * switches to a pre-registered one-sided exact sign test. The exact path is\n * deliberately conservative: it requires both a point estimate above the\n * threshold and enough consistently positive paired differences.\n *\n * ## A zero-width interval is never significant\n *\n * When every paired delta is identical the resample distribution is a point\n * mass and the interval collapses: `[0, 0]` when all pairs tie, `[g, g]` on n\n * identical deltas of g. Neither says the effect is certain — both say the\n * sample carries no information about how far the estimate could be wrong, and\n * `low > threshold` then answers on the point estimate alone. It fails in both\n * directions: `[0, 0]` clears every NEGATIVE threshold, which is how a\n * tie-dominated pass/fail comparison laundered a regression into a\n * noninferiority pass, and `[g, g]` clears every threshold below g with no\n * spread behind it. Under a bounded asymmetric null whose true mean paired\n * delta is exactly 0 — 2 % of pairs dropping by 1.0, the rest gaining 0.0204 —\n * every sample that misses the drop is exactly that shape, and deciding on\n * `low > 0` promoted 65.65 % of samples at n = 20 against a nominal 5 %.\n *\n * So `indeterminate` is reported and `significant` is false whenever the\n * interval has zero width, on BOTH paths: at small n the exact sign test is a\n * test of the MEDIAN and a zero-spread sample is precisely where it stops\n * saying anything about the mean the caller is thresholding.\n *\n * `threshold` may be negative — that is a noninferiority margin, and it is the\n * regime the zero-width hole is worst in. For a two-point (pass/fail) outcome\n * the percentile bootstrap is not a valid interval at a nonzero margin at all;\n * use {@link decidePairedPromotion}, which routes those to Tango's score\n * interval, rather than thresholding this function's bootstrap directly.\n */\nexport function pairedDeltaTest(\n before: number[],\n after: number[],\n options: PairedDeltaTestOptions = {},\n): PairedDeltaTestResult {\n const threshold = options.threshold ?? 0\n if (!Number.isFinite(threshold)) {\n throw new Error(`pairedDeltaTest: threshold must be finite, got ${threshold}`)\n }\n const confidence = options.confidence ?? 0.95\n const exactMinimum = minimumPairsForPairedDeltaTest(confidence)\n const requestedMinimum = options.minPairs ?? exactMinimum\n if (!Number.isInteger(requestedMinimum) || requestedMinimum < 1) {\n throw new Error(`pairedDeltaTest: minPairs must be a positive integer, got ${requestedMinimum}`)\n }\n const minimumPairs = Math.max(requestedMinimum, exactMinimum)\n const bootstrap = pairedBootstrap(before, after, options)\n const sufficient = bootstrap.n >= minimumPairs\n // A point-mass resample distribution is an absence of evidence, not a\n // certainty, and it is the shape that clears every negative threshold. Both\n // paths refuse it: see the \"zero-width\" section of this function's docs.\n const indeterminate =\n bootstrap.n > 0 &&\n (!Number.isFinite(bootstrap.low) ||\n !Number.isFinite(bootstrap.high) ||\n bootstrap.low === bootstrap.high)\n\n if (bootstrap.gateEligible) {\n return {\n bootstrap,\n method: 'bootstrap-ci',\n pValue: null,\n minimumPairs,\n sufficient,\n indeterminate,\n significant: sufficient && !indeterminate && bootstrap.low > threshold,\n }\n }\n\n const differences = before.map((value, index) => after[index]! - value - threshold)\n const exact = pairedSignTest(differences, 'greater')\n const estimate = options.statistic === 'mean' ? bootstrap.mean : bootstrap.median\n return {\n bootstrap,\n method: 'exact-sign',\n pValue: exact.pValue,\n minimumPairs,\n sufficient,\n indeterminate,\n significant:\n sufficient &&\n !indeterminate &&\n estimate > threshold &&\n exact.pValue <= (1 - bootstrap.confidence) / 2,\n }\n}\n","/**\n * @module\n * ONE rule for \"does this paired interval clear a promotion threshold\".\n *\n * The rule below was derived on `HeldOutGate` (#479) after the same estimator\n * bug shipped twice. It then turned out that a SECOND gate — the composable\n * `heldOutGate`, plus everything else routed through `heldoutSignificance` —\n * still carried the original defect, because the rule had been written into one\n * gate's method body rather than into a shared function. Two copies of a\n * statistical rule is how a defect survives in one of them, so there is now\n * exactly one copy and both gates call it.\n *\n * Three things the rule does that a bare `pairedBootstrap(...).low > threshold`\n * does not:\n *\n * 1. **Two-point (pass/fail) outcomes decide on Tango's SCORE interval.** On a\n * pass/fail eval the paired delta vector is dominated by ties, so the\n * bootstrap of the mean is a resample of a lattice with three atoms and its\n * percentile interval is not valid at a nonzero margin. The score interval\n * (`pairedRiskDifferenceScore`) re-estimates the nuisance loss rate under\n * each hypothesised margin instead of fixing it at the observed value, which\n * is the only construction that stays a confidence interval as the margin\n * moves off zero — the regime every noninferiority threshold lives in.\n * Measured on the composable gate before this change, at a true risk\n * difference sitting exactly on the production caller's -0.05 margin and a\n * nominal 5 %: 14.60 % false promotion at n = 40 and 10.10 % at n = 76.\n * 2. **McNemar's exact test holds a VETO at every non-negative threshold.**\n * Redundant with the interval by construction and kept anyway, so that\n * swapping the estimator for one without that duality cannot silently\n * reintroduce \"promotes what the exact test refuses\". Witness: n = 6, b = 5,\n * c = 0 — no exact argument reaches alpha = 0.05 with 5 discordant pairs\n * (two-sided floor 2/2^5 = 0.0625), whatever an interval says. A NEGATIVE\n * threshold is a noninferiority question, which McNemar's test of \"no\n * difference\" is not the right test for, so the veto does not apply there.\n * 3. **A ZERO-WIDTH interval is refused, wherever it sits.** At [0, 0] it\n * cannot tell a gain from a regression and clears every negative threshold.\n * Away from zero it fails the opposite way: n identical positive deltas give\n * [g, g], which clears threshold 0 on no spread at all. Both are an absence\n * of evidence. Measured on the composable gate before this change, under a\n * bounded asymmetric null whose true mean paired delta is exactly 0: 88.50 %\n * false promotion at n = 6 and 65.65 % at n = 20 against a nominal 5 %.\n *\n * Eligibility follows the requested target. A continuous mean needs the\n * bootstrap minimum; binary outcomes and explicit median targets use the\n * exact-test minimum. A small-sample sign diagnostic cannot certify a mean\n * effect. These floors establish estimator eligibility, not adequate power.\n */\n\nimport { minimumPairsForPairedDeltaTest, pairedDeltaTest } from './paired-delta-test'\nimport {\n BOOTSTRAP_GATE_MIN_N,\n type PairedBootstrapResult,\n pairedBinaryScale,\n pairedDeltaTieFraction,\n pairedRiskDifferenceExact,\n pairedRiskDifferenceScore,\n} from './statistics'\n\n/** Which paired estimator produced the deciding interval. */\nexport type PairedDecisionStatistic =\n | 'paired_risk_difference'\n | 'mean_bootstrap'\n | 'median_bootstrap'\n\n/** Which test carried the decision, given the estimator and the sample size. */\nexport type PairedDecisionMethod = 'score-interval' | 'bootstrap-ci' | 'exact-sign'\n\n/** McNemar's exact paired-binary evidence, on the two-point path only. */\nexport interface PairedMcNemarEvidence {\n /** Discordant pairs the treatment won. */\n b: number\n /** Discordant pairs the control won. */\n c: number\n /** b + c — the only pairs carrying information. */\n nDiscordant: number\n /** Two-sided exact p-value. */\n pValue: number\n}\n\nexport interface PairedPromotionDecisionOptions {\n /** Smallest candidate-minus-baseline delta that counts as improvement, in the\n * caller's native units. May be negative (a noninferiority margin). Default 0. */\n threshold?: number\n /** Confidence level. Default 0.95. */\n confidence?: number\n /** Bootstrap resamples, on the paths where a bootstrap decides. Default 2000. */\n resamples?: number\n /** Deterministic bootstrap seed. Omitted ⇒ derived from the deltas. */\n seed?: number\n /** Caller-required paired observations. The test also imposes its own\n * minimum: bootstrap eligibility for a continuous mean, or the exact-test\n * minimum for binary and explicit median targets. This is not a power guarantee. */\n minPairs?: number\n /**\n * `'mean'` (default) routes by SHAPE: a two-point (pass/fail) outcome on any\n * encoding decides on the score interval, everything else on the mean\n * bootstrap. `'median'` forces the median bootstrap on every input, including\n * shapes where it is structurally blind — kept for callers who want outlier\n * robustness on genuinely continuous outcomes and accept that cost.\n */\n statistic?: 'mean' | 'median'\n /** Declared binary support {0, binaryScale}, including when all observations\n * are zero. Must be finite and positive; every observation must use that\n * support. Uses the risk-difference mean, so cannot accompany 'median'.\n * Omitted: infer binary support from observed positive values. */\n binaryScale?: number\n /**\n * Declare the outcome continuous: never infer a two-point support from the\n * observed values, so the estimator is fixed before the data is seen. A\n * sealed call on a continuous measure must route to the bootstrap whatever\n * the sample happens to look like; with inference on, a sample whose values\n * all land on {0, s} is silently decided on the score interval instead.\n * Measured under discovery's E1 alternative (deltas in {+1, -0.5, 0} on a\n * zero baseline) at 20 pairs: 5.4 % of 2,000 simulated samples (seed 11)\n * re-route without this flag, 0 with it; the exact rate is 5.54 %\n * (`paired-promotion-power.test.ts`). Cannot accompany `binaryScale`.\n */\n continuous?: boolean\n}\n\nexport interface PairedPromotionDecision {\n /** Paired observations supplied. */\n n: number\n /** Threshold the interval was judged against, native units. */\n threshold: number\n confidence: number\n statistic: PairedDecisionStatistic\n method: PairedDecisionMethod\n /** Declared or inferred positive level ({0,1} ⇒ 1, {0,100} ⇒ 100),\n * or null when the outcome is not two-point. Non-null is exactly the\n * condition for the `paired_risk_difference` path, and it is the factor\n * `delta` / `low` / `high` were rescaled by. */\n binaryScale: number | null\n /** Exact-tie fraction over the paired deltas; null when there are no pairs. */\n tieFraction: number | null\n /** Point estimate of the DECIDING statistic, in the caller's native units. */\n delta: number\n /** Lower bound of the DECIDING interval, native units. */\n low: number\n /** Upper bound of the DECIDING interval, native units. */\n high: number\n /** The bootstrap that decided, or null when the score interval did. Callers\n * that need a bootstrap as a diagnostic on the two-point path compute their\n * own — it is not computed here, so the binary path costs no resamples. */\n bootstrap: PairedBootstrapResult | null\n /** McNemar's exact evidence, or null off the two-point path. */\n mcnemar: PairedMcNemarEvidence | null\n /** Exact one-sided sign-test p-value on the small-sample bootstrap path;\n * null otherwise. */\n pValue: number | null\n /** Effective observation minimum for the target, confidence, and caller floor. */\n minimumPairs: number\n /** n >= minimumPairs. */\n sufficient: boolean\n /** The deciding interval is zero-width at numeric precision or non-finite — no evidence in either\n * direction, so it cannot clear any threshold on evidence. */\n indeterminate: boolean\n /** McNemar's exact test refuses at a non-negative threshold. */\n exactTestVetoes: boolean\n /** The deciding interval clears the threshold, ignoring the other two guards. */\n clearsThreshold: boolean\n /** `sufficient && !indeterminate && clearsThreshold && !exactTestVetoes` —\n * the whole rule. */\n promote: boolean\n /** What `delta` measures, for a reason string. */\n label: 'success-rate' | 'mean' | 'median'\n /** Why a zero-width interval is zero-width; empty when it is not. */\n indeterminateCause: string\n /** Sentence naming the test when the exact sign test decided; else empty. */\n methodDetail: string\n}\n\n/** The shape facts that pick the estimator, without computing an interval. */\nexport interface PairedDecisionShape {\n statistic: PairedDecisionStatistic\n /** Declared or inferred positive binary level; null off the binary path. */\n binaryScale: number | null\n /** Exact-tie fraction over the paired deltas; null when there are no pairs. */\n tieFraction: number | null\n}\n\n/**\n * Which estimator {@link decidePairedPromotion} would use on this data, and the\n * shape facts behind it — for callers that must report the shape on a path\n * where no interval is computed at all (an early rejection, or zero pairs).\n * Cheap: no bootstrap, no interval.\n */\nexport function pairedDecisionShape(\n before: number[],\n after: number[],\n statistic: 'mean' | 'median' = 'mean',\n declaredBinaryScale?: number,\n continuous = false,\n): PairedDecisionShape {\n if (continuous && declaredBinaryScale !== undefined) {\n throw new Error('pairedDecisionShape: continuous cannot accompany binaryScale')\n }\n if (declaredBinaryScale !== undefined) {\n if (!Number.isFinite(declaredBinaryScale) || declaredBinaryScale <= 0) {\n throw new Error('pairedDecisionShape: binaryScale must be finite and positive')\n }\n if (statistic === 'median') {\n throw new Error('pairedDecisionShape: binaryScale requires the mean statistic, not median')\n }\n for (const [name, arm] of [\n ['before', before],\n ['after', after],\n ] as const) {\n for (let i = 0; i < arm.length; i++) {\n const value = arm[i]!\n if (value !== 0 && value !== declaredBinaryScale) {\n throw new Error(\n `pairedDecisionShape: ${name}[${i}] must be 0 or binaryScale (${declaredBinaryScale}); got ${value}`,\n )\n }\n }\n }\n }\n const tieFraction = before.length === 0 ? null : pairedDeltaTieFraction(before, after)\n if (statistic === 'median') {\n return { statistic: 'median_bootstrap', binaryScale: null, tieFraction }\n }\n if (continuous) {\n return { statistic: 'mean_bootstrap', binaryScale: null, tieFraction }\n }\n const binaryScale = declaredBinaryScale ?? pairedBinaryScale(before, after)\n if (binaryScale !== null) {\n return { statistic: 'paired_risk_difference', binaryScale, tieFraction }\n }\n return { statistic: 'mean_bootstrap', binaryScale: null, tieFraction }\n}\n\n/**\n * Decide whether a paired candidate-minus-baseline delta clears a promotion\n * threshold. `before` is the baseline arm, `after` the candidate arm, paired by\n * position. Throws on unequal lengths.\n */\nexport function decidePairedPromotion(\n before: number[],\n after: number[],\n options: PairedPromotionDecisionOptions = {},\n): PairedPromotionDecision {\n if (before.length !== after.length) {\n throw new Error(\n `decidePairedPromotion: unequal sample sizes (${before.length} vs ${after.length})`,\n )\n }\n const threshold = options.threshold ?? 0\n if (!Number.isFinite(threshold)) {\n throw new Error(`decidePairedPromotion: threshold must be finite, got ${threshold}`)\n }\n const confidence = options.confidence ?? 0.95\n const exactMinimum = minimumPairsForPairedDeltaTest(confidence)\n const requestedMinimum = options.minPairs ?? exactMinimum\n if (!Number.isInteger(requestedMinimum) || requestedMinimum < 1) {\n throw new Error(\n `decidePairedPromotion: minPairs must be a positive integer, got ${requestedMinimum}`,\n )\n }\n const { binaryScale, tieFraction } = pairedDecisionShape(\n before,\n after,\n options.statistic,\n options.binaryScale,\n options.continuous ?? false,\n )\n const estimatorMinimum =\n binaryScale === null && options.statistic !== 'median' ? BOOTSTRAP_GATE_MIN_N : exactMinimum\n const minimumPairs = Math.max(requestedMinimum, exactMinimum, estimatorMinimum)\n const n = before.length\n const sufficient = n >= minimumPairs\n\n let core: {\n statistic: PairedDecisionStatistic\n method: PairedDecisionMethod\n delta: number\n low: number\n high: number\n bootstrap: PairedBootstrapResult | null\n mcnemar: PairedMcNemarEvidence | null\n pValue: number | null\n clearsThreshold: boolean\n label: PairedPromotionDecision['label']\n methodDetail: string\n }\n\n if (binaryScale !== null) {\n // Normalise the two-point encoding to {0,1} so the estimators see the\n // pass/fail structure, then rescale the answer back into the caller's\n // native units — the threshold is read in the units of the scores, so a\n // 0-100 pass/fail dimension must be gated in points, not in a rate.\n const unitControl = before.map((v) => v / binaryScale)\n const unitTreatment = after.map((v) => v / binaryScale)\n // TWO estimators with different jobs, because no single one does both.\n // `exact` is the authority on RD = 0 and supplies the veto; its\n // Clopper-Pearson interval conditions on the discordant count and is\n // therefore NOT a confidence interval at a nonzero margin. `score` is\n // Tango's, which is.\n const exact = pairedRiskDifferenceExact(unitControl, unitTreatment, confidence)\n const score = pairedRiskDifferenceScore(unitControl, unitTreatment, confidence)\n const low = score.lower * binaryScale\n core = {\n statistic: 'paired_risk_difference',\n method: 'score-interval',\n delta: score.riskDifference * binaryScale,\n low,\n high: score.upper * binaryScale,\n bootstrap: null,\n mcnemar: {\n b: exact.b,\n c: exact.c,\n nDiscordant: exact.nDiscordant,\n pValue: exact.pValue,\n },\n pValue: null,\n clearsThreshold: low > threshold,\n label: 'success-rate',\n methodDetail: '',\n }\n } else {\n const bootstrapStatistic = options.statistic === 'median' ? 'median' : 'mean'\n const test = pairedDeltaTest(before, after, {\n confidence,\n resamples: options.resamples,\n statistic: bootstrapStatistic,\n seed: options.seed,\n threshold,\n minPairs: minimumPairs,\n })\n const ci = test.bootstrap\n core = {\n statistic: bootstrapStatistic === 'mean' ? 'mean_bootstrap' : 'median_bootstrap',\n method: test.method,\n delta: bootstrapStatistic === 'mean' ? ci.mean : ci.median,\n low: ci.low,\n high: ci.high,\n bootstrap: ci,\n mcnemar: null,\n pValue: test.pValue,\n clearsThreshold: test.significant,\n label: bootstrapStatistic,\n methodDetail:\n test.method === 'exact-sign'\n ? bootstrapStatistic === 'mean'\n ? ` The mean requires ${minimumPairs} pairs for bootstrap eligibility;` +\n ` the exact sign-test p=${fmt(test.pValue ?? 1)} does not establish a mean effect.`\n : ` Below ${BOOTSTRAP_GATE_MIN_N} pairs the interval is descriptive only;` +\n ` the median decision uses the exact one-sided sign test, p=${fmt(test.pValue ?? 1)}.`\n : '',\n }\n }\n\n // Equivalent deltas can differ by rounding after subtraction and averaging.\n // Use the interval's own scale so tiny score units retain the same decision\n // as a rescaled copy of the evidence.\n const intervalScale = Math.max(Math.abs(core.low), Math.abs(core.high))\n const intervalTolerance = intervalScale * Number.EPSILON * 8\n const indeterminate =\n !Number.isFinite(core.low) ||\n !Number.isFinite(core.high) ||\n core.high - core.low <= intervalTolerance\n const indeterminateCause = !indeterminate\n ? ''\n : tieFraction === 1\n ? 'every paired delta is an exact tie'\n : core.mcnemar !== null && core.mcnemar.nDiscordant === 0\n ? 'every pair is concordant (0 discordant pairs)'\n : `the ${core.label} CI collapsed to a point at ${fmt(core.low)}`\n // Only at a non-negative threshold: a negative threshold asks a\n // noninferiority question, which McNemar's test of \"no difference\" does not\n // answer.\n const exactTestVetoes =\n core.mcnemar !== null && threshold >= 0 && !(core.mcnemar.pValue < 1 - confidence)\n\n return {\n n,\n threshold,\n confidence,\n binaryScale,\n tieFraction,\n minimumPairs,\n sufficient,\n indeterminate,\n indeterminateCause,\n exactTestVetoes,\n promote: sufficient && !indeterminate && core.clearsThreshold && !exactTestVetoes,\n ...core,\n }\n}\n\nfunction fmt(x: number): string {\n return x.toFixed(4)\n}\n"],"mappings":";;;AAgCA,SAAgB,+BAA+B,aAAa,KAAc;CACxE,IAAI,CAAC,OAAO,SAAS,UAAU,KAAK,cAAc,KAAK,cAAc,GACnE,MAAM,IAAI,MACR,oEAAo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,GAAG,OAAO,GAAG;GACpD,KAAK,GAAG;GACR,MAAM,GAAG;GACT,WAAW;GACX,SAAS;GACT,QAAQ,KAAK;GACb,iBAAiB,KAAK;GACtB,OAAO;GACP,cACE,KAAK,WAAW,eACZ,uBAAuB,SACrB,sBAAsB,aAAa,0DACT,IAAI,KAAK,UAAU,CAAC,EAAE,sCAChD,+GAC8D,IAAI,KAAK,UAAU,CAAC,EAAE,KACtF;EACR;CACF;CAMA,MAAM,oBADgB,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,GAAG,KAAK,IAAI,KAAK,IAAI,CAC/B,IAAI,OAAO,UAAU;CAC3D,MAAM,gBACJ,CAAC,OAAO,SAAS,KAAK,GAAG,KACzB,CAAC,OAAO,SAAS,KAAK,IAAI,KAC1B,KAAK,OAAO,KAAK,OAAO;CAC1B,MAAM,qBAAqB,CAAC,gBACxB,KACA,gBAAgB,IACd,uCACA,KAAK,YAAY,QAAQ,KAAK,QAAQ,gBAAgB,IACpD,kDACA,OAAO,KAAK,MAAM,8BAA8B,IAAI,KAAK,GAAG;CAIpE,MAAM,kBACJ,KAAK,YAAY,QAAQ,aAAa,KAAK,EAAE,KAAK,QAAQ,SAAS,IAAI;CAEzE,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,cAAc,CAAC,iBAAiB,KAAK,mBAAmB,CAAC;EAClE,GAAG;CACL;AACF;AAEA,SAAS,IAAI,GAAmB;CAC9B,OAAO,EAAE,QAAQ,CAAC;AACpB"}
@@ -1,4 +1,4 @@
1
- import { E as PairedBootstrapResult } from "./index-BdLmBInV.js";
1
+ import { E as PairedBootstrapResult } from "./index-DNXFzSpc.js";
2
2
  /** Which paired estimator produced the deciding interval. */
3
3
  type PairedDecisionStatistic = 'paired_risk_difference' | 'mean_bootstrap' | 'median_bootstrap';
4
4
  /** Which test carried the decision, given the estimator and the sample size. */
@@ -120,4 +120,4 @@ interface PairedDecisionShape {
120
120
  */
121
121
  declare function decidePairedPromotion(before: number[], after: number[], options?: PairedPromotionDecisionOptions): PairedPromotionDecision;
122
122
  export { PairedPromotionDecision as a, PairedMcNemarEvidence as i, PairedDecisionShape as n, PairedPromotionDecisionOptions as o, PairedDecisionStatistic as r, decidePairedPromotion as s, PairedDecisionMethod as t };
123
- //# sourceMappingURL=paired-promotion-decision-BNzPfXDw.d.ts.map
123
+ //# sourceMappingURL=paired-promotion-decision-DJU3fZxH.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paired-promotion-decision-BNzPfXDw.d.ts","names":[],"sources":["../src/paired-promotion-decision.ts"],"mappings":";;KA2DY;;KAMA;;UAGK;;EAEf;;EAEA;;EAEA;;EAEA;;UAGe;;;EAGf;;EAEA;;EAEA;;EAEA;;;;EAIA;;;;;;;;EAQA;;;;;EAKA;;;;;;;;;;;;EAYA;;UAGe;;EAEf;;EAEA;EACA;EACA,WAAW;EACX,QAAQ;;;;;EAKR;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA,WAAW;;EAEX,SAAS;;;EAGT;;EAEA;;EAEA;;;EAGA;;EAEA;;EAEA;;;EAGA;;EAEA;;EAEA;;EAEA;;;UAIe;EACf,WAAW;;EAEX;;EAEA;;;;;;;iBA2Dc,sBACd,kBACA,iBACA,UAAS,iCACR"}
1
+ {"version":3,"file":"paired-promotion-decision-DJU3fZxH.d.ts","names":[],"sources":["../src/paired-promotion-decision.ts"],"mappings":";;KA2DY;;KAMA;;UAGK;;EAEf;;EAEA;;EAEA;;EAEA;;UAGe;;;EAGf;;EAEA;;EAEA;;EAEA;;;;EAIA;;;;;;;;EAQA;;;;;EAKA;;;;;;;;;;;;EAYA;;UAGe;;EAEf;;EAEA;EACA;EACA,WAAW;EACX,QAAQ;;;;;EAKR;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA,WAAW;;EAEX,SAAS;;;EAGT;;EAEA;;EAEA;;;EAGA;;EAEA;;EAEA;;;EAGA;;EAEA;;EAEA;;EAEA;;;UAIe;EACf,WAAW;;EAEX;;EAEA;;;;;;;iBA2Dc,sBACd,kBACA,iBACA,UAAS,iCACR"}
@@ -1,7 +1,7 @@
1
1
  import { a as hashCanonical, i as compareCodeUnits, r as canonicalString } from "./canonical-CicJlINA.js";
2
- import { C as wilson, Z as confidenceInterval, f as DECISION_PAIRED_DELTA_STATISTIC, st as mean } from "./statistics-DCZIC-qT.js";
2
+ import { Q as confidenceInterval, ct as mean, f as DECISION_PAIRED_DELTA_STATISTIC, w as wilson } from "./statistics-CvvC-MPv.js";
3
3
  import { t as mulberry32 } from "./random-DrzcgC7F.js";
4
- import { i as pairedDeltaTest, r as minimumPairsForPairedDeltaTest, t as decidePairedPromotion } from "./paired-promotion-decision-Nt4CkkOT.js";
4
+ import { i as pairedDeltaTest, r as minimumPairsForPairedDeltaTest, t as decidePairedPromotion } from "./paired-promotion-decision-Bi9__RQS.js";
5
5
  import { a as SearchLedgerError } from "./search-ledger-file-BhOdgYIt.js";
6
6
  import { c as redactText } from "./redact-zp_ILC4l.js";
7
7
  import { l as searchUnitScores, p as USD_TOLERANCE, t as FileSearchLedger, u as searchCellId } from "./search-ledger-Dk-yk5Li.js";
@@ -2606,4 +2606,4 @@ function paretoFrontierWithCrowding(candidates, objectives) {
2606
2606
  }
2607
2607
  export { normalizeSignedZero as A, SEARCH_ESTIMATOR as C, searchEstimateMethod as D, searchCellSetDigest as E, searchPosterior as O, requiredPairsForPairedPromotion as S, estimateNodeFromCells as T, planSearchClaim as _, searchDivergence as a, verifySearchClaim as b, MIN_OUTCOMES_FOR_WEIGHT as c, rankingSplit as d, summarizeSamples as f, decideSearchClaim as g, SEARCH_CLAIM_RULE as h, runSearch as i, seedFromDigest as k, operatorYield as l, searchExpansionIndex as m, paretoFrontier as n, searchPolicyView as o, SEARCH_KERNEL_SOURCE as p, paretoFrontierWithCrowding as r, EXPANSION_OPERATORS as s, dominates as t, INSUFFICIENT_FROM as u, searchClaimDecision as v, estimateNode as w, pairedPromotionPower as x, searchClaimReserveUsd as y };
2608
2608
 
2609
- //# sourceMappingURL=pareto-C445lnEH.js.map
2609
+ //# sourceMappingURL=pareto-fJZg8pXm.js.map