@tangle-network/agent-eval 0.128.1 → 0.129.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/CHANGELOG.md +271 -0
  2. package/README.md +18 -0
  3. package/dist/analyst/index.d.ts +107 -165
  4. package/dist/analyst/index.js +5 -9
  5. package/dist/analyst/index.js.map +1 -1
  6. package/dist/belief-state/index.d.ts +2 -19
  7. package/dist/belief-state/index.js +30 -31
  8. package/dist/belief-state/index.js.map +1 -1
  9. package/dist/benchmarks/index.d.ts +5 -8
  10. package/dist/benchmarks/index.js +12 -11
  11. package/dist/builder-eval/index.js +1 -1
  12. package/dist/campaign/index.d.ts +30 -39
  13. package/dist/campaign/index.js +11 -10
  14. package/dist/{chunk-NKAGIDE2.js → chunk-2QU3YOPR.js} +15 -274
  15. package/dist/chunk-2QU3YOPR.js.map +1 -0
  16. package/dist/{chunk-EJGRPCO3.js → chunk-3OCR4R5I.js} +245 -134
  17. package/dist/chunk-3OCR4R5I.js.map +1 -0
  18. package/dist/{chunk-2JX3CFMB.js → chunk-56TAVBOK.js} +5 -2
  19. package/dist/chunk-56TAVBOK.js.map +1 -0
  20. package/dist/{chunk-DPUHNQLN.js → chunk-7FO3TNPI.js} +2 -2
  21. package/dist/{chunk-DJKY2TSY.js → chunk-BSO5JDQH.js} +27 -120
  22. package/dist/chunk-BSO5JDQH.js.map +1 -0
  23. package/dist/{chunk-EZJEIH2R.js → chunk-C6LXANRU.js} +11 -20
  24. package/dist/chunk-C6LXANRU.js.map +1 -0
  25. package/dist/{chunk-ZUUWPZCV.js → chunk-DODXQREJ.js} +4 -4
  26. package/dist/{chunk-2MKQIFS4.js → chunk-E7QXT7SX.js} +2 -2
  27. package/dist/{chunk-NYLOYM6N.js → chunk-EG66UGL4.js} +37 -28
  28. package/dist/chunk-EG66UGL4.js.map +1 -0
  29. package/dist/{chunk-P5W7RQKK.js → chunk-FXTVJPYD.js} +2 -2
  30. package/dist/{chunk-VZSRQ272.js → chunk-G7MGMCZD.js} +6 -2
  31. package/dist/chunk-G7MGMCZD.js.map +1 -0
  32. package/dist/{chunk-IHQDPH7D.js → chunk-H23X7XKK.js} +85 -75
  33. package/dist/chunk-H23X7XKK.js.map +1 -0
  34. package/dist/{chunk-VBQ3CRKH.js → chunk-HPWUNB47.js} +4 -6
  35. package/dist/chunk-HPWUNB47.js.map +1 -0
  36. package/dist/{chunk-XPRT64IE.js → chunk-IYCLP2N2.js} +3 -3
  37. package/dist/chunk-IYCLP2N2.js.map +1 -0
  38. package/dist/{chunk-XDWDC2MP.js → chunk-JQSF5DQT.js} +11 -5
  39. package/dist/chunk-JQSF5DQT.js.map +1 -0
  40. package/dist/{chunk-NACAGYSY.js → chunk-M4YBQKIJ.js} +11 -11
  41. package/dist/chunk-M4YBQKIJ.js.map +1 -0
  42. package/dist/{chunk-YJBNWCAA.js → chunk-NY44NC4A.js} +3 -3
  43. package/dist/chunk-OIUOT4QD.js +44 -0
  44. package/dist/chunk-OIUOT4QD.js.map +1 -0
  45. package/dist/chunk-OWN5NPMC.js +152 -0
  46. package/dist/chunk-OWN5NPMC.js.map +1 -0
  47. package/dist/chunk-PC5DOSM7.js +579 -0
  48. package/dist/chunk-PC5DOSM7.js.map +1 -0
  49. package/dist/{chunk-UB2LOJ6Q.js → chunk-QB6BDBP2.js} +23 -20
  50. package/dist/chunk-QB6BDBP2.js.map +1 -0
  51. package/dist/chunk-RXHCETDZ.js +536 -0
  52. package/dist/chunk-RXHCETDZ.js.map +1 -0
  53. package/dist/{chunk-PBE2LOSS.js → chunk-SFLLL76A.js} +7 -7
  54. package/dist/chunk-SFLLL76A.js.map +1 -0
  55. package/dist/{chunk-VGRCHJON.js → chunk-T6RLYGAD.js} +3 -8
  56. package/dist/chunk-T6RLYGAD.js.map +1 -0
  57. package/dist/{chunk-VLOATJQ2.js → chunk-TJVT4QFF.js} +21 -18
  58. package/dist/chunk-TJVT4QFF.js.map +1 -0
  59. package/dist/{chunk-S5YLIBFX.js → chunk-TQ7LNKZ3.js} +2 -2
  60. package/dist/{chunk-EOSZT7PL.js → chunk-U4L7JRPZ.js} +2 -297
  61. package/dist/chunk-U4L7JRPZ.js.map +1 -0
  62. package/dist/chunk-U4PHLT2N.js +419 -0
  63. package/dist/chunk-U4PHLT2N.js.map +1 -0
  64. package/dist/{chunk-WS3NZZQQ.js → chunk-VCZ5FQYW.js} +3 -4
  65. package/dist/chunk-VCZ5FQYW.js.map +1 -0
  66. package/dist/{chunk-BYT7ELPS.js → chunk-WVATSFCP.js} +2 -2
  67. package/dist/{chunk-TSN7JT6D.js → chunk-X4YIBDER.js} +21 -5
  68. package/dist/{chunk-TSN7JT6D.js.map → chunk-X4YIBDER.js.map} +1 -1
  69. package/dist/{chunk-TBL77AUT.js → chunk-YQN4ICPP.js} +5 -5
  70. package/dist/{chunk-MHELPNRP.js → chunk-ZHTZ4EYI.js} +1 -1
  71. package/dist/chunk-ZHTZ4EYI.js.map +1 -0
  72. package/dist/cli.js +6 -5
  73. package/dist/cli.js.map +1 -1
  74. package/dist/contract/index.d.ts +47 -87
  75. package/dist/contract/index.js +14 -13
  76. package/dist/contract/index.js.map +1 -1
  77. package/dist/control.js +3 -2
  78. package/dist/fuzz.js +3 -2
  79. package/dist/fuzz.js.map +1 -1
  80. package/dist/index.d.ts +659 -203
  81. package/dist/index.js +145 -117
  82. package/dist/index.js.map +1 -1
  83. package/dist/meta-eval/index.js +2 -2
  84. package/dist/multishot/index.d.ts +3 -4
  85. package/dist/multishot/index.js.map +1 -1
  86. package/dist/openapi.json +1 -1
  87. package/dist/pipelines/index.js +5 -5
  88. package/dist/reporting.d.ts +14 -0
  89. package/dist/reporting.js +7 -6
  90. package/dist/rl.d.ts +652 -82
  91. package/dist/rl.js +415 -171
  92. package/dist/rl.js.map +1 -1
  93. package/dist/rollout/index.d.ts +1071 -32
  94. package/dist/rollout/index.js +68 -10
  95. package/dist/run-campaign-OJJ7CZF4.js +18 -0
  96. package/dist/supervisor-run/index.d.ts +114 -4
  97. package/dist/supervisor-run/index.js +4 -3
  98. package/dist/traces.d.ts +1 -1
  99. package/dist/traces.js +6 -5
  100. package/dist/wire/index.d.ts +10 -11
  101. package/dist/wire/index.js +3 -3
  102. package/docs/feature-guide.md +1 -1
  103. package/docs/rollout.md +116 -2
  104. package/package.json +4 -4
  105. package/dist/chunk-2JX3CFMB.js.map +0 -1
  106. package/dist/chunk-DJKY2TSY.js.map +0 -1
  107. package/dist/chunk-EJGRPCO3.js.map +0 -1
  108. package/dist/chunk-EOSZT7PL.js.map +0 -1
  109. package/dist/chunk-EZJEIH2R.js.map +0 -1
  110. package/dist/chunk-IHQDPH7D.js.map +0 -1
  111. package/dist/chunk-MHELPNRP.js.map +0 -1
  112. package/dist/chunk-NACAGYSY.js.map +0 -1
  113. package/dist/chunk-NKAGIDE2.js.map +0 -1
  114. package/dist/chunk-NYLOYM6N.js.map +0 -1
  115. package/dist/chunk-PBE2LOSS.js.map +0 -1
  116. package/dist/chunk-TT4KNT67.js +0 -124
  117. package/dist/chunk-TT4KNT67.js.map +0 -1
  118. package/dist/chunk-UB2LOJ6Q.js.map +0 -1
  119. package/dist/chunk-UWZZKKU7.js +0 -237
  120. package/dist/chunk-UWZZKKU7.js.map +0 -1
  121. package/dist/chunk-VBQ3CRKH.js.map +0 -1
  122. package/dist/chunk-VGRCHJON.js.map +0 -1
  123. package/dist/chunk-VLOATJQ2.js.map +0 -1
  124. package/dist/chunk-VZSRQ272.js.map +0 -1
  125. package/dist/chunk-WS3NZZQQ.js.map +0 -1
  126. package/dist/chunk-XDWDC2MP.js.map +0 -1
  127. package/dist/chunk-XPRT64IE.js.map +0 -1
  128. package/dist/run-campaign-ISHFZ7FJ.js +0 -17
  129. /package/dist/{chunk-DPUHNQLN.js.map → chunk-7FO3TNPI.js.map} +0 -0
  130. /package/dist/{chunk-ZUUWPZCV.js.map → chunk-DODXQREJ.js.map} +0 -0
  131. /package/dist/{chunk-2MKQIFS4.js.map → chunk-E7QXT7SX.js.map} +0 -0
  132. /package/dist/{chunk-P5W7RQKK.js.map → chunk-FXTVJPYD.js.map} +0 -0
  133. /package/dist/{chunk-YJBNWCAA.js.map → chunk-NY44NC4A.js.map} +0 -0
  134. /package/dist/{chunk-S5YLIBFX.js.map → chunk-TQ7LNKZ3.js.map} +0 -0
  135. /package/dist/{chunk-BYT7ELPS.js.map → chunk-WVATSFCP.js.map} +0 -0
  136. /package/dist/{chunk-TBL77AUT.js.map → chunk-YQN4ICPP.js.map} +0 -0
  137. /package/dist/{run-campaign-ISHFZ7FJ.js.map → run-campaign-OJJ7CZF4.js.map} +0 -0
