@tangle-network/agent-eval 0.215.1 → 0.216.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.
- package/CHANGELOG.md +12 -0
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-DmzL8KaJ.d.ts → agent-profile-CIA2Atnt.d.ts} +3 -3
- package/dist/{agent-profile-DmzL8KaJ.d.ts.map → agent-profile-CIA2Atnt.d.ts.map} +1 -1
- package/dist/agreement-irr-DsTURxdr.js +186 -0
- package/dist/agreement-irr-DsTURxdr.js.map +1 -0
- package/dist/analyst/index.d.ts +485 -12
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +1543 -8
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyze-runs-BhFLOztS.d.ts → analyze-runs-CSDAh8A7.d.ts} +2 -2
- package/dist/{analyze-runs-BhFLOztS.d.ts.map → analyze-runs-CSDAh8A7.d.ts.map} +1 -1
- package/dist/{benchmark-command-CgpGi7vY.js → benchmark-command-CByl9dxG.js} +16 -32
- package/dist/benchmark-command-CByl9dxG.js.map +1 -0
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +3 -3
- package/dist/campaign/index.d.ts +6 -6
- package/dist/campaign/index.js +5 -5
- package/dist/{campaign-CpnsCgfz.js → campaign-BQ-Jujuj.js} +6 -6
- package/dist/{campaign-CpnsCgfz.js.map → campaign-BQ-Jujuj.js.map} +1 -1
- package/dist/cli.js +2 -2
- package/dist/cluster-bootstrap-B3JywQQn.js +66 -0
- package/dist/cluster-bootstrap-B3JywQQn.js.map +1 -0
- package/dist/contract/index.d.ts +9 -9
- package/dist/contract/index.js +6 -6
- package/dist/{default-registry-B4B7GMvI.d.ts → default-registry-BrWh62zf.d.ts} +6 -6
- package/dist/{default-registry-B4B7GMvI.d.ts.map → default-registry-BrWh62zf.d.ts.map} +1 -1
- package/dist/{default-registry-KP4-Tolz.js → default-registry-Cn1LQ2Ve.js} +741 -756
- package/dist/default-registry-Cn1LQ2Ve.js.map +1 -0
- package/dist/{define-agent-eval-DfXvNho5.d.ts → define-agent-eval-CEWkX5wZ.d.ts} +7 -7
- package/dist/{define-agent-eval-DfXvNho5.d.ts.map → define-agent-eval-CEWkX5wZ.d.ts.map} +1 -1
- package/dist/{define-agent-eval-BdfnqXeP.js → define-agent-eval-Ch3MWX6k.js} +3 -3
- package/dist/{define-agent-eval-BdfnqXeP.js.map → define-agent-eval-Ch3MWX6k.js.map} +1 -1
- package/dist/diagnosis/index.d.ts +2 -2
- package/dist/{dspy-rlm-engine-DZfHM7kT.js → dspy-rlm-engine-D-KX_e64.js} +3 -3
- package/dist/{dspy-rlm-engine-DZfHM7kT.js.map → dspy-rlm-engine-D-KX_e64.js.map} +1 -1
- package/dist/{engine-C37HS2kr.d.ts → engine-C_zNWfM8.d.ts} +4 -4
- package/dist/{engine-C37HS2kr.d.ts.map → engine-C_zNWfM8.d.ts.map} +1 -1
- package/dist/evaluation-Cn2dRZIz.d.ts +75 -0
- package/dist/evaluation-Cn2dRZIz.d.ts.map +1 -0
- package/dist/evaluation.d.ts +2 -74
- package/dist/{exact-types-Dlb73wN4.d.ts → exact-types-CD0lf5Qd.d.ts} +2 -2
- package/dist/{exact-types-Dlb73wN4.d.ts.map → exact-types-CD0lf5Qd.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +1 -1
- package/dist/{external-optimizer-process-GngofQML.js → external-optimizer-process-nnsY5D_4.js} +2 -2
- package/dist/{external-optimizer-process-GngofQML.js.map → external-optimizer-process-nnsY5D_4.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-BUxifb8g.js → external-optimizer-subprocess-DcerlZSG.js} +261 -2
- package/dist/external-optimizer-subprocess-DcerlZSG.js.map +1 -0
- package/dist/{feedback-trajectory-BLN_6fEs.d.ts → feedback-trajectory-DkaDj0dj.d.ts} +3 -3
- package/dist/{feedback-trajectory-BLN_6fEs.d.ts.map → feedback-trajectory-DkaDj0dj.d.ts.map} +1 -1
- package/dist/{index-B7m2uzJL.d.ts → index-DlH0Y9gI.d.ts} +8 -8
- package/dist/{index-B7m2uzJL.d.ts.map → index-DlH0Y9gI.d.ts.map} +1 -1
- package/dist/{index-B3WBm953.d.ts → index-NvGBiO8H.d.ts} +6 -6
- package/dist/{index-B3WBm953.d.ts.map → index-NvGBiO8H.d.ts.map} +1 -1
- package/dist/{index-tYLUvk_w.d.ts → index-oQ4aHziK.d.ts} +7 -7
- package/dist/{index-tYLUvk_w.d.ts.map → index-oQ4aHziK.d.ts.map} +1 -1
- package/dist/index.d.ts +15 -15
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/{kind-factory-AaEhUADH.js → kind-factory-CbZ-6tvu.js} +2 -2
- package/dist/{kind-factory-AaEhUADH.js.map → kind-factory-CbZ-6tvu.js.map} +1 -1
- package/dist/{llm-judge-Cd5s5Ei6.js → llm-judge-PXV7Xljl.js} +3 -3
- package/dist/{llm-judge-Cd5s5Ei6.js.map → llm-judge-PXV7Xljl.js.map} +1 -1
- package/dist/{matrix-DXVAJMLD.d.ts → matrix-CHMiebFx.d.ts} +2 -2
- package/dist/{matrix-DXVAJMLD.d.ts.map → matrix-CHMiebFx.d.ts.map} +1 -1
- package/dist/meta-eval/index.js +1 -62
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +2 -2
- package/dist/openapi.json +1 -1
- package/dist/pipelines/index.js +1 -1
- package/dist/{prime-protocol-BHia9vDz.d.ts → prime-protocol-CEE4BR9N.d.ts} +2 -2
- package/dist/{prime-protocol-BHia9vDz.d.ts.map → prime-protocol-CEE4BR9N.d.ts.map} +1 -1
- package/dist/{produced-state-BGp4BX8t.js → produced-state-ZCtDBxAE.js} +2 -2
- package/dist/{produced-state-BGp4BX8t.js.map → produced-state-ZCtDBxAE.js.map} +1 -1
- package/dist/{proposal-findings-CXblsskH.js → proposal-findings-BZiMTzAF.js} +2 -36
- package/dist/proposal-findings-BZiMTzAF.js.map +1 -0
- package/dist/{registry-CMYIaDgS.d.ts → registry-JYfPxcVz.d.ts} +9 -11
- package/dist/registry-JYfPxcVz.d.ts.map +1 -0
- package/dist/{report-command-CtIIsQKP.js → report-command-y8H6RSX8.js} +23 -7
- package/dist/report-command-y8H6RSX8.js.map +1 -0
- package/dist/rl.d.ts +3 -3
- package/dist/rl.js +1 -1
- package/dist/search/index.d.ts +2 -2
- package/dist/{search-kernel-BqyBZ9Wm.d.ts → search-kernel-CpcKH5Ih.d.ts} +2 -2
- package/dist/{search-kernel-BqyBZ9Wm.d.ts.map → search-kernel-CpcKH5Ih.d.ts.map} +1 -1
- package/dist/{semantic-concept-judge-BPqbwIVs.js → semantic-concept-judge-zQBG9hHU.js} +3 -3
- package/dist/{semantic-concept-judge-BPqbwIVs.js.map → semantic-concept-judge-zQBG9hHU.js.map} +1 -1
- package/dist/{skillopt-optimization-method-Dcepr6QL.js → skillopt-optimization-method-CCtzralq.js} +4 -4
- package/dist/{skillopt-optimization-method-Dcepr6QL.js.map → skillopt-optimization-method-CCtzralq.js.map} +1 -1
- package/dist/{statistical-heldout-CJTj2EoS.d.ts → statistical-heldout-BeR4bOdg.d.ts} +2 -2
- package/dist/{statistical-heldout-CJTj2EoS.d.ts.map → statistical-heldout-BeR4bOdg.d.ts.map} +1 -1
- package/dist/{store-otlp-DWVhUgEj.js → store-otlp-DtB4Slsr.js} +2 -2
- package/dist/{store-otlp-DWVhUgEj.js.map → store-otlp-DtB4Slsr.js.map} +1 -1
- package/dist/{store-tool-spans-BNzls3OD.d.ts → store-tool-spans-DR1SrCLK.d.ts} +4 -4
- package/dist/{store-tool-spans-BNzls3OD.d.ts.map → store-tool-spans-DR1SrCLK.d.ts.map} +1 -1
- package/dist/{store-tool-spans-BNICrhsb.js → store-tool-spans-fZIigrpP.js} +3 -3
- package/dist/{store-tool-spans-BNICrhsb.js.map → store-tool-spans-fZIigrpP.js.map} +1 -1
- package/dist/supervisor-run/index.d.ts +1 -1
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +1 -1
- package/dist/systemone-CpTLAlqb.d.ts +135 -0
- package/dist/systemone-CpTLAlqb.d.ts.map +1 -0
- package/dist/{systemone-review-DTClwgmE.js → systemone-review-BZWfrtq1.js} +2 -2
- package/dist/{systemone-review-DTClwgmE.js.map → systemone-review-BZWfrtq1.js.map} +1 -1
- package/dist/{systemone-review-C4dZgrgN.d.ts → systemone-review-B_yo1xsd.d.ts} +2 -2
- package/dist/{systemone-review-C4dZgrgN.d.ts.map → systemone-review-B_yo1xsd.d.ts.map} +1 -1
- package/dist/systemone.d.ts +4 -134
- package/dist/systemone.js +1 -1
- package/dist/terminal-record-BHocwFw1.js.map +1 -1
- package/dist/{tool-groups-BKRrtqy4.d.ts → tool-groups-mcxOXVlb.d.ts} +3 -3
- package/dist/tool-groups-mcxOXVlb.d.ts.map +1 -0
- package/dist/{tool-waste-BYt5rdt8.js → tool-waste-D52PqU9Q.js} +3 -156
- package/dist/tool-waste-D52PqU9Q.js.map +1 -0
- package/dist/{trace-questions-CLx8vt6t.d.ts → trace-questions-DG7nqLQ7.d.ts} +3 -3
- package/dist/{trace-questions-CLx8vt6t.d.ts.map → trace-questions-DG7nqLQ7.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/traces.d.ts +3 -3
- package/dist/traces.js +3 -3
- package/dist/{types-CGEmVYOk.d.ts → types-B4C5nFw6.d.ts} +2 -2
- package/dist/{types-CGEmVYOk.d.ts.map → types-B4C5nFw6.d.ts.map} +1 -1
- package/dist/{types-DjOMwGY_.d.ts → types-BqkVmHfv.d.ts} +7 -1
- package/dist/types-BqkVmHfv.d.ts.map +1 -0
- package/dist/{types-DinHtRJp.d.ts → types-CfZMIzB_.d.ts} +2 -2
- package/dist/{types-DinHtRJp.d.ts.map → types-CfZMIzB_.d.ts.map} +1 -1
- package/dist/{types-CW5b90JH.js → types-IXD2HJzu.js} +16 -3
- package/dist/types-IXD2HJzu.js.map +1 -0
- package/dist/{types-DHb5TI36.d.ts → types-oKRhQAde.d.ts} +344 -3
- package/dist/types-oKRhQAde.d.ts.map +1 -0
- package/dist/wire/index.d.ts +1 -1
- package/docs/concepts.md +1 -0
- package/docs/finding-layers.md +69 -0
- package/package.json +1 -1
- package/dist/benchmark-command-CgpGi7vY.js.map +0 -1
- package/dist/default-registry-KP4-Tolz.js.map +0 -1
- package/dist/evaluation.d.ts.map +0 -1
- package/dist/external-optimizer-subprocess-BUxifb8g.js.map +0 -1
- package/dist/proposal-findings-CXblsskH.js.map +0 -1
- package/dist/registry-CMYIaDgS.d.ts.map +0 -1
- package/dist/report-command-CtIIsQKP.js.map +0 -1
- package/dist/systemone.d.ts.map +0 -1
- package/dist/tool-groups-BKRrtqy4.d.ts.map +0 -1
- package/dist/tool-waste-BYt5rdt8.js.map +0 -1
- package/dist/types-CW5b90JH.js.map +0 -1
- package/dist/types-DHb5TI36.d.ts.map +0 -1
- package/dist/types-DjOMwGY_.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ All notable changes to `@tangle-network/agent-eval` and its sibling `agent-eval-
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [0.216.0] — 2026-10-20
|
|
8
|
+
|
|
9
|
+
- factory: The pre-commit hook runs where no global hooks path is set (#1003)
|
|
10
|
+
- factory: Every finding says its layer and the population it holds for (#1000)
|
|
11
|
+
- test(python): retire obsolete facade-global sandbox mocks
|
|
12
|
+
- refactor: preserve complete DSPy runtime source identity
|
|
13
|
+
- refactor: separate analyst registry planning and execution
|
|
14
|
+
- refactor: separate DSPy bridge validation and execution
|
|
15
|
+
- refactor: separate search simulation responsibilities
|
|
16
|
+
- fix: enforce shared file size ratchet through Husky
|
|
17
|
+
- chore: ignore SQLite -shm/-wal beside test fixtures (#997)
|
|
18
|
+
|
|
7
19
|
## [0.215.1] — 2026-10-18
|
|
8
20
|
|
|
9
21
|
- fix(gepa): preserve completed candidates at evaluation budget (#979)
|
package/dist/adapters/http.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as CostReceipt } from "../cost-ledger-CO7UyEcQ.js";
|
|
2
|
-
import { R as Scenario, d as DispatchContext, f as DispatchFn } from "../types-
|
|
3
|
-
import "../index-
|
|
2
|
+
import { R as Scenario, d as DispatchContext, f as DispatchFn } from "../types-B4C5nFw6.js";
|
|
3
|
+
import "../index-DlH0Y9gI.js";
|
|
4
4
|
//#region src/adapters/http.d.ts
|
|
5
5
|
export interface HttpDispatchOptions<TScenario extends Scenario, _TArtifact> {
|
|
6
6
|
/** Static endpoint URL. Mutually exclusive with `resolveUrl`. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as CustomTokenPricing, g as CostReceiptInput } from "./cost-ledger-CO7UyEcQ.js";
|
|
2
|
-
import {
|
|
2
|
+
import { X as TraceAnalysisStore, a as AnalystFinding, h as EvidenceRef, m as AnalystUsageReceipt, u as AnalystRunInputs } from "./types-oKRhQAde.js";
|
|
3
3
|
import { C as ChatResponse, S as ChatRequest } from "./types-DBZ7keha.js";
|
|
4
|
-
import { c as RegistryRunOpts,
|
|
4
|
+
import { c as RegistryRunOpts, t as AnalystRegistry } from "./registry-JYfPxcVz.js";
|
|
5
5
|
import { AgentProfile, AgentProfile as AgentProfile$1, HarnessType, HarnessType as HarnessType$1 } from "@tangle-network/agent-interface";
|
|
6
6
|
//#region src/campaign/external-optimizer-contracts.d.ts
|
|
7
7
|
interface ExternalOptimizerProcessLimits {
|
|
@@ -485,4 +485,4 @@ declare function agentProfileId(profile: AgentProfile): string;
|
|
|
485
485
|
declare function agentProfileHash(profile: AgentProfile): string;
|
|
486
486
|
//#endregion
|
|
487
487
|
export { runAnalystBenchmark as A, ExternalOptimizerModelBudget as B, AnalystEvidenceResolutionError as C, AnalystLatencyDistribution as D, AnalystIssueExpectation as E, ExternalOptimizerCallbackLimits as F, ExternalOptimizerProcessLimits as G, ExternalOptimizerModelCallRequest as H, ExternalOptimizerChatRequest as I, ExternalOptimizerWireCounts as J, ExternalOptimizerResumeMode as K, ExternalOptimizerEndpointFormat as L, scoreAnalystFindings as M, DEFAULT_EXTERNAL_OPTIMIZER_CALLBACK_LIMITS as N, RunAnalystBenchmarkOptions as O, DEFAULT_EXTERNAL_OPTIMIZER_PROCESS_LIMITS as P, resolveExternalOptimizerProcessLimits as Q, ExternalOptimizerEvaluationObservation as R, AnalystEvidenceResolution as S, AnalystFindingScore as T, ExternalOptimizerModelCallResult as U, ExternalOptimizerModelCall as V, ExternalOptimizerModelExecutionObservation as W, ExternalTextEvaluationRequest as X, ExternalTextCandidate as Y, resolveExternalOptimizerCallbackLimits as Z, AnalystBenchmarkProvenance as _, ProfileAxisSpec as a, AnalystBenchmarkSummary as b, expandProfileAxes as c, AnalystBenchmarkDatasetRef as d, AnalystBenchmarkDescriptor as f, AnalystBenchmarkOutput as g, AnalystBenchmarkObservation as h, HarnessType$1 as i, traceStoreEvidenceResolver as j, registryBenchmarkRunner as k, harnessAxisOf as l, AnalystBenchmarkLabelState as m, CODING_HARNESSES as n, agentProfileHash as o, AnalystBenchmarkError as p, ExternalOptimizerRunnerCommand as q, HARNESS_NATIVE_MODEL as r, agentProfileId as s, AgentProfile$1 as t, AnalystBenchmarkCase as u, AnalystBenchmarkResult as v, AnalystEvidenceResolver as w, AnalystEvidenceExpectation as x, AnalystBenchmarkRunner as y, ExternalOptimizerEvaluationRefusalReason as z };
|
|
488
|
-
//# sourceMappingURL=agent-profile-
|
|
488
|
+
//# sourceMappingURL=agent-profile-CIA2Atnt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-profile-
|
|
1
|
+
{"version":3,"file":"agent-profile-CIA2Atnt.d.ts","names":["_$___cost_ledger0.CostReceiptInput"],"sources":["../src/campaign/external-optimizer-contracts.ts","../src/analyst/benchmark-scoring.ts","../src/analyst/benchmark.ts","../src/agent-profile.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EACA;EACA,mBAAmB;EACnB;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;EACA;;UAGe;EACf,UAAU;EACV;EACA;;UAGe;EACf;EACA;EACA,oBAAoB;EACpB,QAAQ;;EAER;;KAGU,wBAAwB,qBAAqB;EACvD;EACA,WAAW;EACX,UAAU;EACV,SAAS;gBACK;;;;;iBAMA,2BAA2B,QACzC,WAAW,OAAO,WAAW,qBAC5B,wBAAwB;UAoBV;EACf,mBAAmB;EACnB,QAAQ;EACR,WAAW;;;;;EAKX;;EAEA,QAAQ;;UAGO;EACf;EACA;EACA;EACA;;UAGe,uBAAuB;EACtC;EACA,QACE,OAAO,QACP;IAAW;IAAgB;IAAoB,SAAS;MACvD,yBAAyB,QAAQ;;UAGrB;EACf;EACA;EACA;EACA,YAAY;EACZ;EACA;EACA;EACA;EACA,mBAAmB;EACnB,OAAO;EACP,qBAAqB;EACrB;EACA,eAAe;EACf,QAAQ;EACR,iBAAiB;EACjB,QAAQ;;UAGO;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;EACA,WAAW;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA,UAAU;EACV;EACA,cAAc;EACd,WAAW;;UAGI,mCAAmC;EAClD;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,YAAY;EACZ,cAAc;EACd,WAAW;;UAGI,2BAA2B;EAC1C,gBAAgB,qBAAqB;EACrC,kBAAkB,uBAAuB;EACzC;EACA;EACA;EACA,kBAAkB,wBAAwB;EAC1C,YAAY;;EAEZ,+BAA+B;EAC/B,iBAAiB,aAAa,uCAAuC;EACrE,SAAS;;iBAGW,oBAAoB,QACxC,SAAS,2BAA2B,UACnC,QAAQ;iBAyDK,wBAAwB;EACtC;EACA,UAAU;EACV,aAAa,KAAK;;EAElB;IACE,uBAAuB;;;;;;;;;;cCpUd,2BAA2B;UAOvB;;;EAGf,MAAM;;EAEN,qBAAqB;;;EAGrB;;;;;;EAMA;;;;;;;cAQW;;;;;;;;;;;;;;;;;;;iBAoBG,kBAAkB,MAAM,kBAAkB;;;;;;;;iBAwD1C,cACd,SAAS,KAAK;EACX,SAAS;EAAa;;;;;;;;;iBAiBX,eAAe,SAAS;;;;;;;;;;;iBAmDxB,iBAAiB,SAAS"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { s as ValidationError } from "./errors-Dngq5h35.js";
|
|
2
|
+
import { r as continuousAgreement } from "./judge-calibration-N44V04Se.js";
|
|
3
|
+
//#region src/statistics/agreement-irr.ts
|
|
4
|
+
/**
|
|
5
|
+
* Inter-rater reliability — Krippendorff's α under the squared-difference
|
|
6
|
+
* metric, pooled across dimensions.
|
|
7
|
+
*
|
|
8
|
+
* Each inner array is one judge's scores. Items are matched by position
|
|
9
|
+
* WITHIN a dimension: the k-th score a judge supplies carrying dimension
|
|
10
|
+
* `d` is item k of `d`, and the ratings compared against each other are
|
|
11
|
+
* the ones different judges gave to the same item. Every judge that scores
|
|
12
|
+
* a dimension at all must supply the same number of scores for it —
|
|
13
|
+
* ragged input cannot be aligned into items and throws rather than
|
|
14
|
+
* comparing mismatched items.
|
|
15
|
+
*
|
|
16
|
+
* α = 1 − D_observed / D_expected: D_observed averages the squared
|
|
17
|
+
* difference over within-item judge pairs, D_expected over every pair of
|
|
18
|
+
* ratings irrespective of item. α = 1 is perfect agreement, 0 is chance,
|
|
19
|
+
* negative is systematic disagreement.
|
|
20
|
+
*/
|
|
21
|
+
function interRaterReliability(judgeScores) {
|
|
22
|
+
if (judgeScores.length < 2) return 1;
|
|
23
|
+
const perDimension = /* @__PURE__ */ new Map();
|
|
24
|
+
for (let judgeIndex = 0; judgeIndex < judgeScores.length; judgeIndex++) for (const s of judgeScores[judgeIndex]) {
|
|
25
|
+
let byJudge = perDimension.get(s.dimension);
|
|
26
|
+
if (byJudge === void 0) {
|
|
27
|
+
byJudge = Array.from({ length: judgeScores.length }, () => []);
|
|
28
|
+
perDimension.set(s.dimension, byJudge);
|
|
29
|
+
}
|
|
30
|
+
byJudge[judgeIndex].push(s.score);
|
|
31
|
+
}
|
|
32
|
+
const allValues = [];
|
|
33
|
+
const pairDiffs = [];
|
|
34
|
+
for (const [dimension, byJudge] of perDimension) {
|
|
35
|
+
const scoring = byJudge.filter((scores) => scores.length > 0);
|
|
36
|
+
if (scoring.length < 2) continue;
|
|
37
|
+
const itemCount = scoring[0].length;
|
|
38
|
+
if (scoring.some((scores) => scores.length !== itemCount)) throw new ValidationError(`interRaterReliability: dimension '${dimension}' has judges supplying ${scoring.map((scores) => scores.length).join("/")} scores — items cannot be aligned`);
|
|
39
|
+
for (let item = 0; item < itemCount; item++) {
|
|
40
|
+
const ratings = scoring.map((scores) => scores[item]);
|
|
41
|
+
for (const v of ratings) allValues.push(v);
|
|
42
|
+
for (let i = 0; i < ratings.length; i++) for (let j = i + 1; j < ratings.length; j++) pairDiffs.push((ratings[i] - ratings[j]) ** 2);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (pairDiffs.length === 0 || allValues.length < 2) return 1;
|
|
46
|
+
const observedDisagreement = pairDiffs.reduce((a, b) => a + b, 0) / pairDiffs.length;
|
|
47
|
+
let expectedDisagreement = 0;
|
|
48
|
+
let expectedCount = 0;
|
|
49
|
+
for (let i = 0; i < allValues.length; i++) for (let j = i + 1; j < allValues.length; j++) {
|
|
50
|
+
expectedDisagreement += (allValues[i] - allValues[j]) ** 2;
|
|
51
|
+
expectedCount++;
|
|
52
|
+
}
|
|
53
|
+
expectedDisagreement = expectedCount > 0 ? expectedDisagreement / expectedCount : 0;
|
|
54
|
+
if (expectedDisagreement === 0) return 1;
|
|
55
|
+
return 1 - observedDisagreement / expectedDisagreement;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Corpus-wide inter-rater agreement across N items × M judges × D dimensions.
|
|
59
|
+
*
|
|
60
|
+
* For each dimension, builds the [n_items][n_judges] matrix of scores
|
|
61
|
+
* (keeping only items every judge rated on that dimension), then runs
|
|
62
|
+
* `continuousAgreement` to get ICC(2,1), κ_w, Pearson, Spearman, and
|
|
63
|
+
* bootstrap CIs. Reports a pooled mean across dimensions as a single
|
|
64
|
+
* "is this judge panel reliable on this corpus?" number.
|
|
65
|
+
*
|
|
66
|
+
* Fail-loud contract:
|
|
67
|
+
* - Empty input throws.
|
|
68
|
+
* - Fewer than 2 judges or fewer than 2 items per dimension throws.
|
|
69
|
+
* - A judge present in some dimensions but with zero scored items on
|
|
70
|
+
* another dimension throws (would silently shrink the matrix).
|
|
71
|
+
* - Duplicate (itemId, judgeName, dimension) records throw.
|
|
72
|
+
*/
|
|
73
|
+
function corpusInterRaterAgreement(records, opts = {}) {
|
|
74
|
+
if (records.length === 0) throw new ValidationError("corpusInterRaterAgreement: no score records supplied");
|
|
75
|
+
const judgesSeen = /* @__PURE__ */ new Set();
|
|
76
|
+
const dimsSeen = /* @__PURE__ */ new Set();
|
|
77
|
+
const grid = /* @__PURE__ */ new Map();
|
|
78
|
+
for (const r of records) {
|
|
79
|
+
if (!Number.isFinite(r.score)) throw new ValidationError(`corpusInterRaterAgreement: non-finite score for (item=${r.itemId}, judge=${r.judgeName}, dim=${r.dimension})`);
|
|
80
|
+
judgesSeen.add(r.judgeName);
|
|
81
|
+
dimsSeen.add(r.dimension);
|
|
82
|
+
const byJudge = grid.get(r.dimension) ?? /* @__PURE__ */ new Map();
|
|
83
|
+
const byItem = byJudge.get(r.judgeName) ?? /* @__PURE__ */ new Map();
|
|
84
|
+
if (byItem.has(r.itemId)) throw new ValidationError(`corpusInterRaterAgreement: duplicate record for (item=${r.itemId}, judge=${r.judgeName}, dim=${r.dimension})`);
|
|
85
|
+
byItem.set(r.itemId, r.score);
|
|
86
|
+
byJudge.set(r.judgeName, byItem);
|
|
87
|
+
grid.set(r.dimension, byJudge);
|
|
88
|
+
}
|
|
89
|
+
const targetDims = opts.dimensions ?? [...dimsSeen].sort();
|
|
90
|
+
for (const d of targetDims) if (!dimsSeen.has(d)) throw new ValidationError(`corpusInterRaterAgreement: dimension '${d}' was requested but no records carry it`);
|
|
91
|
+
const targetJudges = opts.judges ? [...opts.judges] : [...judgesSeen].sort();
|
|
92
|
+
for (const j of targetJudges) if (!judgesSeen.has(j)) throw new ValidationError(`corpusInterRaterAgreement: judge '${j}' was requested but produced no records`);
|
|
93
|
+
if (targetJudges.length < 2) throw new ValidationError(`corpusInterRaterAgreement: need ≥2 judges, got ${targetJudges.length}`);
|
|
94
|
+
const perDimension = [];
|
|
95
|
+
const iccs = [];
|
|
96
|
+
const kappas = [];
|
|
97
|
+
for (const dim of targetDims) {
|
|
98
|
+
const byJudge = grid.get(dim);
|
|
99
|
+
const judgeItemCounts = {};
|
|
100
|
+
for (const j of targetJudges) judgeItemCounts[j] = byJudge.get(j)?.size ?? 0;
|
|
101
|
+
const emptyJudges = targetJudges.filter((j) => judgeItemCounts[j] === 0);
|
|
102
|
+
if (emptyJudges.length > 0) throw new ValidationError(`corpusInterRaterAgreement: dimension '${dim}' has no scores from judge(s) ${emptyJudges.join(", ")} (counts: ${JSON.stringify(judgeItemCounts)})`);
|
|
103
|
+
let commonItems = null;
|
|
104
|
+
for (const j of targetJudges) {
|
|
105
|
+
const ids = new Set(byJudge.get(j).keys());
|
|
106
|
+
if (commonItems === null) commonItems = ids;
|
|
107
|
+
else commonItems = new Set([...commonItems].filter((x) => ids.has(x)));
|
|
108
|
+
}
|
|
109
|
+
const sortedItems = [...commonItems ?? /* @__PURE__ */ new Set()].sort();
|
|
110
|
+
if (sortedItems.length < 2) throw new ValidationError(`corpusInterRaterAgreement: dimension '${dim}' has ${sortedItems.length} item(s) rated by all ${targetJudges.length} judges (need ≥2)`);
|
|
111
|
+
const matrix = sortedItems.map((itemId) => targetJudges.map((j) => byJudge.get(j).get(itemId)));
|
|
112
|
+
const agreement = continuousAgreement(matrix, opts);
|
|
113
|
+
perDimension.push({
|
|
114
|
+
...agreement,
|
|
115
|
+
dimension: dim,
|
|
116
|
+
itemIds: sortedItems,
|
|
117
|
+
judgeIds: [...targetJudges]
|
|
118
|
+
});
|
|
119
|
+
if (Number.isFinite(agreement.icc)) iccs.push(agreement.icc);
|
|
120
|
+
if (Number.isFinite(agreement.weightedKappa)) kappas.push(agreement.weightedKappa);
|
|
121
|
+
}
|
|
122
|
+
const mean = (xs) => xs.length === 0 ? NaN : xs.reduce((a, b) => a + b, 0) / xs.length;
|
|
123
|
+
return {
|
|
124
|
+
perDimension,
|
|
125
|
+
overallIcc: mean(iccs),
|
|
126
|
+
overallWeightedKappa: mean(kappas),
|
|
127
|
+
dimensions: targetDims,
|
|
128
|
+
judgeIds: targetJudges
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Convenience adapter for `JudgeScore[]` data keyed externally by item.
|
|
133
|
+
*
|
|
134
|
+
* Use when you have per-item arrays of `JudgeScore[]` (e.g. one
|
|
135
|
+
* `ScenarioResult.judgeScores` per scenario) and want corpus-wide
|
|
136
|
+
* agreement without manually flattening. `itemId` must be unique per
|
|
137
|
+
* row of `itemsScores`.
|
|
138
|
+
*/
|
|
139
|
+
function corpusInterRaterAgreementFromJudgeScores(itemsScores, opts = {}) {
|
|
140
|
+
const records = [];
|
|
141
|
+
const seen = /* @__PURE__ */ new Set();
|
|
142
|
+
for (const { itemId, scores } of itemsScores) {
|
|
143
|
+
if (seen.has(itemId)) throw new ValidationError(`corpusInterRaterAgreementFromJudgeScores: duplicate itemId '${itemId}'`);
|
|
144
|
+
seen.add(itemId);
|
|
145
|
+
for (const s of scores) records.push({
|
|
146
|
+
itemId,
|
|
147
|
+
judgeName: s.judgeName,
|
|
148
|
+
dimension: s.dimension,
|
|
149
|
+
score: s.score
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return corpusInterRaterAgreement(records, opts);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Unweighted Cohen's κ for paired nominal labels. Labels carry no order, so a
|
|
156
|
+
* near miss counts as a miss; use `calibrateJudge` for ordinal scores.
|
|
157
|
+
*/
|
|
158
|
+
function nominalAgreement(pairs) {
|
|
159
|
+
const n = pairs.length;
|
|
160
|
+
if (n === 0) return {
|
|
161
|
+
n: 0,
|
|
162
|
+
agreement: NaN,
|
|
163
|
+
kappa: NaN
|
|
164
|
+
};
|
|
165
|
+
const left = /* @__PURE__ */ new Map();
|
|
166
|
+
const right = /* @__PURE__ */ new Map();
|
|
167
|
+
let same = 0;
|
|
168
|
+
for (const [a, b] of pairs) {
|
|
169
|
+
if (typeof a !== "string" || typeof b !== "string") throw new ValidationError("nominalAgreement: every label must be a string");
|
|
170
|
+
if (a === b) same += 1;
|
|
171
|
+
left.set(a, (left.get(a) ?? 0) + 1);
|
|
172
|
+
right.set(b, (right.get(b) ?? 0) + 1);
|
|
173
|
+
}
|
|
174
|
+
const observed = same / n;
|
|
175
|
+
let expected = 0;
|
|
176
|
+
for (const [label, count] of left) expected += count / n * ((right.get(label) ?? 0) / n);
|
|
177
|
+
return {
|
|
178
|
+
n,
|
|
179
|
+
agreement: observed,
|
|
180
|
+
kappa: expected === 1 ? NaN : (observed - expected) / (1 - expected)
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
export { nominalAgreement as i, corpusInterRaterAgreementFromJudgeScores as n, interRaterReliability as r, corpusInterRaterAgreement as t };
|
|
185
|
+
|
|
186
|
+
//# sourceMappingURL=agreement-irr-DsTURxdr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agreement-irr-DsTURxdr.js","names":["prev"],"sources":["../src/statistics/agreement-irr.ts"],"sourcesContent":["import { ValidationError } from '../errors'\nimport {\n type ContinuousAgreement,\n type ContinuousAgreementOptions,\n continuousAgreement,\n} from '../judge-calibration'\nimport type { JudgeScore } from '../types'\n\n/**\n * Inter-rater reliability — Krippendorff's α under the squared-difference\n * metric, pooled across dimensions.\n *\n * Each inner array is one judge's scores. Items are matched by position\n * WITHIN a dimension: the k-th score a judge supplies carrying dimension\n * `d` is item k of `d`, and the ratings compared against each other are\n * the ones different judges gave to the same item. Every judge that scores\n * a dimension at all must supply the same number of scores for it —\n * ragged input cannot be aligned into items and throws rather than\n * comparing mismatched items.\n *\n * α = 1 − D_observed / D_expected: D_observed averages the squared\n * difference over within-item judge pairs, D_expected over every pair of\n * ratings irrespective of item. α = 1 is perfect agreement, 0 is chance,\n * negative is systematic disagreement.\n */\nexport function interRaterReliability(judgeScores: JudgeScore[][]): number {\n if (judgeScores.length < 2) return 1\n\n // dimension → one score sequence per judge, in that judge's supplied order.\n const perDimension = new Map<string, number[][]>()\n for (let judgeIndex = 0; judgeIndex < judgeScores.length; judgeIndex++) {\n for (const s of judgeScores[judgeIndex]!) {\n let byJudge = perDimension.get(s.dimension)\n if (byJudge === undefined) {\n byJudge = Array.from({ length: judgeScores.length }, () => [] as number[])\n perDimension.set(s.dimension, byJudge)\n }\n byJudge[judgeIndex]!.push(s.score)\n }\n }\n\n const allValues: number[] = []\n const pairDiffs: number[] = []\n\n for (const [dimension, byJudge] of perDimension) {\n const scoring = byJudge.filter((scores) => scores.length > 0)\n if (scoring.length < 2) continue\n const itemCount = scoring[0]!.length\n if (scoring.some((scores) => scores.length !== itemCount)) {\n throw new ValidationError(\n `interRaterReliability: dimension '${dimension}' has judges supplying ` +\n `${scoring.map((scores) => scores.length).join('/')} scores — items cannot be aligned`,\n )\n }\n for (let item = 0; item < itemCount; item++) {\n const ratings = scoring.map((scores) => scores[item]!)\n for (const v of ratings) allValues.push(v)\n for (let i = 0; i < ratings.length; i++) {\n for (let j = i + 1; j < ratings.length; j++) {\n pairDiffs.push((ratings[i]! - ratings[j]!) ** 2)\n }\n }\n }\n }\n\n if (pairDiffs.length === 0 || allValues.length < 2) return 1\n\n const observedDisagreement = pairDiffs.reduce((a, b) => a + b, 0) / pairDiffs.length\n\n // Expected disagreement from all possible pairings of values\n let expectedDisagreement = 0\n let expectedCount = 0\n for (let i = 0; i < allValues.length; i++) {\n for (let j = i + 1; j < allValues.length; j++) {\n expectedDisagreement += (allValues[i]! - allValues[j]!) ** 2\n expectedCount++\n }\n }\n expectedDisagreement = expectedCount > 0 ? expectedDisagreement / expectedCount : 0\n\n if (expectedDisagreement === 0) return 1\n return 1 - observedDisagreement / expectedDisagreement\n}\n\n// ── Corpus-wide inter-rater agreement ──────────────────────────────\n//\n// `interRaterReliability(judgeScores)` computes a within-item\n// Krippendorff α — multiple judges score *the same item* and we ask\n// \"how much do their scores agree on that item?\" Useful for a single\n// scenario, but it cannot answer \"how reliable are these judges across\n// the whole evaluation corpus?\"\n//\n// `corpusInterRaterAgreement` does the corpus-wide question properly.\n// Inputs are flat per-(item, judge, dimension) score records. For each\n// dimension we pivot to a complete [n_items × n_judges] matrix and feed\n// it to the ICC(2,1) + κ_w machinery already validated in\n// `judge-calibration.ts`. An overall pooled metric averages the\n// per-dimension ICC/κ across dimensions.\n\nexport interface CorpusScoreRecord {\n /** Stable identifier for the rated item (scenario, span, turn, …). */\n itemId: string\n /** Identifier for the judge that produced this score. */\n judgeName: string\n /** Dimension name (matches `JudgeScore.dimension`). */\n dimension: string\n /** Numeric score; must be finite. */\n score: number\n}\n\nexport interface CorpusAgreementPerDimension extends ContinuousAgreement {\n dimension: string\n /** Item IDs that contributed to this dimension's matrix (every judge scored them). */\n itemIds: string[]\n /** Judge IDs that contributed to this dimension's matrix. */\n judgeIds: string[]\n}\n\nexport interface CorpusAgreementReport {\n /** Per-dimension ICC(2,1) + κ_w + Pearson + Spearman + bootstrap CIs. */\n perDimension: CorpusAgreementPerDimension[]\n /** Mean ICC across dimensions (NaN if no dimension yielded a finite ICC). */\n overallIcc: number\n /** Mean weighted κ across dimensions (NaN if none finite). */\n overallWeightedKappa: number\n /** Dimensions evaluated (sorted). */\n dimensions: string[]\n /** Judges seen across the corpus (sorted). */\n judgeIds: string[]\n}\n\nexport interface CorpusAgreementOptions extends ContinuousAgreementOptions {\n /**\n * Restrict the audit to these dimensions. Default = every dimension\n * that appears in the input. A dimension named here but absent from\n * the input throws — silent omission would corrupt the overall metric.\n */\n dimensions?: string[]\n /**\n * Restrict the audit to these judges. Default = every judge that\n * appears in the input. A judge named here but absent from a\n * dimension throws (see \"fail loud\" below).\n */\n judges?: string[]\n}\n\n/**\n * Corpus-wide inter-rater agreement across N items × M judges × D dimensions.\n *\n * For each dimension, builds the [n_items][n_judges] matrix of scores\n * (keeping only items every judge rated on that dimension), then runs\n * `continuousAgreement` to get ICC(2,1), κ_w, Pearson, Spearman, and\n * bootstrap CIs. Reports a pooled mean across dimensions as a single\n * \"is this judge panel reliable on this corpus?\" number.\n *\n * Fail-loud contract:\n * - Empty input throws.\n * - Fewer than 2 judges or fewer than 2 items per dimension throws.\n * - A judge present in some dimensions but with zero scored items on\n * another dimension throws (would silently shrink the matrix).\n * - Duplicate (itemId, judgeName, dimension) records throw.\n */\nexport function corpusInterRaterAgreement(\n records: CorpusScoreRecord[],\n opts: CorpusAgreementOptions = {},\n): CorpusAgreementReport {\n if (records.length === 0) {\n throw new ValidationError('corpusInterRaterAgreement: no score records supplied')\n }\n\n const judgesSeen = new Set<string>()\n const dimsSeen = new Set<string>()\n // dimension → judge → itemId → score\n const grid = new Map<string, Map<string, Map<string, number>>>()\n\n for (const r of records) {\n if (!Number.isFinite(r.score)) {\n throw new ValidationError(\n `corpusInterRaterAgreement: non-finite score for (item=${r.itemId}, judge=${r.judgeName}, dim=${r.dimension})`,\n )\n }\n judgesSeen.add(r.judgeName)\n dimsSeen.add(r.dimension)\n const byJudge = grid.get(r.dimension) ?? new Map<string, Map<string, number>>()\n const byItem = byJudge.get(r.judgeName) ?? new Map<string, number>()\n if (byItem.has(r.itemId)) {\n throw new ValidationError(\n `corpusInterRaterAgreement: duplicate record for (item=${r.itemId}, judge=${r.judgeName}, dim=${r.dimension})`,\n )\n }\n byItem.set(r.itemId, r.score)\n byJudge.set(r.judgeName, byItem)\n grid.set(r.dimension, byJudge)\n }\n\n const targetDims = opts.dimensions ?? [...dimsSeen].sort()\n for (const d of targetDims) {\n if (!dimsSeen.has(d)) {\n throw new ValidationError(\n `corpusInterRaterAgreement: dimension '${d}' was requested but no records carry it`,\n )\n }\n }\n const targetJudges = opts.judges ? [...opts.judges] : [...judgesSeen].sort()\n for (const j of targetJudges) {\n if (!judgesSeen.has(j)) {\n throw new ValidationError(\n `corpusInterRaterAgreement: judge '${j}' was requested but produced no records`,\n )\n }\n }\n if (targetJudges.length < 2) {\n throw new ValidationError(\n `corpusInterRaterAgreement: need ≥2 judges, got ${targetJudges.length}`,\n )\n }\n\n const perDimension: CorpusAgreementPerDimension[] = []\n const iccs: number[] = []\n const kappas: number[] = []\n\n for (const dim of targetDims) {\n const byJudge = grid.get(dim)!\n // Fail loud: every requested judge must have scored ≥1 item on this dim.\n const judgeItemCounts: Record<string, number> = {}\n for (const j of targetJudges) {\n const m = byJudge.get(j)\n judgeItemCounts[j] = m?.size ?? 0\n }\n const emptyJudges = targetJudges.filter((j) => judgeItemCounts[j] === 0)\n if (emptyJudges.length > 0) {\n throw new ValidationError(\n `corpusInterRaterAgreement: dimension '${dim}' has no scores from judge(s) ${emptyJudges.join(', ')} (counts: ${JSON.stringify(judgeItemCounts)})`,\n )\n }\n\n // Items rated by *every* requested judge on this dim.\n let commonItems: Set<string> | null = null\n for (const j of targetJudges) {\n const ids = new Set(byJudge.get(j)!.keys())\n if (commonItems === null) {\n commonItems = ids\n } else {\n const prev: Set<string> = commonItems\n commonItems = new Set([...prev].filter((x) => ids.has(x)))\n }\n }\n const sortedItems = [...(commonItems ?? new Set<string>())].sort()\n if (sortedItems.length < 2) {\n throw new ValidationError(\n `corpusInterRaterAgreement: dimension '${dim}' has ${sortedItems.length} item(s) rated by all ${targetJudges.length} judges (need ≥2)`,\n )\n }\n\n const matrix: number[][] = sortedItems.map((itemId) =>\n targetJudges.map((j) => byJudge.get(j)!.get(itemId)!),\n )\n const agreement = continuousAgreement(matrix, opts)\n perDimension.push({\n ...agreement,\n dimension: dim,\n itemIds: sortedItems,\n judgeIds: [...targetJudges],\n })\n if (Number.isFinite(agreement.icc)) iccs.push(agreement.icc)\n if (Number.isFinite(agreement.weightedKappa)) kappas.push(agreement.weightedKappa)\n }\n\n const mean = (xs: number[]) =>\n xs.length === 0 ? Number.NaN : xs.reduce((a, b) => a + b, 0) / xs.length\n return {\n perDimension,\n overallIcc: mean(iccs),\n overallWeightedKappa: mean(kappas),\n dimensions: targetDims,\n judgeIds: targetJudges,\n }\n}\n\n/**\n * Convenience adapter for `JudgeScore[]` data keyed externally by item.\n *\n * Use when you have per-item arrays of `JudgeScore[]` (e.g. one\n * `ScenarioResult.judgeScores` per scenario) and want corpus-wide\n * agreement without manually flattening. `itemId` must be unique per\n * row of `itemsScores`.\n */\nexport function corpusInterRaterAgreementFromJudgeScores(\n itemsScores: Array<{ itemId: string; scores: JudgeScore[] }>,\n opts: CorpusAgreementOptions = {},\n): CorpusAgreementReport {\n const records: CorpusScoreRecord[] = []\n const seen = new Set<string>()\n for (const { itemId, scores } of itemsScores) {\n if (seen.has(itemId)) {\n throw new ValidationError(\n `corpusInterRaterAgreementFromJudgeScores: duplicate itemId '${itemId}'`,\n )\n }\n seen.add(itemId)\n for (const s of scores) {\n records.push({\n itemId,\n judgeName: s.judgeName,\n dimension: s.dimension,\n score: s.score,\n })\n }\n }\n return corpusInterRaterAgreement(records, opts)\n}\n\n/** Agreement between two raters who each assigned one nominal label per item. */\nexport interface NominalAgreement {\n /** Items both raters labeled. */\n n: number\n /** Share of items with identical labels. */\n agreement: number\n /**\n * Cohen's κ = (pₒ − pₑ) / (1 − pₑ), with pₑ from each rater's own label\n * marginals. NaN when n = 0, or when both raters used one identical label\n * for every item (pₑ = 1): chance and observed agreement are then the same\n * thing, and no number distinguishes skill from luck.\n */\n kappa: number\n}\n\n/**\n * Unweighted Cohen's κ for paired nominal labels. Labels carry no order, so a\n * near miss counts as a miss; use `calibrateJudge` for ordinal scores.\n */\nexport function nominalAgreement(\n pairs: ReadonlyArray<readonly [string, string]>,\n): NominalAgreement {\n const n = pairs.length\n if (n === 0) return { n: 0, agreement: Number.NaN, kappa: Number.NaN }\n const left = new Map<string, number>()\n const right = new Map<string, number>()\n let same = 0\n for (const [a, b] of pairs) {\n if (typeof a !== 'string' || typeof b !== 'string') {\n throw new ValidationError('nominalAgreement: every label must be a string')\n }\n if (a === b) same += 1\n left.set(a, (left.get(a) ?? 0) + 1)\n right.set(b, (right.get(b) ?? 0) + 1)\n }\n const observed = same / n\n let expected = 0\n for (const [label, count] of left) expected += (count / n) * ((right.get(label) ?? 0) / n)\n const kappa = expected === 1 ? Number.NaN : (observed - expected) / (1 - expected)\n return { n, agreement: observed, kappa }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,sBAAsB,aAAqC;CACzE,IAAI,YAAY,SAAS,GAAG,OAAO;CAGnC,MAAM,+BAAe,IAAI,IAAwB;CACjD,KAAK,IAAI,aAAa,GAAG,aAAa,YAAY,QAAQ,cACxD,KAAK,MAAM,KAAK,YAAY,aAAc;EACxC,IAAI,UAAU,aAAa,IAAI,EAAE,SAAS;EAC1C,IAAI,YAAY,KAAA,GAAW;GACzB,UAAU,MAAM,KAAK,EAAE,QAAQ,YAAY,OAAO,SAAS,CAAC,CAAa;GACzE,aAAa,IAAI,EAAE,WAAW,OAAO;EACvC;EACA,QAAQ,WAAW,CAAE,KAAK,EAAE,KAAK;CACnC;CAGF,MAAM,YAAsB,CAAC;CAC7B,MAAM,YAAsB,CAAC;CAE7B,KAAK,MAAM,CAAC,WAAW,YAAY,cAAc;EAC/C,MAAM,UAAU,QAAQ,QAAQ,WAAW,OAAO,SAAS,CAAC;EAC5D,IAAI,QAAQ,SAAS,GAAG;EACxB,MA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