@namzu/sdk 62.12.0 → 62.14.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 +31 -0
- package/dist/agents/file-definitions.d.ts +7 -0
- package/dist/agents/file-definitions.d.ts.map +1 -1
- package/dist/agents/file-definitions.js +20 -0
- package/dist/agents/file-definitions.js.map +1 -1
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +1 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/bridge/acp/server.d.ts +8 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +12 -0
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/connector/index.d.ts +1 -1
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +1 -1
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +96 -0
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +488 -13
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +1 -0
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +1 -0
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/tasks.d.ts +40 -0
- package/dist/connector/mcp/tasks.d.ts.map +1 -0
- package/dist/connector/mcp/tasks.js +55 -0
- package/dist/connector/mcp/tasks.js.map +1 -0
- package/dist/constants/data-epoch.d.ts +18 -0
- package/dist/constants/data-epoch.d.ts.map +1 -0
- package/dist/constants/data-epoch.js +18 -0
- package/dist/constants/data-epoch.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/mcp/index.d.ts +1 -1
- package/dist/constants/mcp/index.d.ts.map +1 -1
- package/dist/constants/mcp/index.js +5 -0
- package/dist/constants/mcp/index.js.map +1 -1
- package/dist/constants/telemetry/index.d.ts +12 -0
- package/dist/constants/telemetry/index.d.ts.map +1 -1
- package/dist/constants/telemetry/index.js +12 -0
- package/dist/constants/telemetry/index.js.map +1 -1
- package/dist/eval/bootstrap.d.ts +122 -0
- package/dist/eval/bootstrap.d.ts.map +1 -0
- package/dist/eval/bootstrap.js +227 -0
- package/dist/eval/bootstrap.js.map +1 -0
- package/dist/eval/compare.d.ts +109 -0
- package/dist/eval/compare.d.ts.map +1 -0
- package/dist/eval/compare.js +324 -0
- package/dist/eval/compare.js.map +1 -0
- package/dist/eval/disclosure.d.ts +70 -0
- package/dist/eval/disclosure.d.ts.map +1 -0
- package/dist/eval/disclosure.js +64 -0
- package/dist/eval/disclosure.js.map +1 -0
- package/dist/eval/experiment.d.ts +23 -0
- package/dist/eval/experiment.d.ts.map +1 -1
- package/dist/eval/experiment.js +87 -15
- package/dist/eval/experiment.js.map +1 -1
- package/dist/eval/from-turn.d.ts.map +1 -1
- package/dist/eval/from-turn.js +5 -0
- package/dist/eval/from-turn.js.map +1 -1
- package/dist/eval/index.d.ts +13 -2
- package/dist/eval/index.d.ts.map +1 -1
- package/dist/eval/index.js +6 -1
- package/dist/eval/index.js.map +1 -1
- package/dist/eval/report-stats.d.ts +77 -0
- package/dist/eval/report-stats.d.ts.map +1 -0
- package/dist/eval/report-stats.js +184 -0
- package/dist/eval/report-stats.js.map +1 -0
- package/dist/eval/run-options.d.ts +30 -0
- package/dist/eval/run-options.d.ts.map +1 -0
- package/dist/eval/run-options.js +20 -0
- package/dist/eval/run-options.js.map +1 -0
- package/dist/eval/run-summary.d.ts +36 -0
- package/dist/eval/run-summary.d.ts.map +1 -0
- package/dist/eval/run-summary.js +57 -0
- package/dist/eval/run-summary.js.map +1 -0
- package/dist/eval/scorers.d.ts +32 -0
- package/dist/eval/scorers.d.ts.map +1 -1
- package/dist/eval/scorers.js +77 -0
- package/dist/eval/scorers.js.map +1 -1
- package/dist/eval/types.d.ts +74 -0
- package/dist/eval/types.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts +3 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +18 -2
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +1 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/loader.d.ts +11 -0
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +15 -2
- package/dist/plugin/loader.js.map +1 -1
- package/dist/public-runtime.d.ts +10 -6
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +13 -5
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +2 -0
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.d.ts +3 -0
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +76 -5
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/runtime/query/cancelled-before-start.d.ts.map +1 -1
- package/dist/runtime/query/cancelled-before-start.js +2 -0
- package/dist/runtime/query/cancelled-before-start.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +17 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +18 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +80 -1
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +18 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +5 -0
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/runtime/query/result.js +2 -0
- package/dist/runtime/query/result.js.map +1 -1
- package/dist/runtime/query/turn/answer-claims.d.ts +52 -0
- package/dist/runtime/query/turn/answer-claims.d.ts.map +1 -0
- package/dist/runtime/query/turn/answer-claims.js +348 -0
- package/dist/runtime/query/turn/answer-claims.js.map +1 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts +7 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +13 -0
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/loader.d.ts +15 -1
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +17 -3
- package/dist/skills/loader.js.map +1 -1
- package/dist/store/goal/index.d.ts +3 -1
- package/dist/store/goal/index.d.ts.map +1 -1
- package/dist/store/goal/index.js +6 -0
- package/dist/store/goal/index.js.map +1 -1
- package/dist/telemetry/genai.d.ts +98 -0
- package/dist/telemetry/genai.d.ts.map +1 -0
- package/dist/telemetry/genai.js +189 -0
- package/dist/telemetry/genai.js.map +1 -0
- package/dist/telemetry/runtime-accessors.d.ts +19 -0
- package/dist/telemetry/runtime-accessors.d.ts.map +1 -1
- package/dist/telemetry/runtime-accessors.js +43 -1
- package/dist/telemetry/runtime-accessors.js.map +1 -1
- package/dist/tools/goal/confirmation.d.ts +154 -0
- package/dist/tools/goal/confirmation.d.ts.map +1 -0
- package/dist/tools/goal/confirmation.js +290 -0
- package/dist/tools/goal/confirmation.js.map +1 -0
- package/dist/tools/goal/index.d.ts +4 -1
- package/dist/tools/goal/index.d.ts.map +1 -1
- package/dist/tools/goal/index.js +27 -2
- package/dist/tools/goal/index.js.map +1 -1
- package/dist/tools/hand-back/index.d.ts +48 -0
- package/dist/tools/hand-back/index.d.ts.map +1 -0
- package/dist/tools/hand-back/index.js +129 -0
- package/dist/tools/hand-back/index.js.map +1 -0
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +15 -1
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +10 -0
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +12 -0
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/types/acp/index.d.ts +18 -0
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/connector/mcp.d.ts +18 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/goal/index.d.ts +12 -0
- package/dist/types/goal/index.d.ts.map +1 -1
- package/dist/types/session/config.d.ts +8 -0
- package/dist/types/session/config.d.ts.map +1 -1
- package/dist/types/session/hand-back.d.ts +29 -0
- package/dist/types/session/hand-back.d.ts.map +1 -0
- package/dist/types/session/hand-back.js +11 -0
- package/dist/types/session/hand-back.js.map +1 -0
- package/dist/types/session/outcome.d.ts +37 -0
- package/dist/types/session/outcome.d.ts.map +1 -1
- package/dist/types/session/outcome.js.map +1 -1
- package/dist/types/session/turn.d.ts +19 -1
- package/dist/types/session/turn.d.ts.map +1 -1
- package/dist/types/session/turn.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/file-definitions.ts +21 -0
- package/src/agents/index.ts +1 -0
- package/src/bridge/acp/server.ts +20 -0
- package/src/connector/index.ts +1 -0
- package/src/connector/mcp/client.ts +531 -14
- package/src/connector/mcp/index.ts +1 -0
- package/src/connector/mcp/tasks.ts +81 -0
- package/src/constants/data-epoch.ts +17 -0
- package/src/constants/index.ts +1 -0
- package/src/constants/mcp/index.ts +6 -1
- package/src/constants/telemetry/index.ts +13 -0
- package/src/eval/bootstrap.ts +314 -0
- package/src/eval/compare.ts +473 -0
- package/src/eval/disclosure.ts +136 -0
- package/src/eval/experiment.ts +127 -15
- package/src/eval/from-turn.ts +5 -0
- package/src/eval/index.ts +51 -0
- package/src/eval/report-stats.ts +257 -0
- package/src/eval/run-options.ts +49 -0
- package/src/eval/run-summary.ts +104 -0
- package/src/eval/scorers.ts +83 -0
- package/src/eval/types.ts +76 -0
- package/src/manager/session/turn-recorder.ts +23 -2
- package/src/plugin/index.ts +7 -1
- package/src/plugin/loader.ts +16 -2
- package/src/public-runtime.ts +70 -0
- package/src/public-types.ts +9 -0
- package/src/registry/command/kernel-commands.ts +94 -6
- package/src/runtime/query/cancelled-before-start.ts +2 -0
- package/src/runtime/query/index.ts +20 -0
- package/src/runtime/query/iteration/index.ts +85 -1
- package/src/runtime/query/iteration/phases/tool-review.ts +24 -1
- package/src/runtime/query/iteration/stream-turn.ts +10 -0
- package/src/runtime/query/result.ts +2 -0
- package/src/runtime/query/turn/answer-claims.ts +413 -0
- package/src/runtime/query/turn/outcome-ledger.ts +12 -0
- package/src/skills/index.ts +1 -0
- package/src/skills/loader.ts +21 -3
- package/src/store/goal/index.ts +11 -0
- package/src/telemetry/genai.ts +202 -0
- package/src/telemetry/runtime-accessors.ts +40 -1
- package/src/tools/goal/confirmation.ts +375 -0
- package/src/tools/goal/index.ts +37 -1
- package/src/tools/hand-back/index.ts +150 -0
- package/src/tools/schedules/schedule-tool.ts +19 -1
- package/src/tools/schedules/types.ts +10 -0
- package/src/toolsets/manager.ts +22 -0
- package/src/types/acp/index.ts +20 -0
- package/src/types/connector/mcp.ts +18 -0
- package/src/types/goal/index.ts +13 -0
- package/src/types/session/config.ts +8 -0
- package/src/types/session/hand-back.ts +31 -0
- package/src/types/session/outcome.ts +42 -0
- package/src/types/session/turn.ts +19 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intervals for an eval, by resampling cases.
|
|
3
|
+
*
|
|
4
|
+
* A pass rate printed alone invites conclusions the data cannot carry: on 80
|
|
5
|
+
* tasks a difference of -1.25 points came with a 95% interval from -10.0 to
|
|
6
|
+
* +7.5, which says almost nothing. The interval here is a percentile
|
|
7
|
+
* bootstrap over CASES. A case is the unit that was sampled from the world, so
|
|
8
|
+
* a case is what gets resampled, and all of a case's repeats travel with it:
|
|
9
|
+
* repeats of one case are not independent evidence about the suite, and
|
|
10
|
+
* treating them as such would narrow the interval for free.
|
|
11
|
+
*
|
|
12
|
+
* Nothing in here reads the clock or an unseeded random source. The generator
|
|
13
|
+
* is a small deterministic one fed by a seed that the report records, so the
|
|
14
|
+
* same cases and the same seed give the same interval.
|
|
15
|
+
*/
|
|
16
|
+
/** Fewest cases an interval is computed for. Below it the report says why. */
|
|
17
|
+
export declare const MIN_CASES_FOR_INTERVAL = 5;
|
|
18
|
+
/** Resamples drawn per interval. */
|
|
19
|
+
export declare const BOOTSTRAP_RESAMPLES = 2000;
|
|
20
|
+
/** The seed used when none is given. A fixed number, so a report is reproducible. */
|
|
21
|
+
export declare const DEFAULT_EVAL_SEED = 1;
|
|
22
|
+
/** Coverage of every interval in this module. */
|
|
23
|
+
export declare const INTERVAL_LEVEL = 0.95;
|
|
24
|
+
/**
|
|
25
|
+
* What one case contributes: the sum of its judged runs' scores, how many of
|
|
26
|
+
* those runs passed, and how many were judged at all. `judged` is at least 1;
|
|
27
|
+
* a case with no judged run has nothing to say and is left out by the caller.
|
|
28
|
+
*/
|
|
29
|
+
export interface CaseTally {
|
|
30
|
+
readonly scoreSum: number;
|
|
31
|
+
readonly passes: number;
|
|
32
|
+
readonly judged: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* An interval, or the reason there is none.
|
|
36
|
+
*
|
|
37
|
+
* `estimate` is the number the interval is around, and is present even when
|
|
38
|
+
* no interval is computed, so a reader always has the point value and the
|
|
39
|
+
* explanation for why it carries no bounds.
|
|
40
|
+
*/
|
|
41
|
+
export type Interval = {
|
|
42
|
+
readonly computed: true;
|
|
43
|
+
readonly estimate: number;
|
|
44
|
+
readonly low: number;
|
|
45
|
+
readonly high: number;
|
|
46
|
+
} | {
|
|
47
|
+
readonly computed: false;
|
|
48
|
+
readonly estimate: number | null;
|
|
49
|
+
readonly reason: string;
|
|
50
|
+
};
|
|
51
|
+
/** The method and its settings, written next to the numbers so they can be reproduced. */
|
|
52
|
+
export interface BootstrapMethod {
|
|
53
|
+
readonly kind: 'percentile bootstrap over cases, repeats kept together';
|
|
54
|
+
readonly level: typeof INTERVAL_LEVEL;
|
|
55
|
+
readonly resamples: number;
|
|
56
|
+
readonly seed: number;
|
|
57
|
+
/** Cases the interval was drawn over. */
|
|
58
|
+
readonly cases: number;
|
|
59
|
+
readonly minimumCases: number;
|
|
60
|
+
}
|
|
61
|
+
export interface CaseIntervals {
|
|
62
|
+
readonly method: BootstrapMethod;
|
|
63
|
+
/** Mean score over judged runs. */
|
|
64
|
+
readonly mean: Interval;
|
|
65
|
+
/** Passed runs over judged runs. */
|
|
66
|
+
readonly passRate: Interval;
|
|
67
|
+
}
|
|
68
|
+
/** The same for a paired difference, second side minus first. */
|
|
69
|
+
export interface DifferenceIntervals {
|
|
70
|
+
readonly method: BootstrapMethod;
|
|
71
|
+
readonly mean: Interval;
|
|
72
|
+
readonly passRate: Interval;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A bad `--repeat` or `--seed`. A RangeError, so existing handlers still see
|
|
76
|
+
* one, and marked with a code so a CLI can tell it from a RangeError a suite's
|
|
77
|
+
* own code threw (and from one thrown by another copy of this class).
|
|
78
|
+
*/
|
|
79
|
+
export declare class EvalUsageError extends RangeError {
|
|
80
|
+
readonly code = "EVAL_USAGE";
|
|
81
|
+
}
|
|
82
|
+
/** True for an {@link EvalUsageError}, even one built by another copy of the SDK. */
|
|
83
|
+
export declare function isEvalUsageError(err: unknown): err is EvalUsageError;
|
|
84
|
+
/**
|
|
85
|
+
* Validate a seed: an integer that fits in 32 bits, unsigned.
|
|
86
|
+
* Thrown as an EvalUsageError so a CLI can turn it into a usage error.
|
|
87
|
+
*/
|
|
88
|
+
export declare function validateSeed(value: number | undefined): number;
|
|
89
|
+
/**
|
|
90
|
+
* mulberry32: a 32-bit generator with one word of state. Not for secrets;
|
|
91
|
+
* its job is to be the same on every machine for a given seed.
|
|
92
|
+
*/
|
|
93
|
+
export declare function createSeededRandom(seed: number): () => number;
|
|
94
|
+
export declare function pooledMeanAndRate(tallies: readonly CaseTally[], draw?: Int32Array): [number, number];
|
|
95
|
+
/**
|
|
96
|
+
* 95% intervals for the mean score and the pass rate over a set of cases.
|
|
97
|
+
*
|
|
98
|
+
* Each resample draws as many cases as there are, with replacement, and pools
|
|
99
|
+
* their runs. Cases without a judged run must not be passed in.
|
|
100
|
+
*/
|
|
101
|
+
export declare function bootstrapCases(tallies: readonly CaseTally[], seed: number): CaseIntervals;
|
|
102
|
+
/** One case seen from both sides of a comparison. */
|
|
103
|
+
export interface PairedTally {
|
|
104
|
+
readonly a: CaseTally;
|
|
105
|
+
readonly b: CaseTally;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 95% intervals for the difference of two runs over the same cases, `b` minus
|
|
109
|
+
* `a`. A resample draws PAIRS, so the two sides of a case always travel
|
|
110
|
+
* together; that is what makes the interval a paired one, and it is much
|
|
111
|
+
* narrower than two separate intervals when the cases are the thing that
|
|
112
|
+
* varies.
|
|
113
|
+
*/
|
|
114
|
+
export declare function bootstrapPairedDifference(pairs: readonly PairedTally[], seed: number): DifferenceIntervals;
|
|
115
|
+
/**
|
|
116
|
+
* Exact two-sided sign test on discordant pairs: under no difference each flip
|
|
117
|
+
* is equally likely to go either way, so the count going one way is
|
|
118
|
+
* Binomial(n, 1/2). Returns twice the smaller tail, capped at 1; with no flips
|
|
119
|
+
* at all the answer is 1.
|
|
120
|
+
*/
|
|
121
|
+
export declare function exactSignTestP(oneWay: number, otherWay: number): number;
|
|
122
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/eval/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AE,MAAM,GAAG,MAAM,CAgBvE"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intervals for an eval, by resampling cases.
|
|
3
|
+
*
|
|
4
|
+
* A pass rate printed alone invites conclusions the data cannot carry: on 80
|
|
5
|
+
* tasks a difference of -1.25 points came with a 95% interval from -10.0 to
|
|
6
|
+
* +7.5, which says almost nothing. The interval here is a percentile
|
|
7
|
+
* bootstrap over CASES. A case is the unit that was sampled from the world, so
|
|
8
|
+
* a case is what gets resampled, and all of a case's repeats travel with it:
|
|
9
|
+
* repeats of one case are not independent evidence about the suite, and
|
|
10
|
+
* treating them as such would narrow the interval for free.
|
|
11
|
+
*
|
|
12
|
+
* Nothing in here reads the clock or an unseeded random source. The generator
|
|
13
|
+
* is a small deterministic one fed by a seed that the report records, so the
|
|
14
|
+
* same cases and the same seed give the same interval.
|
|
15
|
+
*/
|
|
16
|
+
/** Fewest cases an interval is computed for. Below it the report says why. */
|
|
17
|
+
export const MIN_CASES_FOR_INTERVAL = 5;
|
|
18
|
+
/** Resamples drawn per interval. */
|
|
19
|
+
export const BOOTSTRAP_RESAMPLES = 2000;
|
|
20
|
+
/** The seed used when none is given. A fixed number, so a report is reproducible. */
|
|
21
|
+
export const DEFAULT_EVAL_SEED = 1;
|
|
22
|
+
/** Coverage of every interval in this module. */
|
|
23
|
+
export const INTERVAL_LEVEL = 0.95;
|
|
24
|
+
/**
|
|
25
|
+
* A bad `--repeat` or `--seed`. A RangeError, so existing handlers still see
|
|
26
|
+
* one, and marked with a code so a CLI can tell it from a RangeError a suite's
|
|
27
|
+
* own code threw (and from one thrown by another copy of this class).
|
|
28
|
+
*/
|
|
29
|
+
export class EvalUsageError extends RangeError {
|
|
30
|
+
code = 'EVAL_USAGE';
|
|
31
|
+
}
|
|
32
|
+
/** True for an {@link EvalUsageError}, even one built by another copy of the SDK. */
|
|
33
|
+
export function isEvalUsageError(err) {
|
|
34
|
+
return err instanceof RangeError && err.code === 'EVAL_USAGE';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validate a seed: an integer that fits in 32 bits, unsigned.
|
|
38
|
+
* Thrown as an EvalUsageError so a CLI can turn it into a usage error.
|
|
39
|
+
*/
|
|
40
|
+
export function validateSeed(value) {
|
|
41
|
+
if (value === undefined)
|
|
42
|
+
return DEFAULT_EVAL_SEED;
|
|
43
|
+
if (!Number.isInteger(value) || value < 0 || value > 0xffffffff) {
|
|
44
|
+
throw new EvalUsageError(`seed must be an integer from 0 to 4294967295, or omitted; received ${String(value)}`);
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* mulberry32: a 32-bit generator with one word of state. Not for secrets;
|
|
50
|
+
* its job is to be the same on every machine for a given seed.
|
|
51
|
+
*/
|
|
52
|
+
export function createSeededRandom(seed) {
|
|
53
|
+
let state = validateSeed(seed) >>> 0;
|
|
54
|
+
return () => {
|
|
55
|
+
state = (state + 0x6d2b79f5) >>> 0;
|
|
56
|
+
let t = state;
|
|
57
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
58
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
59
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function quantile(sorted, p) {
|
|
63
|
+
const position = p * (sorted.length - 1);
|
|
64
|
+
const lower = Math.floor(position);
|
|
65
|
+
const upper = Math.ceil(position);
|
|
66
|
+
const low = sorted[lower];
|
|
67
|
+
const high = sorted[upper];
|
|
68
|
+
return low + (high - low) * (position - lower);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Draw `resamples` samples of `n` indices with replacement, hand each to
|
|
72
|
+
* `statistics`, and return the 2.5th and 97.5th percentiles of the two numbers
|
|
73
|
+
* it returns. Both statistics see the same draw, so the two intervals come
|
|
74
|
+
* from one set of resampled suites.
|
|
75
|
+
*/
|
|
76
|
+
function bootstrap(n, seed, statistics) {
|
|
77
|
+
const random = createSeededRandom(seed);
|
|
78
|
+
const draw = new Int32Array(n);
|
|
79
|
+
const means = new Float64Array(BOOTSTRAP_RESAMPLES);
|
|
80
|
+
const rates = new Float64Array(BOOTSTRAP_RESAMPLES);
|
|
81
|
+
for (let b = 0; b < BOOTSTRAP_RESAMPLES; b++) {
|
|
82
|
+
for (let i = 0; i < n; i++)
|
|
83
|
+
draw[i] = Math.floor(random() * n);
|
|
84
|
+
const [mean, rate] = statistics(draw);
|
|
85
|
+
means[b] = mean;
|
|
86
|
+
rates[b] = rate;
|
|
87
|
+
}
|
|
88
|
+
means.sort();
|
|
89
|
+
rates.sort();
|
|
90
|
+
const lowP = (1 - INTERVAL_LEVEL) / 2;
|
|
91
|
+
const highP = 1 - lowP;
|
|
92
|
+
return {
|
|
93
|
+
mean: [quantile(means, lowP), quantile(means, highP)],
|
|
94
|
+
passRate: [quantile(rates, lowP), quantile(rates, highP)],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function methodOf(seed, cases) {
|
|
98
|
+
return {
|
|
99
|
+
kind: 'percentile bootstrap over cases, repeats kept together',
|
|
100
|
+
level: INTERVAL_LEVEL,
|
|
101
|
+
resamples: BOOTSTRAP_RESAMPLES,
|
|
102
|
+
seed,
|
|
103
|
+
cases,
|
|
104
|
+
minimumCases: MIN_CASES_FOR_INTERVAL,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function tooFew(one, many, n) {
|
|
108
|
+
return `only ${n} ${n === 1 ? one : many}; an interval needs at least ${MIN_CASES_FOR_INTERVAL}`;
|
|
109
|
+
}
|
|
110
|
+
export function pooledMeanAndRate(tallies, draw) {
|
|
111
|
+
let score = 0;
|
|
112
|
+
let passes = 0;
|
|
113
|
+
let judged = 0;
|
|
114
|
+
const count = draw ? draw.length : tallies.length;
|
|
115
|
+
for (let i = 0; i < count; i++) {
|
|
116
|
+
const t = tallies[draw ? draw[i] : i];
|
|
117
|
+
score += t.scoreSum;
|
|
118
|
+
passes += t.passes;
|
|
119
|
+
judged += t.judged;
|
|
120
|
+
}
|
|
121
|
+
return judged === 0 ? [Number.NaN, Number.NaN] : [score / judged, passes / judged];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 95% intervals for the mean score and the pass rate over a set of cases.
|
|
125
|
+
*
|
|
126
|
+
* Each resample draws as many cases as there are, with replacement, and pools
|
|
127
|
+
* their runs. Cases without a judged run must not be passed in.
|
|
128
|
+
*/
|
|
129
|
+
export function bootstrapCases(tallies, seed) {
|
|
130
|
+
const checked = validateSeed(seed);
|
|
131
|
+
const n = tallies.length;
|
|
132
|
+
const method = methodOf(checked, n);
|
|
133
|
+
const [meanEstimate, rateEstimate] = n === 0 ? [null, null] : pooledMeanAndRate(tallies);
|
|
134
|
+
if (n < MIN_CASES_FOR_INTERVAL) {
|
|
135
|
+
const reason = tooFew('case with a judged run', 'cases with a judged run', n);
|
|
136
|
+
return {
|
|
137
|
+
method,
|
|
138
|
+
mean: { computed: false, estimate: meanEstimate, reason },
|
|
139
|
+
passRate: { computed: false, estimate: rateEstimate, reason },
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
const result = bootstrap(n, checked, (draw) => pooledMeanAndRate(tallies, draw));
|
|
143
|
+
return {
|
|
144
|
+
method,
|
|
145
|
+
mean: {
|
|
146
|
+
computed: true,
|
|
147
|
+
estimate: meanEstimate,
|
|
148
|
+
low: result.mean[0],
|
|
149
|
+
high: result.mean[1],
|
|
150
|
+
},
|
|
151
|
+
passRate: {
|
|
152
|
+
computed: true,
|
|
153
|
+
estimate: rateEstimate,
|
|
154
|
+
low: result.passRate[0],
|
|
155
|
+
high: result.passRate[1],
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* 95% intervals for the difference of two runs over the same cases, `b` minus
|
|
161
|
+
* `a`. A resample draws PAIRS, so the two sides of a case always travel
|
|
162
|
+
* together; that is what makes the interval a paired one, and it is much
|
|
163
|
+
* narrower than two separate intervals when the cases are the thing that
|
|
164
|
+
* varies.
|
|
165
|
+
*/
|
|
166
|
+
export function bootstrapPairedDifference(pairs, seed) {
|
|
167
|
+
const checked = validateSeed(seed);
|
|
168
|
+
const n = pairs.length;
|
|
169
|
+
const method = methodOf(checked, n);
|
|
170
|
+
const aSide = pairs.map((p) => p.a);
|
|
171
|
+
const bSide = pairs.map((p) => p.b);
|
|
172
|
+
const difference = (draw) => {
|
|
173
|
+
const [bMean, bRate] = pooledMeanAndRate(bSide, draw);
|
|
174
|
+
const [aMean, aRate] = pooledMeanAndRate(aSide, draw);
|
|
175
|
+
return [bMean - aMean, bRate - aRate];
|
|
176
|
+
};
|
|
177
|
+
const [meanEstimate, rateEstimate] = n === 0 ? [null, null] : difference();
|
|
178
|
+
if (n < MIN_CASES_FOR_INTERVAL) {
|
|
179
|
+
const reason = tooFew('paired case', 'paired cases', n);
|
|
180
|
+
return {
|
|
181
|
+
method,
|
|
182
|
+
mean: { computed: false, estimate: meanEstimate, reason },
|
|
183
|
+
passRate: { computed: false, estimate: rateEstimate, reason },
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const result = bootstrap(n, checked, (draw) => difference(draw));
|
|
187
|
+
return {
|
|
188
|
+
method,
|
|
189
|
+
mean: {
|
|
190
|
+
computed: true,
|
|
191
|
+
estimate: meanEstimate,
|
|
192
|
+
low: result.mean[0],
|
|
193
|
+
high: result.mean[1],
|
|
194
|
+
},
|
|
195
|
+
passRate: {
|
|
196
|
+
computed: true,
|
|
197
|
+
estimate: rateEstimate,
|
|
198
|
+
low: result.passRate[0],
|
|
199
|
+
high: result.passRate[1],
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Exact two-sided sign test on discordant pairs: under no difference each flip
|
|
205
|
+
* is equally likely to go either way, so the count going one way is
|
|
206
|
+
* Binomial(n, 1/2). Returns twice the smaller tail, capped at 1; with no flips
|
|
207
|
+
* at all the answer is 1.
|
|
208
|
+
*/
|
|
209
|
+
export function exactSignTestP(oneWay, otherWay) {
|
|
210
|
+
const n = oneWay + otherWay;
|
|
211
|
+
if (n === 0)
|
|
212
|
+
return 1;
|
|
213
|
+
const k = Math.min(oneWay, otherWay);
|
|
214
|
+
const logFactorial = new Float64Array(n + 1);
|
|
215
|
+
for (let i = 2; i <= n; i++)
|
|
216
|
+
logFactorial[i] = logFactorial[i - 1] + Math.log(i);
|
|
217
|
+
let tail = 0;
|
|
218
|
+
for (let i = 0; i <= k; i++) {
|
|
219
|
+
const logTerm = logFactorial[n] -
|
|
220
|
+
logFactorial[i] -
|
|
221
|
+
logFactorial[n - i] -
|
|
222
|
+
n * Math.LN2;
|
|
223
|
+
tail += Math.exp(logTerm);
|
|
224
|
+
}
|
|
225
|
+
return Math.min(1, 2 * tail);
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/eval/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC,oCAAoC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEvC,qFAAqF;AACrF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAElC,iDAAiD;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAA;AA2DlC;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IACpC,IAAI,GAAG,YAAY,CAAA;CAC5B;AAED,qFAAqF;AACrF,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC5C,OAAO,GAAG,YAAY,UAAU,IAAK,GAA0B,CAAC,IAAI,KAAK,YAAY,CAAA;AACtF,CAAC;AAED;;;GAGG;AACH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CAAC,CAAC,GAAI,YAAY,CAAC,CAAC,GAAG,CAAC,CAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC5F,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,MAAM,OAAO,GACX,YAAY,CAAC,CAAC,CAAY;YAC1B,YAAY,CAAC,CAAC,CAAY;YAC1B,YAAY,CAAC,CAAC,GAAG,CAAC,CAAY;YAC/B,CAAC,GAAG,IAAI,CAAC,GAAG,CAAA;QACb,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC1B,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;AAC7B,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type DifferenceIntervals } from './bootstrap.js';
|
|
2
|
+
import { type CaseRuns } from './report-stats.js';
|
|
3
|
+
/**
|
|
4
|
+
* Two eval reports, side by side, paired by suite and case id.
|
|
5
|
+
*
|
|
6
|
+
* Two pass rates a few points apart read as a difference, and at the size of
|
|
7
|
+
* a hand-built suite they are usually not one. The comparison pairs the cases
|
|
8
|
+
* both sides ran, takes the difference over those, and puts an interval on it
|
|
9
|
+
* by resampling the pairs. It says "no difference can be claimed at this
|
|
10
|
+
* size" whenever that interval includes zero, and it says what else differs
|
|
11
|
+
* between the two runs, because a difference that comes with a new model and
|
|
12
|
+
* a new harness version and a new effort cannot be credited to any of them.
|
|
13
|
+
*/
|
|
14
|
+
/** One suite of a loaded report file. */
|
|
15
|
+
export interface LoadedSuite {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly cases: readonly CaseRuns[];
|
|
18
|
+
readonly repeats: number;
|
|
19
|
+
/** Whatever the file said about how the suite ran; absent in an older file. */
|
|
20
|
+
readonly facts: Readonly<Record<string, unknown>> | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface LoadedReportFile {
|
|
23
|
+
readonly label: string;
|
|
24
|
+
readonly suites: readonly LoadedSuite[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read the JSON `namzu eval --out` writes. Tolerant of a file from an older
|
|
28
|
+
* version: only `suites[].suite` and each case's name, mean and status are
|
|
29
|
+
* required; repeats, splits and disclosure are read when they are there.
|
|
30
|
+
* Throws an Error whose message names what is wrong, for a person to read.
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadEvalReportFile(json: unknown, label: string): LoadedReportFile;
|
|
33
|
+
export type DisclosureDimension = 'harness' | 'suites' | 'model' | 'route' | 'effort' | 'repeats';
|
|
34
|
+
export interface DisclosureDifference {
|
|
35
|
+
readonly dimension: DisclosureDimension;
|
|
36
|
+
readonly key: string;
|
|
37
|
+
readonly a: string;
|
|
38
|
+
readonly b: string;
|
|
39
|
+
}
|
|
40
|
+
export interface DisclosureUnknown {
|
|
41
|
+
readonly dimension: DisclosureDimension;
|
|
42
|
+
readonly key: string;
|
|
43
|
+
/** Which side does not say; the other side's value is given. */
|
|
44
|
+
readonly missingIn: 'a' | 'b';
|
|
45
|
+
readonly value: string;
|
|
46
|
+
}
|
|
47
|
+
export interface DisclosureComparison {
|
|
48
|
+
readonly differences: readonly DisclosureDifference[];
|
|
49
|
+
/** Facts one side states and the other does not. */
|
|
50
|
+
readonly unknown: readonly DisclosureUnknown[];
|
|
51
|
+
/** Dimensions in which at least one stated fact differs, in a fixed order. */
|
|
52
|
+
readonly differingDimensions: readonly DisclosureDimension[];
|
|
53
|
+
/** Set when more than one dimension differs. */
|
|
54
|
+
readonly warning?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface CaseRef {
|
|
57
|
+
readonly suite: string;
|
|
58
|
+
readonly case: string;
|
|
59
|
+
}
|
|
60
|
+
export interface SideNumbers {
|
|
61
|
+
/** Over the paired cases only. */
|
|
62
|
+
readonly mean: number | null;
|
|
63
|
+
readonly passRate: number | null;
|
|
64
|
+
}
|
|
65
|
+
export interface Flips {
|
|
66
|
+
/** Cases that passed in every run on side B and not on side A. */
|
|
67
|
+
readonly onlyBPasses: number;
|
|
68
|
+
/** The reverse: passed in every run on side A and not on side B. */
|
|
69
|
+
readonly onlyAPasses: number;
|
|
70
|
+
readonly bothPass: number;
|
|
71
|
+
readonly bothFail: number;
|
|
72
|
+
/** Exact two-sided sign test on the two flip counts; 1 with no flips. */
|
|
73
|
+
readonly pValue: number;
|
|
74
|
+
readonly test: 'exact two-sided sign test on the cases that flipped';
|
|
75
|
+
}
|
|
76
|
+
export interface EvalComparison {
|
|
77
|
+
readonly seed: number;
|
|
78
|
+
readonly a: {
|
|
79
|
+
readonly label: string;
|
|
80
|
+
readonly cases: number;
|
|
81
|
+
};
|
|
82
|
+
readonly b: {
|
|
83
|
+
readonly label: string;
|
|
84
|
+
readonly cases: number;
|
|
85
|
+
};
|
|
86
|
+
readonly onlyInA: readonly CaseRef[];
|
|
87
|
+
readonly onlyInB: readonly CaseRef[];
|
|
88
|
+
/** Present on both sides but with no judged run on one of them. */
|
|
89
|
+
readonly notJudged: readonly CaseRef[];
|
|
90
|
+
readonly paired: number;
|
|
91
|
+
readonly sideA: SideNumbers;
|
|
92
|
+
readonly sideB: SideNumbers;
|
|
93
|
+
/** B minus A. */
|
|
94
|
+
readonly difference: DifferenceIntervals;
|
|
95
|
+
readonly flips: Flips;
|
|
96
|
+
readonly verdict: {
|
|
97
|
+
readonly claim: 'better' | 'worse' | 'none';
|
|
98
|
+
/** The one sentence. */
|
|
99
|
+
readonly sentence: string;
|
|
100
|
+
/** Why, in plain words. */
|
|
101
|
+
readonly detail: string;
|
|
102
|
+
};
|
|
103
|
+
readonly disclosure: DisclosureComparison;
|
|
104
|
+
}
|
|
105
|
+
export declare function compareEvalReports(a: LoadedReportFile, b: LoadedReportFile, options?: {
|
|
106
|
+
seed?: number;
|
|
107
|
+
}): EvalComparison;
|
|
108
|
+
export declare function formatEvalComparison(c: EvalComparison): string;
|
|
109
|
+
//# sourceMappingURL=compare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/eval/compare.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,mBAAmB,EAOxB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,KAAK,QAAQ,EAAoD,MAAM,mBAAmB,CAAA;AAGnG;;;;;;;;;;GAUG;AAEH,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAA;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAA;CAC7D;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAA;CACvC;AAMD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAoCjF;AAID,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;AAgFjG,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAA;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,SAAS,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