@openpond/evals 0.4.2 → 0.6.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/CONTRACT.md +27 -1
- package/README.md +31 -2
- package/conformance/telemetry/v1/invalid-batch.json +17 -0
- package/conformance/telemetry/v1/valid-batch.json +58 -0
- package/dist/artifact-verification.js +172 -0
- package/dist/builtin-benchmarks/harness-refiner.js +469 -24
- package/dist/execution-contracts.js +153 -0
- package/dist/execution-receipts.js +185 -0
- package/dist/graders.js +8 -2
- package/dist/index.js +10 -0
- package/dist/learned-preference.js +334 -0
- package/dist/preferences.js +803 -0
- package/dist/rollouts.js +241 -0
- package/dist/tasksets.js +24 -0
- package/dist/telemetry/index.js +4 -0
- package/dist/telemetry-analysis.js +183 -0
- package/dist/telemetry-bundle.js +60 -0
- package/dist/telemetry-catalog.js +50 -0
- package/dist/telemetry.js +112 -0
- package/dist/types/artifact-verification.d.ts +31 -0
- package/dist/types/artifact-verification.d.ts.map +1 -0
- package/dist/types/builtin-benchmarks/harness-refiner.d.ts +22 -0
- package/dist/types/builtin-benchmarks/harness-refiner.d.ts.map +1 -1
- package/dist/types/conformance.d.ts +44 -0
- package/dist/types/conformance.d.ts.map +1 -1
- package/dist/types/evidence/conformance.d.ts +24 -24
- package/dist/types/evidence/contracts.d.ts +42 -42
- package/dist/types/execution-contracts.d.ts +806 -0
- package/dist/types/execution-contracts.d.ts.map +1 -0
- package/dist/types/execution-receipts.d.ts +55 -0
- package/dist/types/execution-receipts.d.ts.map +1 -0
- package/dist/types/graders.d.ts.map +1 -1
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/learned-preference.d.ts +282 -0
- package/dist/types/learned-preference.d.ts.map +1 -0
- package/dist/types/preferences.d.ts +583 -0
- package/dist/types/preferences.d.ts.map +1 -0
- package/dist/types/review-conformance.d.ts +20 -15
- package/dist/types/review-conformance.d.ts.map +1 -1
- package/dist/types/rollouts.d.ts +221 -0
- package/dist/types/rollouts.d.ts.map +1 -0
- package/dist/types/tasksets.d.ts +89 -0
- package/dist/types/tasksets.d.ts.map +1 -1
- package/dist/types/telemetry/index.d.ts +5 -0
- package/dist/types/telemetry/index.d.ts.map +1 -0
- package/dist/types/telemetry-analysis.d.ts +116 -0
- package/dist/types/telemetry-analysis.d.ts.map +1 -0
- package/dist/types/telemetry-bundle.d.ts +309 -0
- package/dist/types/telemetry-bundle.d.ts.map +1 -0
- package/dist/types/telemetry-catalog.d.ts +269 -0
- package/dist/types/telemetry-catalog.d.ts.map +1 -0
- package/dist/types/telemetry.d.ts +266 -0
- package/dist/types/telemetry.d.ts.map +1 -0
- package/package.json +20 -2
- package/schemas/telemetry/v1/evidence-completeness.schema.json +82 -0
- package/schemas/telemetry/v1/evidence-reference.schema.json +41 -0
- package/schemas/telemetry/v1/metric-definition.schema.json +96 -0
- package/schemas/telemetry/v1/metric-observation.schema.json +182 -0
- package/schemas/telemetry/v1/run-metric-summary.schema.json +98 -0
- package/schemas/telemetry/v1/run-telemetry-batch.schema.json +405 -0
- package/schemas/telemetry/v1/run-telemetry-event.schema.json +201 -0
- package/schemas/telemetry/v1/telemetry-cohort.schema.json +100 -0
- package/schemas/telemetry/v1/telemetry-export-bundle.schema.json +655 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ImmutableArtifactRefSchema, ImmutableAssetRefSchema, ImmutableReleaseRefSchema, MetadataSchema, ReleaseHashSchema, ReleaseIdSchema, ReleaseTimestampSchema, } from "@openpond/harness";
|
|
3
|
+
import { EnvironmentContractSchema, GraderSpecSchema } from "./tasksets.js";
|
|
4
|
+
export const ScoringStatusSchema = z.enum(["scored", "unscorable"]);
|
|
5
|
+
export const FailureOwnerSchema = z.enum([
|
|
6
|
+
"policy",
|
|
7
|
+
"environment",
|
|
8
|
+
"collector",
|
|
9
|
+
"verifier",
|
|
10
|
+
"provider",
|
|
11
|
+
"host",
|
|
12
|
+
"user",
|
|
13
|
+
"scheduler",
|
|
14
|
+
]);
|
|
15
|
+
export const AttemptOutcomeClassSchema = z.enum([
|
|
16
|
+
"completed",
|
|
17
|
+
"policy_failure",
|
|
18
|
+
"incomplete_output",
|
|
19
|
+
"task_deadline",
|
|
20
|
+
"environment_failure",
|
|
21
|
+
"collector_failure",
|
|
22
|
+
"verifier_failure",
|
|
23
|
+
"provider_failure",
|
|
24
|
+
"host_failure",
|
|
25
|
+
"infrastructure_timeout",
|
|
26
|
+
"cancelled",
|
|
27
|
+
]);
|
|
28
|
+
export const EnvironmentReleaseContentSchema = z.object({
|
|
29
|
+
schemaVersion: z.literal("openpond.environmentRelease.v1"),
|
|
30
|
+
id: ReleaseIdSchema,
|
|
31
|
+
revision: z.number().int().positive(),
|
|
32
|
+
contract: EnvironmentContractSchema,
|
|
33
|
+
actionSchemaRef: ImmutableAssetRefSchema.nullable(),
|
|
34
|
+
observationSchemaRef: ImmutableAssetRefSchema.nullable(),
|
|
35
|
+
stateSchemaRef: ImmutableAssetRefSchema.nullable(),
|
|
36
|
+
artifactCollection: z.object({
|
|
37
|
+
maxArtifacts: z.number().int().positive().max(100_000),
|
|
38
|
+
maxTotalBytes: z.number().int().positive().max(10_000_000_000),
|
|
39
|
+
}).strict(),
|
|
40
|
+
adapterConformanceHashes: z.record(ReleaseIdSchema, ReleaseHashSchema),
|
|
41
|
+
metadata: MetadataSchema,
|
|
42
|
+
}).strict();
|
|
43
|
+
export const EnvironmentReleaseSchema = EnvironmentReleaseContentSchema
|
|
44
|
+
.extend({ contentHash: ReleaseHashSchema })
|
|
45
|
+
.strict();
|
|
46
|
+
export const ArtifactCollectionStatusSchema = z.enum([
|
|
47
|
+
"collected",
|
|
48
|
+
"missing",
|
|
49
|
+
"skipped",
|
|
50
|
+
"failed",
|
|
51
|
+
]);
|
|
52
|
+
export const ArtifactValidationStatusSchema = z.enum([
|
|
53
|
+
"not_requested",
|
|
54
|
+
"passed",
|
|
55
|
+
"failed",
|
|
56
|
+
]);
|
|
57
|
+
export const ArtifactManifestEntrySchema = z.object({
|
|
58
|
+
requiredOutputPath: z.string().trim().min(1).max(2_000).nullable(),
|
|
59
|
+
collectedPath: z.string().trim().min(1).max(4_000).nullable(),
|
|
60
|
+
declaredMediaType: z.string().trim().min(1).max(200).nullable(),
|
|
61
|
+
detectedMediaType: z.string().trim().min(1).max(200).nullable(),
|
|
62
|
+
artifact: ImmutableArtifactRefSchema.nullable(),
|
|
63
|
+
status: ArtifactCollectionStatusSchema,
|
|
64
|
+
parseStatus: ArtifactValidationStatusSchema,
|
|
65
|
+
schemaStatus: ArtifactValidationStatusSchema,
|
|
66
|
+
errorCode: ReleaseIdSchema.nullable(),
|
|
67
|
+
failureOwner: FailureOwnerSchema.nullable(),
|
|
68
|
+
evidenceRefs: z.array(ImmutableArtifactRefSchema).max(10_000),
|
|
69
|
+
metadata: MetadataSchema,
|
|
70
|
+
}).strict();
|
|
71
|
+
export const ArtifactManifestContentSchema = z.object({
|
|
72
|
+
schemaVersion: z.literal("openpond.artifactManifest.v1"),
|
|
73
|
+
id: ReleaseIdSchema,
|
|
74
|
+
attemptRef: ImmutableReleaseRefSchema,
|
|
75
|
+
entries: z.array(ArtifactManifestEntrySchema).max(100_000),
|
|
76
|
+
createdAt: ReleaseTimestampSchema,
|
|
77
|
+
metadata: MetadataSchema,
|
|
78
|
+
}).strict();
|
|
79
|
+
export const ArtifactManifestSchema = ArtifactManifestContentSchema
|
|
80
|
+
.extend({ contentHash: ReleaseHashSchema })
|
|
81
|
+
.strict();
|
|
82
|
+
export const VerifierSetReleaseContentSchema = z.object({
|
|
83
|
+
schemaVersion: z.literal("openpond.verifierSetRelease.v1"),
|
|
84
|
+
id: ReleaseIdSchema,
|
|
85
|
+
revision: z.number().int().positive(),
|
|
86
|
+
graders: z.array(GraderSpecSchema).min(1).max(1_000),
|
|
87
|
+
isolation: z.object({
|
|
88
|
+
processBoundary: z.enum(["same_process", "isolated_process", "container"]),
|
|
89
|
+
networkPolicy: z.literal("none"),
|
|
90
|
+
defaultTimeoutMs: z.number().int().positive().max(300_000),
|
|
91
|
+
}).strict(),
|
|
92
|
+
calibrationReceiptRefs: z.array(ImmutableReleaseRefSchema).max(10_000),
|
|
93
|
+
metadata: MetadataSchema,
|
|
94
|
+
}).strict();
|
|
95
|
+
export const VerifierSetReleaseSchema = VerifierSetReleaseContentSchema
|
|
96
|
+
.extend({ contentHash: ReleaseHashSchema })
|
|
97
|
+
.strict();
|
|
98
|
+
export const RewardComponentReceiptSchema = z.object({
|
|
99
|
+
verifierId: ReleaseIdSchema,
|
|
100
|
+
verifierVersion: z.string().trim().min(1).max(100),
|
|
101
|
+
status: ScoringStatusSchema,
|
|
102
|
+
rawScore: z.number().finite().nullable(),
|
|
103
|
+
normalizedScore: z.number().min(0).max(1).nullable(),
|
|
104
|
+
weight: z.number().nonnegative().max(1_000),
|
|
105
|
+
passed: z.boolean(),
|
|
106
|
+
hardGate: z.boolean(),
|
|
107
|
+
rewardEligible: z.boolean(),
|
|
108
|
+
rewardContribution: z.number().min(0).max(1).nullable(),
|
|
109
|
+
failureOwner: FailureOwnerSchema.nullable(),
|
|
110
|
+
feedback: z.array(z.string().max(20_000)).max(1_000),
|
|
111
|
+
visibleEvidenceRefs: z.array(ImmutableArtifactRefSchema).max(10_000),
|
|
112
|
+
privilegedEvidenceRefs: z.array(ImmutableArtifactRefSchema).max(10_000),
|
|
113
|
+
metadata: MetadataSchema,
|
|
114
|
+
}).strict().superRefine((component, context) => {
|
|
115
|
+
if (component.status === "scored" && component.normalizedScore === null) {
|
|
116
|
+
context.addIssue({ code: "custom", message: "A scored component requires a normalized score.", path: ["normalizedScore"] });
|
|
117
|
+
}
|
|
118
|
+
if (component.status === "unscorable" && (component.normalizedScore !== null || component.rewardEligible)) {
|
|
119
|
+
context.addIssue({ code: "custom", message: "An unscorable component cannot contribute reward.", path: ["status"] });
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
const RewardReceiptBaseSchema = z.object({
|
|
123
|
+
schemaVersion: z.literal("openpond.rewardReceipt.v1"),
|
|
124
|
+
id: ReleaseIdSchema,
|
|
125
|
+
attemptRef: ImmutableReleaseRefSchema,
|
|
126
|
+
verifierSetRef: ImmutableReleaseRefSchema,
|
|
127
|
+
artifactManifestRef: ImmutableReleaseRefSchema,
|
|
128
|
+
status: ScoringStatusSchema,
|
|
129
|
+
reward: z.number().min(0).max(1).nullable(),
|
|
130
|
+
learningEligible: z.boolean(),
|
|
131
|
+
passed: z.boolean(),
|
|
132
|
+
outcomeClass: AttemptOutcomeClassSchema,
|
|
133
|
+
failureOwner: FailureOwnerSchema.nullable(),
|
|
134
|
+
components: z.array(RewardComponentReceiptSchema).min(1).max(10_000),
|
|
135
|
+
visibleEvidenceRefs: z.array(ImmutableArtifactRefSchema).max(100_000),
|
|
136
|
+
privilegedEvidenceRefs: z.array(ImmutableArtifactRefSchema).max(100_000),
|
|
137
|
+
supersedes: ImmutableReleaseRefSchema.nullable(),
|
|
138
|
+
createdAt: ReleaseTimestampSchema,
|
|
139
|
+
metadata: MetadataSchema,
|
|
140
|
+
}).strict();
|
|
141
|
+
function validateRewardReceipt(receipt, context) {
|
|
142
|
+
if (receipt.status === "scored" && (receipt.reward === null || !receipt.learningEligible)) {
|
|
143
|
+
context.addIssue({ code: "custom", message: "A scored receipt requires a reward and is learning-eligible.", path: ["status"] });
|
|
144
|
+
}
|
|
145
|
+
if (receipt.status === "unscorable" && (receipt.reward !== null || receipt.learningEligible)) {
|
|
146
|
+
context.addIssue({ code: "custom", message: "An unscorable receipt has null reward and is not learning-eligible.", path: ["status"] });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export const RewardReceiptContentSchema = RewardReceiptBaseSchema.superRefine(validateRewardReceipt);
|
|
150
|
+
export const RewardReceiptSchema = RewardReceiptBaseSchema
|
|
151
|
+
.extend({ contentHash: ReleaseHashSchema })
|
|
152
|
+
.strict()
|
|
153
|
+
.superRefine(validateRewardReceipt);
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { contentHash } from "@openpond/harness";
|
|
2
|
+
import { ArtifactManifestContentSchema, ArtifactManifestSchema, EnvironmentReleaseContentSchema, EnvironmentReleaseSchema, RewardComponentReceiptSchema, RewardReceiptContentSchema, RewardReceiptSchema, VerifierSetReleaseContentSchema, VerifierSetReleaseSchema, } from "./execution-contracts.js";
|
|
3
|
+
import { TasksetReleaseContentSchema, TasksetReleaseSchema, } from "./tasksets.js";
|
|
4
|
+
export function createEnvironmentRelease(input) {
|
|
5
|
+
const content = EnvironmentReleaseContentSchema.parse(input);
|
|
6
|
+
return EnvironmentReleaseSchema.parse({ ...content, contentHash: contentHash(content) });
|
|
7
|
+
}
|
|
8
|
+
export function createArtifactManifest(input) {
|
|
9
|
+
const content = ArtifactManifestContentSchema.parse(input);
|
|
10
|
+
return ArtifactManifestSchema.parse({ ...content, contentHash: contentHash(content) });
|
|
11
|
+
}
|
|
12
|
+
export function createVerifierSetRelease(input) {
|
|
13
|
+
const content = VerifierSetReleaseContentSchema.parse(input);
|
|
14
|
+
return VerifierSetReleaseSchema.parse({ ...content, contentHash: contentHash(content) });
|
|
15
|
+
}
|
|
16
|
+
export function bindTasksetExecutionReleases(input) {
|
|
17
|
+
verifyContentHash(input.environment, EnvironmentReleaseContentSchema, "Environment Release");
|
|
18
|
+
verifyContentHash(input.verifierSet, VerifierSetReleaseContentSchema, "Verifier Set Release");
|
|
19
|
+
if (contentHash(input.taskset.environment) !== contentHash(input.environment.contract)) {
|
|
20
|
+
throw new Error("Environment Release does not match the Taskset execution contract.");
|
|
21
|
+
}
|
|
22
|
+
if (contentHash(input.taskset.graders) !== contentHash(input.verifierSet.graders)) {
|
|
23
|
+
throw new Error("Verifier Set Release does not match the Taskset graders.");
|
|
24
|
+
}
|
|
25
|
+
const { contentHash: _previousHash, ...previousContent } = input.taskset;
|
|
26
|
+
const content = TasksetReleaseContentSchema.parse({
|
|
27
|
+
...previousContent,
|
|
28
|
+
environmentRelease: {
|
|
29
|
+
id: input.environment.id,
|
|
30
|
+
contentHash: input.environment.contentHash,
|
|
31
|
+
},
|
|
32
|
+
verifierSetRelease: {
|
|
33
|
+
id: input.verifierSet.id,
|
|
34
|
+
contentHash: input.verifierSet.contentHash,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return TasksetReleaseSchema.parse({ ...content, contentHash: contentHash(content) });
|
|
38
|
+
}
|
|
39
|
+
export function classifyAttemptOutcome(input) {
|
|
40
|
+
switch (input.failureClass) {
|
|
41
|
+
case null:
|
|
42
|
+
return { outcomeClass: "completed", failureOwner: null };
|
|
43
|
+
case "policy_failure":
|
|
44
|
+
return { outcomeClass: "policy_failure", failureOwner: "policy" };
|
|
45
|
+
case "environment_failure":
|
|
46
|
+
return { outcomeClass: "environment_failure", failureOwner: "environment" };
|
|
47
|
+
case "grader_failure":
|
|
48
|
+
return { outcomeClass: "verifier_failure", failureOwner: "verifier" };
|
|
49
|
+
case "infrastructure_failure":
|
|
50
|
+
return { outcomeClass: "host_failure", failureOwner: "host" };
|
|
51
|
+
case "cancelled":
|
|
52
|
+
return { outcomeClass: "cancelled", failureOwner: "user" };
|
|
53
|
+
case "timeout":
|
|
54
|
+
return input.timeoutKind === "task_deadline"
|
|
55
|
+
? { outcomeClass: "task_deadline", failureOwner: "policy" }
|
|
56
|
+
: { outcomeClass: "infrastructure_timeout", failureOwner: "host" };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function createRewardReceipt(input) {
|
|
60
|
+
verifyContentHash(input.verifierSet, VerifierSetReleaseContentSchema, "Verifier Set Release");
|
|
61
|
+
verifyContentHash(input.artifactManifest, ArtifactManifestContentSchema, "Artifact Manifest");
|
|
62
|
+
if (input.artifactManifest.attemptRef.id !== input.attemptRef.id
|
|
63
|
+
|| input.artifactManifest.attemptRef.contentHash !== input.attemptRef.contentHash) {
|
|
64
|
+
throw new Error("Artifact Manifest does not belong to the Reward Receipt Attempt.");
|
|
65
|
+
}
|
|
66
|
+
const outcomeScorable = isScorableOutcome(input.outcomeClass);
|
|
67
|
+
const components = input.components.map((raw) => {
|
|
68
|
+
const component = RewardComponentReceiptSchema.parse(raw);
|
|
69
|
+
const rewardEligible = outcomeScorable
|
|
70
|
+
&& component.status === "scored"
|
|
71
|
+
&& component.normalizedScore !== null
|
|
72
|
+
&& component.rewardEligible;
|
|
73
|
+
return RewardComponentReceiptSchema.parse({
|
|
74
|
+
...component,
|
|
75
|
+
rewardEligible,
|
|
76
|
+
rewardContribution: rewardEligible ? component.normalizedScore : null,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
const eligible = components.filter((component) => component.rewardEligible && component.normalizedScore !== null);
|
|
80
|
+
const status = eligible.length > 0 ? "scored" : "unscorable";
|
|
81
|
+
const hardGateFailed = eligible.some((component) => component.hardGate && !component.passed);
|
|
82
|
+
const totalWeight = eligible.reduce((total, component) => total + component.weight, 0);
|
|
83
|
+
const weightedReward = totalWeight > 0
|
|
84
|
+
? eligible.reduce((total, component) => total + component.normalizedScore * component.weight, 0) / totalWeight
|
|
85
|
+
: 0;
|
|
86
|
+
const reward = status === "scored" ? hardGateFailed ? 0 : weightedReward : null;
|
|
87
|
+
const passed = status === "scored" && eligible.every((component) => component.passed);
|
|
88
|
+
const content = RewardReceiptContentSchema.parse({
|
|
89
|
+
schemaVersion: "openpond.rewardReceipt.v1",
|
|
90
|
+
id: input.id,
|
|
91
|
+
attemptRef: input.attemptRef,
|
|
92
|
+
verifierSetRef: {
|
|
93
|
+
id: input.verifierSet.id,
|
|
94
|
+
contentHash: input.verifierSet.contentHash,
|
|
95
|
+
},
|
|
96
|
+
artifactManifestRef: {
|
|
97
|
+
id: input.artifactManifest.id,
|
|
98
|
+
contentHash: input.artifactManifest.contentHash,
|
|
99
|
+
},
|
|
100
|
+
status,
|
|
101
|
+
reward,
|
|
102
|
+
learningEligible: status === "scored",
|
|
103
|
+
passed,
|
|
104
|
+
outcomeClass: input.outcomeClass,
|
|
105
|
+
failureOwner: input.failureOwner,
|
|
106
|
+
components,
|
|
107
|
+
visibleEvidenceRefs: uniqueArtifactRefs([
|
|
108
|
+
...(input.visibleEvidenceRefs ?? []),
|
|
109
|
+
...components.flatMap((component) => component.visibleEvidenceRefs),
|
|
110
|
+
]),
|
|
111
|
+
privilegedEvidenceRefs: uniqueArtifactRefs([
|
|
112
|
+
...(input.privilegedEvidenceRefs ?? []),
|
|
113
|
+
...components.flatMap((component) => component.privilegedEvidenceRefs),
|
|
114
|
+
]),
|
|
115
|
+
supersedes: input.supersedes ?? null,
|
|
116
|
+
createdAt: input.createdAt,
|
|
117
|
+
metadata: input.metadata ?? {},
|
|
118
|
+
});
|
|
119
|
+
return RewardReceiptSchema.parse({ ...content, contentHash: contentHash(content) });
|
|
120
|
+
}
|
|
121
|
+
export function regradeRewardReceipt(input) {
|
|
122
|
+
if (!verifyRewardReceipt(input.original)) {
|
|
123
|
+
throw new Error("Cannot regrade an invalid Reward Receipt.");
|
|
124
|
+
}
|
|
125
|
+
return createRewardReceipt({
|
|
126
|
+
id: input.id,
|
|
127
|
+
attemptRef: input.original.attemptRef,
|
|
128
|
+
verifierSet: input.verifierSet,
|
|
129
|
+
artifactManifest: input.artifactManifest,
|
|
130
|
+
outcomeClass: input.outcomeClass ?? input.original.outcomeClass,
|
|
131
|
+
failureOwner: input.failureOwner === undefined
|
|
132
|
+
? input.original.failureOwner
|
|
133
|
+
: input.failureOwner,
|
|
134
|
+
components: input.components,
|
|
135
|
+
supersedes: {
|
|
136
|
+
id: input.original.id,
|
|
137
|
+
contentHash: input.original.contentHash,
|
|
138
|
+
},
|
|
139
|
+
createdAt: input.createdAt,
|
|
140
|
+
metadata: {
|
|
141
|
+
...input.metadata,
|
|
142
|
+
regradeOf: input.original.id,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
export function verifyEnvironmentRelease(release) {
|
|
147
|
+
return hasValidContentHash(release, EnvironmentReleaseContentSchema);
|
|
148
|
+
}
|
|
149
|
+
export function verifyArtifactManifest(manifest) {
|
|
150
|
+
return hasValidContentHash(manifest, ArtifactManifestContentSchema);
|
|
151
|
+
}
|
|
152
|
+
export function verifyVerifierSetRelease(release) {
|
|
153
|
+
return hasValidContentHash(release, VerifierSetReleaseContentSchema);
|
|
154
|
+
}
|
|
155
|
+
export function verifyRewardReceipt(receipt) {
|
|
156
|
+
const parsed = RewardReceiptSchema.safeParse(receipt);
|
|
157
|
+
if (!parsed.success)
|
|
158
|
+
return false;
|
|
159
|
+
const { contentHash: actual, ...content } = parsed.data;
|
|
160
|
+
return contentHash(RewardReceiptContentSchema.parse(content)) === actual;
|
|
161
|
+
}
|
|
162
|
+
export function isScorableOutcome(outcome) {
|
|
163
|
+
return outcome === "completed"
|
|
164
|
+
|| outcome === "policy_failure"
|
|
165
|
+
|| outcome === "incomplete_output"
|
|
166
|
+
|| outcome === "task_deadline";
|
|
167
|
+
}
|
|
168
|
+
function uniqueArtifactRefs(refs) {
|
|
169
|
+
return [...new Map(refs.map((ref) => [`${ref.id}:${ref.contentHash}`, ref])).values()];
|
|
170
|
+
}
|
|
171
|
+
function verifyContentHash(value, schema, label) {
|
|
172
|
+
const { contentHash: actual, ...content } = value;
|
|
173
|
+
const expected = contentHash(schema.parse(content));
|
|
174
|
+
if (actual !== expected)
|
|
175
|
+
throw new Error(`${label} content hash mismatch.`);
|
|
176
|
+
}
|
|
177
|
+
function hasValidContentHash(value, schema) {
|
|
178
|
+
try {
|
|
179
|
+
verifyContentHash(value, schema, "Receipt");
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
package/dist/graders.js
CHANGED
|
@@ -68,7 +68,7 @@ function gradeDeterministic(grader, task, attempt) {
|
|
|
68
68
|
return {
|
|
69
69
|
score: passed ? 1 : 0,
|
|
70
70
|
passed,
|
|
71
|
-
rewardEligible: grader.rewardEligible
|
|
71
|
+
rewardEligible: grader.rewardEligible,
|
|
72
72
|
failureClass: passed ? null : "policy_failure",
|
|
73
73
|
feedback: [passed ? "Deterministic grader passed." : "Deterministic grader failed."],
|
|
74
74
|
visibleEvidenceRefs: [...attempt.runtimeEventRefs, ...attempt.artifactRefs],
|
|
@@ -76,7 +76,13 @@ function gradeDeterministic(grader, task, attempt) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
function evidence(grader, result) {
|
|
79
|
-
const content = GraderEvidenceContentSchema.parse({
|
|
79
|
+
const content = GraderEvidenceContentSchema.parse({
|
|
80
|
+
schemaVersion: "openpond.graderEvidence.v1",
|
|
81
|
+
graderId: grader.id,
|
|
82
|
+
graderVersion: grader.version,
|
|
83
|
+
...result,
|
|
84
|
+
rewardEligible: grader.rewardEligible && result.score !== null,
|
|
85
|
+
});
|
|
80
86
|
return GraderEvidenceSchema.parse({ ...content, contentHash: contentHash(content) });
|
|
81
87
|
}
|
|
82
88
|
function unavailable(message) {
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
export * from "./compatibility.js";
|
|
2
2
|
export * from "./benchmarks.js";
|
|
3
|
+
export * from "./artifact-verification.js";
|
|
3
4
|
export * from "./evidence/index.js";
|
|
5
|
+
export * from "./execution-contracts.js";
|
|
6
|
+
export * from "./execution-receipts.js";
|
|
4
7
|
export * from "./graders.js";
|
|
5
8
|
export * from "./harness.js";
|
|
9
|
+
export * from "./learned-preference.js";
|
|
6
10
|
export * from "./runs.js";
|
|
7
11
|
export * from "./model-improvement-qualification.js";
|
|
12
|
+
export * from "./preferences.js";
|
|
8
13
|
export * from "./review-conformance.js";
|
|
14
|
+
export * from "./rollouts.js";
|
|
15
|
+
export * from "./telemetry.js";
|
|
16
|
+
export * from "./telemetry-catalog.js";
|
|
17
|
+
export * from "./telemetry-analysis.js";
|
|
18
|
+
export * from "./telemetry-bundle.js";
|
|
9
19
|
export * from "./tasksets.js";
|