niceeval 0.19.0 → 0.19.1-canary.102

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 (133) hide show
  1. package/INDEX.md +1 -1
  2. package/dist/assertions/record/codec.cjs +19 -13
  3. package/dist/assertions/record/codec.cjs.map +1 -1
  4. package/dist/assertions/record/codec.d.cts +2 -0
  5. package/dist/assertions/record/codec.d.mts +2 -0
  6. package/dist/assertions/record/codec.d.ts +2 -0
  7. package/dist/assertions/record/codec.js +16 -14
  8. package/dist/inspection/assertion-projection.cjs +4 -1
  9. package/dist/inspection/assertion-projection.cjs.map +1 -1
  10. package/dist/inspection/cli/contribution.cjs +18 -14
  11. package/dist/inspection/cli/contribution.cjs.map +1 -1
  12. package/dist/inspection/cli/contribution.d.cts +7 -0
  13. package/dist/inspection/cli/contribution.d.mts +7 -0
  14. package/dist/inspection/cli/contribution.d.ts +7 -0
  15. package/dist/inspection/overview.cjs +28 -14
  16. package/dist/inspection/overview.cjs.map +1 -1
  17. package/dist/inspection/overview.d.cts +151 -18
  18. package/dist/inspection/overview.d.mts +151 -18
  19. package/dist/inspection/overview.d.ts +151 -18
  20. package/dist/inspection/overview.js +4 -2
  21. package/dist/inspection/project-result.d.cts +148 -148
  22. package/dist/inspection/project-result.d.mts +148 -148
  23. package/dist/inspection/project-result.d.ts +148 -148
  24. package/dist/inspection/protocol-values.cjs +1 -1
  25. package/dist/inspection/protocol-values.cjs.map +1 -1
  26. package/dist/inspection/protocol-values.d.cts +1 -1
  27. package/dist/inspection/protocol-values.d.mts +1 -1
  28. package/dist/inspection/protocol-values.d.ts +1 -1
  29. package/dist/inspection/protocol.d.cts +611 -479
  30. package/dist/inspection/protocol.d.mts +611 -479
  31. package/dist/inspection/protocol.d.ts +611 -479
  32. package/dist/inspection/public.cjs +3 -1
  33. package/dist/inspection/public.cjs.map +1 -1
  34. package/dist/inspection/public.d.cts +1 -0
  35. package/dist/inspection/public.d.mts +1 -0
  36. package/dist/inspection/public.d.ts +1 -0
  37. package/dist/inspection/public.js +18 -16
  38. package/dist/inspection/public.mjs +54 -52
  39. package/dist/inspection/results.cjs +11 -15
  40. package/dist/inspection/results.cjs.map +1 -1
  41. package/dist/inspection/results.d.cts +769 -324
  42. package/dist/inspection/results.d.mts +769 -324
  43. package/dist/inspection/results.d.ts +769 -324
  44. package/dist/inspection/results.js +4 -0
  45. package/dist/inspection/select.cjs +12 -72
  46. package/dist/inspection/select.cjs.map +1 -1
  47. package/dist/inspection/verdict.cjs +61 -0
  48. package/dist/inspection/verdict.cjs.map +1 -0
  49. package/dist/inspection/verdict.d.cts +3 -0
  50. package/dist/inspection/verdict.d.mts +3 -0
  51. package/dist/inspection/verdict.d.ts +3 -0
  52. package/dist/inspection/verdict.js +6 -0
  53. package/dist/inspection/verdict.js.map +1 -0
  54. package/dist/runner/discover.cjs +5 -4
  55. package/dist/runner/discover.cjs.map +1 -1
  56. package/dist/sandbox/index.cjs +4 -2
  57. package/dist/sandbox/index.cjs.map +1 -1
  58. package/dist/sandbox/index.d.cts +2 -0
  59. package/dist/sandbox/index.d.mts +2 -0
  60. package/dist/sandbox/index.d.ts +2 -0
  61. package/dist/sandbox/index.js +34 -32
  62. package/dist/sandbox/index.mjs +34 -32
  63. package/dist/sandbox/opensandbox/managed-process.cjs +224 -0
  64. package/dist/sandbox/opensandbox/managed-process.cjs.map +1 -0
  65. package/dist/sandbox/opensandbox/managed-process.d.cts +9 -0
  66. package/dist/sandbox/opensandbox/managed-process.d.mts +9 -0
  67. package/dist/sandbox/opensandbox/managed-process.d.ts +9 -0
  68. package/dist/sandbox/opensandbox/managed-process.js +6 -0
  69. package/dist/sandbox/opensandbox/managed-process.js.map +1 -0
  70. package/dist/sandbox/opensandbox/materialize.cjs +25 -0
  71. package/dist/sandbox/opensandbox/materialize.cjs.map +1 -0
  72. package/dist/sandbox/opensandbox/materialize.d.cts +4 -0
  73. package/dist/sandbox/opensandbox/materialize.d.mts +4 -0
  74. package/dist/sandbox/opensandbox/materialize.d.ts +4 -0
  75. package/dist/sandbox/opensandbox/materialize.js +6 -0
  76. package/dist/sandbox/opensandbox/materialize.js.map +1 -0
  77. package/dist/sandbox/opensandbox/process-bridge.cjs +89 -0
  78. package/dist/sandbox/opensandbox/process-bridge.cjs.map +1 -0
  79. package/dist/sandbox/opensandbox/process-bridge.d.cts +2 -0
  80. package/dist/sandbox/opensandbox/process-bridge.d.mts +2 -0
  81. package/dist/sandbox/opensandbox/process-bridge.d.ts +2 -0
  82. package/dist/sandbox/opensandbox/process-bridge.js +6 -0
  83. package/dist/sandbox/opensandbox/process-bridge.js.map +1 -0
  84. package/dist/sandbox/opensandbox/sandbox.cjs +253 -0
  85. package/dist/sandbox/opensandbox/sandbox.cjs.map +1 -0
  86. package/dist/sandbox/opensandbox/sandbox.d.cts +51 -0
  87. package/dist/sandbox/opensandbox/sandbox.d.mts +51 -0
  88. package/dist/sandbox/opensandbox/sandbox.d.ts +51 -0
  89. package/dist/sandbox/opensandbox/sandbox.js +6 -0
  90. package/dist/sandbox/opensandbox/sandbox.js.map +1 -0
  91. package/dist/sandbox/opensandbox.cjs +88 -0
  92. package/dist/sandbox/opensandbox.cjs.map +1 -0
  93. package/dist/sandbox/opensandbox.d.cts +17 -0
  94. package/dist/sandbox/opensandbox.d.mts +17 -0
  95. package/dist/sandbox/opensandbox.d.ts +17 -0
  96. package/dist/sandbox/opensandbox.js +6 -0
  97. package/dist/sandbox/opensandbox.js.map +1 -0
  98. package/dist/sandbox/runtime.cjs +1 -0
  99. package/dist/sandbox/runtime.cjs.map +1 -1
  100. package/dist/sandbox/runtime.d.cts +2 -0
  101. package/dist/sandbox/runtime.d.mts +2 -0
  102. package/dist/sandbox/runtime.d.ts +2 -0
  103. package/dist/sandbox/runtime.js +2 -0
  104. package/dist/sandbox/types.cjs.map +1 -1
  105. package/dist/sandbox/types.d.cts +1 -1
  106. package/dist/sandbox/types.d.mts +1 -1
  107. package/dist/sandbox/types.d.ts +1 -1
  108. package/dist/show/model.cjs +6 -5
  109. package/dist/show/model.cjs.map +1 -1
  110. package/dist/show/model.d.cts +1 -1
  111. package/dist/show/model.d.mts +1 -1
  112. package/dist/show/model.d.ts +1 -1
  113. package/dist/show/render.cjs +2 -2
  114. package/dist/show/render.cjs.map +1 -1
  115. package/dist/view/app-dist/.vite/manifest.json +2 -2
  116. package/dist/view/app-dist/assets/{index-CxrOUvHC.js → index-f9ZKc4km.js} +16 -16
  117. package/dist/view/app-dist/assets/{quality-cost-scatter-B6Aiss7x.js → quality-cost-scatter-C6lsrigr.js} +1 -1
  118. package/dist/view/app-dist/index.html +1 -1
  119. package/dist/view/function-runtime.mjs +126 -118
  120. package/dist/view/http-protocol.d.cts +1 -1
  121. package/dist/view/http-protocol.d.mts +1 -1
  122. package/dist/view/http-protocol.d.ts +1 -1
  123. package/dist/view/inspection-host.d.cts +625 -493
  124. package/dist/view/inspection-host.d.mts +625 -493
  125. package/dist/view/inspection-host.d.ts +625 -493
  126. package/docs-site/zh/explanation/evals.mdx +4 -0
  127. package/docs-site/zh/reference/cli.mdx +45 -4
  128. package/docs-site/zh/tutorials/compare-runs.mdx +1 -1
  129. package/docs-site/zh/tutorials/niceeval-taste.mdx +34 -1
  130. package/docs-site/zh/tutorials/sandbox-providers.mdx +35 -4
  131. package/docs-site/zh/tutorials/upgrade-0-19.mdx +1 -1
  132. package/docs-site/zh/tutorials/viewing-results.mdx +36 -3
  133. package/package.json +6 -1
