@hmharness/evaluation 0.23.26 → 0.23.28
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/dist/benchmark-layers.d.ts +41 -0
- package/dist/benchmark-layers.js +39 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/metrics.d.ts +69 -0
- package/dist/metrics.js +69 -0
- package/package.json +32 -32
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hmharness/evaluation - benchmark layer taxonomy (upgrade pack 04 section 1, P2)
|
|
3
|
+
*
|
|
4
|
+
* The pack's four physically separated dataset layers, each with a
|
|
5
|
+
* machine-enforced WRITER policy - the headline rule being: the hidden
|
|
6
|
+
* holdout is writable ONLY by the evaluator; the agent and the
|
|
7
|
+
* self-evolution loop can never write it (and can never READ it as a
|
|
8
|
+
* training feed). A rule that lives in a doc is a hope; a rule that lives
|
|
9
|
+
* in assertLayerWrite is a gate.
|
|
10
|
+
*
|
|
11
|
+
* internal - developer-visible, fast regression; evolution may train on it
|
|
12
|
+
* public - external public tasks; HMH MUST NOT MODIFY (read-only
|
|
13
|
+
* ingestion - not even 'developer' may write)
|
|
14
|
+
* real-user - desensitized real-user tasks; user-sourced ingestion
|
|
15
|
+
* hidden - evaluator-only writes, invisible to evolution/agent
|
|
16
|
+
*/
|
|
17
|
+
export type BenchmarkLayer = 'internal' | 'public' | 'real-user' | 'hidden';
|
|
18
|
+
/** who can appear as a writer */
|
|
19
|
+
export type LayerWriter = 'developer' | 'public-source' | 'user' | 'evaluator' | 'evolution' | 'agent';
|
|
20
|
+
export interface LayerPolicy {
|
|
21
|
+
layer: BenchmarkLayer;
|
|
22
|
+
/** the ONLY writers allowed - everyone else refuses */
|
|
23
|
+
writableBy: readonly LayerWriter[];
|
|
24
|
+
/** may self-evolution read tasks of this layer as a training feed */
|
|
25
|
+
visibleToEvolution: boolean;
|
|
26
|
+
description: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const LAYER_POLICIES: Record<BenchmarkLayer, LayerPolicy>;
|
|
29
|
+
/** The machine guard: a disallowed writer refuses WITH the policy stated. */
|
|
30
|
+
export declare function assertLayerWrite(layer: BenchmarkLayer, writer: LayerWriter): void;
|
|
31
|
+
export interface LayeredTask {
|
|
32
|
+
id: string;
|
|
33
|
+
layer: BenchmarkLayer;
|
|
34
|
+
}
|
|
35
|
+
export interface EvolutionFeedCheck {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
/** hidden task ids found in the feed - each one is a contamination */
|
|
38
|
+
violations: string[];
|
|
39
|
+
}
|
|
40
|
+
/** No hidden task may ever enter an evolution training feed. */
|
|
41
|
+
export declare function evolutionFeedOK(feed: LayeredTask[]): EvolutionFeedCheck;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const LAYER_POLICIES = {
|
|
2
|
+
internal: {
|
|
3
|
+
layer: 'internal',
|
|
4
|
+
writableBy: ['developer'],
|
|
5
|
+
visibleToEvolution: true,
|
|
6
|
+
description: 'developer-visible fast regression set',
|
|
7
|
+
},
|
|
8
|
+
public: {
|
|
9
|
+
layer: 'public',
|
|
10
|
+
// "HMH 不得修改": ingestion only - no hmh-side writer may mutate a public set
|
|
11
|
+
writableBy: ['public-source'],
|
|
12
|
+
visibleToEvolution: true,
|
|
13
|
+
description: 'external public tasks, ingested read-only',
|
|
14
|
+
},
|
|
15
|
+
'real-user': {
|
|
16
|
+
layer: 'real-user',
|
|
17
|
+
writableBy: ['user'],
|
|
18
|
+
visibleToEvolution: true,
|
|
19
|
+
description: 'desensitized real-user tasks',
|
|
20
|
+
},
|
|
21
|
+
hidden: {
|
|
22
|
+
layer: 'hidden',
|
|
23
|
+
writableBy: ['evaluator'],
|
|
24
|
+
visibleToEvolution: false,
|
|
25
|
+
description: 'hidden holdout - evaluator-only writes, invisible to evolution and agent',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
/** The machine guard: a disallowed writer refuses WITH the policy stated. */
|
|
29
|
+
export function assertLayerWrite(layer, writer) {
|
|
30
|
+
const policy = LAYER_POLICIES[layer];
|
|
31
|
+
if (!policy.writableBy.includes(writer)) {
|
|
32
|
+
throw new Error(`layer '${layer}' refuses writer '${writer}' - allowed writers: [${policy.writableBy.join(', ')}] (${policy.description})`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** No hidden task may ever enter an evolution training feed. */
|
|
36
|
+
export function evolutionFeedOK(feed) {
|
|
37
|
+
const violations = feed.filter((t) => LAYER_POLICIES[t.layer] && !LAYER_POLICIES[t.layer].visibleToEvolution).map((t) => t.id);
|
|
38
|
+
return { ok: violations.length === 0, violations };
|
|
39
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hmharness/evaluation - unified metric protocol (upgrade pack 04, core metrics)
|
|
3
|
+
*
|
|
4
|
+
* The pack's twelve core metrics as ONE report shape with ONE honesty
|
|
5
|
+
* rule: a metric whose input was not provided is undefined - never zero,
|
|
6
|
+
* never fabricated ("no safety violations recorded" and "we did not
|
|
7
|
+
* measure safety violations" are different claims; conflating them is how
|
|
8
|
+
* benchmark reports start lying).
|
|
9
|
+
*
|
|
10
|
+
* 1 successRate success count / tasks
|
|
11
|
+
* 2 taskCompletionTime mean completion ms
|
|
12
|
+
* 3 actionEfficiency effective actions / total actions
|
|
13
|
+
* 4 recoveryRate recovered failures / failures
|
|
14
|
+
* 5 predictionCalibration brier (lower better; ece reported alongside when given)
|
|
15
|
+
* 6 worldModelDeltaAccuracy given directly (WM 2.0 deltaAccuracy.accuracy)
|
|
16
|
+
* 7 cost total cost in USD
|
|
17
|
+
* 8 latency p50/p95/max of per-action latency ms
|
|
18
|
+
* 9 humanInterventionRate interventions / tasks
|
|
19
|
+
* 10 regressionRate (baseline - current) / baseline when baseline > 0
|
|
20
|
+
* 11 transferGain withTransfer - baseline (target env ONLY -
|
|
21
|
+
* the pack forbids reporting source-env numbers as transfer)
|
|
22
|
+
* 12 safetyViolationRate violations / tasks
|
|
23
|
+
*/
|
|
24
|
+
export interface RunMetricInput {
|
|
25
|
+
tasks?: number;
|
|
26
|
+
successes?: number;
|
|
27
|
+
completionsMs?: number[];
|
|
28
|
+
actions?: number;
|
|
29
|
+
effectiveActions?: number;
|
|
30
|
+
failures?: number;
|
|
31
|
+
recoveredFailures?: number;
|
|
32
|
+
brier?: number;
|
|
33
|
+
ece?: number;
|
|
34
|
+
deltaAccuracy?: number;
|
|
35
|
+
costUsd?: number;
|
|
36
|
+
actionLatenciesMs?: number[];
|
|
37
|
+
humanInterventions?: number;
|
|
38
|
+
/** baseline = the pre-change success count on the SAME task set */
|
|
39
|
+
regressionBaselineSuccesses?: number;
|
|
40
|
+
currentSuccesses?: number;
|
|
41
|
+
/** BOTH fields are target-environment numbers (never source-env) */
|
|
42
|
+
transferWithKnowledge?: number;
|
|
43
|
+
transferBaseline?: number;
|
|
44
|
+
safetyViolations?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface MetricReport {
|
|
47
|
+
successRate?: number;
|
|
48
|
+
taskCompletionTimeMs?: number;
|
|
49
|
+
actionEfficiency?: number;
|
|
50
|
+
recoveryRate?: number;
|
|
51
|
+
predictionCalibration?: {
|
|
52
|
+
brier: number;
|
|
53
|
+
ece?: number;
|
|
54
|
+
};
|
|
55
|
+
worldModelDeltaAccuracy?: number;
|
|
56
|
+
costUsd?: number;
|
|
57
|
+
latency?: {
|
|
58
|
+
p50Ms: number;
|
|
59
|
+
p95Ms: number;
|
|
60
|
+
maxMs: number;
|
|
61
|
+
};
|
|
62
|
+
humanInterventionRate?: number;
|
|
63
|
+
regressionRate?: number;
|
|
64
|
+
transferGain?: number;
|
|
65
|
+
safetyViolationRate?: number;
|
|
66
|
+
/** which metrics were absent (undefined by honesty, not by accident) */
|
|
67
|
+
unmeasured: string[];
|
|
68
|
+
}
|
|
69
|
+
export declare function computeMetrics(input: RunMetricInput): MetricReport;
|
package/dist/metrics.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const pct = (num, den) => den > 0 ? Number((num / den).toFixed(3)) : undefined;
|
|
2
|
+
function quantile(sorted, q) {
|
|
3
|
+
const idx = Math.min(sorted.length - 1, Math.max(0, Math.round(q * (sorted.length - 1))));
|
|
4
|
+
return sorted[idx];
|
|
5
|
+
}
|
|
6
|
+
export function computeMetrics(input) {
|
|
7
|
+
const report = { unmeasured: [] };
|
|
8
|
+
if (input.tasks !== undefined && input.tasks > 0) {
|
|
9
|
+
if (input.successes !== undefined)
|
|
10
|
+
report.successRate = pct(input.successes, input.tasks);
|
|
11
|
+
if (input.humanInterventions !== undefined)
|
|
12
|
+
report.humanInterventionRate = pct(input.humanInterventions, input.tasks);
|
|
13
|
+
if (input.safetyViolations !== undefined)
|
|
14
|
+
report.safetyViolationRate = pct(input.safetyViolations, input.tasks);
|
|
15
|
+
}
|
|
16
|
+
if (input.completionsMs?.length) {
|
|
17
|
+
report.taskCompletionTimeMs = Number((input.completionsMs.reduce((s, x) => s + x, 0) / input.completionsMs.length).toFixed(0));
|
|
18
|
+
}
|
|
19
|
+
if (input.actions !== undefined && input.actions > 0 && input.effectiveActions !== undefined) {
|
|
20
|
+
report.actionEfficiency = pct(input.effectiveActions, input.actions);
|
|
21
|
+
}
|
|
22
|
+
if (input.failures !== undefined && input.failures > 0 && input.recoveredFailures !== undefined) {
|
|
23
|
+
report.recoveryRate = pct(input.recoveredFailures, input.failures);
|
|
24
|
+
}
|
|
25
|
+
if (input.brier !== undefined) {
|
|
26
|
+
report.predictionCalibration = { brier: input.brier, ...(input.ece !== undefined ? { ece: input.ece } : {}) };
|
|
27
|
+
}
|
|
28
|
+
if (input.deltaAccuracy !== undefined)
|
|
29
|
+
report.worldModelDeltaAccuracy = input.deltaAccuracy;
|
|
30
|
+
if (input.costUsd !== undefined)
|
|
31
|
+
report.costUsd = Number(input.costUsd.toFixed(4));
|
|
32
|
+
if (input.actionLatenciesMs?.length) {
|
|
33
|
+
const sorted = [...input.actionLatenciesMs].sort((a, b) => a - b);
|
|
34
|
+
report.latency = {
|
|
35
|
+
p50Ms: quantile(sorted, 0.5),
|
|
36
|
+
p95Ms: quantile(sorted, 0.95),
|
|
37
|
+
maxMs: sorted[sorted.length - 1],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (input.regressionBaselineSuccesses !== undefined && input.currentSuccesses !== undefined) {
|
|
41
|
+
const base = input.regressionBaselineSuccesses;
|
|
42
|
+
// regression = the share of previously-passing outcomes lost; a baseline
|
|
43
|
+
// of 0 leaves it honestly undefined (division would fabricate infinity)
|
|
44
|
+
if (base > 0)
|
|
45
|
+
report.regressionRate = Number(((base - input.currentSuccesses) / base).toFixed(3));
|
|
46
|
+
}
|
|
47
|
+
if (input.transferWithKnowledge !== undefined && input.transferBaseline !== undefined) {
|
|
48
|
+
report.transferGain = Number((input.transferWithKnowledge - input.transferBaseline).toFixed(3));
|
|
49
|
+
}
|
|
50
|
+
const provided = new Set(Object.keys(report));
|
|
51
|
+
const all = [
|
|
52
|
+
['successRate', 'successRate'],
|
|
53
|
+
['taskCompletionTimeMs', 'taskCompletionTime'],
|
|
54
|
+
['actionEfficiency', 'actionEfficiency'],
|
|
55
|
+
['recoveryRate', 'recoveryRate'],
|
|
56
|
+
['predictionCalibration', 'predictionCalibration'],
|
|
57
|
+
['worldModelDeltaAccuracy', 'worldModelDeltaAccuracy'],
|
|
58
|
+
['costUsd', 'cost'],
|
|
59
|
+
['latency', 'latency'],
|
|
60
|
+
['humanInterventionRate', 'humanInterventionRate'],
|
|
61
|
+
['regressionRate', 'regressionRate'],
|
|
62
|
+
['transferGain', 'transferGain'],
|
|
63
|
+
['safetyViolationRate', 'safetyViolationRate'],
|
|
64
|
+
];
|
|
65
|
+
for (const [field, label] of all)
|
|
66
|
+
if (!provided.has(field))
|
|
67
|
+
report.unmeasured.push(label);
|
|
68
|
+
return report;
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hmharness/evaluation",
|
|
3
|
-
"version": "0.23.
|
|
4
|
-
"description": "hmharness evaluation: the Evaluator/Judge contract (V2 blueprint M2). Hard evidence outranks LLM judgment - build results, exit codes, exact/regex assertions first; the LLM judge is a last resort and is labeled as such. Evaluations attach to trajectories (judge.completed events).",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"default": "./dist/index.js"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"types": "dist/index.d.ts",
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc -p tsconfig.build.json"
|
|
16
|
-
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@hmharness/kernel": "0.23.
|
|
19
|
-
"@hmharness/observability": "0.23.
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "git+https://github.com/swsgbl/hmharness.git"
|
|
28
|
-
},
|
|
29
|
-
"engines": {
|
|
30
|
-
"node": ">=22"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@hmharness/evaluation",
|
|
3
|
+
"version": "0.23.28",
|
|
4
|
+
"description": "hmharness evaluation: the Evaluator/Judge contract (V2 blueprint M2). Hard evidence outranks LLM judgment - build results, exit codes, exact/regex assertions first; the LLM judge is a last resort and is labeled as such. Evaluations attach to trajectories (judge.completed events).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc -p tsconfig.build.json"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@hmharness/kernel": "0.23.28",
|
|
19
|
+
"@hmharness/observability": "0.23.28"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/swsgbl/hmharness.git"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=22"
|
|
31
|
+
}
|
|
32
|
+
}
|