@tangle-network/agent-eval 2.0.9 → 2.0.10
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.
- package/CHANGELOG.md +64 -16
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-ORN4aArD.d.ts → agent-profile-_JzxgLDM.d.ts} +11 -5
- package/dist/{agent-profile-ORN4aArD.d.ts.map → agent-profile-_JzxgLDM.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +14 -14
- package/dist/analyst/index.js +31 -10
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyze-runs-DT693FJ7.d.ts → analyze-runs-Izz_ZeWg.d.ts} +2 -2
- package/dist/{analyze-runs-DT693FJ7.d.ts.map → analyze-runs-Izz_ZeWg.d.ts.map} +1 -1
- package/dist/{analyze-runs-CE_5VKh2.js → analyze-runs-xhH2Qxoc.js} +5 -5
- package/dist/{analyze-runs-CE_5VKh2.js.map → analyze-runs-xhH2Qxoc.js.map} +1 -1
- package/dist/app-grade/index.d.ts +4 -4
- package/dist/{benchmark-command-DLg8E4y8.js → benchmark-command-CGQXNFj7.js} +8 -7
- package/dist/benchmark-command-CGQXNFj7.js.map +1 -0
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +2 -2
- package/dist/campaign/index.d.ts +7 -7
- package/dist/campaign/index.js +11 -11
- package/dist/{campaign-C_S3MOYa.js → campaign-eus7YRs2.js} +13 -13
- package/dist/{campaign-C_S3MOYa.js.map → campaign-eus7YRs2.js.map} +1 -1
- package/dist/{campaign-evidence-CM4FBOkX.d.ts → campaign-evidence-BOcX4w0r.d.ts} +5 -5
- package/dist/{campaign-evidence-CM4FBOkX.d.ts.map → campaign-evidence-BOcX4w0r.d.ts.map} +1 -1
- package/dist/{campaign-evidence-BTfzZo1u.js → campaign-evidence-KM5GTsHG.js} +3 -3
- package/dist/{campaign-evidence-BTfzZo1u.js.map → campaign-evidence-KM5GTsHG.js.map} +1 -1
- package/dist/{chat-client-uQNXGuO4.d.ts → chat-client-BlTooBDA.d.ts} +7 -2
- package/dist/{chat-client-uQNXGuO4.d.ts.map → chat-client-BlTooBDA.d.ts.map} +1 -1
- package/dist/{chat-client-CvyDOQBv.js → chat-client-Oyot5tyo.js} +2 -2
- package/dist/{chat-client-CvyDOQBv.js.map → chat-client-Oyot5tyo.js.map} +1 -1
- package/dist/{chat-json-call-DMrwmB-k.js → chat-json-call-DTmv2uNY.js} +2 -2
- package/dist/{chat-json-call-DMrwmB-k.js.map → chat-json-call-DTmv2uNY.js.map} +1 -1
- package/dist/cli.js +7 -7
- package/dist/{cluster-C-K0N2br.d.ts → cluster-BJ0nW3P7.d.ts} +2 -2
- package/dist/{cluster-C-K0N2br.d.ts.map → cluster-BJ0nW3P7.d.ts.map} +1 -1
- package/dist/{cluster-bootstrap-DXbnIdm8.js → cluster-bootstrap-CTC8Dd30.js} +2 -2
- package/dist/{cluster-bootstrap-DXbnIdm8.js.map → cluster-bootstrap-CTC8Dd30.js.map} +1 -1
- package/dist/{completion-verifier-DsotH2l3.js → completion-verifier-CCPG2Yc0.js} +3 -3
- package/dist/{completion-verifier-DsotH2l3.js.map → completion-verifier-CCPG2Yc0.js.map} +1 -1
- package/dist/{completion-verifier-C7wipJOK.d.ts → completion-verifier-CQOC3_bm.d.ts} +2 -2
- package/dist/{completion-verifier-C7wipJOK.d.ts.map → completion-verifier-CQOC3_bm.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +11 -11
- package/dist/contract/index.js +12 -12
- package/dist/{default-registry-kps1SOaD.js → default-registry-Rs5uzlfJ.js} +3 -3
- package/dist/{default-registry-kps1SOaD.js.map → default-registry-Rs5uzlfJ.js.map} +1 -1
- package/dist/{default-registry-Bskl2HzV.d.ts → default-registry-X8McMoUV.d.ts} +6 -6
- package/dist/{default-registry-Bskl2HzV.d.ts.map → default-registry-X8McMoUV.d.ts.map} +1 -1
- package/dist/{define-agent-eval-Dnh4jXLX.js → define-agent-eval-D8ntOXqV.js} +3 -3
- package/dist/{define-agent-eval-Dnh4jXLX.js.map → define-agent-eval-D8ntOXqV.js.map} +1 -1
- package/dist/{define-agent-eval-tu3anVlk.d.ts → define-agent-eval-DH5-xi-F.d.ts} +4 -4
- package/dist/{define-agent-eval-tu3anVlk.d.ts.map → define-agent-eval-DH5-xi-F.d.ts.map} +1 -1
- package/dist/diagnosis/index.d.ts +2 -2
- package/dist/diagnosis/index.js +1 -1
- package/dist/{dspy-rlm-engine-DQbPdT_o.js → dspy-rlm-engine-ChE1PUM5.js} +3 -3
- package/dist/{dspy-rlm-engine-DQbPdT_o.js.map → dspy-rlm-engine-ChE1PUM5.js.map} +1 -1
- package/dist/{eval-campaign-DswSn7Gm.js → eval-campaign-BciGnrGy.js} +2 -2
- package/dist/{eval-campaign-DswSn7Gm.js.map → eval-campaign-BciGnrGy.js.map} +1 -1
- package/dist/{evaluation-C4-tf3Z_.d.ts → evaluation-CjZH6gW0.d.ts} +4 -4
- package/dist/{evaluation-C4-tf3Z_.d.ts.map → evaluation-CjZH6gW0.d.ts.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/{exact-types-CUsSMW3n.d.ts → exact-types-BIHqYBYf.d.ts} +2 -2
- package/dist/{exact-types-CUsSMW3n.d.ts.map → exact-types-BIHqYBYf.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +5 -5
- package/dist/experiment/index.js +8 -8
- package/dist/{external-optimizer-contracts-ZDBfbZ_s.js → external-optimizer-contracts-BFV8lnhl.js} +7 -2
- package/dist/{external-optimizer-contracts-ZDBfbZ_s.js.map → external-optimizer-contracts-BFV8lnhl.js.map} +1 -1
- package/dist/{external-optimizer-process-CVi1x2nb.js → external-optimizer-process-B6emPodQ.js} +3 -3
- package/dist/{external-optimizer-process-CVi1x2nb.js.map → external-optimizer-process-B6emPodQ.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-mV-2swJI.js → external-optimizer-subprocess-_O06eDVA.js} +33 -20
- package/dist/external-optimizer-subprocess-_O06eDVA.js.map +1 -0
- package/dist/{feedback-trajectory-D7hgL6y5.d.ts → feedback-trajectory-CoQPmSJV.d.ts} +3 -3
- package/dist/{feedback-trajectory-D7hgL6y5.d.ts.map → feedback-trajectory-CoQPmSJV.d.ts.map} +1 -1
- package/dist/{findings-store-CZy5kUDo.js → findings-store-CvYUzQBR.js} +4 -4
- package/dist/{findings-store-CZy5kUDo.js.map → findings-store-CvYUzQBR.js.map} +1 -1
- package/dist/{index-Cav3abKy.d.ts → index-BSb3fJyZ.d.ts} +81 -19
- package/dist/{index-Cav3abKy.d.ts.map → index-BSb3fJyZ.d.ts.map} +1 -1
- package/dist/{index-CIqYaySd.d.ts → index-Bk1XEkP7.d.ts} +26 -16
- package/dist/index-Bk1XEkP7.d.ts.map +1 -0
- package/dist/{index-DmMHTDjT.d.ts → index-BmWw8zN6.d.ts} +9 -9
- package/dist/{index-DmMHTDjT.d.ts.map → index-BmWw8zN6.d.ts.map} +1 -1
- package/dist/{index--vDCtdaj.d.ts → index-CCOaNmh2.d.ts} +7 -7
- package/dist/{index--vDCtdaj.d.ts.map → index-CCOaNmh2.d.ts.map} +1 -1
- package/dist/{index-moZnazVj.d.ts → index-ZffK_5sD.d.ts} +21 -21
- package/dist/{index-moZnazVj.d.ts.map → index-ZffK_5sD.d.ts.map} +1 -1
- package/dist/{index-Er8TKQ3q.d.ts → index-aRalB_Ma.d.ts} +3 -3
- package/dist/{index-Er8TKQ3q.d.ts.map → index-aRalB_Ma.d.ts.map} +1 -1
- package/dist/index.d.ts +29 -29
- package/dist/index.js +23 -23
- package/dist/{integrity-BF0tJK21.js → integrity-DacT3oJ1.js} +2 -2
- package/dist/{integrity-BF0tJK21.js.map → integrity-DacT3oJ1.js.map} +1 -1
- package/dist/{integrity-BJGstiCh.d.ts → integrity-DotDLWtj.d.ts} +2 -2
- package/dist/{integrity-BJGstiCh.d.ts.map → integrity-DotDLWtj.d.ts.map} +1 -1
- package/dist/{judge-gate-DANg5FLq.js → judge-gate-CpD3wmcf.js} +2 -2
- package/dist/{judge-gate-DANg5FLq.js.map → judge-gate-CpD3wmcf.js.map} +1 -1
- package/dist/{llm-client-Dw4x6EdE.js → llm-client-Dk8lBnMh.js} +15 -2
- package/dist/{llm-client-Dw4x6EdE.js.map → llm-client-Dk8lBnMh.js.map} +1 -1
- package/dist/{llm-judge-DFoSy4Qn.js → llm-judge-DYmEdo3M.js} +3 -3
- package/dist/{llm-judge-DFoSy4Qn.js.map → llm-judge-DYmEdo3M.js.map} +1 -1
- package/dist/{matrix-OgdWQBQa.d.ts → matrix-BDl7hoBr.d.ts} +2 -2
- package/dist/{matrix-OgdWQBQa.d.ts.map → matrix-BDl7hoBr.d.ts.map} +1 -1
- package/dist/{measure-validity-plan-B1_qYlsk.d.ts → measure-validity-plan-BReXzcVh.d.ts} +62 -4
- package/dist/measure-validity-plan-BReXzcVh.d.ts.map +1 -0
- package/dist/{measure-validity-plan-t0YQRzJQ.js → measure-validity-plan-CJkBNzX_.js} +43 -6
- package/dist/measure-validity-plan-CJkBNzX_.js.map +1 -0
- package/dist/meta-eval/index.d.ts +2 -2
- package/dist/meta-eval/index.js +178 -35
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +56 -17
- package/dist/multishot/index.d.ts.map +1 -1
- package/dist/multishot/index.js +93 -20
- package/dist/multishot/index.js.map +1 -1
- package/dist/node-transport-DJno8V46.js +62 -0
- package/dist/node-transport-DJno8V46.js.map +1 -0
- package/dist/openapi.json +1 -1
- package/dist/{optimization-method-D4CpYsVA.js → optimization-method-4JlbMxd2.js} +27 -38
- package/dist/optimization-method-4JlbMxd2.js.map +1 -0
- package/dist/{paired-arms-B6EXnI47.js → paired-arms-CJH5Q0wx.js} +2 -2
- package/dist/{paired-arms-B6EXnI47.js.map → paired-arms-CJH5Q0wx.js.map} +1 -1
- package/dist/{paired-promotion-decision-xYe881cD.js → paired-promotion-decision-BtfVwEAk.js} +2 -2
- package/dist/{paired-promotion-decision-xYe881cD.js.map → paired-promotion-decision-BtfVwEAk.js.map} +1 -1
- package/dist/{paired-promotion-decision-DuvRdnsW.d.ts → paired-promotion-decision-DJlI4z_k.d.ts} +2 -2
- package/dist/{paired-promotion-decision-DuvRdnsW.d.ts.map → paired-promotion-decision-DJlI4z_k.d.ts.map} +1 -1
- package/dist/{paired-promotion-power-DirShsIs.js → paired-promotion-power-DG1avBKf.js} +3 -3
- package/dist/{paired-promotion-power-DirShsIs.js.map → paired-promotion-power-DG1avBKf.js.map} +1 -1
- package/dist/pipelines/index.js +1 -1
- package/dist/{power-DTg6u30w.js → power-COie_o6E.js} +3 -3
- package/dist/{power-DTg6u30w.js.map → power-COie_o6E.js.map} +1 -1
- package/dist/{prime-protocol-Jm2pWh--.d.ts → prime-protocol-BRMk6dGI.d.ts} +2 -2
- package/dist/{prime-protocol-Jm2pWh--.d.ts.map → prime-protocol-BRMk6dGI.d.ts.map} +1 -1
- package/dist/{promotion-gate-BXgcORnM.d.ts → promotion-gate-B0VTBoXg.d.ts} +2 -2
- package/dist/{promotion-gate-BXgcORnM.d.ts.map → promotion-gate-B0VTBoXg.d.ts.map} +1 -1
- package/dist/{promotion-policy-Z5E-C32U.js → promotion-policy-BgI7PsQn.js} +3 -3
- package/dist/{promotion-policy-Z5E-C32U.js.map → promotion-policy-BgI7PsQn.js.map} +1 -1
- package/dist/{registry-DEZDECdr.d.ts → registry-BeInzotS.d.ts} +4 -4
- package/dist/{registry-DEZDECdr.d.ts.map → registry-BeInzotS.d.ts.map} +1 -1
- package/dist/reporting.d.ts +4 -4
- package/dist/reporting.js +3 -3
- package/dist/{research-report-CIgUe1lv.d.ts → research-report-CL5_UqCX.d.ts} +2 -2
- package/dist/{research-report-CIgUe1lv.d.ts.map → research-report-CL5_UqCX.d.ts.map} +1 -1
- package/dist/{researcher-CY_byuZl.d.ts → researcher-BOpZP_Ja.d.ts} +4 -4
- package/dist/{researcher-CY_byuZl.d.ts.map → researcher-BOpZP_Ja.d.ts.map} +1 -1
- package/dist/rl.d.ts +7 -7
- package/dist/rl.js +4 -4
- package/dist/rollout/index.d.ts +2 -2
- package/dist/rollout/index.js +1 -1
- package/dist/{rollout-B_lrpd9a.js → rollout--rSr43Pd.js} +2 -2
- package/dist/{rollout-B_lrpd9a.js.map → rollout--rSr43Pd.js.map} +1 -1
- package/dist/{rollout-nodes-Vas6OSxX.js → rollout-nodes-DFxKpIr2.js} +39 -10
- package/dist/rollout-nodes-DFxKpIr2.js.map +1 -0
- package/dist/{run-improvement-loop-BaPDVbW8.d.ts → run-improvement-loop-BeHu5D9Z.d.ts} +22 -10
- package/dist/run-improvement-loop-BeHu5D9Z.d.ts.map +1 -0
- package/dist/{runtime-rollouts-Vv-BAqmq.js → runtime-rollouts-CE0MbQPq.js} +54 -7
- package/dist/runtime-rollouts-CE0MbQPq.js.map +1 -0
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-BzTeb89p.d.ts → search-kernel-CJZ-ZSV1.d.ts} +3 -3
- package/dist/{search-kernel-BzTeb89p.d.ts.map → search-kernel-CJZ-ZSV1.d.ts.map} +1 -1
- package/dist/{search-kernel-DOPW08Hx.js → search-kernel-mZc79S6N.js} +4 -4
- package/dist/{search-kernel-DOPW08Hx.js.map → search-kernel-mZc79S6N.js.map} +1 -1
- package/dist/{search-summary-CYOHZAAy.js → search-summary-CCgP2qXz.js} +3 -3
- package/dist/{search-summary-CYOHZAAy.js.map → search-summary-CCgP2qXz.js.map} +1 -1
- package/dist/{self-improve-DY8ZY4lY.d.ts → self-improve-B1fsNejr.d.ts} +6 -6
- package/dist/{self-improve-DY8ZY4lY.d.ts.map → self-improve-B1fsNejr.d.ts.map} +1 -1
- package/dist/{self-improve-CIFqccHV.js → self-improve-C_Bcdmv8.js} +5 -4
- package/dist/{self-improve-CIFqccHV.js.map → self-improve-C_Bcdmv8.js.map} +1 -1
- package/dist/{sequential-B9iROM1S.d.ts → sequential-CHplorpC.d.ts} +2 -2
- package/dist/{sequential-B9iROM1S.d.ts.map → sequential-CHplorpC.d.ts.map} +1 -1
- package/dist/{sequential-tZjGysXY.js → sequential-DR-pnYQ7.js} +3 -3
- package/dist/{sequential-tZjGysXY.js.map → sequential-DR-pnYQ7.js.map} +1 -1
- package/dist/{server-1fzBCxMh.js → server-aZFmRucn.js} +3 -3
- package/dist/{server-1fzBCxMh.js.map → server-aZFmRucn.js.map} +1 -1
- package/dist/{skillopt-optimization-method-CbHBkopM.js → skillopt-optimization-method-DHk1K757.js} +93 -39
- package/dist/skillopt-optimization-method-DHk1K757.js.map +1 -0
- package/dist/{statistical-heldout-C7Jjo5nP.js → statistical-heldout-CL_7mI5C.js} +2 -2
- package/dist/{statistical-heldout-C7Jjo5nP.js.map → statistical-heldout-CL_7mI5C.js.map} +1 -1
- package/dist/{statistics-BPl13X3G.js → statistics-AKnVFnK-.js} +67 -42
- package/dist/statistics-AKnVFnK-.js.map +1 -0
- package/dist/statistics.d.ts +3 -3
- package/dist/statistics.js +1 -1
- package/dist/{store-tool-spans-Dq8r0PbJ.d.ts → store-tool-spans-M3WxeRrG.d.ts} +4 -4
- package/dist/{store-tool-spans-Dq8r0PbJ.d.ts.map → store-tool-spans-M3WxeRrG.d.ts.map} +1 -1
- package/dist/{summary-report-DzbnK81K.js → summary-report-DyBkOC6V.js} +3 -3
- package/dist/{summary-report-DzbnK81K.js.map → summary-report-DyBkOC6V.js.map} +1 -1
- package/dist/supervisor-run/index.d.ts +12 -2
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +3 -3
- package/dist/{systemone-BuSZTI88.d.ts → systemone-4PadCE4C.d.ts} +7 -7
- package/dist/{systemone-BuSZTI88.d.ts.map → systemone-4PadCE4C.d.ts.map} +1 -1
- package/dist/{systemone-review-mlfxWdLz.d.ts → systemone-review-DpAXWDkL.d.ts} +2 -2
- package/dist/{systemone-review-mlfxWdLz.d.ts.map → systemone-review-DpAXWDkL.d.ts.map} +1 -1
- package/dist/systemone.d.ts +3 -3
- package/dist/{tool-groups-PNDX8fd-.d.ts → tool-groups-SlnoQNyT.d.ts} +2 -2
- package/dist/tool-groups-SlnoQNyT.d.ts.map +1 -0
- package/dist/{tool-waste-783VCo1y.js → tool-waste-BZnYSa6J.js} +2 -2
- package/dist/{tool-waste-783VCo1y.js.map → tool-waste-BZnYSa6J.js.map} +1 -1
- package/dist/{trace-questions-DBtr4jWi.d.ts → trace-questions-ybyF0B6N.d.ts} +2 -2
- package/dist/{trace-questions-DBtr4jWi.d.ts.map → trace-questions-ybyF0B6N.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/traces.d.ts +4 -4
- package/dist/{tree-CtlQQL1w.js → tree-CiIe-f3f.js} +4 -4
- package/dist/{tree-CtlQQL1w.js.map → tree-CiIe-f3f.js.map} +1 -1
- package/dist/{types-CKNAzCSA.d.ts → types-B1W3v8dT.d.ts} +3 -3
- package/dist/{types-CKNAzCSA.d.ts.map → types-B1W3v8dT.d.ts.map} +1 -1
- package/dist/{types-BO948H-U.d.ts → types-D5XtEH9Q.d.ts} +8 -4
- package/dist/{types-BO948H-U.d.ts.map → types-D5XtEH9Q.d.ts.map} +1 -1
- package/dist/{types-DbeIGi73.d.ts → types-an-CUndX.d.ts} +2 -2
- package/dist/{types-DbeIGi73.d.ts.map → types-an-CUndX.d.ts.map} +1 -1
- package/dist/{types-D-WF1KM3.d.ts → types-xVtEOBhO.d.ts} +31 -8
- package/dist/types-xVtEOBhO.d.ts.map +1 -0
- package/dist/wire/index.d.ts +4 -4
- package/dist/wire/index.js +1 -1
- package/dist/world/index.d.ts +1 -1
- package/docs/design/statistics-decisions.md +18 -1
- package/docs/eval-surface-map.md +1 -1
- package/docs/feature-guide.md +1 -1
- package/docs/multi-turn-optimization.md +6 -2
- package/docs/outcome-validity.md +51 -12
- package/docs/public-api.md +7 -7
- package/docs/{multi-shot-optimization.md → trajectory-optimization.md} +1 -1
- package/package.json +1 -1
- package/dist/benchmark-command-DLg8E4y8.js.map +0 -1
- package/dist/external-optimizer-subprocess-mV-2swJI.js.map +0 -1
- package/dist/index-CIqYaySd.d.ts.map +0 -1
- package/dist/measure-validity-plan-B1_qYlsk.d.ts.map +0 -1
- package/dist/measure-validity-plan-t0YQRzJQ.js.map +0 -1
- package/dist/optimization-method-D4CpYsVA.js.map +0 -1
- package/dist/rollout-nodes-Vas6OSxX.js.map +0 -1
- package/dist/run-improvement-loop-BaPDVbW8.d.ts.map +0 -1
- package/dist/runtime-rollouts-Vv-BAqmq.js.map +0 -1
- package/dist/skillopt-optimization-method-CbHBkopM.js.map +0 -1
- package/dist/statistics-BPl13X3G.js.map +0 -1
- package/dist/tool-groups-PNDX8fd-.d.ts.map +0 -1
- package/dist/types-D-WF1KM3.d.ts.map +0 -1
package/dist/meta-eval/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { n as CaptureIntegrityError, s as ValidationError } from "../errors-DeEEV9Vx.js";
|
|
2
2
|
import { a as hashCanonical, i as compareCodeUnits } from "../canonical-DKgL_Wby.js";
|
|
3
|
+
import { t as interpolatedQuantile } from "../quantile-CncXP-Ss.js";
|
|
3
4
|
import { f as spearmanR } from "../paired-tests-CXcD_B80.js";
|
|
4
5
|
import { t as mulberry32 } from "../random-DrzcgC7F.js";
|
|
5
|
-
import { $ as selfPreference, H as clusteredAssociation, Q as positionalBias, V as associationEstimate, X as calibrateJudgeContinuous, Y as calibrateJudge, Z as continuousAgreement, b as benjaminiHochberg, et as verbosityBias, n as sampleMedian } from "../statistics-
|
|
6
|
+
import { $ as selfPreference, H as clusteredAssociation, Q as positionalBias, V as associationEstimate, X as calibrateJudgeContinuous, Y as calibrateJudge, Z as continuousAgreement, b as benjaminiHochberg, et as verbosityBias, n as sampleMedian } from "../statistics-AKnVFnK-.js";
|
|
6
7
|
import { s as runMetricExtractor } from "../query-Dhjkwqyx.js";
|
|
7
|
-
import { n as callLlmJson } from "../llm-client-
|
|
8
|
+
import { n as callLlmJson } from "../llm-client-Dk8lBnMh.js";
|
|
8
9
|
import { a as reduceOutcomeMetric, i as hasVariation, n as correlationSummary, o as reduceOutcomeObservation, r as groupOutcomesByRun, s as validateObservationOptions, t as assertUniqueObservationIds } from "../outcome-observations-DEh8_V_P.js";
|
|
9
10
|
import { a as rankedProbabilityScore, i as multiclassBrierScore, n as calibrationCurve, r as calibrationFromPairs, t as brierScore } from "../calibration-Dz8mQb5P.js";
|
|
10
|
-
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-
|
|
11
|
+
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-CpD3wmcf.js";
|
|
11
12
|
import { t as computeInterval } from "../interval-Bd2f4CRT.js";
|
|
12
|
-
import { t as clusterBootstrapMean } from "../cluster-bootstrap-
|
|
13
|
+
import { t as clusterBootstrapMean } from "../cluster-bootstrap-CTC8Dd30.js";
|
|
13
14
|
import { t as rubricPredictiveValidity } from "../rubric-predictive-validity-BXJ92Jp_.js";
|
|
14
15
|
import { n as InMemoryOutcomeStore, r as OutcomeStoreError, t as FileSystemOutcomeStore } from "../outcome-store-TarrcfHG.js";
|
|
15
|
-
import { n as verifyMeasureValidityPlan } from "../measure-validity-plan-
|
|
16
|
+
import { n as verifyMeasureValidityPlan } from "../measure-validity-plan-CJkBNzX_.js";
|
|
16
17
|
import { z } from "zod";
|
|
17
18
|
// src/meta-eval/correlation-study.ts
|
|
18
19
|
/**
|
|
@@ -605,14 +606,21 @@ function validateChanges(changes, plan, requireUniqueIds) {
|
|
|
605
606
|
}
|
|
606
607
|
}
|
|
607
608
|
}
|
|
608
|
-
|
|
609
|
+
/**
|
|
610
|
+
* The observations a change may join, each excluded one counted under the
|
|
611
|
+
* first reason that applies. `asOf` is when the outcomes were read: nothing
|
|
612
|
+
* captured after it can have been known.
|
|
613
|
+
*/
|
|
614
|
+
function eligibleObservations(observations, change, plan, preCut, asOf) {
|
|
609
615
|
const counts = {
|
|
610
616
|
capturedBeforeChange: 0,
|
|
617
|
+
capturedAfterAsOf: 0,
|
|
611
618
|
capturedAfterCutForPreCutChange: 0,
|
|
612
619
|
beyondMaxCaptureLag: 0
|
|
613
620
|
};
|
|
614
621
|
const eligible = [];
|
|
615
622
|
for (const observation of observations) if (observation.capturedAt < change.at) counts.capturedBeforeChange++;
|
|
623
|
+
else if (asOf !== void 0 && observation.capturedAt > asOf) counts.capturedAfterAsOf++;
|
|
616
624
|
else if (plan.maxCaptureLagMs !== void 0 && observation.capturedAt - change.at > plan.maxCaptureLagMs) counts.beyondMaxCaptureLag++;
|
|
617
625
|
else if (preCut && observation.capturedAt > plan.cut) counts.capturedAfterCutForPreCutChange++;
|
|
618
626
|
else eligible.push(observation);
|
|
@@ -783,11 +791,25 @@ function alignedZ(value, direction, reference) {
|
|
|
783
791
|
function selectMeasures(outcome, pairs, pre, post, plan, outcomeRef) {
|
|
784
792
|
const statistic = statisticOf(outcome);
|
|
785
793
|
const nullValue = statistic === "auc" ? .5 : 0;
|
|
786
|
-
const admitted = pairs.filter((pair) => pair.outcome === outcome.id && (pair.label === "predicts" || pair.label === "predicts-pooled-only"));
|
|
794
|
+
const admitted = pairs.filter((pair) => pair.outcome === outcome.id && (pair.label === "predicts" || pair.label === "predicts-through-exposure" || pair.label === "predicts-pooled-only"));
|
|
787
795
|
const excluded = [];
|
|
788
796
|
const references = /* @__PURE__ */ new Map();
|
|
789
797
|
const candidates = [];
|
|
790
798
|
for (const pair of admitted) {
|
|
799
|
+
if (pair.measure === pair.exposure) {
|
|
800
|
+
excluded.push({
|
|
801
|
+
measure: pair.measure,
|
|
802
|
+
reason: "exposure"
|
|
803
|
+
});
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
if (pair.label === "predicts-through-exposure") {
|
|
807
|
+
excluded.push({
|
|
808
|
+
measure: pair.measure,
|
|
809
|
+
reason: "through-exposure"
|
|
810
|
+
});
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
791
813
|
if (pair.label === "predicts-pooled-only") {
|
|
792
814
|
excluded.push({
|
|
793
815
|
measure: pair.measure,
|
|
@@ -803,6 +825,15 @@ function selectMeasures(outcome, pairs, pre, post, plan, outcomeRef) {
|
|
|
803
825
|
});
|
|
804
826
|
continue;
|
|
805
827
|
}
|
|
828
|
+
const floor = plan.selection.minEffect?.[statistic];
|
|
829
|
+
const effect = pair.exposure === null ? pair.postCut.association : pair.postCut.withinExposure;
|
|
830
|
+
if (floor !== void 0 && (effect === null || effect.estimate - effect.null < floor)) {
|
|
831
|
+
excluded.push({
|
|
832
|
+
measure: pair.measure,
|
|
833
|
+
reason: "below-minimum-effect"
|
|
834
|
+
});
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
806
837
|
const values = pre.flatMap((row) => {
|
|
807
838
|
const value = row.change.measures[pair.measure];
|
|
808
839
|
return value === void 0 ? [] : [value];
|
|
@@ -949,10 +980,16 @@ function selectMeasures(outcome, pairs, pre, post, plan, outcomeRef) {
|
|
|
949
980
|
* standardization and the selected subset; every reported statistic comes from
|
|
950
981
|
* changes at or after it with those choices fixed. Intervals resample whole
|
|
951
982
|
* units. Each test is one-sided, in the direction fixed before the cut, and
|
|
952
|
-
* Benjamini-Hochberg at the plan's level runs across every pair tested
|
|
983
|
+
* Benjamini-Hochberg at the plan's level runs across every pair tested, again
|
|
984
|
+
* across every tested pair whose within-unit statistic is tested, and again
|
|
985
|
+
* across every tested pair with a within-exposure statistic, whatever its
|
|
986
|
+
* pooled result. A
|
|
953
987
|
* pooled statistic compares changes across units; a within-unit statistic
|
|
954
988
|
* compares changes of the same unit, so a measure that only tells units apart
|
|
955
|
-
* is visible as `predicts-pooled-only`.
|
|
989
|
+
* is visible as `predicts-pooled-only`. An outcome may name an exposure, a
|
|
990
|
+
* measure it grows with for another reason (a bigger change has more to fix);
|
|
991
|
+
* every other measure is then also tested inside bins of the exposure, and one
|
|
992
|
+
* that predicts only by tracking it is `predicts-through-exposure`.
|
|
956
993
|
*
|
|
957
994
|
* Prediction is not causation. An admitted measure forecasts the outcome of
|
|
958
995
|
* changes like these; it does not show that raising the measure raises the
|
|
@@ -970,52 +1007,67 @@ async function measureValidityStudy(input) {
|
|
|
970
1007
|
const sealed = structuredClone(input.plan);
|
|
971
1008
|
if (!verifyMeasureValidityPlan(sealed)) throw new ValidationError("measureValidityStudy: the plan seal does not verify; seal it with sealMeasureValidityPlan before reading changes after the cut");
|
|
972
1009
|
const plan = sealed.plan;
|
|
1010
|
+
const asOf = input.asOf;
|
|
1011
|
+
if (asOf !== void 0 && !(Number.isFinite(asOf) && asOf >= plan.cut)) throw new ValidationError("measureValidityStudy: asOf must be finite epoch milliseconds at or after the cut");
|
|
1012
|
+
const windowed = plan.outcomes.filter((outcome) => outcome.windowMs !== void 0);
|
|
1013
|
+
if (asOf === void 0 && windowed.length > 0) throw new ValidationError(`measureValidityStudy: outcome ${windowed[0].id} declares windowMs, so asOf, the time the outcomes were read, is required`);
|
|
973
1014
|
validateChanges(input.changes, plan, true);
|
|
974
1015
|
const byRun = groupOutcomesByRun(await input.outcomes.list());
|
|
975
1016
|
const excluded = {
|
|
976
1017
|
capturedBeforeChange: 0,
|
|
1018
|
+
capturedAfterAsOf: 0,
|
|
977
1019
|
capturedAfterCutForPreCutChange: 0,
|
|
978
|
-
beyondMaxCaptureLag: 0
|
|
1020
|
+
beyondMaxCaptureLag: 0,
|
|
1021
|
+
windowOpenAtCut: 0,
|
|
1022
|
+
windowOpenAtEnd: 0
|
|
979
1023
|
};
|
|
980
1024
|
const prepared = input.changes.map((change) => {
|
|
981
1025
|
const preCut = change.at < plan.cut;
|
|
982
|
-
const { eligible, ...counts } = eligibleObservations(byRun.get(change.id) ?? [], change, plan, preCut);
|
|
1026
|
+
const { eligible, ...counts } = eligibleObservations(byRun.get(change.id) ?? [], change, plan, preCut, asOf);
|
|
983
1027
|
excluded.capturedBeforeChange += counts.capturedBeforeChange;
|
|
1028
|
+
excluded.capturedAfterAsOf += counts.capturedAfterAsOf;
|
|
984
1029
|
excluded.capturedAfterCutForPreCutChange += counts.capturedAfterCutForPreCutChange;
|
|
985
1030
|
excluded.beyondMaxCaptureLag += counts.beyondMaxCaptureLag;
|
|
1031
|
+
const outcomes = joinOutcomes(eligible, change, plan.outcomes, plan.reduction);
|
|
1032
|
+
for (const outcome of windowed) {
|
|
1033
|
+
const closesBy = preCut ? plan.cut : asOf;
|
|
1034
|
+
if (change.at + outcome.windowMs > closesBy && outcomes.delete(outcome.id)) {
|
|
1035
|
+
if (preCut) excluded.windowOpenAtCut++;
|
|
1036
|
+
else excluded.windowOpenAtEnd++;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
986
1039
|
return {
|
|
987
1040
|
change,
|
|
988
1041
|
preCut,
|
|
989
|
-
outcomes
|
|
1042
|
+
outcomes
|
|
990
1043
|
};
|
|
991
1044
|
});
|
|
992
1045
|
const pre = prepared.filter((row) => row.preCut);
|
|
993
1046
|
const post = prepared.filter((row) => !row.preCut);
|
|
994
1047
|
const preUnits = new Set(pre.map((row) => row.change.unit));
|
|
995
1048
|
const postUnits = new Set(post.map((row) => row.change.unit));
|
|
1049
|
+
const exposures = plan.outcomes.flatMap((outcome) => outcome.exposure === void 0 ? [] : [exposureBins(outcome, pre)]);
|
|
996
1050
|
const pairs = [];
|
|
997
|
-
for (const measure of plan.measures) for (const outcome of plan.outcomes)
|
|
1051
|
+
for (const measure of plan.measures) for (const outcome of plan.outcomes) {
|
|
1052
|
+
const bins = exposures.find((row) => row.outcome === outcome.id) ?? null;
|
|
1053
|
+
pairs.push(assessPair(measure.id, outcome, bins, pre, post, plan));
|
|
1054
|
+
}
|
|
998
1055
|
const tested = pairs.filter((pair) => pair.postCut.association !== null);
|
|
999
1056
|
const { qValues } = benjaminiHochberg(tested.map((pair) => pair.postCut.association.pValue), plan.level);
|
|
1000
1057
|
tested.forEach((pair, index) => {
|
|
1001
1058
|
pair.postCut.qValue = qValues[index];
|
|
1002
1059
|
});
|
|
1003
|
-
const withinTested = tested.filter((pair) => pair.postCut.withinUnit !== null);
|
|
1060
|
+
const withinTested = tested.filter((pair) => pair.postCut.withinUnit !== null && pair.postCut.withinUnit.units >= plan.minUnits);
|
|
1004
1061
|
const withinQ = benjaminiHochberg(withinTested.map((pair) => pair.postCut.withinUnit.pValue), plan.level).qValues;
|
|
1005
1062
|
withinTested.forEach((pair, index) => {
|
|
1006
1063
|
pair.postCut.withinUnitQValue = withinQ[index];
|
|
1007
1064
|
});
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
} else {
|
|
1015
|
-
pair.label = "not-shown";
|
|
1016
|
-
pair.reason = association.high < association.null ? "direction-reversed" : "not-significant";
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1065
|
+
const exposureTested = tested.filter((pair) => pair.postCut.withinExposure !== null);
|
|
1066
|
+
const exposureQ = benjaminiHochberg(exposureTested.map((pair) => pair.postCut.withinExposure.pValue), plan.level).qValues;
|
|
1067
|
+
exposureTested.forEach((pair, index) => {
|
|
1068
|
+
pair.postCut.withinExposureQValue = exposureQ[index];
|
|
1069
|
+
});
|
|
1070
|
+
for (const pair of tested) labelPair(pair, plan.level);
|
|
1019
1071
|
const outcomeReferences = new Map(plan.outcomes.map((outcome) => [outcome.id, outcomeReference(outcome, pre)]));
|
|
1020
1072
|
for (const pair of pairs) {
|
|
1021
1073
|
const outcome = plan.outcomes.find((row) => row.id === pair.outcome);
|
|
@@ -1034,6 +1086,7 @@ async function measureValidityStudy(input) {
|
|
|
1034
1086
|
return {
|
|
1035
1087
|
planDigest: sealed.digest,
|
|
1036
1088
|
plan,
|
|
1089
|
+
asOf: asOf ?? null,
|
|
1037
1090
|
claim: { ...CLAIM },
|
|
1038
1091
|
hypothesis: HYPOTHESIS,
|
|
1039
1092
|
changes: {
|
|
@@ -1047,15 +1100,76 @@ async function measureValidityStudy(input) {
|
|
|
1047
1100
|
both: [...postUnits].filter((unit) => preUnits.has(unit)).length
|
|
1048
1101
|
},
|
|
1049
1102
|
excludedObservations: excluded,
|
|
1103
|
+
exposures,
|
|
1050
1104
|
coverage: plan.measures.map((measure) => coverageOf(measure.id, pre, post)),
|
|
1051
1105
|
pairs,
|
|
1052
1106
|
tested: tested.length,
|
|
1053
1107
|
withinUnitTested: withinTested.length,
|
|
1108
|
+
withinExposureTested: exposureTested.length,
|
|
1054
1109
|
admitted: pairs.filter((pair) => pair.label === "predicts").length,
|
|
1055
1110
|
movementTested: movementTested.length,
|
|
1056
1111
|
selections
|
|
1057
1112
|
};
|
|
1058
1113
|
}
|
|
1114
|
+
/**
|
|
1115
|
+
* The pooled test admits; the test inside exposure bins and then the tested
|
|
1116
|
+
* within-unit test can only narrow the label.
|
|
1117
|
+
*/
|
|
1118
|
+
function labelPair(pair, level) {
|
|
1119
|
+
const association = pair.postCut.association;
|
|
1120
|
+
if (pair.postCut.qValue > level) {
|
|
1121
|
+
pair.label = "not-shown";
|
|
1122
|
+
pair.reason = association.high < association.null ? "direction-reversed" : "not-significant";
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
if (pair.exposure !== null && pair.exposure !== pair.measure) {
|
|
1126
|
+
if (pair.postCut.withinExposure === null) {
|
|
1127
|
+
pair.label = "predicts-through-exposure";
|
|
1128
|
+
pair.reason = "within-exposure-untested";
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
if (pair.withinExposureDirection !== pair.direction || pair.postCut.withinExposureQValue > level) {
|
|
1132
|
+
pair.label = "predicts-through-exposure";
|
|
1133
|
+
pair.reason = "within-exposure-not-shown";
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
if (pair.postCut.withinUnitQValue === null) {
|
|
1138
|
+
pair.label = "predicts";
|
|
1139
|
+
pair.reason = "within-unit-untested";
|
|
1140
|
+
} else if (pair.postCut.withinUnitQValue > level) {
|
|
1141
|
+
pair.label = "predicts-pooled-only";
|
|
1142
|
+
pair.reason = "within-unit-not-shown";
|
|
1143
|
+
} else {
|
|
1144
|
+
pair.label = "predicts";
|
|
1145
|
+
pair.reason = null;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
/** Bin edges at the exposure's quantiles over changes before the cut joined to the outcome. */
|
|
1149
|
+
function exposureBins(outcome, pre) {
|
|
1150
|
+
const { measure, bins } = outcome.exposure;
|
|
1151
|
+
const values = pre.flatMap((row) => {
|
|
1152
|
+
const value = row.change.measures[measure];
|
|
1153
|
+
return value === void 0 || !row.outcomes.has(outcome.id) ? [] : [value];
|
|
1154
|
+
}).sort((a, b) => a - b);
|
|
1155
|
+
const edges = [];
|
|
1156
|
+
if (values.length > 0) for (let k = 1; k < bins; k++) {
|
|
1157
|
+
const edge = interpolatedQuantile(values, k / bins);
|
|
1158
|
+
if (edge !== edges[edges.length - 1]) edges.push(edge);
|
|
1159
|
+
}
|
|
1160
|
+
return {
|
|
1161
|
+
outcome: outcome.id,
|
|
1162
|
+
measure,
|
|
1163
|
+
bins,
|
|
1164
|
+
edges
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
/** The bin of a value: the number of edges below it. */
|
|
1168
|
+
function binOf(value, edges) {
|
|
1169
|
+
let bin = 0;
|
|
1170
|
+
while (bin < edges.length && value > edges[bin]) bin++;
|
|
1171
|
+
return String(bin);
|
|
1172
|
+
}
|
|
1059
1173
|
function coverageOf(measure, pre, post) {
|
|
1060
1174
|
const measured = (rows) => rows.filter((row) => row.change.measures[measure] !== void 0).length;
|
|
1061
1175
|
const changes = pre.length + post.length;
|
|
@@ -1076,25 +1190,33 @@ function coverageOf(measure, pre, post) {
|
|
|
1076
1190
|
movements: [...pre, ...post].filter((row) => row.change.movements?.[measure] !== void 0).length
|
|
1077
1191
|
};
|
|
1078
1192
|
}
|
|
1079
|
-
|
|
1193
|
+
/** Joined changes for one pair; `stratum` is the exposure bin when the exposure was measured. */
|
|
1194
|
+
function joinedRows(rows, measure, outcome, exposure) {
|
|
1080
1195
|
return rows.flatMap((row) => {
|
|
1081
1196
|
const x = row.change.measures[measure];
|
|
1082
1197
|
const joined = row.outcomes.get(outcome);
|
|
1083
|
-
|
|
1198
|
+
if (x === void 0 || joined === void 0) return [];
|
|
1199
|
+
const exposed = exposure === null ? void 0 : row.change.measures[exposure.measure];
|
|
1200
|
+
return [{
|
|
1084
1201
|
x,
|
|
1085
1202
|
y: joined.better,
|
|
1086
1203
|
unit: row.change.unit,
|
|
1087
|
-
lag: joined.capturedAt - row.change.at
|
|
1204
|
+
lag: joined.capturedAt - row.change.at,
|
|
1205
|
+
...exposed === void 0 ? {} : { stratum: binOf(exposed, exposure.edges) }
|
|
1088
1206
|
}];
|
|
1089
1207
|
});
|
|
1090
1208
|
}
|
|
1091
|
-
function assessPair(measure, outcome, pre, post, plan) {
|
|
1209
|
+
function assessPair(measure, outcome, exposure, pre, post, plan) {
|
|
1092
1210
|
const statistic = statisticOf(outcome);
|
|
1093
1211
|
const nullValue = statistic === "auc" ? .5 : 0;
|
|
1094
|
-
const preRows = joinedRows(pre, measure, outcome.id);
|
|
1095
|
-
const postRows = joinedRows(post, measure, outcome.id);
|
|
1212
|
+
const preRows = joinedRows(pre, measure, outcome.id, exposure);
|
|
1213
|
+
const postRows = joinedRows(post, measure, outcome.id, exposure);
|
|
1096
1214
|
const preEstimate = preRows.length >= 3 ? associationEstimate(statistic, preRows) : NaN;
|
|
1097
|
-
const direction =
|
|
1215
|
+
const direction = directionOf(preEstimate, nullValue);
|
|
1216
|
+
const testsExposure = exposure !== null && exposure.measure !== measure;
|
|
1217
|
+
const preBinned = preRows.filter((row) => row.stratum !== void 0);
|
|
1218
|
+
const preWithinExposure = testsExposure && preBinned.length >= 3 ? associationEstimate(statistic, preBinned, "stratified") : NaN;
|
|
1219
|
+
const exposureDirection = directionOf(preWithinExposure, nullValue);
|
|
1098
1220
|
const postUnits = new Set(postRows.map((row) => row.unit)).size;
|
|
1099
1221
|
const lags = postRows.map((row) => row.lag);
|
|
1100
1222
|
const result = {
|
|
@@ -1104,10 +1226,13 @@ function assessPair(measure, outcome, pre, post, plan) {
|
|
|
1104
1226
|
label: "insufficient",
|
|
1105
1227
|
reason: null,
|
|
1106
1228
|
direction,
|
|
1229
|
+
exposure: exposure?.measure ?? null,
|
|
1230
|
+
withinExposureDirection: exposureDirection,
|
|
1107
1231
|
preCut: {
|
|
1108
1232
|
n: preRows.length,
|
|
1109
1233
|
units: new Set(preRows.map((row) => row.unit)).size,
|
|
1110
|
-
estimate: Number.isFinite(preEstimate) ? preEstimate : null
|
|
1234
|
+
estimate: Number.isFinite(preEstimate) ? preEstimate : null,
|
|
1235
|
+
withinExposure: Number.isFinite(preWithinExposure) ? preWithinExposure : null
|
|
1111
1236
|
},
|
|
1112
1237
|
postCut: {
|
|
1113
1238
|
n: postRows.length,
|
|
@@ -1116,7 +1241,9 @@ function assessPair(measure, outcome, pre, post, plan) {
|
|
|
1116
1241
|
association: null,
|
|
1117
1242
|
qValue: null,
|
|
1118
1243
|
withinUnit: null,
|
|
1119
|
-
withinUnitQValue: null
|
|
1244
|
+
withinUnitQValue: null,
|
|
1245
|
+
withinExposure: null,
|
|
1246
|
+
withinExposureQValue: null
|
|
1120
1247
|
},
|
|
1121
1248
|
leadTimeMs: lags.length === 0 ? null : {
|
|
1122
1249
|
median: sampleMedian(lags),
|
|
@@ -1144,12 +1271,28 @@ function assessPair(measure, outcome, pre, post, plan) {
|
|
|
1144
1271
|
...plan.seed === void 0 ? {} : { seed: plan.seed }
|
|
1145
1272
|
};
|
|
1146
1273
|
result.postCut.association = clusteredAssociation(aligned, options);
|
|
1147
|
-
if (comparableUnits(aligned) >=
|
|
1274
|
+
if (comparableUnits(aligned) >= 2 && Number.isFinite(associationEstimate(statistic, aligned, "within-unit"))) result.postCut.withinUnit = clusteredAssociation(aligned, {
|
|
1148
1275
|
...options,
|
|
1149
1276
|
scope: "within-unit"
|
|
1150
1277
|
});
|
|
1278
|
+
if (testsExposure && exposureDirection !== null) {
|
|
1279
|
+
const binned = postRows.flatMap((row) => row.stratum === void 0 ? [] : [{
|
|
1280
|
+
x: exposureDirection === "lower" ? -row.x : row.x,
|
|
1281
|
+
y: row.y,
|
|
1282
|
+
unit: row.unit,
|
|
1283
|
+
stratum: row.stratum
|
|
1284
|
+
}]);
|
|
1285
|
+
if (new Set(binned.map((row) => row.unit)).size >= 2 && Number.isFinite(associationEstimate(statistic, binned, "stratified"))) result.postCut.withinExposure = clusteredAssociation(binned, {
|
|
1286
|
+
...options,
|
|
1287
|
+
scope: "stratified"
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1151
1290
|
return result;
|
|
1152
1291
|
}
|
|
1292
|
+
function directionOf(estimate, nullValue) {
|
|
1293
|
+
if (!Number.isFinite(estimate)) return null;
|
|
1294
|
+
return estimate > nullValue ? "higher" : estimate < nullValue ? "lower" : null;
|
|
1295
|
+
}
|
|
1153
1296
|
/** Values that differ from the most common value: the smaller class of a two-valued measure. */
|
|
1154
1297
|
function minorityCount(values) {
|
|
1155
1298
|
const counts = /* @__PURE__ */ new Map();
|