@@ -650,40 +650,45 @@ var AssertionCollectionReceiptSchema = Schema.Struct({
650
650
  identifier: "AssertionCollectionReceipt",
651
651
  description: "a collection receipt whose counts and completion boundary agree"
652
652
  }));
653
- var AssertionFactValueSchema = Schema.suspend(() => Schema.Union([
654
- Schema.Struct({
655
- kind: Schema.Literal("unavailable"),
656
- reason: Schema.Literals([
657
- "not-recorded",
658
- "not-declared",
659
- "source-unavailable"
660
- ])
661
- }),
662
- Schema.Struct({
663
- kind: Schema.Literal("value"),
664
- value: Schema.Union([
665
- Schema.Null,
666
- Schema.Boolean,
667
- Schema.Finite,
668
- BoundedJsonStringSchema
669
- ])
670
- }),
671
- Schema.Struct({
672
- kind: Schema.Literal("text"),
673
- text: BoundedJsonStringSchema
674
- }),
675
- Schema.Struct({
676
- kind: Schema.Literal("list"),
677
- items: Schema.Array(AssertionFactValueSchema)
678
- }),
679
- Schema.Struct({
680
- kind: Schema.Literal("fields"),
681
- fields: Schema.Array(Schema.Struct({
682
- label: BoundedJsonStringSchema,
683
- value: AssertionFactValueSchema
684
- }))
685
- })
686
- ]));
653
+ /** Share the fact shape while letting each evidence owner apply its string budget. */
654
+ function createAssertionFactValueSchema(text) {
655
+ const fact = Schema.suspend(() => Schema.Union([
656
+ Schema.Struct({
657
+ kind: Schema.Literal("unavailable"),
658
+ reason: Schema.Literals([
659
+ "not-recorded",
660
+ "not-declared",
661
+ "source-unavailable"
662
+ ])
663
+ }),
664
+ Schema.Struct({
665
+ kind: Schema.Literal("value"),
666
+ value: Schema.Union([
667
+ Schema.Null,
668
+ Schema.Boolean,
669
+ Schema.Finite,
670
+ text
671
+ ])
672
+ }),
673
+ Schema.Struct({
674
+ kind: Schema.Literal("text"),
675
+ text
676
+ }),
677
+ Schema.Struct({
678
+ kind: Schema.Literal("list"),
679
+ items: Schema.Array(fact)
680
+ }),
681
+ Schema.Struct({
682
+ kind: Schema.Literal("fields"),
683
+ fields: Schema.Array(Schema.Struct({
684
+ label: text,
685
+ value: fact
686
+ }))
687
+ })
688
+ ]));
689
+ return fact;
690
+ }
691
+ var AssertionFactValueSchema = createAssertionFactValueSchema(BoundedJsonStringSchema);
687
692
  var MatcherRelationStatusSchema = Schema.Union([Schema.Struct({ state: Schema.Literal("exact") }), Schema.Struct({
688
693
  state: Schema.Literal("unavailable"),
689
694
  reason: Schema.Literals([
@@ -4023,7 +4028,7 @@ function validateObservabilityCollection(collection) {
4023
4028
  }
4024
4029
  //#endregion
4025
4030
  //#region src/inspection/protocol-values.ts
4026
- var QUERY_PROTOCOL = "niceeval.query/v2";
4031
+ var QUERY_PROTOCOL = "niceeval.query/v3";
4027
4032
  /** Selector semantics revision; independent from the wire protocol major. */
4028
4033
  var INSPECTION_BEHAVIOR_VERSION = "2.0.0";
4029
4034
  //#endregion
@@ -4400,6 +4405,7 @@ var ProjectedLocatorSchema = Schema.Union([Schema.Struct({
4400
4405
  kind: Schema.Literal("event"),
4401
4406
  eventId: Schema.String
4402
4407
  })]);
4408
+ var SourceRowFactValueSchema = createAssertionFactValueSchema(Schema.String);
4403
4409
  var MatcherRowSchema = Schema.Struct({
4404
4410
  kind: Schema.Literals([
4405
4411
  "tool",
@@ -4414,7 +4420,7 @@ var MatcherRowSchema = Schema.Struct({
4414
4420
  "historical"
4415
4421
  ]),
4416
4422
  summary: Schema.String,
4417
- detail: AssertionFactValueSchema,
4423
+ detail: SourceRowFactValueSchema,
4418
4424
  locator: Schema.optional(ProjectedLocatorSchema),
4419
4425
  evaluation: Schema.Struct({
4420
4426
  result: Schema.Literals([
@@ -7218,8 +7224,7 @@ var AggregateFields = {
7218
7224
  coverage: Schema.Array(OverviewCoverageSchema),
7219
7225
  issues: Schema.Array(OverviewIssueSchema)
7220
7226
  };
7221
- var OverviewPublishedMemberSchema = Schema.Struct({
7222
- ...InspectionPublishedPublicationSchema.fields,
7227
+ var PlannedAttemptMetricsSchema = Schema.Struct({
7223
7228
  verdict: Schema.NullOr(Schema.Literals([
7224
7229
  "passed",
7225
7230
  "failed",
@@ -7231,6 +7236,13 @@ var OverviewPublishedMemberSchema = Schema.Struct({
7231
7236
  durationMs: MetricSchema,
7232
7237
  tokens: MetricSchema
7233
7238
  });
7239
+ var PlannedAttemptMemberSchema = Schema.Struct({
7240
+ plannedAttemptId: PlannedAttemptSchema.fields.plannedAttemptId,
7241
+ evalId: PlannedAttemptSchema.fields.evalId,
7242
+ attemptOrdinal: PlannedAttemptSchema.fields.attemptOrdinal,
7243
+ publication: PlannedAttemptPublicationSchema,
7244
+ ...PlannedAttemptMetricsSchema.fields
7245
+ });
7234
7246
  var InspectionExecutionValueSchema = Schema.Union([
7235
7247
  Schema.Struct({
7236
7248
  state: Schema.Literal("available"),
@@ -7241,16 +7253,9 @@ var InspectionExecutionValueSchema = Schema.Union([
7241
7253
  ]);
7242
7254
  var InspectionLabelsSchema = Schema.Record(Schema.String, InspectionExecutionValueSchema);
7243
7255
  var OverviewMemberSchema = Schema.Struct({
7256
+ ...PlannedAttemptMemberSchema.fields,
7244
7257
  runId: Schema.String,
7245
- plannedAttemptId: Schema.String,
7246
- evalId: Schema.String,
7247
- attemptOrdinal: Schema.Number,
7248
- labels: InspectionLabelsSchema,
7249
- publication: Schema.Union([
7250
- RunPendingPublicationSchema,
7251
- OverviewPublishedMemberSchema,
7252
- RunAbsentPublicationSchema
7253
- ])
7258
+ labels: InspectionLabelsSchema
7254
7259
  });
7255
7260
  var OverviewGroupSchema = Schema.Struct({
7256
7261
  groupPath: Schema.Array(Schema.String),
@@ -8398,7 +8403,7 @@ var RunOverviewMemberLimitationSchema = Schema.Union([
8398
8403
  ]);
8399
8404
  var RunOverviewMemberSchema = Schema.Struct({
8400
8405
  ...PlannedAttemptSchema.fields,
8401
- publication: PlannedAttemptPublicationSchema,
8406
+ ...PlannedAttemptMemberSchema.fields,
8402
8407
  state: Schema.Literals([
8403
8408
  "executed",
8404
8409
  "carried",
@@ -8407,7 +8412,6 @@ var RunOverviewMemberSchema = Schema.Struct({
8407
8412
  "interrupted",
8408
8413
  "pending"
8409
8414
  ]),
8410
- locator: Schema.NullOr(Schema.String),
8411
8415
  relation: Schema.NullOr(Schema.Literals(["origin", "reference"])),
8412
8416
  outcome: Schema.NullOr(Schema.Literals([
8413
8417
  "completed",
@@ -8415,8 +8419,6 @@ var RunOverviewMemberSchema = Schema.Struct({
8415
8419
  "cancelled",
8416
8420
  "interrupted"
8417
8421
  ])),
8418
- verdict: VerdictSchema,
8419
- score: Schema.NullOr(InspectionScoredValueSchema),
8420
8422
  coverage: RunOverviewCoverageSchema,
8421
8423
  usage: RunOverviewUsageSchema,
8422
8424
  limitations: Schema.Array(RunOverviewMemberLimitationSchema)
@@ -14676,6 +14678,45 @@ function foldRecordedAttemptVerdict(input) {
14676
14678
  return foldVerdict(recordedAttemptFacts(input));
14677
14679
  }
14678
14680
  //#endregion
14681
+ //#region src/inspection/verdict.ts
14682
+ function attemptVerdict(resolved, assertions = readInspectionAssertions(resolved)) {
14683
+ if (assertions.state === "available") return foldRecordedAttemptVerdict({
14684
+ outcome: resolved.attempt.outcome,
14685
+ assertions: assertions.value
14686
+ });
14687
+ if (assertions.state !== "failed" || assertions.attachment === void 0) return null;
14688
+ if (resolved.attempt.outcome === "errored" || resolved.attempt.outcome === "interrupted") return "errored";
14689
+ if (containsRequiredAssertionError(assertions.attachment.value)) return "errored";
14690
+ return containsFailedDecision(assertions.attachment.value) ? "failed" : null;
14691
+ }
14692
+ function containsFailedDecision(value) {
14693
+ return assertionWireEntries(value)?.some((entry) => {
14694
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return false;
14695
+ const decision = entry.decision;
14696
+ if (typeof decision !== "object" || decision === null || Array.isArray(decision)) return false;
14697
+ const record = decision;
14698
+ return record.result === "mismatched" && record.gate === "failed";
14699
+ }) ?? false;
14700
+ }
14701
+ function containsRequiredAssertionError(value) {
14702
+ return assertionWireEntries(value)?.some((entry) => {
14703
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return false;
14704
+ const record = entry;
14705
+ const decision = record.decision;
14706
+ const policy = record.policy;
14707
+ const requirement = typeof policy === "object" && policy !== null && !Array.isArray(policy) ? policy.requirement : void 0;
14708
+ if (typeof decision !== "object" || decision === null || Array.isArray(decision) || typeof requirement !== "object" || requirement === null || Array.isArray(requirement)) return false;
14709
+ const decisionRecord = decision;
14710
+ const requirementRecord = requirement;
14711
+ return (decisionRecord.result === "unavailable" || decisionRecord.result === "errored") && decisionRecord.gate === "unavailable" && requirementRecord.state === "available" && requirementRecord.value === "required";
14712
+ }) ?? false;
14713
+ }
14714
+ function assertionWireEntries(value) {
14715
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
14716
+ const entries = value["entries-data"];
14717
+ return Array.isArray(entries) ? entries : void 0;
14718
+ }
14719
+ //#endregion
14679
14720
  //#region src/inspection/limits.ts
14680
14721
  /** Maximum UTF-8 JSON bytes for any one fixed operation result field. */
14681
14722
  var INSPECTION_RESULT_BYTE_LIMIT = 524288;
@@ -16689,7 +16730,7 @@ function aggregateInspectionCurrentSlots(inputs) {
16689
16730
  coverage: Object.freeze([]),
16690
16731
  issues: Object.freeze([]),
16691
16732
  ref: null
16692
- }) : analyzeAttempt(recorded.resolved, recorded.target, recorded.member, recorded.slot)
16733
+ }) : analyzeAttempt(recorded.resolved, recorded.target.run.runId, recorded.member, recorded.slot)
16693
16734
  });
16694
16735
  }));
16695
16736
  }
@@ -16721,14 +16762,14 @@ function selectLatestSlots(runs, resolutionRuns = runs) {
16721
16762
  slot,
16722
16763
  member,
16723
16764
  resolved,
16724
- analysis: analyzeAttempt(resolved, target, member, slot)
16765
+ analysis: analyzeAttempt(resolved, target.run.runId, member, slot)
16725
16766
  });
16726
16767
  }));
16727
16768
  }
16728
16769
  function compareOccurrence(left, right) {
16729
16770
  return left.run.completedAt - right.run.completedAt || left.run.startedAt - right.run.startedAt || compareText(left.run.runId, right.run.runId);
16730
16771
  }
16731
- function analyzeAttempt(resolved, target, member, slot) {
16772
+ function analyzeAttempt(resolved, runId, member, slot) {
16732
16773
  if (resolved === void 0) {
16733
16774
  const hasReference = member?.attempt !== void 0 && member.attempt !== null;
16734
16775
  return Object.freeze({
@@ -16740,7 +16781,7 @@ function analyzeAttempt(resolved, target, member, slot) {
16740
16781
  durationMs: unavailableOperationalMetric(),
16741
16782
  tokens: unavailableOperationalMetric(),
16742
16783
  coverage: Object.freeze([]),
16743
- issues: Object.freeze([overviewIssue(hasReference ? "attempt-origin-missing" : "attempt-not-observed", target.run.runId, slot)]),
16784
+ issues: Object.freeze([overviewIssue(hasReference ? "attempt-origin-missing" : "attempt-not-observed", runId, slot)]),
16744
16785
  ref: null
16745
16786
  });
16746
16787
  }
@@ -16750,7 +16791,7 @@ function analyzeAttempt(resolved, target, member, slot) {
16750
16791
  if (assertions.state !== "available") return Object.freeze({
16751
16792
  assertionsState: assertions.state,
16752
16793
  evaluationKind: null,
16753
- verdict: null,
16794
+ verdict: attemptVerdict(resolved, assertions),
16754
16795
  score: emptyAttemptScore(),
16755
16796
  costUSD: costUSDOf(resolved),
16756
16797
  ...operational,
@@ -16798,10 +16839,7 @@ function analyzeAttempt(resolved, target, member, slot) {
16798
16839
  return Object.freeze({
16799
16840
  assertionsState: "available",
16800
16841
  evaluationKind: hasPoints ? "points" : "pass",
16801
- verdict: foldRecordedAttemptVerdict({
16802
- outcome: resolved.attempt.outcome,
16803
- assertions: assertions.value
16804
- }),
16842
+ verdict: attemptVerdict(resolved, assertions),
16805
16843
  score: Object.freeze({
16806
16844
  hasPoints,
16807
16845
  earned,
@@ -16826,14 +16864,14 @@ function makeCell(slots, labelKeys) {
16826
16864
  ...aggregate(slots, scoreForCell(slots)),
16827
16865
  members: Object.freeze(slots.flatMap((selected) => {
16828
16866
  if (selected.target === void 0 || selected.slot === void 0) return [];
16829
- selected.resolved;
16830
16867
  return [Object.freeze({
16831
16868
  runId: selected.target.run.runId,
16832
16869
  plannedAttemptId: selected.slot.slotId,
16833
16870
  evalId: selected.slot.evalId,
16834
16871
  attemptOrdinal: selected.slot.attemptOrdinal,
16835
16872
  labels: inspectionLabels([selected], labelKeys),
16836
- publication: overviewPublication(selected)
16873
+ publication: overviewPublication(selected),
16874
+ ...memberMetrics(selected)
16837
16875
  })];
16838
16876
  }))
16839
16877
  });
@@ -16958,13 +16996,22 @@ function overviewPublication(selected) {
16958
16996
  attemptId: member.attempt.attemptId,
16959
16997
  attemptLocator: resolved.locator,
16960
16998
  originRunId: member.attempt.originRunId,
16961
- originPlannedAttemptId: resolved.attempt.slotId,
16999
+ originPlannedAttemptId: resolved.attempt.slotId
17000
+ });
17001
+ }
17002
+ /** Shared metrics for one planned position, including missing and unresolved publications. */
17003
+ function projectPlannedAttemptMetrics(runId, slot, member, resolved) {
17004
+ return memberMetrics({ analysis: analyzeAttempt(resolved, runId, member, slot) });
17005
+ }
17006
+ var decodeMemberMetrics = Schema.decodeUnknownSync(PlannedAttemptMetricsSchema);
17007
+ function memberMetrics(selected) {
17008
+ return Object.freeze(decodeMemberMetrics({
16962
17009
  verdict: selected.analysis.verdict,
16963
17010
  score: scoreForMember(selected),
16964
- costUSD: costForSlots([selected]),
17011
+ costUSD: costForAnalyses([selected]),
16965
17012
  durationMs: metricForSlots([selected], "durationMs", "ms", "average"),
16966
17013
  tokens: metricForSlots([selected], "tokens", "tokens", "sum")
16967
- });
17014
+ }));
16968
17015
  }
16969
17016
  function executionValue(values) {
16970
17017
  if (new Set(values).size !== 1) return Object.freeze({ state: "mixed" });
@@ -17036,7 +17083,9 @@ function costForSlots(slots) {
17036
17083
  const key = slot.resolved?.locator ?? (slot.target === void 0 ? `current:${slot.experimentId}:${slot.evalId}:${slot.attemptOrdinal}` : `slot:${slot.target.run.runId}:${slot.slot.slotId}`);
17037
17084
  if (!unique.has(key)) unique.set(key, slot);
17038
17085
  }
17039
- const subjects = [...unique.values()];
17086
+ return costForAnalyses([...unique.values()]);
17087
+ }
17088
+ function costForAnalyses(subjects) {
17040
17089
  const valued = subjects.filter(({ analysis }) => analysis.costUSD.value !== null);
17041
17090
  const sources = new Set(valued.flatMap(({ analysis }) => analysis.costUSD.source === null ? [] : [analysis.costUSD.source]));
17042
17091
  const hasReported = sources.has("reported") || sources.has("mixed");
@@ -20213,6 +20262,11 @@ function runDetail(_all, selectedResource) {
20213
20262
  reason: binding.reason
20214
20263
  }) : Object.freeze({ state: "pending" });
20215
20264
  const targetMember = bindings.get(slot.plannedAttemptId);
20265
+ const resolved = targetMember?.attempt == null ? void 0 : resolveInspectionResourceMemberAttempt(selectedResource, targetMember);
20266
+ const metrics = projectPlannedAttemptMetrics(value.runId, {
20267
+ ...slot,
20268
+ slotId: slot.plannedAttemptId
20269
+ }, targetMember, resolved);
20216
20270
  if (targetMember === void 0) {
20217
20271
  if (publication.state !== "pending" && publication.state !== "absent") throw new Error(`Terminal Run ${value.runId} has no binding or absence for Planned attempt ${slot.plannedAttemptId}`);
20218
20272
  const limitation = Object.freeze({
@@ -20222,12 +20276,10 @@ function runDetail(_all, selectedResource) {
20222
20276
  return Object.freeze({ member: Object.freeze({
20223
20277
  ...slot,
20224
20278
  publication,
20279
+ ...metrics,
20225
20280
  state: limitation.state,
20226
- locator: null,
20227
20281
  relation: null,
20228
20282
  outcome: null,
20229
- verdict: null,
20230
- score: null,
20231
20283
  coverage: unavailableCoverage(),
20232
20284
  usage: unavailableUsage(),
20233
20285
  limitations: Object.freeze([limitation])
@@ -20241,18 +20293,15 @@ function runDetail(_all, selectedResource) {
20241
20293
  return Object.freeze({ member: Object.freeze({
20242
20294
  ...slot,
20243
20295
  publication,
20296
+ ...metrics,
20244
20297
  state: targetMember.action,
20245
- locator: null,
20246
20298
  relation: null,
20247
20299
  outcome: null,
20248
- verdict: null,
20249
- score: null,
20250
20300
  coverage: unavailableCoverage(),
20251
20301
  usage: unavailableUsage(),
20252
20302
  limitations: Object.freeze([limitation])
20253
20303
  }) });
20254
20304
  }
20255
- const resolved = resolveInspectionResourceMemberAttempt(selectedResource, targetMember);
20256
20305
  if (resolved === void 0) {
20257
20306
  const limitation = Object.freeze({
20258
20307
  kind: "attempt-unresolved",
@@ -20262,12 +20311,10 @@ function runDetail(_all, selectedResource) {
20262
20311
  return Object.freeze({ member: Object.freeze({
20263
20312
  ...slot,
20264
20313
  publication,
20314
+ ...metrics,
20265
20315
  state: targetMember.action,
20266
- locator: null,
20267
20316
  relation: null,
20268
20317
  outcome: null,
20269
- verdict: null,
20270
- score: null,
20271
20318
  coverage: unavailableCoverage(),
20272
20319
  usage: unavailableUsage(),
20273
20320
  limitations: Object.freeze([limitation])
@@ -20290,12 +20337,10 @@ function runDetail(_all, selectedResource) {
20290
20337
  member: Object.freeze({
20291
20338
  ...slot,
20292
20339
  publication,
20340
+ ...metrics,
20293
20341
  state: targetMember.action,
20294
- locator: resolved.locator,
20295
20342
  relation: resolved.attempt.originRunId === value.runId ? "origin" : "reference",
20296
20343
  outcome: resolved.attempt.outcome,
20297
- verdict: attemptVerdict(resolved, assertions),
20298
- score: assertionScore(assertions.state === "available" ? assertions.value.entries : []),
20299
20344
  coverage: Object.freeze({
20300
20345
  state: coverageState,
20301
20346
  facts: coverageFacts,
@@ -20319,11 +20364,11 @@ function runDetail(_all, selectedResource) {
20319
20364
  const members = Object.freeze(projected.map(({ member }) => member));
20320
20365
  const locatedLimitations = Object.freeze(members.flatMap((member) => member.limitations.map((limitation) => Object.freeze({
20321
20366
  plannedAttemptId: member.plannedAttemptId,
20322
- locator: member.locator,
20367
+ locator: member.publication.state === "published" ? member.publication.attemptLocator : null,
20323
20368
  limitation
20324
20369
  }))));
20325
20370
  const usageResults = projected.flatMap(({ usage }) => usage === void 0 ? [] : [usage]);
20326
- const observed = members.filter(({ locator }) => locator !== null).length;
20371
+ const observed = members.filter(({ relation }) => relation !== null).length;
20327
20372
  const incompleteUsage = observed !== members.length || usageResults.some(({ state }) => state !== "complete");
20328
20373
  const coverageLimitations = Object.freeze(locatedLimitations.filter(({ limitation }) => limitation.kind !== "usage"));
20329
20374
  const usageLimitations = Object.freeze(locatedLimitations.filter(({ limitation }) => limitation.kind !== "coverage"));
@@ -20363,16 +20408,6 @@ function aggregateRunOverviewState(states) {
20363
20408
  if (states.every((state) => state === "invalid")) return "invalid";
20364
20409
  return "partial";
20365
20410
  }
20366
- function attemptVerdict(resolved, assertions = readInspectionAssertions(resolved)) {
20367
- if (assertions.state === "available") return foldRecordedAttemptVerdict({
20368
- outcome: resolved.attempt.outcome,
20369
- assertions: assertions.value
20370
- });
20371
- if (assertions.state !== "failed" || assertions.attachment === void 0) return null;
20372
- if (resolved.attempt.outcome === "errored" || resolved.attempt.outcome === "interrupted") return "errored";
20373
- if (containsRequiredAssertionError(assertions.attachment.value)) return "errored";
20374
- return containsFailedDecision(assertions.attachment.value) ? "failed" : null;
20375
- }
20376
20411
  function assertionScore(entries) {
20377
20412
  let possible = 0;
20378
20413
  let earned = 0;
@@ -20469,33 +20504,6 @@ function attemptLimitations(resolved, entries) {
20469
20504
  function isAttemptCoverageChannel(value) {
20470
20505
  return value === "events" || value === "actions" || value === "messages" || value === "usage" || value === "status" || value === "data";
20471
20506
  }
20472
- function containsFailedDecision(value) {
20473
- return assertionWireEntries(value)?.some((entry) => {
20474
- if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return false;
20475
- const decision = entry.decision;
20476
- if (typeof decision !== "object" || decision === null || Array.isArray(decision)) return false;
20477
- const record = decision;
20478
- return record.result === "mismatched" && record.gate === "failed";
20479
- }) ?? false;
20480
- }
20481
- function containsRequiredAssertionError(value) {
20482
- return assertionWireEntries(value)?.some((entry) => {
20483
- if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return false;
20484
- const record = entry;
20485
- const decision = record.decision;
20486
- const policy = record.policy;
20487
- const requirement = typeof policy === "object" && policy !== null && !Array.isArray(policy) ? policy.requirement : void 0;
20488
- if (typeof decision !== "object" || decision === null || Array.isArray(decision) || typeof requirement !== "object" || requirement === null || Array.isArray(requirement)) return false;
20489
- const decisionRecord = decision;
20490
- const requirementRecord = requirement;
20491
- return (decisionRecord.result === "unavailable" || decisionRecord.result === "errored") && decisionRecord.gate === "unavailable" && requirementRecord.state === "available" && requirementRecord.value === "required";
20492
- }) ?? false;
20493
- }
20494
- function assertionWireEntries(value) {
20495
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
20496
- const entries = value["entries-data"];
20497
- return Array.isArray(entries) ? entries : void 0;
20498
- }
20499
20507
  function comparisonDocument(source, all, operation) {
20500
20508
  const left = selectRuns(all, operation.leftRunIds);
20501
20509
  const right = selectRuns(all, operation.rightRunIds);
@@ -18,7 +18,7 @@ export type ViewGenerationCommitRequest = Schema.Schema.Type<typeof ViewGenerati
18
18
  export declare const ViewInspectionHttpRequestSchema: Schema.Struct<{
19
19
  readonly generationId: Schema.String;
20
20
  readonly request: Schema.Struct<{
21
- readonly protocol: Schema.Literal<"niceeval.query/v2">;
21
+ readonly protocol: Schema.Literal<"niceeval.query/v3">;
22
22
  readonly operation: Schema.Union<(Schema.Struct<{
23
23
  readonly kind: Schema.Literal<"project.get">;
24
24
  } & {
@@ -18,7 +18,7 @@ export type ViewGenerationCommitRequest = Schema.Schema.Type<typeof ViewGenerati
18
18
  export declare const ViewInspectionHttpRequestSchema: Schema.Struct<{
19
19
  readonly generationId: Schema.String;
20
20
  readonly request: Schema.Struct<{
21
- readonly protocol: Schema.Literal<"niceeval.query/v2">;
21
+ readonly protocol: Schema.Literal<"niceeval.query/v3">;
22
22
  readonly operation: Schema.Union<(Schema.Struct<{
23
23
  readonly kind: Schema.Literal<"project.get">;
24
24
  } & {
@@ -18,7 +18,7 @@ export type ViewGenerationCommitRequest = Schema.Schema.Type<typeof ViewGenerati
18
18
  export declare const ViewInspectionHttpRequestSchema: Schema.Struct<{
19
19
  readonly generationId: Schema.String;
20
20
  readonly request: Schema.Struct<{
21
- readonly protocol: Schema.Literal<"niceeval.query/v2">;
21
+ readonly protocol: Schema.Literal<"niceeval.query/v3">;
22
22
  readonly operation: Schema.Union<(Schema.Struct<{
23
23
  readonly kind: Schema.Literal<"project.get">;
24
24
  } & {