@@ -14,12 +14,15 @@ import {
14
14
  } from "../chunk-T4SQEITX.js";
15
15
  import {
16
16
  offPolicyEstimateAll
17
- } from "../chunk-VGRCHJON.js";
17
+ } from "../chunk-T6RLYGAD.js";
18
18
  import {
19
19
  confidenceInterval
20
- } from "../chunk-MHELPNRP.js";
20
+ } from "../chunk-ZHTZ4EYI.js";
21
21
  import "../chunk-VI2UW6B6.js";
22
22
  import "../chunk-PXE2VKMX.js";
23
+ import {
24
+ trainingScore
25
+ } from "../chunk-OIUOT4QD.js";
23
26
  import {
24
27
  ValidationError
25
28
  } from "../chunk-ONWEPEDO.js";
@@ -73,9 +76,6 @@ function embeddedBeliefOpeTargetPolicy(id = "embedded-target-prob") {
73
76
  },
74
77
  vHatTargetOf(point) {
75
78
  return point.vHatTarget;
76
- },
77
- qHatOf(point) {
78
- return point.qHat;
79
79
  }
80
80
  };
81
81
  }
@@ -94,12 +94,10 @@ function beliefDecisionsToOffPolicyTrajectories(points, targetPolicy, options =
94
94
  let targetProb;
95
95
  let qHatChosen;
96
96
  let vHatTarget;
97
- let qHat;
98
97
  try {
99
98
  targetProb = targetPolicy.targetProbOf(point);
100
99
  qHatChosen = targetPolicy.qHatChosenOf?.(point);
101
100
  vHatTarget = targetPolicy.vHatTargetOf?.(point);
102
- qHat = targetPolicy.qHatOf?.(point);
103
101
  } catch (error) {
104
102
  diagnostics.push(
105
103
  `${point.id}: target policy ${targetPolicy.id} threw (${errorMessage(error)})`
@@ -122,18 +120,13 @@ function beliefDecisionsToOffPolicyTrajectories(points, targetPolicy, options =
122
120
  );
123
121
  continue;
124
122
  }
125
- if (!hasQHatChosen && !hasVHatTarget && qHat !== null && qHat !== void 0 && !isTargetProbability(qHat)) {
126
- diagnostics.push(`${point.id}: invalid qHat ${formatProbability(qHat)}; ignoring qHat`);
127
- qHat = null;
128
- }
129
123
  trajectories.push({
130
124
  runId: point.id,
131
125
  reward: rewardOf(point),
132
126
  behaviorProb: point.behaviorProb,
133
127
  targetProb,
134
128
  ...qHatChosen !== void 0 ? { qHatChosen } : {},
135
- ...vHatTarget !== void 0 ? { vHatTarget } : {},
136
- qHat
129
+ ...vHatTarget !== void 0 ? { vHatTarget } : {}
137
130
  });
138
131
  }
139
132
  return {
@@ -151,8 +144,7 @@ function evaluateBeliefOffPolicy(points, targetPolicy, options = {}) {
151
144
  minEffectiveSampleSize: options.minEffectiveSampleSize ?? 30,
152
145
  minEffectiveSampleRatio: options.minEffectiveSampleRatio ?? 0.25,
153
146
  dropped: trajectoryReport.dropped,
154
- diagnostics: trajectoryReport.diagnostics,
155
- legacyScalarContributions: estimates.dr.contributionCounts?.legacyScalar ?? 0
147
+ diagnostics: trajectoryReport.diagnostics
156
148
  });
157
149
  return { targetPolicyId: targetPolicy.id, ...estimates, support };
158
150
  }
@@ -165,11 +157,6 @@ function supportDiagnostics(estimate, options) {
165
157
  if (options.dropped > 0) {
166
158
  reasons.push(`dropped ${options.dropped} unsupported decision(s)`);
167
159
  }
168
- if (options.legacyScalarContributions > 0) {
169
- reasons.push(
170
- `${options.legacyScalarContributions} decision(s) used deprecated scalar qHat; supply qHatChosen and vHatTarget for contextual doubly robust estimation`
171
- );
172
- }
173
160
  if (estimate.effectiveSampleSize < options.minEffectiveSampleSize) {
174
161
  reasons.push(
175
162
  `effective sample size ${estimate.effectiveSampleSize.toFixed(2)} below ${options.minEffectiveSampleSize}`
@@ -248,7 +235,6 @@ function thresholdSelectivePolicy(options) {
248
235
  targetProb: point.targetProb,
249
236
  qHatChosen: point.qHatChosen,
250
237
  vHatTarget: point.vHatTarget,
251
- qHat: point.qHat,
252
238
  reason: confidence >= threshold ? "confidence threshold passed" : "confidence threshold failed"
253
239
  };
254
240
  }
@@ -708,9 +694,7 @@ function outcomeScore2(outcome) {
708
694
  return null;
709
695
  }
710
696
  function scoreFromRun(run) {
711
- if (typeof run.outcome.holdoutScore === "number") return run.outcome.holdoutScore;
712
- if (typeof run.outcome.searchScore === "number") return run.outcome.searchScore;
713
- return null;
697
+ return trainingScore(run) ?? null;
714
698
  }
715
699
  function sortBuckets(a, b) {
716
700
  return b.n - a.n || a.id.localeCompare(b.id);
@@ -1075,7 +1059,6 @@ function parseDecisionEvent(event, context) {
1075
1059
  targetProb: numberField(payload, "targetProb"),
1076
1060
  qHatChosen: finiteUnitField(payload, "qHatChosen"),
1077
1061
  vHatTarget: finiteUnitField(payload, "vHatTarget"),
1078
- qHat: finiteUnitField(payload, "qHat"),
1079
1062
  costUsd: nonNegativeNumberField(payload, "costUsd"),
1080
1063
  evidence,
1081
1064
  outcome: parseOutcome(payload),
@@ -1191,7 +1174,6 @@ function runtimeDecisionPointToBeliefDecisionPoint(point, options) {
1191
1174
  targetProb: finiteNumberOrUndefined(options.targetProb),
1192
1175
  qHatChosen: options.qHatChosen === null ? null : unitProbabilityOrUndefined(options.qHatChosen),
1193
1176
  vHatTarget: options.vHatTarget === null ? null : unitProbabilityOrUndefined(options.vHatTarget),
1194
- qHat: options.qHat === null ? null : unitProbabilityOrUndefined(options.qHat),
1195
1177
  costUsd: nonNegativeNumberOrUndefined(options.costUsd),
1196
1178
  evidence: evidence.map((ref) => runtimeEvidenceToBeliefEvidence(ref, point)),
1197
1179
  outcome: options.outcome,
@@ -1422,7 +1404,6 @@ function buildRuntimeBeliefPhase0Measurement(options) {
1422
1404
  targetProb: label.targetProb,
1423
1405
  qHatChosen: label.qHatChosen,
1424
1406
  vHatTarget: label.vHatTarget,
1425
- qHat: label.qHat,
1426
1407
  costUsd: label.costUsd,
1427
1408
  outcome: label.outcome,
1428
1409
  lifecycleEvents: options.events,
@@ -1718,7 +1699,8 @@ ${input.context}` : "",
1718
1699
  evidenceRefs: ["evidence id"],
1719
1700
  wouldChangeMindIf: ["observable evidence"],
1720
1701
  targetProb: "optional number in [0,1]",
1721
- qHat: "optional number in [0,1]"
1702
+ qHatChosen: "optional number in [0,1], paired with vHatTarget",
1703
+ vHatTarget: "optional number in [0,1], paired with qHatChosen"
1722
1704
  })
1723
1705
  ].filter(Boolean).join("\n");
1724
1706
  }
@@ -1817,11 +1799,27 @@ function normalizeProbeResponse(response, options) {
1817
1799
  reason: `invalid targetProb ${String(response.targetProb)}`
1818
1800
  });
1819
1801
  }
1820
- if (response.qHat !== void 0 && response.qHat !== null && !isUnitProbability(response.qHat)) {
1802
+ const hasQHatChosen = response.qHatChosen !== void 0 && response.qHatChosen !== null;
1803
+ const hasVHatTarget = response.vHatTarget !== void 0 && response.vHatTarget !== null;
1804
+ if (hasQHatChosen !== hasVHatTarget) {
1805
+ diagnostics.push({
1806
+ decisionId: options.point.id,
1807
+ severity: "error",
1808
+ reason: "qHatChosen and vHatTarget must be supplied together"
1809
+ });
1810
+ }
1811
+ if (hasQHatChosen && !isUnitProbability(response.qHatChosen)) {
1812
+ diagnostics.push({
1813
+ decisionId: options.point.id,
1814
+ severity: "error",
1815
+ reason: `invalid qHatChosen ${String(response.qHatChosen)}`
1816
+ });
1817
+ }
1818
+ if (hasVHatTarget && !isUnitProbability(response.vHatTarget)) {
1821
1819
  diagnostics.push({
1822
1820
  decisionId: options.point.id,
1823
1821
  severity: "error",
1824
- reason: `invalid qHat ${String(response.qHat)}`
1822
+ reason: `invalid vHatTarget ${String(response.vHatTarget)}`
1825
1823
  });
1826
1824
  }
1827
1825
  if (diagnostics.length > 0 || !predictedAction) return { diagnostics };
@@ -1834,7 +1832,8 @@ function normalizeProbeResponse(response, options) {
1834
1832
  evidenceRefs: compactStrings(response.evidenceRefs),
1835
1833
  wouldChangeMindIf: compactStrings(response.wouldChangeMindIf),
1836
1834
  ...response.targetProb !== void 0 ? { targetProb: response.targetProb } : {},
1837
- ...response.qHat !== void 0 ? { qHat: response.qHat } : {},
1835
+ ...response.qHatChosen !== void 0 ? { qHatChosen: response.qHatChosen } : {},
1836
+ ...response.vHatTarget !== void 0 ? { vHatTarget: response.vHatTarget } : {},
1838
1837
  ...response.metadata ? { metadata: response.metadata } : {}
1839
1838
  },
1840
1839
  diagnostics